Skip to content

Sync to 1.3.0 #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jun 30, 2018
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Arduino core support for STM32 based boards
### Latest release [![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Core_STM32.svg)](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest) [![GitHub commits](https://img.shields.io/github/commits-since/stm32duino/Arduino_Core_STM32/1.2.0.svg)](https://github.com/stm32duino/Arduino_Core_STM32/compare/1.2.0...master)
### Latest release [![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Core_STM32.svg)](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest) [![GitHub commits](https://img.shields.io/github/commits-since/stm32duino/Arduino_Core_STM32/1.3.0.svg)](https://github.com/stm32duino/Arduino_Core_STM32/compare/1.3.0...master)

**Warning**: release versioning has been changed from date versioning to semantic one. See [Release Versioning change](https://github.com/stm32duino/wiki/wiki/Release-Versioning-change)

Expand All @@ -26,6 +26,7 @@ For advanced user, you can use the repository: see the [Using git repository](ht
* STM32F0
* [Nucleo F030R8](http://www.st.com/en/evaluation-tools/nucleo-f030r8.html)
* [Nucleo F091RC](http://www.st.com/en/evaluation-tools/nucleo-f091rc.html)
* [32F0308DISCOVERY](http://www.st.com/en/evaluation-tools/32f0308discovery.html)

* STM32F1
* BluePill F103C8 (Basic support, no USB)
Expand Down Expand Up @@ -62,6 +63,8 @@ For advanced user, you can use the repository: see the [Using git repository](ht
* STM32L4
* [Nucleo L432KC](http://www.st.com/en/evaluation-tools/nucleo-l432kc.html)
* [Nucleo L476RG](http://www.st.com/en/evaluation-tools/nucleo-l476rg.html)
* [NUCLEO-L496ZG-P](http://www.st.com/en/evaluation-tools/nucleo-l496zg.html)
* [NUCLEO-L496ZG-P](http://www.st.com/en/evaluation-tools/nucleo-l496zg-p.html)
* [B-L475E-IOT01A](http://www.st.com/en/evaluation-tools/b-l475e-iot01a.html)

### Next release
Expand Down
106 changes: 59 additions & 47 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,30 @@ Nucleo_144.menu.pnum.NUCLEO_F429ZI.build.product_line=STM32F429xx
Nucleo_144.menu.pnum.NUCLEO_F429ZI.build.variant=NUCLEO_F429ZI
Nucleo_144.menu.pnum.NUCLEO_F429ZI.build.cmsis_lib_gcc=arm_cortexM4l_math

# NUCLEO_L496ZG board
Nucleo_144.menu.pnum.NUCLEO_L496ZG=Nucleo L496ZG
Nucleo_144.menu.pnum.NUCLEO_L496ZG.node=NODE_L496ZG
Nucleo_144.menu.pnum.NUCLEO_L496ZG.upload.maximum_size=1048576
Nucleo_144.menu.pnum.NUCLEO_L496ZG.upload.maximum_data_size=327680
Nucleo_144.menu.pnum.NUCLEO_L496ZG.build.mcu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
Nucleo_144.menu.pnum.NUCLEO_L496ZG.build.board=NUCLEO_L496ZG
Nucleo_144.menu.pnum.NUCLEO_L496ZG.build.series=STM32L4xx
Nucleo_144.menu.pnum.NUCLEO_L496ZG.build.product_line=STM32L496xx
Nucleo_144.menu.pnum.NUCLEO_L496ZG.build.variant=NUCLEO_L496ZG
Nucleo_144.menu.pnum.NUCLEO_L496ZG.build.cmsis_lib_gcc=arm_cortexM4l_math

# NUCLEO_L496ZG-P board
Nucleo_144.menu.pnum.NUCLEO_L496ZG-P=Nucleo L496ZG-P
Nucleo_144.menu.pnum.NUCLEO_L496ZG-P.node=NODE_L496ZG
Nucleo_144.menu.pnum.NUCLEO_L496ZG-P.upload.maximum_size=1048576
Nucleo_144.menu.pnum.NUCLEO_L496ZG-P.upload.maximum_data_size=327680
Nucleo_144.menu.pnum.NUCLEO_L496ZG-P.build.mcu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
Nucleo_144.menu.pnum.NUCLEO_L496ZG-P.build.board=NUCLEO_L496ZG_P
Nucleo_144.menu.pnum.NUCLEO_L496ZG-P.build.series=STM32L4xx
Nucleo_144.menu.pnum.NUCLEO_L496ZG-P.build.product_line=STM32L496xx
Nucleo_144.menu.pnum.NUCLEO_L496ZG-P.build.variant=NUCLEO_L496ZG
Nucleo_144.menu.pnum.NUCLEO_L496ZG-P.build.cmsis_lib_gcc=arm_cortexM4l_math

# Upload menu
Nucleo_144.menu.upload_method.MassStorage=Mass Storage
Nucleo_144.menu.upload_method.MassStorage.upload.protocol=
Expand Down Expand Up @@ -472,53 +496,41 @@ Maple.menu.upload_method.serialMethod.upload.tool=serial_upload

################################################################################
# Serialx activation
Nucleo_144.menu.xserial.generic=Generic Serial
Nucleo_144.menu.xserial.none=No Serial
Nucleo_144.menu.xserial.none.build.xSerial=-DNO_HWSERIAL
Nucleo_144.menu.xserial.all=All (up to 10)
Nucleo_144.menu.xserial.all.build.xSerial=-DALL_HWSERIAL
Nucleo_144.menu.xserial.third=Enable first third (USART1 to 3 if available)
Nucleo_144.menu.xserial.third.build.xSerial=-DFIRST_THIRD_HWSERIAL

Nucleo_64.menu.xserial.generic=Generic Serial
Nucleo_64.menu.xserial.none=No Serial
Nucleo_64.menu.xserial.none.build.xSerial=-DNO_HWSERIAL
Nucleo_64.menu.xserial.all=All (up to 10)
Nucleo_64.menu.xserial.all.build.xSerial=-DALL_HWSERIAL
Nucleo_64.menu.xserial.third=Enable first third (USART1 to 3 if available)
Nucleo_64.menu.xserial.third.build.xSerial=-DFIRST_THIRD_HWSERIAL

Nucleo_32.menu.xserial.generic=Generic Serial
Nucleo_32.menu.xserial.none=No Serial
Nucleo_32.menu.xserial.none.build.xSerial=-DNO_HWSERIAL
Nucleo_32.menu.xserial.all=All (up to 10)
Nucleo_32.menu.xserial.all.build.xSerial=-DALL_HWSERIAL
Nucleo_32.menu.xserial.third=Enable first third (USART1 to 3 if available)
Nucleo_32.menu.xserial.third.build.xSerial=-DFIRST_THIRD_HWSERIAL

Disco.menu.xserial.generic=Generic Serial
Disco.menu.xserial.none=No Serial
Disco.menu.xserial.none.build.xSerial=-DNO_HWSERIAL
Disco.menu.xserial.all=All (up to 10)
Disco.menu.xserial.all.build.xSerial=-DALL_HWSERIAL
Disco.menu.xserial.third=Enable first third (USART1 to 3 if available)
Disco.menu.xserial.third.build.xSerial=-DFIRST_THIRD_HWSERIAL

GenF103.menu.xserial.generic=Generic Serial
GenF103.menu.xserial.none=No Serial
GenF103.menu.xserial.none.build.xSerial=-DNO_HWSERIAL
GenF103.menu.xserial.all=All (up to 10)
GenF103.menu.xserial.all.build.xSerial=-DALL_HWSERIAL
GenF103.menu.xserial.third=Enable first third (USART1 to 3 if available)
GenF103.menu.xserial.third.build.xSerial=-DFIRST_THIRD_HWSERIAL

Maple.menu.xserial.generic=Generic Serial
Maple.menu.xserial.none=No Serial
Maple.menu.xserial.none.build.xSerial=-DNO_HWSERIAL
Maple.menu.xserial.all=All (up to 10)
Maple.menu.xserial.all.build.xSerial=-DALL_HWSERIAL
Maple.menu.xserial.third=Enable first third (USART1 to 3 if available)
Maple.menu.xserial.third.build.xSerial=-DFIRST_THIRD_HWSERIAL
Nucleo_144.menu.xserial.generic=Enabled with generic Serial
Nucleo_144.menu.xserial.none=Enabled without generic Serial
Nucleo_144.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE
Nucleo_144.menu.xserial.disabled=Disabled (No Serial)
Nucleo_144.menu.xserial.disabled.build.xSerial=

Nucleo_64.menu.xserial.generic=Enabled with generic Serial
Nucleo_64.menu.xserial.none=Enabled without generic Serial
Nucleo_64.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE
Nucleo_64.menu.xserial.disabled=Disabled (No Serial)
Nucleo_64.menu.xserial.disabled.build.xSerial=

Nucleo_32.menu.xserial.generic=Enabled with generic Serial
Nucleo_32.menu.xserial.none=Enabled without generic Serial
Nucleo_32.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE
Nucleo_32.menu.xserial.disabled=Disabled (No Serial)
Nucleo_32.menu.xserial.disabled.build.xSerial=

Disco.menu.xserial.generic=Enabled with generic Serial
Disco.menu.xserial.none=Enabled without generic Serial
Disco.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE
Disco.menu.xserial.disabled=Disabled (No Serial)
Disco.menu.xserial.disabled.build.xSerial=

GenF103.menu.xserial.generic=Enabled with generic Serial
GenF103.menu.xserial.none=Enabled without generic Serial
GenF103.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE
GenF103.menu.xserial.disabled=Disabled (No Serial)
GenF103.menu.xserial.disabled.build.xSerial=

Maple.menu.xserial.generic=Enabled with generic Serial
Maple.menu.xserial.none=Enabled without generic Serial
Maple.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE
Maple.menu.xserial.disabled=Disabled (No Serial)
Maple.menu.xserial.disabled.build.xSerial=

# USB connectivity
Nucleo_144.menu.usb.none=None
Expand Down
16 changes: 12 additions & 4 deletions cores/arduino/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
#include "Arduino.h"
#include "HardwareSerial.h"

#if !defined(NO_HWSERIAL)
#if defined(HAL_UART_MODULE_ENABLED)
#if defined(HAVE_HWSERIAL1) || defined(HAVE_HWSERIAL2) || defined(HAVE_HWSERIAL3) ||\
defined(HAVE_HWSERIAL4) || defined(HAVE_HWSERIAL5) || defined(HAVE_HWSERIAL6) ||\
defined(HAVE_HWSERIAL7) || defined(HAVE_HWSERIAL8) || defined(HAVE_HWSERIAL8) ||\
defined(HAVE_HWSERIAL10)
defined(HAVE_HWSERIAL10) || defined(HAVE_HWSERIALLP1)
// SerialEvent functions are weak, so when the user doesn't define them,
// the linker just sets their address to 0 (which is checked below).
#if defined(HAVE_HWSERIAL1)
Expand Down Expand Up @@ -103,6 +103,12 @@
void serialEvent10() __attribute__((weak));
#endif

#if defined(HAVE_HWSERIALLP1)
HardwareSerial SerialLP1(LPUART1);
void serialEventLP1() __attribute__((weak));
#endif
#endif // HAVE_HWSERIALx

void serialEventRun(void)
{
#if defined(HAVE_HWSERIAL1)
Expand Down Expand Up @@ -135,6 +141,9 @@ void serialEventRun(void)
#if defined(HAVE_HWSERIAL10)
if (serialEventl10 && Serial10.available()) serialEvent10();
#endif
#if defined(HAVE_HWSERIALLP1)
if (serialEventLP1 && SerialLP1.available()) serialEventLP1();
#endif
}

// Constructors ////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -391,5 +400,4 @@ void HardwareSerial::setRx(PinName _rx) {
void HardwareSerial::setTx(PinName _tx){
_serial.pin_tx = _tx;
}
#endif // HAVE_HWSERIALx
#endif // !NO_HWSERIAL
#endif // HAL_UART_MODULE_ENABLED
1 change: 1 addition & 0 deletions cores/arduino/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ extern HardwareSerial Serial7;
extern HardwareSerial Serial8;
extern HardwareSerial Serial9;
extern HardwareSerial Serial10;
extern HardwareSerial SerialLP1;

extern void serialEventRun(void) __attribute__((weak));

Expand Down
18 changes: 17 additions & 1 deletion cores/arduino/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ enum {

// Arduino analog pins
// Analog pins must be contiguous to be able to loop on each value
#define MAX_ANALOG_INPUTS 20
#define MAX_ANALOG_INPUTS 24
_Static_assert(NUM_ANALOG_INPUTS <= MAX_ANALOG_INPUTS,
"Core NUM_ANALOG_INPUTS limited to MAX_ANALOG_INPUTS" );
_Static_assert(NUM_ANALOG_FIRST >= NUM_ANALOG_INPUTS,
Expand Down Expand Up @@ -138,6 +138,22 @@ static const uint8_t A18 = PIN_A18;
#define PIN_A19 (PIN_A18 + 1)
static const uint8_t A19 = PIN_A19;
#endif
#if NUM_ANALOG_INPUTS > 20
#define PIN_A20 (PIN_A19 + 1)
static const uint8_t A20 = PIN_A20;
#endif
#if NUM_ANALOG_INPUTS > 21
#define PIN_A21 (PIN_A20 + 1)
static const uint8_t A21 = PIN_A21;
#endif
#if NUM_ANALOG_INPUTS > 22
#define PIN_A22 (PIN_A21 + 1)
static const uint8_t A22 = PIN_A22;
#endif
#if NUM_ANALOG_INPUTS > 23
#define PIN_A23 (PIN_A22 + 1)
static const uint8_t A23 = PIN_A23;
#endif

// Default for Arduino connector compatibility
// SPI Definitions
Expand Down
5 changes: 5 additions & 0 deletions cores/arduino/stm32/PortNames.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ GPIO_TypeDef *set_GPIO_Port_Clock(uint32_t port_idx) {
#endif
#if defined GPIOG_BASE
case PortG:
#if defined(STM32L4xx) && defined(PWR_CR2_IOSV)
// Enable VDDIO2 supply for 14 I/Os (Port G[15:2])
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWREx_EnableVddIO2();
#endif
gpioPort = (GPIO_TypeDef *)GPIOG_BASE;
__HAL_RCC_GPIOG_CLK_ENABLE();
break;
Expand Down
60 changes: 59 additions & 1 deletion cores/arduino/stm32/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*
******************************************************************************
*/
#include "stm32_def.h"
#include "clock.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -120,6 +120,64 @@ void delayInsideIT(uint32_t delay_us)
#endif
}

/**
* @brief Enable the specified clock if not already set
* @param source: clock source: LSE_CLOCK, LSI_CLOCK, HSI_CLOCK or HSE_CLOCK
* @retval None
*/
void enableClock(sourceClock_t source)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

switch(source) {
case LSI_CLOCK:
if(__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY) == RESET) {
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
}
break;
case HSI_CLOCK:
if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) == RESET) {
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
}
break;
case LSE_CLOCK:
/* Enable Power Clock */
if(__HAL_RCC_PWR_IS_CLK_DISABLED()) {
__HAL_RCC_PWR_CLK_ENABLE();
}
#ifdef HAL_PWR_MODULE_ENABLED
/* Allow access to Backup domain */
HAL_PWR_EnableBkUpAccess();
#endif
if(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET) {
#ifdef __HAL_RCC_LSEDRIVE_CONFIG
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
#endif
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
}
break;
case HSE_CLOCK:
if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET) {
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
}
break;
default:
/* No valid clock to enable */
break;
}
if(RCC_OscInitStruct.OscillatorType != RCC_OSCILLATORTYPE_NONE) {
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
Error_Handler();
}
}
}

#ifdef __cplusplus
}
#endif
Expand Down
9 changes: 9 additions & 0 deletions cores/arduino/stm32/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,22 @@
#endif

/* Exported types ------------------------------------------------------------*/
/* Clock source selection */
typedef enum {
LSI_CLOCK,
HSI_CLOCK,
LSE_CLOCK,
HSE_CLOCK
} sourceClock_t;

/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
uint32_t GetCurrentMilli(void);
uint32_t GetCurrentMicro(void);
void delayInsideIT(uint32_t delay_us);

void enableClock(sourceClock_t source);
#ifdef __cplusplus
}
#endif
Expand Down
21 changes: 16 additions & 5 deletions cores/arduino/stm32/low_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
extern "C" {
#endif

#ifdef UART_IT_WUF
#if defined(UART_IT_WUF) && defined(HAL_UART_MODULE_ENABLED)
/* Save UART handler for callback */
static UART_HandleTypeDef* WakeUpUart = NULL;
#endif
Expand Down Expand Up @@ -201,7 +201,7 @@ void LowPower_sleep(uint32_t regulator){
void LowPower_stop(serial_t *obj){
__disable_irq();

#ifdef UART_IT_WUF
#if defined(UART_IT_WUF) && defined(HAL_UART_MODULE_ENABLED)
if (WakeUpUart != NULL) {
HAL_UARTEx_EnableStopMode(WakeUpUart);
}
Expand All @@ -223,8 +223,8 @@ void LowPower_stop(serial_t *obj){
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);

/* Exit Stop mode reset clocks */
SystemClock_Config();
#ifdef UART_IT_WUF
SystemClock_ConfigFromStop();
#if defined(UART_IT_WUF) && defined(HAL_UART_MODULE_ENABLED)
if (WakeUpUart != NULL) {
/* In case of WakeUp from UART, reset its clock source to HSI */
uart_config_lowpower(obj);
Expand Down Expand Up @@ -290,7 +290,7 @@ void LowPower_shutdown(){
* @retval None
*/
void LowPower_EnableWakeUpUart(serial_t* serial, void (*FuncPtr)( void ) ) {
#ifdef UART_IT_WUF
#if defined(UART_IT_WUF) && defined(HAL_UART_MODULE_ENABLED)
UART_WakeUpTypeDef WakeUpSelection;
if(serial == NULL) {
return;
Expand Down Expand Up @@ -319,6 +319,17 @@ void LowPower_EnableWakeUpUart(serial_t* serial, void (*FuncPtr)( void ) ) {
WakeUpUartCb = FuncPtr;
}

/**
* @brief Configures system clock after wake-up from STOP
* @note Weaked function which can be redefined by user at the sketch level.
* By default, call 'SystemClock_Config()'.
* @param None
* @retval None
*/
WEAK void SystemClock_ConfigFromStop(void) {
SystemClock_Config();
}

#ifdef __cplusplus
}
#endif
Expand Down
Loading