SimpleLink MCU SDK Driver APIs  tidrivers_cc13xx_cc26xx_3_01_01_03
UARTCC26XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
344 #ifndef ti_drivers_uart_UARTCC26XX__include
345 #define ti_drivers_uart_UARTCC26XX__include
346 
347 #ifdef __cplusplus
348 extern "C" {
349 #endif
350 
351 #include <stdint.h>
352 #include <stdbool.h>
353 #include <ti/drivers/UART.h>
355 #include <ti/drivers/Power.h>
357 
358 #ifdef DEVICE_FAMILY
359  #undef DEVICE_FAMILY_PATH
360  #define DEVICE_FAMILY_PATH(x) <ti/devices/DEVICE_FAMILY/x>
361 #else
362  #error "You must define DEVICE_FAMILY at the project level as one of cc26x0, cc26x0r2, cc13x0, etc."
363 #endif
364 
365 #include DEVICE_FAMILY_PATH(driverlib/uart.h)
366 
367 /*
368  * The following allows this header file to be included in an application file
369  * which also includes ti/sysbios/hal/Hwi.h.
370  */
371 #define ti_sysbios_family_arm_m3_Hwi__nolocalnames
372 #include <ti/sysbios/family/arm/m3/Hwi.h>
373 #include <ti/sysbios/knl/Swi.h>
374 #include <ti/sysbios/knl/Clock.h>
375 #include <ti/sysbios/knl/Semaphore.h>
376 
387 /* Add UARTCC26XX_STATUS_* macros here */
388 
408 #define UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE UART_CMD_RESERVED + 0
409 
417 #define UARTCC26XX_CMD_RETURN_PARTIAL_DISABLE UART_CMD_RESERVED + 1
418 
425 #define UARTCC26XX_CMD_RX_FIFO_FLUSH UART_CMD_RESERVED + 2
426 
429 #define UARTCC26XX_FIFO_SIZE 32
430 
431 /* BACKWARDS COMPATIBILITY */
432 #define UARTCC26XX_RETURN_PARTIAL_ENABLE UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE
433 #define UARTCC26XX_RETURN_PARTIAL_DISABLE UARTCC26XX_CMD_RETURN_PARTIAL_DISABLE
434 /* END BACKWARDS COMPATIBILITY */
435 
436 /* UART function table pointer */
438 
479 typedef struct UARTCC26XX_HWAttrsV2 {
480  uint32_t baseAddr;
481  uint32_t powerMngrId;
482  int intNum;
495  uint8_t intPriority;
501  uint32_t swiPriority;
502  uint8_t txPin;
503  uint8_t rxPin;
504  uint8_t ctsPin;
505  uint8_t rtsPin;
506  unsigned char *ringBufPtr;
507  size_t ringBufSize;
509 
515 typedef enum UART_Status {
516  UART_TIMED_OUT = 0x10,
517  UART_PARITY_ERROR = UART_RXERROR_PARITY,
518  UART_BRAKE_ERROR = UART_RXERROR_BREAK,
519  UART_OVERRUN_ERROR = UART_RXERROR_OVERRUN,
520  UART_FRAMING_ERROR = UART_RXERROR_FRAMING,
521  UART_OK = 0x0
522 } UART_Status;
523 
529 typedef enum UART_FifoThreshold {
536 
542 typedef struct UARTCC26XX_Object {
543  /* UART control variables */
544  bool opened;
547  unsigned int readTimeout;
548  unsigned int writeTimeout;
561  uint32_t baudRate;
567  /* UART write variables */
568  const void *writeBuf;
569  size_t writeCount;
570  size_t writeSize;
571  bool writeCR;
573  /* UART receive variables */
575  void *readBuf;
576  size_t readCount;
577  size_t readSize;
582  /* PIN driver state object and handle */
585 
587  void *uartPostFxn;
590 
591  /* UART SYS/BIOS objects */
592  ti_sysbios_family_arm_m3_Hwi_Struct hwi;
593  Swi_Struct swi;
594  Semaphore_Struct writeSem;
595  Semaphore_Struct readSem;
596  Clock_Struct txFifoEmptyClk;
598 
599 
600 
601 /* Do not interfere with the app if they include the family Hwi module */
602 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
603 
604 #ifdef __cplusplus
605 }
606 #endif
607 
608 #endif /* ti_drivers_uart_UARTCC26XX__include */
uint8_t rtsPin
Definition: UARTCC26XX.h:505
UARTCC26XX Hardware attributes.
Definition: UARTCC26XX.h:479
UART_Mode readMode
Definition: UARTCC26XX.h:545
Definition: UARTCC26XX.h:516
Power_NotifyObj uartPostObj
Definition: UARTCC26XX.h:589
uint32_t baudRate
Baud rate for CC26xx UART.
Definition: UARTCC26XX.h:561
const void * writeBuf
Definition: UARTCC26XX.h:568
size_t writeSize
Definition: UARTCC26XX.h:570
Definition: UARTCC26XX.h:534
enum UART_PAR_ UART_PAR
UART parity type settings.
Power manager interface.
enum UART_LEN_ UART_LEN
UART data length settings.
const UART_FxnTable UARTCC26XX_fxnTable
RingBuf_Object ringBuffer
Definition: UARTCC26XX.h:580
enum UART_Mode_ UART_Mode
UART mode settings.
Definition: UARTCC26XX.h:530
Power notify object structure.
Definition: Power.h:113
uint8_t writeFifoThreshold
Definition: UARTCC26XX.h:579
size_t readSize
Definition: UARTCC26XX.h:577
Definition: UARTCC26XX.h:518
unsigned int readTimeout
Definition: UARTCC26XX.h:547
bool readRetPartial
Definition: UARTCC26XX.h:574
void * uartPostFxn
Definition: UARTCC26XX.h:587
UART_ReturnMode readReturnMode
Definition: UARTCC26XX.h:551
UART_Status
UART status.
Definition: UARTCC26XX.h:515
Semaphore_Struct writeSem
Definition: UARTCC26XX.h:594
Definition: UARTCC26XX.h:520
UARTCC26XX Object.
Definition: UARTCC26XX.h:542
UART_Callback readCallback
Definition: UARTCC26XX.h:549
Swi_Struct swi
Definition: UARTCC26XX.h:593
UART_PAR parityType
Definition: UARTCC26XX.h:564
Definition: UARTCC26XX.h:519
size_t readCount
Definition: UARTCC26XX.h:576
UART_LEN dataLength
Definition: UARTCC26XX.h:562
ti_sysbios_family_arm_m3_Hwi_Struct hwi
Definition: UARTCC26XX.h:592
Definition: UARTCC26XX.h:532
UART_FifoThreshold readFifoThreshold
Definition: UARTCC26XX.h:578
Device-specific pin & GPIO driver for CC26xx family [def].
struct UARTCC26XX_HWAttrsV2 UARTCC26XX_HWAttrsV2
UARTCC26XX Hardware attributes.
Semaphore_Struct readSem
Definition: UARTCC26XX.h:595
uint32_t baseAddr
Definition: UARTCC26XX.h:480
int intNum
Definition: UARTCC26XX.h:482
UART_Status status
Definition: UARTCC26XX.h:565
Definition: UARTCC26XX.h:521
The definition of a UART function table that contains the required set of functions to control a spec...
Definition: UART.h:648
size_t writeCount
Definition: UARTCC26XX.h:569
unsigned int writeTimeout
Definition: UARTCC26XX.h:548
bool opened
Definition: UARTCC26XX.h:544
uint8_t intPriority
UART Peripheral's interrupt priority.
Definition: UARTCC26XX.h:495
UART driver interface.
size_t ringBufSize
Definition: UARTCC26XX.h:507
uint8_t rxPin
Definition: UARTCC26XX.h:503
unsigned char * ringBufPtr
Definition: UARTCC26XX.h:506
UART_STOP stopBits
Definition: UARTCC26XX.h:563
bool writeCR
Definition: UARTCC26XX.h:571
Definition: UARTCC26XX.h:517
Definition: UARTCC26XX.h:533
underlying data structure for type PIN_State
Definition: PIN.h:687
UART_Mode writeMode
Definition: UARTCC26XX.h:546
enum UART_STOP_ UART_STOP
UART stop bit settings.
enum UART_ReturnMode_ UART_ReturnMode
UART return mode settings.
Definition: RingBuf.h:44
void * readBuf
Definition: UARTCC26XX.h:575
UART_DataMode readDataMode
Definition: UARTCC26XX.h:552
struct UARTCC26XX_Object * UARTCC26XX_Handle
UART_DataMode writeDataMode
Definition: UARTCC26XX.h:553
PIN_State pinState
Definition: UARTCC26XX.h:583
uint8_t ctsPin
Definition: UARTCC26XX.h:504
struct UARTCC26XX_Object UARTCC26XX_Object
UARTCC26XX Object.
Definition: UARTCC26XX.h:531
uint32_t swiPriority
SPI SWI priority. The higher the number, the higher the priority. The minimum is 0 and the maximum is...
Definition: UARTCC26XX.h:501
UART_Callback writeCallback
Definition: UARTCC26XX.h:550
Clock_Struct txFifoEmptyClk
Definition: UARTCC26XX.h:596
uint32_t powerMngrId
Definition: UARTCC26XX.h:481
PIN_Handle hPin
Definition: UARTCC26XX.h:584
UART_FifoThreshold
UART FIFO threshold.
Definition: UARTCC26XX.h:529
void(* UART_Callback)(UART_Handle handle, void *buf, size_t count)
The definition of a callback function used by the UART driver when used in UART_MODE_CALLBACK The cal...
Definition: UART.h:434
uint8_t txPin
Definition: UARTCC26XX.h:502
enum UART_DataMode_ UART_DataMode
UART data mode settings.
Copyright 2016, Texas Instruments Incorporated