1.1.5.3.1 DRV_I2S_ReadBufferAdd Function
void DRV_I2S_ReadBufferAdd ( const DRV_HANDLE handle, void * buffer, const size_t size, DRV_I2S_BUFFER_HANDLE * bufferHandle )
Summary
Queues a read operation.
Description
This function schedules a non-blocking read operation. The function returns with a valid buffer handle in the bufferHandle argument if the read request was scheduled successfully. The function adds the request to the hardware instance receive queue and returns immediately. While the request is in the queue, the application buffer is owned by the driver and should not be modified. The function returns DRV_I2S_BUFFER_HANDLE_INVALID in the bufferHandle argument:
if a buffer could not be allocated to the request
if the input buffer pointer is NULL
if the buffer size is 0
if the read queue size is full or queue depth is insufficient.
if the driver handle is invalid
If the requesting client registered an event callback with the driver, the driver will issue a DRV_I2S_BUFFER_EVENT_COMPLETE event if the buffer was processed successfully of DRV_I2S_BUFFER_EVENT_ERROR event if the buffer was not processed successfully.
Preconditions
DRV_I2S_Open must have been called to obtain a valid opened device handle.
Parameters
Parameters | Description |
---|---|
handle | Handle of the communication channel as returned by the DRV_I2S_Open function. |
buffer | Buffer where the received data will be stored. |
size | Buffer size in bytes. |
bufferHandle | Pointer to an argument that will contain the return buffer handle. |
Returns
The buffer handle is returned in the bufferHandle argument. This is DRV_I2S_BUFFER_HANDLE_INVALID if the request was not successful.
Remarks
This function is thread safe in a RTOS application. It can be called from within the I2S Driver Buffer Event Handler that is registered by the client. It should not be called in the event handler associated with another I2S driver instance. It should not be called directly in an ISR.
Example
MY_APP_OBJ myAppObj; uint8_t mybuffer[MY_BUFFER_SIZE]; DRV_I2S_BUFFER_HANDLE bufferHandle; _// myI2SHandle is the handle returned // by the DRV_I2S_Open function._ DRV_I2S_ReadBufferAdd(myI2Shandle, myBuffer, MY_BUFFER_SIZE, &bufferHandle); if(DRV_I2S_BUFFER_HANDLE_INVALID == bufferHandle) { _// Error handling here_ } _// Event is received when the buffer is processed._
C
void DRV_I2S_ReadBufferAdd(const DRV_HANDLE handle, void * buffer, const size_t size, DRV_I2S_BUFFER_HANDLE * const bufferHandle);