nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
dk_buttons_and_leds.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef DK_BUTTON_AND_LEDS_H__
8#define DK_BUTTON_AND_LEDS_H__
9
16#include <zephyr/types.h>
17#include <zephyr/sys/slist.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#define DK_NO_LEDS_MSK (0)
24#define DK_LED1 0
25#define DK_LED2 1
26#define DK_LED3 2
27#define DK_LED4 3
28#define DK_LED1_MSK BIT(DK_LED1)
29#define DK_LED2_MSK BIT(DK_LED2)
30#define DK_LED3_MSK BIT(DK_LED3)
31#define DK_LED4_MSK BIT(DK_LED4)
32#define DK_ALL_LEDS_MSK (DK_LED1_MSK | DK_LED2_MSK |\
33 DK_LED3_MSK | DK_LED4_MSK)
34
35#define DK_NO_BTNS_MSK (0)
36#define DK_BTN1 0
37#define DK_BTN2 1
38#define DK_BTN3 2
39#define DK_BTN4 3
40#define DK_BTN1_MSK BIT(DK_BTN1)
41#define DK_BTN2_MSK BIT(DK_BTN2)
42#define DK_BTN3_MSK BIT(DK_BTN3)
43#define DK_BTN4_MSK BIT(DK_BTN4)
44#define DK_ALL_BTNS_MSK (DK_BTN1_MSK | DK_BTN2_MSK | \
45 DK_BTN3_MSK | DK_BTN4_MSK)
53typedef void (*button_handler_t)(uint32_t button_state, uint32_t has_changed);
54
58 sys_snode_t node;
59};
60
66int dk_leds_init(void);
67
76
87
96
102void dk_read_buttons(uint32_t *button_state, uint32_t *has_changed);
103
108uint32_t dk_get_buttons(void);
109
117int dk_set_leds(uint32_t leds);
118
119
133int dk_set_leds_state(uint32_t leds_on_mask, uint32_t leds_off_mask);
134
147int dk_set_led(uint8_t led_idx, uint32_t val);
148
156int dk_set_led_on(uint8_t led_idx);
157
165int dk_set_led_off(uint8_t led_idx);
166
167#ifdef __cplusplus
168}
169#endif
170
173#endif /* DK_BUTTON_AND_LEDS_H__ */
int dk_button_handler_remove(struct button_handler *handler)
Remove a dynamic button handler callback.
int dk_set_leds_state(uint32_t leds_on_mask, uint32_t leds_off_mask)
Set value of LED pins as specified in two bitmasks.
void dk_read_buttons(uint32_t *button_state, uint32_t *has_changed)
Read current button states.
uint32_t dk_get_buttons(void)
Get current button state from internal variable.
int dk_buttons_init(button_handler_t button_handler)
Initialize the library to read the button state.
void dk_button_handler_add(struct button_handler *handler)
Add a dynamic button handler callback.
int dk_set_led_on(uint8_t led_idx)
Turn a single LED on.
int dk_set_led_off(uint8_t led_idx)
Turn a single LED off.
int dk_leds_init(void)
Initialize the library to control the LEDs.
int dk_set_leds(uint32_t leds)
Set value of LED pins as specified in one bitmask.
int dk_set_led(uint8_t led_idx, uint32_t val)
Set a single LED value.
void(* button_handler_t)(uint32_t button_state, uint32_t has_changed)
Callback that is executed when a button state change is detected.
Definition: dk_buttons_and_leds.h:53
sys_snode_t node
Definition: dk_buttons_and_leds.h:58
button_handler_t cb
Definition: dk_buttons_and_leds.h:57
Definition: dk_buttons_and_leds.h:56