nrf5: Update pyb module, and led module to only be compiled in if MICROPY_HW_HAS_LED is set to 1.

This commit is contained in:
Glenn Ruben Bakke 2017-06-05 17:39:47 +02:00
parent 9779910e3e
commit 2f983d3ef9
4 changed files with 15 additions and 7 deletions

View File

@ -37,8 +37,10 @@ const char * nrf5_help_text =
"For online help please visit http://micropython.org/help/.\n"
"\n"
"Quick overview of commands for the board:\n"
#if MICROPY_HW_HAS_LED
" pyb.LED(n) -- create an LED object for LED n (n=" HELP_TEXT_BOARD_LED ")\n"
"\n"
#endif
#if BLUETOOTH_SD
HELP_TEXT_SD
#endif

View File

@ -90,7 +90,6 @@ soft_reset:
// to recover from limit hit. (Limit is measured in bytes.)
mp_stack_set_limit((char*)&_ram_end - (char*)&_heap_end - 400);
led_init();
machine_init();
gc_init(&_heap_start, &_heap_end);
@ -171,11 +170,9 @@ pin_init0();
}
#endif
#if MICROPY_HW_LED_TRICOLOR
do_str("import pyb\r\n" \
"pyb.LED(1).on()",
MP_PARSE_FILE_INPUT);
#elif (MICROPY_HW_LED_COUNT > 0)
#if (MICROPY_HW_HAS_LED)
led_init();
do_str("import pyb\r\n" \
"pyb.LED(1).on()",
MP_PARSE_FILE_INPUT);

View File

@ -31,6 +31,8 @@
#include "led.h"
#include "mpconfigboard.h"
#if MICROPY_HW_HAS_LED
#define LED_OFF(led) {(MICROPY_HW_LED_PULLUP) ? hal_gpio_pin_set(0, led) : hal_gpio_pin_clear(0, led); }
#define LED_ON(led) {(MICROPY_HW_LED_PULLUP) ? hal_gpio_pin_clear(0, led) : hal_gpio_pin_set(0, led); }
@ -154,3 +156,4 @@ const mp_obj_type_t pyb_led_type = {
.locals_dict = (mp_obj_dict_t*)&led_locals_dict,
};
#endif // MICROPY_HW_HAS_LED

View File

@ -32,11 +32,17 @@
#include "nrf.h" // TODO: figure out where to put this import
#include "pin.h"
#if MICROPY_HW_HAS_LED
#define PYB_LED_MODULE { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pyb_led_type) },
#else
#define PYB_LED_MODULE
#endif
STATIC const mp_rom_map_elem_t pyb_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_pyb) },
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pyb_led_type) },
{ MP_ROM_QSTR(MP_QSTR_repl_info), MP_ROM_PTR(&pyb_set_repl_info_obj) },
{ MP_ROM_QSTR(MP_QSTR_Pin), MP_ROM_PTR(&pin_type) },
PYB_LED_MODULE
/* { MP_ROM_QSTR(MP_QSTR_main), MP_ROM_PTR(&pyb_main_obj) }*/
};