Skip to content

Commit cd99f64

Browse files
committed
STM32G4: cleanup
1 parent 4f95500 commit cd99f64

17 files changed

+165
-214
lines changed
Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2016 ARM Limited
3-
* SPDX-License-Identifier: Apache-2.0
2+
* SPDX-License-Identifier: BSD-3-Clause
3+
******************************************************************************
44
*
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
5+
* Copyright (c) 2015-2020 STMicroelectronics.
6+
* All rights reserved.
87
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* This software component is licensed by ST under BSD 3-Clause license,
9+
* the "License"; You may not use this file except in compliance with the
10+
* License. You may obtain a copy of the License at:
11+
* opensource.org/licenses/BSD-3-Clause
1012
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
13+
******************************************************************************
1614
*/
15+
1716
#ifndef MBED_PERIPHERALNAMES_H
1817
#define MBED_PERIPHERALNAMES_H
1918

@@ -26,25 +25,36 @@ extern "C" {
2625
typedef enum {
2726
ADC_1 = (int)ADC1_BASE,
2827
ADC_2 = (int)ADC2_BASE,
28+
#if defined ADC3_BASE
2929
ADC_3 = (int)ADC3_BASE,
30+
#endif
31+
#if defined ADC4_BASE
3032
ADC_4 = (int)ADC4_BASE,
31-
ADC_5 = (int)ADC5_BASE
33+
#endif
34+
#if defined ADC5_BASE
35+
ADC_5 = (int)ADC5_BASE,
36+
#endif
3237
} ADCName;
3338

3439
typedef enum {
3540
DAC_1 = (int)DAC1_BASE,
41+
#if defined DAC2_BASE
3642
DAC_2 = (int)DAC2_BASE,
43+
#endif
3744
DAC_3 = (int)DAC3_BASE,
45+
#if defined DAC4_BASE
3846
DAC_4 = (int)DAC4_BASE,
39-
47+
#endif
4048
} DACName;
4149

4250
typedef enum {
4351
UART_1 = (int)USART1_BASE,
4452
UART_2 = (int)USART2_BASE,
4553
UART_3 = (int)USART3_BASE,
4654
UART_4 = (int)UART4_BASE,
55+
#if defined UART5_BASE
4756
UART_5 = (int)UART5_BASE,
57+
#endif
4858
LPUART_1 = (int)LPUART1_BASE
4959
} UARTName;
5060

@@ -53,40 +63,54 @@ typedef enum {
5363
SPI_1 = (int)SPI1_BASE,
5464
SPI_2 = (int)SPI2_BASE,
5565
SPI_3 = (int)SPI3_BASE,
66+
#if defined SPI4_BASE
5667
SPI_4 = (int)SPI4_BASE,
68+
#endif
5769
} SPIName;
5870

5971
typedef enum {
6072
I2C_1 = (int)I2C1_BASE,
6173
I2C_2 = (int)I2C2_BASE,
6274
I2C_3 = (int)I2C3_BASE,
75+
#if defined I2C4_BASE
6376
I2C_4 = (int)I2C4_BASE
77+
#endif
6478
} I2CName;
6579

6680
typedef enum {
6781
PWM_1 = (int)TIM1_BASE,
6882
PWM_2 = (int)TIM2_BASE,
6983
PWM_3 = (int)TIM3_BASE,
7084
PWM_4 = (int)TIM4_BASE,
85+
#if defined TIM5_BASE
7186
PWM_5 = (int)TIM5_BASE,
87+
#endif
7288
PWM_6 = (int)TIM6_BASE,
7389
PWM_7 = (int)TIM7_BASE,
7490
PWM_8 = (int)TIM8_BASE,
7591
PWM_15 = (int)TIM15_BASE,
7692
PWM_16 = (int)TIM16_BASE,
7793
PWM_17 = (int)TIM17_BASE,
78-
PWM_20 = (int)TIM20_BASE
94+
#if defined TIM20_BASE
95+
PWM_20 = (int)TIM20_BASE,
96+
#endif
7997
} PWMName;
8098

8199
typedef enum {
82100
CAN_1 = (int)FDCAN1_BASE,
101+
#if defined FDCAN2_BASE
83102
CAN_2 = (int)FDCAN2_BASE,
84-
CAN_3 = (int)FDCAN3_BASE
103+
#endif
104+
#if defined FDCAN3_BASE
105+
CAN_3 = (int)FDCAN3_BASE,
106+
#endif
85107
} CANName;
86108

109+
#if defined QSPI_R_BASE
87110
typedef enum {
88111
QSPI_1 = (int)QSPI_R_BASE,
89112
} QSPIName;
113+
#endif
90114

91115
typedef enum {
92116
USB_FS = (int)USB_BASE

targets/TARGET_STM/TARGET_STM32G4/analogin_device.c

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2016, STMicroelectronics
3-
* All rights reserved.
2+
* SPDX-License-Identifier: BSD-3-Clause
3+
******************************************************************************
44
*
5-
* Redistribution and use in source and binary forms, with or without
6-
* modification, are permitted provided that the following conditions are met:
5+
* Copyright (c) 2015-2020 STMicroelectronics.
6+
* All rights reserved.
77
*
8-
* 1. Redistributions of source code must retain the above copyright notice,
9-
* this list of conditions and the following disclaimer.
10-
* 2. Redistributions in binary form must reproduce the above copyright notice,
11-
* this list of conditions and the following disclaimer in the documentation
12-
* and/or other materials provided with the distribution.
13-
* 3. Neither the name of STMicroelectronics nor the names of its contributors
14-
* may be used to endorse or promote products derived from this software
15-
* without specific prior written permission.
8+
* This software component is licensed by ST under BSD 3-Clause license,
9+
* the "License"; You may not use this file except in compliance with the
10+
* License. You may obtain a copy of the License at:
11+
* opensource.org/licenses/BSD-3-Clause
1612
*
17-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13+
******************************************************************************
2714
*/
15+
2816
#include "mbed_assert.h"
2917
#include "analogin_api.h"
3018

@@ -313,12 +301,11 @@ void analogin_free(analogin_t *obj)
313301
#if defined(ADC1)
314302
if ((ADCName)obj->handle.Instance == ADC_1) {
315303
adc1_en_counter--;
316-
if(ADC1_EN_CTR == 0)
317-
{
304+
if (ADC1_EN_CTR == 0) {
318305
HAL_ADC_DeInit(&obj->handle);
319306

320307
// Disable clock if ADC2 is also unused
321-
if(ADC2_EN_CTR == 0) {
308+
if (ADC2_EN_CTR == 0) {
322309
LL_AHB2_GRP1_DisableClock(LL_AHB2_GRP1_PERIPH_ADC12);
323310
}
324311
}
@@ -327,12 +314,11 @@ void analogin_free(analogin_t *obj)
327314
#if defined(ADC2)
328315
if ((ADCName)obj->handle.Instance == ADC_2) {
329316
adc2_en_counter--;
330-
if(ADC2_EN_CTR == 0)
331-
{
317+
if (ADC2_EN_CTR == 0) {
332318
HAL_ADC_DeInit(&obj->handle);
333319

334320
// Disable clock if ADC1 is also unused
335-
if(ADC1_EN_CTR == 0) {
321+
if (ADC1_EN_CTR == 0) {
336322
LL_AHB2_GRP1_DisableClock(LL_AHB2_GRP1_PERIPH_ADC12);
337323
}
338324
}
@@ -341,12 +327,11 @@ void analogin_free(analogin_t *obj)
341327
#if defined(ADC3)
342328
if ((ADCName)obj->handle.Instance == ADC_3) {
343329
adc3_en_counter--;
344-
if(ADC3_EN_CTR == 0)
345-
{
330+
if (ADC3_EN_CTR == 0) {
346331
HAL_ADC_DeInit(&obj->handle);
347332

348333
// Disable clock if ADC4 and ADC5 are also unused
349-
if((ADC4_EN_CTR + ADC5_EN_CTR) == 0) {
334+
if ((ADC4_EN_CTR + ADC5_EN_CTR) == 0) {
350335
LL_AHB2_GRP1_DisableClock(LL_AHB2_GRP1_PERIPH_ADC345);
351336
}
352337
}
@@ -355,12 +340,11 @@ void analogin_free(analogin_t *obj)
355340
#if defined(ADC4)
356341
if ((ADCName)obj->handle.Instance == ADC_4) {
357342
adc4_en_counter--;
358-
if(ADC4_EN_CTR == 0)
359-
{
343+
if (ADC4_EN_CTR == 0) {
360344
HAL_ADC_DeInit(&obj->handle);
361345

362346
// Disable clock if ADC3 and ADC5 are also unused
363-
if((ADC3_EN_CTR + ADC5_EN_CTR) == 0) {
347+
if ((ADC3_EN_CTR + ADC5_EN_CTR) == 0) {
364348
LL_AHB2_GRP1_DisableClock(LL_AHB2_GRP1_PERIPH_ADC345);
365349
}
366350
}
@@ -370,12 +354,11 @@ void analogin_free(analogin_t *obj)
370354
#if defined(ADC5)
371355
if ((ADCName)obj->handle.Instance == ADC_5) {
372356
adc5_en_counter--;
373-
if(ADC5_EN_CTR == 0)
374-
{
357+
if (ADC5_EN_CTR == 0) {
375358
HAL_ADC_DeInit(&obj->handle);
376359

377360
// Disable clock if ADC3 and ADC4 are also unused
378-
if((ADC3_EN_CTR + ADC4_EN_CTR) == 0) {
361+
if ((ADC3_EN_CTR + ADC4_EN_CTR) == 0) {
379362
LL_AHB2_GRP1_DisableClock(LL_AHB2_GRP1_PERIPH_ADC345);
380363
}
381364
}

targets/TARGET_STM/TARGET_STM32G4/analogout_device.c

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2015, STMicroelectronics
3-
* All rights reserved.
2+
* SPDX-License-Identifier: BSD-3-Clause
3+
******************************************************************************
44
*
5-
* Redistribution and use in source and binary forms, with or without
6-
* modification, are permitted provided that the following conditions are met:
5+
* Copyright (c) 2015-2020 STMicroelectronics.
6+
* All rights reserved.
77
*
8-
* 1. Redistributions of source code must retain the above copyright notice,
9-
* this list of conditions and the following disclaimer.
10-
* 2. Redistributions in binary form must reproduce the above copyright notice,
11-
* this list of conditions and the following disclaimer in the documentation
12-
* and/or other materials provided with the distribution.
13-
* 3. Neither the name of STMicroelectronics nor the names of its contributors
14-
* may be used to endorse or promote products derived from this software
15-
* without specific prior written permission.
8+
* This software component is licensed by ST under BSD 3-Clause license,
9+
* the "License"; You may not use this file except in compliance with the
10+
* License. You may obtain a copy of the License at:
11+
* opensource.org/licenses/BSD-3-Clause
1612
*
17-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13+
******************************************************************************
2714
*/
15+
2816
#include "mbed_assert.h"
2917
#include "analogout_api.h"
3018

targets/TARGET_STM/TARGET_STM32G4/cmsis.h

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2019 ARM Limited
3-
* SPDX-License-Identifier: Apache-2.0
2+
* SPDX-License-Identifier: BSD-3-Clause
3+
******************************************************************************
44
*
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
5+
* Copyright (c) 2015-2020 STMicroelectronics.
6+
* All rights reserved.
87
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* This software component is licensed by ST under BSD 3-Clause license,
9+
* the "License"; You may not use this file except in compliance with the
10+
* License. You may obtain a copy of the License at:
11+
* opensource.org/licenses/BSD-3-Clause
1012
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
13+
******************************************************************************
1614
*/
1715

1816
#ifndef MBED_CMSIS_H

targets/TARGET_STM/TARGET_STM32G4/flash_api.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2017 ARM Limited
3-
* Copyright (c) 2017 STMicroelectronics
4-
* SPDX-License-Identifier: Apache-2.0
2+
* SPDX-License-Identifier: BSD-3-Clause
3+
******************************************************************************
54
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
5+
* Copyright (c) 2015-2020 STMicroelectronics.
6+
* All rights reserved.
97
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* This software component is licensed by ST under BSD 3-Clause license,
9+
* the "License"; You may not use this file except in compliance with the
10+
* License. You may obtain a copy of the License at:
11+
* opensource.org/licenses/BSD-3-Clause
1112
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
13+
******************************************************************************
1714
*/
1815

1916
#include "flash_api.h"
@@ -51,7 +48,7 @@ static uint32_t GetPage(uint32_t Addr)
5148
static uint32_t GetBank(uint32_t Addr)
5249
{
5350
uint32_t bank = 0;
54-
#if defined(SYSCFG_MEMRMP_FB_MODE)
51+
#if defined(SYSCFG_MEMRMP_FB_MODE) && defined(FLASH_OPTR_DBANK)
5552
if (READ_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_FB_MODE) == 0) {
5653
/* No Bank swap */
5754
if (Addr < (FLASH_BASE + FLASH_BANK_SIZE)) {
@@ -68,7 +65,6 @@ static uint32_t GetBank(uint32_t Addr)
6865
}
6966
}
7067
#else
71-
/* Device like L432KC */
7268
bank = FLASH_BANK_1;
7369
#endif
7470

targets/TARGET_STM/TARGET_STM32G4/gpio_irq_device.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* SPDX-License-Identifier: BSD-3-Clause
33
******************************************************************************
44
*
5-
* Copyright (c) 2017 STMicroelectronics.
5+
* Copyright (c) 2015-2020 STMicroelectronics.
66
* All rights reserved.
77
*
88
* This software component is licensed by ST under BSD 3-Clause license,
@@ -12,6 +12,7 @@
1212
*
1313
******************************************************************************
1414
*/
15+
1516
#include "cmsis.h"
1617
#include "gpio_irq_device.h"
1718

targets/TARGET_STM/TARGET_STM32G4/gpio_irq_device.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* SPDX-License-Identifier: BSD-3-Clause
33
******************************************************************************
44
*
5-
* Copyright (c) 2017 STMicroelectronics.
5+
* Copyright (c) 2015-2020 STMicroelectronics.
66
* All rights reserved.
77
*
88
* This software component is licensed by ST under BSD 3-Clause license,
@@ -12,6 +12,7 @@
1212
*
1313
******************************************************************************
1414
*/
15+
1516
#ifndef MBED_GPIO_IRQ_DEVICE_H
1617
#define MBED_GPIO_IRQ_DEVICE_H
1718

0 commit comments

Comments
 (0)