Data Direction
Polled mode can be used with both FreeRTOS_read() and FreeRTOS_write().
Description
In polled mode, data transfers are performed by busy waiting on peripheral
status bits. Interrupts are not used.
Polled Transfer Mode
|
Advantages
|
Disadvantages
|
-
Very simple usage model
-
In most cases, the FreeRTOS_read() or FreeRTOS_write()
operation will only return after all the data has been
read or written respectively.
-
The FreeRTOS-Plus-IO driver does not need any RAM for
data buffering.
|
-
The task performing the read or write remains in the
Ready or Running state for the
duration of the read or write operation - even when there are
no actions to perform because the peripheral's status bits have
not changed since they were last polled. The result
is CPU time being wasted by the polling task at the
expense of another task that could have performed its processing immediately.
-
There is no in-built mutual exclusion method. The
application writter must ensure mutual exclusion (for
example by using a mutex) if more than one task needs
to access the same peripheral.
-
There is not (yet) the possibility to change the read or
write timeout.
|
Polling is the default mode when a peripheral is opened. Not all peripherals
provide a method to return to polled mode once it has been exited.
Polled writes will only return after all the bytes have been
written to the peripheral, unless an error occurs.
Polled reads will only return after the requested number of
bytes have been read from the peripheral, unless an error occurs.
Example Usage
#include "FreeRTOS_IO.h"
void vAFunction( void )
{
Peripheral_Descriptor_t xOpenedPort;
BaseType_t xBytesTransferred;
xOpenedPort = FreeRTOS_open( "/SPI2/", NULL );
if( xOpenedPort != NULL )
{
xBytesTransferred = FreeRTOS_write( xOpenedPort, ucBuffer, 10 );
configASSERT( xBytesTransferred == 10 );
xBytesTransferred = FreeRTOS_read( xOpenedPort, ucBuffer, 10 );
configASSERT( xBytesTransferred == 10 );
}
else
{
}
}
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.