Azure Sphere MT3620 M4 API Reference Manual
|
This section provides Fixed APIs(defined as Common Interface) to fully control the MediaTek SPIM HW. More...
This section provides Fixed APIs(defined as Common Interface) to fully control the MediaTek SPIM HW.
Functions | |
int | mtk_mhal_spim_dump_reg (struct mtk_spi_controller *ctlr) |
This function is used to dump spi register for debugging. More... | |
int | mtk_mhal_spim_clear_irq_status (struct mtk_spi_controller *ctlr) |
This function is used to clear SPIM HW status. More... | |
int | mtk_mhal_spim_fifo_handle_rx (struct mtk_spi_controller *ctlr, struct mtk_spi_transfer *xfer) |
This function is used to read FIFO data from SPIM HW. More... | |
int | mtk_mhal_spim_prepare_hw (struct mtk_spi_controller *ctlr, struct mtk_spi_config *config) |
This function is used to initialize SPIM HW based on *config settings. More... | |
int | mtk_mhal_spim_prepare_transfer (struct mtk_spi_controller *ctlr, struct mtk_spi_transfer *xfer) |
This function is used to initialize SPIM based on mtk_spi_transfer setting. More... | |
int | mtk_mhal_spim_fifo_transfer_one (struct mtk_spi_controller *ctlr, struct mtk_spi_transfer *xfer) |
This function is used to perform a single mtk_spi_transfer by FIFO mode. More... | |
int | mtk_mhal_spim_dma_done_callback_register (struct mtk_spi_controller *ctlr, spi_dma_done_callback callback, void *user_data) |
This function is used to register user's DMA callback to M-HAL. More... | |
int | mtk_mhal_spim_dma_transfer_one (struct mtk_spi_controller *ctlr, struct mtk_spi_transfer *xfer) |
This function is used to perform a single mtk_spi_transfer by DMA mode. More... | |
int | mtk_mhal_spim_allocate_dma_chan (struct mtk_spi_controller *ctlr) |
This function is used to allocate SPIM DMA channel. More... | |
int | mtk_mhal_spim_release_dma_chan (struct mtk_spi_controller *ctlr) |
This function is used to release SPIM DMA channel. More... | |
int | mtk_mhal_spim_enable_clk (struct mtk_spi_controller *ctlr) |
This function is used to enable SPIM clock before transfer. More... | |
int | mtk_mhal_spim_disable_clk (struct mtk_spi_controller *ctlr) |
This function is used to disable SPIM clock before transfer. More... | |
int mtk_mhal_spim_dump_reg | ( | struct mtk_spi_controller * | ctlr | ) |
This function is used to dump spi register for debugging.
Usage:Used for OS-HAL to dump SPIM register.
[in] | ctlr | : SPI controller used with the device. |
int mtk_mhal_spim_clear_irq_status | ( | struct mtk_spi_controller * | ctlr | ) |
This function is used to clear SPIM HW status.
Usage: It's called in irq function to clear SPIM HW irq status.
[in] | ctlr | : SPI controller used with the device. |
int mtk_mhal_spim_fifo_handle_rx | ( | struct mtk_spi_controller * | ctlr, |
struct mtk_spi_transfer * | xfer | ||
) |
This function is used to read FIFO data from SPIM HW.
Usage: it must be called in irq function with FIFO mode. while using FIFO mode, read rx FIFO register and copy data to xfer->rx_buffer.
[in] | ctlr | : SPI controller used with the device. |
[in] | xfer | : the read/write buffer pair user should transfer. |
int mtk_mhal_spim_prepare_hw | ( | struct mtk_spi_controller * | ctlr, |
struct mtk_spi_config * | config | ||
) |
This function is used to initialize SPIM HW based on *config settings.
Usage: Use *config setting to init HW. It must be called before transferring.
[in] | ctlr | : SPI controller used with the device. |
[in] | config | : HW setting |
int mtk_mhal_spim_prepare_transfer | ( | struct mtk_spi_controller * | ctlr, |
struct mtk_spi_transfer * | xfer | ||
) |
This function is used to initialize SPIM based on mtk_spi_transfer setting.
Usage: Initialize HW according to *xfer arg(such as speed). It must be called before transferring.
[in] | ctlr | : SPI controller used with the device. |
[in] | xfer | : The read/write buffer pair user should transfer. |
int mtk_mhal_spim_fifo_transfer_one | ( | struct mtk_spi_controller * | ctlr, |
struct mtk_spi_transfer * | xfer | ||
) |
This function is used to perform a single mtk_spi_transfer by FIFO mode.
Usage: this function triggers SPIM HW to perform a single mtk_spi_transfer.
while the function returns, the transfer may not be completed.
So OS-HAL should wait for SPIM HW irq to be finished (maybe use semaphore).
[in] | ctlr | : SPI controller used with the device. |
[in] | xfer | : The read/write buffer pair user should transfer. |
int mtk_mhal_spim_dma_done_callback_register | ( | struct mtk_spi_controller * | ctlr, |
spi_dma_done_callback | callback, | ||
void * | user_data | ||
) |
This function is used to register user's DMA callback to M-HAL.
It's used for DMA mode transaction. In DMA mode, mtk_mhal_spim_dma_transfer_one() returns a value once the SPI hardware register is assigned and the DMA is configured.
During this process the transaction is usually not completed, once it is completed, a DMA interrupt is triggered and a related user callback is called in the DMA interrupt service routine.
[in] | ctlr | : SPI controller used with the device. |
[in] | callback | : The callback function given by OS-HAL which will be called at SPI master's DMA interrupt service routine. |
[in] | user_data | : A parameter given by OS-HAL and will be passed to user when the callback function is called. |
int mtk_mhal_spim_dma_transfer_one | ( | struct mtk_spi_controller * | ctlr, |
struct mtk_spi_transfer * | xfer | ||
) |
This function is used to perform a single mtk_spi_transfer by DMA mode.
Usage: This function triggers SPIM HW to perform a single mtk_spi_transfer. When the function returns, the transfer may not be completed. So OS-HAL should wait for SPIM HW irq to be finished (maybe use semaphore).
[in] | ctlr | : SPI controller used with the device. |
[in] | xfer | : The read/write buffer pair user should transfer. |
int mtk_mhal_spim_allocate_dma_chan | ( | struct mtk_spi_controller * | ctlr | ) |
This function is used to allocate SPIM DMA channel.
Usage: User should call it to allocate DMA channel after call #mtk_mhal_spim_alloc_controller and set dma_chan in initial flow.
[in] | ctlr | : SPI controller used with the device. |
int mtk_mhal_spim_release_dma_chan | ( | struct mtk_spi_controller * | ctlr | ) |
This function is used to release SPIM DMA channel.
Usage: user should call it to release DMA channel before call #mtk_mhal_spim_release_controller in de-initial flow.
[in] | ctlr | : SPI controller used with the device. |
int mtk_mhal_spim_enable_clk | ( | struct mtk_spi_controller * | ctlr | ) |
This function is used to enable SPIM clock before transfer.
Usage: It must be called to enable clock before transferring, otherwise the access to SPIM register will fail .
[in] | ctlr | : SPI controller used with the device. |
int mtk_mhal_spim_disable_clk | ( | struct mtk_spi_controller * | ctlr | ) |
This function is used to disable SPIM clock before transfer.
Usage: It needs to be called after transfer to disable clock.
[in] | ctlr | : SPIM controller used with the device. |