CryptoAuthLib
Atmel CryptoAuthentication Library
atca_iface.h
Go to the documentation of this file.
1 
43 #ifndef ATCA_IFACE_H
44 #define ATCA_IFACE_H
45 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 #include "atca_command.h"
57 
58 typedef enum {
64  // additional physical interface types here
66 
67 /* ATCAIfaceCfg is a mediator object between a completely abstract notion of a physical interface and an actual physical interface.
68 
69  The main purpose of it is to keep hardware specifics from bleeding into the higher levels - hardware specifics could include
70  things like framework specific items (ASF SERCOM) vs a non-Atmel I2C library constant that defines an I2C port. But I2C has
71  roughly the same parameters regardless of architecture and framework. I2C
72  */
73 
74 typedef struct {
75 
76  ATCAIfaceType iface_type; // active iface - how to interpret the union below
77  ATCADeviceType devtype; // explicit device type
78 
79  union { // each instance of an iface cfg defines a single type of interface
80  struct ATCAI2C {
81  uint8_t slave_address; // 8-bit slave address
82  uint8_t bus; // logical i2c bus number, 0-based - HAL will map this to a pin pair for SDA SCL
83  uint32_t baud; // typically 400000
84  } atcai2c;
85 
86  struct ATCASWI {
87  uint8_t bus; // logical SWI bus - HAL will map this to a pin or uart port
88  } atcaswi;
89 
90  struct ATCAUART {
91  int port; // logic port number
92  uint32_t baud; // typically 115200
93  uint8_t wordsize; // usually 8
94  uint8_t parity; // 0 == even, 1 == odd, 2 == none
95  uint8_t stopbits; // 0,1,2
96  } atcauart;
97 
98  struct ATCAHID {
99  int idx; // HID enumeration index
100  uint32_t vid; // Vendor ID of kit (0x03EB for CK101)
101  uint32_t pid; // Product ID of kit (0x2312 for CK101)
102  uint32_t packetsize; // Size of the USB packet
103  uint8_t guid[16]; // The GUID for this HID device
104  } atcahid;
105 
106  };
107 
108  uint16_t wake_delay; // microseconds of tWHI + tWLO which varies based on chip type
109  int rx_retries; // the number of retries to attempt for receiving bytes
110  void *cfg_data; // opaque data used by HAL in device discovery
111 } ATCAIfaceCfg;
112 
113 typedef struct atca_iface * ATCAIface;
114 ATCAIface newATCAIface(ATCAIfaceCfg *cfg); // constructor
115 // IFace methods
116 ATCA_STATUS atinit(ATCAIface caiface);
117 ATCA_STATUS atpostinit(ATCAIface caiface);
118 ATCA_STATUS atsend(ATCAIface caiface, uint8_t *txdata, int txlength);
119 ATCA_STATUS atreceive(ATCAIface caiface, uint8_t *rxdata, uint16_t *rxlength);
120 ATCA_STATUS atwake(ATCAIface caiface);
121 ATCA_STATUS atidle(ATCAIface caiface);
122 ATCA_STATUS atsleep(ATCAIface caiface);
123 
124 // accessors
125 ATCAIfaceCfg * atgetifacecfg(ATCAIface caiface);
126 void* atgetifacehaldat(ATCAIface caiface);
127 
128 void deleteATCAIface( ATCAIface *dev ); // destructor
129 /*---- end of OATCAIface ----*/
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif
136 
137 
138 
Definition: atca_iface.h:60
struct atca_iface * ATCAIface
Definition: atca_iface.h:113
uint32_t packetsize
Definition: atca_iface.h:102
char * dev
HAL implementation of Kit USB CDC init.
Definition: hal_linux_kit_cdc.c:84
ATCA_STATUS atidle(ATCAIface caiface)
Definition: atca_iface.c:131
uint8_t slave_address
Definition: atca_iface.h:81
ATCA_STATUS atsleep(ATCAIface caiface)
Definition: atca_iface.c:137
ATCADeviceType
Definition: atca_devtypes.h:53
ATCADeviceType devtype
Definition: atca_iface.h:77
int rx_retries
Definition: atca_iface.h:109
atca_iface is the C object backing ATCAIface. See the atca_iface.h file for details on the ATCAIface ...
Definition: atca_iface.c:57
int idx
Definition: atca_iface.h:99
void * atgetifacehaldat(ATCAIface caiface)
Definition: atca_iface.c:148
ATCA_STATUS atpostinit(ATCAIface caiface)
ATCA_STATUS
Definition: atca_status.h:55
ATCA_STATUS atwake(ATCAIface caiface)
Definition: atca_iface.c:126
ATCAIface newATCAIface(ATCAIfaceCfg *cfg)
constructor for ATCAIface objects
Definition: atca_iface.c:81
ATCA_STATUS atsend(ATCAIface caiface, uint8_t *txdata, int txlength)
Definition: atca_iface.c:116
Definition: atca_iface.h:74
Definition: hal_win_kit_hid.h:66
Atmel Crypto Auth device command object - this is a command builder only, it does not send the comman...
uint32_t vid
Definition: atca_iface.h:100
Definition: atca_iface.h:62
void deleteATCAIface(ATCAIface *caiface)
Definition: atca_iface.c:153
ATCAIfaceCfg * atgetifacecfg(ATCAIface caiface)
Definition: atca_iface.c:143
uint8_t bus
Definition: atca_iface.h:82
void * cfg_data
Definition: atca_iface.h:110
ATCA_STATUS atinit(ATCAIface caiface)
Definition: atca_iface.c:98
uint8_t stopbits
Definition: atca_iface.h:95
Definition: atca_iface.h:59
uint8_t parity
Definition: atca_iface.h:94
uint32_t pid
Definition: atca_iface.h:101
uint8_t wordsize
Definition: atca_iface.h:93
int port
Definition: atca_iface.h:91
ATCAIfaceType iface_type
Definition: atca_iface.h:76
Definition: atca_iface.h:63
uint16_t wake_delay
Definition: atca_iface.h:108
ATCA_STATUS atreceive(ATCAIface caiface, uint8_t *rxdata, uint16_t *rxlength)
Definition: atca_iface.c:121
uint32_t baud
Definition: atca_iface.h:83
ATCAIfaceType
Definition: atca_iface.h:58
Definition: atca_iface.h:61