diff options
author | Uros Majstorovic <majstor@majstor.org> | 2021-11-25 05:21:17 +0100 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2021-11-25 05:21:17 +0100 |
commit | 0a6233e3acf598e09dd5d676c37883cbbf444130 (patch) | |
tree | 4a6f3ec5024b8f2389086de1356c8e7333854c38 /fw/fe310/eos/spi.c | |
parent | 6a31936e80ae2743376dcbf9d39cd92461c4deca (diff) |
spi display driver initial commit
Diffstat (limited to 'fw/fe310/eos/spi.c')
-rw-r--r-- | fw/fe310/eos/spi.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/fw/fe310/eos/spi.c b/fw/fe310/eos/spi.c index 085802c..234bff6 100644 --- a/fw/fe310/eos/spi.c +++ b/fw/fe310/eos/spi.c @@ -21,8 +21,6 @@ #define SPI_FLAG_XCHG 0x10 -#define SPI_IOF_MASK (((uint32_t)1 << IOF_SPI1_SCK) | ((uint32_t)1 << IOF_SPI1_MOSI) | ((uint32_t)1 << IOF_SPI1_MISO)) | SPI_IOF_MASK_CS - #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) #define MAX(X, Y) (((X) > (Y)) ? (X) : (Y)) @@ -56,6 +54,24 @@ void eos_spi_init(uint8_t wakeup_cause) { eos_evtq_set_handler(EOS_EVT_SPI, spi_handle_evt); eos_intr_set(INT_SPI1_BASE, IRQ_PRIORITY_SPI_XCHG, NULL); + GPIO_REG(GPIO_OUTPUT_VAL) &= ~(1 << IOF_SPI1_SCK); + GPIO_REG(GPIO_OUTPUT_VAL) |= (1 << IOF_SPI1_MOSI); + + GPIO_REG(GPIO_INPUT_EN) &= ~(1 << IOF_SPI1_SCK); + GPIO_REG(GPIO_OUTPUT_EN) |= (1 << IOF_SPI1_SCK); + GPIO_REG(GPIO_PULLUP_EN) &= ~(1 << IOF_SPI1_SCK); + GPIO_REG(GPIO_OUTPUT_XOR) &= ~(1 << IOF_SPI1_SCK); + + GPIO_REG(GPIO_INPUT_EN) &= ~(1 << IOF_SPI1_MOSI); + GPIO_REG(GPIO_OUTPUT_EN) |= (1 << IOF_SPI1_MOSI); + GPIO_REG(GPIO_PULLUP_EN) &= ~(1 << IOF_SPI1_MOSI); + GPIO_REG(GPIO_OUTPUT_XOR) &= ~(1 << IOF_SPI1_MOSI); + + GPIO_REG(GPIO_INPUT_EN) |= (1 << IOF_SPI1_MISO); + GPIO_REG(GPIO_OUTPUT_EN) &= ~(1 << IOF_SPI1_MISO); + GPIO_REG(GPIO_PULLUP_EN) &= ~(1 << IOF_SPI1_MISO); + GPIO_REG(GPIO_OUTPUT_XOR) &= ~(1 << IOF_SPI1_MISO); + SPI1_REG(SPI_REG_SCKMODE) = SPI_MODE0; SPI1_REG(SPI_REG_FMT) = SPI_FMT_PROTO(SPI_PROTO_S) | SPI_FMT_ENDIAN(SPI_ENDIAN_MSB) | |