Azure Sphere MT3620 M4 API Reference Manual
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Function

This section provides high level APIs to upper layer. More...

Overview

This section provides high level APIs to upper layer.

Functions

int mtk_os_hal_spim_dump_reg (spim_num bus_num)
 Dump SPIM register value. More...
 
int mtk_os_hal_spim_ctlr_init (spim_num bus_num)
 Init SPIM controller. More...
 
int mtk_os_hal_spim_ctlr_deinit (spim_num bus_num)
 Deinit SPIM controller. More...
 
int mtk_os_hal_spim_transfer (spim_num bus_num, struct mtk_spi_config *config, struct mtk_spi_transfer *xfer)
 use FIFO or DMA mode to do one blocking/synchronous SPI data transfer. More...
 
int mtk_os_hal_spim_async_transfer (spim_num bus_num, struct mtk_spi_config *config, struct mtk_spi_transfer *xfer, spi_usr_complete_callback complete, void *context)
 use FIFO or DMA mode to do one asynchronous SPI transfer. More...
 

Function Documentation

int mtk_os_hal_spim_dump_reg ( spim_num  bus_num)

Dump SPIM register value.

Parameters
[in]bus_num: SPIM ISU Port number, it can be OS_HAL_SPIM_ISU0~OS_HAL_SPIM_ISU4
Returns
negative value means fail.
0 means success.
int mtk_os_hal_spim_ctlr_init ( spim_num  bus_num)

Init SPIM controller.

Parameters
[in]bus_num: SPIM ISU Port number, it can be OS_HAL_SPIM_ISU0~OS_HAL_SPIM_ISU4
Returns
negative value means fail.
0 means success.
int mtk_os_hal_spim_ctlr_deinit ( spim_num  bus_num)

Deinit SPIM controller.

Parameters
[in]bus_num: SPIM ISU Port number, it can be OS_HAL_SPIM_ISU0~OS_HAL_SPIM_ISU4
Returns
negative value means fail.
0 means success.
int mtk_os_hal_spim_transfer ( spim_num  bus_num,
struct mtk_spi_config config,
struct mtk_spi_transfer xfer 
)

use FIFO or DMA mode to do one blocking/synchronous SPI data transfer.

Parameters
[in]bus_num: SPIM ISU Port number, it can be OS_HAL_SPIM_ISU0~OS_HAL_SPIM_ISU4
[in]config: the HW setting
[in]xfer: the data should be read/writen.

Note:

The transfer data format should be as belows:

  • Half-duplex transaction: There is only one valid transaction at a time on a single direction: either Send or Receive.
    • Send: Device driver should provide mtk_spi_transfer->opcode, mtk_spi_transfer->opcode_len, mtk_spi_transfer->tx_buf, mtk_spi_transfer->len and set mtk_spi_transfer->rx_buf = NULL. mtk_spi_transfer->opcode_len should be 1~4bytes, mtk_spi_transfer->len should be 0~32bytes.
    • Receive: Device driver should provide mtk_spi_transfer->opcode, mtk_spi_transfer->opcode_len, mtk_spi_transfer->rx_buf, mtk_spi_transfer->len and set mtk_spi_transfer->tx_buf = NULL. mtk_spi_transfer->opcode_len should be 0~4bytes, mtk_spi_transfer->len should be 1~32bytes.
  • Full-duplex transaction: There are two valid mutually inclusive transactions: Send and Receive.
    • Device driver should provide mtk_spi_transfer->len, mtk_spi_transfer->opcode, mtk_spi_transfer->opcode_len, mtk_spi_transfer->tx_buf and set mtk_spi_transfer->rx_buf at the same time.
    • mtk_spi_transfer->opcode_len should be 1~4bytes, mtk_spi_transfer->len should be 1~16bytes.
Returns
negative value means fail.
0 means success.
int mtk_os_hal_spim_async_transfer ( spim_num  bus_num,
struct mtk_spi_config config,
struct mtk_spi_transfer xfer,
spi_usr_complete_callback  complete,
void *  context 
)

use FIFO or DMA mode to do one asynchronous SPI transfer.

Parameters
[in]bus_num: SPIM ISU Port number, it can be OS_HAL_SPIM_ISU0~OS_HAL_SPIM_ISU4
[in]config: the HW setting
[in]xfer: the data should be read/writen.
[in]complete: called to report transaction completions
[in]context: the argument to complete() when it's called
Returns
negative value means fail.
0 means success.