from: https://eroro.tistory.com/600
PF0, PF1을 사용하기 위해 RCC_DeInit함수 사용
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
/* For PF0, PF1 */ RCC_DeInit(); GPIO_InitTypeDef GPIO_InitStruct; // AFIO_REMAP_ENABLE(AFIO_MAPR_PD01_REMAP); /* Enable GPIOF clock */ RCC_AHBPeriphClockCmd(PERI_BUTTON, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); GPIO_InitStruct.GPIO_Pin = PIN_BUTTON_0 | PIN_BUTTON_1; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;//GPIO_PuPd_UP; //GPIO_Mode_IPU; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz; GPIO_Init(PORT_BUTTON, &GPIO_InitStruct); while(1){ if (GPIO_ReadInputDataBit(PORT_BUTTON, PIN_BUTTON_0) != SET) {/* Forward */ DEBUGPRINT("BTN0\r\n"); } if (GPIO_ReadInputDataBit(PORT_BUTTON, PIN_BUTTON_1) != SET) {/* Forward */ DEBUGPRINT("BTN1\r\n"); } GPIO_ToggleBit(PORT_LED, PIN_LED_0); GPIO_ToggleBit(PORT_LED, PIN_LED_1); Delay(100); } |