EasyManua.ls Logo

Waveshare NRF52840 - Chapter 4. Controling LED; Codes

Waveshare NRF52840
72 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 20 / 72
CHAPTER 4. CONTROLING LED
In this chapter, we will instruct how to configure GPIO and control LED. The
examples used herein is 001_LED.
CODES
Open led.h files, you can find that the GPIO and related control functions are defined
in this header file:
#ifndef __LED_H__
#define __LED_H__
#include "nrf.h"
#include "nrf_gpio.h"
#define LED0 NRF_GPIO_PIN_MAP(0,13)
#define LED1 NRF_GPIO_PIN_MAP(0,14)
#define LED2 NRF_GPIO_PIN_MAP(0,19)
#define LED3 NRF_GPIO_PIN_MAP(0,16)
void LED_On(uint32_t led_number);
void LED_Off(uint32_t led_number);
#endif
Functions defined in header file will be realized in led.c file:
#include "led.h"
void LED_On(uint32_t led_number)
{
nrf_gpio_cfg_output(led_number);
nrf_gpio_pin_clear(led_number);
}
void LED_Off(uint32_t led_number)
{
nrf_gpio_cfg_output(led_number);
nrf_gpio_pin_set(led_number);
}
LED_On(led_number): Turn the LED on
LED_Off(led_number): Turn the LED off