/* Includes ------------------------------------------------------------------*/ #include "stm32f4xx.h" /* Private typedef -----------------------------------------------------------*/ GPIO_InitTypeDef GPIO_InitStructure; int main(void) { /* GPIOB Periph clock enable */ RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOB ,ENABLE); GPIO_InitStructure.GPIO_Pin=GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode= GPIO_Mode_IN ; GPIO_InitStructure.GPIO_Speed= GPIO_Speed_40KHz ; GPIO_InitStructure.GPIO_OType= GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd= GPIO_PuPd_UP ; /* Initialisation de la strcture au GPIOB */ GPIO_Init( GPIOB, &GPIO_InitStructure); RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOD,ENABLE); GPIO_InitStructure.GPIO_Pin=GPIO_Pin_2|GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode= GPIO_Mode_OUT ; GPIO_InitStructure.GPIO_Speed= GPIO_Speed_2MHz ; GPIO_InitStructure.GPIO_OType= GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd= GPIO_PuPd_UP ; /* Initialisation de la strcture au GPIOD */ GPIO_Init( GPIOD, &GPIO_InitStructure); while (1) { GPIO_WriteBit( GPIOD, GPIO_Pin_2, Bit_SET); delayTime(10);// If( GPIO_ReadInputDataBit( GPIOB, GPIO_Pin_3)==0) { GPIO_WriteBit( GPIOD, GPIO_Pin_3, Bit_SET); } } }