replace MY_DEBUG_UART -> NRF_DEBUG_PRINT.

This commit is contained in:
jun2sak 2021-02-25 01:49:57 +09:00
parent 72b5f1a9a6
commit 9661d67cd3
8 changed files with 31 additions and 31 deletions

2
main.c
View File

@ -537,7 +537,7 @@ STATIC int run_repl(void) {
return exit_code;
}
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
extern void dbg_dump_reset_reason(void);
#endif

View File

@ -94,8 +94,8 @@ else
CFLAGS += -flto -flto-partition=none
endif
ifeq ($(MY_DEBUGUART), 1)
CFLAGS += -DMY_DEBUGUART=1
ifeq ($(NRF_DEBUG_PRINT), 1)
CFLAGS += -DNRF_DEBUG_PRINT=1
SRC_SUPERVISOR += supervisor/debug_uart.c
endif

View File

@ -29,7 +29,7 @@
#include "py/runtime.h"
#include "common-hal/alarm/SleepMemory.h"
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
extern void dbg_dump_RAMreg(void);
#endif
@ -66,7 +66,7 @@ static void initialize_sleep_memory(void) {
memset((uint8_t *)_sleep_mem, 0, SLEEP_MEMORY_LENGTH);
set_memory_retention();
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
dbg_dump_RAMreg();
#endif

View File

@ -42,7 +42,7 @@
//#include "shared-bindings/microcontroller/__init__.h"
#include "supervisor/port.h"
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
#include "supervisor/serial.h" // dbg_printf()
#endif
@ -98,7 +98,7 @@ bool alarm_woken_from_sleep(void) {
|| cause == NRF_SLEEP_WAKEUP_RESETPIN);
}
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
#if 0
static const char* cause_str[] = {
"UNDEFINED",
@ -150,7 +150,7 @@ STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t
}
STATIC void _idle_until_alarm(void) {
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
int ct = 40;
#endif
reset_reason_saved = 0;
@ -160,14 +160,14 @@ STATIC void _idle_until_alarm(void) {
// Allow ctrl-C interrupt.
if (alarm_woken_from_sleep()) {
alarm_save_wake_alarm();
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
int cause = _get_wakeup_cause();
printf("wakeup(%d)\r\n", cause);
#endif
return;
}
port_idle_until_interrupt();
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
if (ct > 0) {
printf("_");
--ct;
@ -179,14 +179,14 @@ STATIC void _idle_until_alarm(void) {
mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) {
mp_obj_t r_obj = mp_const_none;
_setup_sleep_alarms(false, n_alarms, alarms);
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
dbg_printf("\r\nsleep...");
#endif
_idle_until_alarm();
if (mp_hal_is_interrupted()) {
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
dbg_printf("mp_hal_is_interrupted\r\n");
#endif
r_obj = mp_const_none;
@ -213,7 +213,7 @@ void NORETURN alarm_enter_deep_sleep(void) {
set_memory_retention();
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
dbg_printf("go system off.. %d\r\n", sd_enabled);
#endif
if (sd_enabled) {

View File

@ -154,7 +154,7 @@ static void setup_pin1_for_lightsleep(void) {
};
for(size_t i = 0; i < 64; ++i) {
uint64_t mask = 1ull << i;
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
int pull = 0;
int sense = 0;
#endif
@ -165,7 +165,7 @@ static void setup_pin1_for_lightsleep(void) {
cfg.sense = NRF_GPIOTE_POLARITY_LOTOHI;
cfg.pull = ((pull_pins & mask) != 0) ?
NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_NOPULL;
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
pull = -1; sense = 1;
#endif
}
@ -174,21 +174,21 @@ static void setup_pin1_for_lightsleep(void) {
cfg.sense = NRF_GPIOTE_POLARITY_HITOLO;
cfg.pull = ((pull_pins & mask) != 0) ?
NRF_GPIO_PIN_PULLUP : NRF_GPIO_PIN_NOPULL;
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
pull = 1; sense = -1;
#endif
}
else {
cfg.sense = NRF_GPIOTE_POLARITY_TOGGLE;
cfg.pull = NRF_GPIO_PIN_NOPULL;
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
sense = 9;
#endif
}
nrfx_gpiote_in_init((nrfx_gpiote_pin_t)i, &cfg,
pinalarm_gpiote_handler);
nrfx_gpiote_in_event_enable((nrfx_gpiote_pin_t)i, true);
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
dbg_printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull);
#endif
}
@ -198,7 +198,7 @@ static void setup_pin1_for_deepsleep(void) {
for(size_t i = 0; i < 64; ++i) {
uint64_t mask = 1ull << i;
int pull = 0;
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
int sense = 0;
#endif
if (((high_alarms & mask) == 0) && ((low_alarms & mask) == 0)) {
@ -209,7 +209,7 @@ static void setup_pin1_for_deepsleep(void) {
NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_NOPULL;
nrf_gpio_cfg_input((uint32_t)i, (nrf_gpio_pin_pull_t)pull);
nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_HIGH);
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
sense = NRF_GPIO_PIN_SENSE_HIGH;
#endif
}
@ -219,11 +219,11 @@ static void setup_pin1_for_deepsleep(void) {
NRF_GPIO_PIN_PULLUP : NRF_GPIO_PIN_NOPULL;
nrf_gpio_cfg_input((uint32_t)i, (nrf_gpio_pin_pull_t)pull);
nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_LOW);
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
sense = NRF_GPIO_PIN_SENSE_LOW;
#endif
}
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
dbg_printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull);
#endif
}

View File

@ -8,7 +8,7 @@
#include <stdint.h>
#include <string.h>
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
#define DEBUG_UART_TXPIN 26
#define DEBUG_UART_RXPIN 15
@ -119,8 +119,8 @@ void dbg_dump_reset_reason(void) {
dbg_printf("reset_reason=%s\r\n", rr_str[reset_reason]);
}
#else /*!MY_DEBUGUART*/
#else /*!NRF_DEBUG_PRINT*/
int dbg_printf(const char *fmt, ...) {
return 0;
}
#endif /*!MY_DEBUGUART*/
#endif /*!NRF_DEBUG_PRINT*/

View File

@ -73,7 +73,7 @@ static void power_warning_handler(void) {
reset_into_safe_mode(BROWNOUT);
}
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
extern void _debug_uart_init(void);
#endif
@ -234,7 +234,7 @@ void reset_port(void) {
reset_all_pins();
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
_debug_uart_init();
#endif
}

View File

@ -36,7 +36,7 @@
#include "tusb.h"
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
// XXX these functions are in nrf/supervisor/debug_uart.c
extern void _debug_uart_init(void);
extern void _debug_print_substr(const char* text, uint32_t length);
@ -70,14 +70,14 @@ void serial_early_init(void) {
common_hal_busio_uart_never_reset(&debug_uart);
#endif
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
_debug_uart_init();
#endif
}
void serial_init(void) {
usb_init();
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
_debug_uart_init();
#endif
}
@ -157,7 +157,7 @@ void serial_write_substring(const char* text, uint32_t length) {
common_hal_busio_uart_write(&debug_uart, (const uint8_t*) text, length, &uart_errcode);
#endif
#ifdef MY_DEBUGUART
#ifdef NRF_DEBUG_PRINT
_debug_print_substr(text, length);
#endif
}