These methods define the hardware abstraction layer for communicating with a CryptoAuth device. More...
Cryptoauthlib has several intermediate conceptual layers
The hal and phy layers have the same construction. A hal or phy must have the following functions and their signatures
If the hal is a native driver no phy is required. See the tables below for which hal is required to be ported based on a configured interface
Device Interface | Physical Interface | HAL | PHY |
---|---|---|---|
i2c | i2c | hal_i2c | |
gpio | hal_i2c_gpio | hal_gpio | |
spi | spi | hal_spi | |
swi | uart | hal_swi | hal_uart |
gpio | hal_swi_gpio | hal_gpio | |
any | uart | kit | hal_uart |
hid | kit | hal_hid | |
any (user provided) | kit_bridge |
Obtain library and configure using Harmony 3
Interface | Files | API | Notes |
---|---|---|---|
I2C | hal_i2c_harmony.c | plib.h | For all Harmony 3 based projects |
SPI | hal_spi_harmony.c | plib.h | |
UART | hal_uart_harmony.c | plib.h |
Obtain library and integration through Microchip Code Configurator
Use CMake to configure the library in Linux, Windows, and MacOS environments
OS | Interface | Files | API | Notes |
---|---|---|---|---|
Linux | I2C | hal_linux_i2c_userspace.c/h | i2c-dev | |
Linux | SPI | hal_linux_spi_userspace.c/h | spidev | |
Linux/Mac | hal_linux.c | For all Linux/Mac projects | ||
Windows | hal_windows.c | For all Windows projects | ||
All | kit-hid | hal_all_platforms_kit_hidapi.c/h | hidapi | Works for Windows, Linux, and Mac |
freeRTOS | hal_freertos.c | freeRTOS common routines |
Interface | Files | API | Notes |
---|---|---|---|
hal_timer_start.c | START | Timer implementation | |
I2C | hal_i2c_start.c/h | START | |
SWI | swi_uart_start.c/h | START | SWI using UART |
SAM Micros | Interface | Files | API | Notes |
---|---|---|---|---|
cortex-m0 | I2C | hal_sam0_i2c_asf.c/h | ASF3 | SAMD21, SAMB11, etc |
cortex-m3/4/7 | I2C | hal_sam_i2c_asf.c/h | ASF3 | SAM4S, SAMG55, SAMV71, etc |
all | hal_sam_timer_asf.c | ASF3 | Common timer hal for all platforms |
Data Structures | |
struct | atca_hal_kit_phy_t |
struct | atca_hal_shm_t |
struct | i2c_start_instance |
struct | atca_i2c_host_s |
struct | i2c_sam_instance |
struct | atcaI2Cmaster |
this is the hal_data for ATCA HAL for ASF SERCOM More... | |
struct | atcaSWImaster |
this is the hal_data for ATCA HAL for ASF SERCOM More... | |
Macros | |
#define | ATCA_POLLING_INIT_TIME_MSEC 1 |
#define | ATCA_POLLING_FREQUENCY_TIME_MSEC 2 |
#define | ATCA_POLLING_MAX_TIME_MSEC 2500 |
#define | ATCA_HAL_CONTROL_WAKE (0U) |
Execute the hardware specific wake - generally only for kits. | |
#define | ATCA_HAL_CONTROL_IDLE (1U) |
Execute the hardware specific idle - generally only for kits. | |
#define | ATCA_HAL_CONTROL_SLEEP (2U) |
Execute the hardware specific sleep - generally only for kits. | |
#define | ATCA_HAL_CONTROL_RESET (3U) |
Execute the hardware specific reset - generally only for kits. | |
#define | ATCA_HAL_CONTROL_SELECT (4U) |
Select the device - assert CS, open device, etc. | |
#define | ATCA_HAL_CONTROL_DESELECT (5U) |
Select the device - de-assert CS, release device, etc. | |
#define | ATCA_HAL_CHANGE_BAUD (6U) |
Change the datarate of the phy. | |
#define | ATCA_HAL_FLUSH_BUFFER (7U) |
If the phy has a buffer make sure all bytes are transmitted. | |
#define | ATCA_HAL_CONTROL_DIRECTION (8U) |
Set the PIN mode (in vs out) | |
#define | MAX_I2C_BUSES 3 |
#define | KIT_MAX_SCAN_COUNT 8 |
#define | KIT_MAX_TX_BUF 32 |
#define | KIT_TX_WRAP_SIZE (10) |
#define | KIT_MSG_SIZE (32u) |
#define | KIT_RX_WRAP_SIZE (KIT_MSG_SIZE + 6u) |
#define | MAX_SWI_BUSES 6 |
#define | RECEIVE_MODE 0 |
#define | TRANSMIT_MODE 1 |
#define | RX_DELAY 10 |
#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 |
Typedefs | |
typedef void * | hal_mutex_t |
Generic mutex type definition for most systems. | |
typedef void(* | start_change_baudrate) (ATCAIface iface, uint32_t speed) |
typedef struct i2c_start_instance | i2c_start_instance_t |
typedef struct atca_i2c_host_s | atca_i2c_host_t |
typedef void(* | sam_change_baudrate) (ATCAIface iface, uint32_t speed) |
typedef struct i2c_sam_instance | i2c_sam_instance_t |
typedef struct atcaI2Cmaster | ATCAI2CMaster_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 ASF SERCOM | |
typedef struct atcaSWImaster | ATCASWIMaster_t |
this is the hal_data for ATCA HAL for ASF SERCOM | |
Functions | |
ATCA_STATUS | hal_iface_init (ATCAIfaceCfg *cfg, ATCAHAL_t **hal, ATCAHAL_t **phy) |
Standard HAL API for ATCA to initialize a physical interface. | |
ATCA_STATUS | hal_iface_release (ATCAIfaceType iface_type, void *hal_data) |
releases a physical interface, HAL knows how to interpret hal_data | |
ATCA_STATUS | hal_check_wake (const uint8_t *response, int response_size) |
Utility function for hal_wake to check the reply. | |
void | atca_delay_ms (uint32_t ms) |
Timer API for legacy implementations. | |
void | atca_delay_us (uint32_t delay) |
This function delays for a number of microseconds. | |
void | hal_delay_ms (uint32_t delay) |
Timer API implemented at the HAL level. | |
void | hal_delay_us (uint32_t delay) |
This function delays for a number of microseconds. | |
ATCA_STATUS | hal_create_mutex (void **ppMutex, const char *pName) |
Optional hal interfaces. | |
ATCA_STATUS | hal_init_mutex (void *pMutex, bool shared) |
ATCA_STATUS | hal_destroy_mutex (void *pMutex) |
ATCA_STATUS | hal_lock_mutex (void *pMutex) |
ATCA_STATUS | hal_unlock_mutex (void *pMutex) |
ATCA_STATUS | hal_alloc_shared (void **pShared, size_t size, const char *pName, bool *initialized) |
ATCA_STATUS | hal_free_shared (void *pShared, size_t size) |
ATCA_STATUS | hal_iface_register_hal (ATCAIfaceType iface_type, ATCAHAL_t *hal, ATCAHAL_t **old_hal, ATCAHAL_t *phy, ATCAHAL_t **old_phy) |
Register/Replace a HAL with a. | |
uint8_t | hal_is_command_word (uint8_t word_address) |
Utility function for hal_wake to check the reply. | |
ATCA_STATUS | hal_kit_hid_init (ATCAIface iface, ATCAIfaceCfg *cfg) |
HAL implementation of Kit USB HID init. | |
ATCA_STATUS | hal_kit_hid_post_init (ATCAIface iface) |
HAL implementation of Kit HID post init. | |
ATCA_STATUS | hal_kit_hid_send (ATCAIface iface, uint8_t word_address, uint8_t *txdata, int txlength) |
HAL implementation of kit protocol send over USB HID. | |
ATCA_STATUS | hal_kit_hid_receive (ATCAIface iface, uint8_t word_address, uint8_t *rxdata, uint16_t *rxlength) |
HAL implementation of send over USB HID. | |
ATCA_STATUS | hal_kit_hid_control (ATCAIface iface, uint8_t option, void *param, size_t paramlen) |
Perform control operations for the kit protocol. | |
ATCA_STATUS | hal_kit_hid_release (void *hal_data) |
Close the physical port for HID. | |
void * | hal_malloc (size_t size) |
void | hal_free (void *ptr) |
void | hal_rtos_delay_ms (uint32_t delay) |
This function delays for a number of milliseconds. | |
ATCA_STATUS | hal_i2c_discover_buses (int i2c_buses[], int max_buses) |
discover i2c buses available for this hardware this maintains a list of logical to physical bus mappings freeing the application of the a-prior knowledge | |
ATCA_STATUS | hal_i2c_discover_devices (int bus_num, ATCAIfaceCfg cfg[], int *found) |
discover any CryptoAuth devices on a given logical bus number | |
ATCA_STATUS | hal_i2c_init (ATCAIface iface, 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. | |
ATCA_STATUS | hal_i2c_post_init (ATCAIface iface) |
HAL implementation of I2C post init. | |
ATCA_STATUS | hal_i2c_send (ATCAIface iface, uint8_t word_address, uint8_t *txdata, int txlength) |
HAL implementation of I2C send over START. | |
ATCA_STATUS | hal_i2c_receive (ATCAIface iface, uint8_t address, uint8_t *rxdata, uint16_t *rxlength) |
HAL implementation of I2C receive function for START I2C. | |
ATCA_STATUS | change_i2c_speed (ATCAIface iface, uint32_t speed) |
method to change the bus speec of I2C | |
ATCA_STATUS | hal_i2c_control (ATCAIface iface, uint8_t option, void *param, size_t paramlen) |
Perform control operations for the kit protocol. | |
ATCA_STATUS | hal_i2c_release (void *hal_data) |
manages reference count on given bus and releases resource if no more refences exist | |
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. | |
ATCA_STATUS | hal_i2c_wake (ATCAIface iface) |
wake up CryptoAuth device using I2C bus | |
ATCA_STATUS | hal_i2c_idle (ATCAIface iface) |
idle CryptoAuth device using I2C bus | |
ATCA_STATUS | hal_i2c_sleep (ATCAIface iface) |
sleep CryptoAuth device using I2C bus | |
ATCA_STATUS | hal_kit_attach_phy (ATCAIfaceCfg *cfg, atca_hal_kit_phy_t *phy) |
Helper function that connects a physical layer context structure that will be used by the kit protocol bridge. | |
ATCA_STATUS | hal_kit_init (ATCAIface iface, ATCAIfaceCfg *cfg) |
HAL implementation of Kit USB HID init. | |
ATCA_STATUS | hal_kit_post_init (ATCAIface iface) |
HAL implementation of Kit HID post init. | |
ATCA_STATUS | hal_kit_send (ATCAIface iface, uint8_t word_address, uint8_t *txdata, int txlength) |
HAL implementation of kit protocol send over USB HID. | |
ATCA_STATUS | hal_kit_receive (ATCAIface iface, uint8_t word_address, uint8_t *rxdata, uint16_t *rxsize) |
HAL implementation of send over USB HID. | |
ATCA_STATUS | hal_kit_control (ATCAIface iface, uint8_t option, void *param, size_t paramlen) |
Kit Protocol Control. | |
ATCA_STATUS | hal_kit_release (void *hal_data) |
Close the physical port for HID. | |
ATCA_STATUS | hal_check_pid (hal_pid_t pid) |
Check if the pid exists in the system. | |
void | atca_delay_10us (uint32_t delay) |
This function delays for a number of tens of microseconds. | |
ATCA_STATUS | hal_spi_discover_buses (int spi_buses[], int max_buses) |
discover spi buses available for this hardware this maintains a list of logical to physical bus mappings freeing the application of the a-priori knowledge | |
ATCA_STATUS | hal_spi_discover_devices (int bus_num, ATCAIfaceCfg cfg[], int *found) |
discover any TA10x devices on a given logical bus number | |
ATCA_STATUS | hal_spi_init (ATCAIface iface, ATCAIfaceCfg *cfg) |
initialize an SPI interface using given config | |
ATCA_STATUS | hal_spi_post_init (ATCAIface iface) |
HAL implementation of SPI post init. | |
ATCA_STATUS | hal_spi_select (ATCAIface iface) |
HAL implementation to assert the device chip select. | |
ATCA_STATUS | hal_spi_deselect (ATCAIface iface) |
HAL implementation to deassert the device chip select. | |
ATCA_STATUS | hal_spi_send (ATCAIface iface, uint8_t word_address, uint8_t *txdata, int txlength) |
HAL implementation of SPI send over Harmony. | |
ATCA_STATUS | hal_spi_receive (ATCAIface iface, uint8_t word_address, uint8_t *rxdata, uint16_t *rxlength) |
HAL implementation of SPI receive function for HARMONY SPI. | |
ATCA_STATUS | hal_spi_control (ATCAIface iface, uint8_t option, void *param, size_t paramlen) |
Perform control operations for the kit protocol. | |
ATCA_STATUS | hal_spi_release (void *hal_data) |
manages reference count on given bus and releases resource if no more refences exist | |
ATCA_STATUS | hal_swi_init (ATCAIface iface, ATCAIfaceCfg *cfg) |
initialize an SWI interface using given config | |
ATCA_STATUS | hal_swi_post_init (ATCAIface iface) |
HAL implementation of SWI post init. | |
ATCA_STATUS | hal_swi_send (ATCAIface iface, uint8_t word_address, uint8_t *txdata, int txlength) |
HAL implementation of SWI send command over UART. | |
ATCA_STATUS | hal_swi_receive (ATCAIface iface, uint8_t word_address, uint8_t *rxdata, uint16_t *rxlength) |
HAL implementation of SWI receive function over UART. | |
ATCA_STATUS | hal_swi_wake (ATCAIface iface) |
Send Wake flag via SWI. | |
ATCA_STATUS | hal_swi_sleep (ATCAIface iface) |
Send Sleep flag via SWI. | |
ATCA_STATUS | hal_swi_idle (ATCAIface iface) |
Send Idle flag via SWI. | |
ATCA_STATUS | hal_swi_control (ATCAIface iface, uint8_t option, void *param, size_t paramlen) |
Perform control operations for the kit protocol. | |
ATCA_STATUS | hal_swi_release (void *hal_data) |
manages reference count on given bus and releases resource if no more refences exist | |
const char * | kit_id_from_devtype (ATCADeviceType devtype) |
const char * | kit_interface_from_kittype (ATCAKitType kittype) |
const char * | kit_interface (ATCAKitType kittype) |
ATCA_STATUS | kit_init (ATCAIface iface, ATCAIfaceCfg *cfg) |
ATCA_STATUS | kit_post_init (ATCAIface iface) |
ATCA_STATUS | kit_send (ATCAIface iface, uint8_t word_address, uint8_t *txdata, int txlength) |
ATCA_STATUS | kit_receive (ATCAIface iface, uint8_t word_address, uint8_t *rxdata, uint16_t *rxsize) |
ATCA_STATUS | kit_control (ATCAIface iface, uint8_t option, void *param, size_t paramlen) |
ATCA_STATUS | kit_release (void *hal_data) |
ATCA_STATUS | kit_wrap_cmd (ATCAIface iface, uint8_t word_address, const uint8_t *txdata, int txlen, char *pkitcmd, int *nkitcmd) |
ATCA_STATUS | kit_parse_rsp (const char *pkitbuf, int nkitbuf, uint8_t *kitstatus, uint8_t *rxdata, int *datasize) |
ATCA_STATUS | kit_wake (ATCAIface iface) |
ATCA_STATUS | kit_idle (ATCAIface iface) |
ATCA_STATUS | kit_sleep (ATCAIface iface) |
ATCA_STATUS | kit_phy_send (ATCAIface iface, uint8_t *txdata, int txlength) |
ATCA_STATUS | kit_phy_receive (ATCAIface iface, uint8_t *rxdata, int *rxsize) |
ATCA_STATUS | swi_uart_init (ATCASWIMaster_t *instance) |
Implementation of SWI UART init. | |
ATCA_STATUS | swi_uart_deinit (ATCASWIMaster_t *instance) |
Implementation of SWI UART deinit. | |
void | swi_uart_setbaud (ATCASWIMaster_t *instance, uint32_t baudrate) |
implementation of SWI UART change baudrate. | |
void | swi_uart_mode (ATCASWIMaster_t *instance, uint8_t mode) |
implementation of SWI UART change mode. | |
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 | |
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. | |
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. | |
Variables | |
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 TA10x device.
< Uncomment when debugging
These methods define the hardware abstraction layer for communicating with a CryptoAuth device using I2C driver of ASF.
#define MAX_SWI_BUSES 6 |
#define MAX_SWI_BUSES 6 |
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 |
[in] | delay | number of 0.01 milliseconds to delay |
void atca_delay_ms | ( | uint32_t | delay | ) |
Timer API for legacy implementations.
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.
[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 | ) |
This function delays for a number of microseconds.
[in] | delay | number of 0.001 milliseconds to delay |
[in] | delay | number of microseconds to delay |
[in] | delay | number of 0.001 milliseconds to delay |
ATCA_STATUS change_i2c_speed | ( | ATCAIface | iface, |
uint32_t | speed | ||
) |
method to change the bus speec of I2C
method to change the bus speed of I2C
[in] | iface | interface on which to change bus speed |
[in] | speed | baud rate (typically 100000 or 400000) |
[in] | iface | interface on which to change bus speed |
[in] | speed | baud rate (typically 100000 or 400000) |
ATCA_STATUS hal_check_wake | ( | const uint8_t * | response, |
int | response_size | ||
) |
Utility function for hal_wake to check the reply.
[in] | response | Wake response to be checked. |
[in] | response_size | Size of the response to check. |
ATCA_STATUS hal_create_mutex | ( | void ** | ppMutex, |
const char * | pName | ||
) |
Optional hal interfaces.
Application callback for creating a mutex object.
[in,out] | ppMutex | location to receive ptr to mutex |
[in,out] | pName | String used to identify the mutex |
[IN/OUT] | ppMutex location to receive ptr to mutex | |
[IN] | pName Name of the mutex for systems using named objects |
void hal_delay_ms | ( | uint32_t | delay | ) |
Timer API implemented at the HAL level.
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 hal_delay_us | ( | uint32_t | delay | ) |
This function delays for a number of microseconds.
[in] | delay | number of microseconds to delay |
[in] | delay | number of microseconds to delay |
ATCA_STATUS hal_i2c_control | ( | ATCAIface | iface, |
uint8_t | option, | ||
void * | param, | ||
size_t | paramlen | ||
) |
Perform control operations for the kit protocol.
[in] | iface | Interface to interact with. |
[in] | option | Control parameter identifier |
[in] | param | Optional pointer to parameter value |
[in] | paramlen | Length of the parameter |
ATCA_STATUS hal_i2c_discover_buses | ( | int | i2c_buses[], |
int | max_buses | ||
) |
discover i2c buses available for this hardware this maintains a list of logical to physical bus mappings freeing the application of the a-prior knowledge
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.
logical to physical bus mapping structure
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 |
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 |
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 return ATCA_SUCCESS |
ATCA_STATUS hal_i2c_discover_devices | ( | int | bus_num, |
ATCAIfaceCfg | cfg[], | ||
int * | found | ||
) |
discover any CryptoAuth devices on a given logical bus number
[in] | bus_num | 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] | bus_num | - 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] | bus_num | 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_idle | ( | ATCAIface | iface | ) |
idle CryptoAuth device using I2C bus
[in] | iface | interface to logical device to idle |
[in] | iface | interface to logical device to idle |
ATCA_STATUS hal_i2c_init | ( | ATCAIface | iface, |
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 implementation of I2C init.
initialize an I2C interface using given config
[in] | hal | - opaque ptr to HAL data |
[in] | cfg | - interface configuration |
this implementation assumes I2C peripheral has been enabled by user. It only initialize an I2C interface using given config.
[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_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
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 |
initialize an I2C interface using given config
[in] | hal | - opaque ptr to HAL data |
[in] | cfg | - interface configuration |
ATCA_STATUS hal_i2c_post_init | ( | ATCAIface | iface | ) |
HAL implementation of I2C post init.
[in] | iface | instance |
[in] | iface | instance |
[in] | iface | instance |
ATCA_STATUS hal_i2c_receive | ( | ATCAIface | iface, |
uint8_t | word_address, | ||
uint8_t * | rxdata, | ||
uint16_t * | rxlength | ||
) |
HAL implementation of I2C receive function for START I2C.
HAL implementation of I2C receive function for ASF I2C.
HAL implementation of I2C receive function.
[in] | iface | Device to interact with. |
[in] | word_address | device transaction type |
[out] | rxdata | Data received will be returned here. |
[in,out] | rxlength | As input, the size of the rxdata buffer. As output, the number of bytes received. |
[in] | iface | Device to interact with. |
[out] | rxdata | Data received will be returned here. |
[in,out] | rxlength | As input, the size of the rxdata buffer. As output, the number of bytes received. |
[in] | iface | Device to interact with. |
[in] | address | device address |
[out] | rxdata | Data received will be returned here. |
[in,out] | rxlength | As input, the size of the rxdata buffer. As output, the number of bytes received. |
[in] | iface | Device to interact with. |
[in] | word_address | device word address |
[out] | rxdata | Data received will be returned here. |
[in,out] | rxlength | As input, the size of the rxdata buffer. As output, the number of bytes received. |
ATCA_STATUS hal_i2c_release | ( | void * | hal_data | ) |
manages reference count on given bus and releases resource if no more refences exist
manages reference count on given bus and releases resource if no more refernces 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 return ATCA_SUCCESS |
[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 | word_address, | ||
uint8_t * | txdata, | ||
int | txlength | ||
) |
HAL implementation of I2C send over START.
HAL implementation of I2C send over ASF.
HAL implementation of I2C send.
[in] | iface | instance |
[in] | word_address | device transaction type |
[in] | txdata | pointer to space 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 |
[in] | iface | instance |
[in] | word_address | device word address |
[in] | txdata | pointer to space to bytes to send |
[in] | txlength | number of bytes to send |
[in] | iface | instance |
[in] | word_address | device word address |
[in] | txdata | pointer to space to bytes to send |
[in] | txlength | number of bytes to send |
Add 1 byte for word address
Add 1 byte for word address
ATCA_STATUS hal_i2c_sleep | ( | ATCAIface | iface | ) |
sleep CryptoAuth device using I2C bus
[in] | iface | interface to logical device to sleep |
[in] | iface | interface to logical device to sleep |
ATCA_STATUS hal_i2c_wake | ( | ATCAIface | iface | ) |
wake up CryptoAuth device using I2C bus
[in] | iface | interface to logical device to wakeup |
[in] | iface | interface to logical device to wakeup |
ATCA_STATUS hal_iface_init | ( | ATCAIfaceCfg * | cfg, |
ATCAHAL_t ** | hal, | ||
ATCAHAL_t ** | phy | ||
) |
Standard HAL API for ATCA to initialize a physical interface.
[in] | cfg | pointer to ATCAIfaceCfg object |
[in] | hal | pointer to ATCAHAL_t intermediate data structure |
ATCA_STATUS hal_iface_register_hal | ( | ATCAIfaceType | iface_type, |
ATCAHAL_t * | hal, | ||
ATCAHAL_t ** | old_hal, | ||
ATCAHAL_t * | phy, | ||
ATCAHAL_t ** | old_phy | ||
) |
ATCA_STATUS hal_iface_release | ( | ATCAIfaceType | iface_type, |
void * | hal_data | ||
) |
releases a physical interface, HAL knows how to interpret hal_data
[in] | iface_type | - the type of physical interface to release |
[in] | hal_data | - pointer to opaque hal data maintained by HAL implementation for this interface type |
uint8_t hal_is_command_word | ( | uint8_t | word_address | ) |
Utility function for hal_wake to check the reply.
[in] | word_address | Command to check |
ATCA_STATUS hal_kit_attach_phy | ( | ATCAIfaceCfg * | cfg, |
atca_hal_kit_phy_t * | phy | ||
) |
Helper function that connects a physical layer context structure that will be used by the kit protocol bridge.
cfg | [IN] Interface configuration structure |
phy | [IN] Structure with physical layer interface functions and context |
ATCA_STATUS hal_kit_control | ( | ATCAIface | iface, |
uint8_t | option, | ||
void * | param, | ||
size_t | paramlen | ||
) |
Kit Protocol Control.
[in] | iface | ATCAIface instance that is the interface object to send the bytes over |
[in] | option | Control option to use |
ATCA_STATUS hal_kit_hid_control | ( | ATCAIface | iface, |
uint8_t | option, | ||
void * | param, | ||
size_t | paramlen | ||
) |
Perform control operations for the kit protocol.
[in] | iface | Interface to interact with. |
[in] | option | Control parameter identifier |
[in] | param | Optional pointer to parameter value |
[in] | paramlen | Length of the parameter |
ATCA_STATUS hal_kit_hid_init | ( | ATCAIface | iface, |
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 | word_address, | ||
uint8_t * | rxdata, | ||
uint16_t * | rxlength | ||
) |
HAL implementation of send over USB HID.
[in] | iface | instance |
[in] | word_address | determine device transaction type |
[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 | word_address, | ||
uint8_t * | txdata, | ||
int | txlength | ||
) |
HAL implementation of kit protocol send over USB HID.
[in] | iface | instance |
[in] | word_address | determine device transaction type |
[in] | txdata | pointer to bytes to send |
[in] | txlength | number of bytes to send |
ATCA_STATUS hal_kit_init | ( | ATCAIface | iface, |
ATCAIfaceCfg * | cfg | ||
) |
HAL implementation of Kit USB HID init.
[in] | iface | instance |
[in] | cfg | pointer to HAL specific configuration data that is used to initialize this HAL |
ATCA_STATUS hal_kit_post_init | ( | ATCAIface | iface | ) |
HAL implementation of Kit HID post init.
[in] | iface | instance |
ATCA_STATUS hal_kit_receive | ( | ATCAIface | iface, |
uint8_t | word_address, | ||
uint8_t * | rxdata, | ||
uint16_t * | rxsize | ||
) |
HAL implementation of send over USB HID.
[in] | iface | instance |
[in] | word_address | determine device transaction type |
[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_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_send | ( | ATCAIface | iface, |
uint8_t | word_address, | ||
uint8_t * | txdata, | ||
int | txlength | ||
) |
HAL implementation of kit protocol send over USB HID.
[in] | iface | instance |
[in] | word_address | determine device transaction type |
[in] | txdata | pointer to bytes to send |
[in] | txlength | number of bytes to send |
Add 1 byte to txlength for word address
void hal_rtos_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.
[in] | delay | Number of milliseconds to delay |
ATCA_STATUS hal_spi_control | ( | ATCAIface | iface, |
uint8_t | option, | ||
void * | param, | ||
size_t | paramlen | ||
) |
Perform control operations for the kit protocol.
[in] | iface | Interface to interact with. |
[in] | option | Control parameter identifier |
[in] | param | Optional pointer to parameter value |
[in] | paramlen | Length of the parameter |
ATCA_STATUS hal_spi_deselect | ( | ATCAIface | iface | ) |
HAL implementation to deassert the device chip select.
[in] | iface | Device to interact with. |
ATCA_STATUS hal_spi_discover_buses | ( | int | spi_buses[], |
int | max_buses | ||
) |
discover spi buses available for this hardware this maintains a list of logical to physical bus mappings freeing the application of the a-priori knowledge
[in] | spi_buses | - an array of logical bus numbers |
[in] | max_buses | - maximum number of buses the app wants to attempt to discover |
ATCA_STATUS hal_spi_discover_devices | ( | int | bus_num, |
ATCAIfaceCfg | cfg[], | ||
int * | found | ||
) |
discover any TA10x devices on a given logical bus number
[in] | bus_num | logical bus number on which to look for TA10x 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_spi_init | ( | ATCAIface | iface, |
ATCAIfaceCfg * | cfg | ||
) |
initialize an SPI interface using given config
[in] | hal | - opaque ptr to HAL data |
[in] | cfg | - interface configuration |
ATCA_STATUS hal_spi_post_init | ( | ATCAIface | iface | ) |
HAL implementation of SPI post init.
[in] | iface | instance |
ATCA_STATUS hal_spi_receive | ( | ATCAIface | iface, |
uint8_t | word_address, | ||
uint8_t * | rxdata, | ||
uint16_t * | rxlength | ||
) |
HAL implementation of SPI receive function for HARMONY SPI.
[in] | iface | Device to interact with. |
[in] | word_address | device transaction type |
[out] | rxdata | Data received will be returned here. |
[in,out] | rxlength | As input, the size of the rxdata buffer. As output, the number of bytes received. |
ATCA_STATUS hal_spi_release | ( | void * | hal_data | ) |
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 |
ATCA_STATUS hal_spi_select | ( | ATCAIface | iface | ) |
HAL implementation to assert the device chip select.
[in] | iface | Device to interact with. |
ATCA_STATUS hal_spi_send | ( | ATCAIface | iface, |
uint8_t | word_address, | ||
uint8_t * | txdata, | ||
int | txlength | ||
) |
HAL implementation of SPI send over Harmony.
[in] | iface | instance |
[in] | word_address | device transaction type |
[in] | txdata | pointer to space to bytes to send |
[in] | txlength | number of bytes to send |
ATCA_STATUS hal_swi_control | ( | ATCAIface | iface, |
uint8_t | option, | ||
void * | param, | ||
size_t | paramlen | ||
) |
Perform control operations for the kit protocol.
[in] | iface | Interface to interact with. |
[in] | option | Control parameter identifier |
[in] | param | Optional pointer to parameter value |
[in] | paramlen | Length of the parameter |
ATCA_STATUS hal_swi_idle | ( | ATCAIface | iface | ) |
Send Idle flag via SWI.
[in] | iface | interface of the logical device to idle |
ATCA_STATUS hal_swi_init | ( | ATCAIface | iface, |
ATCAIfaceCfg * | cfg | ||
) |
initialize an SWI interface using given config
[in] | hal | - opaque ptr to HAL data |
[in] | cfg | - interface configuration |
ATCA_STATUS hal_swi_post_init | ( | ATCAIface | iface | ) |
HAL implementation of SWI post init.
[in] | iface | instance |
ATCA_STATUS hal_swi_receive | ( | ATCAIface | iface, |
uint8_t | word_address, | ||
uint8_t * | rxdata, | ||
uint16_t * | rxlength | ||
) |
HAL implementation of SWI receive function over UART.
[in] | iface | Device to interact with. |
[in] | word_address | device transaction type |
[out] | rxdata | Data received will be returned here. |
[in,out] | rxlength | As input, the size of the rxdata buffer. As output, the number of bytes received. |
ATCA_STATUS hal_swi_release | ( | void * | hal_data | ) |
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 |
ATCA_STATUS hal_swi_send | ( | ATCAIface | iface, |
uint8_t | word_address, | ||
uint8_t * | txdata, | ||
int | txlength | ||
) |
HAL implementation of SWI send command over UART.
[in] | iface | instance |
[in] | word_address | device transaction type |
[in] | txdata | pointer to space to bytes to send |
[in] | txlength | number of bytes to send |
Send word address
Send data
ATCA_STATUS hal_swi_sleep | ( | ATCAIface | iface | ) |
Send Sleep flag via SWI.
[in] | iface | interface of the logical device to sleep |
ATCA_STATUS hal_swi_wake | ( | ATCAIface | iface | ) |
Send Wake flag via SWI.
[in] | iface | interface of the logical device to wake up |
const char * kit_id_from_devtype | ( | ATCADeviceType | devtype | ) |
Kit Protocol is key
const char * kit_interface | ( | ATCAKitType | kittype | ) |
Kit parser physical interface string
const char * kit_interface_from_kittype | ( | ATCAKitType | kittype | ) |
Kit interface from device
ATCA_STATUS swi_uart_deinit | ( | ATCASWIMaster_t * | instance | ) |
Implementation of SWI UART deinit.
HAL implementation of SWI UART deinit.
[in] | instance | instance |
[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 |
[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 |
[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 | number of 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) |