![]() |
![]() |
Functions | |
| CSL_Status | SPI_init (void) |
| CSL_Status | SPI_deInit (void) |
| CSL_SpiHandle | SPI_open (SPI_HwMode csNum, SPI_OperMode opMode) |
| CSL_Status | SPI_close (CSL_SpiHandle hSpi) |
| CSL_Status | SPI_config (CSL_SpiHandle hSpi, SPI_Config *spiHwConfig) |
| CSL_Status | SPI_read (CSL_SpiHandle hSpi, Uint16 *readBuffer, Uint16 bufLen) |
| CSL_Status | SPI_write (CSL_SpiHandle hSpi, Uint16 *writeBuffer, Uint16 bufLen) |
| CSL_Status | SPI_dataTransaction (CSL_SpiHandle hSpi, Uint16 *rwBuffer, Uint16 rwBufLen, SPI_Command readOrWrite) |
| CSL_Status SPI_close | ( | CSL_SpiHandle | hSpi | ) |
===========================================================================
SPI_close
Description
This function closes the specified handle to SPI.
Arguments
spiHandle Handle to the spi
Return Value CSL_Status
Pre Condition
SPI_open() function has to call before call this function.
Post Condition
There should not be any function call after this function call.
Modifies
None
Example
CSL_SpiHandle hSpi;
CSL_status status;
status = SPI_close(hSpi);
===========================================================================
References CSL_SpiObj::configured.
| CSL_Status SPI_config | ( | CSL_SpiHandle | hSpi, |
| SPI_Config * | spiHwConfig | ||
| ) |
===========================================================================
SPI_config
Description
It configures the SPI Controller registers of particular handle as per the values passed in the SPI config structure.
Arguments
spiHandle Handle to the spi.
spiHwConfig Pointer to spi Config structure.
Return Value CSL_Status
Pre Condition
SPI_open function should call before call this function.
Post Condition
SPI_close function can call after this function call.
Modifies
1. SPI registers will be updated as per config parameter
2. CSL_SpiObj Object will be updated to store some info as passed config parameter.
Example
CSL_SpiHandle hSpi;
SPI_Config spiHwConfig;
Int16 status;
status = SPI_config(hSpi, &spiHwConfig);
...
===========================================================================
References SPI_Config::clkPh, SPI_Config::clkPol, CSL_SpiObj::configured, SPI_Config::csNum, SPI_Config::csPol, SPI_Config::dataDelay, SPI_Config::fcEnable, SPI_Config::frLen, SPI_Config::spiClkDiv, SPI_Config::wcEnable, and SPI_Config::wLen.
| CSL_Status SPI_dataTransaction | ( | CSL_SpiHandle | hSpi, |
| Uint16 * | rwBuffer, | ||
| Uint16 | rwBufLen, | ||
| SPI_Command | readOrWrite | ||
| ) |
===========================================================================
SPI_dataTransaction
Description
This function read or Write data to specified device.
Arguments
spiHandle Handle to the spi
writeBuff Pointer to the write buffer.
buffLen Maximum read buffer size.
readOrWrite Read or write command.
Return Value CSL_Status
Pre Condition This function can after SPI_open function.
Post Condition
SPI_deInit can be call after this function call.
Modifies
Example
CSL_SpiHandle hSpi;
Uint16 writeBuff[size];
Uint16 buffLen;
SPI_Command readOrWrite
CSL_status status;
...
...
status = SPI_dataTransaction(hSpi, &rwBuffer,
rwBufLen, readOrWrite);
===========================================================================
References CSL_SpiObj::configured, SPI_read(), SPI_READ_CMD, SPI_write(), and SPI_WRITE_CMD.
| CSL_Status SPI_deInit | ( | void | ) |
===========================================================================
SPI_deInit
Description
This function unintialize and activate the SPI module
Arguments
void No parameter
Return Value CSL_SOK
Return value CSL_SOK for success
Pre Condition
This function call call after SPI_init function.
Post Condition
SPI_close function can be call after this function call.
Modifies
1. Set the register to activate SPI module
2.
Example
void
result = SPI_deInit();
...
===========================================================================
References CSL_SpiObj::configured, and SPI_Instance.
| CSL_Status SPI_init | ( | void | ) |
===========================================================================
SPI_init
Description
This function intialize and activate the SPI module
Arguments
None
Return Value CSL_SOK
Return value CSL_SOK for success
Pre Condition
This functionality has to call before any function call.
Post Condition
None
Modifies
None
Example
void
result = SPI_init();
...
===========================================================================
| CSL_SpiHandle SPI_open | ( | SPI_HwMode | csNum, |
| SPI_OperMode | opMode | ||
| ) |
===========================================================================
SPI_open
Description
This function returns the handle to the SPI instance. This handle is passed to all other CSL APIs.
Arguments
Mode chip select mode.
Return Value CSL_SpiHandle
Valid SPI handle will be returned if handler value is not equal to NULL.
Pre Condition
SPI_init function has to call before call this function.
Post Condition
1. The status is returned in the status variable. If status returned is
Modifies
1. CSL_SpiObj SPI object structure
2.
Example
SPI_HwMode csNum;
SPI_OperMode opMode(Polling/Interrupt)
...
hSpi = SPI_open(SPI_HwMode csNum, SPI_OperMode opMode);
...
===========================================================================
References CSL_SpiObj::configured, CSL_SpiObj::mode, CSL_SpiObj::opMode, and SPI_Instance.
| CSL_Status SPI_read | ( | CSL_SpiHandle | hSpi, |
| Uint16 * | readBuffer, | ||
| Uint16 | bufLen | ||
| ) |
===========================================================================
SPI_read
Description
This function Read data form specified device.
Arguments
hSpi Pointer to handler
readBuff Pointer to the read buffer.
buffLen Maximum read buffer size.
Return Value CSL_Status
Pre Condition
This function can call by SPI_dataTransaction function.
Post Condition
SPI_deInit can be call after this function call.
Modifies
Example
CSL_SpiHandle hSpi
Uint16 readBuff[size];
Uint16 buffLen;
CSL_status status;
status = SPI_read(hSpi,&readBuff, buffLen);
===========================================================================
References SPI_MAX_WORD_LEN.
Referenced by SPI_dataTransaction().
| CSL_Status SPI_write | ( | CSL_SpiHandle | hSpi, |
| Uint16 * | writeBuffer, | ||
| Uint16 | bufLen | ||
| ) |
===========================================================================
SPI_write
Description
This function Write data to specified device.
Arguments
hSpi Pointer to handler
writeBuff Pointer to the write buffer.
buffLen Maximum read buffer size.
Return Value CSL_Status
Pre Condition This function can call by SPI_dataTransaction function.
Post Condition
SPI_deInit can be call after this function call.
Modifies
Example
CSL_SpiHandle hSpi
Uint16 writeBuff[size];
Uint16 buffLen;
CSL_status status;
status = SPI_write(hSpi,&writeBuff, buffLen);
===========================================================================
References SPI_MAX_WORD_LEN, and SPI_WRITE_CMD.
Referenced by SPI_dataTransaction().
1.7.4