File tree Expand file tree Collapse file tree 3 files changed +38
-5
lines changed Expand file tree Collapse file tree 3 files changed +38
-5
lines changed Original file line number Diff line number Diff line change 1111DEVICE_HID_PID = 0x2312
1212KIT_VERSION = "2.0.0"
1313
14+ KIT_APP_COMMAND_SET_TIME = 0
1415
1516def kit_crc (data ):
1617 """Return bytes object of the crc based on the input data bytes"""
Original file line number Diff line number Diff line change @@ -179,19 +179,46 @@ ATCA_STATUS atca_kit_detect_I2c_devices()
179179{
180180 ATCA_STATUS status = ATCA_NO_DEVICES ;
181181 uint8_t revision [4 ];
182+ uint8_t i ;
182183
183184 status = atcab_init ( & cfg_ateccx08a_i2c_default );
184- if (status != ATCA_SUCCESS ) return status ;
185+ for (i = 0xB0 ; i < 0xC8 && status ; i += 2 )
186+ {
187+ cfg_ateccx08a_i2c_default .atcai2c .slave_address = i ;
188+ status = atcab_init ( & cfg_ateccx08a_i2c_default );
189+ }
190+
191+ /* If the loop terminated before finding a device */
192+ if (status != ATCA_SUCCESS )
193+ {
194+ return status ;
195+ }
185196
186- // Test the init
197+ /* Verify the device by retrieving the revision */
187198 status = atcab_info (revision );
188- if (status != ATCA_SUCCESS ) {
199+ if (status != ATCA_SUCCESS )
200+ {
189201 return status ;
190202 }
191203
192204 device_info [device_count ].address = cfg_ateccx08a_i2c_default .atcai2c .slave_address ;
193205 device_info [device_count ].bus_type = DEVKIT_IF_I2C ;
194- device_info [device_count ].device_type = DEVICE_TYPE_ECC508A ;
206+
207+ switch (revision [2 ])
208+ {
209+ case 0x50 :
210+ device_info [device_count ].device_type = DEVICE_TYPE_ECC508A ;
211+ cfg_ateccx08a_i2c_default .devtype = ATECC508A ;
212+ break ;
213+ case 0x60 :
214+ device_info [device_count ].device_type = DEVICE_TYPE_ECC608A ;
215+ cfg_ateccx08a_i2c_default .devtype = ATECC608A ;
216+ break ;
217+ default :
218+ device_info [device_count ].device_type = DEVICE_TYPE_ECC108A ;
219+ break ;
220+ }
221+
195222 memcpy (device_info [device_count ].dev_rev , revision , sizeof (revision ));
196223
197224 device_count ++ ;
Original file line number Diff line number Diff line change 3333#include "config.h"
3434#include "time_utils.h"
3535#include "jwt/atca_jwt.h"
36+ #include "atca_kit_client.h"
3637
3738#ifdef CONFIG_USE_STATIC_CONFIG
3839
@@ -54,7 +55,8 @@ const char config_gcp_thing_id[] = "<EXAMPLE_DEVICE_ID>";
5455
5556void config_crypto (void )
5657{
57- cfg_ateccx08a_i2c_default .atcai2c .slave_address = 0xB0 ;
58+ /* Configure the default I2C address of the device */
59+ cfg_ateccx08a_i2c_default .atcai2c .slave_address = 0xB0 ;
5860
5961#if BOARD == SAMW25_XPLAINED_PRO
6062 /* For the ATSAMW25-XPRO Development Board */
@@ -63,6 +65,9 @@ void config_crypto(void)
6365 /* For the ATSAMG55-XPRO Development board */
6466 cfg_ateccx08a_i2c_default .atcai2c .bus = 1 ;
6567#endif
68+
69+ /* Detect devices */
70+ (void )atca_kit_detect_I2c_devices ();
6671}
6772
6873bool config_ready (void )
You can’t perform that action at this time.
0 commit comments