Functions

static hal_spi_handlehal_spi_get_handle (KSPINum spi)
 Fetches SPI bus data structure. More...
 
static hal_spi_handlehal_spi_device_init (KSPI *spi)
 Initializes SPI bus structure with data needed to setup hardware. More...
 
static KSPIStatus hal_spi_hw_init (hal_spi_handle *handle)
 Initializes the SPI according to the specified parameters in the configuration and creates the associated handle. More...
 
static void hal_spi_terminate (hal_spi_handle *handle)
 SPI hardware cleanup and disabling. More...
 
static void hal_spi_gpio_init (hal_spi_handle *handle)
 Initializes the SPI bus pins. More...
 
KSPIStatus kprv_spi_dev_init (KSPINum spi_num)
 Setup and enable SPI bus. More...
 
KSPIStatus kprv_spi_dev_terminate (KSPINum spi)
 SPI hardware cleanup and disabling. More...
 
KSPIStatus kprv_spi_write (KSPINum spi, uint8_t *buffer, uint32_t len)
 Write data over SPI bus. More...
 
KSPIStatus kprv_spi_read (KSPINum spi, uint8_t *buffer, uint32_t len)
 Read data over SPI bus. More...
 
KSPIStatus kprv_spi_write_read (KSPINum spi, uint8_t *txBuffer, uint8_t *rxBuffer, uint32_t len)
 Write and read data over SPI bus. More...
 

Variables

static hal_spi_handle hal_spi_dev [K_NUM_SPI]
 Static array of spi bus handles. More...
 
static uint32_t spi_timeout = 1000
 Default spi request timeout value. More...
 

Function Documentation

static hal_spi_handle * hal_spi_device_init ( KSPI *  spi)
static

Initializes SPI bus structure with data needed to setup hardware.

Parameters
spihigher level hal SPI data
Returns
hal_spi_handle* NULL if bad bus num, otherwise data ready for dev setup
static hal_spi_handle * hal_spi_get_handle ( KSPINum  spi)
static

Fetches SPI bus data structure.

Parameters
numSPI bus num to fetch
Returns
hal_spi_handle* pointer to data structure
static void hal_spi_gpio_init ( hal_spi_handle handle)
static

Initializes the SPI bus pins.

Parameters
handlepointer to hal_spi_handle containing config information
static KSPIStatus hal_spi_hw_init ( hal_spi_handle handle)
static

Initializes the SPI according to the specified parameters in the configuration and creates the associated handle.

Parameters
handlepointer to hal_spi_handle containing config information
Returns
KSPIStatus SPI_OK if success, otherwise a specific error flag
static void hal_spi_terminate ( hal_spi_handle handle)
static

SPI hardware cleanup and disabling.

Parameters
handlepointer to hal_spi_handle containing config information
KSPIStatus kprv_spi_dev_init ( KSPINum  spi_num)

Setup and enable SPI bus.

Parameters
spiSPI bus to initialize
Returns
KSPIStatus SPI_OK if success, otherwise a specific error flag
KSPIStatus kprv_spi_dev_terminate ( KSPINum  spi)

SPI hardware cleanup and disabling.

Parameters
spibus num to terminate
Returns
KSPIStatus SPI_OK if success, otherwise a specific error flag
KSPIStatus kprv_spi_read ( KSPINum  spi,
uint8_t *  buffer,
uint32_t  len 
)

Read data over SPI bus.

Parameters
spiSPI bus to read from
bufferpointer to data buffer
lenlength of data to read
Returns
KSPIStatus SPI_OK on success, otherwise failure
KSPIStatus kprv_spi_write ( KSPINum  spi,
uint8_t *  buffer,
uint32_t  len 
)

Write data over SPI bus.

Parameters
spiSPI bus to write to
bufferpointer to data buffer
lenlength of data to write
Returns
KSPIStatus SPI_OK on success, otherwise failure
KSPIStatus kprv_spi_write_read ( KSPINum  spi,
uint8_t *  txBuffer,
uint8_t *  rxBuffer,
uint32_t  len 
)

Write and read data over SPI bus.

Parameters
spiSPI bus to write to
txBufferpointer to data buffer to write from
rxBufferpointer to data buffer to read into
lenlength of data to write and read
Returns
KSPIStatus SPI_OK on success, otherwise failure

Variable Documentation

hal_spi_handle hal_spi_dev[K_NUM_SPI]
static

Static array of spi bus handles.

uint32_t spi_timeout = 1000
static

Default spi request timeout value.