CryptoAuthLib
Microchip CryptoAuthentication Library
Hardware abstraction layer (hal_)

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  atcahid
 
struct  atcaI2Cmaster
 this is the hal_data for ATCA HAL created using ASF More...
 
struct  cdc_device
 
struct  atcacdc
 
struct  hid_device
 
struct  DRV_I2C_Object
 
struct  atcaSWImaster
 This is the hal_data for ATCA HAL. More...
 

Macros

#define HID_DEVICES_MAX   10
 
#define HID_PACKET_MAX   512
 
#define MAX_I2C_BUSES   1
 
#define MAX_I2C_BUSES   6
 
#define MAX_I2C_BUSES   2
 
#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 HID_DEVICES_MAX   10
 
#define HID_PACKET_MAX   512
 
#define GetSystemClock()   (80000000ul)
 
#define GetPeripheralClock()   (GetSystemClock() / (1 << OSCCONbits.PBDIV))
 
#define GetInstructionClock()   (GetSystemClock())
 
#define MAX_I2C_BUSES   4
 
#define CPU_CLOCK   (80000000UL)
 
#define us_SCALE   ((CPU_CLOCK / 2) / 1000000)
 
#define HARMONY_I2C_DRIVER   1
 
#define MAX_I2C_BUSES   3
 
#define GetSystemClock()   (200000000UL)/* Fcy = 200MHz */
 
#define us_SCALE   (GetSystemClock() / 2000000)
 
#define MAX_I2C_BUSES   2
 
#define MAX_I2C_BUSES   2
 
#define MAX_I2C_BUSES   6
 
#define MAX_I2C_BUSES   2
 
#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_MAX_SCAN_COUNT   4
 
#define KIT_MAX_TX_BUF   32
 
#define KIT_TX_WRAP_SIZE   (7)
 
#define KIT_MSG_SIZE   (32)
 
#define KIT_RX_WRAP_SIZE   (KIT_MSG_SIZE + 6)
 
#define MAX_SWI_BUSES   1
 
#define RECEIVE_MODE   0
 
#define TRANSMIT_MODE   1
 
#define RX_DELAY   10
 
#define TX_DELAY   90
 
#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
 
#define MAX_SWI_BUSES   6
 
#define RECEIVE_MODE   0
 
#define TRANSMIT_MODE   1
 
#define RX_DELAY   10
 
#define TX_DELAY   90
 

Typedefs

typedef struct atcahid atcahid_t
 
typedef struct atcaI2Cmaster ATCAI2CMaster_t
 this is the hal_data for ATCA HAL created using ASF More...
 
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 Atmel START SERCOM More...
 
typedef struct atcaI2Cmaster ATCAI2CMaster_t
 
typedef int HANDLE
 
typedef struct cdc_device cdc_device_t
 
typedef struct atcacdc atcacdc_t
 
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 More...
 
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 More...
 
typedef struct atcaI2Cmaster ATCAI2CMaster_t
 this is the hal_data for ATCA HAL for ASF 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 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 SWI UART 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...
 
ATCA_STATUS hal_check_wake (const uint8_t *response, int response_size)
 Utility function for hal_wake to check the reply. 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. More...
 
ATCA_STATUS hal_create_mutex (void **ppMutex, char *pName)
 Optional hal interfaces. More...
 
ATCA_STATUS hal_destroy_mutex (void *pMutex)
 
ATCA_STATUS hal_lock_mutex (void *pMutex)
 
ATCA_STATUS hal_unlock_mutex (void *pMutex)
 
ATCA_STATUS hal_kit_hid_discover_buses (int i2c_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_kit_hid_discover_devices (int bus_num, ATCAIfaceCfg cfg[], int *found)
 discover any CryptoAuth devices on a given logical bus number More...
 
ATCA_STATUS hal_kit_hid_init (void *hal, ATCAIfaceCfg *cfg)
 HAL implementation of Kit USB HID init. More...
 
ATCA_STATUS hal_kit_hid_post_init (ATCAIface iface)
 HAL implementation of Kit HID post init. More...
 
ATCA_STATUS kit_phy_send (ATCAIface iface, uint8_t *txdata, int txlength)
 HAL implementation of send over USB HID. More...
 
ATCA_STATUS kit_phy_receive (ATCAIface iface, uint8_t *rxdata, int *rxsize)
 HAL implementation of kit protocol send over USB HID. 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 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 prior knowledge More...
 
ATCA_STATUS hal_i2c_discover_devices (int bus_num, ATCAIfaceCfg cfg[], int *found)
 discover any CryptoAuth devices on a given logical bus number More...
 
ATCA_STATUS hal_i2c_init (void *hal, ATCAIfaceCfg *cfg)
 initialize an I2C interface using given config 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)
 HAL implementation of I2C send over ASF. More...
 
ATCA_STATUS hal_i2c_receive (ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength)
 HAL implementation of I2C receive function for ASF I2C. More...
 
void change_i2c_speed (ATCAIface iface, uint32_t speed)
 method to change the bus speed of I2C More...
 
ATCA_STATUS hal_i2c_wake (ATCAIface iface)
 wake up CryptoAuth device using I2C bus More...
 
ATCA_STATUS hal_i2c_idle (ATCAIface iface)
 idle CryptoAuth device using I2C bus More...
 
ATCA_STATUS hal_i2c_sleep (ATCAIface iface)
 sleep CryptoAuth device using I2C bus More...
 
ATCA_STATUS hal_i2c_release (void *hal_data)
 manages reference count on given bus and releases resource if no more refences 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.This function is currently not implemented. More...
 
ATCA_STATUS hal_cdc_discover_devices (int bus_num, 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)
 HAL implementation of Kit USB CDC init. More...
 
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, const char *txdata, int txlength)
 HAL implementation of kit protocol send .It is called by the top layer. More...
 
ATCA_STATUS kit_phy_receive (ATCAIface iface, char *rxdata, int *rxsize)
 HAL implementation of kit protocol receive data.It is called by the top layer. 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 kit protocol receive over USB CDC. More...
 
ATCA_STATUS hal_kit_cdc_wake (ATCAIface iface)
 Call the wake for kit protocol over USB CDC. More...
 
ATCA_STATUS hal_kit_cdc_idle (ATCAIface iface)
 Call the idle for kit protocol over USB CDC. More...
 
ATCA_STATUS hal_kit_cdc_sleep (ATCAIface iface)
 Call the sleep for kit protocol over USB CDC. More...
 
ATCA_STATUS hal_kit_cdc_release (void *hal_data)
 Close the physical port for CDC over USB CDC. More...
 
ATCA_STATUS hal_kit_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.This function is currently not implemented. More...
 
ATCA_STATUS hal_kit_cdc_discover_devices (int bus_num, ATCAIfaceCfg *cfg, int *found)
 discover any CryptoAuth devices on a given logical bus number More...
 
void i2c_write (I2C_MODULE i2c_id, uint8_t address, uint8_t *data, int len)
 
ATCA_STATUS i2c_read (I2C_MODULE i2c_id, uint8_t address, uint8_t *data, uint16_t len)
 
void delay_us (UINT32 delay)
 
void delay_us (uint32_t delay)
 
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.This function is currently not supported. of the a-priori knowledge More...
 
ATCA_STATUS hal_swi_discover_devices (int bus_num, ATCAIfaceCfg cfg[], int *found)
 discover any CryptoAuth devices on a given logical bus number.This function is curently not supported. 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_send_flag (ATCAIface iface, uint8_t data)
 HAL implementation of SWI send one byte over UART. More...
 
char * strnchr (const char *s, size_t count, int c)
 
char kit_id_from_devtype (ATCADeviceType devtype)
 
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, const 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 (const uint8_t *txdata, int txlen, char *pkitcmd, int *nkitcmd, char target)
 Wrap binary bytes in ascii kit protocol. More...
 
ATCA_STATUS kit_parse_rsp (const 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

atcahid_t _gHid
 
ATCAI2CMaster_ti2c_hal_data [MAX_I2C_BUSES]
 
int i2c_bus_ref_ct = 0
 
atcacdc_t _gCdc
 
char * dev = "/dev/ttyACM0"
 
int speed = B115200
 
atcahid_t _gHid
 
atcahid_t _gHid
 
struct port_config pin_conf
 

Detailed Description

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 driver of Harmony.

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.

Macro Definition Documentation

◆ CDC_BUFFER_MAX

#define CDC_BUFFER_MAX   1024

◆ CDC_DEVICES_MAX

#define CDC_DEVICES_MAX   10

◆ CPU_CLOCK

#define CPU_CLOCK   (80000000UL)

◆ DEBUG_PIN_1

#define DEBUG_PIN_1   EXT2_PIN_5

◆ DEBUG_PIN_2

#define DEBUG_PIN_2   EXT2_PIN_6

◆ GetInstructionClock

#define GetInstructionClock ( )    (GetSystemClock())

◆ GetPeripheralClock

#define GetPeripheralClock ( )    (GetSystemClock() / (1 << OSCCONbits.PBDIV))

◆ GetSystemClock [1/2]

#define GetSystemClock ( )    (80000000ul)

◆ GetSystemClock [2/2]

#define GetSystemClock ( )    (200000000UL)/* Fcy = 200MHz */

◆ HARMONY_I2C_DRIVER

#define HARMONY_I2C_DRIVER   1

◆ HID_DEVICES_MAX [1/3]

#define HID_DEVICES_MAX   10

◆ HID_DEVICES_MAX [2/3]

#define HID_DEVICES_MAX   10

◆ HID_DEVICES_MAX [3/3]

#define HID_DEVICES_MAX   10

◆ HID_GUID

#define HID_GUID   { 0x4d1e55b2, 0xf16f, 0x11cf, 0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 }

◆ HID_PACKET_MAX [1/3]

#define HID_PACKET_MAX   512

◆ HID_PACKET_MAX [2/3]

#define HID_PACKET_MAX   512

◆ HID_PACKET_MAX [3/3]

#define HID_PACKET_MAX   512

◆ INVALID_HANDLE_VALUE

#define INVALID_HANDLE_VALUE   ((int)(-1))

◆ KIT_MAX_SCAN_COUNT

#define KIT_MAX_SCAN_COUNT   4

◆ KIT_MAX_TX_BUF

#define KIT_MAX_TX_BUF   32

◆ KIT_MSG_SIZE

#define KIT_MSG_SIZE   (32)

◆ KIT_RX_WRAP_SIZE

#define KIT_RX_WRAP_SIZE   (KIT_MSG_SIZE + 6)

◆ KIT_TX_WRAP_SIZE

#define KIT_TX_WRAP_SIZE   (7)

◆ max

#define max (   a,
 
)    (((a) > (b)) ? (a) : (b))

◆ MAX_I2C_BUSES [1/11]

#define MAX_I2C_BUSES   2

◆ MAX_I2C_BUSES [2/11]

#define MAX_I2C_BUSES   2

◆ MAX_I2C_BUSES [3/11]

#define MAX_I2C_BUSES   6

◆ MAX_I2C_BUSES [4/11]

#define MAX_I2C_BUSES   6

◆ MAX_I2C_BUSES [5/11]

#define MAX_I2C_BUSES   3

◆ MAX_I2C_BUSES [6/11]

#define MAX_I2C_BUSES   4

◆ MAX_I2C_BUSES [7/11]

#define MAX_I2C_BUSES   3

◆ MAX_I2C_BUSES [8/11]

#define MAX_I2C_BUSES   2

◆ MAX_I2C_BUSES [9/11]

#define MAX_I2C_BUSES   1

◆ MAX_I2C_BUSES [10/11]

#define MAX_I2C_BUSES   2

◆ MAX_I2C_BUSES [11/11]

#define MAX_I2C_BUSES   4

◆ MAX_SWI_BUSES [1/4]

#define MAX_SWI_BUSES   6
  • this HAL implementation assumes you've included the ASF SERCOM UART libraries in your project, otherwise, the HAL layer will not compile because the ASF UART drivers are a dependency *

◆ MAX_SWI_BUSES [2/4]

#define MAX_SWI_BUSES   1
  • this HAL implementation assumes you've included the ASF UART libraries in your project, otherwise, the HAL layer will not compile because the ASF UART drivers are a dependency *

◆ MAX_SWI_BUSES [3/4]

#define MAX_SWI_BUSES   6
  • this HAL implementation assumes you've included the ASF UART libraries in your project, otherwise, the HAL layer will not compile because the ASF UART drivers are a dependency *

◆ MAX_SWI_BUSES [4/4]

#define MAX_SWI_BUSES   6
  • this HAL implementation assumes you've included the ASF SERCOM UART libraries in your project, otherwise, the HAL layer will not compile because the ASF UART drivers are a dependency *

◆ min

#define min (   a,
 
)    (((a) < (b)) ? (a) : (b))

◆ RECEIVE_MODE [1/4]

#define RECEIVE_MODE   0

◆ RECEIVE_MODE [2/4]

#define RECEIVE_MODE   0

◆ RECEIVE_MODE [3/4]

#define RECEIVE_MODE   0

◆ RECEIVE_MODE [4/4]

#define RECEIVE_MODE   0

◆ RX_DELAY [1/4]

#define RX_DELAY   10

◆ RX_DELAY [2/4]

#define RX_DELAY   10

◆ RX_DELAY [3/4]

#define RX_DELAY   10

◆ RX_DELAY [4/4]

#define RX_DELAY   10

◆ SWI_FLAG_CMD

#define SWI_FLAG_CMD   ((uint8_t)0x77)

flag preceding a command

◆ SWI_FLAG_IDLE

#define SWI_FLAG_IDLE   ((uint8_t)0xBB)

flag requesting to go into Idle mode

◆ SWI_FLAG_SLEEP

#define SWI_FLAG_SLEEP   ((uint8_t)0xCC)

flag requesting to go into Sleep mode

◆ SWI_FLAG_TX

#define SWI_FLAG_TX   ((uint8_t)0x88)

flag requesting a response

◆ SWI_WAKE_TOKEN

#define SWI_WAKE_TOKEN   ((uint8_t)0x00)

flag preceding a command

◆ TRANSMIT_MODE [1/4]

#define TRANSMIT_MODE   1

◆ TRANSMIT_MODE [2/4]

#define TRANSMIT_MODE   1

◆ TRANSMIT_MODE [3/4]

#define TRANSMIT_MODE   1

◆ TRANSMIT_MODE [4/4]

#define TRANSMIT_MODE   1

◆ TX_DELAY [1/4]

#define TX_DELAY   90

◆ TX_DELAY [2/4]

#define TX_DELAY   90

◆ TX_DELAY [3/4]

#define TX_DELAY   90

◆ TX_DELAY [4/4]

#define TX_DELAY   93

◆ us_SCALE [1/2]

#define us_SCALE   ((CPU_CLOCK / 2) / 1000000)

◆ us_SCALE [2/2]

#define us_SCALE   (GetSystemClock() / 2000000)

Typedef Documentation

◆ atcacdc_t

typedef struct atcacdc atcacdc_t

◆ atcahid_t [1/3]

typedef struct atcahid atcahid_t

◆ atcahid_t [2/3]

typedef struct atcahid atcahid_t

◆ atcahid_t [3/3]

typedef struct atcahid atcahid_t

◆ ATCAI2CMaster_t [1/12]

◆ ATCAI2CMaster_t [2/12]

this is the hal_data for ATCA HAL created using ASF

◆ ATCAI2CMaster_t [3/12]

this is the hal_data for ATCA HAL for ASF

◆ ATCAI2CMaster_t [4/12]

this is the hal_data for ATCA HAL for Atmel START SERCOM

◆ ATCAI2CMaster_t [5/12]

this is the hal_data for ATCA HAL created using ASF

◆ ATCAI2CMaster_t [6/12]

this is the hal_data for ATCA HAL

◆ ATCAI2CMaster_t [7/12]

this is the hal_data for ATCA HAL for ASF SERCOM

◆ ATCAI2CMaster_t [8/12]

this is the hal_data for ATCA HAL for ASF SERCOM

◆ ATCAI2CMaster_t [9/12]

this is the hal_data for ATCA HAL

◆ ATCAI2CMaster_t [10/12]

this is the hal_data for ATCA HAL

◆ ATCAI2CMaster_t [11/12]

this is the hal_data for ATCA HAL

◆ ATCAI2CMaster_t [12/12]

This is the hal_data for ATCA HAL.

◆ ATCASWIMaster_t [1/5]

this is the hal_data for ATCA HAL for SWI UART

◆ ATCASWIMaster_t [2/5]

this is the hal_data for ATCA HAL for SWI UART

◆ ATCASWIMaster_t [3/5]

this is the hal_data for ATCA HAL for ASF SERCOM

◆ ATCASWIMaster_t [4/5]

this is the hal_data for ATCA HAL for ASF SERCOM

◆ ATCASWIMaster_t [5/5]

This is the hal_data for ATCA HAL.

◆ cdc_device_t

typedef struct cdc_device cdc_device_t

◆ HANDLE

typedef int HANDLE

◆ hid_device_t [1/2]

typedef struct hid_device hid_device_t

◆ hid_device_t [2/2]

typedef struct hid_device hid_device_t

Enumeration Type Documentation

◆ i2c_read_write_flag

This enumeration lists flags for I2C read or write addressing.

Enumerator
I2C_WRITE 

write command flag

I2C_READ 

read command flag

◆ swi_flag

enum swi_flag

This enumeration lists flags for SWI.

Enumerator
SWI_FLAG_CMD 

flag preceding a command

SWI_FLAG_TX 

flag requesting a response

SWI_FLAG_IDLE 

flag requesting to go into Idle mode

SWI_FLAG_SLEEP 

flag requesting to go into Sleep mode

Function Documentation

◆ atca_delay_10us()

void atca_delay_10us ( uint32_t  delay)

This function delays for a number of tens of microseconds.

Parameters
[in]delaynumber of 0.01 milliseconds to delay

◆ atca_delay_ms()

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.

Parameters
[in]delaynumber of milliseconds to delay

◆ atca_delay_us()

void atca_delay_us ( uint32_t  delay)

Timer API implemented at the HAL level.

This function delays for a number of microseconds.

Parameters
[in]delaynumber of microseconds to delay
[in]delaynumber of 0.001 milliseconds to delay

◆ change_i2c_speed()

void change_i2c_speed ( ATCAIface  iface,
uint32_t  speed 
)

method to change the bus speed of I2C

method to change the bus speed of I2C.This function is not used in Linux.

method to change the bus speec of I2C

Parameters
[in]ifaceinterface on which to change bus speed
[in]speedbaud rate (typically 100000 or 400000)
[in]ifaceinterface on which to change bus speed
[in]speedbaud rate (typically 100000 or 400000)
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ delay_us() [1/2]

void delay_us ( UINT32  delay)

◆ delay_us() [2/2]

void delay_us ( uint32_t  delay)

◆ hal_cdc_discover_buses()

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.This function is currently not implemented.

Parameters
[in]cdc_buses- an array of logical bus numbers
[in]max_buses- maximum number of buses the app wants to attempt to discover
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_cdc_discover_devices()

ATCA_STATUS hal_cdc_discover_devices ( int  bus_num,
ATCAIfaceCfg  cfg[],
int *  found 
)

discover any CryptoAuth devices on a given logical bus number

Parameters
[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
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_check_wake()

ATCA_STATUS hal_check_wake ( const uint8_t *  response,
int  response_size 
)

Utility function for hal_wake to check the reply.

Parameters
[in]responseWake response to be checked.
[in]response_sizeSize of the response to check.
Returns
ATCA_SUCCESS for expected wake, ATCA_STATUS_SELFTEST_ERROR if the power on self test failed, ATCA_WAKE_FAILED for other failures.

◆ hal_create_mutex()

ATCA_STATUS hal_create_mutex ( void **  ppMutex,
char *  pName 
)

Optional hal interfaces.

◆ hal_destroy_mutex()

ATCA_STATUS hal_destroy_mutex ( void *  pMutex)

◆ hal_i2c_discover_buses()

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 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.

This HAL implementation assumes you've included the Plib libraries in your project, otherwise, the HAL layer will not compile because the Plib 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.This function is not implemented.

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

Parameters
[in]i2c_busesan array of logical bus numbers
[in]max_busesmaximum number of buses the app wants to attempt to discover
Returns
ATCA_SUCCESS on success, otherwise an error code.
Parameters
[in]i2c_buses- an array of logical bus numbers
[in]max_buses- maximum number of buses the app wants to attempt to discover
Returns
ATCA_SUCCESS on success, otherwise an error code.
Parameters
[in]i2c_buses- an array of logical bus numbers
[in]max_buses- maximum number of buses the app wants to attempt to discover
Returns
ATCA_SUCCESS
Parameters
[in]i2c_buses- an array of logical bus numbers
[in]max_buses- maximum number of buses the app wants to attempt to discover
Returns
ATCA_UNIMPLEMENTED

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.This function is currently not implemented.

Parameters
[in]i2c_buses- an array of logical bus numbers
[in]max_buses- maximum number of buses the app wants to attempt to discover
Returns
ATCA_UNIMPLEMENTED

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

Parameters
[in]i2c_buses- an array of logical bus numbers
[in]max_buses- maximum number of buses the app wants to attempt to discover
Returns
ATCA_SUCCESS

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

Parameters
[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

◆ hal_i2c_discover_devices()

ATCA_STATUS hal_i2c_discover_devices ( int  bus_num,
ATCAIfaceCfg  cfg[],
int *  found 
)

discover any CryptoAuth devices on a given logical bus number

discover any CryptoAuth devices on a given logical bus number.This function is currently not implemented.

Parameters
[in]bus_numlogical bus number on which to look for CryptoAuth devices
[out]cfgpointer to head of an array of interface config structures which get filled in by this method
[out]foundnumber of devices found on this bus
Returns
ATCA_SUCCESS on success, otherwise an error code.
Parameters
[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
Returns
ATCA_SUCCESS on success, otherwise an error code.
Parameters
[in]bus_numlogical bus number on which to look for CryptoAuth devices
[out]cfgpointer to head of an array of interface config structures which get filled in by this method
[out]foundnumber of devices found on this bus
Returns
ATCA_SUCCESS
Parameters
[in]bus_numlogical bus number on which to look for CryptoAuth devices
[out]cfgpointer to head of an array of interface config structures which get filled in by this method
[out]foundnumber of devices found on this bus
Returns
ATCA_UNIMPLEMENTED
Parameters
[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
Returns
ATCA_UNIMPLEMENTED
Parameters
[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
Returns
ATCA_SUCCESS
Parameters
[in]bus_numLogical bus number on which to look for CryptoAuth devices
[out]cfgPointer to head of an array of interface config structures which get filled in by this method
[out]foundNumber of devices found on this bus
Returns
ATCA_SUCCESS on success, otherwise an error code.

default configuration, to be reused during discovery process

default configuration, to be reused during discovery process

default configuration, to be reused during discovery process

default configuration, to be reused during discovery process

default configuration, to be reused during discovery process

default configuration, to be reused during discovery process

default configuration, to be reused during discovery process

default configuration, to be reused during discovery process

◆ hal_i2c_idle()

ATCA_STATUS hal_i2c_idle ( ATCAIface  iface)

idle CryptoAuth device using I2C bus

Parameters
[in]ifaceinterface to logical device to idle
Returns
ATCA_SUCCESS on success, otherwise an error code.
Parameters
[in]ifaceinterface to logical device to idle
Returns
ATCA_SUCCESS

< Word Address Value = Idle

◆ hal_i2c_init()

ATCA_STATUS hal_i2c_init ( void *  hal,
ATCAIfaceCfg cfg 
)

initialize an I2C interface using given config

HAL implementation of I2C init.

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.

Parameters
[in]halopaque ptr to HAL data
[in]cfgpointer to interface configuration
Returns
ATCA_SUCCESS on success, otherwise an error code.

Initialize an I2C interface using given config.

Parameters
[in]halopaque pointer to HAL data
[in]cfginterface configuration
Returns
ATCA_SUCCESS on success, otherwise an error code.
  • this HAL implementation assumes you've included the START Twi libraries in your project, otherwise, the HAL layer will not compile because the START TWI drivers are a dependency *initialize an I2C interface using given config
    Parameters
    [in]hal- opaque ptr to HAL data
    [in]cfg- interface configuration
    Returns
    ATCA_SUCCESS on success, otherwise an error code.
    this implementation assumes I2C peripheral has been enabled by user. It only initialize an I2C interface using given config.
Parameters
[in]halpointer to HAL specific data that is maintained by this HAL
[in]cfgpointer to HAL specific configuration data that is used to initialize this HAL
Returns
ATCA_SUCCESS on success, otherwise an error code.

initialize an I2C interface using given config

Parameters
[in]hal- opaque ptr to HAL data
[in]cfg- interface configuration
Returns
ATCA_SUCCESS on success, otherwise an error code.
  • this HAL implementation assumes you've included the ASF I2C libraries in your project, otherwise, the HAL layer will not compile because the ASF I2C drivers are a dependency *initialize an I2C interface using given config
    Parameters
    [in]hal- opaque ptr to HAL data
    [in]cfg- interface configuration
    Returns
    ATCA_SUCCESS on success, otherwise an error code.
  • this HAL implementation assumes you've included the ASF SERCOM I2C libraries in your project, otherwise, the HAL layer will not compile because the ASF I2C drivers are a dependency *initialize an I2C interface using given config
    Parameters
    [in]hal- opaque ptr to HAL data
    [in]cfg- interface configuration
    Returns
    ATCA_SUCCESS on success, otherwise an error code.
  • 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 *initialize an I2C interface using given config
    Parameters
    [in]hal- opaque ptr to HAL data
    [in]cfg- interface configuration
    Returns
    ATCA_SUCCESS on success, otherwise an error code.

◆ hal_i2c_post_init()

ATCA_STATUS hal_i2c_post_init ( ATCAIface  iface)

HAL implementation of I2C post init.

Parameters
[in]ifaceinstance
Returns
ATCA_SUCCESS on success, otherwise an error code.
Parameters
[in]ifaceinstance
Returns
ATCA_STATUS
Parameters
[in]ifaceinstance
Returns
ATCA_SUCCESS

◆ hal_i2c_receive()

ATCA_STATUS hal_i2c_receive ( ATCAIface  iface,
uint8_t *  rxdata,
uint16_t *  rxlength 
)

HAL implementation of I2C receive function for ASF I2C.

HAL implementation of I2C receive function.

HAL implementation of I2C receive function for START I2C.

HAL implementation of receive bytes via I2C bit-banged.

Parameters
[in]ifaceDevice to interact with.
[out]rxdataData received will be returned here.
[in,out]rxlengthAs input, the size of the rxdata buffer. As output, the number of bytes received.
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_i2c_release()

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

manages reference count on given bus and releases resource if no more references exist

Parameters
[in]hal_data- opaque pointer to hal data structure - known only to the HAL implementation
Returns
ATCA_SUCCESS on success, otherwise an error code.
Parameters
[in]hal_dataopaque pointer to hal data structure - known only to the HAL implementation
Returns
ATCA_SUCCESS on success, otherwise an error code.
Parameters
[in]hal_data- opaque pointer to hal data structure - known only to the HAL implementation
Returns
ATCA_SUCESS
Parameters
[in]hal_data- opaque pointer to hal data structure - known only to the HAL implementation
Returns
ATCA_SUCCESS
Parameters
[in]hal_data- opaque pointer to hal data structure - known only to the HAL implementation return ATCA_SUCCESS

◆ hal_i2c_send()

ATCA_STATUS hal_i2c_send ( ATCAIface  iface,
uint8_t *  txdata,
int  txlength 
)

HAL implementation of I2C send over ASF.

HAL implementation of I2C send.

HAL implementation of I2C send over START.

HAL implementation of Send byte(s) via I2C.

Parameters
[in]ifaceinstance
[in]txdatapointer to space to bytes to send
[in]txlengthnumber of bytes to send
Returns
ATCA_SUCCESS on success, otherwise an error code.
Parameters
[in]ifaceinterface of the logical device to send data to
[in]txdatapointer to bytes to send
[in]txlengthnumber of bytes to send
Returns
ATCA_SUCCESS on success, otherwise an error code.

< 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

◆ hal_i2c_sleep()

ATCA_STATUS hal_i2c_sleep ( ATCAIface  iface)

sleep CryptoAuth device using I2C bus

Parameters
[in]ifaceinterface to logical device to sleep
Returns
ATCA_SUCCESS on success, otherwise an error code.
Parameters
[in]ifaceinterface to logical device to sleep
Returns
ATCA_SUCESS

< Word Address Value = Sleep

◆ hal_i2c_wake()

ATCA_STATUS hal_i2c_wake ( ATCAIface  iface)

wake up CryptoAuth device using I2C bus

Parameters
[in]ifaceinterface to logical device to wakeup
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_iface_init()

ATCA_STATUS hal_iface_init ( ATCAIfaceCfg cfg,
ATCAHAL_t hal 
)

Standard HAL API for ATCA to initialize a physical interface.

Parameters
[in]cfgpointer to ATCAIfaceCfg object
[in]halpointer to ATCAHAL_t intermediate data structure
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_iface_release()

ATCA_STATUS hal_iface_release ( ATCAIfaceType  iface_type,
void *  hal_data 
)

releases a physical interface, HAL knows how to interpret hal_data

Parameters
[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
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_cdc_discover_buses()

ATCA_STATUS hal_kit_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.This function is currently not implemented.

Parameters
[in]cdc_buses- an array of logical bus numbers
[in]max_buses- maximum number of buses the app wants to attempt to discover
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_cdc_discover_devices()

ATCA_STATUS hal_kit_cdc_discover_devices ( int  bus_num,
ATCAIfaceCfg cfg,
int *  found 
)

discover any CryptoAuth devices on a given logical bus number

Parameters
[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
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_cdc_idle()

ATCA_STATUS hal_kit_cdc_idle ( ATCAIface  iface)

Call the idle for kit protocol over USB CDC.

Parameters
[in]ifaceATCAIface instance that is the interface object to send the bytes over
Returns
ATCA_SUCCESS on success, otherwise an error code.S

◆ hal_kit_cdc_init()

ATCA_STATUS hal_kit_cdc_init ( void *  hal,
ATCAIfaceCfg cfg 
)

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"

Parameters
[in]halpointer to HAL specific data that is maintained by this HAL
[in]cfgpointer to HAL specific configuration data that is used to initialize this HAL
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_cdc_post_init()

ATCA_STATUS hal_kit_cdc_post_init ( ATCAIface  iface)

HAL implementation of Kit USB CDC post init.

Parameters
[in]ifaceinstance
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_cdc_receive()

ATCA_STATUS hal_kit_cdc_receive ( ATCAIface  iface,
uint8_t *  rxdata,
uint16_t *  rxsize 
)

HAL implementation of kit protocol receive over USB CDC.

Parameters
[in]ifaceDevice to interact with.
[out]rxdataData received will be returned here.
[in,out]rxsizeAs input, the size of the rxdata buffer. As output, the number of bytes received.
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_cdc_release()

ATCA_STATUS hal_kit_cdc_release ( void *  hal_data)

Close the physical port for CDC over USB CDC.

Parameters
[in]hal_dataThe hardware abstraction data specific to this HAL
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_cdc_send()

ATCA_STATUS hal_kit_cdc_send ( ATCAIface  iface,
uint8_t *  txdata,
int  txlength 
)

HAL implementation of kit protocol send over USB CDC.

Parameters
[in]ifaceinstance
[in]txdatapointer to bytes to send
[in]txlengthnumber of bytes to send
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_cdc_sleep()

ATCA_STATUS hal_kit_cdc_sleep ( ATCAIface  iface)

Call the sleep for kit protocol over USB CDC.

Parameters
[in]ifaceATCAIface instance that is the interface object to send the bytes over
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_cdc_wake()

ATCA_STATUS hal_kit_cdc_wake ( ATCAIface  iface)

Call the wake for kit protocol over USB CDC.

Parameters
[in]ifaceATCAIface instance that is the interface object to send the bytes over
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_hid_discover_buses()

ATCA_STATUS hal_kit_hid_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

discover all HID kits available.This function is currently not implemented. this maintains a list of logical to physical bus mappings freeing the application of the a-priori knowledge

discover hid buses available for this hardware this maintains a list of logical to physical bus mappings freeing the application of the a-priori knowledge.This function is currently not implemented.

Parameters
[in]cdc_buses- an array of logical bus numbers
[in]max_buses- maximum number of buses the app wants to attempt to discover
[in]cdc_buses- an array of logical bus numbers
[in]max_buses- maximum number of buses the app wants to attempt to discover
Returns
ATCA_UNIMPLEMENTED
Parameters
[in]cdc_busesan array of logical bus numbers
[in]max_busesmaximum number of buses the app wants to attempt to discover
Returns
ATCA_UNIMPLEMENTED

◆ hal_kit_hid_discover_devices()

ATCA_STATUS hal_kit_hid_discover_devices ( int  bus_num,
ATCAIfaceCfg  cfg[],
int *  found 
)

discover any CryptoAuth devices on a given logical bus number

discover any CryptoAuth devices on a given logical bus number.This function is currently not implemented.

Parameters
[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
Returns
ATCA_UNIMPLEMENTED

◆ hal_kit_hid_idle()

ATCA_STATUS hal_kit_hid_idle ( ATCAIface  iface)

Call the idle for kit protocol.

Call the idle for kit protocol over USB HID.

Parameters
[in]ifaceATCAIface instance that is the interface object to send the bytes over
Returns
ATCA_STATUS
Parameters
[in]ifaceATCAIface instance that is the interface object to send the bytes over
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_hid_init()

ATCA_STATUS hal_kit_hid_init ( void *  hal,
ATCAIfaceCfg cfg 
)

HAL implementation of Kit USB HID init.

Parameters
[in]halpointer to HAL specific data that is maintained by this HAL
[in]cfgpointer to HAL specific configuration data that is used to initialize this HAL
Returns
ATCA_STATUS
Parameters
[in]halpointer to HAL specific data that is maintained by this HAL
[in]cfgpointer to HAL specific configuration data that is used to initialize this HAL
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_hid_post_init()

ATCA_STATUS hal_kit_hid_post_init ( ATCAIface  iface)

HAL implementation of Kit HID post init.

Parameters
[in]ifaceinstance
Returns
ATCA_STATUS
Parameters
[in]ifaceinstance
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_hid_receive()

ATCA_STATUS hal_kit_hid_receive ( ATCAIface  iface,
uint8_t *  rxdata,
uint16_t *  rxsize 
)

HAL implementation of send over USB HID.

Parameters
[in]ifaceinstance
[in]rxdatapointer to space to receive the data
[in,out]rxsizeptr to expected number of receive bytes to request
Returns
ATCA_STATUS
Parameters
[in]ifaceinstance
[in]rxdatapointer to space to receive the data
[in,out]rxsizeptr to expected number of receive bytes to request
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_hid_release()

ATCA_STATUS hal_kit_hid_release ( void *  hal_data)

Close the physical port for HID.

Parameters
[in]hal_dataThe hardware abstraction data specific to this HAL
Returns
ATCA_STATUS
Parameters
[in]hal_dataThe hardware abstraction data specific to this HAL
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_hid_send()

ATCA_STATUS hal_kit_hid_send ( ATCAIface  iface,
uint8_t *  txdata,
int  txlength 
)

HAL implementation of kit protocol send over USB HID.

Parameters
[in]ifaceinstance
[in]txdatapointer to bytes to send
[in]txlengthnumber of bytes to send
Returns
ATCA_STATUS
Parameters
[in]ifaceinstance
[in]txdatapointer to bytes to send
[in]txlengthnumber of bytes to send
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_hid_sleep()

ATCA_STATUS hal_kit_hid_sleep ( ATCAIface  iface)

Call the sleep for kit protocol.

Call the sleep for kit protocol over USB HID.

Parameters
[in]ifaceATCAIface instance that is the interface object to send the bytes over
Returns
ATCA_STATUS
Parameters
[in]ifaceATCAIface instance that is the interface object to send the bytes over
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_hid_wake()

ATCA_STATUS hal_kit_hid_wake ( ATCAIface  iface)

Call the wake for kit protocol.

Call the wake for kit protocol over USB HID.

Parameters
[in]ifaceATCAIface instance that is the interface object to send the bytes over
Returns
ATCA_STATUS
Parameters
[in]ifaceATCAIface instance that is the interface object to send the bytes over
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_kit_phy_num_found()

ATCA_STATUS hal_kit_phy_num_found ( int8_t *  num_found)

Number of USB CDC devices found.

Parameters
[out]num_found
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_lock_mutex()

ATCA_STATUS hal_lock_mutex ( void *  pMutex)

◆ hal_swi_discover_buses()

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.This function is currently not supported. of the a-priori knowledge

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

Parameters
[in]swi_buses- an array of logical bus numbers
[in]max_buses- maximum number of buses the app wants to attempt to discover
Returns
ATCA_UNIMPLEMENTED
Parameters
[in]swi_buses- an array of logical bus numbers
[in]max_buses- maximum number of buses the app wants to attempt to discover
Returns
ATCA_SUCCESS

◆ hal_swi_discover_devices()

ATCA_STATUS hal_swi_discover_devices ( int  bus_num,
ATCAIfaceCfg  cfg[],
int *  found 
)

discover any CryptoAuth devices on a given logical bus number.This function is curently not supported.

discover any CryptoAuth devices on a given logical bus number

Parameters
[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
Returns
ATCA_UNIMPLEMENTED
Parameters
[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
Returns
ATCA_SUCCESS

default configuration, to be reused during discovery process

◆ hal_swi_idle()

ATCA_STATUS hal_swi_idle ( ATCAIface  iface)

Send Idle flag via SWI.

idle CryptoAuth device using SWI interface

Parameters
[in]ifaceinterface of the logical device to idle
Returns
ATCA_SUCCES
Parameters
[in]ifaceinterface to logical device to idle
Returns
ATCA_SUCCESS on success, otherwise an error code.

Set SWI pin

◆ hal_swi_init()

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.

Parameters
[in]halopaque pointer to HAL data
[in]cfginterface configuration
Returns
ATCA_SUCCESS on success, otherwise an error code.

initialize an SWI interface using given config

Parameters
[in]hal- opaque ptr to HAL data
[in]cfg- interface configuration
Returns
ATCA_SUCCESS on success, otherwise an error code.

assign GPIO pin

◆ hal_swi_post_init()

ATCA_STATUS hal_swi_post_init ( ATCAIface  iface)

HAL implementation of SWI post init.

Parameters
[in]ifaceATCAIface instance
Returns
ATCA_SUCCESS
Parameters
[in]ifaceinstance
Returns
ATCA_SUCCESS

◆ hal_swi_receive()

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.

Parameters
[in]ifaceDevice to interact with.
[out]rxdataData received will be returned here.
[in,out]rxlengthAs input, the size of the rxdata buffer. As output, the number of bytes received.
Returns
ATCA_SUCCESS on success, otherwise an error code.

Set SWI pin

◆ hal_swi_release()

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

Parameters
[in]hal_dataopaque pointer to hal data structure - known only to the HAL implementation
Returns
ATCA_SUCCESS
Parameters
[in]hal_data- opaque pointer to hal data structure - known only to the HAL implementation
Returns
ATCA_SUCCESS on success, otherwise an error code.

if the use count for this bus has gone to 0 references, disable it. protect against an unbracketed release

◆ hal_swi_send()

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.

Parameters
[in]ifaceinterface of the logical device to send data to
[in]txdatapointer to bytes to send
[in]txlengthnumber of bytes to send
Returns
ATCA_SUCCESS
Parameters
[in]ifaceinstance
[in]txdatapointer to space to bytes to send
[in]txlengthnumber of bytes to send
Returns
ATCA_SUCCESS on success, otherwise an error code.

Skip the Word Address data as SWI doesn't use it

Set SWI pin

Send Command Flag

Send the remaining bytes

◆ hal_swi_send_flag()

ATCA_STATUS hal_swi_send_flag ( ATCAIface  iface,
uint8_t  data 
)

HAL implementation of SWI send one byte over UART.

Parameters
[in]ifaceinstance
[in]databytes to send
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_swi_sleep()

ATCA_STATUS hal_swi_sleep ( ATCAIface  iface)

Send Sleep flag via SWI.

sleep CryptoAuth device using SWI interface

Parameters
[in]ifaceinterface of the logical device to sleep
Returns
ATCA_SUCCESS
Parameters
[in]ifaceinterface to logical device to sleep
Returns
ATCA_SUCCESS on success, otherwise an error code.

Set SWI pin

◆ hal_swi_wake()

ATCA_STATUS hal_swi_wake ( ATCAIface  iface)

Send Wake flag via SWI.

wake up CryptoAuth device using SWI interface

Parameters
[in]ifaceinterface of the logical device to wake up
Returns
ATCA_SUCCESS on success, otherwise an error code.
Parameters
[in]ifaceinterface to logical device to wakeup
Returns
ATCA_SUCCESS on success, otherwise an error code.

Set SWI pin

Generate Wake Token

Wait tWHI + tWLO

◆ hal_unlock_mutex()

ATCA_STATUS hal_unlock_mutex ( void *  pMutex)

◆ i2c_read()

ATCA_STATUS i2c_read ( I2C_MODULE  i2c_id,
uint8_t  address,
uint8_t *  data,
uint16_t  len 
)

◆ i2c_write()

void i2c_write ( I2C_MODULE  i2c_id,
uint8_t  address,
uint8_t *  data,
int  len 
)

◆ kit_id_from_devtype()

char kit_id_from_devtype ( ATCADeviceType  devtype)

Kit Protocol is key

◆ kit_idle()

ATCA_STATUS kit_idle ( ATCAIface  iface)

Call the idle for kit protocol.

Parameters
[in]ifacethe interface object to send the bytes over
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ kit_init()

ATCA_STATUS kit_init ( ATCAIface  iface)

HAL implementation of kit protocol init. This function calls back to the physical protocol to send the bytes.

Parameters
[in]ifaceinstance
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ kit_parse_rsp()

ATCA_STATUS kit_parse_rsp ( const char *  pkitbuf,
int  nkitbuf,
uint8_t *  kitstatus,
uint8_t *  rxdata,
int *  datasize 
)

Parse the response ascii from the kit.

Parameters
[out]pkitbufpointer to ascii kit protocol data to parse
[in]nkitbuflength of the ascii kit protocol data
[in]kitstatusstatus of the ascii device
[in]rxdatapointer to the binary data buffer
[in]datasizesize of the pointer to the binary data buffer
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ kit_phy_num_found()

ATCA_STATUS kit_phy_num_found ( int8_t *  num_found)

Number of USB HID devices found.

Parameters
[out]num_found
Returns
ATCA_STATUS
Parameters
[out]num_found
Returns
ATCA_SUCCESS on success, otherwise an error code.
Parameters
[out]num_found
Returns
SUCCESS

◆ kit_phy_receive() [1/2]

ATCA_STATUS kit_phy_receive ( ATCAIface  iface,
char *  rxdata,
int *  rxsize 
)

HAL implementation of kit protocol receive data.It is called by the top layer.

Parameters
[in]ifaceinstance
[out]rxdatapointer to space to receive the data
[in,out]rxsizeptr to expected number of receive bytes to request
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ kit_phy_receive() [2/2]

ATCA_STATUS kit_phy_receive ( ATCAIface  iface,
uint8_t *  rxdata,
int *  rxsize 
)

HAL implementation of kit protocol send over USB HID.

HAL implementation of kit protocol receive.This function is called by the top layer.

Parameters
[in]ifaceinstance
[out]rxdatapointer to space to receive the data
[in,out]rxsizeptr to expected number of receive bytes to request
Returns
ATCA_STATUS
Parameters
[in]ifaceinstance
[out]rxdatapointer to space to receive the data
[in,out]rxsizeptr to expected number of receive bytes to request
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ kit_phy_send() [1/2]

ATCA_STATUS kit_phy_send ( ATCAIface  iface,
uint8_t *  txdata,
int  txlength 
)

HAL implementation of send over USB HID.

HAL implementation of send over Kit protocol.This function is called by the top layer.

Parameters
[in]ifaceinstance
[in]txdatapointer to bytes to send
[in]txlengthnumber of bytes to send
Returns
ATCA_STATUS
Parameters
[in]ifaceinstance
[in]txdatapointer to bytes to send
[in]txlengthnumber of bytes to send
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ kit_phy_send() [2/2]

ATCA_STATUS kit_phy_send ( ATCAIface  iface,
const char *  txdata,
int  txlength 
)

HAL implementation of kit protocol send .It is called by the top layer.

Parameters
[in]ifaceinstance
[in]txdatapointer to bytes to send
[in]txlengthnumber of bytes to send
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ kit_receive()

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.

Parameters
[in]ifaceinstance
[in]rxdatapointer to space to receive the data
[in,out]rxsizeptr to expected number of receive bytes to request
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ kit_send()

ATCA_STATUS kit_send ( ATCAIface  iface,
const uint8_t *  txdata,
int  txlength 
)

HAL implementation of kit protocol send. This function calls back to the physical protocol to send the bytes.

Parameters
[in]ifaceinstance
[in]txdatapointer to bytes to send
[in]txlengthnumber of bytes to send
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ kit_sleep()

ATCA_STATUS kit_sleep ( ATCAIface  iface)

Call the sleep for kit protocol.

Parameters
[in]ifacethe interface object to send the bytes over
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ kit_wake()

ATCA_STATUS kit_wake ( ATCAIface  iface)

Call the wake for kit protocol.

Parameters
[in]ifacethe interface object to send the bytes over
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ kit_wrap_cmd()

ATCA_STATUS kit_wrap_cmd ( const uint8_t *  txdata,
int  txlen,
char *  pkitcmd,
int *  nkitcmd,
char  target 
)

Wrap binary bytes in ascii kit protocol.

Parameters
[in]txdataBinary data to wrap.
[in]txlenLength of binary data in bytes.
[out]pkitcmdASCII kit protocol wrapped data is return here.
[in,out]nkitcmdAs input, the size of the pkitcmd buffer. As output, the number of bytes returned in the pkitcmd buffer.
[in]targetTarget char to use 's' for SHA devices, 'e' for ECC devices.
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ strnchr()

char* strnchr ( const char *  s,
size_t  count,
int  c 
)

◆ swi_uart_deinit()

ATCA_STATUS swi_uart_deinit ( ATCASWIMaster_t instance)

Implementation of SWI UART deinit.

HAL implementation of SWI UART deinit.

Parameters
[in]instanceinstance
Returns
ATCA_SUCCESS
Parameters
[in]instanceinstance
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ swi_uart_discover_buses()

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

Parameters
[in]swi_uart_buses- an array of logical bus numbers
[in]max_buses- maximum number of buses the app wants to attempt to discover

◆ swi_uart_init()

ATCA_STATUS swi_uart_init ( ATCASWIMaster_t instance)

Implementation of SWI UART init.

HAL implementation of SWI UART init.

  • this HAL implementation assumes you've included the ASF SERCOM UART libraries in your project, otherwise, the HAL layer will not compile because the ASF UART drivers are a dependency *
    Parameters
    [in]instanceinstance
    Returns
    ATCA_SUCCESS on success, otherwise an error code.
  • this HAL implementation assumes you've included the START SERCOM UART libraries in your project, otherwise, the HAL layer will not compile because the START UART drivers are a dependency *
    Parameters
    [in]instanceinstance
    Returns
    ATCA_SUCCESS on success, otherwise an error code.

◆ swi_uart_mode()

void swi_uart_mode ( ATCASWIMaster_t instance,
uint8_t  mode 
)

implementation of SWI UART change mode.

HAL implementation of SWI UART change mode.

Parameters
[in]instanceinstance
[in]mode(TRANSMIT_MODE or RECEIVE_MODE)

◆ swi_uart_receive_byte()

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.

Parameters
[in]instanceinstance
[in,out]datapointer to space to receive the data
Returns
ATCA_SUCCESS on success, otherwise an error code.
Parameters
[in]instanceinstance
[out]datapointer to space to receive the data
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ swi_uart_send_byte()

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.

Parameters
[in]instanceinstance
[in]databyte to send
Returns
ATCA_SUCCESS on success, otherwise an error code.
Parameters
[in]instanceinstance
[in]datanumber of byte to send
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ swi_uart_setbaud()

void swi_uart_setbaud ( ATCASWIMaster_t instance,
uint32_t  baudrate 
)

implementation of SWI UART change baudrate.

HAL implementation of SWI UART change baudrate.

Parameters
[in]instanceinstance
[in]baudrate(typically 230400 , 160000 or 115200)
[in]instanceinstance
[in]baudrate(typically 230400 or 115200)

Variable Documentation

◆ _gCdc

atcacdc_t _gCdc

◆ _gHid [1/3]

atcahid_t _gHid

◆ _gHid [2/3]

atcahid_t _gHid

◆ _gHid [3/3]

atcahid_t _gHid

◆ dev

char* dev = "/dev/ttyACM0"

◆ i2c_bus_ref_ct

int i2c_bus_ref_ct = 0

◆ i2c_hal_data

◆ pin_conf

struct port_config pin_conf

◆ speed

int speed = B115200