Merge branch 'master' into usbboot

This commit is contained in:
hathach 2018-05-17 15:23:45 +07:00
commit 6d4a2f5524
7 changed files with 27 additions and 8 deletions

@ -1 +1 @@
Subproject commit d48561b07386132b849d0125b0ff6a532d833d8b
Subproject commit 9e7dfb28a5c6f3d7a19340971b32e0c2b4128ecf

View File

@ -31,11 +31,11 @@ __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)
$(NRFUTIL) dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL) -b 115200
$(NRFUTIL) dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL) -b 115200 --singlebank
boot-flash:
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)

View File

@ -36,7 +36,7 @@ dfu-gen:
dfu-flash:
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)
$(NRFUTIL) --verbose dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL) -b 115200
$(NRFUTIL) --verbose dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL) -b 115200 --singlebank
boot-flash:
nrfjprog --program $(BOOT_UART_FILE).hex -f nrf52 --chiperase --reset

View File

@ -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)
{

View File

@ -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);

View File

@ -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

View File

@ -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) {