From 5bf2bacdc5f1526a300321ad487676bdc97991a4 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> Date: Sat, 9 Sep 2006 15:35:44 +0000 Subject: - cleanup of comments in TC/SSC PCD/PICC spearation - add first 'main_openpicc' TARGET for PICC git-svn-id: https://svn.openpcd.org:2342/trunk@154 6dc7ffe9-61d6-0310-9af1-9938baff3ed1 --- openpcd/firmware/Makefile | 5 ++- openpcd/firmware/src/os/tc_cdiv.h | 3 ++ openpcd/firmware/src/picc/main_openpicc.c | 66 +++++++++++++++++++++++++++++++ openpcd/firmware/src/picc/ssc_picc.c | 22 ++++++----- 4 files changed, 84 insertions(+), 12 deletions(-) create mode 100644 openpcd/firmware/src/picc/main_openpicc.c diff --git a/openpcd/firmware/Makefile b/openpcd/firmware/Makefile index 4d8f2a6..1098c4f 100644 --- a/openpcd/firmware/Makefile +++ b/openpcd/firmware/Makefile @@ -86,7 +86,8 @@ endif SRCARM += src/os/pcd_enumerate.c src/os/fifo.c src/os/dbgu.c \ src/os/led.c src/os/req_ctx.c src/os/trigger.c \ src/os/main.c src/os/syscalls.c src/os/usb_handler.c \ - src/os/usb_benchmark.c src/os/dfu.c src/start/Cstartup_SAM7.c + src/os/usb_benchmark.c src/os/dfu.c src/start/Cstartup_SAM7.c \ + src/os/tc_cdiv.c ifdef PCD # PCD support code @@ -96,7 +97,7 @@ SRCARM += src/pcd/rc632.c src/pcd/rc632_highlevel.c \ SRCARM += src/pcd/$(TARGET).c else # PICC support code -SRCARM += src/picc/tc.c src/picc/ssc.c +SRCARM += src/picc/tc_fdt.c src/picc/ssc_picc.c # finally, the actual main application SRCARM += src/picc/$(TARGET).c endif diff --git a/openpcd/firmware/src/os/tc_cdiv.h b/openpcd/firmware/src/os/tc_cdiv.h index 8b4031d..4f2bc02 100644 --- a/openpcd/firmware/src/os/tc_cdiv.h +++ b/openpcd/firmware/src/os/tc_cdiv.h @@ -2,6 +2,9 @@ #define _TC_CDIV_H #include +#include + +static AT91PS_TCB tcb; extern void tc_cdiv_phase_add(int16_t inc); extern void tc_cdiv_set_divider(u_int16_t div); diff --git a/openpcd/firmware/src/picc/main_openpicc.c b/openpcd/firmware/src/picc/main_openpicc.c new file mode 100644 index 0000000..795f460 --- /dev/null +++ b/openpcd/firmware/src/picc/main_openpicc.c @@ -0,0 +1,66 @@ +#include +#include +#include +#include +#include "ssc_picc.h" +#include +#include +#include +#include "../openpcd.h" +#include + +void _init_func(void) +{ + tc_cdiv_init(); + ssc_rx_init(); + // ssc_tx_init(); +} + +int _main_dbgu(char key) +{ + unsigned char value; + + switch (key) { + #if 0 + case '4': + AT91F_DBGU_Printk("Testing RC632 : "); + if (rc632_test(RAH) == 0) + AT91F_DBGU_Printk("SUCCESS!\n\r"); + else + AT91F_DBGU_Printk("ERROR!\n\r"); + + break; + case '5': + rc632_reg_read(RAH, RC632_REG_RX_WAIT, &value); + DEBUGPCR("Reading RC632 Reg RxWait: 0x%02xr", value); + + break; + case '6': + DEBUGPCR("Writing RC632 Reg RxWait: 0x55"); + rc632_reg_write(RAH, RC632_REG_RX_WAIT, 0x55); + break; + case '7': + rc632_dump(); + break; + case 'P': + rc632_power(1); + break; + case 'p': + rc632_power(0); + break; +#endif + } + + return -EINVAL; +} + +void _main_func(void) +{ + /* first we try to get rid of pending to-be-sent stuff */ + usb_out_process(); + + /* next we deal with incoming reqyests from USB EP1 (OUT) */ + usb_in_process(); + + ssc_rx_unthrottle(); +} diff --git a/openpcd/firmware/src/picc/ssc_picc.c b/openpcd/firmware/src/picc/ssc_picc.c index 0cd20cc..ac371b7 100644 --- a/openpcd/firmware/src/picc/ssc_picc.c +++ b/openpcd/firmware/src/picc/ssc_picc.c @@ -15,9 +15,9 @@ #include #include -#include "usb_handler.h" -#include "openpcd.h" -#include "dbgu.h" +#include +#include +#include "../openpcd.h" /* definitions for four-times oversampling */ #define REQA 0x10410441 @@ -27,9 +27,11 @@ static const AT91PS_SSC ssc = AT91C_BASE_SSC; static AT91PS_PDC rx_pdc; enum ssc_mode { + SSC_MODE_NONE, SSC_MODE_14443A_SHORT, SSC_MODE_14443A_STANDARD, SSC_MODE_14443B, + SSC_MODE_EDGE_ONE_SHOT, }; struct ssc_state { @@ -57,7 +59,6 @@ static void ssc_rx_mode_set(enum ssc_mode ssc_mode) AT91C_SSC_CP0 | AT91C_SSC_CP1); switch (ssc_mode) { -#ifdef CONFIG_PICCSIM case SSC_MODE_14443A_SHORT: start_cond = AT91C_SSC_START_0; sync_len = ISO14443A_SOF_LEN; @@ -76,7 +77,12 @@ static void ssc_rx_mode_set(enum ssc_mode ssc_mode) /* start sampling at first falling data edge */ //start_cond = break; -#endif /* CONFIG_PICCSIM */ + case SSC_MODE_EDGE_ONE_SHOT: + start_cond = AT91C_SSC_START_EDGE_RF; + sync_len = 0; + data_len = 8; + num_data = 50; + break; default: return; } @@ -107,7 +113,6 @@ static void ssc_tx_mode_set(enum ssc_mode ssc_mode) AT91C_SSC_TXBUFE | AT91C_SSC_TXSYN; switch (ssc_mode) { -#ifdef CONFIG_PICCSIM case SSC_MODE_14443A_SHORT: start_cond = AT91C_SSC_START_RISE_RF; sync_len = ISO14443A_SOF_LEN; @@ -121,7 +126,6 @@ static void ssc_tx_mode_set(enum ssc_mode ssc_mode) data_len = 1; num_data = 1; /* FIXME */ break; -#endif /* CONFIG_PICCSIM */ } ssc->SSC_TFMR = (data_len-1) & 0x1f | (((num_data-1) & 0x0f) << 8) | @@ -169,7 +173,7 @@ static char dmabuf2[512]; */ static int8_t ssc_rx_refill(void) { -#if 0 +#if 1 struct req_ctx *rctx; rctx = req_ctx_find_get(RCTX_STATE_FREE, RCTX_STATE_SSC_RX_BUSY); @@ -230,7 +234,6 @@ static void ssc_irq(void) DEBUGP("RX OVERRUN "); switch (ssc_state.mode) { -#ifdef CONFIG_PICCSIM case SSC_MODE_14443A_SHORT: if (ssc_sr & AT91C_SSC_RXSYN) DEBUGP("RXSYN "); @@ -274,7 +277,6 @@ static void ssc_irq(void) AT91C_SSC_OVRUN); } break; -#endif /* CONFIG_PICCSIM */ } } -- cgit v1.2.3