Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cores/arduino/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ void HardwareSerial::init(void)
_serial.tx_tail = 0;
}

void HardwareSerial::configForLowPower(void)
{
#if defined(HAL_PWR_MODULE_ENABLED) && defined(UART_IT_WUF)
// Reconfigure properly Serial instance to use HSI as clock source
end();
uart_config_lowpower(&_serial);
begin(_serial.baudrate, _config);
#endif
}

// Actual interrupt handlers //////////////////////////////////////////////////////////////

void HardwareSerial::_rx_complete_irq(serial_t* obj)
Expand Down Expand Up @@ -226,6 +236,7 @@ void HardwareSerial::begin(unsigned long baud, byte config)
uint32_t databits = 0;

_serial.baudrate = (uint32_t)baud;
_config = config;

// Manage databits
switch(config & 0x07) {
Expand Down
4 changes: 4 additions & 0 deletions cores/arduino/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,15 @@ class HardwareSerial : public Stream
void setRx(PinName _rx);
void setTx(PinName _tx);

friend class STM32LowPower;

// Interrupt handlers
static void _rx_complete_irq(serial_t* obj);
static int _tx_complete_irq(serial_t* obj);
private:
uint8_t _config;
void init(void);
void configForLowPower(void);
};

extern HardwareSerial Serial1;
Expand Down
1 change: 1 addition & 0 deletions cores/arduino/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extern "C"{
#include "digital_io.h"
#include "hal_uart_emul.h"
#include "hw_config.h"
#include "low_power.h"
#include "rtc.h"
#include "spi_com.h"
#include "stm32_eeprom.h"
Expand Down
10 changes: 8 additions & 2 deletions cores/arduino/stm32/PinNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ extern "C" {
#endif

typedef enum {
// Not connected
NC = (int)0xFFFFFFFF,

// Pin name definition
PA_0 = (PortA << 4) + 0x00,
PA_1 = (PortA << 4) + 0x01,
PA_2 = (PortA << 4) + 0x02,
Expand Down Expand Up @@ -205,8 +208,11 @@ typedef enum {
PK_14 = (PortK << 4) + 0x0E,
PK_15 = (PortK << 4) + 0x0F,
#endif
// Not connected
NC = (int)0xFFFFFFFF
// Specific pin name define in the variant
#if __has_include("PinNamesVar.h")
#include "PinNamesVar.h"
#endif
P_END = NC
} PinName;

#ifdef __cplusplus
Expand Down
Loading