19 #define ISF_SPI_LOCK_DEFAULT (0)
48 OSA_EnterCritical(kCriticalDisableInt);
59 OSA_MutexCreate(apBusHandle->
pLock);
60 OSA_MutexCreate(apBusHandle->
pRdLock);
61 SPI_Type * base = g_dspiBase[pBusHandle->
instance];
63 SPI_BWR_MCR_DIS_RXF(base, 1);
64 SPI_BWR_MCR_DIS_TXF(base, 1);
65 SPI_BWR_MCR_ROOE(base,1);
66 DSPI_HAL_SetDelay(base, kDspiCtar0, 1, 2, kDspiPcsToSck);
67 DSPI_HAL_SetDelay(base, kDspiCtar0, 1, 2, kDspiLastSckToPcs);
68 DSPI_HAL_SetDelay(base, kDspiCtar0, 1, 2, kDspiAfterTransfer);
72 apBusHandle->
pHandle = pBusHandle;
85 uint32_t calculatedBaudRate;
86 if((NULL == apBusHandle) || (NULL == apBusConfig)){
97 dspi_status_t status = DSPI_DRV_MasterConfigureBus(pBusHandle->
instance,&apBusConfig->
device, &calculatedBaudRate);
113 if(NULL == apBusHandle){
128 if((NULL == apBusHandle) || (NULL == apBusConfig)){
145 if(NULL == apBusHandle){
162 if(NULL == apBusHandle){
178 if(NULL == apBusHandle){
186 DSPI_HAL_Enable(g_dspiBase[pBusHandle->
instance]);
201 if( NULL == apBusHandle){
208 DSPI_HAL_Disable(g_dspiBase[pBusHandle->
instance]);
228 if((NULL == apBusHandle) || (NULL == apEndpointHandle) || (NULL == apDevice)){
242 *apEndpointHandle = pEndpoint;
258 if(NULL == apEndpoint){
261 OSA_MemFree(apEndpoint);
278 if((NULL == pEndpoint) || (NULL == pWriteBuffer) || (NULL == pEndpoint->pSlaveInfo)){
281 if(buffsize < nByteWrite){
289 ret = bus_lock(pEndpoint->pBusHandle, pBusHandle->busConfig.timeout,
SPI_LOCK_COMMON);
294 if(
ISF_SUCCESS != pEndpoint->pSlaveInfo->writepreProcess(&slaveCmd, offset, nByteWrite, pWriteBuffer)){
297 ret = DSPI_DRV_MasterTransferBlocking(pBusHandle->instance,NULL,
298 (
const uint8_t *) slaveCmd.pWriteBuffer, slaveCmd.pReadBuffer,
299 slaveCmd.size, pBusHandle->busConfig.timeout);
302 pEndpoint->pSlaveInfo->writepostProcess(&slaveCmd);
322 if((NULL == pEndpoint) || (NULL == pReadBuffer) || (NULL == pEndpoint->pSlaveInfo)){
325 if(buffsize < nByteRead){
332 ret = bus_lock(pEndpoint->pBusHandle, pBusHandle->busConfig.timeout,
SPI_LOCK_READ);
337 if(
ISF_SUCCESS != pEndpoint->pSlaveInfo->readpreProcess(&slaveCmd, offset, nByteRead)){
340 ret = DSPI_DRV_MasterTransferBlocking(pBusHandle->instance,NULL,
341 (
const uint8_t *)slaveCmd.pWriteBuffer,slaveCmd.pReadBuffer, slaveCmd.size, pBusHandle->busConfig.timeout);
343 pEndpoint->pSlaveInfo->readpostProcess(&slaveCmd, pReadBuffer);
364 pnLock = &apBusHandle->
nRdLock;
366 pLock = apBusHandle->
pLock;
367 pnLock = &apBusHandle->
nLock;
376 if(kStatus_OSA_Success != OSA_MutexLock((mutex_t*)pLock, OSA_WAIT_FOREVER)){
398 pnLock = &apBusHandle->
nRdLock;
400 pLock = apBusHandle->
pLock;
401 pnLock = &apBusHandle->
nLock;
412 OSA_MutexUnlock((mutex_t*)pLock);
isf_status_t spi_master_adapter_init(comm_Id_t aBusId, busHandle_t *apBusHandle)
This function initializes a spi bus.
isf_status_t spi_master_adapter_read(void *apEndpointHandle, int32 offset, void *pReadBuffer, uint32 buffsize, uint32 nByteRead, spi_master_readFlags_t aFlags)
This function reads from a spi device.
uint32 comm_Id_t
This type is for a numeric channel identifier- index into an array of channels in the system...
isf_spi_master_adapter.h defines the API definitions and types for the spi master protocol adapter...
isf_status_t spi_master_adapter_release_endpoint(spi_master_Endpoint_t *apEndpoint)
This function closes a particular endpoint.
isf_status_t spi_master_adapter_configure(busHandle_t *apBusHandle, spi_master_busConfig_t *apBusConfig)
This function reconfigures an already initialized bus.
isf_status_t spi_master_adapter_get_config(busHandle_t *apBusHandle, void *apBusConfig)
This function returns the current bus configuration.
spi_master_slaveInfo_t * pSlaveInfo
isf_status_t spi_master_adapter_start(busHandle_t *apBusHandle)
This function starts a bus.
isf_status_t spi_master_adapter_release_lock(busHandle_t *apBusHandle)
This function releases exclusive bus access.
comm_State_t spi_master_adapter_get_state(busHandle_t *apBusHandle)
This function returns the current bus state.
This structure defines a device endpoint encapsulation for spi handler.
comm_Flags_t spi_master_readFlags_t
#define ISF_SPI_LOCK_DEFAULT
isf_protocol_adapter.h defines the general interface definition for the protocol adapter.
The isf_util.h file contains the utility method declarations and macros.
comm_Flags_t spi_master_writeFlags_t
This structure is a declaration of a BusHandle type.
spi_master_busHandle_t spi_busHandle[]
isf_status_t spi_master_adapter_get_endpoint(busHandle_t *apBusHandle, void *apDevice, void **apEndpointHandle)
This function creates a endpoint for a device at a specified bus address.
This structure defines the spi slave command format.
uint32 isf_duration_t
ISF time duration in microseconds.
Main ISF header file. Contains code common to all ISF components.
isf_status_t spi_master_adapter_stop(busHandle_t *apBusHandle)
This function stops the given spi bus.
spi_master_busConfig_t busConfig
int32 isf_status_t
ISF return status type.
enum comm_State_vals comm_State_t
This enum holds an enumerated value describing the state of a channel.
isf_status_t spi_master_adapter_acquire_lock(busHandle_t *apBusHandle, isf_duration_t aTimeout)
This function locks the bus for exclusive access.
This structure defines the data bus handle.
isf_devmsg.h defines the API definitions and types for the Intelligent Sensing (ISF) Device Messaging...
isf_status_t spi_master_adapter_write(void *apEndpointHandle, int32 offset, void *pWriteBuffer, uint32 buffsize, uint32 nByteWrite, spi_master_writeFlags_t aFlags)
This function writes to a spi device.