My Demo
Please click “more” on the right!
My assignment:
Change the Delay(10000) to nrf_delay_ms(20)
Part of my source files
key.c
1 | #include "key.h" #include "nrf_delay.h" void KEY_Init(void) { //Configure GPIO pins as in Pullup input nrf_gpio_cfg_input(21,NRF_GPIO_PIN_PULLUP); nrf_gpio_cfg_input(22,NRF_GPIO_PIN_PULLUP); nrf_gpio_cfg_input(23,NRF_GPIO_PIN_PULLUP); nrf_gpio_cfg_input(30,NRF_GPIO_PIN_PULLUP); } void Delay(uint32_t temp) { for(; temp!= 0; temp--) ; } uint8_t KEY_Down(uint8_t KEY_X) { /*Check the Key */ if( nrf_gpio_pin_read(KEY_X)== 0 ) { /*Delay for a while to prevent unexpected read*/ // Delay(10000); nrf_delay_ms(20); if(nrf_gpio_pin_read(KEY_X)== 0 ) { /*Wait for the Key released */ while(nrf_gpio_pin_read(KEY_X)== 0 ); return 0; } else return 1; } else return 1; } |
Download my files
This work is licensed under a Creative Commons Attribution 4.0 International License.