I am Developing a Custom HAL Driver For STM32F446xx and STM32F407xx MCU.It Currently Supports
- GPIO
- Interrupts
And Support for the following are yet to come
- USART
- SPI
- I2C
GPIO_PinOutput(pGPIOx, PinNumber, PinSpeed, PinOPType, PinPUPDC)
-
pGPIOx- Gpio Port of the Pin you want to Initialize (Parameters:GPIOA,GPIOB,....,GPIOH)
-
PinNumber - Pin Number of the GPIO Port (Parameters:0,1,2,....,15)
-
PinSpeed - Pin Speed of the GPIO Pin (Parameters:LOW,MEDIUM,FAST,FULL)
-
PinOPType - Pin Output like Push-Pull and Open-Drain(Parameters:OD,PP)
-
PinPUPDC - Used For Activating Internal PushDown-PullUp resistor(Parameters:NO_PUPD,PUSHDOWN,PULLUP)
GPIO_PinOutput(GPIOA, 5, HIGH, PP, NO_PUPD);
GPIO_PinInput(pGPIOx, PinNumber, PinSpeed, PinPUPDC)
-
pGPIOx- Gpio Port of the Pin you want to Initialize (Parameters:GPIOA,GPIOB,....,GPIOH)
-
PinNumber - Pin Number of the GPIO Pin (Parameters:0,1,2,....,15)
-
PinSpeed - Pin Speed of the GPIO Pin (Parameters:LOW,MEDIUM,FAST,FULL)
-
PinPUPDC - Used For Activating Internal PushDown-PullUp resistor(Parameters:NO_PUPD,PUSHDOWN,PULLUP)
GPIO_PinInput(GPIOC, 13, HIGH, NO_PUPD);
GPIO_PinSetup(pGPIOx, PinNumber, PinMode, PinSpeed, PinOPType, PinPUPDC)
-
pGPIOx- Gpio Port of the pin you want to Initialize (Parameters:GPIOA,GPIOB,....,GPIOH)
-
PinNumber - Pin Number of the GPIO Pin (Parameters:0,1,2,....,15)
-
PinMode - The Mode of the GPIO Pin (Parameters:INPUT,OUTPUT,ANALOG,ALTFN,IT_FT,IT_RT_IT_RFT) NOTE : The IT_FT,IT_RT_IT_RFT Modes uses Interrupt Mode Of the MCU,Please Refer to the Interupt Documentation
-
PinSpeed - Pin Speed of the GPIO Pin (Parameters:LOW,MEDIUM,FAST,FULL)
-
PinOPType - Sets the GPIO Pin as Open-Drain , Push-Pull (Parameters:OD,PP,NONE)
-
PinPUPDC - Used For Activating Internal PushDown-PullUp resistor(Parameters:NO_PUPD,PUSHDOWN,PULLUP)
NOTE : SET THE PinOPType AS NONE WHEN SETTING THE PIN AS INPUT
GPIO_PinSetup(GPIOB, 14, ANALOG, HIGH, 0,NO_PUPD);
GPIO_WriteToOutputPin(pGPIOx, PinNumber, Value)
-
pGPIOx- Gpio Port of the Pin you want to write to (Parameters:GPIOA,GPIOB,....,GPIOH)
-
PinNumber - Pin Number of the GPIO Pin (Parameters:0,1,2,....,15)
-
Value - Value to Write to the GPIO Pin (Parameters:HIGH,LOW)
GPIO_WriteToOutputPin(GPIOA, 5, 0);
GPIO_WriteToOutputPin(pGPIOx, Value)
-
pGPIOx- Gpio Port you want to write to (Parameters:GPIOA,GPIOB,....,GPIOH)
-
Value - Value to Write to the GPIO Pin (Parameters:HIGH,LOW)
GPIO_WriteToOutputPort(GPIOA, 0);
GPIO_ToggleOutputPin(pGPIOx, PinNumber)
-
pGPIOx- Gpio Port of the pin the you want to toggle(Parameters:GPIOA,GPIOB,....,GPIOH)
-
PinNumber - Pin Number of the GPIO Pin (Parameters:0,1,2,....,15)
GPIO_ToggleOutputPin(GPIOA, 5);
GPIO_ToggleOutputPort(pGPIOx)
- pGPIOx- Gpio Port you want to toggle(Parameters:GPIOA,GPIOB,....,GPIOH)
GPIO_ToggleOutputPin(GPIOA);
GPIO_ReadFromInputPin(pGPIOx, PinNumber)
-
pGPIOx- Gpio Port of the pin you want read(Parameters:GPIOA,GPIOB,....,GPIOH)
-
PinNumber - Pin Number of the GPIO Pin (Parameters:0,1,2,....,15)
GPIO_ReadFromInputPin(GPIOC, 13);
GPIO_ReadFromInputPort(pGPIOx)
- pGPIOx- Gpio Port From which you want to read (Parameters:GPIOA,GPIOB,....,GPIOH)
GPIO_ReadFromInputPort(GPIOC);
NOTE:THE GPIO PIN SHOULD BE INITIALISED AS INTERRUPT MODE,PLEASE REFER "For initializing GPIO Pin as OTHER -"
GPIO_IRQInterruptConfig(IRQNumber, EnorDi)
1.IRQNumber-
It is define IRQ Number of the Corresponding GPIO Pin's EXTI Engine
(Parameter:IRQ_NO_EXTI0,...,IRQ_NO_EXTI4,IRQ_NO_EXTI5_9,IRQ_NO_EXTI15_10)
Note: The x in IRQ_NO_EXTIx matches the corresponding GPIO Pin you want to set it up
2.EnorDi - It is used the enable or disable the corresponding EXTI Engine (Parameters: ENABLE,DISABLE)
Setting up the Interrupt for GPIO Pin 13
GPIO_IRQInterruptConfig(IRQ_NO_EXTI15_10, ENABLE);
GPIO_IRQPriorityConfig(IRQNumber, IRQPriority)
1.IRQNumber-
It is define IRQ Number of the Corresponding GPIO Pin's EXTI Engine
(Parameter:IRQ_NO_EXTI0,...,IRQ_NO_EXTI4,IRQ_NO_EXTI5_9,IRQ_NO_EXTI15_10)
Note: The x in IRQ_NO_EXTIx matches the corresponding GPIO Pin you want to set it up
2.IRQPriority - It is used set the the Interrupt Priority Number of the Interrupt (Parameters: 15,.....,1)
Setting up the Interrupt Priority for GPIO Pin 13
GPIO_IRQPriorityConfig(IRQ_NO_EXTI15_10, 15);