CryptoAuthLib
Atmel CryptoAuthentication Library
|
These methods define the hardware abstraction layer for communicating with a CryptoAuth device. More...
Data Structures | |
struct | ATCAHAL_t |
an intermediary data structure to allow the HAL layer to point the standard API functions used by the upper layers to the HAL implementation for the interface. This isolates the upper layers and loosely couples the ATCAIface object from the physical implementation. More... | |
struct | atcaI2Cmaster |
This is the hal_data for ATCA HAL. More... | |
struct | cdc_device |
struct | atcacdc |
struct | atcaSWImaster |
This is the hal_data for ATCA HAL. More... | |
struct | hid_device |
struct | atcahid |
Macros | |
#define | max(a, b) (((a) > (b)) ? (a) : (b)) |
#define | min(a, b) (((a) < (b)) ? (a) : (b)) |
#define | CDC_DEVICES_MAX 10 |
#define | CDC_BUFFER_MAX 1024 |
#define | INVALID_HANDLE_VALUE ((int)(-1)) |
#define | MAX_I2C_BUSES 2 |
#define | MAX_I2C_BUSES 6 |
#define | MAX_I2C_BUSES 6 |
#define | MAX_I2C_BUSES 3 |
#define | SWI_WAKE_TOKEN ((uint8_t)0x00) |
flag preceding a command More... | |
#define | SWI_FLAG_CMD ((uint8_t)0x77) |
flag preceding a command More... | |
#define | SWI_FLAG_TX ((uint8_t)0x88) |
flag requesting a response More... | |
#define | SWI_FLAG_IDLE ((uint8_t)0xBB) |
flag requesting to go into Idle mode More... | |
#define | SWI_FLAG_SLEEP ((uint8_t)0xCC) |
flag requesting to go into Sleep mode More... | |
#define | HID_GUID { 0x4d1e55b2, 0xf16f, 0x11cf, 0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 } |
#define | HID_DEVICES_MAX 10 |
#define | HID_PACKET_MAX 512 |
#define | MAX_I2C_BUSES 4 |
#define | KIT_TX_WRAP_SIZE (7) |
#define | KIT_MSG_SIZE (32) |
#define | KIT_RX_WRAP_SIZE (KIT_MSG_SIZE + 6) |
#define | MAX_SWI_BUSES 6 |
#define | RECEIVE_MODE 0 |
#define | TRANSMIT_MODE 1 |
#define | RX_DELAY { volatile uint8_t delay = 90; while (delay--) __asm__(""); } |
#define | TX_DELAY 90 |
#define | DEBUG_PIN_1 EXT2_PIN_5 |
#define | DEBUG_PIN_2 EXT2_PIN_6 |
#define | MAX_SWI_BUSES 6 |
#define | RECEIVE_MODE 0 |
#define | TRANSMIT_MODE 1 |
#define | RX_DELAY 10 |
#define | TX_DELAY 93 |
#define | MAX_SWI_BUSES 6 |
#define | RECEIVE_MODE 0 |
#define | TRANSMIT_MODE 1 |
#define | RX_DELAY 10 |
#define | TX_DELAY 90 |
Typedefs | |
typedef struct atcaI2Cmaster | ATCAI2CMaster_t |
This is the hal_data for ATCA HAL. More... | |
typedef int | HANDLE |
typedef struct cdc_device | cdc_device_t |
typedef struct atcacdc | atcacdc_t |
typedef struct atcaI2Cmaster | ATCAI2CMaster_t |
this is the hal_data for ATCA HAL More... | |
typedef struct atcaI2Cmaster | ATCAI2CMaster_t |
this is the hal_data for ATCA HAL for ASF SERCOM More... | |
typedef struct atcaI2Cmaster | ATCAI2CMaster_t |
this is the hal_data for ATCA HAL for Atmel START SERCOM More... | |
typedef struct atcaI2Cmaster | ATCAI2CMaster_t |
this is the hal_data for ATCA HAL for ASF SERCOM More... | |
typedef struct atcaSWImaster | ATCASWIMaster_t |
This is the hal_data for ATCA HAL. More... | |
typedef struct hid_device | hid_device_t |
typedef struct atcahid | atcahid_t |
typedef struct atcaI2Cmaster | ATCAI2CMaster_t |
this is the hal_data for ATCA HAL created using ASF More... | |
typedef struct atcaSWImaster | ATCASWIMaster_t |
this is the hal_data for ATCA HAL for ASF SERCOM More... | |
typedef struct atcaSWImaster | ATCASWIMaster_t |
this is the hal_data for ATCA HAL for ASF SERCOM More... | |
typedef struct atcaSWImaster | ATCASWIMaster_t |
this is the hal_data for ATCA HAL for SWI UART More... | |
Enumerations | |
enum | i2c_read_write_flag { I2C_WRITE = (uint8_t) 0x00, I2C_READ = (uint8_t) 0x01 } |
This enumeration lists flags for I2C read or write addressing. More... | |
enum | swi_flag { SWI_FLAG_CMD = (uint8_t) 0x77, SWI_FLAG_TX = (uint8_t) 0x88, SWI_FLAG_IDLE = (uint8_t) 0xBB, SWI_FLAG_SLEEP = (uint8_t) 0xCC } |
This enumeration lists flags for SWI. More... | |
Functions | |
ATCA_STATUS | hal_iface_init (ATCAIfaceCfg *, ATCAHAL_t *hal) |
Standard HAL API for ATCA to initialize a physical interface. More... | |
ATCA_STATUS | hal_iface_release (ATCAIfaceType, void *hal_data) |
releases a physical interface, HAL knows how to interpret hal_data More... | |
void | atca_delay_us (uint32_t delay) |
Timer API implemented at the HAL level. More... | |
void | atca_delay_10us (uint32_t delay) |
This function delays for a number of tens of microseconds. More... | |
void | atca_delay_ms (uint32_t delay) |
This function delays for a number of milliseconds. You can override this function if you like to do something else in your system while delaying. More... | |
ATCA_STATUS | hal_i2c_init (void *hal, ATCAIfaceCfg *cfg) |
hal_i2c_init manages requests to initialize a physical interface. It manages use counts so when an interface has released the physical layer, it will disable the interface for some other use. You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on multiple i2c buses, so hal_i2c_init manages these things and ATCAIFace is abstracted from the physical details. More... | |
ATCA_STATUS | hal_i2c_post_init (ATCAIface iface) |
HAL implementation of I2C post init. More... | |
ATCA_STATUS | hal_i2c_send (ATCAIface iface, uint8_t *txdata, int txlength) |
Send byte(s) via I2C. More... | |
ATCA_STATUS | hal_i2c_receive (ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength) |
Receive byte(s) via I2C. More... | |
ATCA_STATUS | hal_i2c_wake (ATCAIface iface) |
Send Wake flag via I2C. More... | |
ATCA_STATUS | hal_i2c_idle (ATCAIface iface) |
Send Idle flag via I2C. More... | |
ATCA_STATUS | hal_i2c_sleep (ATCAIface iface) |
Send Sleep flag via I2C. More... | |
ATCA_STATUS | hal_i2c_release (void *hal_data) |
Manages reference count on given bus and releases resource if no more reference(s) exist. More... | |
ATCA_STATUS | hal_cdc_discover_buses (int cdc_buses[], int max_buses) |
discover cdc buses available for this hardware this maintains a list of logical to physical bus mappings freeing the application of the a-priori knowledge More... | |
ATCA_STATUS | hal_cdc_discover_devices (int busNum, ATCAIfaceCfg cfg[], int *found) |
discover any CryptoAuth devices on a given logical bus number More... | |
ATCA_STATUS | hal_kit_cdc_init (void *hal, ATCAIfaceCfg *cfg) |
ATCA_STATUS | hal_kit_cdc_post_init (ATCAIface iface) |
HAL implementation of Kit USB CDC post init. More... | |
ATCA_STATUS | kit_phy_send (ATCAIface iface, uint8_t *txdata, int txlength) |
HAL implementation of send over USB CDC. More... | |
ATCA_STATUS | kit_phy_receive (ATCAIface iface, uint8_t *rxdata, int *rxsize) |
HAL implementation of kit protocol send over USB CDC. More... | |
ATCA_STATUS | hal_kit_phy_num_found (int8_t *num_found) |
Number of USB CDC devices found. More... | |
ATCA_STATUS | hal_kit_cdc_send (ATCAIface iface, uint8_t *txdata, int txlength) |
HAL implementation of kit protocol send over USB CDC. More... | |
ATCA_STATUS | hal_kit_cdc_receive (ATCAIface iface, uint8_t *rxdata, uint16_t *rxsize) |
HAL implementation of send over USB CDC. More... | |
ATCA_STATUS | hal_kit_cdc_wake (ATCAIface iface) |
Call the wake for kit protocol. More... | |
ATCA_STATUS | hal_kit_cdc_idle (ATCAIface iface) |
Call the idle for kit protocol. More... | |
ATCA_STATUS | hal_kit_cdc_sleep (ATCAIface iface) |
Call the sleep for kit protocol. More... | |
ATCA_STATUS | hal_kit_cdc_release (void *hal_data) |
Close the physical port for CDC. More... | |
ATCA_STATUS | hal_kit_cdc_discover_buses (int i2c_buses[], int max_buses) |
ATCA_STATUS | hal_kit_cdc_discover_devices (int busNum, ATCAIfaceCfg *cfg, int *found) |
ATCA_STATUS | hal_i2c_discover_buses (int i2c_buses[], int max_buses) |
This HAL implementation assumes you've included the ASF TWI libraries in your project, otherwise, the HAL layer will not compile because the ASF TWI drivers are a dependency. More... | |
ATCA_STATUS | hal_i2c_discover_devices (int busNum, ATCAIfaceCfg cfg[], int *found) |
discover any CryptoAuth devices on a given logical bus number More... | |
void | change_i2c_speed (ATCAIface iface, uint32_t speed) |
method to change the bus speed of I2C More... | |
ATCA_STATUS | hal_swi_init (void *hal, ATCAIfaceCfg *cfg) |
hal_swi_init manages requests to initialize a physical interface. It manages use counts so when an interface has released the physical layer, it will disable the interface for some other use. You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on multiple swi buses, so hal_swi_init manages these things and ATCAIFace is abstracted from the physical details. More... | |
ATCA_STATUS | hal_swi_post_init (ATCAIface iface) |
HAL implementation of SWI post init. More... | |
ATCA_STATUS | hal_swi_send (ATCAIface iface, uint8_t *txdata, int txlength) |
Send byte(s) via SWI. More... | |
ATCA_STATUS | hal_swi_receive (ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength) |
Receive byte(s) via SWI. More... | |
ATCA_STATUS | hal_swi_wake (ATCAIface iface) |
Send Wake flag via SWI. More... | |
ATCA_STATUS | hal_swi_idle (ATCAIface iface) |
Send Idle flag via SWI. More... | |
ATCA_STATUS | hal_swi_sleep (ATCAIface iface) |
Send Sleep flag via SWI. More... | |
ATCA_STATUS | hal_swi_release (void *hal_data) |
Manages reference count on given bus and releases resource if no more reference(s) exist. More... | |
ATCA_STATUS | hal_swi_discover_buses (int swi_buses[], int max_buses) |
discover swi buses available for this hardware this maintains a list of logical to physical bus mappings freeing the application of the a-priori knowledge More... | |
ATCA_STATUS | hal_swi_discover_devices (int busNum, ATCAIfaceCfg cfg[], int *found) |
discover any CryptoAuth devices on a given logical bus number More... | |
ATCA_STATUS | hal_swi_send_flag (ATCAIface iface, uint8_t data) |
HAL implementation of SWI send one byte over UART. More... | |
ATCA_STATUS | hal_kit_hid_init (void *hal, ATCAIfaceCfg *cfg) |
HAL implementation of Kit USB HID init. More... | |
ATCA_STATUS | hal_kit_hid_discover_buses (int i2c_buses[], int max_buses) |
ATCA_STATUS | hal_kit_hid_discover_devices (int busNum, ATCAIfaceCfg cfg[], int *found) |
discover any CryptoAuth devices on a given logical bus number More... | |
ATCA_STATUS | hal_kit_hid_post_init (ATCAIface iface) |
HAL implementation of Kit HID post init. More... | |
ATCA_STATUS | kit_phy_num_found (int8_t *num_found) |
Number of USB HID devices found. More... | |
ATCA_STATUS | hal_kit_hid_send (ATCAIface iface, uint8_t *txdata, int txlength) |
HAL implementation of kit protocol send over USB HID. More... | |
ATCA_STATUS | hal_kit_hid_receive (ATCAIface iface, uint8_t *rxdata, uint16_t *rxsize) |
HAL implementation of send over USB HID. More... | |
ATCA_STATUS | hal_kit_hid_wake (ATCAIface iface) |
Call the wake for kit protocol. More... | |
ATCA_STATUS | hal_kit_hid_idle (ATCAIface iface) |
Call the idle for kit protocol. More... | |
ATCA_STATUS | hal_kit_hid_sleep (ATCAIface iface) |
Call the sleep for kit protocol. More... | |
ATCA_STATUS | hal_kit_hid_release (void *hal_data) |
Close the physical port for HID. More... | |
ATCA_STATUS | kit_init (ATCAIface iface) |
HAL implementation of kit protocol init. This function calls back to the physical protocol to send the bytes. More... | |
ATCA_STATUS | kit_send (ATCAIface iface, uint8_t *txdata, int txlength) |
HAL implementation of kit protocol send. This function calls back to the physical protocol to send the bytes. More... | |
ATCA_STATUS | kit_receive (ATCAIface iface, uint8_t *rxdata, uint16_t *rxsize) |
HAL implementation to receive bytes and unwrap from kit protocol. This function calls back to the physical protocol to receive the bytes. More... | |
ATCA_STATUS | kit_wake (ATCAIface iface) |
Call the wake for kit protocol. More... | |
ATCA_STATUS | kit_idle (ATCAIface iface) |
Call the idle for kit protocol. More... | |
ATCA_STATUS | kit_sleep (ATCAIface iface) |
Call the sleep for kit protocol. More... | |
ATCA_STATUS | kit_wrap_cmd (uint8_t *txdata, int txlen, char *pkitcmd, int *nkitcmd) |
Wrap binary bytes in ascii kit protocol. More... | |
ATCA_STATUS | kit_parse_rsp (char *pkitbuf, int nkitbuf, uint8_t *kitstatus, uint8_t *rxdata, int *datasize) |
Parse the response ascii from the kit. More... | |
ATCA_STATUS | swi_uart_init (ATCASWIMaster_t *instance) |
Implementation of SWI UART init. More... | |
ATCA_STATUS | swi_uart_deinit (ATCASWIMaster_t *instance) |
Implementation of SWI UART deinit. More... | |
void | swi_uart_setbaud (ATCASWIMaster_t *instance, uint32_t baudrate) |
implementation of SWI UART change baudrate. More... | |
void | swi_uart_mode (ATCASWIMaster_t *instance, uint8_t mode) |
implementation of SWI UART change mode. More... | |
void | swi_uart_discover_buses (int swi_uart_buses[], int max_buses) |
discover UART buses available for this hardware this maintains a list of logical to physical bus mappings freeing the application of the a-priori knowledge More... | |
ATCA_STATUS | swi_uart_send_byte (ATCASWIMaster_t *instance, uint8_t data) |
HAL implementation of SWI UART send byte over ASF. This function send one byte over UART. More... | |
ATCA_STATUS | swi_uart_receive_byte (ATCASWIMaster_t *instance, uint8_t *data) |
HAL implementation of SWI UART receive bytes over ASF. This function receive one byte over UART. More... | |
Variables | |
ATCAI2CMaster_t * | i2c_hal_data [MAX_I2C_BUSES] |
Logical to physical bus mapping structure. More... | |
int | i2c_bus_ref_ct = 0 |
total in-use count across buses More... | |
atcacdc_t | _gCdc |
char * | dev = "/dev/ttyACM0" |
HAL implementation of Kit USB CDC init. More... | |
int | speed = B115200 |
ATCAI2CMaster_t * | i2c_hal_data [MAX_I2C_BUSES] |
Logical to physical bus mapping structure. More... | |
int | i2c_bus_ref_ct = 0 |
twi_master_options_t | opt_twi_master |
ATCAI2CMaster_t * | i2c_hal_data [MAX_I2C_BUSES] |
logical to physical bus mapping structure More... | |
int | i2c_bus_ref_ct = 0 |
ATCAI2CMaster_t * | i2c_hal_data [MAX_I2C_BUSES] |
int | i2c_bus_ref_ct = 0 |
ATCAI2CMaster_t * | i2c_hal_data [MAX_I2C_BUSES] |
logical to physical bus mapping structure More... | |
int | i2c_bus_ref_ct = 0 |
ATCASWIMaster_t * | swi_hal_data [MAX_SWI_BUSES] |
Logical to physical bus mapping structure. More... | |
int | swi_bus_ref_ct = 0 |
total in-use count across buses More... | |
ATCASWIMaster_t * | swi_hal_data [MAX_SWI_BUSES] |
logical to physical bus mapping structure More... | |
int | swi_bus_ref_ct = 0 |
atcahid_t | _gHid |
ATCAI2CMaster_t * | i2c_hal_data [MAX_I2C_BUSES] |
logical to physical bus mapping structure More... | |
int | i2c_bus_ref_ct = 0 |
struct port_config | pin_conf |
These methods define the hardware abstraction layer for communicating with a CryptoAuth device.
These methods define the hardware abstraction layer for communicating with a CryptoAuth device using SWI interface.
These methods define the hardware abstraction layer for communicating with a CryptoAuth device using SWI Interface.
These methods define the hardware abstraction layer for communicating with a CryptoAuth device using SWI bit banging.
< Uncomment when debugging
These methods define the hardware abstraction layer for communicating with a CryptoAuth device using I2C bit banging.
These methods define the hardware abstraction layer for communicating with a CryptoAuth device using I2C driver of ASF.
#define CDC_BUFFER_MAX 1024 |
#define CDC_DEVICES_MAX 10 |
#define DEBUG_PIN_1 EXT2_PIN_5 |
#define DEBUG_PIN_2 EXT2_PIN_6 |
#define HID_DEVICES_MAX 10 |
#define HID_GUID { 0x4d1e55b2, 0xf16f, 0x11cf, 0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 } |
#define HID_PACKET_MAX 512 |
#define INVALID_HANDLE_VALUE ((int)(-1)) |
#define KIT_MSG_SIZE (32) |
#define KIT_RX_WRAP_SIZE (KIT_MSG_SIZE + 6) |
#define KIT_TX_WRAP_SIZE (7) |
#define max | ( | a, | |
b | |||
) | (((a) > (b)) ? (a) : (b)) |
#define MAX_I2C_BUSES 6 |
#define MAX_I2C_BUSES 3 |
#define MAX_I2C_BUSES 6 |
#define MAX_I2C_BUSES 4 |
#define MAX_I2C_BUSES 2 |
#define MAX_SWI_BUSES 6 |
#define MAX_SWI_BUSES 6 |
#define MAX_SWI_BUSES 6 |
#define min | ( | a, | |
b | |||
) | (((a) < (b)) ? (a) : (b)) |
#define RECEIVE_MODE 0 |
#define RECEIVE_MODE 0 |
#define RECEIVE_MODE 0 |
#define RX_DELAY { volatile uint8_t delay = 90; while (delay--) __asm__(""); } |
#define RX_DELAY 10 |
#define RX_DELAY 10 |
#define SWI_FLAG_CMD ((uint8_t)0x77) |
flag preceding a command
#define SWI_FLAG_IDLE ((uint8_t)0xBB) |
flag requesting to go into Idle mode
#define SWI_FLAG_SLEEP ((uint8_t)0xCC) |
flag requesting to go into Sleep mode
#define SWI_FLAG_TX ((uint8_t)0x88) |
flag requesting a response
#define SWI_WAKE_TOKEN ((uint8_t)0x00) |
flag preceding a command
#define TRANSMIT_MODE 1 |
#define TRANSMIT_MODE 1 |
#define TRANSMIT_MODE 1 |
#define TX_DELAY 90 |
#define TX_DELAY 90 |
#define TX_DELAY 93 |
typedef struct atcaI2Cmaster ATCAI2CMaster_t |
this is the hal_data for ATCA HAL for ASF SERCOM
typedef struct atcaI2Cmaster ATCAI2CMaster_t |
this is the hal_data for ATCA HAL for ASF SERCOM
typedef struct atcaI2Cmaster ATCAI2CMaster_t |
this is the hal_data for ATCA HAL for Atmel START SERCOM
typedef struct atcaI2Cmaster ATCAI2CMaster_t |
this is the hal_data for ATCA HAL created using ASF
typedef struct atcaI2Cmaster ATCAI2CMaster_t |
this is the hal_data for ATCA HAL
typedef struct atcaI2Cmaster ATCAI2CMaster_t |
This is the hal_data for ATCA HAL.
typedef struct atcaSWImaster ATCASWIMaster_t |
this is the hal_data for ATCA HAL for ASF SERCOM
typedef struct atcaSWImaster ATCASWIMaster_t |
this is the hal_data for ATCA HAL for SWI UART
typedef struct atcaSWImaster ATCASWIMaster_t |
this is the hal_data for ATCA HAL for ASF SERCOM
typedef struct atcaSWImaster ATCASWIMaster_t |
This is the hal_data for ATCA HAL.
typedef struct cdc_device cdc_device_t |
typedef int HANDLE |
typedef struct hid_device hid_device_t |
enum i2c_read_write_flag |
enum swi_flag |
void atca_delay_10us | ( | uint32_t | delay | ) |
This function delays for a number of tens of microseconds.
[in] | delay | number of 0.01 milliseconds to delay |
void atca_delay_ms | ( | uint32_t | delay | ) |
This function delays for a number of milliseconds. You can override this function if you like to do something else in your system while delaying.
This function delays for a number of milliseconds.
[in] | delay | number of milliseconds to delay |
You can override this function if you like to do something else in your system while delaying.
[in] | delay | number of milliseconds to delay |
void atca_delay_us | ( | uint32_t | delay | ) |
Timer API implemented at the HAL level.
This function delays for a number of microseconds.
[in] | delay | number of 0.001 milliseconds to delay |
[in] | delay | number of 1 microseconds to delay |
void change_i2c_speed | ( | ATCAIface | iface, |
uint32_t | speed | ||
) |
method to change the bus speed of I2C
method to change the bus speec of I2C
[in] | iface | interface on which to change bus speed |
[in] | speed | baud rate (typically 100000 or 400000) |
ATCA_STATUS hal_cdc_discover_buses | ( | int | cdc_buses[], |
int | max_buses | ||
) |
discover cdc buses available for this hardware this maintains a list of logical to physical bus mappings freeing the application of the a-priori knowledge
[in] | cdc_buses | - an array of logical bus numbers |
[in] | max_buses | - maximum number of buses the app wants to attempt to discover |
ATCA_STATUS hal_cdc_discover_devices | ( | int | busNum, |
ATCAIfaceCfg | cfg[], | ||
int * | found | ||
) |
discover any CryptoAuth devices on a given logical bus number
[in] | busNum | - logical bus number on which to look for CryptoAuth devices |
[out] | cfg[] | - pointer to head of an array of interface config structures which get filled in by this method |
[out] | *found | - number of devices found on this bus |
ATCA_STATUS hal_i2c_discover_buses | ( | int | i2c_buses[], |
int | max_buses | ||
) |
This HAL implementation assumes you've included the ASF TWI libraries in your project, otherwise, the HAL layer will not compile because the ASF TWI drivers are a dependency.
discover i2c buses available for this hardware this maintains a list of logical to physical bus mappings freeing the application of the a-priori knowledge
discover i2c buses available for this hardware this maintains a list of logical to physical bus mappings freeing the application of the a-priori knowledge
[in] | i2c_buses | - an array of logical bus numbers |
[in] | max_buses | - maximum number of buses the app wants to attempt to discover |
[in] | i2c_buses | - an array of logical bus numbers |
[in] | max_buses | - maximum number of buses the app wants to attempt to discover |
ATCA_STATUS hal_i2c_discover_devices | ( | int | busNum, |
ATCAIfaceCfg | cfg[], | ||
int * | found | ||
) |
discover any CryptoAuth devices on a given logical bus number
[in] | busNum | - logical bus number on which to look for CryptoAuth devices |
[out] | cfg[] | - pointer to head of an array of interface config structures which get filled in by this method |
[out] | *found | - number of devices found on this bus |
[in] | busNum | logical bus number on which to look for CryptoAuth devices |
[out] | cfg | pointer to head of an array of interface config structures which get filled in by this method |
[out] | found | number of devices found on this bus |
default configuration, to be reused during discovery process
default configuration, to be reused during discovery process
default configuration, to be reused during discovery process
ATCA_STATUS hal_i2c_idle | ( | ATCAIface | iface | ) |
Send Idle flag via I2C.
idle CryptoAuth device using I2C bus
[in] | iface | interface of the logical device to idle |
[in] | iface | interface to logical device to idle |
[in] | iface | interface to logical device to idle |
Set I2C pins
Address the device and indicate that bytes are to be written
< Word Address Value = Idle
ATCA_STATUS hal_i2c_init | ( | void * | hal, |
ATCAIfaceCfg * | cfg | ||
) |
hal_i2c_init manages requests to initialize a physical interface. It manages use counts so when an interface has released the physical layer, it will disable the interface for some other use. You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on multiple i2c buses, so hal_i2c_init manages these things and ATCAIFace is abstracted from the physical details.
hal_i2c_init manages requests to initialize a physical interface. it manages use counts so when an interface has released the physical layer, it will disable the interface for some other use. You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on multiple i2c buses, so hal_i2c_init manages these things and ATCAIFace is abstracted from the physical details.
Initialize an I2C interface using given config.
[in] | hal | opaque pointer to HAL data |
[in] | cfg | interface configuration |
initialize an I2C interface using given config
[in] | hal | - opaque ptr to HAL data |
[in] | cfg | - interface configuration |
[in] | hal | - opaque ptr to HAL data |
[in] | cfg | - interface configuration |
[in] | hal | - opaque ptr to HAL data |
[in] | cfg | - interface configuration |
[in] | hal | - opaque ptr to HAL data |
[in] | cfg | - interface configuration |
< 0-based logical bus number
< power up state, no i2c buses will have been used
< total across buses
if this is the first time this bus and interface has been created, do the physical work of enabling it
< buses are shared, this is the first instance
assign GPIO pins
store this for use during the release phase
otherwise, another interface already initialized the bus, so this interface will share it and any different cfg parameters will be ignored...first one to initialize this sets the configuration
ATCA_STATUS hal_i2c_post_init | ( | ATCAIface | iface | ) |
HAL implementation of I2C post init.
[in] | iface | ATCAIface instance |
[in] | iface | instance |
ATCA_STATUS hal_i2c_receive | ( | ATCAIface | iface, |
uint8_t * | rxdata, | ||
uint16_t * | rxlength | ||
) |
Receive byte(s) via I2C.
HAL implementation of I2C receive function for START I2C.
HAL implementation of I2C receive function for ASF I2C.
[in] | iface | interface of the logical device to receive data from |
[in] | rxdata | pointer to where bytes will be received |
[in] | rxlength | pointer to expected number of receive bytes to request |
[in] | iface | instance |
[in] | rxdata | pointer to space to receive the data |
[in] | rxlength | ptr to expected number of receive bytes to request |
Set I2C pins
Address the device and indicate that bytes are to be read
Receive count byte
Receive the remaining bytes
ATCA_STATUS hal_i2c_release | ( | void * | hal_data | ) |
Manages reference count on given bus and releases resource if no more reference(s) exist.
manages reference count on given bus and releases resource if no more refences exist
[in] | hal_data | opaque pointer to hal data structure - known only to the HAL implementation |
[in] | hal_data | - opaque pointer to hal data structure - known only to the HAL implementation |
[in] | hal_data | - opaque pointer to hal data structure - known only to the HAL implementation |
ATCA_STATUS hal_i2c_send | ( | ATCAIface | iface, |
uint8_t * | txdata, | ||
int | txlength | ||
) |
Send byte(s) via I2C.
HAL implementation of I2C send over START.
HAL implementation of I2C send over ASF.
[in] | iface | interface of the logical device to send data to |
[in] | txdata | pointer to bytes to send |
[in] | txlength | number of bytes to send |
[in] | iface | instance |
[in] | txdata | pointer to space to bytes to send |
[in] | txlength | number of bytes to send |
< Word Address Value = Command
< count Word Address byte towards txlength
Set I2C pins
Address the device and indicate that bytes are to be written
Send the remaining bytes
Send STOP regardless of i2c_status
ATCA_STATUS hal_i2c_sleep | ( | ATCAIface | iface | ) |
Send Sleep flag via I2C.
sleep CryptoAuth device using I2C bus
[in] | iface | interface of the logical device to sleep |
[in] | iface | interface to logical device to sleep |
[in] | iface | interface to logical device to sleep |
Set I2C pins
Address the device and indicate that bytes are to be written
< Word Address Value = Sleep
ATCA_STATUS hal_i2c_wake | ( | ATCAIface | iface | ) |
Send Wake flag via I2C.
wake up CryptoAuth device using I2C bus
[in] | iface | interface of the logical device to wake up |
[in] | iface | interface to logical device to wakeup |
[in] | iface | interface to logical device to wakeup |
Set I2C pins
Generate Wake Token
Wait tWHI + tWLO
Receive Wake Response
Compare response with expected_response
ATCA_STATUS hal_iface_init | ( | ATCAIfaceCfg * | cfg, |
ATCAHAL_t * | hal | ||
) |
Standard HAL API for ATCA to initialize a physical interface.
[in] | cfg | pointer to ATCAIfaceCfg object |
[in] | hal | pointer to ATCAHAL_t intermediate datastructure |
ATCA_STATUS hal_iface_release | ( | ATCAIfaceType | ifacetype, |
void * | hal_data | ||
) |
releases a physical interface, HAL knows how to interpret hal_data
[in] | ifacetype | - the type of physical interface to release |
[in] | hal_data | - pointer to opaque hal data maintained by HAL implementation for this interface type |
ATCA_STATUS hal_kit_cdc_discover_buses | ( | int | i2c_buses[], |
int | max_buses | ||
) |
ATCA_STATUS hal_kit_cdc_discover_devices | ( | int | busNum, |
ATCAIfaceCfg * | cfg, | ||
int * | found | ||
) |
ATCA_STATUS hal_kit_cdc_idle | ( | ATCAIface | iface | ) |
Call the idle for kit protocol.
[in] | iface | ATCAIface instance that is the interface object to send the bytes over |
ATCA_STATUS hal_kit_cdc_init | ( | void * | hal, |
ATCAIfaceCfg * | cfg | ||
) |
ATCA_STATUS hal_kit_cdc_post_init | ( | ATCAIface | iface | ) |
HAL implementation of Kit USB CDC post init.
[in] | iface | instance |
ATCA_STATUS hal_kit_cdc_receive | ( | ATCAIface | iface, |
uint8_t * | rxdata, | ||
uint16_t * | rxsize | ||
) |
HAL implementation of send over USB CDC.
[in] | iface | instance |
[in] | rxdata | pointer to space to receive the data |
[in,out] | rxsize | ptr to expected number of receive bytes to request |
ATCA_STATUS hal_kit_cdc_release | ( | void * | hal_data | ) |
Close the physical port for CDC.
[in] | hal_data | The hardware abstraction data specific to this HAL |
ATCA_STATUS hal_kit_cdc_send | ( | ATCAIface | iface, |
uint8_t * | txdata, | ||
int | txlength | ||
) |
HAL implementation of kit protocol send over USB CDC.
[in] | iface | instance |
[in] | txdata | pointer to bytes to send |
[in] | txlength | number of bytes to send |
ATCA_STATUS hal_kit_cdc_sleep | ( | ATCAIface | iface | ) |
Call the sleep for kit protocol.
[in] | iface | ATCAIface instance that is the interface object to send the bytes over |
ATCA_STATUS hal_kit_cdc_wake | ( | ATCAIface | iface | ) |
Call the wake for kit protocol.
[in] | iface | ATCAIface instance that is the interface object to send the bytes over |
ATCA_STATUS hal_kit_hid_discover_buses | ( | int | i2c_buses[], |
int | max_buses | ||
) |
ATCA_STATUS hal_kit_hid_discover_devices | ( | int | busNum, |
ATCAIfaceCfg | cfg[], | ||
int * | found | ||
) |
discover any CryptoAuth devices on a given logical bus number
[in] | busNum | - logical bus number on which to look for CryptoAuth devices |
[out] | cfg[] | - pointer to head of an array of interface config structures which get filled in by this method |
[out] | *found | - number of devices found on this bus |
ATCA_STATUS hal_kit_hid_idle | ( | ATCAIface | iface | ) |
Call the idle for kit protocol.
[in] | iface | ATCAIface instance that is the interface object to send the bytes over |
ATCA_STATUS hal_kit_hid_init | ( | void * | hal, |
ATCAIfaceCfg * | cfg | ||
) |
HAL implementation of Kit USB HID init.
[in] | hal | pointer to HAL specific data that is maintained by this HAL |
[in] | cfg | pointer to HAL specific configuration data that is used to initialize this HAL |
ATCA_STATUS hal_kit_hid_post_init | ( | ATCAIface | iface | ) |
HAL implementation of Kit HID post init.
[in] | iface | instance |
ATCA_STATUS hal_kit_hid_receive | ( | ATCAIface | iface, |
uint8_t * | rxdata, | ||
uint16_t * | rxsize | ||
) |
HAL implementation of send over USB HID.
[in] | iface | instance |
[in] | rxdata | pointer to space to receive the data |
[in,out] | rxsize | ptr to expected number of receive bytes to request |
ATCA_STATUS hal_kit_hid_release | ( | void * | hal_data | ) |
Close the physical port for HID.
[in] | hal_data | The hardware abstraction data specific to this HAL |
ATCA_STATUS hal_kit_hid_send | ( | ATCAIface | iface, |
uint8_t * | txdata, | ||
int | txlength | ||
) |
HAL implementation of kit protocol send over USB HID.
[in] | iface | instance |
[in] | txdata | pointer to bytes to send |
[in] | txlength | number of bytes to send |
ATCA_STATUS hal_kit_hid_sleep | ( | ATCAIface | iface | ) |
Call the sleep for kit protocol.
[in] | iface | ATCAIface instance that is the interface object to send the bytes over |
ATCA_STATUS hal_kit_hid_wake | ( | ATCAIface | iface | ) |
Call the wake for kit protocol.
[in] | iface | ATCAIface instance that is the interface object to send the bytes over |
ATCA_STATUS hal_kit_phy_num_found | ( | int8_t * | num_found | ) |
Number of USB CDC devices found.
[out] | num_found |
ATCA_STATUS hal_swi_discover_buses | ( | int | swi_buses[], |
int | max_buses | ||
) |
discover swi buses available for this hardware this maintains a list of logical to physical bus mappings freeing the application of the a-priori knowledge
[in] | swi_buses | - an array of logical bus numbers |
[in] | max_buses | - maximum number of buses the app wants to attempt to discover |
ATCA_STATUS hal_swi_discover_devices | ( | int | busNum, |
ATCAIfaceCfg | cfg[], | ||
int * | found | ||
) |
discover any CryptoAuth devices on a given logical bus number
[in] | busNum | - logical bus number on which to look for CryptoAuth devices |
[out] | cfg[] | - pointer to head of an array of interface config structures which get filled in by this method |
[out] | *found | - number of devices found on this bus |
default configuration, to be reused during discovery process
ATCA_STATUS hal_swi_idle | ( | ATCAIface | iface | ) |
Send Idle flag via SWI.
idle CryptoAuth device using SWI interface
[in] | iface | interface of the logical device to idle |
[in] | iface | interface to logical device to idle |
Set SWI pin
ATCA_STATUS hal_swi_init | ( | void * | hal, |
ATCAIfaceCfg * | cfg | ||
) |
hal_swi_init manages requests to initialize a physical interface. It manages use counts so when an interface has released the physical layer, it will disable the interface for some other use. You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on multiple swi buses, so hal_swi_init manages these things and ATCAIFace is abstracted from the physical details.
hal_swi_init manages requests to initialize a physical interface. it manages use counts so when an interface has released the physical layer, it will disable the interface for some other use. You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on multiple swi buses, so hal_swi_init manages these things and ATCAIFace is abstracted from the physical details.
Initialize an SWI interface using given config.
[in] | hal | opaque pointer to HAL data |
[in] | cfg | interface configuration |
initialize an SWI interface using given config
[in] | hal | - opaque ptr to HAL data |
[in] | cfg | - interface configuration |
< 0-based logical bus number
< power up state, no swi buses will have been used
< total across buses
if this is the first time this bus and interface has been created, do the physical work of enabling it
assign GPIO pin
store this for use during the release phase
otherwise, another interface already initialized the bus, any different cfg parameters will be ignored...first one to initialize this sets the configuration
ATCA_STATUS hal_swi_post_init | ( | ATCAIface | iface | ) |
HAL implementation of SWI post init.
[in] | iface | ATCAIface instance |
[in] | iface | instance |
ATCA_STATUS hal_swi_receive | ( | ATCAIface | iface, |
uint8_t * | rxdata, | ||
uint16_t * | rxlength | ||
) |
Receive byte(s) via SWI.
HAL implementation of SWI receive function over UART.
[in] | iface | interface of the logical device to receive data from |
[in] | rxdata | pointer to where bytes will be received |
[in] | rxlength | pointer to expected number of receive bytes to request |
[in] | iface | instance |
[in] | rxdata | pointer to space to receive the data |
[in] | rxlength | ptr to expected number of receive bytes to request |
Set SWI pin
ATCA_STATUS hal_swi_release | ( | void * | hal_data | ) |
Manages reference count on given bus and releases resource if no more reference(s) exist.
manages reference count on given bus and releases resource if no more refences exist
[in] | hal_data | opaque pointer to hal data structure - known only to the HAL implementation |
[in] | hal_data | - opaque pointer to hal data structure - known only to the HAL implementation |
< track total SWI instances
if the use count for this bus has gone to 0 references, disable it. protect against an unbracketed release
ATCA_STATUS hal_swi_send | ( | ATCAIface | iface, |
uint8_t * | txdata, | ||
int | txlength | ||
) |
Send byte(s) via SWI.
HAL implementation of SWI send command over UART.
[in] | iface | interface of the logical device to send data to |
[in] | txdata | pointer to bytes to send |
[in] | txlength | number of bytes to send |
[in] | iface | instance |
[in] | txdata | pointer to space to bytes to send |
[in] | txlength | number of bytes to send |
Skip the Word Address data as SWI doesn't use it
Set SWI pin
Send Command Flag
Send the remaining bytes
ATCA_STATUS hal_swi_send_flag | ( | ATCAIface | iface, |
uint8_t | data | ||
) |
HAL implementation of SWI send one byte over UART.
[in] | iface | instance |
[in] | data | bytes to send |
ATCA_STATUS hal_swi_sleep | ( | ATCAIface | iface | ) |
Send Sleep flag via SWI.
sleep CryptoAuth device using SWI interface
[in] | iface | interface of the logical device to sleep |
[in] | iface | interface to logical device to sleep |
Set SWI pin
ATCA_STATUS hal_swi_wake | ( | ATCAIface | iface | ) |
Send Wake flag via SWI.
wake up CryptoAuth device using SWI interface
[in] | iface | interface of the logical device to wake up |
[in] | iface | interface to logical device to wakeup |
Set SWI pin
Generate Wake Token
Wait tWHI + tWLO
Compare response with expected_response
ATCA_STATUS kit_idle | ( | ATCAIface | iface | ) |
Call the idle for kit protocol.
[in] | iface | the interface object to send the bytes over |
ATCA_STATUS kit_init | ( | ATCAIface | iface | ) |
HAL implementation of kit protocol init. This function calls back to the physical protocol to send the bytes.
[in] | iface | instance |
ATCA_STATUS kit_parse_rsp | ( | char * | pkitbuf, |
int | nkitbuf, | ||
uint8_t * | kitstatus, | ||
uint8_t * | rxdata, | ||
int * | datasize | ||
) |
Parse the response ascii from the kit.
[out] | pkitbuf | pointer to ascii kit protocol data to parse |
[in] | nkitbuf | length of the ascii kit protocol data |
[in] | rxdata | pointer to the binary data buffer |
[in] | datasize | size of the pointer to the binary data buffer |
ATCA_STATUS kit_phy_num_found | ( | int8_t * | num_found | ) |
Number of USB HID devices found.
[out] | num_found |
ATCA_STATUS kit_phy_receive | ( | ATCAIface | iface, |
uint8_t * | rxdata, | ||
int * | rxsize | ||
) |
HAL implementation of kit protocol send over USB CDC.
HAL implementation of kit protocol send over USB HID.
[in] | iface | instance |
[out] | rxdata | pointer to space to receive the data |
[in,out] | rxsize | ptr to expected number of receive bytes to request |
ATCA_STATUS kit_phy_send | ( | ATCAIface | iface, |
uint8_t * | txdata, | ||
int | txlength | ||
) |
HAL implementation of send over USB CDC.
HAL implementation of send over USB HID.
[in] | iface | instance |
[in] | txdata | pointer to bytes to send |
[in] | txlength | number of bytes to send |
ATCA_STATUS kit_receive | ( | ATCAIface | iface, |
uint8_t * | rxdata, | ||
uint16_t * | rxsize | ||
) |
HAL implementation to receive bytes and unwrap from kit protocol. This function calls back to the physical protocol to receive the bytes.
[in] | iface | instance |
[in] | rxdata | pointer to space to receive the data |
[in,out] | rxsize | ptr to expected number of receive bytes to request |
ATCA_STATUS kit_send | ( | ATCAIface | iface, |
uint8_t * | txdata, | ||
int | txlength | ||
) |
HAL implementation of kit protocol send. This function calls back to the physical protocol to send the bytes.
[in] | iface | instance |
[in] | txdata | pointer to bytes to send |
[in] | txlength | number of bytes to send |
ATCA_STATUS kit_sleep | ( | ATCAIface | iface | ) |
Call the sleep for kit protocol.
[in] | iface | the interface object to send the bytes over |
ATCA_STATUS kit_wake | ( | ATCAIface | iface | ) |
Call the wake for kit protocol.
[in] | iface | the interface object to send the bytes over |
ATCA_STATUS kit_wrap_cmd | ( | uint8_t * | txdata, |
int | txlen, | ||
char * | pkitcmd, | ||
int * | nkitcmd | ||
) |
Wrap binary bytes in ascii kit protocol.
[in] | txdata | pointer to the binary data to wrap |
[in] | txlen | length of the binary data to wrap |
[out] | pkitcmd | pointer to binary data converted to ascii kit protocol |
[in,out] | nkitcmd | pointer to the size of the binary data converted to ascii kit protocol |
ATCA_STATUS swi_uart_deinit | ( | ATCASWIMaster_t * | instance | ) |
Implementation of SWI UART deinit.
HAL implementation of SWI UART deinit.
[in] | instance | instance |
void swi_uart_discover_buses | ( | int | swi_uart_buses[], |
int | max_buses | ||
) |
discover UART buses available for this hardware this maintains a list of logical to physical bus mappings freeing the application of the a-priori knowledge
[in] | swi_uart_buses | - an array of logical bus numbers |
[in] | max_buses | - maximum number of buses the app wants to attempt to discover |
ATCA_STATUS swi_uart_init | ( | ATCASWIMaster_t * | instance | ) |
Implementation of SWI UART init.
HAL implementation of SWI UART init.
[in] | instance | instance |
void swi_uart_mode | ( | ATCASWIMaster_t * | instance, |
uint8_t | mode | ||
) |
implementation of SWI UART change mode.
HAL implementation of SWI UART change mode.
[in] | instance | instance |
[in] | mode | (TRANSMIT_MODE or RECEIVE_MODE) |
ATCA_STATUS swi_uart_receive_byte | ( | ATCASWIMaster_t * | instance, |
uint8_t * | data | ||
) |
HAL implementation of SWI UART receive bytes over ASF. This function receive one byte over UART.
[in] | instance | instance |
[in,out] | data | pointer to space to receive the data |
ATCA_STATUS swi_uart_send_byte | ( | ATCASWIMaster_t * | instance, |
uint8_t | data | ||
) |
HAL implementation of SWI UART send byte over ASF. This function send one byte over UART.
[in] | instance | instance |
[in] | data | byte to send |
void swi_uart_setbaud | ( | ATCASWIMaster_t * | instance, |
uint32_t | baudrate | ||
) |
implementation of SWI UART change baudrate.
HAL implementation of SWI UART change baudrate.
[in] | instance | instance |
[in] | baudrate | (typically 230400 , 160000 or 115200) |
[in] | instance | instance |
[in] | baudrate | (typically 230400 or 115200) |
atcacdc_t _gCdc |
atcahid_t _gHid |
char* dev = "/dev/ttyACM0" |
HAL implementation of Kit USB CDC init.
this discovery assumes a udev rule is active which renames the ATCK101 CDC device as a ttyATCAn the udev rule is:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2122", MODE:="0777", SYMLINK+="ttyATCA%n"
[in] | hal | pointer to HAL specific data that is maintained by this HAL |
[in] | cfg | pointer to HAL specific configuration data that is used to initialize this HAL |
int i2c_bus_ref_ct = 0 |
total in-use count across buses
int i2c_bus_ref_ct = 0 |
int i2c_bus_ref_ct = 0 |
int i2c_bus_ref_ct = 0 |
int i2c_bus_ref_ct = 0 |
int i2c_bus_ref_ct = 0 |
ATCAI2CMaster_t* i2c_hal_data[MAX_I2C_BUSES] |
Logical to physical bus mapping structure.
map logical, 0-based bus number to index
ATCAI2CMaster_t* i2c_hal_data[MAX_I2C_BUSES] |
logical to physical bus mapping structure
ATCAI2CMaster_t* i2c_hal_data[MAX_I2C_BUSES] |
logical to physical bus mapping structure
ATCAI2CMaster_t* i2c_hal_data[MAX_I2C_BUSES] |
logical to physical bus mapping structure
ATCAI2CMaster_t* i2c_hal_data[MAX_I2C_BUSES] |
ATCAI2CMaster_t* i2c_hal_data[MAX_I2C_BUSES] |
Logical to physical bus mapping structure.
twi_master_options_t opt_twi_master |
struct port_config pin_conf |
int speed = B115200 |
int swi_bus_ref_ct = 0 |
int swi_bus_ref_ct = 0 |
total in-use count across buses
ATCASWIMaster_t* swi_hal_data[MAX_SWI_BUSES] |
logical to physical bus mapping structure
ATCASWIMaster_t* swi_hal_data[MAX_SWI_BUSES] |
Logical to physical bus mapping structure.
map logical, 0-based bus number to index