openpcd/openpicc/application/ssc_buffer.h @ master
1 | ad5b96d5 | henryk | #ifndef SSC_BUFFER_H_
|
---|---|---|---|
2 | #define SSC_BUFFER_H_
|
||
3 | |||
4 | d3bab6e9 | henryk | #include "iso14443.h"
|
5 | |||
6 | ad5b96d5 | henryk | #define SSC_RX_BUFFER_SIZE_AS_UINT8 2048
|
7 | c319d646 | henryk | #define SSC_DMA_BUFFER_COUNT 0
|
8 | ad5b96d5 | henryk | |
9 | d3bab6e9 | henryk | /* in bytes, used for the sample buffer that holds the subcarrier modulation data at fc/8 = 1695 MHz */
|
10 | #define SSC_TX_BUFFER_SIZE_AS_UINT8 ((MAXIMUM_FRAME_SIZE*( (8+1)*2 ) ) + 2 + 2)
|
||
11 | |||
12 | ad5b96d5 | henryk | #if SSC_RX_BUFFER_SIZE_AS_UINT8 < DIV_ROUND_UP((ISO14443A_MAX_RX_FRAME_SIZE_IN_BITS*ISO14443A_SAMPLE_LEN),8)
|
13 | #undef SSC_RX_BUFFER_SIZE_AS_UINT8
|
||
14 | #define SSC_RX_BUFFER_SIZE_AS_UINT8 DIV_ROUND_UP((ISO14443A_MAX_RX_FRAME_SIZE_IN_BITS*ISO14443A_SAMPLE_LEN),8)
|
||
15 | #endif
|
||
16 | |||
17 | typedef enum { |
||
18 | e2e37bea | henryk | SSC_FREE=0, /* Buffer is free */ |
19 | SSC_PENDING, /* Buffer has been given to the DMA controller and is currently being filled */ |
||
20 | SSC_FULL, /* DMA controller signalled that the buffer is full */ |
||
21 | SSC_PROCESSING,/* The buffer is currently processed by the consumer (e.g. decoder) */ |
||
22 | SSC_PREFILLED, /* The buffer has been prefilled for later usage (only used for TX) */ |
||
23 | ad5b96d5 | henryk | } ssc_dma_buffer_state_t; |
24 | |||
25 | enum ssc_mode { |
||
26 | SSC_MODE_NONE, |
||
27 | SSC_MODE_14443A, |
||
28 | };
|
||
29 | |||
30 | typedef struct { |
||
31 | enum ssc_mode mode; |
||
32 | u_int16_t transfersize_ssc; |
||
33 | u_int16_t transfersize_pdc; |
||
34 | u_int16_t transfers; |
||
35 | } ssc_mode_def; |
||
36 | |||
37 | typedef struct { |
||
38 | volatile ssc_dma_buffer_state_t state; |
||
39 | u_int32_t len_transfers; /* Length of the content, in transfers */ |
||
40 | struct { |
||
41 | int overflow:1; |
||
42 | } flags; |
||
43 | const ssc_mode_def *reception_mode; /* Pointer to the SSC mode definition that the buffer has been loaded for (affects element size and count) */ |
||
44 | u_int8_t data[SSC_RX_BUFFER_SIZE_AS_UINT8]; |
||
45 | } ssc_dma_rx_buffer_t; |
||
46 | |||
47 | typedef struct { |
||
48 | d3bab6e9 | henryk | volatile ssc_dma_buffer_state_t state; |
49 | u_int32_t len; /* Length of the content in bytes */ |
||
50 | void *source; /* Source pointer for a prefilled buffer; set to NULL if not used */ |
||
51 | u_int8_t data[SSC_TX_BUFFER_SIZE_AS_UINT8]; |
||
52 | ad5b96d5 | henryk | } ssc_dma_tx_buffer_t; |
53 | |||
54 | #endif /*SSC_BUFFER_H_*/ |