define CIRCUITPY_BOOT_OUTPUT_FILE will cause mp_hal_stdout_tx_strn() to
invoke before serial_init() is called. Solution is skipped output to
serial if it is not inited.
crypto-aes
hathach 4 years ago
parent d655e2194c
commit 53593d1315
  1. 2
      ports/nrf/boards/feather52/mpconfigboard.mk
  2. 4
      ports/nrf/hal/hal_uart.c
  3. 1
      ports/nrf/hal/hal_uart.h
  4. 2
      ports/nrf/mpconfigport.h
  5. 20
      ports/nrf/mphalport.c

@ -31,7 +31,7 @@ __check_defined = \
.PHONY: dfu-gen dfu-flash boot-flash
dfu-gen:
$(NRFUTIL) dfu genpkg --dev-type 0x0052 --application $(BUILD)/$(OUTPUT_FILENAME).hex $(BUILD)/dfu-package.zip
$(NRFUTIL) dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application $(BUILD)/$(OUTPUT_FILENAME).hex $(BUILD)/dfu-package.zip
dfu-flash:
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)

@ -156,6 +156,10 @@ void hal_uart_init(NRF_UART_Type * p_instance, hal_uart_init_t const * p_uart_in
NVIC_EnableIRQ(p_uart_init->irq_num);
}
bool hal_uart_inited(NRF_UART_Type * p_instance)
{
return !(p_instance->PSELTXD & (1 << 31)) && !(p_instance->PSELRXD & (1 << 31));
}
void UARTE0_UART0_IRQHandler(void)
{

@ -117,6 +117,7 @@ typedef struct
typedef void (*uart_complete_cb)(void);
void hal_uart_init(NRF_UART_Type * p_instance, hal_uart_init_t const * p_uart_init);
bool hal_uart_inited(NRF_UART_Type * p_instance);
hal_uart_error_t hal_uart_char_write(NRF_UART_Type * p_instance, uint8_t ch);

@ -330,6 +330,6 @@ extern const struct _mp_obj_module_t ble_module;
#include <alloca.h>
#define MICROPY_PIN_DEFS_PORT_H "pin_defs_nrf5.h"
//#define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt"
#define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt"
#endif

@ -65,9 +65,23 @@ bool mp_hal_stdin_any(void) {
}
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
while(len--) {
hal_uart_char_write(UART_INSTANCE, *str++);
}
// #ifdef MICROPY_HW_LED_TX
// gpio_toggle_pin_level(MICROPY_HW_LED_TX);
// #endif
//
// #ifdef CIRCUITPY_BOOT_OUTPUT_FILE
// if (boot_output_file != NULL) {
// UINT bytes_written = 0;
// f_write(boot_output_file, str, len, &bytes_written);
// }
// #endif
if ( hal_uart_inited(UART_INSTANCE) ) {
while(len--) {
hal_uart_char_write(UART_INSTANCE, *str++);
}
}
}
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len) {

Loading…
Cancel
Save