FreeRTOS_IO.h
size_t FreeRTOS_read( Peripheral_Descriptor_t const pxPeripheral,
void * const pvBuffer,
const size_t xBytes );
Reads one or more bytes from an open peripheral.
The board support package
defines the peripherals that are available to be opened. FreeRTOS_ioctl()
is used to select between interrupt driven and polled read modes.
Parameters:
pxPeripheral
|
The descriptor associated with the peripheral from
which bytes are being read. The descriptor will have
been returned from the
FreeRTOS_open()
call used to open the peripheral.
|
pvBuffer
|
The buffer into which read data are placed.
|
xBytes
|
The total number of bytes requested.
When an interrupt driven transfer mode
is used, the total number
of bytes actually read will be less than the total
number requested if the total number requested are
not available before the peripheral's read timeout
expires. FreeRTOS_ioctl() is used
to set the read timeout value.
|
Returns:
The total number of bytes read. This will be less than the number
of bytes requested by the xBytes parameter if the requested number
of bytes cannot be read before the peripheral's read timeout
expires. FreeRTOS_ioctl() is used to set
the read timeout value.
Example usage:
The example 1 code snippet demonstrates how to perform a read when a peripheral
is configured to use the polled transfer mode. Peripherals
default to polled mode when they are opened.
xBytesRead = FreeRTOS_read( xPort, ucBuffer, sizeof( ucBuffer ) );
configASSERT( xBytes == sizeof( ucBuffer ) );
Example 1: Reading bytes from a peripheral that is configured to use the polled transfer mode.
The example 2 code snippet demonstrates how to perform a read when a peripheral
is configured to use either the interrupt driven character queue
transfer mode,
or the interrupt driven circular buffer transfer mode.
In these modes, the task making the FreeRTOS_read() call is held in the
Blocked state (not using any CPU time) until either the requested number of
bytes have been read, or the read timeout expires. FreeRTOS_ioctl()
is used with the iocltSET_RX_TIMEOUT request code to configure
the read timeout.
xBytesRead = FreeRTOS_read( xPort, ucBuffer, sizeof( ucBuffer ) );
if( xBytesRead < sizeof( ucBuffer ) )
{
}
else
{
}
Example 2: Reading bytes from a peripheral that is configured to used either the
interrupt driven character queue transfer mode, or the interrupt driven circular
buffer transfer mode.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.