HomeCore 0.1.3 (07b5544)
Bare-metal personal computer firmware for Cortex-M
Loading...
Searching...
No Matches
led.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: MIT */
6#ifndef HOMECORE_DRIVERS_LED_H
7#define HOMECORE_DRIVERS_LED_H
8
9#include "homecore/vfs/vfs.h"
10#include <stdbool.h>
11
55unsigned led_count(void);
56
67int led_set(unsigned index, bool on);
68
79int led_get(unsigned index, bool *on);
80
89int led_toggle(unsigned index);
96typedef struct {
98 int (*set)(void *device, bool on);
100 int (*get)(void *device, bool *on);
101} led_ops_t;
102
104typedef struct {
108 void *device;
109} led_t;
110
112typedef struct {
114 const led_t *leds;
116 unsigned count;
118
120extern const led_table_t dt_led_table;
121
133void led_register_node(vfs_node_t *node, const char *path, const led_t *led);
138#endif /* HOMECORE_DRIVERS_LED_H */
void led_register_node(vfs_node_t *node, const char *path, const led_t *led)
Register the device file of an LED.
const led_table_t dt_led_table
The board's LEDs; generated in devicetree.c.
unsigned led_count(void)
Report how many LEDs the board describes.
int led_toggle(unsigned index)
Invert an LED.
int led_get(unsigned index, bool *on)
Read whether an LED is lit.
int led_set(unsigned index, bool on)
Turn an LED on or off.
Operations an LED driver provides; every one is required.
Definition led.h:96
An LED: driver operations bound to one device instance.
Definition led.h:104
const led_ops_t * ops
Operations of the LED's driver.
Definition led.h:106
void * device
Driver instance passed to every operation.
Definition led.h:108
Every LED in index order; generated in devicetree.c.
Definition led.h:112
const led_t * leds
The LEDs, or NULL when count is 0.
Definition led.h:114
unsigned count
Number of LEDs.
Definition led.h:116
Named entry in the VFS namespace.
Definition vfs.h:145
Virtual file system: device nodes, RAM files and directories, mounted filesystems,...