Abstract Command-Response Card Object¶
Abstract Command-Response Card object.
This header defines an abstract interface used to communicate with an Integrated Circtuit Card (either with contacts or contactless) using request-response frames. Each frame is a request and should generate some response frame or a timeout. Example of such a card is ISO/IEC 14443 Proximity Integrated Circuit Card or ISO/IEC 7816 Integrated Circuit Card exchanging command-response pairs using T=0 or T=1 protocol.
For now only synchronous API is defined. Async API may be added later if needed.
Macro functions (Pcd)
Convenience macros for easy calling of ‘member functions’
-
crcardTransceive(inst, tx_buf_p, tx_buf_size, resp_size_p)¶
-
crcardGetResponseSize(inst)¶
-
crcardGetResponse(inst, buf_p, max_buf_size)¶
Enums
-
enum
crcard_result_t¶ Operation result codes.
Values:
-
CRCARD_OK¶ Transmission successful, received response
-
CRCARD_TX_ERROR¶ Unrecoverable transmission errror
-
CRCARD_RX_ERRPR¶ Unrecoverable reception error
-
CRCARD_TIMEOUT¶ Transmission successful, no response
-
CRCARD_NONEXISTENT¶ Card removed, no further comm possible
-
-
struct
CRCardVMT¶ - #include <hal_abstract_CRCard.h>
Abstract CRCard Virtual Method Table.
- Note
- use macros defined in this file to call these functions for convenience. Name of the macro is the same as a name of this function with
crcardprefix.
Public Members
-
crcard_result_t (*
transceive)(void *inst, uint8_t *tx_buffer, uint16_t tx_buffer_size, uint16_t *response_size)¶ Send a frame of data to a card and wait for a response.
The response will be stored in a response buffer. Invoking this function will clear contents of the response buffer, if any.
- Return
- Operation result
- Parameters
inst: Pointer to a CRCard structuretx_buffer: Data to sendtx_buffer_size: Number of bytes to sendresponse_size: Number of bytes received
-
uint16_t (*
getResponseSize)(void *inst)¶ Get number of remaining bytes in the response buffer.
- Return
- Number of bytes in the response buffer
- Parameters
inst: Pointer to a CRCard structure
-
uint16_t (*
getResponse)(void *inst, uint8_t *data, uint16_t buffer_size)¶ Retrieves a response from the response buffer.
Think of the response buffer as a queue. When this function is called no more than
buffer_sizebytes are removed from this queue and copied todatabuffer.Function getResponseSize returns number of bytes in this queue.
- Return
- Number of copied bytes
- Parameters
inst: Pointer to a CRCard structuredata: Buffer to copy the response tobuffer_size: Maximum number of bytes to copy
-
struct
CRCard¶ - #include <hal_abstract_CRCard.h>
Base Command-Response Card.
This class represents a generic Command-Response Card.