Skip to content

Commit b8e6f11

Browse files
committed
feat: Add STM32Cube HAL getter to SPI, Wire and HardwareSerial
Could be used for example to mix Arduino API and STM32Cube HAL API. For example to configure DMA. Warning: Use at your own risk Fixes stm32duino#1035 Signed-off-by: Alexandre Bourdiol <[email protected]>
1 parent 67a5298 commit b8e6f11

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

cores/arduino/HardwareSerial.h

+7
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ class HardwareSerial : public Stream {
174174
// Interrupt handlers
175175
static void _rx_complete_irq(serial_t *obj);
176176
static int _tx_complete_irq(serial_t *obj);
177+
178+
// Could be used to mix Arduino API and STM32Cube HAL API (ex: DMA). Use at your own risk.
179+
UART_HandleTypeDef *getHandle(void)
180+
{
181+
return &(_serial.handle);
182+
}
183+
177184
private:
178185
bool _rx_enabled;
179186
uint8_t _config;

libraries/SPI/src/SPI.h

+6
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ class SPIClass {
227227
void attachInterrupt(void);
228228
void detachInterrupt(void);
229229

230+
// Could be used to mix Arduino API and STM32Cube HAL API (ex: DMA). Use at your own risk.
231+
SPI_HandleTypeDef *getHandle(void)
232+
{
233+
return &(_spi.handle);
234+
}
235+
230236
private:
231237
/* Contains various spiSettings for the same spi instance. Each spi spiSettings
232238
is associated to a CS pin. */

libraries/Wire/src/Wire.h

+6
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ class TwoWire : public Stream {
130130
return write((uint8_t)n);
131131
}
132132
using Print::write;
133+
134+
// Could be used to mix Arduino API and STM32Cube HAL API (ex: DMA). Use at your own risk.
135+
I2C_HandleTypeDef *getHandle(void)
136+
{
137+
return &(_i2c.handle);
138+
}
133139
};
134140

135141

0 commit comments

Comments
 (0)