Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mtb-psoc6-libs
Submodule mtb-psoc6-libs updated 1 files
+1 −1 Makefile
2 changes: 1 addition & 1 deletion ports/psoc6/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ CFLAGS += -Wno-error=double-promotion -Wno-error=overflow -Wno-error=analyzer-n

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

Expand Down
16 changes: 16 additions & 0 deletions ports/psoc6/mphalport.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,19 @@ void mp_hal_pin_input(mp_hal_pin_obj_t pin) {
mp_hal_pin_obj_t mp_hal_get_pin_obj(mp_obj_t obj) {
return pin_addr_by_name(obj);
}

void mp_hal_get_random(size_t n, uint8_t *buf) {
uint32_t r = 0;
cyhal_trng_t trng_obj;

cyhal_trng_init(&trng_obj);

for (int i = 0; i < n; i++) {
if ((i & 3) == 0) {
r = cyhal_trng_generate(&trng_obj); // returns 32-bit hardware random number
}
buf[i] = r;
r >>= 8;
}
cyhal_trng_free(&trng_obj);
}
3 changes: 3 additions & 0 deletions ports/psoc6/mphalport.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,6 @@ static inline void mp_hal_pin_config(mp_hal_pin_obj_t pin, uint32_t mode, uint32
// gpio_set_dir(pin, mode);
// gpio_set_pulls(pin, pull == MP_HAL_PIN_PULL_UP, pull == MP_HAL_PIN_PULL_DOWN);
}


void mp_hal_get_random(size_t n, uint8_t *buf);
Loading