22 #ifndef RNG90_HAL_PLATFORM
34 #define RNG90_HAL_PLATFORM avr0
47 #define RNG90_ADDRESS 0x40
50 #ifndef RNG90_RESET_COMMAND
60 #define RNG90_RESET_COMMAND 0x00
63 #ifndef RNG90_SLEEP_COMMAND1
74 #define RNG90_SLEEP_COMMAND1 0x01
77 #ifndef RNG90_SLEEP_COMMAND2
87 #define RNG90_SLEEP_COMMAND2 0x02
90 #ifndef RNG90_EXECUTE_COMMAND
100 #define RNG90_EXECUTE_COMMAND 0x03
103 #ifndef RNG90_OPERATION_INFO
113 #define RNG90_OPERATION_INFO 0x30
115 #ifndef RNG90_OPERATION_INFO_PARAM1
125 #define RNG90_OPERATION_INFO_PARAM1 0x00
128 #ifndef RNG90_OPERATION_INFO_PARAM2
138 #define RNG90_OPERATION_INFO_PARAM2 0x0000
142 #ifndef RNG90_OPERATION_RANDOM
152 #define RNG90_OPERATION_RANDOM 0x16
154 #ifndef RNG90_OPERATION_RANDOM_PARAM1
164 #define RNG90_OPERATION_RANDOM_PARAM1 0x00
167 #ifndef RNG90_OPERATION_RANDOM_PARAM2
177 #define RNG90_OPERATION_RANDOM_PARAM2 0x0000
180 #ifndef RNG90_OPERATION_RANDOM_DATA_SIZE
190 #define RNG90_OPERATION_RANDOM_DATA_SIZE 20UL
192 #ifndef RNG90_OPERATION_RANDOM_DATA
202 #define RNG90_OPERATION_RANDOM_DATA 0x00
206 #ifndef RNG90_OPERATION_RANDOM_RNG_SIZE
216 #define RNG90_OPERATION_RANDOM_RNG_SIZE 32UL
220 #ifndef RNG90_OPERATION_READ
230 #define RNG90_OPERATION_READ 0x02
232 #ifndef RNG90_OPERATION_READ_PARAM1
242 #define RNG90_OPERATION_READ_PARAM1 0x01
245 #ifndef RNG90_OPERATION_READ_PARAM2
255 #define RNG90_OPERATION_READ_PARAM2 0x0000
258 #ifndef RNG90_OPERATION_READ_DATA_SIZE
268 #define RNG90_OPERATION_READ_DATA_SIZE 16UL
271 #ifndef RNG90_OPERATION_READ_SERIAL_SIZE
281 #define RNG90_OPERATION_READ_SERIAL_SIZE 8UL
285 #ifndef RNG90_OPERATION_SELF_TEST
295 #define RNG90_OPERATION_SELF_TEST 0x77
297 #ifndef RNG90_OPERATION_SELF_TEST_PARAM1_READ
307 #define RNG90_OPERATION_SELF_TEST_PARAM1_READ 0x00
310 #ifndef RNG90_OPERATION_SELF_TEST_PARAM1_RUN_DRBG
320 #define RNG90_OPERATION_SELF_TEST_PARAM1_RUN_DRBG 0x01
323 #ifndef RNG90_OPERATION_SELF_TEST_PARAM1_RUN_SHA256
333 #define RNG90_OPERATION_SELF_TEST_PARAM1_RUN_SHA256 0x20
336 #ifndef RNG90_OPERATION_SELF_TEST_PARAM1_RUN_DRBG_AND_SHA256
348 #define RNG90_OPERATION_SELF_TEST_PARAM1_RUN_DRBG_AND_SHA256 0x21
351 #ifndef RNG90_OPERATION_SELF_TEST_PARAM2
364 #define RNG90_OPERATION_SELF_TEST_PARAM2 0x0000
368 #ifndef RNG90_NEW_BUS_TRANSMISSION_US
378 #define RNG90_NEW_BUS_TRANSMISSION_US 2UL
381 #ifndef RNG90_STATUS_SUCCESSFUL_COMMAND_EXECUTION
391 #define RNG90_STATUS_SUCCESSFUL_COMMAND_EXECUTION 0x00
394 #ifndef RNG90_STATUS_PARSE_ERROR
404 #define RNG90_STATUS_PARSE_ERROR 0x03
407 #ifndef RNG90_STATUS_SELF_TEST_ERROR
417 #define RNG90_STATUS_SELF_TEST_ERROR 0x07
420 #ifndef RNG90_STATUS_HEALTH_TEST_ERROR
430 #define RNG90_STATUS_HEALTH_TEST_ERROR 0x08
433 #ifndef RNG90_STATUS_EXECUTION_ERROR
443 #define RNG90_STATUS_EXECUTION_ERROR 0x0F
446 #ifndef RNG90_STATUS_AFTER_WAKE
456 #define RNG90_STATUS_AFTER_WAKE 0x11
459 #ifndef RNG90_STATUS_TWI_ERROR
469 #define RNG90_STATUS_TWI_ERROR 0xF0
472 #ifndef RNG90_STATUS_CRC_OR_COMMUNICATION_ERROR
482 #define RNG90_STATUS_CRC_OR_COMMUNICATION_ERROR 0xFF
485 #ifndef RNG90_SELFTEST_STATUS_PASSED_SUCCESSFULLY
495 #define RNG90_SELFTEST_STATUS_PASSED_SUCCESSFULLY 0x00
498 #ifndef RNG90_SELFTEST_STATUS_DRBG_SELFTEST_FAIL
508 #define RNG90_SELFTEST_STATUS_DRBG_SELFTEST_FAIL 0x01
511 #ifndef RNG90_SELFTEST_STATUS_SHA256_SELFTEST_FAIL
521 #define RNG90_SELFTEST_STATUS_SHA256_SELFTEST_FAIL 0x20
524 #ifndef RNG90_SELFTEST_STATUS_DRBG_SHA256_SELFTEST_FAIL
534 #define RNG90_SELFTEST_STATUS_DRBG_SHA256_SELFTEST_FAIL 0x21
537 #ifndef RNG90_SELFTEST_STATUS_DRBG_SELFTEST_NOT_RUN
547 #define RNG90_SELFTEST_STATUS_DRBG_SELFTEST_NOT_RUN 0x02
550 #ifndef RNG90_SELFTEST_STATUS_SHA256_SELFTEST_NOT_RUN
560 #define RNG90_SELFTEST_STATUS_SHA256_SELFTEST_NOT_RUN 0x10
563 #ifndef RNG90_SELFTEST_STATUS_NEITHER_SELFTEST_NOT_RUN
573 #define RNG90_SELFTEST_STATUS_NEITHER_SELFTEST_NOT_RUN 0x12
576 #ifndef RNG90_SELFTEST_STATUS_ERROR
586 #define RNG90_SELFTEST_STATUS_ERROR 0xFF
589 #ifndef RNG90_INFO_EXECUTION_TIME_MS
599 #define RNG90_INFO_EXECUTION_TIME_MS 1UL
602 #ifndef RNG90_RANDOM_EXECUTION_TIME_MS
612 #define RNG90_RANDOM_EXECUTION_TIME_MS 75UL
615 #ifndef RNG90_READ_EXECUTION_TIME_MS
625 #define RNG90_READ_EXECUTION_TIME_MS 1UL
628 #ifndef RNG90_SELFTEST_EXECUTION_TIME_MS
638 #define RNG90_SELFTEST_EXECUTION_TIME_MS 32UL
641 #ifndef RNG90_WDT_RESET_TIME_MS
651 #define RNG90_WDT_RESET_TIME_MS 1300UL
654 #ifndef RNG90_CRC_POLYNOMIAL
664 #define RNG90_CRC_POLYNOMIAL 0x8005
667 #ifndef RNG90_CRC_SIZE
677 #define RNG90_CRC_SIZE 2UL
680 #ifndef RNG90_STANDARD_FRAME_SIZE
690 #define RNG90_STANDARD_FRAME_SIZE 4UL
693 #ifndef RNG90_INFO_FRAME_SIZE
703 #define RNG90_INFO_FRAME_SIZE 7UL
706 #ifndef RNG90_NUMBER_FRAME_SIZE
716 #define RNG90_NUMBER_FRAME_SIZE 35UL
719 #ifndef RNG90_SERIAL_FRAME_SIZE
729 #define RNG90_SERIAL_FRAME_SIZE 19UL
734 #include _STR(../../../hal/RNG90_HAL_PLATFORM/twi/twi.h)
Header file with declarations and macros for CRC16 checksum calculation.
#define RNG90_SELFTEST_STATUS_DRBG_SELFTEST_FAIL
Defines the self-test status code indicating the DRBG self-test failed on the RNG90 device.
Definition rng90.h:508
RNG90_Run_SelfTest_t
Selects which self-test routine to run on the RNG90 device.
Definition rng90.h:772
@ RNG90_Run_SHA256_SelfTest
Definition rng90.h:774
@ RNG90_Run_DBRG_SHA256_SelfTest
Definition rng90.h:775
@ RNG90_Run_DRBG_SelfTest
Definition rng90.h:773
RNG90_Status rng90_init(void)
#define RNG90_STATUS_TWI_ERROR
Defines the status code for a TWI/I2C communication error with the RNG90 device.
Definition rng90.h:469
enum RNG90_Run_SelfTest_t RNG90_Run_SelfTest
Alias for enum RNG90_Run_SelfTest_t representing RNG90 self-test selections.
Definition rng90.h:782
enum RNG90_SelfTest_Status_t RNG90_SelfTest_Status
Alias for enum RNG90_SelfTest_Status_t representing RNG90 self-test result codes.
Definition rng90.h:811
struct RNG90_Packet_t RNG90_Packet
Alias for struct RNG90_Packet_t representing an RNG90 packet.
Definition rng90.h:854
#define RNG90_SELFTEST_STATUS_DRBG_SELFTEST_NOT_RUN
Defines the self-test status code indicating the DRBG self-test was not run on the RNG90 device.
Definition rng90.h:547
struct RNG90_Info_t RNG90_Info
Alias for struct RNG90_Info_t representing RNG90 device information.
Definition rng90.h:832
RNG90_Status_t
Represents status codes returned by the RNG90 device.
Definition rng90.h:747
@ RNG90_Status_Success
Definition rng90.h:748
@ RNG90_Status_Execution_Error
Definition rng90.h:752
@ RNG90_Status_AfterWake_Indication
Definition rng90.h:753
@ RNG90_Status_HealthTest_Error
Definition rng90.h:751
@ RNG90_Status_SelfTest_Error
Definition rng90.h:750
@ RNG90_Status_Parse_Error
Definition rng90.h:749
@ RNG90_Status_Other_Error
Definition rng90.h:755
@ RNG90_Status_TWI_Error
Definition rng90.h:754
RNG90_Data_Status_t
Indicates whether received RNG90 data is valid.
Definition rng90.h:864
@ RNG90_Data_Status_Invalid
Definition rng90.h:866
@ RNG90_Data_Status_Valid
Definition rng90.h:865
#define RNG90_STATUS_EXECUTION_ERROR
Defines the status code for an execution error on the RNG90 device.
Definition rng90.h:443
enum RNG90_Data_Status_t RNG90_Data_Status
Alias for enum RNG90_Data_Status_t representing RNG90 data validity status.
Definition rng90.h:873
enum RNG90_Status_t RNG90_Status
Alias for enum RNG90_Status_t representing RNG90 status codes.
Definition rng90.h:762
#define RNG90_STATUS_CRC_OR_COMMUNICATION_ERROR
Defines the status code for a CRC or communication error with the RNG90 device.
Definition rng90.h:482
#define RNG90_SELFTEST_STATUS_NEITHER_SELFTEST_NOT_RUN
Defines the self-test status code indicating neither DRBG nor SHA-256 self-tests were run on the RNG9...
Definition rng90.h:573
#define RNG90_STATUS_PARSE_ERROR
Defines the status code for a parse error on the RNG90 device.
Definition rng90.h:404
#define RNG90_STATUS_HEALTH_TEST_ERROR
Defines the status code for a health test error on the RNG90 device.
Definition rng90.h:430
RNG90_Status rng90_info(RNG90_Info *info)
Requests device information from the RNG90 and fills an info structure.
Definition rng90.c:178
struct RNG90_Frame_t RNG90_Frame
Alias for struct RNG90_Frame_t representing an RNG90 data frame.
Definition rng90.h:892
#define RNG90_STATUS_SUCCESSFUL_COMMAND_EXECUTION
Defines the status code for a successfully executed command on the RNG90 device.
Definition rng90.h:391
#define RNG90_SELFTEST_STATUS_ERROR
Defines the self-test status code indicating an error occurred during self-testing on the RNG90 devic...
Definition rng90.h:586
#define RNG90_OPERATION_SELF_TEST_PARAM1_RUN_DRBG
Parameter for running the DRBG self-test on the RNG90 device.
Definition rng90.h:320
#define RNG90_STATUS_SELF_TEST_ERROR
Defines the status code for a self-test error on the RNG90 device.
Definition rng90.h:417
#define RNG90_SELFTEST_STATUS_SHA256_SELFTEST_NOT_RUN
Defines the self-test status code indicating the SHA-256 self-test was not run on the RNG90 device.
Definition rng90.h:560
RNG90_SelfTest_Status_t
Represents the result status of self-test routines on the RNG90 device.
Definition rng90.h:796
@ RNG90_SelfTest_Error
Definition rng90.h:804
@ RNG90_SelfTest_Fail_DBRG
Definition rng90.h:798
@ RNG90_SelfTest_Success
Definition rng90.h:797
@ RNG90_SelfTest_Not_Run_SHA256
Definition rng90.h:800
@ RNG90_SelfTest_Fail_SHA256
Definition rng90.h:802
@ RNG90_SelfTest_Fail_DBRG_SHA256
Definition rng90.h:803
@ RNG90_SelfTest_Not_Run_Neither
Definition rng90.h:801
@ RNG90_SelfTest_Not_Run_DBRG
Definition rng90.h:799
#define RNG90_STATUS_AFTER_WAKE
Defines the status code indicating the RNG90 device has just woken up from sleep mode.
Definition rng90.h:456
RNG90_Status rng90_serial(unsigned char *serial)
Reads the device serial number from the RNG90 and stores it in a buffer.
Definition rng90.c:285
#define RNG90_SELFTEST_STATUS_SHA256_SELFTEST_FAIL
Defines the self-test status code indicating the SHA-256 self-test failed on the RNG90 device.
Definition rng90.h:521
RNG90_SelfTest_Status rng90_selftest(RNG90_Run_SelfTest test)
Initializes the RNG90 device by running a self-test.
Definition rng90.c:136
RNG90_Status rng90_random(unsigned char *numbers)
Requests random numbers from the RNG90 device and stores them in a buffer.
Definition rng90.c:224
#define RNG90_SELFTEST_STATUS_PASSED_SUCCESSFULLY
Defines the self-test status code indicating all tests passed successfully on the RNG90 device.
Definition rng90.h:495
#define RNG90_OPERATION_SELF_TEST_PARAM1_RUN_SHA256
Parameter for running the SHA-256 self-test on the RNG90 device.
Definition rng90.h:333
#define RNG90_SELFTEST_STATUS_DRBG_SHA256_SELFTEST_FAIL
Defines the self-test status code indicating both DRBG and SHA-256 self-tests failed on the RNG90 dev...
Definition rng90.h:534
#define RNG90_OPERATION_SELF_TEST_PARAM1_RUN_DRBG_AND_SHA256
Parameter for running both DRBG and SHA-256 self-tests on the RNG90 device.
Definition rng90.h:348
Helper macros for stringification in C preprocessor.
Describes a processed data frame received from the RNG90 device.
Definition rng90.h:883
unsigned char length
Definition rng90.h:884
RNG90_Data_Status status
Definition rng90.h:885
Holds basic identification and revision information for the RNG90 device.
Definition rng90.h:821
unsigned char Revision
Definition rng90.h:825
unsigned char DeviceID
Definition rng90.h:823
unsigned char RFU
Definition rng90.h:822
unsigned char SiliconID
Definition rng90.h:824
Represents a generic command or response packet for the RNG90 device.
Definition rng90.h:842
unsigned int crc
Definition rng90.h:847
unsigned char opcode
Definition rng90.h:844
unsigned char param1
Definition rng90.h:845
unsigned char count
Definition rng90.h:843
unsigned int param2
Definition rng90.h:846
Header file with declarations and macros for systick utility.