]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_FreedomStudio/freedom-metal/src/led.c
Update RISCC-V-RV32-SiFive_HiFive1_FreedomStudio project to latest tools and metal...
[freertos] / FreeRTOS / Demo / RISC-V_RV32_SiFive_HiFive1_FreedomStudio / freedom-metal / src / led.c
1 /* Copyright 2018 SiFive, Inc */
2 /* SPDX-License-Identifier: Apache-2.0 */
3
4 #include <string.h>
5 #include <metal/led.h>
6 #include <metal/machine.h>
7
8 struct metal_led* metal_led_get_rgb (char *label, char *color)
9 {
10     int i;
11     struct metal_led *led;
12     char led_label[100];
13
14     if ((__METAL_DT_MAX_LEDS == 0) ||
15         (label == NULL) || (color == NULL)) {
16         return NULL;
17     }
18
19     strcpy(led_label, label);
20     strcat(led_label, color);
21     for (i = 0; i < __METAL_DT_MAX_LEDS; i++) {
22         led = (struct metal_led*)__metal_led_table[i];
23         if (led->vtable->led_exist(led, led_label)) {
24             return led;
25         }
26     }
27     return NULL;
28 }
29
30 struct metal_led* metal_led_get (char *label)
31 {
32     return metal_led_get_rgb(label, "");
33 }
34
35 extern __inline__ void metal_led_enable(struct metal_led *led);
36 extern __inline__ void metal_led_on(struct metal_led *led);
37 extern __inline__ void metal_led_off(struct metal_led *led);
38 extern __inline__ void metal_led_toggle(struct metal_led *led);