1 /*
2  * Copyright (c) 2016 Brian Swetland
3  *
4  * Use of this source code is governed by a MIT-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/MIT
7  */
8 
9 #include <dev/gpio.h>
10 
11 #include <driverlib/gpio.h>
12 #include <driverlib/ioc.h>
13 
gpio_config(unsigned nr,unsigned flags)14 int gpio_config(unsigned nr, unsigned flags) {
15     if (flags & GPIO_INPUT) {
16         IOCPortConfigureSet(nr, IOC_PORT_GPIO, IOC_INPUT_ENABLE);
17     } else {
18         IOCPortConfigureSet(nr, IOC_PORT_GPIO, 0);
19     }
20     if (flags & GPIO_OUTPUT) {
21         GPIO_setOutputEnableDio(nr, GPIO_OUTPUT_ENABLE);
22     } else {
23         GPIO_setOutputEnableDio(nr, GPIO_OUTPUT_DISABLE);
24     }
25     return 0;
26 }
27 
gpio_set(unsigned nr,unsigned on)28 void gpio_set(unsigned nr, unsigned on) {
29     GPIO_writeDio(nr, on);
30 }
31 
gpio_get(unsigned nr)32 int gpio_get(unsigned nr) {
33     return GPIO_readDio(nr);
34 }
35