From daa99a04830e46bfab7747deb694b034b526e034 Mon Sep 17 00:00:00 2001 From: canhu Date: Fri, 28 Aug 2020 11:42:00 +0800 Subject: [PATCH] SoC: update SPI drivers for hbirdv2 --- SoC/hbirdv2/Common/Include/hbirdv2.h | 3 ++- SoC/hbirdv2/Common/Include/hbirdv2_spi.h | 14 +++++++------- SoC/hbirdv2/Common/Source/Drivers/hbirdv2_spi.c | 14 +++++++------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/SoC/hbirdv2/Common/Include/hbirdv2.h b/SoC/hbirdv2/Common/Include/hbirdv2.h index 622a861..1ebbdd4 100644 --- a/SoC/hbirdv2/Common/Include/hbirdv2.h +++ b/SoC/hbirdv2/Common/Include/hbirdv2.h @@ -221,7 +221,8 @@ typedef enum EXCn { #define IOF_PWM3_CH2_MASK _AC(0x00000040, UL) #define IOF_PWM3_CH3_MASK _AC(0x00000080, UL) -#define IOF_SPI_MASK _AC(0x00003F00,UL) +#define IOF_SPI_MASK _AC(0x00000F00,UL) +#define IOF_QSPI_MASK _AC(0x00003F00,UL) #define IOF_SPI_SCK (8u) #define IOF_SPI_SS0 (9u) #define IOF_SPI_MOSI (10u) diff --git a/SoC/hbirdv2/Common/Include/hbirdv2_spi.h b/SoC/hbirdv2/Common/Include/hbirdv2_spi.h index f2bcc5b..5892f59 100644 --- a/SoC/hbirdv2/Common/Include/hbirdv2_spi.h +++ b/SoC/hbirdv2/Common/Include/hbirdv2_spi.h @@ -18,14 +18,14 @@ #define SPI_CSN2 2 #define SPI_CSN3 3 -int32_t spi_setup_cmd_addr(SPI_TypeDef *spi, int cmd, int cmdlen, int addr, int addrlen); -int32_t spi_setup_dummy(SPI_TypeDef *spi, int dummy_rd, int dummy_wr); -int32_t spi_setup_clk(SPI_TypeDef *spi, int clkdiv); -int32_t spi_set_datalen(SPI_TypeDef *spi, int datalen); -int32_t spi_start_transaction(SPI_TypeDef *spi, int trans_type, int csnum); +int32_t spi_setup_cmd_addr(SPI_TypeDef *spi, uint32_t cmd, uint32_t cmdlen, uint32_t addr, uint32_t addrlen); +int32_t spi_setup_dummy(SPI_TypeDef *spi, uint16_t dummy_rd, uint16_t dummy_wr); +int32_t spi_setup_clk(SPI_TypeDef *spi, uint8_t clkdiv); +int32_t spi_set_datalen(SPI_TypeDef *spi, uint32_t datalen); +int32_t spi_start_transaction(SPI_TypeDef *spi, uint32_t trans_type, uint32_t csnum); int32_t spi_get_status(SPI_TypeDef *spi); -int32_t spi_write_fifo(SPI_TypeDef *spi, int *data, int datalen); -int32_t spi_read_fifo(SPI_TypeDef *spi, int *data, int datalen); +int32_t spi_write_fifo(SPI_TypeDef *spi, uint32_t *data, uint32_t datalen); +int32_t spi_read_fifo(SPI_TypeDef *spi, uint32_t *data, uint32_t datalen); int32_t spi_enable_interrupt(SPI_TypeDef *spi); int32_t spi_disable_interrupt(SPI_TypeDef *spi); int32_t spi_get_int_status(SPI_TypeDef *spi); diff --git a/SoC/hbirdv2/Common/Source/Drivers/hbirdv2_spi.c b/SoC/hbirdv2/Common/Source/Drivers/hbirdv2_spi.c index 78297e8..9b991af 100644 --- a/SoC/hbirdv2/Common/Source/Drivers/hbirdv2_spi.c +++ b/SoC/hbirdv2/Common/Source/Drivers/hbirdv2_spi.c @@ -2,7 +2,7 @@ #include "hbirdv2_spi.h" -int32_t spi_setup_cmd_addr(SPI_TypeDef *spi, int cmd, int cmdlen, int addr, int addrlen) { +int32_t spi_setup_cmd_addr(SPI_TypeDef *spi, uint32_t cmd, uint32_t cmdlen, uint32_t addr, uint32_t addrlen) { if (__RARELY(spi == NULL)) { return -1; @@ -18,7 +18,7 @@ int32_t spi_setup_cmd_addr(SPI_TypeDef *spi, int cmd, int cmdlen, int addr, int return 0; } -int32_t spi_setup_clk(SPI_TypeDef *spi, int clkdiv) { +int32_t spi_setup_clk(SPI_TypeDef *spi, uint8_t clkdiv) { if (__RARELY(spi == NULL)) { return -1; @@ -29,7 +29,7 @@ int32_t spi_setup_clk(SPI_TypeDef *spi, int clkdiv) { return 0; } -int32_t spi_setup_dummy(SPI_TypeDef *spi, int dummy_rd, int dummy_wr) { +int32_t spi_setup_dummy(SPI_TypeDef *spi, uint16_t dummy_rd, uint16_t dummy_wr) { if (__RARELY(spi == NULL)) { return -1; @@ -40,7 +40,7 @@ int32_t spi_setup_dummy(SPI_TypeDef *spi, int dummy_rd, int dummy_wr) { return 0; } -int32_t spi_set_datalen(SPI_TypeDef *spi, int datalen) { +int32_t spi_set_datalen(SPI_TypeDef *spi, uint32_t datalen) { if (__RARELY(spi == NULL)) { return -1; @@ -54,7 +54,7 @@ int32_t spi_set_datalen(SPI_TypeDef *spi, int datalen) { return 0; } -int32_t spi_start_transaction(SPI_TypeDef *spi, int trans_type, int csnum) { +int32_t spi_start_transaction(SPI_TypeDef *spi, uint32_t trans_type, uint32_t csnum) { if (__RARELY(spi == NULL)) { return -1; @@ -74,7 +74,7 @@ int32_t spi_get_status(SPI_TypeDef *spi) { return spi->STATUS; } -int32_t spi_write_fifo(SPI_TypeDef *spi, int *data, int datalen) { +int32_t spi_write_fifo(SPI_TypeDef *spi, uint32_t *data, uint32_t datalen) { if (__RARELY(spi == NULL)) { return -1; @@ -95,7 +95,7 @@ int32_t spi_write_fifo(SPI_TypeDef *spi, int *data, int datalen) { return 0; } -int32_t spi_read_fifo(SPI_TypeDef *spi, int *data, int datalen) { +int32_t spi_read_fifo(SPI_TypeDef *spi, uint32_t *data, uint32_t datalen) { if (__RARELY(spi == NULL)) { return -1;