esp8266/esp_mphal: Add support for debug UART-only output.
Helpful when debugging dupterm support (because otherwise all output is spooled to dupterm too). To use: mp_printf(&mp_debug_print, "...");
This commit is contained in:
parent
8fc5e56a6a
commit
402a743821
@ -39,6 +39,9 @@ extern void ets_wdt_disable(void);
|
|||||||
extern void wdt_feed(void);
|
extern void wdt_feed(void);
|
||||||
extern void ets_delay_us();
|
extern void ets_delay_us();
|
||||||
|
|
||||||
|
void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len);
|
||||||
|
const mp_print_t mp_debug_print = {NULL, mp_hal_debug_tx_strn_cooked};
|
||||||
|
|
||||||
void mp_hal_init(void) {
|
void mp_hal_init(void) {
|
||||||
ets_wdt_disable(); // it's a pain while developing
|
ets_wdt_disable(); // it's a pain while developing
|
||||||
mp_hal_rtc_init();
|
mp_hal_rtc_init();
|
||||||
@ -74,6 +77,15 @@ void mp_hal_stdout_tx_char(char c) {
|
|||||||
mp_uos_dupterm_tx_strn(&c, 1);
|
mp_uos_dupterm_tx_strn(&c, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
void mp_hal_debug_str(const char *str) {
|
||||||
|
while (*str) {
|
||||||
|
uart_tx_one_char(UART0, *str++);
|
||||||
|
}
|
||||||
|
uart_flush(UART0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void mp_hal_stdout_tx_str(const char *str) {
|
void mp_hal_stdout_tx_str(const char *str) {
|
||||||
while (*str) {
|
while (*str) {
|
||||||
mp_hal_stdout_tx_char(*str++);
|
mp_hal_stdout_tx_char(*str++);
|
||||||
@ -95,6 +107,16 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len) {
|
||||||
|
(void)env;
|
||||||
|
while (len--) {
|
||||||
|
if (*str == '\n') {
|
||||||
|
uart_tx_one_char(UART0, '\r');
|
||||||
|
}
|
||||||
|
uart_tx_one_char(UART0, *str++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t mp_hal_ticks_ms(void) {
|
uint32_t mp_hal_ticks_ms(void) {
|
||||||
return system_get_time() / 1000;
|
return system_get_time() / 1000;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
#ifndef _INCLUDED_MPHAL_H_
|
#ifndef _INCLUDED_MPHAL_H_
|
||||||
#define _INCLUDED_MPHAL_H_
|
#define _INCLUDED_MPHAL_H_
|
||||||
|
|
||||||
|
struct _mp_print_t;
|
||||||
|
// Structure for UART-only output via mp_printf()
|
||||||
|
extern const struct _mp_print_t mp_debug_print;
|
||||||
|
|
||||||
void mp_hal_init(void);
|
void mp_hal_init(void);
|
||||||
void mp_hal_rtc_init(void);
|
void mp_hal_rtc_init(void);
|
||||||
void mp_hal_feed_watchdog(void);
|
void mp_hal_feed_watchdog(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user