The second method is to go to the Nordic
Semiconductor website and open up the nRF
driver portion of the SDK documentation. The
explanation of the code we just used to illuminate
the LEDs can be found under GPIO Abstraction.
I’ve captured the results of right-clicking on the
“nrf_gpio.h” text in Screenshot 4.
The menu that appears allows many options,
including opening the nrf_gpio.h file in the
Keil text editor window. Recall that the human
programmer can also get details of functions
in the same way. In Screenshot 5, I have right-clicked on a function. Note that I can choose to
be directed to the reference of the function or
the initial definition of the function.
Hands-Off I/O
And I do mean hands-off. The nRF52832
gpio.h” text in the Keil source editor. Note the Open document
is capable of manipulating its GPIO subsystem
“nrf_gpio.h” menu item.
without the aid of its ARM CPU. This is done
using the on-chip GPIOTE peripheral. The “TE” is short for
We won’t need the services of the timer handler.
Tasks/Events. The concept is relatively simple.
task and event addresses and PPI channel:
However, some of the timer related functions require the
The output state of an nRF52832 GPIO pin can be
presence of a handler. The timer details are set up within
changed upon the occurrence of a predefined event.
the Configuration Wizard (sdk_config.h). Take a look at
Thus, the GPIO pin performs the “task” depending on
Screenshots 6 and 6b. Within both screenshots, the Timer0
the reception of an event. There are a number of possible
instance was enabled and the primary timer properties
events. Events can emanate from the radio, timers, other
were set up. Our Timer0 will operate with a 1 MHz clock
GPIO input pins, or other peripherals. Our event will
in 32-bit timer mode.
trigger on a timer compare. With that, let’s set up our
The path between the blue LED GPIO pin and the
timer:
Timer0 event is made using another ingenious nRF52832
feature. That “feature” is PPI (Programmable Peripheral
static nrf_drv_timer_t timer = NRF_DRV_TIMER_
Interconnect). To use PPI, we must supply an address for
INSTANCE(0);
the task and an address for the event.
void timer_dummy_handler(nrf_timer_event_t event_
PPI uses the address information to form a link
type, void p_context){}
between the event and task. The event generates a
signal that is routed to the task via the PPI
connection. Here’s the code that defines the
static void initLED()
//task address variable
n SCREENSHOT 5. Right-clicking on the
text nrf_gpio_cfg_output( 9) brings up the
menu you see here. The programmer can
click on Go To Definition Of “nrf_gpio_
cfg_output( 9)” and get the details of the
function.
December 2016 55