UARTCC26X0.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020, 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  */
340 #ifndef ti_drivers_uart_UARTCC26X0__include
341 #define ti_drivers_uart_UARTCC26X0__include
342 
343 #include <stdint.h>
344 #include <stdbool.h>
345 
346 #include <ti/drivers/dpl/ClockP.h>
347 #include <ti/drivers/dpl/HwiP.h>
348 #include <ti/drivers/dpl/SemaphoreP.h>
349 #include <ti/drivers/dpl/SwiP.h>
350 #include <ti/drivers/Power.h>
351 #include <ti/drivers/UART.h>
352 #include <ti/drivers/pin/PINCC26XX.h>
354 
355 #ifdef __cplusplus
356 extern "C" {
357 #endif
358 
362 #define UARTCC26X0_FLOWCTRL_NONE 0
363 
367 #define UARTCC26X0_FLOWCTRL_HARDWARE 1
368 
379 /* Add UARTCC26X0_STATUS_* macros here */
380 
400 #define UARTCC26X0_CMD_RETURN_PARTIAL_ENABLE (UART_CMD_RESERVED + 0)
401 
409 #define UARTCC26X0_CMD_RETURN_PARTIAL_DISABLE (UART_CMD_RESERVED + 1)
410 
417 #define UARTCC26X0_CMD_RX_FIFO_FLUSH (UART_CMD_RESERVED + 2)
418 
422 #define UARTCC26X0_FIFO_SIZE 32
423 
435 typedef enum
436 {
444 
455 typedef void (*UARTCC26X0_ErrorCallback)(UART_Handle handle, uint32_t error);
456 
457 /* UART function table pointer */
459 
514 typedef struct
515 {
517  uint32_t baseAddr;
519  int intNum;
521  uint8_t intPriority;
527  uint32_t swiPriority;
529  uint32_t flowControl;
531  unsigned char *ringBufPtr;
533  size_t ringBufSize;
535  uint8_t rxPin;
537  uint8_t txPin;
539  uint8_t ctsPin;
541  uint8_t rtsPin;
543  UARTCC26X0_FifoThreshold txIntFifoThr;
545  UARTCC26X0_FifoThreshold rxIntFifoThr;
549 
555 typedef struct
556 {
557  /* UART state variable */
558  struct
559  {
560  bool opened:1; /* Has the obj been opened */
561  UART_Mode readMode:1; /* Mode for all read calls */
562  UART_Mode writeMode:1; /* Mode for all write calls */
563  UART_DataMode readDataMode:1; /* Type of data being read */
564  UART_DataMode writeDataMode:1; /* Type of data being written */
565  UART_ReturnMode readReturnMode:1; /* Receive return mode */
566  UART_Echo readEcho:1; /* Echo received data back */
567  /*
568  * Flag to determine if a timeout has occurred when the user called
569  * UART_read(). This flag is set by the timeoutClk clock object.
570  */
571  bool bufTimeout:1;
572  /*
573  * Flag to determine when an ISR needs to perform a callback; in both
574  * UART_MODE_BLOCKING or UART_MODE_CALLBACK
575  */
576  bool callCallback:1;
577  /*
578  * Flag to determine if the ISR is in control draining the ring buffer
579  * when in UART_MODE_CALLBACK
580  */
581  bool drainByISR:1;
582  /* Keep track of RX enabled state set by app with UART_control() */
583  bool ctrlRxEnabled:1;
584  /* Flag to keep the state of the read Power constraints */
585  bool rxEnabled:1;
586  /* Flag to keep the state of the write Power constraints */
587  bool txEnabled:1;
588  } state;
589 
590  HwiP_Struct hwi; /* Hwi object for interrupts */
591  SwiP_Struct swi; /* Swi for read/write callbacks */
592  ClockP_Struct timeoutClk; /* Clock object to for timeouts */
593  ClockP_Struct txFifoEmptyClk; /* UART TX FIFO empty clock */
594  uint32_t baudRate; /* Baud rate for UART */
595  UART_LEN dataLength; /* Data length for UART */
596  UART_STOP stopBits; /* Stop bits for UART */
597  UART_PAR parityType; /* Parity bit type for UART */
598  uint32_t status; /* RX status */
599 
600  /* UART read variables */
601  RingBuf_Object ringBuffer; /* local circular buffer object */
602  unsigned char *readBuf; /* Buffer data pointer */
603  size_t readSize; /* Desired number of bytes to read */
604  size_t readCount; /* Number of bytes left to read */
605  SemaphoreP_Struct readSem; /* UART read semaphore */
606  unsigned int readTimeout; /* Timeout for read semaphore */
607  UART_Callback readCallback; /* Pointer to read callback */
608  bool readRetPartial; /* Return partial RX data if timeout occurs */
609 
610  /* UART write variables */
611  const unsigned char *writeBuf; /* Buffer data pointer */
612  size_t writeSize; /* Desired number of bytes to write*/
613  size_t writeCount; /* Number of bytes left to write */
614  SemaphoreP_Struct writeSem; /* UART write semaphore*/
615  unsigned int writeTimeout; /* Timeout for write semaphore */
616  UART_Callback writeCallback; /* Pointer to write callback */
617  unsigned int writeEmptyClkTimeout; /* TX FIFO timeout tick count */
618 
619  /* PIN driver state object and handle */
620  PIN_State pinState;
621  PIN_Handle hPin;
622 
623  /* For Power management */
626 
627 #ifdef __cplusplus
628 }
629 #endif
630 
631 #endif /* ti_drivers_uart_UARTCC26X0__include */
UART_STOP
UART stop bit settings.
Definition: UART.h:530
UARTCC26X0_FifoThreshold
UART TX/RX interrupt FIFO threshold select.
Definition: UARTCC26X0.h:435
UARTCC26X0 Object.
Definition: UARTCC26X0.h:555
size_t readSize
Definition: UARTCC26X0.h:603
size_t readCount
Definition: UARTCC26X0.h:604
unsigned int readTimeout
Definition: UARTCC26X0.h:606
The definition of a UART function table that contains the required set of functions to control a spec...
Definition: UART.h:641
bool readRetPartial
Definition: UARTCC26X0.h:608
Power Manager.
UART_PAR
UART parity type settings.
Definition: UART.h:541
struct UARTCC26X0_Object * UARTCC26X0_Handle
UARTCC26X0_FifoThreshold txIntFifoThr
Definition: UARTCC26X0.h:543
UART_Mode
UART mode settings.
Definition: UART.h:430
uint8_t rtsPin
Definition: UARTCC26X0.h:541
Definition: UARTCC26X0.h:439
UART_DataMode
UART data mode settings.
Definition: UART.h:487
uint8_t intPriority
Definition: UARTCC26X0.h:521
HwiP_Struct hwi
Definition: UARTCC26X0.h:590
UART_ReturnMode
UART return mode settings.
Definition: UART.h:464
unsigned char * ringBufPtr
Definition: UARTCC26X0.h:531
uint8_t rxPin
Definition: UARTCC26X0.h:535
uint32_t status
Definition: UARTCC26X0.h:598
UART_Echo
UART echo settings.
Definition: UART.h:506
Definition: UARTCC26X0.h:441
UART Global configuration.
Definition: UART.h:685
size_t writeCount
Definition: UARTCC26X0.h:613
unsigned char * readBuf
Definition: UARTCC26X0.h:602
int intNum
Definition: UARTCC26X0.h:519
SemaphoreP_Struct readSem
Definition: UARTCC26X0.h:605
Power_NotifyObj postNotify
Definition: UARTCC26X0.h:624
uint8_t txPin
Definition: UARTCC26X0.h:537
size_t ringBufSize
Definition: UARTCC26X0.h:533
uint32_t baudRate
Definition: UARTCC26X0.h:594
SwiP_Struct swi
Definition: UARTCC26X0.h:591
Definition: UARTCC26X0.h:440
uint32_t baseAddr
Definition: UARTCC26X0.h:517
PIN_State pinState
Definition: UARTCC26X0.h:620
size_t writeSize
Definition: UARTCC26X0.h:612
Power notify object structure.
Definition: Power.h:442
ClockP_Struct timeoutClk
Definition: UARTCC26X0.h:592
Universal Asynchronous Receiver-Transmitter (UART) Driver.
const unsigned char * writeBuf
Definition: UARTCC26X0.h:611
UART_Callback writeCallback
Definition: UARTCC26X0.h:616
uint8_t ctsPin
Definition: UARTCC26X0.h:539
SemaphoreP_Struct writeSem
Definition: UARTCC26X0.h:614
ClockP_Struct txFifoEmptyClk
Definition: UARTCC26X0.h:593
Definition: UARTCC26X0.h:438
UARTCC26X0 Hardware attributes.
Definition: UARTCC26X0.h:514
unsigned int writeTimeout
Definition: UARTCC26X0.h:615
RingBuf_Object ringBuffer
Definition: UARTCC26X0.h:601
Definition: RingBuf.h:44
UARTCC26X0_FifoThreshold rxIntFifoThr
Definition: UARTCC26X0.h:545
uint32_t swiPriority
Swi priority. The higher the number, the higher the priority. The minimum priority is 0 and the maxim...
Definition: UARTCC26X0.h:527
UART_LEN
UART data length settings.
Definition: UART.h:517
UARTCC26X0_ErrorCallback errorFxn
Definition: UARTCC26X0.h:547
void(* UARTCC26X0_ErrorCallback)(UART_Handle handle, uint32_t error)
The definition of an optional callback function used by the UART driver to notify the application whe...
Definition: UARTCC26X0.h:455
unsigned int writeEmptyClkTimeout
Definition: UARTCC26X0.h:617
UART_Callback readCallback
Definition: UARTCC26X0.h:607
const UART_FxnTable UARTCC26X0_fxnTable
uint32_t flowControl
Definition: UARTCC26X0.h:529
PIN_Handle hPin
Definition: UARTCC26X0.h:621
Definition: UARTCC26X0.h:437
UART_PAR parityType
Definition: UARTCC26X0.h:597
UART_LEN dataLength
Definition: UARTCC26X0.h:595
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:423
Definition: UARTCC26X0.h:442
UART_STOP stopBits
Definition: UARTCC26X0.h:596
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale