- if(div > 3) {
- smpl = decbyte;
- if(ManchesterDecoding(smpl & 0x0F)) {
- time_stop = (GetCountSspClk()-time_0) << 4;
-
- rsamples = samples - Demod.samples;
- LED_B_ON();
-
- uint8_t parity[MAX_PARITY_SIZE];
- GetParity(Demod.output, Demod.len, parity);
- LogTrace(Demod.output, Demod.len, time_start, time_stop, parity, false);
-
- // And ready to receive another response.
- memset(&Demod, 0, sizeof(Demod));
- Demod.output = tagToReaderResponse;
- Demod.state = DEMOD_UNSYNCD;
- LED_C_OFF();
- }else{
- time_start = (GetCountSspClk()-time_0) << 4;
+ LED_A_OFF();
+ smpl = upTo[0];
+ upTo++;
+ lastRxCounter -= 1;
+ if (upTo - dmaBuf > DMA_BUFFER_SIZE) {
+ upTo -= DMA_BUFFER_SIZE;
+ lastRxCounter += DMA_BUFFER_SIZE;
+ AT91C_BASE_PDC_SSC->PDC_RNPR = (uint32_t) upTo;
+ AT91C_BASE_PDC_SSC->PDC_RNCR = DMA_BUFFER_SIZE;
+ }
+
+ //samples += 4;
+ samples += 1;
+
+ if (smpl & 0xF) {
+ decbyte ^= (1 << (3 - div));
+ }
+
+ // FOR READER SIDE COMMUMICATION...
+
+ decbyter <<= 2;
+ decbyter ^= (smpl & 0x30);
+
+ div++;
+
+ if ((div + 1) % 2 == 0) {
+ smpl = decbyter;
+ if (OutOfNDecoding((smpl & 0xF0) >> 4)) {
+ rsamples = samples - Uart.samples;
+ time_stop = (GetCountSspClk()-time_0) << 4;
+ LED_C_ON();
+
+ //if (!LogTrace(Uart.output, Uart.byteCnt, rsamples, Uart.parityBits,true)) break;
+ //if (!LogTrace(NULL, 0, Uart.endTime*16 - DELAY_READER_AIR2ARM_AS_SNIFFER, 0, true)) break;
+ uint8_t parity[MAX_PARITY_SIZE];
+ GetParity(Uart.output, Uart.byteCnt, parity);
+ LogTrace(Uart.output, Uart.byteCnt, time_start, time_stop, parity, true);
+
+ /* And ready to receive another command. */
+ Uart.state = STATE_UNSYNCD;
+ /* And also reset the demod code, which might have been */
+ /* false-triggered by the commands from the reader. */
+ Demod.state = DEMOD_UNSYNCD;
+ LED_B_OFF();
+ Uart.byteCnt = 0;
+ } else {
+ time_start = (GetCountSspClk()-time_0) << 4;
+ }
+ decbyter = 0;
+ }
+
+ if (div > 3) {
+ smpl = decbyte;
+ if (ManchesterDecoding(smpl & 0x0F)) {
+ time_stop = (GetCountSspClk()-time_0) << 4;
+
+ rsamples = samples - Demod.samples;
+ LED_B_ON();
+
+ uint8_t parity[MAX_PARITY_SIZE];
+ GetParity(Demod.output, Demod.len, parity);
+ LogTrace(Demod.output, Demod.len, time_start, time_stop, parity, false);
+
+ // And ready to receive another response.
+ memset(&Demod, 0, sizeof(Demod));
+ Demod.output = tagToReaderResponse;
+ Demod.state = DEMOD_UNSYNCD;
+ LED_C_OFF();
+ } else {
+ time_start = (GetCountSspClk()-time_0) << 4;
+ }
+
+ div = 0;
+ decbyte = 0x00;