|
||||||||||||||
Returns: When the polled transfer mode is used, the returned value is the total number of bytes actually written to the peripheral. This will be the total number requested assuming no errors occurred. When the interrupt driven character queue transfer mode is used, the returned value is the total number of bytes actually written to the write queue. This will be less than the requested number of bytes if there was not enough space in the queue for all the bytes to be written immediately, and the peripheral's write timeout expired before enough space became available. The actual transmission of data is controlled by the FreeRTOS+IO interrupt service routine, and may complete after the call to FreeRTOS_write() has returned. When the interrupt driven zero copy transfer mode is used, then:
FreeRTOS_ioctl() is used to set the write timeout value.
The example 1 code snippet demonstrates how to perform a write when a peripheral is configured to use the polled transfer mode. Peripherals default to polled mode when they are opened.
The example 2 code snippet demonstrates how to perform a write when a peripheral is configured to use the interrupt driven character queue transfer mode. In this mode, the task making the FreeRTOS_write() call is held in the Blocked state (not using any CPU time) until either all the requested number of bytes have been sent to the queue, or the write timeout expires. FreeRTOS_ioctl() is used with the ioctlSET_TX_TIMEOUT request code to configure the write timeout, and the ioctlWAIT_PREVIOUS_WRITE_COMPLETE request code wait for the write queue to be empty.
The example 3 code snippet demonstrates how to perform a write when a peripheral is configured to use the interrupt driven zero copy transfer mode. In this mode, the task making the FreeRTOS_write() call will always return immediately. If the returned value equals the number of bytes that are to be written, then the FreeRTOS_write() call successfully started the interrupt driven transmission. If the returned value equals zero, then the FreeRTOS_write() call could not start the transmission, either because it did not hold the write mutex, or because FreeRTOSIOConfig.h was not configured to support it.
|
[ Back to the top ]
[ About FreeRTOS ]
[ Privacy ]
[ FreeRTOS+ Sitemap ]
[ Main FreeRTOS Sitemap ]
[
]
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|