summaryrefslogtreecommitdiff
path: root/openpicc/application/iso14443_layer3a.c
diff options
context:
space:
mode:
authorhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2007-11-26 06:20:17 +0000
committerhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2007-11-26 06:20:17 +0000
commit16d42d5f6b8df076a04a18ffd13d0defc999c7bf (patch)
tree5ea288cc5c509bdc549690877a68bb03679cb447 /openpicc/application/iso14443_layer3a.c
parent29ea5bbf5b9c3b3679aa40e4ee7029284cb424c6 (diff)
Prepare transmission code
Restructure/add some buffer code Reset the watchdog timer (now at 1.5s), add a watchdog pinger thread git-svn-id: https://svn.openpcd.org:2342/trunk@352 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'openpicc/application/iso14443_layer3a.c')
-rw-r--r--openpicc/application/iso14443_layer3a.c55
1 files changed, 52 insertions, 3 deletions
diff --git a/openpicc/application/iso14443_layer3a.c b/openpicc/application/iso14443_layer3a.c
index 841ad14..2239655 100644
--- a/openpicc/application/iso14443_layer3a.c
+++ b/openpicc/application/iso14443_layer3a.c
@@ -34,20 +34,34 @@
#include "tc_cdiv_sync.h"
#include "usb_print.h"
#include "cmd.h"
+#include "load_modulation.h"
+#include "decoder.h"
+#include "iso14443a_manchester.h"
+#include "led.h"
static enum ISO14443_STATES state = STARTING_UP;
+const iso14443_frame ATQA_FRAME = {
+ TYPE_A,
+ {{STANDARD_FRAME, NO_PARITY}},
+ 2,
+ 0, 0,
+ {4, 0},
+ {}
+};
+
+
#define PLL_LOCK_HYSTERESIS portTICK_RATE_MS*5
#define LAYER3_DEBUG usb_print_string
-extern void main_help_print_buffer(ssc_dma_buffer_t *buffer, int *pktcount);
+extern void main_help_print_buffer(ssc_dma_rx_buffer_t *buffer, int *pktcount);
void iso14443_layer3a_state_machine (void *pvParameters)
{
unsigned long int last_pll_lock = ~0;
int pktcount=0;
(void)pvParameters;
while(1) {
- ssc_dma_buffer_t* buffer = NULL;
+ ssc_dma_rx_buffer_t* buffer = NULL;
portBASE_TYPE need_receive = 0, switch_on = 0;
/* First let's see whether there is a reader */
@@ -97,7 +111,7 @@ void iso14443_layer3a_state_machine (void *pvParameters)
tc_cdiv_set_divider(64);
#endif
tc_fdt_init();
-#if 0
+#if 1
ssc_tx_init();
#else
AT91F_PIO_CfgInput(AT91C_BASE_PIOA, OPENPICC_MOD_PWM);
@@ -107,6 +121,10 @@ void iso14443_layer3a_state_machine (void *pvParameters)
#endif
ssc_rx_init();
+ load_mod_init();
+ load_mod_level(3);
+
+
state = POWERED_OFF;
break;
case POWERED_OFF:
@@ -127,6 +145,7 @@ void iso14443_layer3a_state_machine (void *pvParameters)
if(need_receive) {
if(xQueueReceive(ssc_rx_queue, &buffer, portTICK_RATE_MS)) {
+ vLedSetGreen(0);
portENTER_CRITICAL();
buffer->state = PROCESSING;
portEXIT_CRITICAL();
@@ -145,6 +164,36 @@ void iso14443_layer3a_state_machine (void *pvParameters)
LAYER3_DEBUG("Received ");
LAYER3_DEBUG(first_sample == WUPA ? "WUPA" : "REQA");
LAYER3_DEBUG(" waking up to send ATQA\n\r");
+ portENTER_CRITICAL();
+ if(ssc_tx_buffer.state != FREE) {
+ portEXIT_CRITICAL();
+ /* Wait for another frame */
+ ssc_rx_mode_set(SSC_MODE_14443A_SHORT);
+ ssc_rx_start();
+ } else {
+ ssc_tx_buffer.state = PROCESSING;
+ portEXIT_CRITICAL();
+ ssc_tx_buffer.len = sizeof(ssc_tx_buffer.data);
+ unsigned int ret =
+ manchester_encode(ssc_tx_buffer.data,
+ ssc_tx_buffer.len,
+ &ATQA_FRAME);
+ if(ret>0) {
+ ssc_tx_buffer.len = ret;
+ LAYER3_DEBUG("Buffer ");
+ DumpUIntToUSB(ret);
+ LAYER3_DEBUG(" ");
+ DumpBufferToUSB((char*)ssc_tx_buffer.data, ssc_tx_buffer.len);
+ LAYER3_DEBUG("\n\r");
+ } else {
+ portENTER_CRITICAL();
+ ssc_tx_buffer.state = FREE;
+ portEXIT_CRITICAL();
+ /* Wait for another frame */
+ ssc_rx_mode_set(SSC_MODE_14443A_SHORT);
+ ssc_rx_start();
+ }
+ }
} else {
/* Wait for another frame */
ssc_rx_mode_set(SSC_MODE_14443A_SHORT);
personal git repositories of Harald Welte. Your mileage may vary