26 #include "in_compile.h" 33 #define SPI_REG_CTRL0_OFS 0x00000000UL 34 #define SPI_REG_CTRL1_OFS 0x00000004UL 35 #define SPI_REG_SSIEN_OFS 0x00000008UL 36 #define SPI_REG_SE_OFS 0x00000010UL 37 #define SPI_REG_BAUD_OFS 0x00000014UL 38 #define SPI_REG_TXFTL_OFS 0x00000018UL 39 #define SPI_REG_RXFTL_OFS 0x0000001CUL 40 #define SPI_REG_TXFL_OFS 0x00000020UL 41 #define SPI_REG_RXFL_OFS 0x00000024UL 42 #define SPI_REG_SR_OFS 0x00000028UL 43 #define SPI_REG_IMR_OFS 0x0000002CUL 44 #define SPI_REG_ISR_OFS 0x00000030UL 45 #define SPI_REG_RISR_OFS 0x00000034UL 46 #define SPI_REG_TXOIC_OFS 0x00000038UL 47 #define SPI_REG_RXOIC_OFS 0x0000003CUL 48 #define SPI_REG_RXUIC_OFS 0x00000040UL 49 #define SPI_REG_ICR_OFS 0x00000048UL 50 #define SPI_REG_ICR_OFS 0x00000048UL 51 #define SPI_REG_DMACR_OFS 0x0000004CUL 52 #define SPI_REG_DMATDL_OFS 0x00000050UL 53 #define SPI_REG_DMARDL_OFS 0x00000054UL 54 #define SPI_REG_DR_OFS 0x00000060UL 55 #define SPI_REG_RX_SAMPLE_DLY 0x000000F0UL 56 #define SPI_REG_DUAL_QUAD_CTRL_OFS 0x000000F4UL 58 #define SPI_CTL0_DFS_16 0x0000000FUL 59 #define SPI_CTL0_SCPH 0x00000040UL 60 #define SPI_CTL0_SCPOL 0x00000080UL 61 #define SPI_CTL0_TMOD 0x00000300UL 62 #define SPI_CTL0_DFS 0x001F0000UL 63 #define SPI_CTL0_FRF 0x00600000UL 65 #define SPI_CTL1_NDF 0x0000FFFFUL 67 #define SPI_SE_EN 0x0000000FUL 69 #define SPI_BAUD_SCKDV 0x0000FFFFUL 71 #define SPI_TXFTL_TFT 0x0000000FUL 73 #define SPI_RXFTL_RFT 0x0000000FUL 75 #define SPI_TXFL_TXTFL 0x0000000FUL 77 #define SPI_RXFL_RXTFL 0x0000000FUL 79 #define SPI_SR_BUSY 0x00000001UL 80 #define SPI_SR_TFNF 0x00000002UL 81 #define SPI_SR_TFE 0x00000004UL 82 #define SPI_SR_RFNE 0x00000008UL 83 #define SPI_SR_RFF 0x00000010UL 84 #define SPI_SR_TXE 0x00000020UL 85 #define SPI_SR_DCOL 0x00000040UL 87 #define SPI_IT_TXE 0x00000001UL 88 #define SPI_IT_TXO 0x00000002UL 89 #define SPI_IT_RXU 0x00000004UL 90 #define SPI_IT_RXO 0x00000008UL 91 #define SPI_IT_RXF 0x00000010UL 92 #define SPI_IT_MSTIM 0x00000020UL 93 #define SPI_IT_ALL (SPI_IT_TXE|SPI_IT_TXO|SPI_IT_RXU|SPI_IT_RXO|SPI_IT_RXF|SPI_IT_MSTIM) 95 #define SPI_DUAL_QUAD_TRANS_TYPE 0x00000003UL 96 #define SPI_DUAL_QUAD_ADDR_LEN 0x0000003CUL 97 #define SPI_DUAL_QUAD_INS_LEN 0x00000300UL 98 #define SPI_DUAL_QUAD_WAIT_CYCLES 0x00007800UL 140 SPI_DFS_4_BITS = 0x4,
175 SPI_ERR_INVALID_PARAM = -1,
176 SPI_ERR_INVALID_OPER = -2,
180 SPI_ERR_DMA_NOT_AVAIL = -6,
181 SPI_ERR_DMA_ERROR = -7,
204 QSPI_CMD_WIDTH_0BITS,
205 QSPI_CMD_WIDTH_4BITS,
206 QSPI_CMD_WIDTH_8BITS,
207 QSPI_CMD_WIDTH_16BITS,
212 QSPI_ADDR_WIDTH_0BITS,
213 QSPI_DDR_WIDTH_4BITS,
214 QSPI_ADDR_WIDTH_8BITS,
215 QSPI_ADDR_WIDTH_12BITS,
216 QSPI_ADDR_WIDTH_16BITS,
217 QSPI_ADDR_WIDTH_20BITS,
218 QSPI_ADDR_WIDTH_24BITS,
219 QSPI_ADDR_WIDTH_28BITS,
220 QSPI_ADDR_WIDTH_32BITS,
221 QSPI_ADDR_WIDTH_36BITS,
222 QSPI_ADDR_WIDTH_40BITS,
223 QSPI_ADDR_WIDTH_44BITS,
224 QSPI_ADDR_WIDTH_48BITS,
225 QSPI_ADDR_WIDTH_52BITS,
226 QSPI_ADDR_WIDTH_56BITS,
227 QSPI_ADDR_WIDTH_60BITS,
232 QSPI_TT_CMD_STD_ADDR_STD,
233 QSPI_TT_CMD_STD_ADDR_QUAD,
234 QSPI_TT_CMD_ADDR_QUAD,
242 static INLINE
void spi_ctl0_clear(uint32_t spi_base)
244 WR_WORD((spi_base + SPI_REG_CTRL0_OFS), 0);
247 static INLINE
void spi_ctl0(uint32_t spi_base,
int fmt,
int tmod,
int dfs,
int phase_high,
int polarity_high)
249 uint32_t reg = RD_WORD(spi_base + SPI_REG_CTRL0_OFS);
253 reg |= SPI_CTL0_SCPH;
255 reg &= ~SPI_CTL0_SCPH;
260 reg |= SPI_CTL0_SCPOL;
262 reg &= ~SPI_CTL0_SCPOL;
266 reg &= ~SPI_CTL0_FRF;
267 reg |= ((fmt&0x3)<<21);
270 reg &= ~SPI_CTL0_TMOD;
274 reg &= ~SPI_CTL0_DFS;
276 reg |= ((dfs&0x1F)<<16);
278 WR_WORD((spi_base + SPI_REG_CTRL0_OFS), reg);
281 static FORCEINLINE
void spi_phase_0(uint32_t spi_base)
283 WR_WORD((spi_base + SPI_REG_CTRL0_OFS), (RD_WORD(spi_base + SPI_REG_CTRL0_OFS) & ~SPI_CTL0_SCPH));
286 static FORCEINLINE
void spi_phase_1(uint32_t spi_base)
288 WR_WORD((spi_base + SPI_REG_CTRL0_OFS), (RD_WORD(spi_base + SPI_REG_CTRL0_OFS) | SPI_CTL0_SCPH));
291 static FORCEINLINE
void spi_polarity_0(uint32_t spi_base)
293 WR_WORD((spi_base + SPI_REG_CTRL0_OFS), (RD_WORD(spi_base + SPI_REG_CTRL0_OFS) & ~SPI_CTL0_SCPOL));
296 static FORCEINLINE
void spi_polarity_1(uint32_t spi_base)
298 WR_WORD((spi_base + SPI_REG_CTRL0_OFS), (RD_WORD(spi_base + SPI_REG_CTRL0_OFS) | SPI_CTL0_SCPOL));
301 static FORCEINLINE
void spi_tmod(uint32_t spi_base,
int tmod)
303 WR_WORD((spi_base + SPI_REG_CTRL0_OFS), ((RD_WORD(spi_base + SPI_REG_CTRL0_OFS) & ~SPI_CTL0_TMOD) | (tmod << 8)));
306 static FORCEINLINE
void spi_dfs(uint32_t spi_base,
int len)
308 WR_WORD((spi_base + SPI_REG_CTRL0_OFS), ((RD_WORD(spi_base + SPI_REG_CTRL0_OFS) & ~SPI_CTL0_DFS) | (((len - 1)&0x1F)<<16)));
311 static FORCEINLINE
void spi_frf(uint32_t spi_base,
int fmt)
313 WR_WORD((spi_base + SPI_REG_CTRL0_OFS), ((RD_WORD(spi_base + SPI_REG_CTRL0_OFS) & ~SPI_CTL0_FRF) | ((fmt&0x3)<<21)));
316 static FORCEINLINE
void spi_ndf(uint32_t spi_base, uint16_t ndf)
318 WR_WORD((spi_base + SPI_REG_CTRL1_OFS), ((RD_WORD(spi_base + SPI_REG_CTRL1_OFS) & ~SPI_CTL1_NDF)|ndf));
321 static FORCEINLINE
void spi_enable(uint32_t spi_base)
323 WR_WORD((spi_base + SPI_REG_SSIEN_OFS), (RD_WORD(spi_base + SPI_REG_SSIEN_OFS) |1UL));
326 static FORCEINLINE
void spi_disable(uint32_t spi_base)
328 WR_WORD((spi_base + SPI_REG_SSIEN_OFS), (RD_WORD(spi_base + SPI_REG_SSIEN_OFS) & ~1UL));
331 static FORCEINLINE
void spi_ser_en(uint32_t spi_base,
int bit)
333 WR_WORD((spi_base + SPI_REG_SE_OFS), (RD_WORD(spi_base + SPI_REG_SE_OFS)|(1<<bit)));
336 static FORCEINLINE
void spi_ser_dis(uint32_t spi_base,
int bit)
338 WR_WORD((spi_base + SPI_REG_SE_OFS), (RD_WORD(spi_base + SPI_REG_SE_OFS)&~(1<<bit)));
341 static INLINE
void spi_ser(uint32_t spi_base,
int enable,
int bit)
343 uint32_t reg = RD_WORD(spi_base + SPI_REG_SE_OFS);
347 reg |= (1 << (bit & 0x3));
352 WR_WORD((spi_base + SPI_REG_SE_OFS), reg);
356 static INLINE
void spi_fpga_cs(
int ss,
int low)
358 uint32_t reg = RD_WORD(FPGA_SPI_FLASH_CTRL);
360 if (((reg >> 8) & 0xF) != 1) {
365 reg &= ~(1<<((ss & 0xF) + 4));
367 reg |= (1<<((ss & 0xF) + 4));
370 WR_WORD(FPGA_SPI_FLASH_CTRL, reg);
374 static INLINE
void spi_baud_rate(uint32_t spi_base, uint32_t clk, uint32_t spi_clk)
376 uint16_t div = clk/spi_clk;
382 WR_WORD((spi_base + SPI_REG_BAUD_OFS), div);
385 static FORCEINLINE
void spi_txftl(uint32_t spi_base, uint8_t tl)
387 WR_WORD((spi_base + SPI_REG_TXFTL_OFS), tl);
390 static INLINE
void spi_rxftl(uint32_t spi_base, uint8_t tl)
392 WR_WORD((spi_base + SPI_REG_RXFTL_OFS), tl);
395 static INLINE uint8_t spi_txfl(uint32_t spi_base)
397 return (RD_WORD(spi_base + SPI_REG_TXFL_OFS));
400 static INLINE uint8_t spi_rxfl(uint32_t spi_base)
402 return (RD_WORD(spi_base + SPI_REG_RXFL_OFS) & 0xF);
405 static INLINE uint32_t spi_sr(uint32_t spi_base)
407 return (RD_WORD(spi_base + SPI_REG_SR_OFS));
410 static FORCEINLINE
void spi_intr_mask(uint32_t spi_base, uint32_t mask)
412 WR_WORD((spi_base + SPI_REG_IMR_OFS), (RD_WORD(spi_base + SPI_REG_IMR_OFS) & ~mask));
415 static FORCEINLINE
void spi_intr_unmask(uint32_t spi_base, uint32_t mask)
417 WR_WORD((spi_base + SPI_REG_IMR_OFS), (RD_WORD(spi_base + SPI_REG_IMR_OFS)|mask));
420 static FORCEINLINE uint32_t spi_intr_status(uint32_t spi_base)
422 return RD_WORD(spi_base + SPI_REG_ISR_OFS);
425 static FORCEINLINE uint32_t spi_intr_raw_status(uint32_t spi_base)
427 return RD_WORD(spi_base + SPI_REG_RISR_OFS);
430 static FORCEINLINE uint32_t spi_intr_txo_clr(uint32_t spi_base)
432 return RD_WORD(spi_base + SPI_REG_TXOIC_OFS);
435 static FORCEINLINE uint32_t spi_intr_rxo_clr(uint32_t spi_base)
437 return RD_WORD(spi_base + SPI_REG_RXOIC_OFS);
440 static FORCEINLINE uint32_t spi_intr_rxu_clr(uint32_t spi_base)
442 return RD_WORD(spi_base + SPI_REG_RXUIC_OFS);
445 static FORCEINLINE uint32_t spi_intr_clr(uint32_t spi_base)
447 return RD_WORD(spi_base + SPI_REG_ICR_OFS);
450 static FORCEINLINE
void spi_txdma_enable(uint32_t spi_base)
452 WR_WORD(spi_base + SPI_REG_DMACR_OFS, (RD_WORD(spi_base + SPI_REG_DMACR_OFS)|0x2));
455 static FORCEINLINE
void spi_txdma_disable(uint32_t spi_base)
457 WR_WORD(spi_base + SPI_REG_DMACR_OFS, (RD_WORD(spi_base + SPI_REG_DMACR_OFS)&~0x2));
460 static FORCEINLINE
void spi_txdma_req_level(uint32_t spi_base,
int level)
462 WR_WORD(spi_base + SPI_REG_DMATDL_OFS, (level & 0xFF));
465 static FORCEINLINE
void spi_rxdma_enable(uint32_t spi_base)
467 WR_WORD(spi_base + SPI_REG_DMACR_OFS, (RD_WORD(spi_base + SPI_REG_DMACR_OFS)|0x1));
470 static FORCEINLINE
void spi_rxdma_disable(uint32_t spi_base)
472 WR_WORD(spi_base + SPI_REG_DMACR_OFS, (RD_WORD(spi_base + SPI_REG_DMACR_OFS)&~0x1));
475 static INLINE
void spi_rxdma_req_level(uint32_t spi_base,
int level)
480 WR_WORD(spi_base + SPI_REG_DMARDL_OFS, ((level-1) & 0xFF));
483 static FORCEINLINE
void spi_dr_write(uint32_t spi_base, uint32_t data)
485 WR_WORD((spi_base + SPI_REG_DR_OFS), data);
488 static FORCEINLINE uint32_t spi_dr_read(uint32_t spi_base)
490 return RD_WORD(spi_base + SPI_REG_DR_OFS);
493 static FORCEINLINE
void spi_rx_samp_dly(uint32_t spi_base, uint8_t delay)
495 WR_WORD((spi_base + SPI_REG_RX_SAMPLE_DLY), delay);
498 static INLINE
void qspi_spi_ctl(uint32_t spi_base,
int wc,
int ins_len,
int adr_len,
int tt)
500 uint32_t reg = RD_WORD(spi_base + SPI_REG_DUAL_QUAD_CTRL_OFS);
502 reg &= ~SPI_DUAL_QUAD_WAIT_CYCLES;
503 reg |= ((wc&0xF) << 11);
505 reg &= ~SPI_DUAL_QUAD_INS_LEN;
506 reg |= ((ins_len&0x3) << 8);
508 reg &= ~SPI_DUAL_QUAD_ADDR_LEN;
509 reg |= ((adr_len&0xF) << 2);
511 reg &= ~SPI_DUAL_QUAD_TRANS_TYPE;
514 WR_WORD((spi_base + SPI_REG_DUAL_QUAD_CTRL_OFS), reg);
517 static INLINE
void qspi_wait_cycle(uint32_t spi_base,
int wc)
520 uint32_t reg = RD_WORD(spi_base + SPI_REG_DUAL_QUAD_CTRL_OFS);
522 reg &= ~SPI_DUAL_QUAD_WAIT_CYCLES;
523 reg |= ((wc&0xF) << 11);
525 WR_WORD((spi_base + SPI_REG_DUAL_QUAD_CTRL_OFS), reg);
530 uint32_t reg = RD_WORD(spi_base + SPI_REG_DUAL_QUAD_CTRL_OFS);
532 reg &= ~SPI_DUAL_QUAD_INS_LEN;
533 reg |= ((ins_len&0x3) << 8);
535 WR_WORD((spi_base + SPI_REG_DUAL_QUAD_CTRL_OFS), reg);
540 uint32_t reg = RD_WORD(spi_base + SPI_REG_DUAL_QUAD_CTRL_OFS);
542 reg &= ~SPI_DUAL_QUAD_ADDR_LEN;
543 reg |= ((adr_len&0xF) << 2);
545 WR_WORD((spi_base + SPI_REG_DUAL_QUAD_CTRL_OFS), reg);
548 static INLINE
void qspi_trans_type(uint32_t spi_base,
int tt)
550 uint32_t reg = RD_WORD(spi_base + SPI_REG_DUAL_QUAD_CTRL_OFS);
552 reg &= ~SPI_DUAL_QUAD_TRANS_TYPE;
555 WR_WORD((spi_base + SPI_REG_DUAL_QUAD_CTRL_OFS), reg);
558 static INLINE
void qspi_single_wire_mode(
int single)
562 WR_WORD(FPGA_REG_FPGA_SPI_M0_CTRL, 1);
564 WR_WORD(FPGA_REG_FPGA_SPI_M0_CTRL, 0);
568 static INLINE
void qspi_xip_enable(
int addr_width,
int wait_cycle,
int tran_type)
570 uint32_t reg = SPIFLASH_REG_SPIFLASH_MISC_CTRL_CTL_SPI_APB_MUX_SEL |
571 SPIFLASH_REG_SPIFLASH_MISC_CTRL_CTL_SPI_FLASH_ENDIAN_PRDATA_SWAP |
572 ((addr_width & SPIFLASH_REG_SPIFLASH_MISC_CTRL_CTL_SPI_FLASH_ADDR_LENGTH_MASK) << SPIFLASH_REG_SPIFLASH_MISC_CTRL_CTL_SPI_FLASH_ADDR_LENGTH_SHIFT) |
573 ((wait_cycle & SPIFLASH_REG_SPIFLASH_MISC_CTRL_CTL_SPI_WAIT_CYCLE_MASK) << SPIFLASH_REG_SPIFLASH_MISC_CTRL_CTL_SPI_WAIT_CYCLE_SHIFT) |
574 ((tran_type & SPIFLASH_REG_SPIFLASH_MISC_CTRL_CTL_SPI_TRANS_TYPE_MASK) << SPIFLASH_REG_SPIFLASH_MISC_CTRL_CTL_SPI_TRANS_TYPE_SHIFT) |
575 SPIFLASH_REG_SPIFLASH_MISC_CTRL_CTL_SPI_FLASH_ADDR_SRC;
577 WR_WORD(SPIFLASH_REG_SPIFLASH_MISC_CTRL, reg);
580 static INLINE
void qspi_xip_disable(
void)
582 WR_WORD(SPIFLASH_REG_SPIFLASH_MISC_CTRL, SPIFLASH_REG_SPIFLASH_MISC_CTRL_DEFAULT);
585 static INLINE
void qspi_xip_ins(uint32_t ins)
587 WR_WORD(SPIFLASH_REG_SPIFLASH_INSTRUCTION, ins);
590 static INLINE
void qspi_xip_ssn(
int ssn)
592 WR_WORD(SPIFLASH_REG_SPIFLASH_SLV_SEL, (ssn & SPIFLASH_REG_SPIFLASH_SLV_SEL_CTL_SPI_FLASH_SLAVE_SEL_MASK));
594 static INLINE
void qspi_addr_set_offset(uint32_t offset)
596 WR_WORD(SPIFLASH_REG_SPIFLASH_ADDR_OFFSET, offset);
598 static INLINE uint32_t qspi_addr_get_offset(
void)
600 return RD_WORD(SPIFLASH_REG_SPIFLASH_ADDR_OFFSET);
602 static INLINE
void spi_flash_icache_dec(
int en)
605 WR_WORD(SPIFLASH_REG_ICACHE_DEC_MISC_CTRL, 1);
607 WR_WORD(SPIFLASH_REG_ICACHE_DEC_MISC_CTRL, 0);
611 static INLINE
void spi_reset(
int id)
613 uint32_t reg = RD_WORD(GLOBAL_REG_RESET_CTRL_1);
617 reg &= ~GLOBAL_REG_RESET_CTRL_1_CTL_RESET_1_D0_CPU_SSI_MASTER1_SSI_RSTN_REG;
620 reg &= ~GLOBAL_REG_RESET_CTRL_1_CTL_RESET_1_D0_CPU_SSI_SLAVE0_SSI_RSTN_REG;
622 reg &= ~GLOBAL_REG_RESET_CTRL_1_CTL_RESET_1_D0_CPU_SSI_SLAVE1_SSI_RSTN_REG;
624 WR_WORD(GLOBAL_REG_RESET_CTRL_1, reg);
626 reg |= GLOBAL_REG_RESET_CTRL_1_CTL_RESET_1_D0_CPU_SSI_MASTER1_SSI_RSTN_REG;
629 reg |= GLOBAL_REG_RESET_CTRL_1_CTL_RESET_1_D0_CPU_SSI_SLAVE0_SSI_RSTN_REG;
631 reg |= GLOBAL_REG_RESET_CTRL_1_CTL_RESET_1_D0_CPU_SSI_SLAVE1_SSI_RSTN_REG;
633 WR_WORD(GLOBAL_REG_RESET_CTRL_1, reg);
636 static INLINE
int qspi_is_xip_enable(
void)
638 return ((RD_WORD(SPIFLASH_REG_SPIFLASH_MISC_CTRL) & SPIFLASH_REG_SPIFLASH_MISC_CTRL_CTL_SPI_APB_MUX_SEL) ? 1:0);
642 static INLINE
void qspi_reset(
void)
644 uint32_t reg = RD_WORD(GLOBAL_REG_RESET_CTRL_1);
647 reg &= ~GLOBAL_REG_RESET_CTRL_1_CTL_RESET_1_D0_CPU_SSI_MASTER0_SSI_RSTN_REG;
648 WR_WORD(GLOBAL_REG_RESET_CTRL_1, reg);
649 reg |= GLOBAL_REG_RESET_CTRL_1_CTL_RESET_1_D0_CPU_SSI_MASTER0_SSI_RSTN_REG;
650 WR_WORD(GLOBAL_REG_RESET_CTRL_1, reg);
670 void *
hal_spi_open(
int id,
int speed,
int phase,
int polarity,
int prio);
672 void *hal_spi_open_dma(
int id,
int speed,
int phase,
int polarity,
int prio);
685 int hal_spi_close_dma(
void *hdl);
724 int hal_spi_tx_non_block(
void *hdl,
int cs,
int dfs,
void *buffer, uint16_t buffer_len,
void *arg,
void (*callback)(
void *arg,
int status, uint16_t size));
725 int hal_spi_tx_block(
void *hdl,
int cs,
int dfs,
void *buffer, uint16_t buffer_len, uint32_t tmo, uint16_t *actual_size);
726 int hal_spi_tx_dma_block(
void *hdl,
int cs,
int dfs,
void *buffer, uint16_t buffer_len, uint32_t tmo, uint16_t *actual_size);
727 int hal_spi_tx_dma_non_block(
void *hdl,
int cs,
int dfs,
void *buffer, uint16_t buffer_len,
void *arg,
void (*callback)(
void *arg,
int status, uint16_t actual_size));
753 int hal_spi_rx_non_block(
void *hdl,
int cs,
int dfs,
void *buffer, uint16_t buffer_len,
void *arg,
void (*callback)(
void *arg,
int status, uint16_t size));
754 int hal_spi_rx_block(
void *hdl,
int cs,
int dfs,
void *buffer, uint16_t buffer_len, uint32_t tmo, uint16_t *actual_size);
755 int hal_spi_rx_dma_block(
void *hdl,
int cs,
int dfs,
void *buffer, uint16_t buffer_len, uint32_t tmo, uint16_t *actual_size);
756 int hal_spi_rx_dma_non_block(
void *hdl,
int cs,
int dfs,
void *buffer, uint16_t buffer_len,
void *arg,
void (*callback)(
void *arg,
int status, uint16_t actual_size));
786 int hal_spi_trx_non_block(
void *hdl,
int cs,
int dfs,
void *wbuf,
void *rbuf, uint16_t buf_len,
void *arg,
void (*callback)(
void *arg,
int status, uint16_t actual_size));
787 int hal_spi_trx_block(
void *hdl,
int cs,
int dfs,
void *wbuf,
void *rbuf, uint16_t buf_len, uint32_t tmo, uint16_t *actual_size);
788 int hal_spi_trx_dma_block(
void *hdl,
int cs,
int dfs,
void *wbuf,
void *rbuf, uint16_t buffer_len, uint32_t tmo, uint16_t *actual_size);
789 int hal_spi_trx_dma_non_block(
void *hdl,
int cs,
int dfs,
void *wbuf,
void *rbuf, uint16_t buffer_len,
void *arg,
void (*callback)(
void *arg,
int status, uint16_t actual_size));
817 int hal_spi_tx_dma(
void *hdl,
int cs,
void *buffer, uint16_t buffer_len, uint16_t *actual_size);
841 int hal_spi_rx_dma(
void *hdl,
int cs,
void *buffer, uint16_t buffer_len, uint16_t *actual_size);
869 int hal_spi_trx_dma(
void *hdl,
int cs,
void *wbuf,
void *rbuf, uint16_t buffer_len, uint16_t *actual_size);
898 int hal_slv_spi_tx(
void *hdl,
int phase,
int polarity,
int dfs,
void *buf, uint16_t buf_len, uint16_t *wlen);
920 int hal_slv_spi_rx(
void *hdl,
int phase,
int polarity,
int dfs,
void *buf, uint16_t buf_len, uint16_t *rlen);
947 int hal_slv_spi_trx(
void *hdl,
int phase,
int polarity,
int dfs,
void *wbuf,
void *rbuf, uint16_t buf_len, uint16_t* wlen, uint16_t *rlen);
1003 int hal_spi_trx_dma_chain_start(
void *hdl,
int cs,
int speed,
int phase,
int polarity,
int dfs,
void *wbuf[2],
void *rbuf[2], uint16_t buffer_len,
void *arg,
void (*callback)(
void *arg,
int dir,
int id,
int status));
1019 int hal_spiflash_trx_dma(
void *h,
int cs,
int speed,
void *wbuf, uint16_t wbuf_len,
void *rbuf, uint16_t rbuf_len,
void *arg,
void (*comp_cb)(
void *arg,
int status));
int hal_spi_close(void *hdl)
Close the SPI driver.
qspi_addr_width
Dual or Quad SPI address width.
Definition: hal_spi.h:211
int hal_spi_trx_dma_chain_start(void *hdl, int cs, int speed, int phase, int polarity, int dfs, void *wbuf[2], void *rbuf[2], uint16_t buffer_len, void *arg, void(*callback)(void *arg, int dir, int id, int status))
Master SPI Transmit and Receive DMA block chain function (bi-direction)
spi_id
SPI ID.
Definition: hal_spi.h:106
int hal_slv_spi_rx(void *hdl, int phase, int polarity, int dfs, void *buf, uint16_t buf_len, uint16_t *rlen)
Slave SPI Receive function.
Standard.
Definition: hal_spi.h:118
int hal_spi_trx_non_block(void *hdl, int cs, int dfs, void *wbuf, void *rbuf, uint16_t buf_len, void *arg, void(*callback)(void *arg, int status, uint16_t actual_size))
Master or Slave SPI Transmit and Receive function (bi-direction)
void hal_slv_spi_stop(void *hdl)
Slave SPI stop function.
qspi_ttype
Quad SPI command and address transfer type.
Definition: hal_spi.h:231
int hal_spi_busy(void *hdl)
Get SPI busy status.
spi_err
SPI error code.
Definition: hal_spi.h:173
spi_dir
SPI DMA direction.
Definition: hal_spi.h:188
Slave SPI Id.
Definition: hal_spi.h:110
Dual format with 2 data wire.
Definition: hal_spi.h:120
spi_mstr_cs
SPI CS (master only)
Definition: hal_spi.h:194
int hal_spi_tx_dma(void *hdl, int cs, void *buffer, uint16_t buffer_len, uint16_t *actual_size)
Master or Slave SPI transmit DMA function.
Master SPI Id.
Definition: hal_spi.h:108
qspi_cmd_width
Dual or Quad SPI command width.
Definition: hal_spi.h:203
int hal_spi_rx_dma(void *hdl, int cs, void *buffer, uint16_t buffer_len, uint16_t *actual_size)
Master or Slave SPI Receive DMA function.
int hal_spi_int_prio(void *hdl, int prio)
Set SPI interrupt priority.
int hal_spi_rx_non_block(void *hdl, int cs, int dfs, void *buffer, uint16_t buffer_len, void *arg, void(*callback)(void *arg, int status, uint16_t size))
Master or Slave SPI Receive function.
Quad format with 4 data wire.
Definition: hal_spi.h:122
int hal_slv_spi_trx(void *hdl, int phase, int polarity, int dfs, void *wbuf, void *rbuf, uint16_t buf_len, uint16_t *wlen, uint16_t *rlen)
Slave SPI Transmit and Receive function (bi-direction)
Tranfer in TX mode only.
Definition: hal_spi.h:130
int hal_spi_trx_dma(void *hdl, int cs, void *wbuf, void *rbuf, uint16_t buffer_len, uint16_t *actual_size)
Master or Slave SPI Transmit and Receive DMA function (bi-direction)
Transfer in RX mode only.
Definition: hal_spi.h:132
Slave SPI Id.
Definition: hal_spi.h:112
spi_tmod
SPI transfer mode.
Definition: hal_spi.h:126
Transfer in bi-direction mode.
Definition: hal_spi.h:128
spi_dfs_bit
SPI data frame size.
Definition: hal_spi.h:139
Transfer in EEPROM.
Definition: hal_spi.h:134
spi_fmt
SPI format.
Definition: hal_spi.h:116
int hal_slv_spi_tx(void *hdl, int phase, int polarity, int dfs, void *buf, uint16_t buf_len, uint16_t *wlen)
Slave SPI transmit function.
int hal_spi_trx_dma_chain_stop(void *hdl)
Master or Slave SPI Transmit and Receive DMA block chain function (bi-direction)
int hal_spi_tx_non_block(void *hdl, int cs, int dfs, void *buffer, uint16_t buffer_len, void *arg, void(*callback)(void *arg, int status, uint16_t size))
Master or Slave SPI transmit function.
void * hal_spi_open(int id, int speed, int phase, int polarity, int prio)
Open the SPI driver.