nrf: Remove the random hal and module
Thus getting rid of the whole old hal! The module is not needed because the common-hal nRF implementation uses HW RNG anyway.
This commit is contained in:
parent
1163462635
commit
2c63fb2a94
|
@ -43,9 +43,7 @@ INC += -I$(BUILD)
|
|||
INC += -I$(BUILD)/genhdr
|
||||
INC += -I./../../lib/cmsis/inc
|
||||
INC += -I./boards/$(BOARD)
|
||||
INC += -I./hal
|
||||
INC += -I./modules/ubluepy
|
||||
INC += -I./modules/random
|
||||
INC += -I./modules/ble
|
||||
INC += -I./nrfx
|
||||
INC += -I./nrfx/hal
|
||||
|
@ -63,7 +61,6 @@ CFLAGS += $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(COPT) $(NRF_DEFINES)
|
|||
CFLAGS += -fno-strict-aliasing
|
||||
CFLAGS += -fstack-usage -fno-builtin -fshort-enums
|
||||
CFLAGS += -fdata-sections -ffunction-sections
|
||||
CFLAGS += -DNRF5_HAL_H='<$(MCU_VARIANT)_hal.h>'
|
||||
CFLAGS += -D__START=main
|
||||
|
||||
LDFLAGS = $(CFLAGS)
|
||||
|
@ -89,10 +86,6 @@ LIBS := -L $(dir $(LIBM_FILE_NAME)) -lm
|
|||
LIBS += -L $(dir $(LIBC_FILE_NAME)) -lc
|
||||
LIBS += -L $(dir $(LIBGCC_FILE_NAME)) -lgcc
|
||||
|
||||
SRC_HAL = $(addprefix hal/,\
|
||||
hal_rng.c \
|
||||
)
|
||||
|
||||
SRC_NRFX = $(addprefix nrfx/,\
|
||||
drivers/src/nrfx_spim.c \
|
||||
drivers/src/nrfx_twim.c \
|
||||
|
@ -135,7 +128,6 @@ DRIVERS_SRC_C += $(addprefix modules/,\
|
|||
ubluepy/ubluepy_scanner.c \
|
||||
ubluepy/ubluepy_scan_entry.c \
|
||||
ble/modble.c \
|
||||
random/modrandom.c \
|
||||
)
|
||||
|
||||
SRC_COMMON_HAL += \
|
||||
|
@ -201,7 +193,8 @@ SRC_SHARED_BINDINGS = \
|
|||
bitbangio/__init__.c \
|
||||
bitbangio/I2C.c \
|
||||
bitbangio/SPI.c \
|
||||
bitbangio/OneWire.c
|
||||
bitbangio/OneWire.c \
|
||||
random/__init__.c
|
||||
|
||||
|
||||
SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_BINDINGS)) \
|
||||
|
@ -212,7 +205,6 @@ FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/,$(FROZEN_MPY_PY_FILES:.py=.mpy))
|
|||
|
||||
OBJ += $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
||||
OBJ += $(BUILD)/pins_gen.o
|
||||
OBJ += $(addprefix $(BUILD)/, $(SRC_HAL:.c=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(SRC_NRFX:.c=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o))
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
#ifndef NRF52_HAL_CONF_H__
|
||||
#define NRF52_HAL_CONF_H__
|
||||
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
#define HAL_SPI_MODULE_ENABLED
|
||||
#define HAL_TIME_MODULE_ENABLED
|
||||
#define HAL_PWM_MODULE_ENABLED
|
||||
#define HAL_RTC_MODULE_ENABLED
|
||||
#define HAL_TIMER_MODULE_ENABLED
|
||||
#define HAL_TWI_MODULE_ENABLED
|
||||
#define HAL_ADCE_MODULE_ENABLED
|
||||
#define HAL_TEMP_MODULE_ENABLED
|
||||
#define HAL_RNG_MODULE_ENABLED
|
||||
// #define HAL_UARTE_MODULE_ENABLED
|
||||
// #define HAL_SPIE_MODULE_ENABLED
|
||||
// #define HAL_TWIE_MODULE_ENABLED
|
||||
|
||||
#endif // NRF52_HAL_CONF_H__
|
|
@ -1,18 +0,0 @@
|
|||
#ifndef NRF52_HAL_CONF_H__
|
||||
#define NRF52_HAL_CONF_H__
|
||||
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
#define HAL_SPI_MODULE_ENABLED
|
||||
#define HAL_TIME_MODULE_ENABLED
|
||||
#define HAL_PWM_MODULE_ENABLED
|
||||
#define HAL_RTC_MODULE_ENABLED
|
||||
#define HAL_TIMER_MODULE_ENABLED
|
||||
#define HAL_TWI_MODULE_ENABLED
|
||||
#define HAL_ADCE_MODULE_ENABLED
|
||||
#define HAL_TEMP_MODULE_ENABLED
|
||||
#define HAL_RNG_MODULE_ENABLED
|
||||
// #define HAL_UARTE_MODULE_ENABLED
|
||||
// #define HAL_SPIE_MODULE_ENABLED
|
||||
// #define HAL_TWIE_MODULE_ENABLED
|
||||
|
||||
#endif // NRF52_HAL_CONF_H__
|
|
@ -1,18 +0,0 @@
|
|||
#ifndef NRF52_HAL_CONF_H__
|
||||
#define NRF52_HAL_CONF_H__
|
||||
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
#define HAL_SPI_MODULE_ENABLED
|
||||
#define HAL_TIME_MODULE_ENABLED
|
||||
#define HAL_PWM_MODULE_ENABLED
|
||||
#define HAL_RTC_MODULE_ENABLED
|
||||
#define HAL_TIMER_MODULE_ENABLED
|
||||
#define HAL_TWI_MODULE_ENABLED
|
||||
#define HAL_ADCE_MODULE_ENABLED
|
||||
#define HAL_TEMP_MODULE_ENABLED
|
||||
#define HAL_RNG_MODULE_ENABLED
|
||||
// #define HAL_UARTE_MODULE_ENABLED
|
||||
// #define HAL_SPIE_MODULE_ENABLED
|
||||
// #define HAL_TWIE_MODULE_ENABLED
|
||||
|
||||
#endif // NRF52_HAL_CONF_H__
|
|
@ -1,18 +0,0 @@
|
|||
#ifndef NRF52_HAL_CONF_H__
|
||||
#define NRF52_HAL_CONF_H__
|
||||
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
#define HAL_SPI_MODULE_ENABLED
|
||||
#define HAL_TIME_MODULE_ENABLED
|
||||
#define HAL_PWM_MODULE_ENABLED
|
||||
#define HAL_RTC_MODULE_ENABLED
|
||||
#define HAL_TIMER_MODULE_ENABLED
|
||||
#define HAL_TWI_MODULE_ENABLED
|
||||
#define HAL_ADCE_MODULE_ENABLED
|
||||
#define HAL_TEMP_MODULE_ENABLED
|
||||
#define HAL_RNG_MODULE_ENABLED
|
||||
// #define HAL_UARTE_MODULE_ENABLED
|
||||
// #define HAL_SPIE_MODULE_ENABLED
|
||||
// #define HAL_TWIE_MODULE_ENABLED
|
||||
|
||||
#endif // NRF52_HAL_CONF_H__
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Glenn Ruben Bakke
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "mphalport.h"
|
||||
#include "hal_rng.h"
|
||||
|
||||
#ifdef HAL_RNG_MODULE_ENABLED
|
||||
|
||||
#if BLUETOOTH_SD
|
||||
#include "py/nlr.h"
|
||||
#include "ble_drv.h"
|
||||
#include "nrf_soc.h"
|
||||
|
||||
#define BLUETOOTH_STACK_ENABLED() (ble_drv_stack_enabled())
|
||||
|
||||
#endif // BLUETOOTH_SD
|
||||
|
||||
uint32_t hal_rng_generate(void) {
|
||||
|
||||
uint32_t retval = 0;
|
||||
|
||||
#if BLUETOOTH_SD
|
||||
|
||||
if (BLUETOOTH_STACK_ENABLED() == 1) {
|
||||
uint32_t status;
|
||||
do {
|
||||
status = sd_rand_application_vector_get((uint8_t *)&retval, 4); // Extract 4 bytes
|
||||
} while (status != 0);
|
||||
} else {
|
||||
#endif
|
||||
uint8_t * p_retval = (uint8_t *)&retval;
|
||||
|
||||
NRF_RNG->EVENTS_VALRDY = 0;
|
||||
NRF_RNG->TASKS_START = 1;
|
||||
|
||||
for (uint16_t i = 0; i < 4; i++) {
|
||||
while (NRF_RNG->EVENTS_VALRDY == 0) {
|
||||
;
|
||||
}
|
||||
NRF_RNG->EVENTS_VALRDY = 0;
|
||||
p_retval[i] = NRF_RNG->VALUE;
|
||||
}
|
||||
|
||||
NRF_RNG->TASKS_STOP = 1;
|
||||
#if BLUETOOTH_SD
|
||||
}
|
||||
#endif
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif // HAL_RNG_MODULE_ENABLED
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Glenn Ruben Bakke
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef HAL_RNG_H__
|
||||
#define HAL_RNG_H__
|
||||
|
||||
#include "nrf.h"
|
||||
|
||||
uint32_t hal_rng_generate(void);
|
||||
|
||||
#endif // HAL_RNG_H__
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Glenn Ruben Bakke
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <nrf.h>
|
||||
|
||||
// include config from board
|
||||
#include "nrf52_hal_conf.h"
|
|
@ -1,177 +0,0 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Paul Sokolovsky
|
||||
* Copyright (c) 2016 Damien P. George
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "py/runtime.h"
|
||||
#include "hal_rng.h"
|
||||
|
||||
#if MICROPY_PY_HW_RNG
|
||||
|
||||
static inline int rand30() {
|
||||
uint32_t val = hal_rng_generate();
|
||||
return (val & 0x3fffffff); // binary mask b00111111111111111111111111111111
|
||||
}
|
||||
|
||||
static inline int randbelow(int n) {
|
||||
return rand30() % n;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t mod_random_getrandbits(mp_obj_t num_in) {
|
||||
int n = mp_obj_get_int(num_in);
|
||||
if (n > 30 || n == 0) {
|
||||
nlr_raise(mp_obj_new_exception(&mp_type_ValueError));
|
||||
}
|
||||
uint32_t mask = ~0;
|
||||
// Beware of C undefined behavior when shifting by >= than bit size
|
||||
mask >>= (32 - n);
|
||||
return mp_obj_new_int_from_uint(rand30() & mask);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_random_getrandbits_obj, mod_random_getrandbits);
|
||||
|
||||
STATIC mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
|
||||
mp_int_t start = mp_obj_get_int(args[0]);
|
||||
if (n_args == 1) {
|
||||
// range(stop)
|
||||
if (start > 0) {
|
||||
return mp_obj_new_int(randbelow(start));
|
||||
} else {
|
||||
nlr_raise(mp_obj_new_exception(&mp_type_ValueError));
|
||||
}
|
||||
} else {
|
||||
mp_int_t stop = mp_obj_get_int(args[1]);
|
||||
if (n_args == 2) {
|
||||
// range(start, stop)
|
||||
if (start < stop) {
|
||||
return mp_obj_new_int(start + randbelow(stop - start));
|
||||
} else {
|
||||
nlr_raise(mp_obj_new_exception(&mp_type_ValueError));
|
||||
}
|
||||
} else {
|
||||
// range(start, stop, step)
|
||||
mp_int_t step = mp_obj_get_int(args[2]);
|
||||
mp_int_t n;
|
||||
if (step > 0) {
|
||||
n = (stop - start + step - 1) / step;
|
||||
} else if (step < 0) {
|
||||
n = (stop - start + step + 1) / step;
|
||||
} else {
|
||||
nlr_raise(mp_obj_new_exception(&mp_type_ValueError));
|
||||
}
|
||||
if (n > 0) {
|
||||
return mp_obj_new_int(start + step * randbelow(n));
|
||||
} else {
|
||||
nlr_raise(mp_obj_new_exception(&mp_type_ValueError));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_randrange_obj, 1, 3, mod_random_randrange);
|
||||
|
||||
STATIC mp_obj_t mod_random_randint(mp_obj_t a_in, mp_obj_t b_in) {
|
||||
mp_int_t a = mp_obj_get_int(a_in);
|
||||
mp_int_t b = mp_obj_get_int(b_in);
|
||||
if (a <= b) {
|
||||
return mp_obj_new_int(a + randbelow(b - a + 1));
|
||||
} else {
|
||||
nlr_raise(mp_obj_new_exception(&mp_type_ValueError));
|
||||
}
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_random_randint_obj, mod_random_randint);
|
||||
|
||||
STATIC mp_obj_t mod_random_choice(mp_obj_t seq) {
|
||||
mp_int_t len = mp_obj_get_int(mp_obj_len(seq));
|
||||
if (len > 0) {
|
||||
return mp_obj_subscr(seq, mp_obj_new_int(randbelow(len)), MP_OBJ_SENTINEL);
|
||||
} else {
|
||||
nlr_raise(mp_obj_new_exception(&mp_type_IndexError));
|
||||
}
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_random_choice_obj, mod_random_choice);
|
||||
|
||||
#if MICROPY_PY_BUILTINS_FLOAT
|
||||
|
||||
// returns a number in the range [0..1) using RNG to fill in the fraction bits
|
||||
STATIC mp_float_t randfloat(void) {
|
||||
#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
|
||||
typedef uint64_t mp_float_int_t;
|
||||
#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
|
||||
typedef uint32_t mp_float_int_t;
|
||||
#endif
|
||||
union {
|
||||
mp_float_t f;
|
||||
#if MP_ENDIANNESS_LITTLE
|
||||
struct { mp_float_int_t frc:MP_FLOAT_FRAC_BITS, exp:MP_FLOAT_EXP_BITS, sgn:1; } p;
|
||||
#else
|
||||
struct { mp_float_int_t sgn:1, exp:MP_FLOAT_EXP_BITS, frc:MP_FLOAT_FRAC_BITS; } p;
|
||||
#endif
|
||||
} u;
|
||||
u.p.sgn = 0;
|
||||
u.p.exp = (1 << (MP_FLOAT_EXP_BITS - 1)) - 1;
|
||||
if (MP_FLOAT_FRAC_BITS <= 30) {
|
||||
u.p.frc = rand30();
|
||||
} else {
|
||||
u.p.frc = ((uint64_t)rand30() << 30) | (uint64_t)rand30();
|
||||
}
|
||||
return u.f - 1;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t mod_random_random(void) {
|
||||
return mp_obj_new_float(randfloat());
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_random_random_obj, mod_random_random);
|
||||
|
||||
STATIC mp_obj_t mod_random_uniform(mp_obj_t a_in, mp_obj_t b_in) {
|
||||
mp_float_t a = mp_obj_get_float(a_in);
|
||||
mp_float_t b = mp_obj_get_float(b_in);
|
||||
return mp_obj_new_float(a + (b - a) * randfloat());
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_random_uniform_obj, mod_random_uniform);
|
||||
|
||||
#endif
|
||||
|
||||
STATIC const mp_rom_map_elem_t mp_module_random_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_random) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_getrandbits), MP_ROM_PTR(&mod_random_getrandbits_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_randrange), MP_ROM_PTR(&mod_random_randrange_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_randint), MP_ROM_PTR(&mod_random_randint_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_choice), MP_ROM_PTR(&mod_random_choice_obj) },
|
||||
#if MICROPY_PY_BUILTINS_FLOAT
|
||||
{ MP_ROM_QSTR(MP_QSTR_random), MP_ROM_PTR(&mod_random_random_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_uniform), MP_ROM_PTR(&mod_random_uniform_obj) },
|
||||
#endif
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(mp_module_random_globals, mp_module_random_globals_table);
|
||||
|
||||
const mp_obj_module_t random_module = {
|
||||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t*)&mp_module_random_globals,
|
||||
};
|
||||
|
||||
#endif // MICROPY_PY_HW_RNG
|
|
@ -183,16 +183,9 @@ extern const struct _mp_obj_module_t supervisor_module;
|
|||
extern const struct _mp_obj_module_t gamepad_module;
|
||||
|
||||
extern const struct _mp_obj_module_t mp_module_ubluepy;
|
||||
extern const struct _mp_obj_module_t random_module;
|
||||
|
||||
extern const struct _mp_obj_module_t ble_module;
|
||||
|
||||
#if MICROPY_PY_HW_RNG
|
||||
#define RANDOM_MODULE { MP_ROM_QSTR(MP_QSTR_random), MP_ROM_PTR(&random_module) },
|
||||
#else
|
||||
#define RANDOM_MODULE
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_UBLUEPY
|
||||
#define UBLUEPY_MODULE { MP_ROM_QSTR(MP_QSTR_ubluepy), MP_ROM_PTR(&mp_module_ubluepy) },
|
||||
#else
|
||||
|
@ -221,7 +214,6 @@ extern const struct _mp_obj_module_t ble_module;
|
|||
{ MP_OBJ_NEW_QSTR (MP_QSTR_supervisor ), (mp_obj_t)&supervisor_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_gamepad ), (mp_obj_t)&gamepad_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_time ), (mp_obj_t)&time_module }, \
|
||||
RANDOM_MODULE \
|
||||
BLE_MODULE \
|
||||
UBLUEPY_MODULE \
|
||||
|
||||
|
|
|
@ -31,10 +31,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include "lib/utils/interrupt_char.h"
|
||||
#include "nrf.h"
|
||||
#include NRF5_HAL_H
|
||||
#include "nrfx_uart.h"
|
||||
#include "pin.h"
|
||||
#include "py/mpconfig.h"
|
||||
|
||||
extern nrfx_uart_t serial_instance;
|
||||
|
|
Loading…
Reference in New Issue