summaryrefslogtreecommitdiff
path: root/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1-RevB_FreedomStudio/freedom-metal/src/led.c
blob: 91b74dbde44fcc9562f89d69a197adb60986ec5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* Copyright 2018 SiFive, Inc */
/* SPDX-License-Identifier: Apache-2.0 */

#include <string.h>
#include <metal/led.h>
#include <metal/machine.h>

struct metal_led* metal_led_get_rgb (char *label, char *color)
{
    int i;
    struct metal_led *led;
    char led_label[100];

    if ((__METAL_DT_MAX_LEDS == 0) ||
	(label == NULL) || (color == NULL)) {
        return NULL;
    }

    strcpy(led_label, label);
    strcat(led_label, color);
    for (i = 0; i < __METAL_DT_MAX_LEDS; i++) {
        led = (struct metal_led*)__metal_led_table[i];
        if (led->vtable->led_exist(led, led_label)) {
	    return led;
	}
    }
    return NULL;
}

struct metal_led* metal_led_get (char *label)
{
    return metal_led_get_rgb(label, "");
}

extern __inline__ void metal_led_enable(struct metal_led *led);
extern __inline__ void metal_led_on(struct metal_led *led);
extern __inline__ void metal_led_off(struct metal_led *led);
extern __inline__ void metal_led_toggle(struct metal_led *led);