Skip to content

Commit d92741a

Browse files
committed
Add NULCEO-L476RG variant
Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
1 parent c58275b commit d92741a

File tree

12 files changed

+1672
-6
lines changed

12 files changed

+1672
-6
lines changed

boards.txt

+16
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,22 @@ Nucleo_64.menu.Nucleo_64_board.NUCLEO_L053R8.build.cmsis_lib_gcc=arm_cortexM0l_m
108108
#To enable HID (keyboard and mouse support) add also '-DUSBD_USE_HID_COMPOSITE'
109109
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L053R8.build.extra_flags=-DSTM32L053xx -D__CORTEX_SC=0 {build.usb_flags}
110110

111+
# NUCLEO_L476RG board
112+
113+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG=Nucleo L476RG
114+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.node=NODE_L476RG
115+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.upload.maximum_size=1048576
116+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.upload.maximum_data_size=131072
117+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.mcu=cortex-m4
118+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.f_cpu=4000000L
119+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.usb_product="NUCLEO-L476RG"
120+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.board=NUCLEO_L476RG
121+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.series=STM32L4xx
122+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.variant=NUCLEO_L476RG
123+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.cmsis_lib_gcc=arm_cortexM4l_math
124+
#To enable USB add '-DUSBCON'
125+
#To enable HID (keyboard and mouse support) add also '-DUSBD_USE_HID_COMPOSITE'
126+
Nucleo_64.menu.Nucleo_64_board.NUCLEO_L476RG.build.extra_flags=-DSTM32L476xx {build.usb_flags}
111127

112128
Nucleo_64.menu.upload_method.MassStorageMethod=Mass Storage
113129
Nucleo_64.menu.upload_method.MassStorageMethod.upload.protocol=

cores/arduino/stm32/analog.c

+17-1
Original file line numberDiff line numberDiff line change
@@ -421,13 +421,25 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
421421
}
422422
#endif
423423

424+
#ifdef __HAL_RCC_ADC_CLK_ENABLE
425+
__HAL_RCC_ADC_CLK_ENABLE();
426+
#endif
427+
#ifdef __HAL_RCC_ADC_CONFIG
428+
/* ADC Periph interface clock configuration */
429+
__HAL_RCC_ADC_CONFIG(RCC_ADCCLKSOURCE_SYSCLK);
430+
#endif
431+
424432
/* Enable GPIO clock ****************************************/
425433
port = set_GPIO_Port_Clock(STM_PORT(g_current_pin));
426434

427435
/*##-2- Configure peripheral GPIO ##########################################*/
428436
/* ADC Channel GPIO pin configuration */
429437
GPIO_InitStruct.Pin = STM_GPIO_PIN(g_current_pin);
438+
#ifdef GPIO_MODE_ANALOG_ADC_CONTROL
439+
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL;
440+
#else
430441
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
442+
#endif
431443
GPIO_InitStruct.Pull = GPIO_NOPULL;
432444
HAL_GPIO_Init(port, &GPIO_InitStruct);
433445
}
@@ -573,7 +585,11 @@ uint16_t adc_read_value(PinName pin)
573585
}
574586

575587
AdcChannelConf.Channel = get_adc_channel(pin); /* Specifies the channel to configure into ADC */
588+
#ifdef STM32L4xx
589+
if (!IS_ADC_CHANNEL(&AdcHandle, AdcChannelConf.Channel)) return 0;
590+
#else
576591
if (!IS_ADC_CHANNEL(AdcChannelConf.Channel)) return 0;
592+
#endif
577593
AdcChannelConf.Rank = ADC_REGULAR_RANK_1; /* Specifies the rank in the regular group sequencer */
578594
#ifndef STM32L0xx
579595
AdcChannelConf.SamplingTime = SAMPLINGTIME; /* Sampling time value to be set for the selected channel */
@@ -585,7 +601,7 @@ uint16_t adc_read_value(PinName pin)
585601
return 0;
586602
}
587603

588-
#ifdef STM32F3xx
604+
#if defined (STM32F3xx) || defined (STM32L4xx)
589605
/*##-2.1- Calibrate ADC then Start the conversion process ####################*/
590606
if (HAL_ADCEx_Calibration_Start(&AdcHandle, ADC_SINGLE_ENDED) != HAL_OK)
591607
{

cores/arduino/stm32/stm32_def_build.h

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#define CMSIS_STARTUP_FILE "startup_stm32f429xx.s"
3333
#elif defined(STM32L053xx)
3434
#define CMSIS_STARTUP_FILE "startup_stm32l053xx.s"
35+
#elif defined(STM32L476xx)
36+
#define CMSIS_STARTUP_FILE "startup_stm32l476xx.s"
3537
#else
3638
#error UNKNOWN CHIP
3739
#endif

cores/arduino/stm32/stm32_eeprom.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
#define FLASH_DATA_SECTOR 15
8181
#elif defined (STM32L0xx)
8282
#define FLASH_BASE_ADDRESS ((uint32_t)(DATA_EEPROM_BASE)) /* 0x08080000 */
83+
#elif defined (STM32L4xx)
84+
// Flash base address (Bank2, page 256)
85+
#define FLASH_BASE_ADDRESS 0x080FF800
86+
#define FLASH_PAGE_NUMBER 255
8387
#endif
8488

8589
/**
@@ -162,20 +166,27 @@ void set_data_to_flash(void)
162166
uint32_t offset = 0;
163167
uint32_t address = FLASH_BASE_ADDRESS;
164168
uint32_t address_end = FLASH_BASE_ADDRESS + E2END;
165-
#if defined (STM32F0xx) || defined (STM32F3xx) || defined (STM32L0xx)
169+
#if defined (STM32F0xx) || defined (STM32F3xx) || defined (STM32L0xx) || defined(STM32L4xx)
166170
uint32_t pageError = 0;
167171
uint64_t data = 0;
168172

169173
// ERASING page
170174
EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
175+
#ifdef STM32L4xx
176+
EraseInitStruct.Banks = FLASH_BANK_2;
177+
EraseInitStruct.Page = FLASH_PAGE_NUMBER;
178+
#else
171179
EraseInitStruct.PageAddress = FLASH_BASE_ADDRESS;
172180
EraseInitStruct.NbPages = 1;
181+
#endif
173182

174183
if(HAL_FLASH_Unlock() == HAL_OK) {
175184
#ifdef STM32L0xx
176185
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP|FLASH_FLAG_WRPERR|FLASH_FLAG_PGAERR|\
177186
FLASH_FLAG_SIZERR|FLASH_FLAG_OPTVERR|FLASH_FLAG_RDERR|\
178187
FLASH_FLAG_FWWERR|FLASH_FLAG_NOTZEROERR);
188+
#elif defined (STM32L4xx)
189+
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
179190
#else
180191
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP|FLASH_FLAG_WRPERR|FLASH_FLAG_PGERR);
181192
#endif

cores/arduino/stm32/twi.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ void i2c_custom_init(i2c_t *obj, i2c_timing_e timing, uint32_t addressingMode, u
225225
HAL_GPIO_Init(port, &GPIO_InitStruct);
226226

227227
handle->Instance = obj->i2c;
228-
#if defined (STM32F0xx) || defined (STM32F3xx) || defined (STM32L0xx)
228+
#if defined (STM32F0xx) || defined (STM32F3xx) || defined (STM32L0xx) || defined (STM32L4xx)
229229
handle->Init.Timing = timing;
230230
#else
231231
handle->Init.ClockSpeed = timing;
@@ -280,7 +280,7 @@ void i2c_setTiming(i2c_t *obj, uint32_t frequency)
280280
else if(frequency <= 400000)
281281
f = I2C_400KHz;
282282

283-
#if defined (STM32F0xx) || defined (STM32F3xx) || defined (STM32L0xx)
283+
#if defined (STM32F0xx) || defined (STM32F3xx) || defined (STM32L0xx) || defined (STM32L4xx)
284284
obj->handle.Init.Timing = f;
285285
#else
286286
obj->handle.Init.ClockSpeed = f;

cores/arduino/stm32/twi.h

+11-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ typedef enum {
8383
}i2c_status_e;
8484

8585
typedef enum {
86-
#if defined (STM32F0xx) || defined (STM32F3xx)
86+
#if defined (STM32F0xx) || defined (STM32F3xx) || defined (STM32L0xx)
8787
//calculated with SYSCLK = 64MHz at
8888
/*https://www.google.fr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwiC4q6O7ojMAhWCOhoKHYlyBtIQFggmMAE&url=http%3A%2F%2Fuglyduck.ath.cx%2FPDF%2FSTMicro%2FARM%2FSTM32F0%2FI2C_Timing_Configuration_V1.0.1.xls&usg=AFQjCNGGjPSUAzVUdbUqMUxPub8Ojzhh9w&sig2=4YgzXFixj15GhqkAzVS4tA*/
8989
I2C_10KHz = 0xE010A9FF,
@@ -94,7 +94,16 @@ typedef enum {
9494
I2C_600KHz = 0x00900E50,
9595
I2C_800KHz = 0x00900E35,
9696
I2C_1000KHz = 0x00900E25
97-
#else
97+
#elif defined (STM32L4xx)
98+
I2C_10KHz = 0xF010F3FE,
99+
I2C_50KHz = 0x30608CFF,
100+
I2C_100KHz = 0x10D0A4E4,
101+
I2C_200KHz = 0x00F082FF,
102+
I2C_400KHz = 0x00F02E8B,
103+
I2C_600KHz = 0x00B01265,
104+
I2C_800KHz = 0x00B01243,
105+
I2C_1000KHz = 0x00B0122F
106+
#else //STM32F4xx
98107
I2C_10KHz = 10000,
99108
I2C_50KHz = 50000,
100109
I2C_100KHz = 100000,

0 commit comments

Comments
 (0)