nrf/modules/random: Rename port config for RNG

Renaming config for enabling random module with hw
random number generator from MICROPY_PY_HW_RNG to
MICROPY_PY_RANDOM_HW_RNG to indicate which module it
is configuring.

Also, disabling the config by default in mpconfigport.h.

Adding the enable of RNG in all board configs.

Moving ifdef in modrandom, which test for the config being
set, earlier in the code. This is to prevent un-necessary
includes if not needed.
This commit is contained in:
Glenn Ruben Bakke 2018-04-10 20:46:28 +02:00 committed by Damien George
parent f4382a2885
commit 0f7da42c75
13 changed files with 19 additions and 9 deletions

View File

@ -39,6 +39,7 @@
#define MICROPY_PY_MACHINE_I2C (1) #define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1) #define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1) #define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)
#define MICROPY_HW_HAS_LED (1) #define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (1) #define MICROPY_HW_LED_COUNT (1)

View File

@ -36,6 +36,7 @@
#define MICROPY_PY_MACHINE_I2C (1) #define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1) #define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1) #define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)
#define MICROPY_HW_HAS_LED (1) #define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (2) #define MICROPY_HW_LED_COUNT (2)

View File

@ -36,6 +36,7 @@
#define MICROPY_PY_MACHINE_I2C (1) #define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1) #define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1) #define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)
#define MICROPY_HW_HAS_LED (1) #define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (2) #define MICROPY_HW_LED_COUNT (2)

View File

@ -37,7 +37,7 @@
#define MICROPY_PY_MACHINE_I2C (1) #define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1) #define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1) #define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_HW_RNG (1) #define MICROPY_PY_RANDOM_HW_RNG (1)
#define MICROPY_HW_HAS_LED (0) #define MICROPY_HW_HAS_LED (0)

View File

@ -35,6 +35,7 @@
#define MICROPY_PY_MACHINE_I2C (0) #define MICROPY_PY_MACHINE_I2C (0)
#define MICROPY_PY_MACHINE_ADC (0) #define MICROPY_PY_MACHINE_ADC (0)
#define MICROPY_PY_MACHINE_TEMP (1) #define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)
#define MICROPY_HW_HAS_LED (1) #define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_TRICOLOR (1) #define MICROPY_HW_LED_TRICOLOR (1)

View File

@ -35,6 +35,7 @@
#define MICROPY_PY_MACHINE_I2C (1) #define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1) #define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1) #define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)
#define MICROPY_HW_HAS_LED (1) #define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (2) #define MICROPY_HW_LED_COUNT (2)

View File

@ -35,6 +35,7 @@
#define MICROPY_PY_MACHINE_I2C (1) #define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1) #define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1) #define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)
#define MICROPY_HW_HAS_LED (1) #define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (4) #define MICROPY_HW_LED_COUNT (4)

View File

@ -35,6 +35,7 @@
#define MICROPY_PY_MACHINE_I2C (1) #define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1) #define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1) #define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)
#define MICROPY_HW_HAS_LED (1) #define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_TRICOLOR (1) #define MICROPY_HW_LED_TRICOLOR (1)

View File

@ -36,7 +36,7 @@
#define MICROPY_PY_MACHINE_I2C (1) #define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1) #define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1) #define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_HW_RNG (1) #define MICROPY_PY_RANDOM_HW_RNG (1)
#define MICROPY_HW_HAS_LED (1) #define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (4) #define MICROPY_HW_LED_COUNT (4)

View File

@ -36,6 +36,7 @@
#define MICROPY_PY_MACHINE_I2C (1) #define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1) #define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1) #define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)
#define MICROPY_HW_HAS_LED (1) #define MICROPY_HW_HAS_LED (1)
#define MICROPY_HW_LED_COUNT (4) #define MICROPY_HW_LED_COUNT (4)

View File

@ -37,6 +37,7 @@
#define MICROPY_PY_MACHINE_I2C (1) #define MICROPY_PY_MACHINE_I2C (1)
#define MICROPY_PY_MACHINE_ADC (1) #define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_TEMP (1) #define MICROPY_PY_MACHINE_TEMP (1)
#define MICROPY_PY_RANDOM_HW_RNG (1)
#define MICROPY_HW_HAS_LED (0) #define MICROPY_HW_HAS_LED (0)

View File

@ -29,6 +29,9 @@
#include <string.h> #include <string.h>
#include "py/runtime.h" #include "py/runtime.h"
#if MICROPY_PY_RANDOM_HW_RNG
#include "nrf_rng.h" #include "nrf_rng.h"
#include "modrandom.h" #include "modrandom.h"
@ -38,8 +41,6 @@
#define BLUETOOTH_STACK_ENABLED() (ble_drv_stack_enabled()) #define BLUETOOTH_STACK_ENABLED() (ble_drv_stack_enabled())
#endif #endif
#if MICROPY_PY_HW_RNG
static inline uint32_t generate_hw_random(void) { static inline uint32_t generate_hw_random(void) {
uint32_t retval = 0; uint32_t retval = 0;
uint8_t * p_retval = (uint8_t *)&retval; uint8_t * p_retval = (uint8_t *)&retval;
@ -219,4 +220,4 @@ const mp_obj_module_t random_module = {
.globals = (mp_obj_dict_t*)&mp_module_random_globals, .globals = (mp_obj_dict_t*)&mp_module_random_globals,
}; };
#endif // MICROPY_PY_HW_RNG #endif // MICROPY_PY_RANDOM_HW_RNG

View File

@ -169,8 +169,8 @@
#define MICROPY_PY_MACHINE_RTCOUNTER (0) #define MICROPY_PY_MACHINE_RTCOUNTER (0)
#endif #endif
#ifndef MICROPY_PY_HW_RNG #ifndef MICROPY_PY_RANDOM_HW_RNG
#define MICROPY_PY_HW_RNG (1) #define MICROPY_PY_RANDOM_HW_RNG (0)
#endif #endif
@ -227,7 +227,7 @@ extern const struct _mp_obj_module_t random_module;
#define MUSIC_MODULE #define MUSIC_MODULE
#endif #endif
#if MICROPY_PY_HW_RNG #if MICROPY_PY_RANDOM_HW_RNG
#define RANDOM_MODULE { MP_ROM_QSTR(MP_QSTR_random), MP_ROM_PTR(&random_module) }, #define RANDOM_MODULE { MP_ROM_QSTR(MP_QSTR_random), MP_ROM_PTR(&random_module) },
#else #else
#define RANDOM_MODULE #define RANDOM_MODULE