summaryrefslogtreecommitdiff
path: root/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_FreedomStudio/freedom-metal/src/button.c
blob: 649388b3ce91c2392918a06a26763e1ae4dac239 (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
/* Copyright 2018 SiFive, Inc */
/* SPDX-License-Identifier: Apache-2.0 */

#include <metal/button.h>
#include <metal/machine.h>

struct metal_button* metal_button_get (char *label)
{
    int i;
    struct metal_button *button;

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

    for (i = 0; i < __METAL_DT_MAX_BUTTONS; i++) {
        button = (struct metal_button*)__metal_button_table[i];
        if (button->vtable->button_exist(button, label)) {
            return button;
        }
    }
    return NULL;
}

extern inline struct metal_interrupt*
    metal_button_interrupt_controller(struct metal_button *button);
extern inline int metal_button_get_interrupt_id(struct metal_button *button);