Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/atecc608_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const uint8_t ECCX08_DEFAULT_CONFIGURATION_VALS[112] = {
};

extern "C" int atecc_handler_write_configuration(const uint8_t *config, size_t len);
extern "C" int atecc_handle_write_default_configuration();
extern "C" int atecc_handler_lock_zone(uint8_t zone);
extern "C" int atecc_handler_init(int i2cAddr, int bus);
extern "C" int atecc_handler_read_configuration(uint8_t *config_data);
Expand Down
14 changes: 14 additions & 0 deletions src/atecc608_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ int atecc_handler_write_configuration(const uint8_t *config, size_t len)
return status;
}

/** \brief Write default configuration to the chip.
* \return ATCA_SUCCESS on success, otherwise an error code.
*/
int atecc_handle_write_default_configuration(){
ATCA_STATUS status;
status = atcab_init(&cfg);
if (status == ATCA_SUCCESS)
{
status = atecc_handler_write_configuration(ECCX08_DEFAULT_CONFIGURATION_VALS, sizeof(ECCX08_DEFAULT_CONFIGURATION_VALS));
return status;
}
return status;
}


/** \brief Check if a the DATA_ZONE or CONFIG_ZONE is locked
* \param[in] zone LOCK_ZONE_DATA or LOCK_ZONE_CONFIG
Expand Down
8 changes: 4 additions & 4 deletions test/test_atecc608.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ void printHexBuffer(std::vector<uint8_t> input){

void write_atecc_config()
{
auto status = atecc_handler_init(0xC0);
auto status = atecc_handler_init(0xC0, 1);
if(status){
std::cout << "atecc_handler_init Fail! ";
std::cout << status << "\n";
return;
}

status = atecc_handler_write_configuration(ECCX08_DEFAULT_CONFIGURATION_VALS, sizeof(ECCX08_DEFAULT_CONFIGURATION_VALS));
status = atecc_handle_write_default_configuration();
if(status){
std::cout << "atecc_handler_write_configuration Fail! ";
std::cout << status << "\n";
Expand All @@ -41,7 +41,7 @@ void write_atecc_config()


int general_test(){
auto status = atecc_handler_init(0xC0);
auto status = atecc_handler_init(0xC0, 1);
if(status){
std::cout << "atecc_handler_init Fail! ";
std::cout << status << "\n";
Expand Down Expand Up @@ -120,7 +120,7 @@ int general_test(){


int main(){
// write_atecc_config();
write_atecc_config();
general_test();

return 0;
Expand Down