Skip to content

Commit 164024a

Browse files
committed
[gpio, sw] Added functions to write all output and output_en pins
Signed-off-by: Kinza Qamar <kqzaman@lowrisc.org>
1 parent 075f513 commit 164024a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

sw/device/lib/hal/gpio.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,13 @@ void gpio_set_oe_pin(gpio_t gpio, uint32_t pin, bool output)
3030
uint32_t mask = 1u << (pin & 0xFu);
3131
DEV_WRITE(gpio + reg, (mask << 16) | (output ? mask : 0u));
3232
}
33+
34+
void gpio_write(gpio_t gpio, uint32_t output_reg_addr, uint32_t value)
35+
{
36+
DEV_WRITE(gpio + output_reg_addr, value);
37+
}
38+
39+
void gpio_set_all_oe(gpio_t gpio, uint32_t value)
40+
{
41+
DEV_WRITE(gpio + GPIO_REG_DIRECT_OE, value);
42+
}

sw/device/lib/hal/gpio.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,11 @@ bool gpio_read_pin(gpio_t gpio, uint32_t pin);
2525
// Set the value of one output pin
2626
void gpio_write_pin(gpio_t gpio, uint32_t pin, bool state);
2727

28+
// Set the value of all output pins
29+
void gpio_write(gpio_t gpio, uint32_t output_reg_addr, uint32_t value);
30+
2831
// Set the output enable state of one pin
2932
void gpio_set_oe_pin(gpio_t gpio, uint32_t pin, bool output);
33+
34+
// Set the output enable state of all pins
35+
void gpio_set_all_oe(gpio_t gpio, uint32_t value);

0 commit comments

Comments
 (0)