Created
October 6, 2019 08:42
-
-
Save igotit-anything/78eb1e845b7f709f8125addbbb118a13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "nrf52840.h" | |
#include "nrf52840_bitfields.h" | |
#include "nrf_delay.h" // added 2019-10-05 . step by step 1. for time delay | |
#include "nrf_drv_gpiote.h" // added 2019-10-06. step by step 2. for GPIOTE | |
void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action) | |
{ | |
nrf_drv_gpiote_out_toggle(13); | |
} | |
void init_gpiote(void) | |
{ | |
nrf_drv_gpiote_init(); | |
nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false); | |
nrf_drv_gpiote_out_init(13, &out_config); | |
nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true); | |
in_config.pull = NRF_GPIO_PIN_PULLUP; | |
nrf_drv_gpiote_in_init(11, &in_config, in_pin_handler); | |
nrf_drv_gpiote_in_event_enable(11, true); | |
} | |
int main() | |
{ | |
init_gpiote(); | |
while(1) | |
{ | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://igotit.tistory.com/2326