File tree Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 2
2
#
3
3
# SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
4
4
# SPDX-FileCopyrightText: Copyright (c) 2024 Brandon Hurst, Analog Devices, Inc.
5
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Peggy Zhu, Analog Devices, Inc.
5
6
#
6
7
# SPDX-License-Identifier: MIT
7
8
@@ -83,7 +84,8 @@ INC += \
83
84
-I$(PERIPH_SRC ) /ICC \
84
85
-I$(PERIPH_SRC ) /TMR \
85
86
-I$(PERIPH_SRC ) /RTC \
86
- -I$(PERIPH_SRC ) /UART
87
+ -I$(PERIPH_SRC ) /UART \
88
+ -I$(PERIPH_SRC ) /TRNG
87
89
88
90
INC += -I$(CMSIS_ROOT ) /Device/Maxim/$(MCU_VARIANT_UPPER ) /Source/GCC
89
91
@@ -116,7 +118,9 @@ SRC_MAX32 += \
116
118
$(PERIPH_SRC ) /TMR/tmr_$(DIE_TYPE ) .c \
117
119
$(PERIPH_SRC ) /UART/uart_common.c \
118
120
$(PERIPH_SRC ) /UART/uart_$(DIE_TYPE ) .c \
119
- $(PERIPH_SRC ) /UART/uart_revb.c
121
+ $(PERIPH_SRC ) /UART/uart_revb.c \
122
+ $(PERIPH_SRC ) /TRNG/trng_revb.c \
123
+ $(PERIPH_SRC ) /TRNG/trng_$(DIE_TYPE ) .c
120
124
121
125
SRC_C += $(SRC_MAX32 ) \
122
126
boards/$(BOARD ) /board.c \
Original file line number Diff line number Diff line change 2
2
//
3
3
// SPDX-FileCopyrightText: Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
4
4
// SPDX-FileCopyrightText: Copyright (c) 2019 Lucian Copeland for Adafruit Industries
5
+ // SPDX-FileCopyrightText: Copyright (c) 2025 Peggy Zhu, Analog Devices, Inc.
5
6
//
6
7
// SPDX-License-Identifier: MIT
7
8
15
16
16
17
// #include "peripherals/periph.h"
17
18
19
+ // true random number generator, TRNG
20
+ #include "trng.h"
21
+
18
22
bool common_hal_os_urandom (uint8_t * buffer , uint32_t length ) {
19
23
#if (HAS_TRNG )
20
- // todo (low prior): implement
24
+ // get a random number of "length" number of bytes
25
+ MXC_TRNG_Random (buffer , length );
26
+ return true;
21
27
#else
22
28
#endif
23
29
return false;
Original file line number Diff line number Diff line change 2
2
#
3
3
# SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
4
4
# SPDX-FileCopyrightText: Copyright (c) 2024 Brandon Hurst, Analog Devices, Inc.
5
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Peggy Zhu, Analog Devices, Inc.
5
6
#
6
7
# SPDX-License-Identifier: MIT
7
8
@@ -51,7 +52,7 @@ CIRCUITPY_BITBANGIO ?= 1
51
52
# Requires Microcontroller
52
53
CIRCUITPY_TOUCHIO ?= 1
53
54
# Requires OS
54
- CIRCUITPY_RANDOM ?= 0
55
+ CIRCUITPY_RANDOM ?= 1
55
56
# Requires busio.UART
56
57
CIRCUITPY_CONSOLE_UART ?= 0
57
58
# Does nothing without I2C
Original file line number Diff line number Diff line change 44
44
#include "mxc_delay.h"
45
45
#include "rtc.h"
46
46
47
+ // true random number generator, TRNG
48
+ #include "trng.h"
49
+
47
50
// msec to RTC subsec ticks (4 kHz)
48
51
/* Converts a time in milleseconds to equivalent RSSA register value */
49
52
#define MSEC_TO_SS_ALARM (x ) (0 - ((x * 4096) / 1000))
@@ -112,9 +115,18 @@ safe_mode_t port_init(void) {
112
115
}
113
116
;
114
117
118
+ // enable TRNG (true random number generator)
119
+ #ifdef CIRCUITPY_RANDOM
120
+ MXC_TRNG_Init ();
121
+ #endif
122
+
115
123
return SAFE_MODE_NONE ;
116
124
}
117
125
126
+ void TRNG_IRQHandler (void ) {
127
+ MXC_TRNG_Handler ();
128
+ }
129
+
118
130
void RTC_IRQHandler (void ) {
119
131
// Read flags to clear
120
132
int flags = MXC_RTC_GetFlags ();
You can’t perform that action at this time.
0 commit comments