SHARE
TWEET

Untitled

a guest Apr 18th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "sysinit/sysinit.h"
  2. #include "os/os.h"
  3.  
  4. #include <mcu/nrf52_hal.h>
  5. #include "nrf_twim.h"
  6. #include <nrf.h>
  7.  
  8. void NFCT_IRQHandler(void) {
  9.   if (NRF_NFCT->EVENTS_FIELDDETECTED == 1)
  10.   {
  11.     NRF_NFCT->EVENTS_FIELDDETECTED = 0;
  12.     //Field detected
  13.   }    
  14. }
  15.  
  16. int
  17. main(int argc, char **argv)
  18. {
  19.     /* Perform some extra setup if we're running in the simulator. */
  20. #ifdef ARCH_sim
  21.     mcu_sim_parse_args(argc, argv);
  22. #endif
  23.  
  24.     /* Initialize all packages. */
  25.     sysinit();
  26.  
  27.     // Initialise the NFC in sense mode
  28.     NRF_UICR->NFCPINS = 1;
  29.     //Enable interrupt for FIELDDETECT Event
  30.     NRF_NFCT->INTENSET = 1 << 1;    
  31.     //Register interrupt for NFCT module
  32.     NVIC_EnableIRQ(NFCT_IRQn);    
  33.  
  34.     NRF_NFCT->TASKS_SENSE = 1;
  35.  
  36.     /* As the last thing, process events from default event queue. */
  37.     while (1) {
  38.         os_eventq_run(os_eventq_dflt_get());
  39.     }
  40.  
  41.     return 0;
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top