aboutsummaryrefslogtreecommitdiff
path: root/ports/nrf/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'ports/nrf/main.c')
-rw-r--r--ports/nrf/main.c95
1 files changed, 49 insertions, 46 deletions
diff --git a/ports/nrf/main.c b/ports/nrf/main.c
index af5991281..3c5d0a05d 100644
--- a/ports/nrf/main.c
+++ b/ports/nrf/main.c
@@ -110,7 +110,7 @@ soft_reset:
// Stack limit should be less than real stack size, so we have a chance
// to recover from limit hit. (Limit is measured in bytes.)
- mp_stack_set_limit((char*)&_ram_end - (char*)&_heap_end - 400);
+ mp_stack_set_limit((char *)&_ram_end - (char *)&_heap_end - 400);
machine_init();
@@ -124,35 +124,35 @@ soft_reset:
readline_init0();
-#if MICROPY_PY_MACHINE_HW_SPI
+ #if MICROPY_PY_MACHINE_HW_SPI
spi_init0();
-#endif
+ #endif
-#if MICROPY_PY_MACHINE_I2C
+ #if MICROPY_PY_MACHINE_I2C
i2c_init0();
-#endif
+ #endif
-#if MICROPY_PY_MACHINE_ADC
+ #if MICROPY_PY_MACHINE_ADC
adc_init0();
-#endif
+ #endif
-#if MICROPY_PY_MACHINE_HW_PWM
+ #if MICROPY_PY_MACHINE_HW_PWM
pwm_init0();
-#endif
+ #endif
-#if MICROPY_PY_MACHINE_RTCOUNTER
+ #if MICROPY_PY_MACHINE_RTCOUNTER
rtc_init0();
-#endif
+ #endif
-#if MICROPY_PY_MACHINE_TIMER
+ #if MICROPY_PY_MACHINE_TIMER
timer_init0();
-#endif
+ #endif
-#if MICROPY_PY_MACHINE_UART
+ #if MICROPY_PY_MACHINE_UART
uart_init0();
-#endif
+ #endif
-#if (MICROPY_PY_BLE_NUS == 0) && (MICROPY_HW_USB_CDC == 0)
+ #if (MICROPY_PY_BLE_NUS == 0) && (MICROPY_HW_USB_CDC == 0)
{
mp_obj_t args[2] = {
MP_OBJ_NEW_SMALL_INT(0),
@@ -160,15 +160,15 @@ soft_reset:
};
MP_STATE_PORT(board_stdio_uart) = machine_hard_uart_type.make_new((mp_obj_t)&machine_hard_uart_type, MP_ARRAY_SIZE(args), 0, args);
}
-#endif
+ #endif
-pin_init0();
+ pin_init0();
-#if MICROPY_MBFS
+ #if MICROPY_MBFS
microbit_filesystem_init();
-#endif
+ #endif
-#if MICROPY_HW_HAS_SDCARD
+ #if MICROPY_HW_HAS_SDCARD
// if an SD card is present then mount it on /sd/
if (sdcard_is_present()) {
// create vfs object
@@ -197,46 +197,46 @@ pin_init0();
// use SD card as current directory
f_chdrive("/sd");
}
- no_mem_for_sd:;
+ no_mem_for_sd:;
}
-#endif
+ #endif
// Main script is finished, so now go into REPL mode.
// The REPL mode can change, or it can request a soft reset.
int ret_code = 0;
-#if MICROPY_PY_BLE_NUS
+ #if MICROPY_PY_BLE_NUS
ble_uart_init0();
-#endif
+ #endif
-#if MICROPY_PY_MACHINE_SOFT_PWM
+ #if MICROPY_PY_MACHINE_SOFT_PWM
ticker_init0();
softpwm_init0();
-#endif
+ #endif
-#if MICROPY_PY_MUSIC
+ #if MICROPY_PY_MUSIC
microbit_music_init0();
-#endif
-#if BOARD_SPECIFIC_MODULES
+ #endif
+ #if BOARD_SPECIFIC_MODULES
board_modules_init0();
-#endif
+ #endif
-#if MICROPY_PY_MACHINE_SOFT_PWM
+ #if MICROPY_PY_MACHINE_SOFT_PWM
ticker_start();
pwm_start();
-#endif
+ #endif
-led_state(1, 0);
+ led_state(1, 0);
-#if MICROPY_VFS || MICROPY_MBFS || MICROPY_MODULE_FROZEN
+ #if MICROPY_VFS || MICROPY_MBFS || MICROPY_MODULE_FROZEN
// run boot.py and main.py if they exist.
pyexec_file_if_exists("boot.py");
pyexec_file_if_exists("main.py");
-#endif
+ #endif
-#if MICROPY_HW_USB_CDC
+ #if MICROPY_HW_USB_CDC
usb_cdc_init();
-#endif
+ #endif
for (;;) {
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
@@ -255,9 +255,9 @@ led_state(1, 0);
printf("MPY: soft reboot\n");
-#if BLUETOOTH_SD
+ #if BLUETOOTH_SD
sd_softdevice_disable();
-#endif
+ #endif
goto soft_reset;
@@ -298,9 +298,8 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open);
#endif
-void HardFault_Handler(void)
-{
-#if defined(NRF52_SERIES) || defined(NRF91_SERIES)
+void HardFault_Handler(void) {
+ #if defined(NRF52_SERIES) || defined(NRF91_SERIES)
static volatile uint32_t reg;
static volatile uint32_t reg2;
static volatile uint32_t bfar;
@@ -312,11 +311,13 @@ void HardFault_Handler(void)
(void)reg2;
(void)bfar;
}
-#endif
+ #endif
}
void NORETURN __fatal_error(const char *msg) {
- while (1);
+ while (1) {
+ ;
+ }
}
void nlr_jump_fail(void *val) {
@@ -330,4 +331,6 @@ void MP_WEAK __assert_func(const char *file, int line, const char *func, const c
__fatal_error("Assertion failed");
}
-void _start(void) {main(0, NULL);}
+void _start(void) {
+ main(0, NULL);
+}