Files
lk/platform/lpc43xx/gpio.c
Travis Geiselbrecht cba9e47987 [license] replace the longer full MIT license with a shorter one
Used scripts/replacelic. Everything seems to build fine.
2019-07-05 17:22:23 -07:00

30 lines
710 B
C

/*
* Copyright (c) 2015 Brian Swetland
*
* Use of this source code is governed by a MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT
*/
#include <lk/reg.h>
#include <platform/lpc43xx-gpio.h>
inline int gpio_config(unsigned nr, unsigned flags) {
unsigned m = _GPIOm(nr);
unsigned n = _GPIOn(nr);
if (flags & GPIO_INPUT) {
writel(readl(GPIO_DIR(m)) & (~(1 << n)), GPIO_DIR(m));
} else {
writel(readl(GPIO_DIR(m)) | (1 << n), GPIO_DIR(m));
}
return 0;
}
inline void gpio_set(unsigned nr, unsigned on) {
writel(on, GPIO_WORD(nr));
}
inline int gpio_get(unsigned nr) {
return readl(GPIO_WORD(nr)) & 1;
}