summaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2019-12-06 01:42:35 +0100
committerUros Majstorovic <majstor@majstor.org>2019-12-06 01:42:35 +0100
commitdb165818cd02bac16ac70f5317f947c5f6aa20da (patch)
treeaeaaebf23d560afef35b451f4df39c1783de0f0c /code
parent5454acdb6e04aa454989b78a2f20be2c25740585 (diff)
refactor gpio initialization
Diffstat (limited to 'code')
-rw-r--r--code/fe310/eos/net.c22
-rw-r--r--code/fe310/eos/spi.c3
2 files changed, 15 insertions, 10 deletions
diff --git a/code/fe310/eos/net.c b/code/fe310/eos/net.c
index 8f259db..9f19b4b 100644
--- a/code/fe310/eos/net.c
+++ b/code/fe310/eos/net.c
@@ -253,17 +253,21 @@ void eos_net_init(void) {
}
eos_evtq_set_handler(EOS_EVT_NET, net_handler_evt);
- GPIO_REG(GPIO_OUTPUT_EN) &= ~(1 << NET_PIN_CTS);
- GPIO_REG(GPIO_PULLUP_EN) |= (1 << NET_PIN_CTS);
- GPIO_REG(GPIO_INPUT_EN) |= (1 << NET_PIN_CTS);
- GPIO_REG(GPIO_RISE_IE) |= (1 << NET_PIN_CTS);
+ GPIO_REG(GPIO_INPUT_EN) |= (1 << NET_PIN_CTS);
+ GPIO_REG(GPIO_OUTPUT_EN) &= ~(1 << NET_PIN_CTS);
+ GPIO_REG(GPIO_PULLUP_EN) &= ~(1 << NET_PIN_CTS);
+ GPIO_REG(GPIO_OUTPUT_XOR) &= ~(1 << NET_PIN_CTS);
+
+ GPIO_REG(GPIO_RISE_IE) |= (1 << NET_PIN_CTS);
eos_intr_set(INT_GPIO_BASE + NET_PIN_CTS, IRQ_PRIORITY_NET_CTS, net_handler_cts);
- GPIO_REG(GPIO_OUTPUT_EN) &= ~(1 << NET_PIN_RTS);
- GPIO_REG(GPIO_PULLUP_EN) |= (1 << NET_PIN_RTS);
- GPIO_REG(GPIO_INPUT_EN) |= (1 << NET_PIN_RTS);
- GPIO_REG(GPIO_RISE_IE) |= (1 << NET_PIN_RTS);
- GPIO_REG(GPIO_FALL_IE) |= (1 << NET_PIN_RTS);
+ GPIO_REG(GPIO_INPUT_EN) |= (1 << NET_PIN_RTS);
+ GPIO_REG(GPIO_OUTPUT_EN) &= ~(1 << NET_PIN_RTS);
+ GPIO_REG(GPIO_PULLUP_EN) &= ~(1 << NET_PIN_RTS);
+ GPIO_REG(GPIO_OUTPUT_XOR) &= ~(1 << NET_PIN_RTS);
+
+ GPIO_REG(GPIO_RISE_IE) |= (1 << NET_PIN_RTS);
+ GPIO_REG(GPIO_FALL_IE) |= (1 << NET_PIN_RTS);
eos_intr_set(INT_GPIO_BASE + NET_PIN_RTS, IRQ_PRIORITY_NET_RTS, net_handler_rts);
}
diff --git a/code/fe310/eos/spi.c b/code/fe310/eos/spi.c
index 0c9a38c..56ef318 100644
--- a/code/fe310/eos/spi.c
+++ b/code/fe310/eos/spi.c
@@ -60,10 +60,11 @@ static void spi_xchg_wait(void) {
}
void eos_spi_init(void) {
- GPIO_REG(GPIO_OUTPUT_VAL) |= (1 << SPI_CS_PIN_CAM);
GPIO_REG(GPIO_INPUT_EN) &= ~(1 << SPI_CS_PIN_CAM);
GPIO_REG(GPIO_OUTPUT_EN) |= (1 << SPI_CS_PIN_CAM);
+ GPIO_REG(GPIO_PULLUP_EN) &= ~(1 << SPI_CS_PIN_CAM);
GPIO_REG(GPIO_OUTPUT_XOR) &= ~(1 << SPI_CS_PIN_CAM);
+ GPIO_REG(GPIO_OUTPUT_VAL) |= (1 << SPI_CS_PIN_CAM);
SPI1_REG(SPI_REG_SCKMODE) = SPI_MODE0;
SPI1_REG(SPI_REG_FMT) = SPI_FMT_PROTO(SPI_PROTO_S) |