Skip to content

Instantly share code, notes, and snippets.

@igotit-anything
Created October 6, 2019 08:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igotit-anything/78eb1e845b7f709f8125addbbb118a13 to your computer and use it in GitHub Desktop.
Save igotit-anything/78eb1e845b7f709f8125addbbb118a13 to your computer and use it in GitHub Desktop.
#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)
{
}
}
@igotit-anything
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment