Browse Source

nrf: Make machine.UART optional.

Leave it enabled by default on all targets.

This is only possible when using UART-over-BLE (NUS) instead of the
default hardware peripheral. The flash area saved is quite substantial
(about 2.2KB) so this is useful for custom builds that do not need UART.
pull/3137/merge
Ayke van Laethem 7 years ago
committed by Damien George
parent
commit
987381dfa0
  1. 1
      ports/nrf/boards/arduino_primo/mpconfigboard.h
  2. 1
      ports/nrf/boards/dvk_bl652/mpconfigboard.h
  3. 1
      ports/nrf/boards/feather52/mpconfigboard.h
  4. 1
      ports/nrf/boards/microbit/mpconfigboard.h
  5. 1
      ports/nrf/boards/pca10000/mpconfigboard.h
  6. 1
      ports/nrf/boards/pca10001/mpconfigboard.h
  7. 1
      ports/nrf/boards/pca10028/mpconfigboard.h
  8. 1
      ports/nrf/boards/pca10031/mpconfigboard.h
  9. 1
      ports/nrf/boards/pca10040/mpconfigboard.h
  10. 1
      ports/nrf/boards/pca10056/mpconfigboard.h
  11. 1
      ports/nrf/boards/wt51822_s4at/mpconfigboard.h
  12. 2
      ports/nrf/main.c
  13. 2
      ports/nrf/modules/machine/modmachine.c
  14. 3
      ports/nrf/modules/machine/uart.c
  15. 4
      ports/nrf/modules/uos/moduos.c

1
ports/nrf/boards/arduino_primo/mpconfigboard.h

@ -31,6 +31,7 @@
#define MICROPY_PY_MACHINE_SOFT_PWM (1)
#define MICROPY_PY_MUSIC (1)
#define MICROPY_PY_MACHINE_UART (1)
#define MICROPY_PY_MACHINE_HW_PWM (1)
#define MICROPY_PY_MACHINE_HW_SPI (1)
#define MICROPY_PY_MACHINE_TIMER (1)

1
ports/nrf/boards/dvk_bl652/mpconfigboard.h

@ -30,6 +30,7 @@
#define MICROPY_HW_MCU_NAME "NRF52832"
#define MICROPY_PY_SYS_PLATFORM "bl652"
#define MICROPY_PY_MACHINE_UART (1)
#define MICROPY_PY_MACHINE_PWM (1)
#define MICROPY_PY_MACHINE_HW_SPI (1)
#define MICROPY_PY_MACHINE_TIMER (1)

1
ports/nrf/boards/feather52/mpconfigboard.h

@ -30,6 +30,7 @@
#define MICROPY_HW_MCU_NAME "NRF52832"
#define MICROPY_PY_SYS_PLATFORM "nrf52"
#define MICROPY_PY_MACHINE_UART (1)
#define MICROPY_PY_MACHINE_HW_PWM (1)
#define MICROPY_PY_MACHINE_HW_SPI (1)
#define MICROPY_PY_MACHINE_TIMER (1)

1
ports/nrf/boards/microbit/mpconfigboard.h

@ -30,6 +30,7 @@
#define MICROPY_HW_MCU_NAME "NRF51822"
#define MICROPY_PY_SYS_PLATFORM "nrf51"
#define MICROPY_PY_MACHINE_UART (1)
#define MICROPY_PY_MUSIC (1)
#define MICROPY_PY_MACHINE_SOFT_PWM (1)
#define MICROPY_PY_MACHINE_HW_SPI (1)

1
ports/nrf/boards/pca10000/mpconfigboard.h

@ -30,6 +30,7 @@
#define MICROPY_HW_MCU_NAME "NRF51822"
#define MICROPY_PY_SYS_PLATFORM "nrf51-dongle"
#define MICROPY_PY_MACHINE_UART (1)
#define MICROPY_PY_MACHINE_HW_SPI (0)
#define MICROPY_PY_MACHINE_TIMER (1)
#define MICROPY_PY_MACHINE_RTC (1)

1
ports/nrf/boards/pca10001/mpconfigboard.h

@ -30,6 +30,7 @@
#define MICROPY_HW_MCU_NAME "NRF51822"
#define MICROPY_PY_SYS_PLATFORM "nrf51-DK"
#define MICROPY_PY_MACHINE_UART (1)
#define MICROPY_PY_MACHINE_HW_SPI (0)
#define MICROPY_PY_MACHINE_TIMER (1)
#define MICROPY_PY_MACHINE_RTC (1)

1
ports/nrf/boards/pca10028/mpconfigboard.h

@ -30,6 +30,7 @@
#define MICROPY_HW_MCU_NAME "NRF51822"
#define MICROPY_PY_SYS_PLATFORM "nrf51-DK"
#define MICROPY_PY_MACHINE_UART (1)
#define MICROPY_PY_MACHINE_HW_SPI (1)
#define MICROPY_PY_MACHINE_TIMER (1)
#define MICROPY_PY_MACHINE_RTC (1)

1
ports/nrf/boards/pca10031/mpconfigboard.h

@ -30,6 +30,7 @@
#define MICROPY_HW_MCU_NAME "NRF51822"
#define MICROPY_PY_SYS_PLATFORM "nrf51-dongle"
#define MICROPY_PY_MACHINE_UART (1)
#define MICROPY_PY_MACHINE_HW_SPI (1)
#define MICROPY_PY_MACHINE_TIMER (1)
#define MICROPY_PY_MACHINE_RTC (1)

1
ports/nrf/boards/pca10040/mpconfigboard.h

@ -30,6 +30,7 @@
#define MICROPY_HW_MCU_NAME "NRF52832"
#define MICROPY_PY_SYS_PLATFORM "nrf52-DK"
#define MICROPY_PY_MACHINE_UART (1)
#define MICROPY_PY_MACHINE_HW_PWM (1)
#define MICROPY_PY_MACHINE_HW_SPI (1)
#define MICROPY_PY_MACHINE_TIMER (1)

1
ports/nrf/boards/pca10056/mpconfigboard.h

@ -30,6 +30,7 @@
#define MICROPY_HW_MCU_NAME "NRF52840"
#define MICROPY_PY_SYS_PLATFORM "nrf52840-PDK"
#define MICROPY_PY_MACHINE_UART (1)
#define MICROPY_PY_MACHINE_HW_PWM (1)
#define MICROPY_PY_MACHINE_HW_SPI (1)
#define MICROPY_PY_MACHINE_TIMER (1)

1
ports/nrf/boards/wt51822_s4at/mpconfigboard.h

@ -32,6 +32,7 @@
#define MICROPY_HW_MCU_NAME "NRF51822"
#define MICROPY_PY_SYS_PLATFORM "nrf51"
#define MICROPY_PY_MACHINE_UART (1)
#define MICROPY_PY_MACHINE_HW_SPI (1)
#define MICROPY_PY_MACHINE_TIMER (1)
#define MICROPY_PY_MACHINE_RTC (1)

2
ports/nrf/main.c

@ -134,7 +134,9 @@ soft_reset:
timer_init0();
#endif
#if MICROPY_PY_MACHINE_UART
uart_init0();
#endif
#if (MICROPY_PY_BLE_NUS == 0)
{

2
ports/nrf/modules/machine/modmachine.c

@ -201,7 +201,9 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_deepsleep), MP_ROM_PTR(&machine_deepsleep_obj) },
{ MP_ROM_QSTR(MP_QSTR_reset_cause), MP_ROM_PTR(&machine_reset_cause_obj) },
{ MP_ROM_QSTR(MP_QSTR_Pin), MP_ROM_PTR(&pin_type) },
#if MICROPY_PY_MACHINE_UART
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&machine_hard_uart_type) },
#endif
#if MICROPY_PY_MACHINE_HW_SPI
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&machine_hard_spi_type) },
#endif

3
ports/nrf/modules/machine/uart.c

@ -43,6 +43,8 @@
#include "mphalport.h"
#include "hal_uart.h"
#if MICROPY_PY_MACHINE_UART
typedef struct _machine_hard_uart_obj_t {
mp_obj_base_t base;
UART_HandleTypeDef * uart;
@ -380,3 +382,4 @@ const mp_obj_type_t machine_hard_uart_type = {
.locals_dict = (mp_obj_dict_t*)&machine_hard_uart_locals_dict,
};
#endif // MICROPY_PY_MACHINE_UART

4
ports/nrf/modules/uos/moduos.c

@ -109,6 +109,7 @@ STATIC mp_obj_t os_urandom(mp_obj_t num) {
STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_urandom_obj, os_urandom);
#endif
#if MICROPY_PY_MACHINE_UART
// Get or set the UART object that the REPL is repeated on.
// TODO should accept any object with read/write methods.
STATIC mp_obj_t os_dupterm(mp_uint_t n_args, const mp_obj_t *args) {
@ -130,6 +131,7 @@ STATIC mp_obj_t os_dupterm(mp_uint_t n_args, const mp_obj_t *args) {
}
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_os_dupterm_obj, 0, 1, os_dupterm);
#endif // MICROPY_PY_MACHINE_UART
STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uos) },
@ -165,7 +167,9 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
#endif
// these are MicroPython extensions
#if MICROPY_PY_MACHINE_UART
{ MP_ROM_QSTR(MP_QSTR_dupterm), MP_ROM_PTR(&mod_os_dupterm_obj) },
#endif
#if MICROPY_VFS
{ MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&mp_vfs_mount_obj) },
{ MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&mp_vfs_umount_obj) },

Loading…
Cancel
Save