-
Notifications
You must be signed in to change notification settings - Fork 14
/
micropython.diff
96 lines (88 loc) · 2.79 KB
/
micropython.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
diff --git a/ports/esp32/CMakeLists.txt b/ports/esp32/CMakeLists.txt
index 8b2f09a72..bc4af823a 100644
--- a/ports/esp32/CMakeLists.txt
+++ b/ports/esp32/CMakeLists.txt
@@ -18,6 +18,10 @@ if(NOT EXISTS ${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
message(FATAL_ERROR "Invalid MICROPY_BOARD specified: ${MICROPY_BOARD}")
endif()
+
+set(IDF_TARGET esp32s3)
+include($ENV{IOT_SOLUTION_PATH}/component.cmake)
+
# Include main IDF cmake file.
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
diff --git a/ports/esp32/mphalport.c b/ports/esp32/mphalport.c
index 41e6e6ec0..761e93c01 100644
--- a/ports/esp32/mphalport.c
+++ b/ports/esp32/mphalport.c
@@ -107,13 +107,8 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) {
if (release_gil) {
MP_THREAD_GIL_EXIT();
}
- #if CONFIG_USB_ENABLED
usb_tx_strn(str, len);
- #elif CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
- usb_serial_jtag_tx_strn(str, len);
- #else
uart_stdout_tx_strn(str, len);
- #endif
if (release_gil) {
MP_THREAD_GIL_ENTER();
}
diff --git a/ports/esp32/uart.c b/ports/esp32/uart.c
index f6493dc79..9d393a2fc 100644
--- a/ports/esp32/uart.c
+++ b/ports/esp32/uart.c
@@ -34,10 +34,31 @@
#include "py/runtime.h"
#include "py/mphal.h"
#include "uart.h"
+#include "nvs.h"
STATIC void uart_irq_handler(void *arg);
+static bool uart_inited = false;
+static void uart_stdout_do_init();
+
+static const char *TAG = "uart";
+
void uart_stdout_init(void) {
+ nvs_handle_t h = 0;
+ esp_err_t err = nvs_open("tidal", NVS_READONLY, &h);
+ if (err == ESP_OK) {
+ int32_t val = 0;
+ err = nvs_get_i32(h, "uart_sdascl", &val);
+ if (err == ESP_OK && val > 0) {
+ uart_stdout_do_init();
+ } else {
+ }
+ nvs_close(h);
+ } else {
+ }
+}
+
+static void uart_stdout_do_init() {
uart_config_t uartcfg = {
.baud_rate = MICROPY_HW_UART_REPL_BAUD,
.data_bits = UART_DATA_8_BITS,
@@ -57,9 +78,13 @@ void uart_stdout_init(void) {
uart_isr_free(MICROPY_HW_UART_REPL);
uart_isr_register(MICROPY_HW_UART_REPL, uart_irq_handler, NULL, ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM, &handle);
uart_enable_rx_intr(MICROPY_HW_UART_REPL);
+ uart_inited = true;
}
int uart_stdout_tx_strn(const char *str, size_t len) {
+ if (!uart_inited) {
+ return len;
+ }
size_t remaining = len;
// TODO add a timeout
for (;;) {
diff --git a/ports/esp32/usb.c b/ports/esp32/usb.c
index 5a613d244..b1047c230 100644
--- a/ports/esp32/usb.c
+++ b/ports/esp32/usb.c
@@ -35,7 +35,7 @@
#define CDC_ITF TINYUSB_CDC_ACM_0
-static uint8_t usb_rx_buf[CONFIG_USB_CDC_RX_BUFSIZE];
+static uint8_t usb_rx_buf[CONFIG_TINYUSB_CDC_RX_BUFSIZE];
static uint8_t usb_cdc_connected;
static void usb_callback_rx(int itf, cdcacm_event_t *event) {