Functions
Functions
Peripheral Driver » APP DRIVER » SPI

## Functions
uint16_t | app_spi_init (app_spi_params_t *p_params, app_spi_evt_handler_t evt_handler)
| Initialize the APP SPI DRIVER according to the specified parameters in the app_spi_params_t and app_spi_evt_handler_t. More...
uint16_t | app_spi_deinit (app_spi_id_t id)
| De-initialize the APP SPI DRIVER peripheral. More...
uint16_t | app_spi_abort (app_spi_id_t id)
| Abort spi communication with Interrupt. More...
uint16_t | app_spim_transmit_with_ia (app_spi_id_t id, uint8_t instruction, uint32_t address, uint8_t *p_data, uint16_t data_length)
| SPI master transmit with 1-byte inst and 3-byte addr, can use to write flash/display/eeprom, etc. More...
uint16_t | app_spim_receive_with_ia (app_spi_id_t id, uint8_t instruction, uint32_t address, uint8_t dummy_bytes, uint8_t *p_data, uint16_t data_length)
| SPI master receive with 1-byte inst and 3-byte addr and 0~4 dummy Byte, can use to read flash/display/eeprom, etc. More...
uint16_t | app_spi_receive_sync (app_spi_id_t id, uint8_t *p_data, uint16_t size, uint32_t timeout)
| Receive in master or slave mode an amount of data in blocking mode. More...
uint16_t | app_spi_receive_async (app_spi_id_t id, uint8_t *p_data, uint16_t size)
| Receive in master or slave mode an amount of data in non-blocking mode with Interrupt. More...
uint16_t | app_spi_transmit_sync (app_spi_id_t id, uint8_t *p_data, uint16_t size, uint32_t timeout)
| Transmits in master or slave mode an amount of data in blocking mode. More...
uint16_t | app_spi_transmit_async (app_spi_id_t id, uint8_t *p_data, uint16_t size)
| Transmits in master or slave mode an amount of data in non-blocking mode with Interrupt. More...
uint16_t | app_spi_transmit_receive_sync (app_spi_id_t id, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t size, uint32_t timeout)
| Transmits and receive in master or slave mode an amount of data in blocking mode. More...
uint16_t | app_spi_transmit_receive_async (app_spi_id_t id, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t size)
| Transmits and receive in master or slave mode an amount of data in non-blocking mode with Interrupt. More...
uint16_t | app_spi_read_eeprom_sync (app_spi_id_t id, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_size, uint32_t rx_size, uint32_t timeout)
| Read an amount of data from EEPROM in blocking mode. More...
uint16_t | app_spi_read_eeprom_async (app_spi_id_t id, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_size, uint32_t rx_size)
| Read an amount of data from EEPROM in non-blocking mode with Interrupt. More...
spi_handle_t * | app_spi_get_handle (app_spi_id_t id)
| Return the SPI handle. More...
uint16_t | app_spi_write_memory_async (app_spi_id_t id, uint8_t *p_cmd_data, uint8_t *p_tx_data, uint32_t cmd_size, uint32_t tx_size)
| Transmits in master or slave mode an amount of data in non-blocking mode with DMA. More...
uint16_t | app_spi_read_memory_async (app_spi_id_t id, uint8_t *p_cmd_data, uint8_t *p_rx_data, uint32_t cmd_size, uint32_t rx_size)
| Read an amount of data from EEPROM in non-blocking mode with DMA. More...
uint16_t | app_spi_receive_high_speed_sync (app_spi_id_t id, uint8_t *p_data, uint16_t size)
| [High speed] Receive in master or slave mode an amount of data in blocking mode. More...
uint16_t | app_spi_transmit_high_speed_sync (app_spi_id_t id, uint8_t *p_data, uint16_t size)
| [High speed] Transmit in master or slave mode an amount of data in blocking mode. More...
uint16_t | app_spi_dma_init (app_spi_params_t *p_params)
| Initialize the APP SPI DRIVER according to the specified parameters in the app_spi_params_t and app_spi_evt_handler_t. More...
uint16_t | app_spi_dma_deinit (app_spi_id_t id)
| De-initialize the APP SPI DRIVER peripheral. More...
uint16_t | app_spim_dma_transmit_with_ia (app_spi_id_t id, uint8_t instruction, uint32_t address, uint8_t *p_data, uint16_t data_length)
| SPI master transmit with 1-byte inst and 3-byte addr, can use to write flash/display/eeprom, etc. More...
uint16_t | app_spim_dma_receive_with_ia (app_spi_id_t id, uint8_t instruction, uint32_t address, uint8_t dummy_bytes, uint8_t *p_data, uint16_t data_length)
| SPI master receive with 1-byte inst and 3-byte addr and 0~4 dummy Byte, can use to read flash/display/eeprom, etc. More...
uint16_t | app_spi_dma_receive_async (app_spi_id_t id, uint8_t *p_data, uint16_t size)
| Receive in master or slave mode an amount of data in non-blocking mode with Interrupt. More...
uint16_t | app_spi_dma_transmit_async (app_spi_id_t id, uint8_t *p_data, uint16_t size)
| Transmits in master or slave mode an amount of data in non-blocking mode with Interrupt. More...
uint16_t | app_spi_dma_transmit_receive_async (app_spi_id_t id, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t size)
| Transmits and receive in master or slave mode an amount of data in non-blocking mode with Interrupt. More...
uint16_t | app_spi_dma_read_eeprom_async (app_spi_id_t id, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_size, uint32_t rx_size)
| Read an amount of data from EEPROM in non-blocking mode with Interrupt. More...
uint16_t | app_spi_dma_write_memory_async (app_spi_id_t id, uint8_t *p_cmd_data, uint8_t *p_tx_data, uint32_t cmd_size, uint32_t tx_size)
| Transmits in master or slave mode an amount of data in non-blocking mode with DMA. More...
uint16_t | app_spi_dma_read_memory_async (app_spi_id_t id, uint8_t *p_cmd_data, uint8_t *p_rx_data, uint32_t cmd_size, uint32_t rx_size)
| Read an amount of data from EEPROM in non-blocking mode with DMA. More...
uint16_t | app_spi_dma_receive_high_speed_sync (app_spi_id_t id, uint8_t *p_data, uint16_t size)
| [High speed] Receive in master or slave mode an amount of data in blocking mode. More...
uint16_t | app_spi_dma_transmit_high_speed_sync (app_spi_id_t id, uint8_t *p_data, uint16_t size)
| [High speed] Transmit in master or slave mode an amount of data in blocking mode. More...

## Detailed Description

## Function Documentation

## ◆ app_spi_abort()

uint16_t app_spi_abort | ( | app_spi_id_t | id | ) |

Abort spi communication with Interrupt.

Parameters

  [in] | id | SPI module ID.

Returns
  Result of operation.

## ◆ app_spi_deinit()

uint16_t app_spi_deinit | ( | app_spi_id_t | id | ) |

De-initialize the APP SPI DRIVER peripheral.

Parameters

  [in] | id | De-initialize for a specific ID.

Returns
  Result of De-initialization.

## ◆ app_spi_dma_deinit()

uint16_t app_spi_dma_deinit | ( | app_spi_id_t | id | ) |

De-initialize the APP SPI DRIVER peripheral.

Parameters

  [in] | id | De-initialize for a specific ID.

Returns
  Result of De-initialization.

## ◆ app_spi_dma_init()

uint16_t app_spi_dma_init | ( | app_spi_params_t * | p_params | ) |

Initialize the APP SPI DRIVER according to the specified parameters in the app_spi_params_t and app_spi_evt_handler_t.

Note
  If interrupt mode is set, you can use blocking mode. Conversely, if blocking mode is set, you can't use interrupt mode.

Parameters

  [in] | p_params | Pointer to app_spi_params_t parameter which contains the configuration information for the specified SPI module.

Returns
  Result of initialization.

## ◆ app_spi_dma_read_eeprom_async()

uint16_t app_spi_dma_read_eeprom_async | ( | app_spi_id_t | id,
|  | uint8_t * | p_tx_data,
|  | uint8_t * | p_rx_data,
|  | uint32_t | tx_size,
|  | uint32_t | rx_size
| ) |  |

Read an amount of data from EEPROM in non-blocking mode with Interrupt.

Parameters

  [in] | id | which SPI module want to transmit.
  [in] | p_tx_data | Pointer to transmission data buffer
  [out] | p_rx_data | Pointer to reception data buffer
  [in] | tx_size | Amount of data to be sent in bytes
  [in] | rx_size | Amount of data to be received in bytes

Returns
  Result of operation.

## ◆ app_spi_dma_read_memory_async()

uint16_t app_spi_dma_read_memory_async | ( | app_spi_id_t | id,
|  | uint8_t * | p_cmd_data,
|  | uint8_t * | p_rx_data,
|  | uint32_t | cmd_size,
|  | uint32_t | rx_size
| ) |  |

Read an amount of data from EEPROM in non-blocking mode with DMA.

Parameters

  [in] | id | which SPI module want to transmit.
  [in] | p_cmd_data | Pointer to command data buffer
  [out] | p_rx_data | Pointer to reception data buffer
  [in] | cmd_size | Amount of command data to be sent in bytes
  [in] | rx_size | Amount of data to be received in bytes

Returns
  Result of operation.

## ◆ app_spi_dma_receive_async()

uint16_t app_spi_dma_receive_async | ( | app_spi_id_t | id,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

Receive in master or slave mode an amount of data in non-blocking mode with Interrupt.

Parameters

  [in] | id | which SPI module want to receive.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_spi_dma_receive_high_speed_sync()

uint16_t app_spi_dma_receive_high_speed_sync | ( | app_spi_id_t | id,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

[High speed] Receive in master or slave mode an amount of data in blocking mode.

Parameters

  [in] | id | which SPI module want to receive.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_spi_dma_transmit_async()

uint16_t app_spi_dma_transmit_async | ( | app_spi_id_t | id,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

Transmits in master or slave mode an amount of data in non-blocking mode with Interrupt.

Parameters

  [in] | id | which SPI module want to transmit.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_spi_dma_transmit_high_speed_sync()

uint16_t app_spi_dma_transmit_high_speed_sync | ( | app_spi_id_t | id,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

[High speed] Transmit in master or slave mode an amount of data in blocking mode.

Parameters

  [in] | id | which SPI module want to receive.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_spi_dma_transmit_receive_async()

uint16_t app_spi_dma_transmit_receive_async | ( | app_spi_id_t | id,
|  | uint8_t * | p_tx_data,
|  | uint8_t * | p_rx_data,
|  | uint32_t | size
| ) |  |

Transmits and receive in master or slave mode an amount of data in non-blocking mode with Interrupt.

Parameters

  [in] | id | which SPI module want to transmit.
  [in] | p_tx_data | Pointer to tx data buffer
  [in] | p_rx_data | Pointer to rx data buffer
  [in] | size | Amount of data to be sent and receive

Returns
  Result of operation.

## ◆ app_spi_dma_write_memory_async()

uint16_t app_spi_dma_write_memory_async | ( | app_spi_id_t | id,
|  | uint8_t * | p_cmd_data,
|  | uint8_t * | p_tx_data,
|  | uint32_t | cmd_size,
|  | uint32_t | tx_size
| ) |  |

Transmits in master or slave mode an amount of data in non-blocking mode with DMA.

Parameters

  [in] | id | which SPI module want to transmit.
  [in] | p_cmd_data | Pointer to command data buffer
  [in] | p_tx_data | Pointer to transmission data buffer
  [in] | cmd_size | Amount of command data to be sent in bytes
  [in] | tx_size | Amount of data to be sent in bytes

Returns
  Result of operation.

## ◆ app_spi_get_handle()

spi_handle_t* app_spi_get_handle | ( | app_spi_id_t | id | ) |

Return the SPI handle.

Parameters

  [in] | id | SPI Channel ID.

Returns
  Pointer to the specified ID's SPI handle.

## ◆ app_spi_init()

uint16_t app_spi_init | ( | app_spi_params_t * | p_params,
|  | app_spi_evt_handler_t | evt_handler
| ) |  |

Initialize the APP SPI DRIVER according to the specified parameters in the app_spi_params_t and app_spi_evt_handler_t.

Note
  If interrupt mode is set, you can use blocking mode. Conversely, if blocking mode is set, you can't use interrupt mode.

Parameters

  [in] | p_params | Pointer to app_spi_params_t parameter which contains the configuration information for the specified SPI module.
  [in] | evt_handler | SPI user callback function.

Returns
  Result of initialization.

## ◆ app_spi_read_eeprom_async()

uint16_t app_spi_read_eeprom_async | ( | app_spi_id_t | id,
|  | uint8_t * | p_tx_data,
|  | uint8_t * | p_rx_data,
|  | uint32_t | tx_size,
|  | uint32_t | rx_size
| ) |  |

Read an amount of data from EEPROM in non-blocking mode with Interrupt.

Parameters

  [in] | id | which SPI module want to transmit.
  [in] | p_tx_data | Pointer to transmission data buffer
  [out] | p_rx_data | Pointer to reception data buffer
  [in] | tx_size | Amount of data to be sent in bytes
  [in] | rx_size | Amount of data to be received in bytes

Returns
  Result of operation.

## ◆ app_spi_read_eeprom_sync()

uint16_t app_spi_read_eeprom_sync | ( | app_spi_id_t | id,
|  | uint8_t * | p_tx_data,
|  | uint8_t * | p_rx_data,
|  | uint32_t | tx_size,
|  | uint32_t | rx_size,
|  | uint32_t | timeout
| ) |  |

Read an amount of data from EEPROM in blocking mode.

Parameters

  [in] | id | which SPI module want to transmit.
  [in] | p_tx_data | Pointer to transmission data buffer
  [out] | p_rx_data | Pointer to reception data buffer
  [in] | tx_size | Amount of data to be sent in bytes
  [in] | rx_size | Amount of data to be received in bytes
  [in] | timeout | Timeout duration

Returns
  Result of operation.

## ◆ app_spi_read_memory_async()

uint16_t app_spi_read_memory_async | ( | app_spi_id_t | id,
|  | uint8_t * | p_cmd_data,
|  | uint8_t * | p_rx_data,
|  | uint32_t | cmd_size,
|  | uint32_t | rx_size
| ) |  |

Read an amount of data from EEPROM in non-blocking mode with DMA.

Parameters

  [in] | id | which SPI module want to transmit.
  [in] | p_cmd_data | Pointer to command data buffer
  [out] | p_rx_data | Pointer to reception data buffer
  [in] | cmd_size | Amount of command data to be sent in bytes
  [in] | rx_size | Amount of data to be received in bytes

Returns
  Result of operation.

## ◆ app_spi_receive_async()

uint16_t app_spi_receive_async | ( | app_spi_id_t | id,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

Receive in master or slave mode an amount of data in non-blocking mode with Interrupt.

Parameters

  [in] | id | which SPI module want to receive.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_spi_receive_high_speed_sync()

uint16_t app_spi_receive_high_speed_sync | ( | app_spi_id_t | id,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

[High speed] Receive in master or slave mode an amount of data in blocking mode.

Parameters

  [in] | id | which SPI module want to receive.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_spi_receive_sync()

uint16_t app_spi_receive_sync | ( | app_spi_id_t | id,
|  | uint8_t * | p_data,
|  | uint16_t | size,
|  | uint32_t | timeout
| ) |  |

Receive in master or slave mode an amount of data in blocking mode.

Parameters

  [in] | id | which SPI module want to receive.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent
  [in] | timeout | Timeout duration

Returns
  Result of operation.

## ◆ app_spi_transmit_async()

uint16_t app_spi_transmit_async | ( | app_spi_id_t | id,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

Transmits in master or slave mode an amount of data in non-blocking mode with Interrupt.

Parameters

  [in] | id | which SPI module want to transmit.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_spi_transmit_high_speed_sync()

uint16_t app_spi_transmit_high_speed_sync | ( | app_spi_id_t | id,
|  | uint8_t * | p_data,
|  | uint16_t | size
| ) |  |

[High speed] Transmit in master or slave mode an amount of data in blocking mode.

Parameters

  [in] | id | which SPI module want to receive.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent

Returns
  Result of operation.

## ◆ app_spi_transmit_receive_async()

uint16_t app_spi_transmit_receive_async | ( | app_spi_id_t | id,
|  | uint8_t * | p_tx_data,
|  | uint8_t * | p_rx_data,
|  | uint32_t | size
| ) |  |

Transmits and receive in master or slave mode an amount of data in non-blocking mode with Interrupt.

Parameters

  [in] | id | which SPI module want to transmit.
  [in] | p_tx_data | Pointer to tx data buffer
  [in] | p_rx_data | Pointer to rx data buffer
  [in] | size | Amount of data to be sent and receive

Returns
  Result of operation.

## ◆ app_spi_transmit_receive_sync()

uint16_t app_spi_transmit_receive_sync | ( | app_spi_id_t | id,
|  | uint8_t * | p_tx_data,
|  | uint8_t * | p_rx_data,
|  | uint32_t | size,
|  | uint32_t | timeout
| ) |  |

Transmits and receive in master or slave mode an amount of data in blocking mode.

Parameters

  [in] | id | which SPI module want to transmit.
  [in] | p_tx_data | Pointer to tx data buffer
  [in] | p_rx_data | Pointer to rx data buffer
  [in] | size | Amount of data to be sent and receive
  [in] | timeout | Timeout duration

Returns
  Result of operation.

## ◆ app_spi_transmit_sync()

uint16_t app_spi_transmit_sync | ( | app_spi_id_t | id,
|  | uint8_t * | p_data,
|  | uint16_t | size,
|  | uint32_t | timeout
| ) |  |

Transmits in master or slave mode an amount of data in blocking mode.

Parameters

  [in] | id | which SPI module want to transmit.
  [in] | p_data | Pointer to data buffer
  [in] | size | Amount of data to be sent
  [in] | timeout | Timeout duration

Returns
  Result of operation.

## ◆ app_spi_write_memory_async()

uint16_t app_spi_write_memory_async | ( | app_spi_id_t | id,
|  | uint8_t * | p_cmd_data,
|  | uint8_t * | p_tx_data,
|  | uint32_t | cmd_size,
|  | uint32_t | tx_size
| ) |  |

Transmits in master or slave mode an amount of data in non-blocking mode with DMA.

Parameters

  [in] | id | which SPI module want to transmit.
  [in] | p_cmd_data | Pointer to command data buffer
  [in] | p_tx_data | Pointer to transmission data buffer
  [in] | cmd_size | Amount of command data to be sent in bytes
  [in] | tx_size | Amount of data to be sent in bytes

Returns
  Result of operation.

## ◆ app_spim_dma_receive_with_ia()

uint16_t app_spim_dma_receive_with_ia | ( | app_spi_id_t | id,
|  | uint8_t | instruction,
|  | uint32_t | address,
|  | uint8_t | dummy_bytes,
|  | uint8_t * | p_data,
|  | uint16_t | data_length
| ) |  |

SPI master receive with 1-byte inst and 3-byte addr and 0~4 dummy Byte, can use to read flash/display/eeprom, etc.

Parameters

  [in] | id | : just support APP_SPI_ID_MASTER
  [in] | instruction | : 1-byte instruction phase
  [in] | address | : 3-byte address phase
  [in] | dummy_bytes | : dummy bytes, 0 ~ 4
  [in] | p_data | : pointer to transmit buffer
  [in] | data_length | : length of buffer, unit in byte

Returns
  APP_DRV_* in app_drv_error.h

## ◆ app_spim_dma_transmit_with_ia()

uint16_t app_spim_dma_transmit_with_ia | ( | app_spi_id_t | id,
|  | uint8_t | instruction,
|  | uint32_t | address,
|  | uint8_t * | p_data,
|  | uint16_t | data_length
| ) |  |

SPI master transmit with 1-byte inst and 3-byte addr, can use to write flash/display/eeprom, etc.

Note
  DO NOT Support interrupt mode

Parameters

  [in] | id | : just support APP_SPI_ID_MASTER
  [in] | instruction | : 1-byte instruction phase
  [in] | address | : 3-byte address phase
  [in] | p_data | : pointer to transmit buffer
  [in] | data_length | : length of buffer, unit in byte

Returns
  APP_DRV_* in app_drv_error.h

## ◆ app_spim_receive_with_ia()

uint16_t app_spim_receive_with_ia | ( | app_spi_id_t | id,
|  | uint8_t | instruction,
|  | uint32_t | address,
|  | uint8_t | dummy_bytes,
|  | uint8_t * | p_data,
|  | uint16_t | data_length
| ) |  |

SPI master receive with 1-byte inst and 3-byte addr and 0~4 dummy Byte, can use to read flash/display/eeprom, etc.

Parameters

  [in] | id | : just support APP_SPI_ID_MASTER
  [in] | instruction | : 1-byte instruction phase
  [in] | address | : 3-byte address phase
  [in] | dummy_bytes | : dummy bytes, 0 ~ 4
  [in] | p_data | : pointer to transmit buffer
  [in] | data_length | : length of buffer, unit in byte

Returns
  APP_DRV_* in app_drv_error.h

## ◆ app_spim_transmit_with_ia()

uint16_t app_spim_transmit_with_ia | ( | app_spi_id_t | id,
|  | uint8_t | instruction,
|  | uint32_t | address,
|  | uint8_t * | p_data,
|  | uint16_t | data_length
| ) |  |

SPI master transmit with 1-byte inst and 3-byte addr, can use to write flash/display/eeprom, etc.

Note
  DO NOT Support interrupt mode

Parameters

  [in] | id | : just support APP_SPI_ID_MASTER
  [in] | instruction | : 1-byte instruction phase
  [in] | address | : 3-byte address phase
  [in] | p_data | : pointer to transmit buffer
  [in] | data_length | : length of buffer, unit in byte

Returns
  APP_DRV_* in app_drv_error.h