Skip to content

Commit

Permalink
nrf: Use MICROPY_HW_ENABLE_RNG instead of MICROPY_PY_RANDOM_HW_RNG.
Browse files Browse the repository at this point in the history
The "random" module no longer uses the hardware RNG (the extmod version of
this module has a pseudo-random number generator), so the config option
MICROPY_PY_RANDOM_HW_RNG is no longer meaningful.  This commit replaces it
with MICROPY_HW_ENABLE_RNG, which controls whether the hardware RNG is
included in the build.
  • Loading branch information
dpgeorge committed Feb 18, 2020
1 parent 6ad3bb1 commit ac8383a
Show file tree
Hide file tree
Showing 21 changed files with 36 additions and 27 deletions.
3 changes: 2 additions & 1 deletion ports/nrf/boards/arduino_primo/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (1)
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/blueio_tag_evim/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (4)
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/dvk_bl652/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (2)
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/evk_nina_b1/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_TRICOLOR (1)
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/feather52/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (2)
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/ibk_blyst_nano/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (3)
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/idk_blyst_nano/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (4)
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/microbit/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_HAS_LED (0)

Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/particle_xenon/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_USB_CDC (1)

Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/pca10000/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
#define MICROPY_PY_MACHINE_I2C (0)
#define MICROPY_PY_MACHINE_ADC (0)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_TRICOLOR (1)
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/pca10001/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (2)
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/pca10028/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (4)
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/pca10031/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_TRICOLOR (1)
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/pca10040/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (4)
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/pca10056/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (4)
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/pca10059/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_USB_CDC (1)

Expand Down
1 change: 0 additions & 1 deletion ports/nrf/boards/pca10090/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (0)
#define MICROPY_PY_MACHINE_TEMP (0)
#define MICROPY_PY_RANDOM_HW_RNG (0)

#define MICROPY_MBFS (0)

Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/wt51822_s4at/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
#define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)

#define MICROPY_HW_ENABLE_RNG (1)

#define MICROPY_HW_HAS_LED (0)

Expand Down
4 changes: 2 additions & 2 deletions ports/nrf/drivers/rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "py/mpconfig.h"

#if MICROPY_PY_RANDOM_HW_RNG
#if MICROPY_HW_ENABLE_RNG

#include "nrf_rng.h"
#include "drivers/rng.h"
Expand Down Expand Up @@ -76,4 +76,4 @@ uint32_t rng_generate_random_word(void) {
return generate_hw_random();
}

#endif // MICROPY_PY_RANDOM_HW_RNG
#endif // MICROPY_HW_ENABLE_RNG
3 changes: 0 additions & 3 deletions ports/nrf/modules/machine/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,6 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_soft_reset), MP_ROM_PTR(&machine_soft_reset_obj) },
{ MP_ROM_QSTR(MP_QSTR_enable_irq), MP_ROM_PTR(&machine_enable_irq_obj) },
{ MP_ROM_QSTR(MP_QSTR_disable_irq), MP_ROM_PTR(&machine_disable_irq_obj) },
#if MICROPY_HW_ENABLE_RNG
{ MP_ROM_QSTR(MP_QSTR_rng), MP_ROM_PTR(&random_module) },
#endif
{ MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&machine_lightsleep_obj) },
{ MP_ROM_QSTR(MP_QSTR_lightsleep), MP_ROM_PTR(&machine_lightsleep_obj) },
{ MP_ROM_QSTR(MP_QSTR_deepsleep), MP_ROM_PTR(&machine_deepsleep_obj) },
Expand Down
4 changes: 0 additions & 4 deletions ports/nrf/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@
#define MICROPY_PY_MACHINE_RTCOUNTER (0)
#endif

#ifndef MICROPY_PY_RANDOM_HW_RNG
#define MICROPY_PY_RANDOM_HW_RNG (0)
#endif


#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1)
#define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0)
Expand Down

0 comments on commit ac8383a

Please sign in to comment.