-/*
-The new tracelog..
- // Traceformat:
- // 32 bits timestamp (little endian)
- // 16 bits duration (little endian)
- // 16 bits data length (little endian, Highest Bit used as readerToTag flag)
- // y Bytes data
- // x Bytes parity (one byte per 8 bytes data)
+// Starts Clock and waits until its reset
+static void Reset(AT91PS_TC clock){
+ clock->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
+ while(clock->TC_CV > 1) ;
+}
+
+// Starts Clock and waits until its reset
+static void ResetClock(void){
+ Reset(timer);
+}
+
+static void frame_append_bit(struct legic_frame * const f, int bit) {
+ // Overflow, won't happen
+ if (f->bits >= 31) return;
+
+ f->data |= (bit << f->bits);
+ f->bits++;
+}
+
+static void frame_clean(struct legic_frame * const f) {
+ f->data = 0;
+ f->bits = 0;
+}
+
+// Prng works when waiting in 99.1us cycles.
+// and while sending/receiving in bit frames (100, 60)
+/*static void CalibratePrng( uint32_t time){
+ // Calculate Cycles based on timer 100us
+ uint32_t i = (time - stop_send_frame_us) / 100 ;
+
+ // substract cycles of finished frames
+ int k = i - legic_prng_count()+1;
+
+ // substract current frame length, rewind to beginning
+ if ( k > 0 )
+ legic_prng_forward(k);
+}