void spi_transceive_dma(void *data_send1, void *data_recv1, uint16_t len1, void *data_send2, void *data_recv2, uint16_t len2) { SPI_PdcSetTx(SPI, data_send1, len1, data_send2, len2); SPI_PdcSetRx(SPI, data_recv1, len1, data_recv2, len2); // Enable RX and TX DMA transfer requests SPI_PdcEnableRx(SPI); SPI_PdcEnableTx(SPI); }
/** * \brief Perform SPI slave transfer using PDC. * \param pBuf Pointer to 1st buffer to transfer. * \param size Size of the 1st buffer. * \param pNextBuf Pointer to 2nd buffer to transfer. * \param nextSize Size of the 2nd buffer. */ static void SpiSlaveTransfer( void* pBuf, uint16_t size, void* pNextBuf, uint16_t nextSize ) { uint32_t spiIER ; SPI_PdcSetTx( SPI_SLAVE_BASE, pBuf, size, pNextBuf, nextSize ) ; SPI_PdcSetRx( SPI_SLAVE_BASE, pBuf, size, pNextBuf, nextSize ) ; /* Enable the RX and TX PDC transfer requests */ SPI_PdcEnableRx( SPI_SLAVE_BASE ) ; SPI_PdcEnableTx( SPI_SLAVE_BASE ) ; /* Transfer done handler is in ISR ... */ spiIER = SPI_IER_NSSR | SPI_IER_RXBUFF | (pNextBuf ? SPI_IER_ENDRX : 0) ; SPI_EnableIt( SPI_SLAVE_BASE, spiIER ) ; }
/** * \brief Perform SPI master transfer using PDC. * \param pBuf Pointer to 1st buffer to transfer. * \param size Size of the 1st buffer. * \param pNextBuf Pointer to 2nd buffer to transfer. * \param nextSize Size of the 2nd buffer. */ static void SpiMasterTransfer( void * pBuf, uint16_t size, void * pNextBuf, uint16_t nextSize ) { SPI_PdcSetTx(SPI_MASTER_BASE, pBuf, size, pNextBuf, nextSize); SPI_PdcSetRx(SPI_MASTER_BASE, pBuf, size, pNextBuf, nextSize); /* Enable the RX and TX PDC transfer requests */ SPI_PdcEnableRx(SPI_MASTER_BASE); SPI_PdcEnableTx(SPI_MASTER_BASE); /* Waiting transfer done*/ while((SPI_GetStatus(SPI_MASTER_BASE)& SPI_SR_RXBUFF) == 0); /* Disable the RX and TX PDC transfer requests */ SPI_PdcDisableTx(SPI_MASTER_BASE); SPI_PdcDisableRx(SPI_MASTER_BASE); }