#include "stm32f2xx.h"
void GPIO_Config_InputMode(void);
int main(void)
{
GPIO_Config_InputMode(); // to be used as an EXTI line
GPIO_ReadInputDataBit(GPIOG, GPIO_Pin_6);
}
void GPIO_Config_InputMode(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable GPIOG's AHB interface clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE);
/* Configure PG6 in input mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOG, &GPIO_InitStructure);
}
/*
<Input mode>
1. Enable GPIOG's AHB interface clock
@reg RCC->AHB1ENR
@fn void RCC_AHB1PeriphClockCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState)
@param RCC_AHB1Periph_GPIOG, ENABLE
@ref stm32f2xx_rcc.h, stm32f2xx.h
2. Configure PG6 in input mode
@reg GPIOx->MODER, GPIOx->PUPDR
@fn void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
@param GPIOG, GPIO_Pin_6, GPIO_Mode_IN, GPIO_PuPd_NOPULL
@ref stm32f2xx.h, stm32f2xx_gpio.h
3. Read PG6 bit
@reg GPIOx->IDR
@fn uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
@param GPIOG, GPIO_Pin_6
@ref stm32fxx, stm32f2xx_gpio.h
*/
void GPIO_Config_InputMode(void);
int main(void)
{
GPIO_Config_InputMode(); // to be used as an EXTI line
GPIO_ReadInputDataBit(GPIOG, GPIO_Pin_6);
}
void GPIO_Config_InputMode(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable GPIOG's AHB interface clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE);
/* Configure PG6 in input mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOG, &GPIO_InitStructure);
}
/*
<Input mode>
1. Enable GPIOG's AHB interface clock
@reg RCC->AHB1ENR
@fn void RCC_AHB1PeriphClockCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState)
@param RCC_AHB1Periph_GPIOG, ENABLE
@ref stm32f2xx_rcc.h, stm32f2xx.h
2. Configure PG6 in input mode
@reg GPIOx->MODER, GPIOx->PUPDR
@fn void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
@param GPIOG, GPIO_Pin_6, GPIO_Mode_IN, GPIO_PuPd_NOPULL
@ref stm32f2xx.h, stm32f2xx_gpio.h
3. Read PG6 bit
@reg GPIOx->IDR
@fn uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
@param GPIOG, GPIO_Pin_6
@ref stm32fxx, stm32f2xx_gpio.h
*/
No comments:
Post a Comment