summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/eve
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/eos/eve')
-rw-r--r--fw/fe310/eos/eve/eve.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/fw/fe310/eos/eve/eve.c b/fw/fe310/eos/eve/eve.c
index 91458d8..e1191fc 100644
--- a/fw/fe310/eos/eve/eve.c
+++ b/fw/fe310/eos/eve/eve.c
@@ -458,27 +458,27 @@ void eve_brightness(uint8_t b) {
int eve_gpio_get(int gpio) {
uint16_t reg = eve_read16(REG_GPIOX);
+
return !!(reg & (1 << gpio));
}
void eve_gpio_set(int gpio, int val) {
uint16_t reg = eve_read16(REG_GPIOX);
uint16_t reg_val = (1 << gpio);
- if (val) {
- reg |= reg_val;
- } else {
- reg &= ~reg_val;
- }
+
+ reg = val ? reg | reg_val : reg & ~reg_val;
eve_write16(REG_GPIOX, reg);
}
uint8_t eve_gpio_get_dir(void) {
uint16_t reg = eve_read16(REG_GPIOX_DIR);
+
return reg & 0x000f;
}
void eve_gpio_set_dir(uint8_t dir) {
uint16_t reg = eve_read16(REG_GPIOX_DIR);
+
reg &= 0xfff0;
reg |= dir & 0x0f;
eve_write16(REG_GPIOX_DIR, reg);