Skip to content

Commit a3d21b7

Browse files
committed
STM32F1: add more alternate functions
1 parent 4cfbea4 commit a3d21b7

File tree

2 files changed

+50
-10
lines changed

2 files changed

+50
-10
lines changed

targets/TARGET_STM/PeripheralPins.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,27 @@
3434
#include "pinmap.h"
3535
#include "PeripheralNames.h"
3636

37+
#if TARGET_STM32F1
38+
#define AFIO_NONE 0
39+
#define AFIO_REMAP_SPI1_ENABLE 1
40+
#define AFIO_REMAP_I2C1_ENABLE 2
41+
#define AFIO_REMAP_USART1_ENABLE 3
42+
#define AFIO_REMAP_USART2_ENABLE 4
43+
#define AFIO_REMAP_USART3_PARTIAL 5
44+
#define AFIO_REMAP_TIM1_PARTIAL 6
45+
#define AFIO_REMAP_TIM3_PARTIAL 7
46+
#define AFIO_REMAP_TIM2_ENABLE 8
47+
#define AFIO_REMAP_TIM3_ENABLE 9
48+
#define AFIO_REMAP_CAN1_2 10
49+
#define AFIO_REMAP_TIM1_ENABLE 11
50+
#define AFIO_REMAP_USART3_ENABLE 12
51+
#define AFIO_REMAP_CAN1_3 13
52+
#define AFIO_REMAP_TIM2_PARTIAL_1 14
53+
#define AFIO_REMAP_TIM2_PARTIAL_2 15
54+
#define AFIO_REMAP_TIM4_ENABLE 16
55+
#endif
56+
57+
3758
//*** GPIO ***
3859
#if GPIO_PINMAP_READY
3960
/* If this macro is defined, then PinMap_GPIO is present in PeripheralPins.c */

targets/TARGET_STM/TARGET_STM32F1/pin_device.h

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "cmsis.h"
3434
#include "stm32f1xx_ll_gpio.h"
35+
#include "PeripheralPins.h"
3536

3637
extern const uint32_t ll_pin_defines[16];
3738

@@ -58,38 +59,56 @@ static inline void stm_pin_SetAFPin(GPIO_TypeDef *gpio, PinName pin, uint32_t af
5859

5960
if (afnum > 0) {
6061
switch (afnum) {
61-
case 1: // Remap SPI1
62+
case AFIO_REMAP_SPI1_ENABLE:
6263
__HAL_AFIO_REMAP_SPI1_ENABLE();
6364
break;
64-
case 2: // Remap I2C1
65+
case AFIO_REMAP_I2C1_ENABLE:
6566
__HAL_AFIO_REMAP_I2C1_ENABLE();
6667
break;
67-
case 3: // Remap USART1
68+
case AFIO_REMAP_USART1_ENABLE:
6869
__HAL_AFIO_REMAP_USART1_ENABLE();
6970
break;
70-
case 4: // Remap USART2
71+
case AFIO_REMAP_USART2_ENABLE:
7172
__HAL_AFIO_REMAP_USART2_ENABLE();
7273
break;
73-
case 5: // Partial Remap USART3
74+
case AFIO_REMAP_USART3_PARTIAL:
7475
__HAL_AFIO_REMAP_USART3_PARTIAL();
7576
break;
76-
case 6: // Partial Remap TIM1
77+
case AFIO_REMAP_TIM1_PARTIAL:
7778
__HAL_AFIO_REMAP_TIM1_PARTIAL();
7879
break;
79-
case 7: // Partial Remap TIM3
80+
case AFIO_REMAP_TIM3_PARTIAL:
8081
__HAL_AFIO_REMAP_TIM3_PARTIAL();
8182
break;
82-
case 8: // Full Remap TIM2
83+
case AFIO_REMAP_TIM2_ENABLE:
8384
__HAL_AFIO_REMAP_TIM2_ENABLE();
8485
break;
85-
case 9: // Full Remap TIM3
86+
case AFIO_REMAP_TIM3_ENABLE:
8687
__HAL_AFIO_REMAP_TIM3_ENABLE();
8788
break;
8889
#if defined(AFIO_MAPR_CAN_REMAP_REMAP1)
89-
case 10: // CAN_RX mapped to PB8, CAN_TX mapped to PB9
90+
case AFIO_REMAP_CAN1_2:
9091
__HAL_AFIO_REMAP_CAN1_2();
9192
break;
9293
#endif
94+
case AFIO_REMAP_TIM1_ENABLE:
95+
__HAL_AFIO_REMAP_TIM1_ENABLE();
96+
break;
97+
case AFIO_REMAP_USART3_ENABLE:
98+
__HAL_AFIO_REMAP_USART3_ENABLE();
99+
break;
100+
case AFIO_REMAP_CAN1_3:
101+
__HAL_AFIO_REMAP_CAN1_3();
102+
break;
103+
case AFIO_REMAP_TIM2_PARTIAL_1:
104+
__HAL_AFIO_REMAP_TIM2_PARTIAL_1();
105+
break;
106+
case AFIO_REMAP_TIM2_PARTIAL_2:
107+
__HAL_AFIO_REMAP_TIM2_PARTIAL_2();
108+
break;
109+
case AFIO_REMAP_TIM4_ENABLE:
110+
__HAL_AFIO_REMAP_TIM4_ENABLE();
111+
break;
93112
default:
94113
break;
95114
}

0 commit comments

Comments
 (0)