Hi @dylanou,
you can get inspiration with the following code https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git/+/refs/heads/main/platform/ext/target/stm/common/secure_element/stsafea/se_psa/se_psa.c
in the psa_se_st_get_serial() you have a simple example on how to get the serial number of the STSAFE-A without the middleware.
You have this variable
uint8_t sn_data[] = { 0x14, 0x11, 0xFC, 0xBE };
which is the command to do a query product data to the STSAFE-A.
Then the basic communication over the I2C :
ret = BSP_I2C_Send(0x40, sn_data, 4);
if (ret == 0)
{
BSP_TimeDelay(5);
ret = BSP_I2C_Recv(0x40, r_data, 69);
}
if (ret != 0)
{
return PSA_ERROR_HARDWARE_FAILURE;
}
You need to adapt the BSP_I2C_Send to your I2C driver.
and here a simple trick to get the Serial Number directly from the response :
uint8_t r_data[100];
uint8_t *sn = &r_data[10];
The serial number is 9 bytes long.
Best Regards,
Benjamin