From 58f41971b1e801ad2fbcea08e5152afa2b18ca73 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Mon, 28 Jul 2025 23:27:12 +0200 Subject: sys logging added; power management reimplemented; bugfixes; --- fw/fe310/eos/soc/gpio.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 fw/fe310/eos/soc/gpio.c (limited to 'fw/fe310/eos/soc/gpio.c') diff --git a/fw/fe310/eos/soc/gpio.c b/fw/fe310/eos/soc/gpio.c new file mode 100644 index 0000000..4fa93dd --- /dev/null +++ b/fw/fe310/eos/soc/gpio.c @@ -0,0 +1,20 @@ +#include + +#include "encoding.h" +#include "platform.h" + +int eos_gpio_get(uint32_t reg, int pin) { + return !!(GPIO_REG(reg) & (1 << pin)); +} + +void eos_gpio_set(uint32_t reg, int pin) { + if ((reg == GPIO_OUTPUT_VAL) || (reg == GPIO_LOW_IE)) clear_csr(mstatus, MSTATUS_MIE); + GPIO_REG(reg) |= (1 << pin); + if ((reg == GPIO_OUTPUT_VAL) || (reg == GPIO_LOW_IE)) set_csr(mstatus, MSTATUS_MIE); +} + +void eos_gpio_clear(uint32_t reg, int pin) { + if ((reg == GPIO_OUTPUT_VAL) || (reg == GPIO_LOW_IE)) clear_csr(mstatus, MSTATUS_MIE); + GPIO_REG(reg) &= ~(1 << pin); + if ((reg == GPIO_OUTPUT_VAL) || (reg == GPIO_LOW_IE)) set_csr(mstatus, MSTATUS_MIE); +} -- cgit v1.2.3