]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_FreedomStudio/freedom-metal/metal/button.h
Update RISCC-V-RV32-SiFive_HiFive1_FreedomStudio project to latest tools and metal...
[freertos] / FreeRTOS / Demo / RISC-V_RV32_SiFive_HiFive1_FreedomStudio / freedom-metal / metal / button.h
1 /* Copyright 2018 SiFive, Inc */
2 /* SPDX-License-Identifier: Apache-2.0 */
3
4 #ifndef METAL__BUTTON_H
5 #define METAL__BUTTON_H
6
7 /*!
8  * @file button.h
9  * API for interfacing with physical buttons
10  */
11
12 #include <metal/interrupt.h>
13
14 struct metal_button;
15
16 struct metal_button_vtable {
17     int (*button_exist)(struct metal_button *button, char *label);
18     struct metal_interrupt* (*interrupt_controller)(struct metal_button *button);
19     int (*get_interrupt_id)(struct metal_button *button);
20 };
21
22 /*!
23  * @brief A button device handle
24  *
25  * A `struct metal_button` is an implementation-defined object which represents
26  * a button on a development board.
27  */
28 struct metal_button {
29     const struct metal_button_vtable *vtable;
30 };
31
32 /*!
33  * @brief Get a reference to a button
34  *
35  * @param label The DeviceTree label for the button
36  * @return A handle for the button
37  */
38 struct metal_button* metal_button_get(char *label);
39
40
41 /*!
42  * @brief Get the interrupt controller for a button
43  *
44  * @param button The handle for the button
45  * @return A pointer to the interrupt controller responsible for handling
46  * button interrupts.
47  */
48 __inline__ struct metal_interrupt*
49     metal_button_interrupt_controller(struct metal_button *button) { return button->vtable->interrupt_controller(button); }
50
51 /*!
52  * @brief Get the interrupt id for a button
53  *
54  * @param button The handle for the button
55  * @return The interrupt id corresponding to a button.
56  */
57 __inline__ int metal_button_get_interrupt_id(struct metal_button *button) { return button->vtable->get_interrupt_id(button); }
58
59 #endif