-static void frame_send_tag(uint16_t response, int bits, int crypt)
-{
- /* Bitbang the response */
- AT91C_BASE_PIOA->PIO_CODR = GPIO_SSC_DOUT;
- AT91C_BASE_PIOA->PIO_OER = GPIO_SSC_DOUT;
- AT91C_BASE_PIOA->PIO_PER = GPIO_SSC_DOUT;
-
- /* Use time to crypt frame */
- if(crypt) {
- legic_prng_forward(2); /* TAG_TIME_WAIT -> shift by 2 */
- int key = 0;
- for(int i = 0; i < bits; i++) {
- key |= legic_prng_get_bit() << i;
- legic_prng_forward(1);
- }
- response = response ^ key;
- }
-
- /* Wait for the frame start */
- //while(timer->TC_CV < (TAG_TIME_WAIT - 30)) ;
- WAIT( TAG_TIME_WAIT - 30)
-
- uint8_t bit = 0;
- for(int i = 0; i < bits; i++) {
- int nextbit = timer->TC_CV + TAG_TIME_BIT;
- bit = response & 1;
- response >>= 1;
-
- if (bit)
- AT91C_BASE_PIOA->PIO_SODR = GPIO_SSC_DOUT;
- else
- AT91C_BASE_PIOA->PIO_CODR = GPIO_SSC_DOUT;
-
- //while(timer->TC_CV < nextbit) ;
- WAIT(nextbit)
- }
- AT91C_BASE_PIOA->PIO_CODR = GPIO_SSC_DOUT;
-}
+static void frame_send_tag(uint16_t response, uint8_t bits, uint8_t crypt) {
+ /* Bitbang the response */
+ LOW(GPIO_SSC_DOUT);
+ AT91C_BASE_PIOA->PIO_OER = GPIO_SSC_DOUT;
+ AT91C_BASE_PIOA->PIO_PER = GPIO_SSC_DOUT;