Project

General

Profile

Download (3.99 KB) Statistics
| Branch: | Tag: | Revision:
1
#ifndef ISO14443_LAYER2A_H_
2
#define ISO14443_LAYER2A_H_
3

    
4
#include "ssc_buffer.h"
5

    
6
/* Callback type for iso14443_receive().
7
 * Parameter buffer is either being passed a pointer to an SSC Rx buffer structure that this 
8
 * receive happened on, or a fully decoded iso14443_frame. 
9
 * If it's an SSC buffer you might want to pass this into iso14443a_decode_miller().
10
 * Parameter in_irq is true if the callback has been called while still in IRQ mode. It must then *NOT*
11
 * perform any calls that might upset the IRQ processing. Especially it may not call into FreeRTOS or
12
 * any parts of the applications that do.
13
 */
14
typedef void (*iso14443_receive_callback_t)(ssc_dma_rx_buffer_t *buffer, iso14443_frame *frame, u_int8_t in_irq);
15

    
16
/* Wait for and receive a frame. Parameters callback and buffer are optional. If you omit them you'll lose
17
 * the received frame, obviously.
18
 * Parameter callback is a callback function that will be called for each received frame and might
19
 * then trigger a response.
20
 * Parameter frame is an output pointer to a pointer to an ISO14443 frame structure containing the
21
 * received frame.
22
 * Parameter timeout gives an optional timeout for the receive operation after which the receive will
23
 * be aborted. When timeout is 0 the receive will not time out.
24
 * This call will block until a frame is received or an exception happens. Obviously it must not be run
25
 * from IRQ context.
26
 * 
27
 * Warning: When you get a frame from the function then its state is set to SSC_PROCESSING and you must 
28
 * SSC_FREE it yourself. However, you MUST NOT free a buffer or a frame from the callback.
29
 * 
30
 * Return values:
31
 * = 0         Frame received
32
 * -ENETDOWN   PLL is not locked or PLL lock lost
33
 * -ETIMEDOUT  Receive timed out without receiving anything (usually not regarded an error condition)
34
 * -EBUSY      A Tx is currently running or pending; can't receive
35
 * -EALREADY   There's already an iso14443_receive() invocation running
36
 */
37
extern int iso14443_receive(iso14443_receive_callback_t callback, iso14443_frame **frame, unsigned int timeout);
38

    
39
/*
40
 * Transmit a frame. Starts transmitting fdt carrier cycles after the end of the received frame.
41
 * Parameters buffer and fdt specify the SSC Tx buffer to be sent and the frame delay time in carrier cycles.
42
 * When parameter async is set then this call will only schedule the buffer for sending and return immediately,
43
 * otherwise the call will block until the buffer has been sent completely, until the specified timeout is reached
44
 * or an error occurs.
45
 * This function may be run from IRQ context, especially from within the iso14443_receive callback, with the async
46
 * parameter set.
47
 * 
48
 * Note: When your callback calls iso14443_transmit() from IRQ context it must set the async parameter to have transmit
49
 * return immediately and then not block within the callback. When the scheduled transmission has not happened by the next
50
 * time you call iso14443_receive() it will abort with -EBUSY and you can then either decide to wait for the transmission
51
 * to go through, or abort the scheduled transmission with iso14443_tx_abort(). You can check for whether a Tx is currently
52
 * pending or running with iso14443_tx_busy().
53
 */
54
extern int iso14443_transmit(ssc_dma_tx_buffer_t *buffer, unsigned int fdt, u_int8_t async, unsigned int timeout);
55

    
56
extern int iso14443_tx_abort(void);
57
extern int iso14443_tx_busy(void);
58

    
59
/*
60
 * Wait for the presence of a reader to be detected.
61
 * Returns 0 when the PLL is locked.
62
 */
63
extern int iso14443_wait_for_carrier(unsigned int timeout);
64

    
65
/* Initialize the layer 2 transceiver code.
66
 * Parameter enable_fast_receive, when set, will enable special code to guarantee fast response times
67
 * for frames shorter than or equal to 56 data bits (bit oriented anticollision frame length). This
68
 * generally involves running the callback from an IRQ handler. 
69
 */
70
extern int iso14443_layer2a_init(u_int8_t enable_fast_receive);
71

    
72
extern u_int8_t iso14443_set_fast_receive(u_int8_t enable_fast_receive);
73
extern u_int8_t iso14443_get_fast_receive(void);
74

    
75
#endif /*ISO14443_LAYER2A_H_*/
(20-20/59)
Add picture from clipboard (Maximum size: 48.8 MB)