From 90e4f56186f743e73cf53242d19cd42fc5482e42 Mon Sep 17 00:00:00 2001
From: Leroy Baynum <lbaynum@gmail.com>
Date: Sat, 5 Oct 2024 17:17:40 -0400
Subject: [PATCH 1/6] Update Serial.h for 9-bit support

Added to write function declarations for functions being added to the serial.cpp to support the 9-bit functionality of the processor.

The "bool wake" allows turning on the 9-bit, also known as the wake bit.
---
 cores/arduino/Serial.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cores/arduino/Serial.h b/cores/arduino/Serial.h
index cc818d466..1f97966f4 100644
--- a/cores/arduino/Serial.h
+++ b/cores/arduino/Serial.h
@@ -64,6 +64,8 @@ class UART : public arduino::HardwareSerial {
     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_9bit(uint8_t c, bool wake);
+    size_t write_9bit(uint8_t* c, bool wake, size_t len);
     using Print::write; 
     operator bool(); // { return true; }
 

From 39c72ad321ababbfc76473481bdceddd010657d0 Mon Sep 17 00:00:00 2001
From: Leroy Baynum <lbaynum@gmail.com>
Date: Sat, 5 Oct 2024 17:23:43 -0400
Subject: [PATCH 2/6] Update Serial.cpp to support 9-bit functionality on UART

Add two functions and the supporting 9N1 case logic to allow for turning on 9-bit support and sending commands. The second argument, bool, allows for turning on or off the 9th bit, also known as the wake bit.

Serial1.begin(19200, SERIAL_9N1);
Serial1.write_9bit(0x81, true);
Serial1.write_9bit(&temp[1], false, len - 1);
---
 cores/arduino/Serial.cpp | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/cores/arduino/Serial.cpp b/cores/arduino/Serial.cpp
index d905edd90..561a39598 100644
--- a/cores/arduino/Serial.cpp
+++ b/cores/arduino/Serial.cpp
@@ -260,6 +260,11 @@ void UART::begin(unsigned long baudrate, uint16_t config) {
           uart_cfg.parity = UART_PARITY_ODD;
           uart_cfg.stop_bits = UART_STOP_BITS_2;
           break;
+      case SERIAL_9N1:
+          uart_cfg.data_bits = UART_DATA_BITS_9;
+          uart_cfg.parity = UART_PARITY_OFF;
+          uart_cfg.stop_bits = UART_STOP_BITS_1;
+          break;
     }
     
     uart_cfg.p_callback = UART::WrapperCallback;
@@ -335,4 +340,28 @@ size_t UART::write_raw(uint8_t* c, size_t len) {
     i++;
   }
   return len;
-}
\ No newline at end of file
+}
+
+/* -------------------------------------------------------------------------- */
+size_t UART::write_9bit(uint8_t c, bool wake) {
+/* -------------------------------------------------------------------------- */
+  uint16_t bit = 0x00;
+  if (wake) {bit = 0x100;}
+  uart_ctrl.p_reg->TDRHL = 0xFC00 + bit + c;
+  while (uart_ctrl.p_reg->SSR_b.TEND == 0) {}
+  return 1;
+}
+
+/* -------------------------------------------------------------------------- */
+size_t UART::write_9bit(uint8_t* c, bool wake, size_t len) {
+/* -------------------------------------------------------------------------- */
+  size_t i = 0;
+  uint16_t bit = 0x00;
+  if (wake) {bit = 0x100;}
+  while (i < len) {
+    uart_ctrl.p_reg->TDRHL = *(c+i) + 0xFC00 + bit; 
+    while (uart_ctrl.p_reg->SSR_b.TEND == 0) {}
+    i++;
+  }
+  return len;
+}

From 627bb4c44bf7f2ef1c091f5ef758d618f7ce21ec Mon Sep 17 00:00:00 2001
From: Leroy Baynum <lbaynum@gmail.com>
Date: Sun, 13 Oct 2024 10:33:36 -0400
Subject: [PATCH 3/6] Update Serial.cpp

I removed two unnecessary functions that I added with this pull request to turn on 9bit. There was a little code cleanup /refactoring.
---
 cores/arduino/Serial.cpp | 24 ------------------------
 1 file changed, 24 deletions(-)

diff --git a/cores/arduino/Serial.cpp b/cores/arduino/Serial.cpp
index 561a39598..cbd418233 100644
--- a/cores/arduino/Serial.cpp
+++ b/cores/arduino/Serial.cpp
@@ -341,27 +341,3 @@ size_t UART::write_raw(uint8_t* c, size_t len) {
   }
   return len;
 }
-
-/* -------------------------------------------------------------------------- */
-size_t UART::write_9bit(uint8_t c, bool wake) {
-/* -------------------------------------------------------------------------- */
-  uint16_t bit = 0x00;
-  if (wake) {bit = 0x100;}
-  uart_ctrl.p_reg->TDRHL = 0xFC00 + bit + c;
-  while (uart_ctrl.p_reg->SSR_b.TEND == 0) {}
-  return 1;
-}
-
-/* -------------------------------------------------------------------------- */
-size_t UART::write_9bit(uint8_t* c, bool wake, size_t len) {
-/* -------------------------------------------------------------------------- */
-  size_t i = 0;
-  uint16_t bit = 0x00;
-  if (wake) {bit = 0x100;}
-  while (i < len) {
-    uart_ctrl.p_reg->TDRHL = *(c+i) + 0xFC00 + bit; 
-    while (uart_ctrl.p_reg->SSR_b.TEND == 0) {}
-    i++;
-  }
-  return len;
-}

From e8d56d6022aff06df921ea5bdec89acf230244a7 Mon Sep 17 00:00:00 2001
From: Leroy Baynum <lbaynum@gmail.com>
Date: Sun, 13 Oct 2024 10:35:52 -0400
Subject: [PATCH 4/6] Update Serial.h

I removed functions that are unnecessary for the 9-bit code to work.
---
 cores/arduino/Serial.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/cores/arduino/Serial.h b/cores/arduino/Serial.h
index 1f97966f4..cc818d466 100644
--- a/cores/arduino/Serial.h
+++ b/cores/arduino/Serial.h
@@ -64,8 +64,6 @@ class UART : public arduino::HardwareSerial {
     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_9bit(uint8_t c, bool wake);
-    size_t write_9bit(uint8_t* c, bool wake, size_t len);
     using Print::write; 
     operator bool(); // { return true; }
 

From 36083a34e69f9a7674ade97f8ee941ea3767d269 Mon Sep 17 00:00:00 2001
From: Leroy Baynum <lbaynum@gmail.com>
Date: Fri, 18 Oct 2024 17:17:12 -0400
Subject: [PATCH 5/6] Add files via upload

---
 package.json | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 package.json

diff --git a/package.json b/package.json
new file mode 100644
index 000000000..4373372c0
--- /dev/null
+++ b/package.json
@@ -0,0 +1,15 @@
+{
+  "name": "framework-arduinorenesas-uno",
+  "version": "1.1.0",
+  "description": "Arduino Wiring-based Framework for Renesas MCUs (UNOR4 core)",
+  "keywords": [
+    "framework",
+    "arduino",
+    "renesas",
+    "RA"
+  ],
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/arduino/ArduinoCore-renesas.git"
+  }
+}

From a1cfd2467f34f97614d55b64fb9b5f1c0816d26f Mon Sep 17 00:00:00 2001
From: Leroy Baynum <lbaynum@gmail.com>
Date: Fri, 18 Oct 2024 17:18:16 -0400
Subject: [PATCH 6/6] Update package.json

---
 package.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/package.json b/package.json
index 4373372c0..8fa7f61f1 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "framework-arduinorenesas-uno",
-  "version": "1.1.0",
+  "version": "1.1.1",
   "description": "Arduino Wiring-based Framework for Renesas MCUs (UNOR4 core)",
   "keywords": [
     "framework",
@@ -10,6 +10,6 @@
   ],
   "repository": {
     "type": "git",
-    "url": "https://github.com/arduino/ArduinoCore-renesas.git"
+    "url": "https://github.com/vashadow/ArduinoCore-renesas.git"
   }
 }