Skip to content

Commit 61754d6

Browse files
jaenrig-ifxactions-user
authored andcommitted
psoc6: Updated changes on mbedtls extmod.
Signed-off-by: jaenrig-ifx <enriquezgarcia.external@infineon.com>
1 parent e7fd7aa commit 61754d6

4 files changed

Lines changed: 20 additions & 1 deletion

File tree

ports/psoc6/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ CFLAGS += -Wno-error=double-promotion -Wno-error=overflow -Wno-error=analyzer-n
5656

5757
ifeq ($(MICROPY_PSOC6_SSL_MBEDTLS),1)
5858
INC += -I$(TOP)/extmod/mbedtls
59-
CFLAGS += -DMBEDTLS_CONFIG_FILE=\"mbedtls/mbedtls_config.h\"
59+
CFLAGS += -DMBEDTLS_CONFIG_FILE=\"mbedtls/mbedtls_config_port.h\"
6060
CFLAGS += -DMICROPY_SSL_MBEDTLS=1
6161
endif
6262

ports/psoc6/mphalport.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,19 @@ void mp_hal_pin_input(mp_hal_pin_obj_t pin) {
174174
mp_hal_pin_obj_t mp_hal_get_pin_obj(mp_obj_t obj) {
175175
return pin_addr_by_name(obj);
176176
}
177+
178+
void mp_hal_get_random(size_t n, uint8_t *buf) {
179+
uint32_t r = 0;
180+
cyhal_trng_t trng_obj;
181+
182+
cyhal_trng_init(&trng_obj);
183+
184+
for (int i = 0; i < n; i++) {
185+
if ((i & 3) == 0) {
186+
r = cyhal_trng_generate(&trng_obj); // returns 32-bit hardware random number
187+
}
188+
buf[i] = r;
189+
r >>= 8;
190+
}
191+
cyhal_trng_free(&trng_obj);
192+
}

ports/psoc6/mphalport.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,6 @@ static inline void mp_hal_pin_config(mp_hal_pin_obj_t pin, uint32_t mode, uint32
9595
// gpio_set_dir(pin, mode);
9696
// gpio_set_pulls(pin, pull == MP_HAL_PIN_PULL_UP, pull == MP_HAL_PIN_PULL_DOWN);
9797
}
98+
99+
100+
void mp_hal_get_random(size_t n, uint8_t *buf);

0 commit comments

Comments
 (0)