|
32 | 32 |
|
33 | 33 | #include "cmsis.h"
|
34 | 34 |
|
35 |
| -// when LL is available, below include can be used |
36 |
| -// #include "stm32f2xx_ll_gpio.h" |
37 |
| -// until then let's define locally the required functions |
38 |
| -#define LL_GPIO_PIN_0 GPIO_BSRR_BS0 /*!< Select pin 0 */ |
39 |
| -#define LL_GPIO_PIN_1 GPIO_BSRR_BS1 /*!< Select pin 1 */ |
40 |
| -#define LL_GPIO_PIN_2 GPIO_BSRR_BS2 /*!< Select pin 2 */ |
41 |
| -#define LL_GPIO_PIN_3 GPIO_BSRR_BS3 /*!< Select pin 3 */ |
42 |
| -#define LL_GPIO_PIN_4 GPIO_BSRR_BS4 /*!< Select pin 4 */ |
43 |
| -#define LL_GPIO_PIN_5 GPIO_BSRR_BS5 /*!< Select pin 5 */ |
44 |
| -#define LL_GPIO_PIN_6 GPIO_BSRR_BS6 /*!< Select pin 6 */ |
45 |
| -#define LL_GPIO_PIN_7 GPIO_BSRR_BS7 /*!< Select pin 7 */ |
46 |
| -#define LL_GPIO_PIN_8 GPIO_BSRR_BS8 /*!< Select pin 8 */ |
47 |
| -#define LL_GPIO_PIN_9 GPIO_BSRR_BS9 /*!< Select pin 9 */ |
48 |
| -#define LL_GPIO_PIN_10 GPIO_BSRR_BS10 /*!< Select pin 10 */ |
49 |
| -#define LL_GPIO_PIN_11 GPIO_BSRR_BS11 /*!< Select pin 11 */ |
50 |
| -#define LL_GPIO_PIN_12 GPIO_BSRR_BS12 /*!< Select pin 12 */ |
51 |
| -#define LL_GPIO_PIN_13 GPIO_BSRR_BS13 /*!< Select pin 13 */ |
52 |
| -#define LL_GPIO_PIN_14 GPIO_BSRR_BS14 /*!< Select pin 14 */ |
53 |
| -#define LL_GPIO_PIN_15 GPIO_BSRR_BS15 /*!< Select pin 15 */ |
54 |
| - |
55 |
| -#define LL_GPIO_MODE_INPUT ((uint32_t)0x00000000U) /*!< Select input mode */ |
56 |
| -#define LL_GPIO_MODE_OUTPUT GPIO_MODER_MODE0_0 /*!< Select output mode */ |
57 |
| -#define LL_GPIO_MODE_ALTERNATE GPIO_MODER_MODE0_1 /*!< Select alternate function mode */ |
58 |
| -#define LL_GPIO_MODE_ANALOG GPIO_MODER_MODE0 /*!< Select analog mode */ |
59 |
| - |
60 |
| -#define LL_GPIO_OUTPUT_PUSHPULL ((uint32_t)0x00000000U) /*!< Select push-pull as output type */ |
61 |
| -#define LL_GPIO_OUTPUT_OPENDRAIN GPIO_OTYPER_OT0 /*!< Select open-drain as output type */ |
62 |
| - |
63 |
| -#define LL_GPIO_PULL_NO ((uint32_t)0x00000000U) /*!< Select I/O no pull */ |
64 |
| -#define LL_GPIO_PULL_UP GPIO_PUPDR_PUPD0_0 /*!< Select I/O pull up */ |
65 |
| -#define LL_GPIO_PULL_DOWN GPIO_PUPDR_PUPD0_1 /*!< Select I/O pull down */ |
66 |
| - |
67 |
| -#define LL_GPIO_SPEED_FREQ_LOW ((uint32_t)0x00000000U) /*!< Select I/O low output speed */ |
68 |
| -#define LL_GPIO_SPEED_FREQ_MEDIUM GPIO_OSPEEDER_OSPEEDR0_0 /*!< Select I/O medium output speed */ |
69 |
| -#define LL_GPIO_SPEED_FREQ_HIGH GPIO_OSPEEDER_OSPEEDR0_1 /*!< Select I/O fast output speed */ |
70 |
| -#define LL_GPIO_SPEED_FREQ_VERY_HIGH GPIO_OSPEEDER_OSPEEDR0 /*!< Select I/O high output speed */ |
71 |
| - |
72 |
| -__STATIC_INLINE void LL_GPIO_SetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate) |
73 |
| -{ |
74 |
| - MODIFY_REG(GPIOx->AFR[0], (GPIO_AFRL_AFSEL0 << (POSITION_VAL(Pin) * 4U)), |
75 |
| - (Alternate << (POSITION_VAL(Pin) * 4U))); |
76 |
| -} |
77 |
| - |
78 |
| -__STATIC_INLINE void LL_GPIO_SetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate) |
79 |
| -{ |
80 |
| - MODIFY_REG(GPIOx->AFR[1], (GPIO_AFRH_AFSEL8 << (POSITION_VAL(Pin >> 8U) * 4U)), |
81 |
| - (Alternate << (POSITION_VAL(Pin >> 8U) * 4U))); |
82 |
| -} |
83 |
| -__STATIC_INLINE void LL_GPIO_SetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Mode) |
84 |
| -{ |
85 |
| - MODIFY_REG(GPIOx->MODER, (GPIO_MODER_MODE0 << (POSITION_VAL(Pin) * 2U)), (Mode << (POSITION_VAL(Pin) * 2U))); |
86 |
| -} |
87 |
| -__STATIC_INLINE uint32_t LL_GPIO_GetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin) |
88 |
| -{ |
89 |
| - return (uint32_t)(READ_BIT(GPIOx->MODER, ((Pin * Pin) * GPIO_MODER_MODER0)) / (Pin * Pin)); |
90 |
| -} |
91 |
| -__STATIC_INLINE void LL_GPIO_SetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Pull) |
92 |
| -{ |
93 |
| - MODIFY_REG(GPIOx->PUPDR, (GPIO_PUPDR_PUPD0 << (POSITION_VAL(Pin) * 2U)), (Pull << (POSITION_VAL(Pin) * 2U))); |
94 |
| -} |
95 |
| -__STATIC_INLINE void LL_GPIO_SetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t PinMask, uint32_t OutputType) |
96 |
| -{ |
97 |
| - MODIFY_REG(GPIOx->OTYPER, PinMask, (PinMask * OutputType)); |
98 |
| -} |
99 |
| -__STATIC_INLINE void LL_GPIO_SetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Speed) |
100 |
| -{ |
101 |
| - MODIFY_REG(GPIOx->OSPEEDR, (GPIO_OSPEEDER_OSPEEDR0 << (POSITION_VAL(Pin) * 2U)), |
102 |
| - (Speed << (POSITION_VAL(Pin) * 2U))); |
103 |
| -} |
104 |
| -// Above lines shall be defined in LL when available |
| 35 | +#include "stm32f2xx_ll_gpio.h" |
105 | 36 |
|
106 | 37 | extern const uint32_t ll_pin_defines[16];
|
107 | 38 |
|
|
0 commit comments