TI-RTOS for SimpleLink Wireless MCUs
2.14.02.22
|
UART driver implementation for a CC26XX UART controller.
============================================================================
The UART header file should be included in an application as follows:
The general UART API should used in application code, i.e. UART_open() is used instead of UARTCC26XX_open(). The board file will define the device specific config, and casting in the general API will ensure that the correct device specific functions are called. This is also reflected in the example code in Use Cases.
Before using the UART in CC26XX:
The following is true for receive operation:
The following apply for transmit operation:
If UART is no longer needed by application:
If an error occurs during read operation:
If a timeout occurs during a write, an UART_ERROR will be returned and the UART_Object.status will be set to UART_TIMED_OUT. All bytes that are not transmitted, will be flushed. If flow control is not enabled, the UARTCC26XX_Object.writeTimeout should be kept at default value, BIOS_WAIT_FOREVER. The write call will return after all bytes are transmitted. If flow control is enabled, the timeout should be set by the application in order to recover if the receiver gets stuck.
A timeout value can only be specified for reads and writes in UART_MODE_BLOCKING. If a timeout occurs during a read when in UART_MODE_BLOCKING, the number of bytes received will be returned and the UART_Object.status will be set to UART_TIMED_OUT. After a read timeout, RX will remain on, but device is allowed to enter standby. For more details see Power Management chapter below.
In UART_MODE_CALLBACK there is no timeout and the application must call UART_readCancel() or UART_writeCancel() to abort the operation.
The TI-RTOS power management framework will try to put the device into the most power efficient mode whenever possible. Please see the technical reference manual for further details on each power mode.
The UARTCC26XX driver is setting a power constraint during operation to keep the device out of standby. When the operation has finished, the power constraint is released. The following statements are valid:
To enable Flow Control, the RTS and CTS pins must be assigned in the UARTCC26XX_HWAttrs:
If the RTS and CTS pins are set to PIN_UNASSIGNED, the flow control is disabled. An example is shown in the UARTCC26XX_HWAttrs description.
Generic API function | API function | Description |
---|---|---|
UART_init() | UARTCC26XX_init() | Initialize UART driver |
UART_open() | UARTCC26XX_open() | Initialize UART HW and set system dependencies |
UART_close() | UARTCC26XX_close() | Disable UART HW and release system dependencies |
UART_control() | UARTCC26XX_control() | Configure an already opened UART handle |
UART_read() | UARTCC26XX_read() | Start read from UART |
UART_readCancel() | UARTCC26XX_readCancel() | Cancel ongoing read from UART |
UART_write() | UARTCC26XX_write() | Start write to UART |
UART_writeCancel() | UARTCC26XX_writeCancel() | Cancel ongoing write to UART |
The CC26XX UART driver currently does not support:
Receive 100 bytes over UART in UART_MODE_BLOCKING.
This use case will read in UART_MODE_BLOCKING until the wanted amount of bytes is received or until a started reception is inactive for a 32-bit period. This UART_read() call can also be used when unknown amount of bytes shall be read. Note: The partial return is also possible in UART_MODE_CALLBACK mode.
This case will configure the UART to send the data in txBuf in BLOCKING_MODE.
This case will configure the UART to receive continously in UART_MODE_CALLBACK, 16 bytes at the time and transmit them back via UART TX. Note that UART_Params.readTimeout is not in use when using UART_MODE_CALLBACK mode.
The CC26xx driver supports baud rates up to 3Mbaud. However, when receiving more than 32 bytes back-to-back the baud rate is limited to approximately 2Mbaud. The throughput is also dependent on the user application.
There are no additional stack requirements for calling UART_read() within its own callback.
The UART driver interface produces log statements if instrumentation is enabled.
Diagnostics Mask | Log details |
---|---|
Diags_USER1 | basic UART operations performed |
Diags_USER2 | detailed UART operations performed |
#include <stdint.h>
#include <stdbool.h>
#include <ti/drivers/UART.h>
#include <ti/drivers/pin/PINCC26XX.h>
#include <ti/sysbios/family/arm/cc26xx/Power.h>
#include <driverlib/uart.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Semaphore.h>
Go to the source code of this file.
Data Structures | |
struct | UARTCC26XX_HWAttrs |
UARTCC26XX Hardware attributes. More... | |
struct | UARTCC26XX_Object |
UARTCC26XX Object. More... | |
Typedefs | |
typedef struct UARTCC26XX_HWAttrs | UARTCC26XX_HWAttrs |
UARTCC26XX Hardware attributes. More... | |
typedef enum UART_Status | UART_Status |
UART status. More... | |
typedef enum UART_FifoThreshold | UART_FifoThreshold |
UART FIFO threshold. More... | |
typedef struct UARTCC26XX_Object | UARTCC26XX_Object |
UARTCC26XX Object. More... | |
typedef struct UARTCC26XX_Object * | UARTCC26XX_Handle |
Enumerations | |
enum | UART_Status { UART_TIMED_OUT = 0x10, UART_PARITY_ERROR = UART_RXERROR_PARITY, UART_BRAKE_ERROR = UART_RXERROR_BREAK, UART_OVERRUN_ERROR = UART_RXERROR_OVERRUN, UART_FRAMING_ERROR = UART_RXERROR_FRAMING, UART_OK = 0x0 } |
UART status. More... | |
enum | UART_FifoThreshold { UART_TH_FIFO_1_8 = 4, UART_TH_FIFO_2_8 = 8, UART_TH_FIFO_4_8 = 16, UART_TH_FIFO_6_8 = 24, UART_TH_FIFO_7_8 = 28 } |
UART FIFO threshold. More... | |
Variables | |
const UART_FxnTable | UARTCC26XX_fxnTable |
#define ti_sysbios_family_arm_m3_Hwi__nolocalnames |
#define UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE UART_CMD_RESERVED + 0 |
Enable RETURN_PARTIAL, used as cmd to UART_control()
#define UARTCC26XX_CMD_RETURN_PARTIAL_DISABLE UART_CMD_RESERVED + 1 |
Disable RETURN_PARTIAL, used as cmd to UART_control()
#define UARTCC26XX_FIFO_SIZE 32 |
Size of the TX and RX FIFOs is 32 items
#define UARTCC26XX_RETURN_PARTIAL_ENABLE UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE |
#define UARTCC26XX_RETURN_PARTIAL_DISABLE UARTCC26XX_CMD_RETURN_PARTIAL_DISABLE |
typedef struct UARTCC26XX_HWAttrs UARTCC26XX_HWAttrs |
UARTCC26XX Hardware attributes.
These fields are used by driverlib APIs and therefore must be populated by driverlib macro definitions. For CC26xxWare these definitions are found in:
A sample structure is shown below:
The .ctsPin and .rtsPin must be assigned to enable flow control.
typedef enum UART_Status UART_Status |
UART status.
The UART Status is used to flag the different Receive Errors.
typedef enum UART_FifoThreshold UART_FifoThreshold |
UART FIFO threshold.
Mapping of FIFO thresholds from level to number of bytes.
typedef struct UARTCC26XX_Object UARTCC26XX_Object |
UARTCC26XX Object.
The application must not access any member variables of this structure!
typedef struct UARTCC26XX_Object * UARTCC26XX_Handle |
enum UART_Status |
enum UART_FifoThreshold |
UART FIFO threshold.
Mapping of FIFO thresholds from level to number of bytes.
const UART_FxnTable UARTCC26XX_fxnTable |