Skip to content

Commit 8bb369c

Browse files
committed
refactor debug UART to console UART; get working on ESP32
1 parent b0efd13 commit 8bb369c

File tree

21 files changed

+110
-98
lines changed

21 files changed

+110
-98
lines changed

ports/broadcom/mpconfigport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
#define MICROPY_PORT_ROOT_POINTERS \
6161
CIRCUITPY_COMMON_ROOT_POINTERS
6262

63-
#define CIRCUITPY_DEBUG_UART_TX (&pin_GPIO14)
64-
#define CIRCUITPY_DEBUG_UART_RX (&pin_GPIO15)
63+
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO14)
64+
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO15)
6565

6666
#endif // __INCLUDED_MPCONFIGPORT_H

ports/espressif/boards/adafruit_feather_esp32_v2/mpconfigboard.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@
4747
// Explanation of how a user got into safe mode
4848
#define BOARD_USER_SAFE_MODE_ACTION translate("pressing SW38 button at start up.\n")
4949

50-
#define CIRCUITPY_DEBUG_UART_TX (&pin_GPIO8)
51-
#define CIRCUITPY_DEBUG_UART_RX (&pin_GPIO7)
50+
// UART pins attached to the USB-serial converter chip
51+
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
52+
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO3)

ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@
3737
#define DEFAULT_UART_BUS_TX (&pin_GPIO21)
3838

3939
// Serial over UART
40-
#define CIRCUITPY_DEBUG_UART_RX DEFAULT_UART_BUS_RX
41-
#define CIRCUITPY_DEBUG_UART_TX DEFAULT_UART_BUS_TX
40+
#define CIRCUITPY_CONSOLE_UART_RX DEFAULT_UART_BUS_RX
41+
#define CIRCUITPY_CONSOLE_UART_TX DEFAULT_UART_BUS_TX

ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@
3737
#define DEFAULT_UART_BUS_TX (&pin_GPIO21)
3838

3939
// Serial over UART
40-
#define CIRCUITPY_DEBUG_UART_RX DEFAULT_UART_BUS_RX
41-
#define CIRCUITPY_DEBUG_UART_TX DEFAULT_UART_BUS_TX
40+
#define CIRCUITPY_CONSOLE_UART_RX DEFAULT_UART_BUS_RX
41+
#define CIRCUITPY_CONSOLE_UART_TX DEFAULT_UART_BUS_TX

ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@
3737
#define DEFAULT_UART_BUS_TX (&pin_GPIO21)
3838

3939
// Serial over UART
40-
#define CIRCUITPY_DEBUG_UART_RX DEFAULT_UART_BUS_RX
41-
#define CIRCUITPY_DEBUG_UART_TX DEFAULT_UART_BUS_TX
40+
#define CIRCUITPY_CONSOLE_UART_RX DEFAULT_UART_BUS_RX
41+
#define CIRCUITPY_CONSOLE_UART_TX DEFAULT_UART_BUS_TX

ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
#define DEFAULT_UART_BUS_RX (&pin_GPIO20)
77
#define DEFAULT_UART_BUS_TX (&pin_GPIO21)
88

9-
#define CIRCUITPY_DEBUG_UART_RX DEFAULT_UART_BUS_RX
10-
#define CIRCUITPY_DEBUG_UART_TX DEFAULT_UART_BUS_TX
9+
#define CIRCUITPY_CONSOLE_UART_RX DEFAULT_UART_BUS_RX
10+
#define CIRCUITPY_CONSOLE_UART_TX DEFAULT_UART_BUS_TX

ports/espressif/boards/lilygo_ttgo_t-oi-plus/mpconfigboard.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
#define DEFAULT_UART_BUS_RX (&pin_GPIO20)
77
#define DEFAULT_UART_BUS_TX (&pin_GPIO21)
88

9-
#define CIRCUITPY_DEBUG_UART_RX DEFAULT_UART_BUS_RX
10-
#define CIRCUITPY_DEBUG_UART_TX DEFAULT_UART_BUS_TX
9+
#define CIRCUITPY_CONSOLE_UART_RX DEFAULT_UART_BUS_RX
10+
#define CIRCUITPY_CONSOLE_UART_TX DEFAULT_UART_BUS_TX

ports/espressif/boards/microdev_micro_c3/mpconfigboard.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@
4444
#define DEFAULT_UART_BUS_TX (&pin_GPIO21)
4545

4646
// Serial over UART
47-
#define CIRCUITPY_DEBUG_UART_RX DEFAULT_UART_BUS_RX
48-
#define CIRCUITPY_DEBUG_UART_TX DEFAULT_UART_BUS_TX
47+
#define CIRCUITPY_CONSOLE_UART_RX DEFAULT_UART_BUS_RX
48+
#define CIRCUITPY_CONSOLE_UART_TX DEFAULT_UART_BUS_TX

ports/espressif/common-hal/busio/UART.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ static void uart_event_task(void *param) {
5050
if (xQueueReceive(self->event_queue, &event, portMAX_DELAY)) {
5151
switch (event.type) {
5252
case UART_PATTERN_DET:
53-
// When the debug uart receives CTRL+C, wake the main task and schedule a keyboard interrupt
54-
if (self->is_debug) {
53+
// When the console uart receives CTRL+C, wake the main task and schedule a keyboard interrupt
54+
if (self->is_console) {
5555
port_wake_main_task();
5656
if (mp_interrupt_char == CHAR_CTRL_C) {
5757
uart_flush(self->uart_num);
@@ -60,8 +60,8 @@ static void uart_event_task(void *param) {
6060
}
6161
break;
6262
case UART_DATA:
63-
// When the debug uart receives any key, wake the main task
64-
if (self->is_debug) {
63+
// When the console uart receives any key, wake the main task
64+
if (self->is_console) {
6565
port_wake_main_task();
6666
}
6767
break;
@@ -162,13 +162,15 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
162162
uart_set_mode(self->uart_num, mode) != ESP_OK) {
163163
mp_raise_RuntimeError(translate("UART init"));
164164
}
165-
// On the debug uart, enable pattern detection to look for CTRL+C
166-
#ifdef CIRCUITPY_DEBUG_UART_RX
167-
if (rx == CIRCUITPY_DEBUG_UART_RX) {
168-
self->is_debug = true;
165+
166+
// On the console uart, enable pattern detection to look for CTRL+C
167+
#if CIRCUITPY_CONSOLE_UART
168+
if (rx == CIRCUITPY_CONSOLE_UART_RX) {
169+
self->is_console = true;
169170
uart_enable_pattern_det_baud_intr(self->uart_num, CHAR_CTRL_C, 1, 1, 0, 0);
170171
}
171172
#endif
173+
172174
// Start a task to listen for uart events
173175
xTaskCreatePinnedToCore(
174176
uart_event_task,

ports/espressif/common-hal/busio/UART.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ typedef struct {
4646
uint8_t character_bits;
4747
bool rx_error;
4848
uint32_t timeout_ms;
49-
bool is_debug;
49+
bool is_console;
5050
QueueHandle_t event_queue;
5151
TaskHandle_t event_task;
5252
} busio_uart_obj_t;

0 commit comments

Comments
 (0)