From 0a6233e3acf598e09dd5d676c37883cbbf444130 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Thu, 25 Nov 2021 05:21:17 +0100 Subject: spi display driver initial commit --- fw/fe310/eos/spi.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'fw/fe310/eos/spi.c') 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) | -- cgit v1.2.3