HAL  v0.6.1
Hardware Abstraction Layer
Loading...
Searching...
No Matches
hal_spi.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include "hal_gpio.h"
Include dependency graph for hal_spi.h:

Data Structures

struct  spi_channel_attr_t
 
struct  spi_handle_t
 

Enumerations

enum  spi_result_t {
  SPI_RESULT_OK ,
  SPI_RESULT_INVALID ,
  SPI_RESULT_UNSUPPORTED ,
  SPI_RESULT_TIMEOUT ,
  SPI_RESULT_IDLE ,
  SPI_RESULT_BUSY ,
  SPI_RESULT_ERR ,
  TOTAL_SPI_RESULT
}
 
enum  spi_status_t {
  SPI_STATUS_UNKNOWN ,
  SPI_STATUS_OK ,
  SPI_STATUS_BUSY ,
  SPI_STATUS_STOP ,
  SPI_STATUS_SENDING ,
  SPI_STATUS_RECEIVING ,
  SPI_STATUS_ERR ,
  TOTAL_SPI_STATUS
}
 
enum  spi_mode_t {
  SPI_MODE_MASTER ,
  SPI_MODE_SLAVE ,
  TOTAL_SPI_MODE
}
 
enum  spi_direction_t {
  SPI_DIRECTION_MSB_FIRST ,
  SPI_DIRECTION_LSB_FIRST ,
  TOTAL_SPI_DIRECTION
}
 

Functions

spi_result_t hal_spi_init (spi_handle_t *handle, const spi_channel_attr_t attr)
 Configure SPI channel with specific attributes.
 
spi_result_t hal_spi_write (spi_handle_t *handle, const uint8_t *tx_buffer, const size_t len)
 Write data to SPI bus.
 
spi_result_t hal_spi_read (spi_handle_t *handle, uint8_t *rx_buffer, const size_t len)
 Read data from SPI bus.
 
spi_result_t hal_spi_read_write (spi_handle_t *handle, const uint8_t *tx_buffer, uint8_t *rx_buffer, const size_t len)
 Simultaneous read and write operation.
 
spi_result_t hal_spi_stop (spi_handle_t *handle)
 Stop SPI operation.
 
spi_result_t hal_spi_mutex_take (const uint8_t channel, const uint32_t timeout_ms)
 Try acquire RTOS mutex for specified channel.
 
spi_result_t hal_spi_mutex_give (const uint8_t channel)
 Release RTOS mutex for specified channel.