SPI API#
SPI_ConfigureMemSeg()#
Description#
Sets the memory segment where file system internal data structures will be allocated.
Files#
spi.h/spi.c
Prototype#
void  SPI_ConfigureMemSeg  (MEM_SEG  *p_seg)Arguments#
p_seg
Pointer to a memory segment.
Returned Value#
None.
Notes / Warnings#
None.
SPI_ConfigureSlaveHandleQty()#
Description#
Configure the maximum number of SPI slave handles for all the SPI busses.
Files#
spi.h/spi.c
Prototype#
void  SPI_ConfigureSlaveHandleQty  (CPU_SIZE_T  handle_qty)Arguments#
handle_qty
Max number of SPI slave handles.
Returned Value#
None.
Notes / Warnings#
None.
SPI_BusAdd()#
Description#
Creates/Adds SPI bus.
Files#
spi_bus.h/spi_bus.c
Prototype#
SPI_BUS_HANDLE  SPI_BusAdd (const  CPU_CHAR  *name,
                                   RTOS_ERR  *p_err)Arguments#
name
Name to give to the new bus. Must be unique, constant, and in scope for the remainder of the program.
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
- RTOS_ERR_NONE
- RTOS_ERR_NOT_FOUND
- RTOS_ERR_BLK_ALLOC_CALLBACK
- RTOS_ERR_SEG_OVF
- RTOS_ERR_OS_SCHED_LOCKED
- RTOS_ERR_NOT_AVAIL
- RTOS_ERR_OS_ILLEGAL_RUN_TIME
- RTOS_ERR_WOULD_OVF
- RTOS_ERR_POOL_EMPTY
- RTOS_ERR_OS_OBJ_DEL
- RTOS_ERR_WOULD_BLOCK
- RTOS_ERR_IS_OWNER
- RTOS_ERR_ABORT
- RTOS_ERR_TIMEOUT
Returned Value#
Handle to SPI bus.
Notes / Warnings#
None.
SPI_BusHandleGetFromName()#
Description#
Gets SPI bus handle from serial controller name.
Files#
spi_bus.h/spi_bus.c
Prototype#
SPI_BUS_HANDLE  SPI_BusHandleGetFromName (const  CPU_CHAR  *name)Arguments#
name
Serial controller name.
Returned Value#
Bas handle, if exists. SPI_BusHandleNull, otherwise.
Notes / Warnings#
None.
SPI_BusStart()#
Description#
Starts given SPI bus/driver.
Files#
spi_bus.h/spi_bus.c
Prototype#
void  SPI_BusStart (SPI_BUS_HANDLE   bus_handle,
                    RTOS_ERR        *p_err)Arguments#
bus_handle
Handle to SPI bus.
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
- RTOS_ERR_NONE
- RTOS_ERR_NOT_AVAIL
- RTOS_ERR_WOULD_OVF
- RTOS_ERR_OS_OBJ_DEL
- RTOS_ERR_WOULD_BLOCK
- RTOS_ERR_IS_OWNER
- RTOS_ERR_INVALID_STATE
- RTOS_ERR_OS_SCHED_LOCKED
- RTOS_ERR_ABORT
- RTOS_ERR_TIMEOUT
Returned Value#
None.
Notes / Warnings#
None.
SPI_BusStop()#
Description#
Stops given SPI bus/driver.
Files#
spi_bus.h/spi_bus.c
Prototype#
void  SPI_BusStop (SPI_BUS_HANDLE   bus_handle,
                   RTOS_ERR        *p_err)Arguments#
bus_handle
Handle to SPI bus.
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
- RTOS_ERR_NONE
- RTOS_ERR_NOT_AVAIL
- RTOS_ERR_WOULD_OVF
- RTOS_ERR_OS_OBJ_DEL
- RTOS_ERR_WOULD_BLOCK
- RTOS_ERR_IS_OWNER
- RTOS_ERR_INVALID_STATE
- RTOS_ERR_OS_SCHED_LOCKED
- RTOS_ERR_ABORT
- RTOS_ERR_TIMEOUT
Returned Value#
None.
Notes / Warnings#
None.
SPI_BusLoopBackEn()#
Description#
Enables loopback on SPI bus via IO Ctrl.
Files#
spi_bus.h/spi_bus.c
Prototype#
void  SPI_BusLoopBackEn (SPI_BUS_HANDLE   bus_handle,
                         CPU_BOOLEAN      en,
                         RTOS_ERR        *p_err)Arguments#
bus_handle
Handle to SPI bus.
en
Flag indicating if loopback mode should be enabled or disabled.
- DEF_ENABLED
- DEF_DISABLED
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
- RTOS_ERR_NONE
Returned Value#
None.
Notes / Warnings#
None.
SPI_SlaveOpen()#
Description#
Opens/creates a slave on an SPI bus.
Files#
spi_slave.h/spi_slave.c
Prototype#
SPI_SLAVE_HANDLE  SPI_SlaveOpen (       SPI_BUS_HANDLE   bus_handle,
                                 const  SPI_SLAVE_INFO  *p_slave_info,
                                        RTOS_ERR        *p_err)Arguments#
bus_handle
Handle on SPI bus.
p_slave_info
Pointer to slave information structure.
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
- RTOS_ERR_NONE
- RTOS_ERR_NOT_AVAIL
- RTOS_ERR_OS_ILLEGAL_RUN_TIME
- RTOS_ERR_POOL_EMPTY
- RTOS_ERR_BLK_ALLOC_CALLBACK
- RTOS_ERR_SEG_OVF
Returned Value#
SPI slave handle
Notes / Warnings#
None.
SPI_SlaveClose()#
Description#
Closes an SPI slave.
Files#
spi_slave.h/spi_slave.c
Prototype#
void  SPI_SlaveClose (SPI_SLAVE_HANDLE   slave_handle,
                      RTOS_ERR          *p_err)Arguments#
slave_handle
Handle on SPI slave.
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
- RTOS_ERR_NONE
- RTOS_ERR_NOT_INIT
- RTOS_ERR_POOL_FULL
- RTOS_ERR_OWNERSHIP
- RTOS_ERR_OS_SCHED_LOCKED
- RTOS_ERR_NOT_AVAIL
- RTOS_ERR_WOULD_OVF
- RTOS_ERR_OS_OBJ_DEL
- RTOS_ERR_WOULD_BLOCK
- RTOS_ERR_IS_OWNER
- RTOS_ERR_INVALID_STATE
- RTOS_ERR_ABORT
- RTOS_ERR_TIMEOUT
Returned Value#
None.
Notes / Warnings#
None.
SPI_SlaveSel()#
Description#
Enables slave-select for the slave associated with 'handle'
Files#
spi_slave.h/spi_slave.c
Prototype#
void  SPI_SlaveSel (SPI_SLAVE_HANDLE   slave_handle,
                    CPU_INT32U         timeout_ms,
                    SPI_OPT            opt,
                    RTOS_ERR          *p_err)Arguments#
slave_handle
Handle on SPI slave.
timeout_ms
Timeout, in milliseconds.
opt
Options flags for slave-select. May be one of the following:
- SPI_OPT_NONEBlock until the bus is available
- SPI_OPT_NON_BLOCKINGReturn immediately if bus is unavailable
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
- RTOS_ERR_NONE
- RTOS_ERR_NOT_AVAIL
- RTOS_ERR_NOT_INIT
- RTOS_ERR_WOULD_OVF
- RTOS_ERR_OS_OBJ_DEL
- RTOS_ERR_WOULD_BLOCK
- RTOS_ERR_IS_OWNER
- RTOS_ERR_INVALID_STATE
- RTOS_ERR_OS_SCHED_LOCKED
- RTOS_ERR_ABORT
- RTOS_ERR_TIMEOUT
Returned Value#
None.
Notes / Warnings#
- Enabling slave-select will lock the handle's SPI bus to the calling task, preventing any other task from accessing it. 
- Calls to - SPI_SlaveSel()cannot be nested.
SPI_SlaveDesel()#
Description#
Disables slave-select for the slave associated with 'slave_handle'.
Files#
spi_slave.h/spi_slave.c
Prototype#
void  SPI_SlaveDesel (SPI_SLAVE_HANDLE   slave_handle,
                      RTOS_ERR          *p_err)Arguments#
slave_handle
Handle on an SPI slave.
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
- RTOS_ERR_NONE
- RTOS_ERR_NOT_AVAIL
- RTOS_ERR_NOT_INIT
- RTOS_ERR_WOULD_OVF
- RTOS_ERR_OWNERSHIP
- RTOS_ERR_OS_OBJ_DEL
- RTOS_ERR_WOULD_BLOCK
- RTOS_ERR_IS_OWNER
- RTOS_ERR_INVALID_STATE
- RTOS_ERR_OS_SCHED_LOCKED
- RTOS_ERR_ABORT
- RTOS_ERR_TIMEOUT
Returned Value#
None.
Notes / Warnings#
None.
SPI_SlaveRx()#
Description#
Receives data from SPI slave.
Files#
spi_slave.h/spi_slave.c
Prototype#
void  SPI_SlaveRx (SPI_SLAVE_HANDLE   slave_handle,
                   CPU_INT08U        *p_buf,
                   CPU_INT32U         buf_len,
                   CPU_INT32U         timeout_ms,
                   RTOS_ERR          *p_err)Arguments#
slave_handle
Handle on an SPI slave.
p_buf
Pointer to receive buffer.
buf_len
Buffer length, in octets,
timeout_ms
Timeout, in milliseconds.
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
- RTOS_ERR_NONE
- RTOS_ERR_NOT_AVAIL
- RTOS_ERR_NOT_INIT
- RTOS_ERR_WOULD_OVF
- RTOS_ERR_OS_OBJ_DEL
- RTOS_ERR_WOULD_BLOCK
- RTOS_ERR_IS_OWNER
- RTOS_ERR_INVALID_STATE
- RTOS_ERR_OS_SCHED_LOCKED
- RTOS_ERR_ABORT
- RTOS_ERR_TIMEOUT
Returned Value#
None.
Notes / Warnings#
None.
SPI_SlaveTx()#
Description#
Transmits data to SPI slave.
Files#
spi_slave.h/spi_slave.c
Prototype#
void  SPI_SlaveTx (SPI_SLAVE_HANDLE   slave_handle,
                   CPU_INT08U        *p_buf,
                   CPU_INT32U         buf_len,
                   CPU_INT32U         timeout_ms,
                   RTOS_ERR          *p_err)Arguments#
slave_handle
Handle on an SPI slave.
p_buf
Pointer to transmit buffer.
buf_len
Buffer length, in octets,
timeout_ms
Timeout, in milliseconds.
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
- RTOS_ERR_NONE
- RTOS_ERR_NOT_AVAIL
- RTOS_ERR_NOT_INIT
- RTOS_ERR_WOULD_OVF
- RTOS_ERR_OS_OBJ_DEL
- RTOS_ERR_WOULD_BLOCK
- RTOS_ERR_IS_OWNER
- RTOS_ERR_INVALID_STATE
- RTOS_ERR_OS_SCHED_LOCKED
- RTOS_ERR_ABORT
- RTOS_ERR_TIMEOUT
Returned Value#
None.
Notes / Warnings#
None.
SPI_SlaveXfer()#
Description#
Transmits and receives data to/from SPI slave.
Files#
spi_slave.h/spi_slave.c
Prototype#
void  SPI_SlaveXfer (SPI_SLAVE_HANDLE   slave_handle,
                     CPU_INT08U        *p_buf_rx,
                     CPU_INT08U        *p_buf_tx,
                     CPU_INT32U         buf_len,
                     CPU_INT32U         timeout_ms,
                     RTOS_ERR          *p_err)Arguments#
slave_handle
Handle on an SPI slave.
p_buf_rx
Pointer to receive buffer.
p_buf_tx
Pointer to transmit buffer.
buf_len
Buffer length, in octets,
timeout_ms
Timeout, in milliseconds.
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
- RTOS_ERR_NONE
- RTOS_ERR_NOT_AVAIL
- RTOS_ERR_NOT_INIT
- RTOS_ERR_WOULD_OVF
- RTOS_ERR_OS_OBJ_DEL
- RTOS_ERR_WOULD_BLOCK
- RTOS_ERR_IS_OWNER
- RTOS_ERR_INVALID_STATE
- RTOS_ERR_OS_SCHED_LOCKED
- RTOS_ERR_ABORT
- RTOS_ERR_TIMEOUT
Returned Value#
None.
Notes / Warnings#
None.