Skip to content

Commit

Permalink
feat: Add STM32Cube HAL getter to SPI, Wire and HardwareSerial
Browse files Browse the repository at this point in the history
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 #1035

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
  • Loading branch information
ABOSTM committed Mar 9, 2022
1 parent 67a5298 commit b8e6f11
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cores/arduino/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ class HardwareSerial : public Stream {
// Interrupt handlers
static void _rx_complete_irq(serial_t *obj);
static int _tx_complete_irq(serial_t *obj);

// Could be used to mix Arduino API and STM32Cube HAL API (ex: DMA). Use at your own risk.
UART_HandleTypeDef *getHandle(void)
{
return &(_serial.handle);
}

private:
bool _rx_enabled;
uint8_t _config;
Expand Down
6 changes: 6 additions & 0 deletions libraries/SPI/src/SPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ class SPIClass {
void attachInterrupt(void);
void detachInterrupt(void);

// Could be used to mix Arduino API and STM32Cube HAL API (ex: DMA). Use at your own risk.
SPI_HandleTypeDef *getHandle(void)
{
return &(_spi.handle);
}

private:
/* Contains various spiSettings for the same spi instance. Each spi spiSettings
is associated to a CS pin. */
Expand Down
6 changes: 6 additions & 0 deletions libraries/Wire/src/Wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ class TwoWire : public Stream {
return write((uint8_t)n);
}
using Print::write;

// Could be used to mix Arduino API and STM32Cube HAL API (ex: DMA). Use at your own risk.
I2C_HandleTypeDef *getHandle(void)
{
return &(_i2c.handle);
}
};


Expand Down

0 comments on commit b8e6f11

Please sign in to comment.