diff --git a/python/port/helpers.cpp b/python/port/helpers.cpp index b30cc00b5..5f772751f 100644 --- a/python/port/helpers.cpp +++ b/python/port/helpers.cpp @@ -42,3 +42,7 @@ bool micropython_port_interrupt_if_needed() { } return false; } + +int micropython_port_random() { + return Ion::random(); +} diff --git a/python/port/helpers.h b/python/port/helpers.h index 32215ff80..761f96a7d 100644 --- a/python/port/helpers.h +++ b/python/port/helpers.h @@ -12,6 +12,7 @@ extern "C" { bool micropython_port_vm_hook_loop(); bool micropython_port_interruptible_msleep(uint32_t delay); bool micropython_port_interrupt_if_needed(); +int micropython_port_random(); #ifdef __cplusplus } diff --git a/python/port/mpconfigport.h b/python/port/mpconfigport.h index 207d3e6e6..dae99b6f2 100644 --- a/python/port/mpconfigport.h +++ b/python/port/mpconfigport.h @@ -89,6 +89,9 @@ // Whether to include: randrange, randint, choice, random, uniform #define MICROPY_PY_URANDOM_EXTRA_FUNCS (1) +// Function to seed URANDOM with on init +#define MICROPY_PY_URANDOM_SEED_INIT_FUNC micropython_port_random() + // Make a pointer to RAM callable (eg set lower bit for Thumb code) // (This scheme won't work if we want to mix Thumb and normal ARM code.) #define MICROPY_MAKE_POINTER_CALLABLE(p) (p)