Skip to content

Commit 6bc894c

Browse files
authored
Merge branch 'arduino:main' into main
2 parents 304218a + 2ef2b3a commit 6bc894c

File tree

20 files changed

+732
-49
lines changed

20 files changed

+732
-49
lines changed

.github/workflows/compile-examples.yml

+3
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ jobs:
8787
- board:
8888
fqbn: "arduino:renesas_uno:unor4wifi"
8989
additional-sketch-paths: |
90+
- libraries/Arduino_LED_Matrix
9091
- libraries/WiFiS3
9192
- libraries/OTAUpdate
9293
- board:
9394
fqbn: "arduino-git:renesas:unor4wifi"
9495
additional-sketch-paths: |
96+
- libraries/Arduino_LED_Matrix
9597
- libraries/WiFiS3
9698
- libraries/OTAUpdate
9799
- libraries/OPAMP
@@ -157,6 +159,7 @@ jobs:
157159
- name: ArduinoDMX
158160
- name: ArduinoRS485
159161
- name: ArduinoIoTCloud
162+
- name: ArduinoGraphics
160163
platforms: |
161164
# Use Board Manager to install the latest release of Arduino Renesas Boards to get the toolchain
162165
- name: "arduino:renesas_uno"

cores/arduino/IRQManager.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ IRQManager& IRQManager::getInstance() {
3838
return instance;
3939
}
4040

41+
bool IRQManager::addGenericInterrupt(GenericIrqCfg_t &cfg, Irq_f fnc /*= nullptr*/){
42+
/* getting the address of the current location of the irq vector table */
43+
volatile uint32_t *irq_ptr = (volatile uint32_t *)SCB->VTOR;
44+
/* set the displacement to the "programmable" part of the table */
45+
irq_ptr += FIXED_IRQ_NUM;
46+
bool rv = false;
47+
48+
if((cfg.irq == FSP_INVALID_VECTOR) && (last_interrupt_index < PROG_IRQ_NUM)) {
49+
if(fnc != nullptr){
50+
R_ICU->IELSR[last_interrupt_index] = cfg.event;
51+
*(irq_ptr + last_interrupt_index) = (uint32_t)fnc;
52+
R_BSP_IrqDisable((IRQn_Type)last_interrupt_index);
53+
R_BSP_IrqStatusClear((IRQn_Type)last_interrupt_index);
54+
NVIC_SetPriority((IRQn_Type)last_interrupt_index, cfg.ipl);
55+
R_BSP_IrqEnable ((IRQn_Type)last_interrupt_index);
56+
cfg.irq = (IRQn_Type)last_interrupt_index;
57+
last_interrupt_index++;
58+
rv = true;
59+
}
60+
}
61+
return rv;
62+
}
4163

4264
bool IRQManager::addADCScanEnd(ADC_Container *adc, Irq_f fnc /*= nullptr*/) {
4365
/* getting the address of the current location of the irq vector table */

cores/arduino/IRQManager.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ typedef struct timer {
125125
agt_extended_cfg_t *agt_ext_cfg;
126126
} TimerIrqCfg_t;
127127

128+
typedef struct genericIrq {
129+
IRQn_Type irq;
130+
uint8_t ipl;
131+
elc_event_t event;
132+
} GenericIrqCfg_t;
128133

129134

130135
#ifdef __cplusplus
@@ -199,7 +204,8 @@ class IRQManager {
199204
it returns true if the interrupt is correctly added */
200205
bool addDMA(dmac_extended_cfg_t &cfg, Irq_f fnc = nullptr);
201206
#endif
202-
207+
208+
bool addGenericInterrupt(GenericIrqCfg_t &cfg, Irq_f fnc = nullptr);
203209
bool addTimerOverflow(TimerIrqCfg_t &cfg, Irq_f fnc = nullptr);
204210
bool addTimerUnderflow(TimerIrqCfg_t &cfg, Irq_f fnc = nullptr);
205211
bool addTimerCompareCaptureA(TimerIrqCfg_t &cfg, Irq_f fnc = nullptr);

libraries/Arduino_CAN/src/CanUtil.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace util
2828
**************************************************************************************/
2929

3030
std::tuple<bool, uint32_t, uint32_t, uint32_t>
31-
calc_can_bit_timing(CanBitRate const can_bitrate,
31+
calc_can_bit_timing(uint32_t const can_bitrate,
3232
uint32_t const can_clock_Hz,
3333
uint32_t const tq_min,
3434
uint32_t const tq_max,

libraries/Arduino_CAN/src/CanUtil.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ std::tuple<bool, /* valid result found */
3636
uint32_t, /* baud_rate_prescaler */
3737
uint32_t, /* time_segment_1 */
3838
uint32_t> /* time_segment_2 */
39-
calc_can_bit_timing(CanBitRate const can_bitrate, uint32_t const can_clock_Hz, uint32_t const tq_min, uint32_t const tq_max,
39+
calc_can_bit_timing(uint32_t const can_bitrate, uint32_t const can_clock_Hz, uint32_t const tq_min, uint32_t const tq_max,
4040
uint32_t const tseg1_min, uint32_t const tseg1_max, uint32_t const tseg2_min, uint32_t const tseg2_max);
4141

4242
/**************************************************************************************

libraries/Arduino_CAN/src/R7FA4M1_CAN.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ R7FA4M1_CAN::R7FA4M1_CAN(int const can_tx_pin, int const can_rx_pin)
137137
**************************************************************************************/
138138

139139
bool R7FA4M1_CAN::begin(CanBitRate const can_bitrate)
140+
{
141+
return begin(static_cast<uint32_t>(can_bitrate));
142+
}
143+
144+
bool R7FA4M1_CAN::begin(uint32_t const can_bitrate)
140145
{
141146
bool init_ok = true;
142147

libraries/Arduino_CAN/src/R7FA4M1_CAN.h

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class R7FA4M1_CAN final : public HardwareCAN
5252

5353

5454
bool begin(CanBitRate const can_bitrate) override;
55+
bool begin(uint32_t const can_bitrate);
5556
void end() override;
5657

5758
void setFilterMask_Standard(uint32_t const mask);

libraries/Arduino_CAN/src/R7FA6M5_CAN.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ R7FA6M5_CAN::R7FA6M5_CAN(int const can_tx_pin, int const can_rx_pin)
100100
**************************************************************************************/
101101

102102
bool R7FA6M5_CAN::begin(CanBitRate const can_bitrate)
103+
{
104+
return begin(static_cast<uint32_t>(can_bitrate));
105+
}
106+
107+
bool R7FA6M5_CAN::begin(uint32_t const can_bitrate)
103108
{
104109
bool init_ok = true;
105110

libraries/Arduino_CAN/src/R7FA6M5_CAN.h

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class R7FA6M5_CAN final : public HardwareCAN
5454

5555

5656
bool begin(CanBitRate const can_bitrate) override;
57+
bool begin(uint32_t const can_bitrate);
5758
void end() override;
5859

5960

libraries/Arduino_FreeRTOS/src/Arduino_FreeRTOS.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2022 by Alexander Entinger <[email protected]>
3-
* CAN library for Arduino.
3+
* FreeRTOS library for Arduino.
44
*
55
* This file is free software; you can redistribute it and/or modify
66
* it under the terms of either the GNU General Public License version 2

libraries/Arduino_LED_Matrix/examples/DisplaySingleFrame/DisplaySingleFrame.ino

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ void loop() {
3434
matrix.loadFrame(LEDMATRIX_HEART_BIG);
3535
delay(500);
3636

37+
// Turn off the display
38+
matrix.clear();
39+
delay(1000);
40+
3741
// Print the current value of millis() to the serial monitor
3842
Serial.println(millis());
3943
}

libraries/Arduino_LED_Matrix/src/Arduino_LED_Matrix.h

+12-2
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ class ArduinoLEDMatrix
169169
void off(size_t pin) {
170170
turnLed(pin, false);
171171
}
172-
bool begin() {
172+
int begin() {
173173
bool rv = true;
174174
uint8_t type;
175-
uint8_t ch = FspTimer::get_available_timer(type);
175+
int8_t ch = FspTimer::get_available_timer(type);
176176
if(ch == -1) {
177177
return false;
178178
}
@@ -253,6 +253,16 @@ class ArduinoLEDMatrix
253253
_callBack = callBack;
254254
}
255255

256+
void clear() {
257+
const uint32_t fullOff[] = {
258+
0x00000000,
259+
0x00000000,
260+
0x00000000
261+
};
262+
loadFrame(fullOff);
263+
}
264+
265+
256266
#ifdef MATRIX_WITH_ARDUINOGRAPHICS
257267
virtual void set(int x, int y, uint8_t r, uint8_t g, uint8_t b) {
258268
if (y >= canvasHeight || x >= canvasWidth || y < 0 || x < 0) {

libraries/SE05X/src/lib/platform/arduino/sm_port.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void smlog_print(const char *format, ...) {
2323
char debug_buf[1024];
2424
va_list argptr;
2525
va_start(argptr, format);
26-
vsprintf(debug_buf, format, argptr);
26+
vsnprintf(debug_buf, sizeof(debug_buf), format, argptr);
2727
va_end(argptr);
2828
Serial.print(debug_buf);
2929
}

libraries/SSLClient/src/ssl_debug.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void ssl_debug_print(const char *format, ...) {
2323
char debug_buf[1024];
2424
va_list argptr;
2525
va_start(argptr, format);
26-
vsprintf(debug_buf, format, argptr);
26+
vsnprintf(debug_buf, sizeof(debug_buf), format, argptr);
2727
va_end(argptr);
2828
Serial.print(debug_buf);
2929
}
@@ -32,7 +32,7 @@ void ssl_debug_println(const char *format, ...) {
3232
char debug_buf[1024];
3333
va_list argptr;
3434
va_start(argptr, format);
35-
vsprintf(debug_buf, format, argptr);
35+
vsnprintf(debug_buf, sizeof(debug_buf), format, argptr);
3636
va_end(argptr);
3737
Serial.println(debug_buf);
3838
}

libraries/SoftwareSerial/src/SoftwareSerial.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ template <size_t N> struct ss_descr_t {
5757
fsp_dma_t dma;
5858
fsp_pin_t pin;
5959
int irq_chan;
60-
::RingBuffer<char> ringbuf;
60+
::RingBuffer<uint8_t> ringbuf;
6161
uint32_t dmabuf[N][SS_MAX_FRAME_SIZE] __attribute__((aligned(4)));
6262
ss_descr_t(size_t bufsize): irq_chan(-1), ringbuf(bufsize) {
6363
}

libraries/WiFiS3/src/Modem.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,9 @@ bool ModemClass::passthrough(const uint8_t *data, size_t size) {
8888
/* -------------------------------------------------------------------------- */
8989
void ModemClass::write_nowait(const string &cmd, string &str, char * fmt, ...) {
9090
/* -------------------------------------------------------------------------- */
91-
memset(tx_buff,0x00,MAX_BUFF_SIZE);
9291
va_list va;
9392
va_start (va, fmt);
94-
vsprintf ((char *)tx_buff, fmt, va);
93+
vsnprintf((char *)tx_buff, MAX_BUFF_SIZE, fmt, va);
9594
va_end (va);
9695

9796
if(_serial_debug && _debug_level >= 2) {
@@ -109,10 +108,9 @@ void ModemClass::write_nowait(const string &cmd, string &str, char * fmt, ...) {
109108
bool ModemClass::write(const string &prompt, string &data_res, char * fmt, ...){
110109
/* -------------------------------------------------------------------------- */
111110
data_res.clear();
112-
memset(tx_buff,0x00,MAX_BUFF_SIZE);
113111
va_list va;
114112
va_start (va, fmt);
115-
vsprintf ((char *)tx_buff, fmt, va);
113+
vsnprintf((char *)tx_buff, MAX_BUFF_SIZE, fmt, va);
116114
va_end (va);
117115

118116
if(_serial_debug) {

libraries/Wire/Wire.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ extern "C" {
3030

3131
#include "Wire.h"
3232

33-
TwoWire *TwoWire::g_SCIWires[TWOWIRE_MAX_I2C_CHANNELS] = {nullptr};
34-
TwoWire *TwoWire::g_I2CWires[TWOWIRE_MAX_SCI_CHANNELS] = {nullptr};
33+
TwoWire *TwoWire::g_SCIWires[TWOWIRE_MAX_SCI_CHANNELS] = {nullptr};
34+
TwoWire *TwoWire::g_I2CWires[TWOWIRE_MAX_I2C_CHANNELS] = {nullptr};
3535

3636
/* -------------------------------------------------------------------------- */
3737
void TwoWire::setBusStatus(WireStatus_t ws) {
@@ -437,25 +437,28 @@ void TwoWire::end(void) {
437437
if(init_ok) {
438438
if(is_master) {
439439
if(m_close != nullptr) {
440-
m_close(&m_i2c_ctrl);
441440
R_BSP_IrqDisable (m_i2c_cfg.txi_irq);
442441
R_BSP_IrqDisable (m_i2c_cfg.rxi_irq);
443442
R_BSP_IrqDisable (m_i2c_cfg.tei_irq);
444443
R_BSP_IrqDisable (m_i2c_cfg.eri_irq);
445-
444+
m_close(&m_i2c_ctrl);
446445
}
447446
}
448447
else {
449448
if(s_close != nullptr) {
450-
s_close(&s_i2c_ctrl);
451449
R_BSP_IrqDisable (s_i2c_cfg.txi_irq);
452450
R_BSP_IrqDisable (s_i2c_cfg.rxi_irq);
453451
R_BSP_IrqDisable (s_i2c_cfg.tei_irq);
454452
R_BSP_IrqDisable (s_i2c_cfg.eri_irq);
453+
s_close(&s_i2c_ctrl);
455454

456455
}
457456
}
458457
}
458+
/* fix for slave that create a sort of lock on the I2C bus when end is called and the master
459+
is not more able to get the I2C buse working */
460+
R_IOPORT_PinCfg(NULL, g_pin_cfg[sda_pin].pin, IOPORT_CFG_PORT_DIRECTION_INPUT | IOPORT_CFG_PULLUP_ENABLE);
461+
R_IOPORT_PinCfg(NULL, g_pin_cfg[scl_pin].pin, IOPORT_CFG_PORT_DIRECTION_INPUT | IOPORT_CFG_PULLUP_ENABLE);
459462
init_ok = false;
460463
}
461464

libraries/Wire/Wire.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ class TwoWire : public arduino::HardwareI2C {
152152

153153
private:
154154

155-
static TwoWire *g_SCIWires[TWOWIRE_MAX_I2C_CHANNELS];
156-
static TwoWire *g_I2CWires[TWOWIRE_MAX_SCI_CHANNELS];
155+
static TwoWire *g_SCIWires[TWOWIRE_MAX_SCI_CHANNELS];
156+
static TwoWire *g_I2CWires[TWOWIRE_MAX_I2C_CHANNELS];
157157

158158
static void WireSCIMasterCallback(i2c_master_callback_args_t *);
159159
static void WireMasterCallback(i2c_master_callback_args_t *);

libraries/lwIpWrapper/src/CNetIf.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1567,10 +1567,9 @@ char b_dbg[512];
15671567
extern "C" void printDbg(const char* fmt, ...)
15681568
{
15691569

1570-
memset(b_dbg, 0x00, 256);
15711570
va_list va;
15721571
va_start(va, fmt);
1573-
vsprintf(b_dbg, fmt, va);
1572+
vsnprintf(b_dbg, sizeof(b_dbg), fmt, va);
15741573
va_end(va);
15751574

15761575
Serial.println(b_dbg);

0 commit comments

Comments
 (0)