From c637c06357fa1803138cf8679a2f1ecea6b3cd57 Mon Sep 17 00:00:00 2001 From: David <6957239+delta-G@users.noreply.github.com> Date: Thu, 2 May 2024 20:38:41 -0500 Subject: [PATCH 1/4] pulled origin --- extras/fsp | 2 +- extras/uno-r4-wifi-usb-bridge | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extras/fsp b/extras/fsp index 5d13f916..8ec537bc 160000 --- a/extras/fsp +++ b/extras/fsp @@ -1 +1 @@ -Subproject commit 5d13f916c72f9d1471864361dfaf8f492cab5979 +Subproject commit 8ec537bc86b1b71203d72d0cbb28e6e75b353ebd diff --git a/extras/uno-r4-wifi-usb-bridge b/extras/uno-r4-wifi-usb-bridge index a634856e..3f4e668d 160000 --- a/extras/uno-r4-wifi-usb-bridge +++ b/extras/uno-r4-wifi-usb-bridge @@ -1 +1 @@ -Subproject commit a634856e5467022bc7587e7c8a856811255ea890 +Subproject commit 3f4e668d1318feeaa7088c788e7fd88a26a5a671 From 004368ac3c0e4156471fa6823ce0350bc364dfd6 Mon Sep 17 00:00:00 2001 From: David <6957239+delta-G@users.noreply.github.com> Date: Sun, 5 May 2024 21:30:45 -0500 Subject: [PATCH 2/4] Use txBuffer --- cores/arduino/Serial.cpp | 70 ++++++++++++++++++++++------------------ cores/arduino/Serial.h | 5 +-- 2 files changed, 42 insertions(+), 33 deletions(-) diff --git a/cores/arduino/Serial.cpp b/cores/arduino/Serial.cpp index d905edd9..9bf50943 100644 --- a/cores/arduino/Serial.cpp +++ b/cores/arduino/Serial.cpp @@ -61,9 +61,13 @@ void UART::WrapperCallback(uart_callback_args_t *p_args) { case UART_EVENT_TX_COMPLETE: case UART_EVENT_TX_DATA_EMPTY: { - //uint8_t to_enqueue = uart_ptr->txBuffer.available() < uart_ptr->uart_ctrl.fifo_depth ? uart_ptr->txBuffer.available() : uart_ptr->uart_ctrl.fifo_depth; - //while (to_enqueue) { - uart_ptr->tx_done = true; + if(uart_ptr->txBuffer.available()){ + static char txc; + txc = uart_ptr->txBuffer.read_char(); + R_SCI_UART_Write(&(uart_ptr->uart_ctrl), (uint8_t*)&txc , 1); + } else { + uart_ptr->tx_done = true; + } break; } case UART_EVENT_RX_CHAR: @@ -108,27 +112,31 @@ bool UART::setUpUartIrqs(uart_cfg_t &cfg) { /* -------------------------------------------------------------------------- */ size_t UART::write(uint8_t c) { /* -------------------------------------------------------------------------- */ - if(init_ok) { - tx_done = false; - R_SCI_UART_Write(&uart_ctrl, &c, 1); - while (!tx_done) {} - return 1; - } - else { - return 0; - } + if(init_ok) { + while(txBuffer.isFull()){;} + txBuffer.store_char(c); + if(tx_done){ + tx_done = false; + txc = txBuffer.read_char(); // clear out the char we just added and send it to start transmission. + R_SCI_UART_Write(&uart_ctrl, (uint8_t*)&txc , 1); + } + return 1; + } + else { + return 0; + } } size_t UART::write(uint8_t* c, size_t len) { - if(init_ok) { - tx_done = false; - R_SCI_UART_Write(&uart_ctrl, c, len); - while (!tx_done) {} - return len; - } - else { - return 0; - } + if(init_ok) { + for(int i = 0; iTDR = *(c+i); - while (uart_ctrl.p_reg->SSR_b.TEND == 0) {} - i++; - } - return len; -} \ No newline at end of file +//size_t UART::write_raw(uint8_t* c, size_t len) { +///* -------------------------------------------------------------------------- */ +// size_t i = 0; +// while (i < len) { +// uart_ctrl.p_reg->TDR = *(c+i); +// while (uart_ctrl.p_reg->SSR_b.TEND == 0) {} +// i++; +// } +// return len; +//} \ No newline at end of file diff --git a/cores/arduino/Serial.h b/cores/arduino/Serial.h index cc818d46..c61ff7e3 100644 --- a/cores/arduino/Serial.h +++ b/cores/arduino/Serial.h @@ -63,7 +63,7 @@ class UART : public arduino::HardwareSerial { void flush(void); size_t write(uint8_t c); size_t write(uint8_t* c, size_t len); - size_t write_raw(uint8_t* c, size_t len); +// size_t write_raw(uint8_t* c, size_t len); using Print::write; operator bool(); // { return true; } @@ -78,7 +78,8 @@ class UART : public arduino::HardwareSerial { arduino::SafeRingBufferN rxBuffer; arduino::SafeRingBufferN txBuffer; - volatile bool tx_done; + volatile bool tx_done = true; + char txc; sci_uart_instance_ctrl_t uart_ctrl; uart_cfg_t uart_cfg; From 6c5eac41fc478c864384a1710ded888030e48b1b Mon Sep 17 00:00:00 2001 From: David <6957239+delta-G@users.noreply.github.com> Date: Sun, 5 May 2024 22:26:06 -0500 Subject: [PATCH 3/4] added back write_raw --- cores/arduino/Serial.cpp | 14 ++++---------- cores/arduino/Serial.h | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/cores/arduino/Serial.cpp b/cores/arduino/Serial.cpp index 9bf50943..7d7a0ad8 100644 --- a/cores/arduino/Serial.cpp +++ b/cores/arduino/Serial.cpp @@ -334,13 +334,7 @@ void UART::flush() { } /* -------------------------------------------------------------------------- */ -//size_t UART::write_raw(uint8_t* c, size_t len) { -///* -------------------------------------------------------------------------- */ -// size_t i = 0; -// while (i < len) { -// uart_ctrl.p_reg->TDR = *(c+i); -// while (uart_ctrl.p_reg->SSR_b.TEND == 0) {} -// i++; -// } -// return len; -//} \ No newline at end of file +size_t UART::write_raw(uint8_t* c, size_t len) { +/* -------------------------------------------------------------------------- */ + return write(c, len); +} \ No newline at end of file diff --git a/cores/arduino/Serial.h b/cores/arduino/Serial.h index c61ff7e3..e53a55c7 100644 --- a/cores/arduino/Serial.h +++ b/cores/arduino/Serial.h @@ -63,7 +63,7 @@ class UART : public arduino::HardwareSerial { void flush(void); size_t write(uint8_t c); size_t write(uint8_t* c, size_t len); -// size_t write_raw(uint8_t* c, size_t len); + size_t write_raw(uint8_t* c, size_t len); using Print::write; operator bool(); // { return true; } From fcf7f82fa948bd0fa8f55fc06464a2e6772b678e Mon Sep 17 00:00:00 2001 From: David <6957239+delta-G@users.noreply.github.com> Date: Sun, 5 May 2024 23:45:28 -0500 Subject: [PATCH 4/4] fixed submodule issue --- extras/fsp | 2 +- extras/net/lwip | 2 +- extras/protobuf-c | 2 +- extras/tinyusb | 2 +- extras/tls/mbedtls | 2 +- extras/uno-r4-wifi-usb-bridge | 2 +- libraries/WiFi/extra/esptool | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extras/fsp b/extras/fsp index 8ec537bc..e78939d3 160000 --- a/extras/fsp +++ b/extras/fsp @@ -1 +1 @@ -Subproject commit 8ec537bc86b1b71203d72d0cbb28e6e75b353ebd +Subproject commit e78939d32d1ccea9f0ba8bb42c51aceffd386b9b diff --git a/extras/net/lwip b/extras/net/lwip index d8d1e4a0..1cc1536e 160000 --- a/extras/net/lwip +++ b/extras/net/lwip @@ -1 +1 @@ -Subproject commit d8d1e4a0150180bc88cc14dbe17565976780bb85 +Subproject commit 1cc1536e6a7117e23ebaf5546405a843a3e558ae diff --git a/extras/protobuf-c b/extras/protobuf-c index abc67a11..8c201f6e 160000 --- a/extras/protobuf-c +++ b/extras/protobuf-c @@ -1 +1 @@ -Subproject commit abc67a11c6db271bedbb9f58be85d6f4e2ea8389 +Subproject commit 8c201f6e47a53feaab773922a743091eb6c8972a diff --git a/extras/tinyusb b/extras/tinyusb index c796dcfe..7bf59230 160000 --- a/extras/tinyusb +++ b/extras/tinyusb @@ -1 +1 @@ -Subproject commit c796dcfe0bee337547437632dc16829038ef0f3d +Subproject commit 7bf5923052e5861f54c9cb0581e328f8be26a0a9 diff --git a/extras/tls/mbedtls b/extras/tls/mbedtls index 5a55712f..1873d3bf 160000 --- a/extras/tls/mbedtls +++ b/extras/tls/mbedtls @@ -1 +1 @@ -Subproject commit 5a55712ff4206153f7fb093b608199464baa4ff8 +Subproject commit 1873d3bfc2da771672bd8e7e8f41f57e0af77f33 diff --git a/extras/uno-r4-wifi-usb-bridge b/extras/uno-r4-wifi-usb-bridge index 3f4e668d..aef6457c 160000 --- a/extras/uno-r4-wifi-usb-bridge +++ b/extras/uno-r4-wifi-usb-bridge @@ -1 +1 @@ -Subproject commit 3f4e668d1318feeaa7088c788e7fd88a26a5a671 +Subproject commit aef6457c0f324686177a45792d62aa7ba27df8ce diff --git a/libraries/WiFi/extra/esptool b/libraries/WiFi/extra/esptool index 2c69163c..1deb1c65 160000 --- a/libraries/WiFi/extra/esptool +++ b/libraries/WiFi/extra/esptool @@ -1 +1 @@ -Subproject commit 2c69163c21661baa7e103a3e4c133e45c75e5bee +Subproject commit 1deb1c65c140363bbfa16fbd889cff8e6d33b8c0