123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- #ifndef __STM32F10x_GPIO_H
- #define __STM32F10x_GPIO_H
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include "stm32f10x.h"
- #define IS_GPIO_ALL_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \
- ((PERIPH) == GPIOB) || \
- ((PERIPH) == GPIOC) || \
- ((PERIPH) == GPIOD) || \
- ((PERIPH) == GPIOE) || \
- ((PERIPH) == GPIOF) || \
- ((PERIPH) == GPIOG))
-
- typedef enum
- {
- GPIO_Speed_10MHz = 1,
- GPIO_Speed_2MHz,
- GPIO_Speed_50MHz
- }GPIOSpeed_TypeDef;
- #define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_Speed_10MHz) || ((SPEED) == GPIO_Speed_2MHz) || \
- ((SPEED) == GPIO_Speed_50MHz))
- typedef enum
- { GPIO_Mode_AIN = 0x0,
- GPIO_Mode_IN_FLOATING = 0x04,
- GPIO_Mode_IPD = 0x28,
- GPIO_Mode_IPU = 0x48,
- GPIO_Mode_Out_OD = 0x14,
- GPIO_Mode_Out_PP = 0x10,
- GPIO_Mode_AF_OD = 0x1C,
- GPIO_Mode_AF_PP = 0x18
- }GPIOMode_TypeDef;
- #define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_AIN) || ((MODE) == GPIO_Mode_IN_FLOATING) || \
- ((MODE) == GPIO_Mode_IPD) || ((MODE) == GPIO_Mode_IPU) || \
- ((MODE) == GPIO_Mode_Out_OD) || ((MODE) == GPIO_Mode_Out_PP) || \
- ((MODE) == GPIO_Mode_AF_OD) || ((MODE) == GPIO_Mode_AF_PP))
- typedef struct
- {
- uint16_t GPIO_Pin;
- GPIOSpeed_TypeDef GPIO_Speed;
- GPIOMode_TypeDef GPIO_Mode;
- }GPIO_InitTypeDef;
- typedef enum
- { Bit_RESET = 0,
- Bit_SET
- }BitAction;
- #define IS_GPIO_BIT_ACTION(ACTION) (((ACTION) == Bit_RESET) || ((ACTION) == Bit_SET))
- #define GPIO_Pin_0 ((uint16_t)0x0001)
- #define GPIO_Pin_1 ((uint16_t)0x0002)
- #define GPIO_Pin_2 ((uint16_t)0x0004)
- #define GPIO_Pin_3 ((uint16_t)0x0008)
- #define GPIO_Pin_4 ((uint16_t)0x0010)
- #define GPIO_Pin_5 ((uint16_t)0x0020)
- #define GPIO_Pin_6 ((uint16_t)0x0040)
- #define GPIO_Pin_7 ((uint16_t)0x0080)
- #define GPIO_Pin_8 ((uint16_t)0x0100)
- #define GPIO_Pin_9 ((uint16_t)0x0200)
- #define GPIO_Pin_10 ((uint16_t)0x0400)
- #define GPIO_Pin_11 ((uint16_t)0x0800)
- #define GPIO_Pin_12 ((uint16_t)0x1000)
- #define GPIO_Pin_13 ((uint16_t)0x2000)
- #define GPIO_Pin_14 ((uint16_t)0x4000)
- #define GPIO_Pin_15 ((uint16_t)0x8000)
- #define GPIO_Pin_All ((uint16_t)0xFFFF)
- #define IS_GPIO_PIN(PIN) ((((PIN) & (uint16_t)0x00) == 0x00) && ((PIN) != (uint16_t)0x00))
- #define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || \
- ((PIN) == GPIO_Pin_1) || \
- ((PIN) == GPIO_Pin_2) || \
- ((PIN) == GPIO_Pin_3) || \
- ((PIN) == GPIO_Pin_4) || \
- ((PIN) == GPIO_Pin_5) || \
- ((PIN) == GPIO_Pin_6) || \
- ((PIN) == GPIO_Pin_7) || \
- ((PIN) == GPIO_Pin_8) || \
- ((PIN) == GPIO_Pin_9) || \
- ((PIN) == GPIO_Pin_10) || \
- ((PIN) == GPIO_Pin_11) || \
- ((PIN) == GPIO_Pin_12) || \
- ((PIN) == GPIO_Pin_13) || \
- ((PIN) == GPIO_Pin_14) || \
- ((PIN) == GPIO_Pin_15))
- #define GPIO_Remap_SPI1 ((uint32_t)0x00000001)
- #define GPIO_Remap_I2C1 ((uint32_t)0x00000002)
- #define GPIO_Remap_USART1 ((uint32_t)0x00000004)
- #define GPIO_Remap_USART2 ((uint32_t)0x00000008)
- #define GPIO_PartialRemap_USART3 ((uint32_t)0x00140010)
- #define GPIO_FullRemap_USART3 ((uint32_t)0x00140030)
- #define GPIO_PartialRemap_TIM1 ((uint32_t)0x00160040)
- #define GPIO_FullRemap_TIM1 ((uint32_t)0x001600C0)
- #define GPIO_PartialRemap1_TIM2 ((uint32_t)0x00180100)
- #define GPIO_PartialRemap2_TIM2 ((uint32_t)0x00180200)
- #define GPIO_FullRemap_TIM2 ((uint32_t)0x00180300)
- #define GPIO_PartialRemap_TIM3 ((uint32_t)0x001A0800)
- #define GPIO_FullRemap_TIM3 ((uint32_t)0x001A0C00)
- #define GPIO_Remap_TIM4 ((uint32_t)0x00001000)
- #define GPIO_Remap1_CAN1 ((uint32_t)0x001D4000)
- #define GPIO_Remap2_CAN1 ((uint32_t)0x001D6000)
- #define GPIO_Remap_PD01 ((uint32_t)0x00008000)
- #define GPIO_Remap_TIM5CH4_LSI ((uint32_t)0x00200001)
- #define GPIO_Remap_ADC1_ETRGINJ ((uint32_t)0x00200002)
- #define GPIO_Remap_ADC1_ETRGREG ((uint32_t)0x00200004)
- #define GPIO_Remap_ADC2_ETRGINJ ((uint32_t)0x00200008)
- #define GPIO_Remap_ADC2_ETRGREG ((uint32_t)0x00200010)
- #define GPIO_Remap_ETH ((uint32_t)0x00200020)
- #define GPIO_Remap_CAN2 ((uint32_t)0x00200040)
- #define GPIO_Remap_SWJ_NoJTRST ((uint32_t)0x00300100)
- #define GPIO_Remap_SWJ_JTAGDisable ((uint32_t)0x00300200)
- #define GPIO_Remap_SWJ_Disable ((uint32_t)0x00300400)
- #define GPIO_Remap_SPI3 ((uint32_t)0x00201100)
- #define GPIO_Remap_TIM2ITR1_PTP_SOF ((uint32_t)0x00202000)
- #define GPIO_Remap_PTP_PPS ((uint32_t)0x00204000)
- #define GPIO_Remap_TIM15 ((uint32_t)0x80000001)
- #define GPIO_Remap_TIM16 ((uint32_t)0x80000002)
- #define GPIO_Remap_TIM17 ((uint32_t)0x80000004)
- #define GPIO_Remap_CEC ((uint32_t)0x80000008)
- #define GPIO_Remap_TIM1_DMA ((uint32_t)0x80000010)
- #define GPIO_Remap_TIM9 ((uint32_t)0x80000020)
- #define GPIO_Remap_TIM10 ((uint32_t)0x80000040)
- #define GPIO_Remap_TIM11 ((uint32_t)0x80000080)
- #define GPIO_Remap_TIM13 ((uint32_t)0x80000100)
- #define GPIO_Remap_TIM14 ((uint32_t)0x80000200)
- #define GPIO_Remap_FSMC_NADV ((uint32_t)0x80000400)
- #define GPIO_Remap_TIM67_DAC_DMA ((uint32_t)0x80000800)
- #define GPIO_Remap_TIM12 ((uint32_t)0x80001000)
- #define GPIO_Remap_MISC ((uint32_t)0x80002000)
-
- #define IS_GPIO_REMAP(REMAP) (((REMAP) == GPIO_Remap_SPI1) || ((REMAP) == GPIO_Remap_I2C1) || \
- ((REMAP) == GPIO_Remap_USART1) || ((REMAP) == GPIO_Remap_USART2) || \
- ((REMAP) == GPIO_PartialRemap_USART3) || ((REMAP) == GPIO_FullRemap_USART3) || \
- ((REMAP) == GPIO_PartialRemap_TIM1) || ((REMAP) == GPIO_FullRemap_TIM1) || \
- ((REMAP) == GPIO_PartialRemap1_TIM2) || ((REMAP) == GPIO_PartialRemap2_TIM2) || \
- ((REMAP) == GPIO_FullRemap_TIM2) || ((REMAP) == GPIO_PartialRemap_TIM3) || \
- ((REMAP) == GPIO_FullRemap_TIM3) || ((REMAP) == GPIO_Remap_TIM4) || \
- ((REMAP) == GPIO_Remap1_CAN1) || ((REMAP) == GPIO_Remap2_CAN1) || \
- ((REMAP) == GPIO_Remap_PD01) || ((REMAP) == GPIO_Remap_TIM5CH4_LSI) || \
- ((REMAP) == GPIO_Remap_ADC1_ETRGINJ) ||((REMAP) == GPIO_Remap_ADC1_ETRGREG) || \
- ((REMAP) == GPIO_Remap_ADC2_ETRGINJ) ||((REMAP) == GPIO_Remap_ADC2_ETRGREG) || \
- ((REMAP) == GPIO_Remap_ETH) ||((REMAP) == GPIO_Remap_CAN2) || \
- ((REMAP) == GPIO_Remap_SWJ_NoJTRST) || ((REMAP) == GPIO_Remap_SWJ_JTAGDisable) || \
- ((REMAP) == GPIO_Remap_SWJ_Disable)|| ((REMAP) == GPIO_Remap_SPI3) || \
- ((REMAP) == GPIO_Remap_TIM2ITR1_PTP_SOF) || ((REMAP) == GPIO_Remap_PTP_PPS) || \
- ((REMAP) == GPIO_Remap_TIM15) || ((REMAP) == GPIO_Remap_TIM16) || \
- ((REMAP) == GPIO_Remap_TIM17) || ((REMAP) == GPIO_Remap_CEC) || \
- ((REMAP) == GPIO_Remap_TIM1_DMA) || ((REMAP) == GPIO_Remap_TIM9) || \
- ((REMAP) == GPIO_Remap_TIM10) || ((REMAP) == GPIO_Remap_TIM11) || \
- ((REMAP) == GPIO_Remap_TIM13) || ((REMAP) == GPIO_Remap_TIM14) || \
- ((REMAP) == GPIO_Remap_FSMC_NADV) || ((REMAP) == GPIO_Remap_TIM67_DAC_DMA) || \
- ((REMAP) == GPIO_Remap_TIM12) || ((REMAP) == GPIO_Remap_MISC))
-
-
- #define GPIO_PortSourceGPIOA ((uint8_t)0x00)
- #define GPIO_PortSourceGPIOB ((uint8_t)0x01)
- #define GPIO_PortSourceGPIOC ((uint8_t)0x02)
- #define GPIO_PortSourceGPIOD ((uint8_t)0x03)
- #define GPIO_PortSourceGPIOE ((uint8_t)0x04)
- #define GPIO_PortSourceGPIOF ((uint8_t)0x05)
- #define GPIO_PortSourceGPIOG ((uint8_t)0x06)
- #define IS_GPIO_EVENTOUT_PORT_SOURCE(PORTSOURCE) (((PORTSOURCE) == GPIO_PortSourceGPIOA) || \
- ((PORTSOURCE) == GPIO_PortSourceGPIOB) || \
- ((PORTSOURCE) == GPIO_PortSourceGPIOC) || \
- ((PORTSOURCE) == GPIO_PortSourceGPIOD) || \
- ((PORTSOURCE) == GPIO_PortSourceGPIOE))
- #define IS_GPIO_EXTI_PORT_SOURCE(PORTSOURCE) (((PORTSOURCE) == GPIO_PortSourceGPIOA) || \
- ((PORTSOURCE) == GPIO_PortSourceGPIOB) || \
- ((PORTSOURCE) == GPIO_PortSourceGPIOC) || \
- ((PORTSOURCE) == GPIO_PortSourceGPIOD) || \
- ((PORTSOURCE) == GPIO_PortSourceGPIOE) || \
- ((PORTSOURCE) == GPIO_PortSourceGPIOF) || \
- ((PORTSOURCE) == GPIO_PortSourceGPIOG))
- #define GPIO_PinSource0 ((uint8_t)0x00)
- #define GPIO_PinSource1 ((uint8_t)0x01)
- #define GPIO_PinSource2 ((uint8_t)0x02)
- #define GPIO_PinSource3 ((uint8_t)0x03)
- #define GPIO_PinSource4 ((uint8_t)0x04)
- #define GPIO_PinSource5 ((uint8_t)0x05)
- #define GPIO_PinSource6 ((uint8_t)0x06)
- #define GPIO_PinSource7 ((uint8_t)0x07)
- #define GPIO_PinSource8 ((uint8_t)0x08)
- #define GPIO_PinSource9 ((uint8_t)0x09)
- #define GPIO_PinSource10 ((uint8_t)0x0A)
- #define GPIO_PinSource11 ((uint8_t)0x0B)
- #define GPIO_PinSource12 ((uint8_t)0x0C)
- #define GPIO_PinSource13 ((uint8_t)0x0D)
- #define GPIO_PinSource14 ((uint8_t)0x0E)
- #define GPIO_PinSource15 ((uint8_t)0x0F)
- #define IS_GPIO_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == GPIO_PinSource0) || \
- ((PINSOURCE) == GPIO_PinSource1) || \
- ((PINSOURCE) == GPIO_PinSource2) || \
- ((PINSOURCE) == GPIO_PinSource3) || \
- ((PINSOURCE) == GPIO_PinSource4) || \
- ((PINSOURCE) == GPIO_PinSource5) || \
- ((PINSOURCE) == GPIO_PinSource6) || \
- ((PINSOURCE) == GPIO_PinSource7) || \
- ((PINSOURCE) == GPIO_PinSource8) || \
- ((PINSOURCE) == GPIO_PinSource9) || \
- ((PINSOURCE) == GPIO_PinSource10) || \
- ((PINSOURCE) == GPIO_PinSource11) || \
- ((PINSOURCE) == GPIO_PinSource12) || \
- ((PINSOURCE) == GPIO_PinSource13) || \
- ((PINSOURCE) == GPIO_PinSource14) || \
- ((PINSOURCE) == GPIO_PinSource15))
-
- #define GPIO_ETH_MediaInterface_MII ((u32)0x00000000)
- #define GPIO_ETH_MediaInterface_RMII ((u32)0x00000001)
- #define IS_GPIO_ETH_MEDIA_INTERFACE(INTERFACE) (((INTERFACE) == GPIO_ETH_MediaInterface_MII) || \
- ((INTERFACE) == GPIO_ETH_MediaInterface_RMII))
-
- void GPIO_DeInit(GPIO_TypeDef* GPIOx);
- void GPIO_AFIODeInit(void);
- void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);
- void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct);
- uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
- uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
- uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
- uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
- void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
- void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
- void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal);
- void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);
- void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
- void GPIO_EventOutputConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource);
- void GPIO_EventOutputCmd(FunctionalState NewState);
- void GPIO_PinRemapConfig(uint32_t GPIO_Remap, FunctionalState NewState);
- void GPIO_EXTILineConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource);
- void GPIO_ETH_MediaInterfaceConfig(uint32_t GPIO_ETH_MediaInterface);
- #ifdef __cplusplus
- }
- #endif
- #endif
|