Commit 9b78f3e6 authored by Damien George's avatar Damien George

stm32: Make pyb, uos, utime, machine and onewire modules configurable.

The default for these is to enable them, but they can now be disabled
individually by a board configuration.
Signed-off-by: default avatarDamien George <damien@micropython.org>
parent caeec80a
...@@ -406,7 +406,9 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { ...@@ -406,7 +406,9 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_disable_irq), MP_ROM_PTR(&machine_disable_irq_obj) }, { MP_ROM_QSTR(MP_QSTR_disable_irq), MP_ROM_PTR(&machine_disable_irq_obj) },
{ MP_ROM_QSTR(MP_QSTR_enable_irq), MP_ROM_PTR(&machine_enable_irq_obj) }, { MP_ROM_QSTR(MP_QSTR_enable_irq), MP_ROM_PTR(&machine_enable_irq_obj) },
#if MICROPY_PY_MACHINE_PULSE
{ MP_ROM_QSTR(MP_QSTR_time_pulse_us), MP_ROM_PTR(&machine_time_pulse_us_obj) }, { MP_ROM_QSTR(MP_QSTR_time_pulse_us), MP_ROM_PTR(&machine_time_pulse_us_obj) },
#endif
{ MP_ROM_QSTR(MP_QSTR_mem8), MP_ROM_PTR(&machine_mem8_obj) }, { MP_ROM_QSTR(MP_QSTR_mem8), MP_ROM_PTR(&machine_mem8_obj) },
{ MP_ROM_QSTR(MP_QSTR_mem16), MP_ROM_PTR(&machine_mem16_obj) }, { MP_ROM_QSTR(MP_QSTR_mem16), MP_ROM_PTR(&machine_mem16_obj) },
...@@ -425,8 +427,10 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { ...@@ -425,8 +427,10 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
#endif #endif
{ MP_ROM_QSTR(MP_QSTR_SoftI2C), MP_ROM_PTR(&mp_machine_soft_i2c_type) }, { MP_ROM_QSTR(MP_QSTR_SoftI2C), MP_ROM_PTR(&mp_machine_soft_i2c_type) },
#endif #endif
#if MICROPY_PY_MACHINE_SPI
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&machine_hard_spi_type) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&machine_hard_spi_type) },
{ MP_ROM_QSTR(MP_QSTR_SoftSPI), MP_ROM_PTR(&mp_machine_soft_spi_type) }, { MP_ROM_QSTR(MP_QSTR_SoftSPI), MP_ROM_PTR(&mp_machine_soft_spi_type) },
#endif
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&pyb_uart_type) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&pyb_uart_type) },
{ MP_ROM_QSTR(MP_QSTR_WDT), MP_ROM_PTR(&pyb_wdt_type) }, { MP_ROM_QSTR(MP_QSTR_WDT), MP_ROM_PTR(&pyb_wdt_type) },
{ MP_ROM_QSTR(MP_QSTR_Timer), MP_ROM_PTR(&machine_timer_type) }, { MP_ROM_QSTR(MP_QSTR_Timer), MP_ROM_PTR(&machine_timer_type) },
......
...@@ -37,6 +37,11 @@ ...@@ -37,6 +37,11 @@
#define MICROPY_PY_STM (1) #define MICROPY_PY_STM (1)
#endif #endif
// Whether to include the pyb module
#ifndef MICROPY_PY_PYB
#define MICROPY_PY_PYB (1)
#endif
// Whether to include legacy functions and classes in the pyb module // Whether to include legacy functions and classes in the pyb module
#ifndef MICROPY_PY_PYB_LEGACY #ifndef MICROPY_PY_PYB_LEGACY
#define MICROPY_PY_PYB_LEGACY (1) #define MICROPY_PY_PYB_LEGACY (1)
......
...@@ -166,6 +166,11 @@ ...@@ -166,6 +166,11 @@
#ifndef MICROPY_PY_UBINASCII #ifndef MICROPY_PY_UBINASCII
#define MICROPY_PY_UBINASCII (1) #define MICROPY_PY_UBINASCII (1)
#endif #endif
#ifndef MICROPY_PY_UOS
#define MICROPY_PY_UOS (1)
#endif
#define MICROPY_PY_OS_DUPTERM (3)
#define MICROPY_PY_UOS_DUPTERM_BUILTIN_STREAM (1)
#ifndef MICROPY_PY_URANDOM #ifndef MICROPY_PY_URANDOM
#define MICROPY_PY_URANDOM (1) #define MICROPY_PY_URANDOM (1)
#define MICROPY_PY_URANDOM_SEED_INIT_FUNC (rng_get()) #define MICROPY_PY_URANDOM_SEED_INIT_FUNC (rng_get())
...@@ -174,13 +179,15 @@ ...@@ -174,13 +179,15 @@
#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1) #define MICROPY_PY_URANDOM_EXTRA_FUNCS (1)
#endif #endif
#define MICROPY_PY_USELECT (1) #define MICROPY_PY_USELECT (1)
#ifndef MICROPY_PY_UTIME
#define MICROPY_PY_UTIME (1)
#endif
#define MICROPY_PY_UTIME_MP_HAL (MICROPY_PY_UTIME)
#ifndef MICROPY_PY_UTIMEQ #ifndef MICROPY_PY_UTIMEQ
#define MICROPY_PY_UTIMEQ (1) #define MICROPY_PY_UTIMEQ (1)
#endif #endif
#define MICROPY_PY_UTIME_MP_HAL (1)
#define MICROPY_PY_OS_DUPTERM (3)
#define MICROPY_PY_UOS_DUPTERM_BUILTIN_STREAM (1)
#define MICROPY_PY_LWIP_SOCK_RAW (MICROPY_PY_LWIP) #define MICROPY_PY_LWIP_SOCK_RAW (MICROPY_PY_LWIP)
#ifndef MICROPY_PY_MACHINE
#define MICROPY_PY_MACHINE (1) #define MICROPY_PY_MACHINE (1)
#define MICROPY_PY_MACHINE_PULSE (1) #define MICROPY_PY_MACHINE_PULSE (1)
#define MICROPY_PY_MACHINE_PIN_MAKE_NEW mp_pin_make_new #define MICROPY_PY_MACHINE_PIN_MAKE_NEW mp_pin_make_new
...@@ -188,6 +195,7 @@ ...@@ -188,6 +195,7 @@
#define MICROPY_PY_MACHINE_SPI (1) #define MICROPY_PY_MACHINE_SPI (1)
#define MICROPY_PY_MACHINE_SPI_MSB (SPI_FIRSTBIT_MSB) #define MICROPY_PY_MACHINE_SPI_MSB (SPI_FIRSTBIT_MSB)
#define MICROPY_PY_MACHINE_SPI_LSB (SPI_FIRSTBIT_LSB) #define MICROPY_PY_MACHINE_SPI_LSB (SPI_FIRSTBIT_LSB)
#endif
#define MICROPY_HW_SOFTSPI_MIN_DELAY (0) #define MICROPY_HW_SOFTSPI_MIN_DELAY (0)
#define MICROPY_HW_SOFTSPI_MAX_BAUDRATE (HAL_RCC_GetSysClockFreq() / 48) #define MICROPY_HW_SOFTSPI_MAX_BAUDRATE (HAL_RCC_GetSysClockFreq() / 48)
#define MICROPY_PY_UWEBSOCKET (MICROPY_PY_LWIP) #define MICROPY_PY_UWEBSOCKET (MICROPY_PY_LWIP)
...@@ -201,6 +209,9 @@ ...@@ -201,6 +209,9 @@
#ifndef MICROPY_PY_NETWORK #ifndef MICROPY_PY_NETWORK
#define MICROPY_PY_NETWORK (1) #define MICROPY_PY_NETWORK (1)
#endif #endif
#ifndef MICROPY_PY_ONEWIRE
#define MICROPY_PY_ONEWIRE (1)
#endif
// fatfs configuration used in ffconf.h // fatfs configuration used in ffconf.h
#define MICROPY_FATFS_ENABLE_LFN (1) #define MICROPY_FATFS_ENABLE_LFN (1)
...@@ -246,12 +257,38 @@ extern const struct _mp_obj_module_t mp_module_usocket; ...@@ -246,12 +257,38 @@ extern const struct _mp_obj_module_t mp_module_usocket;
extern const struct _mp_obj_module_t mp_module_network; extern const struct _mp_obj_module_t mp_module_network;
extern const struct _mp_obj_module_t mp_module_onewire; extern const struct _mp_obj_module_t mp_module_onewire;
#if MICROPY_PY_PYB
#define PYB_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) },
#else
#define PYB_BUILTIN_MODULE
#endif
#if MICROPY_PY_STM #if MICROPY_PY_STM
#define STM_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_stm), MP_ROM_PTR(&stm_module) }, #define STM_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_stm), MP_ROM_PTR(&stm_module) },
#else #else
#define STM_BUILTIN_MODULE #define STM_BUILTIN_MODULE
#endif #endif
#if MICROPY_PY_MACHINE
#define MACHINE_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&machine_module) },
#define MACHINE_BUILTIN_MODULE_CONSTANTS { MP_ROM_QSTR(MP_QSTR_machine), MP_ROM_PTR(&machine_module) },
#else
#define MACHINE_BUILTIN_MODULE
#define MACHINE_BUILTIN_MODULE_CONSTANTS
#endif
#if MICROPY_PY_UOS
#define UOS_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_uos) },
#else
#define UOS_BUILTIN_MODULE
#endif
#if MICROPY_PY_UTIME
#define UTIME_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_utime) },
#else
#define UTIME_BUILTIN_MODULE
#endif
#if MICROPY_PY_USOCKET && MICROPY_PY_LWIP #if MICROPY_PY_USOCKET && MICROPY_PY_LWIP
// usocket implementation provided by lwIP // usocket implementation provided by lwIP
#define SOCKET_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_lwip) }, #define SOCKET_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_lwip) },
...@@ -269,21 +306,27 @@ extern const struct _mp_obj_module_t mp_module_onewire; ...@@ -269,21 +306,27 @@ extern const struct _mp_obj_module_t mp_module_onewire;
#define NETWORK_BUILTIN_MODULE #define NETWORK_BUILTIN_MODULE
#endif #endif
#if MICROPY_PY_ONEWIRE
#define ONEWIRE_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR__onewire), MP_ROM_PTR(&mp_module_onewire) },
#else
#define ONEWIRE_BUILTIN_MODULE
#endif
#define MICROPY_PORT_BUILTIN_MODULES \ #define MICROPY_PORT_BUILTIN_MODULES \
{ MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&machine_module) }, \ MACHINE_BUILTIN_MODULE \
{ MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) }, \ PYB_BUILTIN_MODULE \
STM_BUILTIN_MODULE \ STM_BUILTIN_MODULE \
{ MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_uos) }, \ UOS_BUILTIN_MODULE \
{ MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_utime) }, \ UTIME_BUILTIN_MODULE \
SOCKET_BUILTIN_MODULE \ SOCKET_BUILTIN_MODULE \
NETWORK_BUILTIN_MODULE \ NETWORK_BUILTIN_MODULE \
{ MP_ROM_QSTR(MP_QSTR__onewire), MP_ROM_PTR(&mp_module_onewire) }, \ ONEWIRE_BUILTIN_MODULE \
// extra constants // extra constants
#define MICROPY_PORT_CONSTANTS \ #define MICROPY_PORT_CONSTANTS \
{ MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&machine_module) }, \ MACHINE_BUILTIN_MODULE \
{ MP_ROM_QSTR(MP_QSTR_machine), MP_ROM_PTR(&machine_module) }, \ MACHINE_BUILTIN_MODULE_CONSTANTS \
{ MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) }, \ PYB_BUILTIN_MODULE \
STM_BUILTIN_MODULE \ STM_BUILTIN_MODULE \
#define MP_STATE_PORT MP_STATE_VM #define MP_STATE_PORT MP_STATE_VM
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment