Trident IoT SDK
 
Loading...
Searching...
No Matches
T32CM11_trng.h
Go to the documentation of this file.
1
12
13#ifndef T32CM11_TRNG_H_
14#define T32CM11_TRNG_H_
15
16#include "tr_hal_platform.h"
17
23
24
25// *****************************************************************
26// the TRNG registers are part of the SYSTEM CONTROL registers
27// these are defined in the GPIO module. This shows the relevant
28// registers
29//
30// typedef struct
31// {
32// ...
33// // random number generator registers (see section 20)
34// __IO uint32_t random_number_trigger; // 0x40
35// __IO uint32_t random_number_select; // 0x44
36// __IO uint32_t random_number_status; // 0x48
37// __IO uint32_t random_number_value; // 0x4C
38
39// } SYS_CTRL_REGISTERS_T;
40
41
42// *****************************************************************
43// access the TRNG registers using this define:
44// #define SYS_CTRL_CHIP_REGISTERS ((SYS_CTRL_REGISTERS_T *) CHIP_MEMORY_MAP_SYS_CTRL_BASE)
45//
46// example:
47// SYS_CTRL_CHIP_REGISTERS->random_number_trigger = TRNG_ENABLE;
48
49
50// for random_number_trigger (0x40) register
51#define TRNG_ENABLE 0x01
52#define TRNG_CLEAR_INTERRUPT 0x02
53
54// for random_number_select (0x44) register
55#define TRNG_CORRECTION_VON_NEUMANN 0x00
56#define TRNG_CORRECTION_XOR 0x01
57#define TRNG_INTERRUPT_ENABLE 0x02
58#define TRNG_INTERRUPT_DISABLE 0x00
59
60// for random_number_status (0x48) register
61#define TRNG_STATUS_BUSY 0x01
62#define TRNG_STATUS_INTERRUPT_PENDING 0x02
63
64// this is for the timeout when waiting for TRNG to finish creating
65// a random number. This usually works in 4000 - 7000 iterations on
66// a system with no load
67#define TRNG_TIMEOUT_COUNT 20000
68
69// used for testing. This returns a 4 byte random number but also
70// returns the number of cycles it took to generate the number
72 uint32_t* busy_cycles);
73
74
78
79
80#endif // T32CM11_GPIO_H_
This file contains the CHIP SPECIFIC types and defines for the T32CM11.
tr_hal_status_t
Definition tr_hal_common.h:25
tr_hal_status_t tr_hal_trng_read_internal(uint32_t *result, uint32_t *busy_cycles)