Skip to content

Commit 33a7e66

Browse files
authored
Merge pull request #13906 from jeromecoutant/PR_G070
STM32G070: generic target creation
2 parents 28eeee2 + b79b8f5 commit 33a7e66

File tree

4 files changed

+64
-12
lines changed

4 files changed

+64
-12
lines changed

targets/TARGET_STM/TARGET_STM32G0/objects.h

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
extern "C" {
2929
#endif
3030

31+
#define RTC_WKUP_IRQn RTC_TAMP_IRQn
32+
3133
struct gpio_irq_s {
3234
IRQn_Type irq_n;
3335
uint32_t irq_index;

targets/TARGET_STM/TARGET_STM32G0/serial_device.c

+22-6
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,32 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
129129

130130
#if defined(USART3_BASE)
131131
if (obj_s->uart == UART_3) {
132+
#if defined(LPUART1_BASE)
132133
irq_n = USART3_4_LPUART1_IRQn;
134+
#else
135+
irq_n = USART3_4_IRQn;
136+
#endif
133137
vector = (uint32_t)&uart3_irq;
134138
}
135139
#endif
136140

137141
#if defined(USART4_BASE)
138142
if (obj_s->uart == UART_4) {
143+
#if defined(LPUART1_BASE)
139144
irq_n = USART3_4_LPUART1_IRQn;
145+
#else
146+
irq_n = USART3_4_IRQn;
147+
#endif
140148
vector = (uint32_t)&uart4_irq;
141149
}
142150
#endif
143151

144152
#if defined(LPUART1_BASE)
145153
if (obj_s->uart == LPUART_1) {
146-
#if defined(STM32G031xx)
147-
irq_n = LPUART1_IRQn;
148-
#else
154+
#if defined(USART3_BASE)
149155
irq_n = USART3_4_LPUART1_IRQn;
156+
#else
157+
irq_n = LPUART1_IRQn;
150158
#endif
151159
vector = (uint32_t)&lpuart1_irq;
152160
}
@@ -326,21 +334,29 @@ static IRQn_Type serial_get_irq_n(UARTName uart_name)
326334
#endif
327335
#if defined(USART3_BASE)
328336
case UART_3:
337+
#if defined(LPUART1_BASE)
329338
irq_n = USART3_4_LPUART1_IRQn;
339+
#else
340+
irq_n = USART3_4_IRQn;
341+
#endif
330342
break;
331343
#endif
332344
#if defined(USART4_BASE)
333345
case UART_4:
346+
#if defined(LPUART1_BASE)
334347
irq_n = USART3_4_LPUART1_IRQn;
348+
#else
349+
irq_n = USART3_4_IRQn;
350+
#endif
335351
break;
336352
#endif
337353

338354
#if defined(LPUART1_BASE)
339355
case LPUART_1:
340-
#if defined(STM32G031xx)
341-
irq_n = LPUART1_IRQn;
342-
#else
356+
#if defined(USART3_BASE)
343357
irq_n = USART3_4_LPUART1_IRQn;
358+
#else
359+
irq_n = LPUART1_IRQn;
344360
#endif
345361
break;
346362
#endif

targets/TARGET_STM/TARGET_STM32G0/us_ticker_data.h

+20-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
* SPDX-License-Identifier: BSD-3-Clause
33
******************************************************************************
44
*
5-
* Copyright (c) 2017 STMicroelectronics.
5+
* Copyright (c) 2017 STMicroelectronics.
66
* All rights reserved.
77
*
88
* 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
9+
* the "License"; You may not use this file except in compliance with the
1010
* License. You may obtain a copy of the License at:
1111
* opensource.org/licenses/BSD-3-Clause
1212
*
@@ -16,13 +16,15 @@
1616
#define __US_TICKER_DATA_H
1717

1818
#ifdef __cplusplus
19-
extern "C" {
19+
extern "C" {
2020
#endif
2121

2222
#include "stm32g0xx.h"
2323
#include "stm32g0xx_ll_tim.h"
2424
#include "cmsis_nvic.h"
25-
25+
26+
#if defined TIM2_BASE
27+
2628
#define TIM_MST TIM2
2729
#define TIM_MST_IRQ TIM2_IRQn
2830
#define TIM_MST_RCC __TIM2_CLK_ENABLE()
@@ -33,12 +35,24 @@
3335

3436
#define TIM_MST_BIT_WIDTH 32 // 16 or 32
3537

36-
#define TIM_MST_PCLK 1 // Select the peripheral clock number (1 or 2)
38+
#else // TIM2_BASE
39+
40+
#define TIM_MST TIM3
41+
#define TIM_MST_IRQ TIM3_IRQn
42+
#define TIM_MST_RCC __TIM3_CLK_ENABLE()
43+
#define TIM_MST_DBGMCU_FREEZE __HAL_DBGMCU_FREEZE_TIM3()
44+
45+
#define TIM_MST_RESET_ON __TIM3_FORCE_RESET()
46+
#define TIM_MST_RESET_OFF __TIM3_RELEASE_RESET()
3747

48+
#define TIM_MST_BIT_WIDTH 16 // 16 or 32
49+
50+
#endif // TIM2_BASE
51+
52+
#define TIM_MST_PCLK 1 // Select the peripheral clock number (1 or 2)
3853

3954
#ifdef __cplusplus
4055
}
4156
#endif
4257

4358
#endif // __US_TICKER_DATA_H
44-

targets/targets.json

+20
Original file line numberDiff line numberDiff line change
@@ -2472,6 +2472,26 @@
24722472
],
24732473
"device_name": "STM32G031K8Tx"
24742474
},
2475+
"MCU_STM32G070xx": {
2476+
"inherits": [
2477+
"MCU_STM32G0"
2478+
],
2479+
"public": false,
2480+
"extra_labels_add": [
2481+
"STM32G070xx"
2482+
],
2483+
"macros_add": [
2484+
"STM32G070xx"
2485+
],
2486+
"macros_remove": [
2487+
"EXTRA_IDLE_STACK_REQUIRED",
2488+
"MBED_TICKLESS"
2489+
],
2490+
"overrides": {
2491+
"lpticker_delay_ticks": 1,
2492+
"lpticker_lptim": "0"
2493+
}
2494+
},
24752495
"MCU_STM32G071xx": {
24762496
"inherits": [
24772497
"MCU_STM32G0"

0 commit comments

Comments
 (0)