summaryrefslogtreecommitdiff
path: root/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/freedom-metal/src/gpio.c
blob: 02a6582c9ee72f9eef545420e5a263c16840b0a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* Copyright 2019 SiFive, Inc */
/* SPDX-License-Identifier: Apache-2.0 */

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

extern inline int metal_gpio_disable_input(struct metal_gpio *gpio, int pin);
extern inline int metal_gpio_enable_output(struct metal_gpio *gpio, int pin);
extern inline int metal_gpio_set_pin(struct metal_gpio *, int pin, int value);
extern inline int metal_gpio_get_pin(struct metal_gpio *, int pin);
extern inline int metal_gpio_clear_pin(struct metal_gpio *, int pin);
extern inline int metal_gpio_toggle_pin(struct metal_gpio *, int pin);
extern inline int metal_gpio_enable_pinmux(struct metal_gpio *, int pin, int io_function);

struct metal_gpio *metal_gpio_get_device(int device_num)
{
    if(device_num > __MEE_DT_MAX_GPIOS) {
	return NULL;
    }

    return (struct metal_gpio *) __metal_gpio_table[device_num];
}