Skip to content

Commit 75a2f26

Browse files
committed
Merge upstream changes and resolve conflicts
2 parents c426a30 + 158e81c commit 75a2f26

File tree

98 files changed

+5841
-2956
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+5841
-2956
lines changed

.github/workflows/compile-examples.yml

+29-6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
- libraries/RTC/examples/Test_RTC
3939
- libraries/SoftwareSerial
4040
- libraries/WDT
41+
SKETCHES_REPORTS_PATH: sketches-reports
4142

4243
strategy:
4344
fail-fast: false
@@ -65,6 +66,7 @@ jobs:
6566
- libraries/RTC/examples/RTC_NTPSync
6667
- libraries/RTC/examples/RTC_Alarm
6768
- libraries/SFU
69+
- libraries/KVStore/examples/StartCounter
6870
- board:
6971
fqbn: "arduino-git:renesas:XIAO_RA4M1"
7072
additional-sketch-paths: |
@@ -80,14 +82,34 @@ jobs:
8082
- libraries/RTC/examples/RTC_NTPSync
8183
- libraries/RTC/examples/RTC_Alarm
8284
- libraries/SFU
85+
- libraries/KVStore/examples/StartCounter
86+
- board:
87+
fqbn: "arduino:renesas_uno:unor4wifi"
88+
additional-sketch-paths: |
89+
- libraries/Arduino_LED_Matrix
90+
- libraries/WiFiS3
91+
- libraries/OTAUpdate
92+
- board:
93+
fqbn: "arduino-git:renesas:unor4wifi"
94+
additional-sketch-paths: |
95+
- libraries/Arduino_LED_Matrix
96+
- libraries/WiFiS3
97+
- libraries/OTAUpdate
98+
- libraries/OPAMP
99+
- libraries/SoftwareATSE
100+
- libraries/Preferences
101+
- board:
102+
fqbn: "arduino-git:renesas:minima"
103+
additional-sketch-paths: |
104+
- libraries/OPAMP
83105
84106
steps:
85107
- name: Checkout repository
86-
uses: actions/checkout@v3
108+
uses: actions/checkout@v4
87109

88110
# The source files are in a subfolder of the ArduinoCore-API repository, so it's not possible to clone it directly to the final destination in the core
89111
- name: Checkout ArduinoCore-API
90-
uses: actions/checkout@v3
112+
uses: actions/checkout@v4
91113
with:
92114
repository: arduino/ArduinoCore-API
93115
path: extras/ArduinoCore-API
@@ -102,7 +124,7 @@ jobs:
102124
if: steps.checkapi.outputs.IS_API == 'true'
103125

104126
- name: Checkout Basic examples
105-
uses: actions/checkout@v3
127+
uses: actions/checkout@v4
106128
with:
107129
repository: arduino/arduino-examples
108130
path: examples
@@ -150,9 +172,10 @@ jobs:
150172
enable-deltas-report: 'false'
151173
verbose: 'true'
152174
github-token: ${{ secrets.GITHUB_TOKEN }}
175+
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
153176

154177
- name: Save memory usage change report as artifact
155-
uses: actions/upload-artifact@v3
178+
uses: actions/upload-artifact@v4
156179
with:
157-
name: sketches-reports
158-
path: sketches-reports
180+
path: ${{ env.SKETCHES_REPORTS_PATH }}
181+
name: sketches-reports-${{ matrix.board.id }}

cores/arduino/Serial.cpp

+17-11
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ void UART::WrapperCallback(uart_callback_args_t *p_args) {
5858
{
5959
break;
6060
}
61-
case UART_EVENT_TX_COMPLETE:
62-
case UART_EVENT_TX_DATA_EMPTY:
61+
case UART_EVENT_TX_COMPLETE: // This is call when the transmission is complete
6362
{
64-
//uint8_t to_enqueue = uart_ptr->txBuffer.available() < uart_ptr->uart_ctrl.fifo_depth ? uart_ptr->txBuffer.available() : uart_ptr->uart_ctrl.fifo_depth;
65-
//while (to_enqueue) {
66-
uart_ptr->tx_done = true;
63+
uart_ptr->tx_complete = true;
64+
break;
65+
}
66+
case UART_EVENT_TX_DATA_EMPTY: // This is called when the buffer is empty
67+
{ // Last byte is transmitting, but ready for more data
68+
uart_ptr->tx_empty = true;
6769
break;
6870
}
6971
case UART_EVENT_RX_CHAR:
@@ -87,6 +89,8 @@ UART::UART(int _pin_tx, int _pin_rx, int _pin_rts, int _pin_cts):
8789
rx_pin(_pin_rx),
8890
rts_pin(_pin_rts),
8991
cts_pin(_pin_cts),
92+
tx_empty(true),
93+
tx_complete(true),
9094
init_ok(false) {
9195
/* -------------------------------------------------------------------------- */
9296
uart_cfg.txi_irq = FSP_INVALID_VECTOR;
@@ -109,9 +113,10 @@ bool UART::setUpUartIrqs(uart_cfg_t &cfg) {
109113
size_t UART::write(uint8_t c) {
110114
/* -------------------------------------------------------------------------- */
111115
if(init_ok) {
112-
tx_done = false;
116+
tx_empty = false;
117+
tx_complete = false;
113118
R_SCI_UART_Write(&uart_ctrl, &c, 1);
114-
while (!tx_done) {}
119+
while (!tx_empty) {}
115120
return 1;
116121
}
117122
else {
@@ -121,9 +126,10 @@ size_t UART::write(uint8_t c) {
121126

122127
size_t UART::write(uint8_t* c, size_t len) {
123128
if(init_ok) {
124-
tx_done = false;
129+
tx_empty = false;
130+
tx_complete = false;
125131
R_SCI_UART_Write(&uart_ctrl, c, len);
126-
while (!tx_done) {}
132+
while (!tx_empty) {}
127133
return len;
128134
}
129135
else {
@@ -322,7 +328,7 @@ int UART::read() {
322328
/* -------------------------------------------------------------------------- */
323329
void UART::flush() {
324330
/* -------------------------------------------------------------------------- */
325-
while(txBuffer.available());
331+
while(!tx_complete);
326332
}
327333

328334
/* -------------------------------------------------------------------------- */
@@ -335,4 +341,4 @@ size_t UART::write_raw(uint8_t* c, size_t len) {
335341
i++;
336342
}
337343
return len;
338-
}
344+
}

cores/arduino/Serial.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ class UART : public arduino::HardwareSerial {
7878
arduino::SafeRingBufferN<SERIAL_BUFFER_SIZE> rxBuffer;
7979
arduino::SafeRingBufferN<SERIAL_BUFFER_SIZE> txBuffer;
8080

81-
volatile bool tx_done;
81+
volatile bool tx_empty;
82+
volatile bool tx_complete;
8283

8384
sci_uart_instance_ctrl_t uart_ctrl;
8485
uart_cfg_t uart_cfg;

cores/arduino/analog.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,10 @@ void analogReference(uint8_t mode) {
558558
R_ADC_Open(&adc1.ctrl, &adc1.cfg);
559559
}
560560

561+
#if defined(AVCC_MEASURE_PIN)
561562
static float aref = 0;
563+
#endif
564+
562565
float analogReference() {
563566
switch (adc.cfg_extend.adc_vref_control) {
564567
case ADC_VREF_CONTROL_1_5V_OUTPUT:
@@ -642,7 +645,7 @@ void analogReadResolution(int bits) {
642645
default:
643646
_analogRequestedReadResolution = 12;
644647
adc.cfg.resolution = ADC_RESOLUTION_12_BIT;
645-
adc1.cfg.resolution = ADC_RESOLUTION_10_BIT;
648+
adc1.cfg.resolution = ADC_RESOLUTION_12_BIT;
646649
break;
647650
}
648651

@@ -817,4 +820,4 @@ void analogWrite(pin_size_t pinNumber, int value)
817820

818821
FspTimer* __get_timer_for_channel(int channel) {
819822
return pwms.get_from_channel(channel)->get_timer();
820-
}
823+
}

cores/arduino/main.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ void unsecure_registers() {
6464
#define str(s) #s
6565

6666
extern "C" void Stacktrace_Handler(void);
67+
extern "C" __attribute__((weak)) void start_freertos_on_header_inclusion() {}
68+
extern "C" __attribute__((weak)) void early_start_freertos_on_header_inclusion() {}
6769

6870
void arduino_main(void)
6971
{
@@ -111,7 +113,9 @@ void arduino_main(void)
111113
Serial.begin(115200);
112114
#endif
113115
startAgt();
116+
early_start_freertos_on_header_inclusion();
114117
setup();
118+
start_freertos_on_header_inclusion();
115119
while (1)
116120
{
117121
loop();

extras/net/lwipopts.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@
277277
* (requires the LWIP_RAW option)
278278
*/
279279
#ifndef MEMP_NUM_RAW_PCB
280-
#define MEMP_NUM_RAW_PCB 0
280+
#define MEMP_NUM_RAW_PCB 1
281281
#endif
282282

283283
/**
@@ -642,7 +642,7 @@
642642
* LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
643643
*/
644644
#ifndef LWIP_RAW
645-
#define LWIP_RAW 0
645+
#define LWIP_RAW 1
646646
#endif
647647

648648
/*

extras/package.sh

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ git checkout platform.txt
2626
sed -i 's/minima./#minima./g' boards.txt
2727
sed -i 's/unor4wifi./#unor4wifi./g' boards.txt
2828
sed -i 's/muxto./#muxto./g' boards.txt
29+
sed -i 's/opta_/#opta_/g' boards.txt
2930
sed -i 's/Arduino Renesas fsp Boards/Arduino Renesas Portenta Boards/g' platform.txt
3031

3132
CORE_BASE=`basename $PWD`
@@ -58,6 +59,7 @@ git checkout platform.txt
5859

5960
sed -i 's/portenta_c33./#portenta_c33./g' boards.txt
6061
sed -i 's/muxto./#muxto./g' boards.txt
62+
sed -i 's/opta_/#opta_/g' boards.txt
6163
sed -i 's/Arduino Renesas fsp Boards/Arduino Renesas UNO R4 Boards/g' platform.txt
6264

6365
CORE_BASE=`basename $PWD`

libraries/Arduino_FreeRTOS/src/Arduino_FreeRTOS.h

+21
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ extern "C" {
2727
#include "lib/FreeRTOS-Kernel-v10.5.1/semphr.h"
2828
#include "lib/FreeRTOS-Kernel-v10.5.1/task.h"
2929
#include "lib/FreeRTOS-Kernel-v10.5.1/timers.h"
30+
#include <stdbool.h>
31+
32+
33+
// If you need to automatically start FREERTOS, declare either EARLY_AUTOSTART_FREERTOS or
34+
// AUTOSTART_FREERTOS in your library or sketch code (.ino or .cpp file)
35+
//
36+
// EARLY_AUTOSTART_FREERTOS -> if you need the scheduler to be already running in setup()
37+
// AUTOSTART_FREERTOS -> if you only declare the threads in setup() and use them in loop()
38+
39+
void _start_freertos_on_header_inclusion_impl(bool early_start);
40+
void early_start_freertos_on_header_inclusion();
41+
void start_freertos_on_header_inclusion();
42+
#define EARLY_AUTOSTART_FREERTOS \
43+
void early_start_freertos_on_header_inclusion() { \
44+
_start_freertos_on_header_inclusion_impl(true); \
45+
}
46+
#define AUTOSTART_FREERTOS \
47+
void start_freertos_on_header_inclusion() { \
48+
_start_freertos_on_header_inclusion_impl(false); \
49+
}
50+
3051

3152
#ifdef __cplusplus
3253
}

libraries/Arduino_FreeRTOS/src/portable/FSP/port.c

+30
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "FreeRTOSConfig.h"
3333
#include "../../lib/FreeRTOS-Kernel-v10.5.1/FreeRTOS.h"
3434
#include "../../lib/FreeRTOS-Kernel-v10.5.1/task.h"
35+
#include "portmacro.h"
3536

3637
#if BSP_TZ_NONSECURE_BUILD
3738
#include "tz_context.h"
@@ -225,6 +226,35 @@ static void prvTaskExitError(void);
225226

226227
#endif
227228

229+
extern void setup(void);
230+
extern void loop(void);
231+
232+
static void sketch_thread_func(void* arg) {
233+
bool early_start = (bool)arg;
234+
if (early_start) {
235+
setup();
236+
}
237+
while (1)
238+
{
239+
loop();
240+
}
241+
}
242+
243+
void _start_freertos_on_header_inclusion_impl(bool early_start) {
244+
static TaskHandle_t sketch_task;
245+
if (xTaskGetSchedulerState() != taskSCHEDULER_RUNNING) {
246+
xTaskCreate(
247+
(TaskFunction_t)sketch_thread_func,
248+
"Sketch Thread",
249+
4096 / 4, /* usStackDepth in words */
250+
(void*)early_start, /* pvParameters */
251+
4, /* uxPriority */
252+
&sketch_task /* pxCreatedTask */
253+
);
254+
vTaskStartScheduler();
255+
}
256+
}
257+
228258
/* Arduino specific overrides */
229259
void delay(uint32_t ms) {
230260
if (xTaskGetSchedulerState() == taskSCHEDULER_RUNNING) {

libraries/Arduino_LED_Matrix/examples/TextWithArduinoGraphics/TextWithArduinoGraphics.ino

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// TextAnimation works only when ArduinoGraphics is installed and used.
2+
// ArduinoGraphics is an external library and needs to be installed using
3+
// Library Manager.
14
// To use ArduinoGraphics APIs, please include BEFORE Arduino_LED_Matrix
25
#include "ArduinoGraphics.h"
36
#include "Arduino_LED_Matrix.h"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// TextAnimation works only when ArduinoGraphics is installed and used.
2+
// ArduinoGraphics is an external library and needs to be installed using
3+
// Library Manager.
4+
// To use ArduinoGraphics APIs, please include BEFORE Arduino_LED_Matrix and TextAnimation
5+
#include "ArduinoGraphics.h"
6+
#include "Arduino_LED_Matrix.h"
7+
#include "TextAnimation.h"
8+
9+
ArduinoLEDMatrix matrix;
10+
11+
// 100 frames maximum. Compute as maximum length of text you want to print (eg. 20 chars)
12+
// multiplied by font width (eg. 5 for Font_5x7), so 20 chars * 5 px = 100. If you enter lower
13+
// value (or your text get unexpectedly long), animation will be cut and end soon.
14+
TEXT_ANIMATION_DEFINE(anim, 100)
15+
16+
int counter;
17+
bool requestNext = false;
18+
19+
void setup() {
20+
pinMode(LED_BUILTIN, OUTPUT);
21+
22+
matrix.begin();
23+
matrix.beginDraw();
24+
25+
matrix.stroke(0xFFFFFFFF);
26+
matrix.textFont(Font_5x7);
27+
matrix.textScrollSpeed(60);
28+
matrix.setCallback(matrixCallback);
29+
30+
const char text[] = " UNO r4 ";
31+
matrix.beginText(0, 1, 0xFFFFFF);
32+
matrix.println(text);
33+
matrix.endTextAnimation(SCROLL_LEFT, anim);
34+
35+
matrix.loadTextAnimationSequence(anim);
36+
matrix.play();
37+
38+
// now animation play asynchronously. Will call matrixCallback once completed.
39+
}
40+
41+
void matrixCallback() {
42+
// callback is executed in IRQ and should run as fast as possible
43+
requestNext = true;
44+
}
45+
46+
void loop() {
47+
if (requestNext) {
48+
requestNext = false;
49+
50+
matrix.beginText(0, 1, 0xFFFFFF);
51+
matrix.print(" ");
52+
matrix.println(counter);
53+
matrix.endTextAnimation(SCROLL_RIGHT, anim);
54+
55+
if (counter++ >= 20) {
56+
counter = 0;
57+
}
58+
59+
matrix.loadTextAnimationSequence(anim);
60+
matrix.play();
61+
}
62+
63+
delay(500);
64+
digitalWrite(LED_BUILTIN, 0);
65+
delay(500);
66+
digitalWrite(LED_BUILTIN, 1);
67+
}

0 commit comments

Comments
 (0)