UARTCC26X2.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2018, 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  */
341 #ifndef ti_drivers_uart_UARTCC26X2__include
342 #define ti_drivers_uart_UARTCC26X2__include
343 
344 #ifdef __cplusplus
345 extern "C" {
346 #endif
347 
348 #include <stdint.h>
349 #include <stdbool.h>
350 
351 #include <ti/drivers/dpl/ClockP.h>
352 #include <ti/drivers/dpl/HwiP.h>
353 #include <ti/drivers/dpl/SemaphoreP.h>
354 #include <ti/drivers/dpl/SwiP.h>
355 #include <ti/drivers/Power.h>
356 #include <ti/drivers/UART.h>
359 
360 
361 
365 #define UARTCC26X2_FLOWCTRL_NONE 0
366 
370 #define UARTCC26X2_FLOWCTRL_HARDWARE 1
371 
382 /* Add UARTCC26X2_STATUS_* macros here */
383 
403 #define UARTCC26X2_CMD_RETURN_PARTIAL_ENABLE (UART_CMD_RESERVED + 0)
404 
412 #define UARTCC26X2_CMD_RETURN_PARTIAL_DISABLE (UART_CMD_RESERVED + 1)
413 
420 #define UARTCC26X2_CMD_RX_FIFO_FLUSH (UART_CMD_RESERVED + 2)
421 
422 
426 #define UARTCC26X2_FIFO_SIZE 32
427 
447 
458 typedef void (*UARTCC26X2_ErrorCallback) (UART_Handle handle, uint32_t error);
459 
460 /* UART function table pointer */
462 
535 typedef struct UARTCC26X2_HWAttrs {
537  uint32_t baseAddr;
539  int intNum;
541  uint8_t intPriority;
547  uint32_t swiPriority;
549  uint32_t flowControl;
551  unsigned char *ringBufPtr;
553  size_t ringBufSize;
555  uint8_t rxPin;
557  uint8_t txPin;
559  uint8_t ctsPin;
561  uint8_t rtsPin;
563  UARTCC26X2_FifoThreshold txIntFifoThr;
565  UARTCC26X2_FifoThreshold rxIntFifoThr;
569 
575 typedef struct UARTCC26X2_Object {
576  /* UART state variable */
577  struct {
578  bool opened:1; /* Has the obj been opened */
579  UART_Mode readMode:1; /* Mode for all read calls */
580  UART_Mode writeMode:1; /* Mode for all write calls */
581  UART_DataMode readDataMode:1; /* Type of data being read */
582  UART_DataMode writeDataMode:1; /* Type of data being written */
583  UART_ReturnMode readReturnMode:1; /* Receive return mode */
584  UART_Echo readEcho:1; /* Echo received data back */
585  /*
586  * Flag to determine if a timeout has occurred when the user called
587  * UART_read(). This flag is set by the timeoutClk clock object.
588  */
589  bool bufTimeout:1;
590  /*
591  * Flag to determine when an ISR needs to perform a callback; in both
592  * UART_MODE_BLOCKING or UART_MODE_CALLBACK
593  */
594  bool callCallback:1;
595  /*
596  * Flag to determine if the ISR is in control draining the ring buffer
597  * when in UART_MODE_CALLBACK
598  */
599  bool drainByISR:1;
600  /* Keep track of RX enabled state set by app with UART_control() */
601  bool ctrlRxEnabled:1;
602  /* Flag to keep the state of the read Power constraints */
603  bool rxEnabled:1;
604  /* Flag to keep the state of the write Power constraints */
605  bool txEnabled:1;
606  } state;
607 
608  HwiP_Struct hwi; /* Hwi object for interrupts */
609  SwiP_Struct readSwi; /* Swi for read callbacks */
610  SwiP_Struct writeSwi; /* Swi for write callbacks */
611  ClockP_Struct timeoutClk; /* Clock object to for timeouts */
612  uint32_t baudRate; /* Baud rate for UART */
613  UART_LEN dataLength; /* Data length for UART */
614  UART_STOP stopBits; /* Stop bits for UART */
615  UART_PAR parityType; /* Parity bit type for UART */
616  uint32_t status; /* RX status */
617 
618  /* UART read variables */
619  RingBuf_Object ringBuffer; /* local circular buffer object */
620  unsigned char *readBuf; /* Buffer data pointer */
621  size_t readSize; /* Desired number of bytes to read */
622  size_t readCount; /* Number of bytes left to read */
623  SemaphoreP_Struct readSem; /* UART read semaphore */
624  unsigned int readTimeout; /* Timeout for read semaphore */
625  UART_Callback readCallback; /* Pointer to read callback */
626  bool readRetPartial; /* Return partial RX data if timeout occurs */
627 
628  /* UART write variables */
629  const unsigned char *writeBuf; /* Buffer data pointer */
630  size_t writeSize; /* Desired number of bytes to write*/
631  size_t writeCount; /* Number of bytes left to write */
632  SemaphoreP_Struct writeSem; /* UART write semaphore*/
633  unsigned int writeTimeout; /* Timeout for write semaphore */
634  UART_Callback writeCallback; /* Pointer to write callback */
635 
636  /* PIN driver state object and handle */
639 
640  /* For Power management */
642  unsigned int powerMgrId; /* Determined from base address */
644 
645 #ifdef __cplusplus
646 }
647 #endif
648 
649 #endif /* ti_drivers_uart_UARTCC26X2__include */
size_t readSize
Definition: UARTCC26X2.h:621
UARTCC26X2 Object.
Definition: UARTCC26X2.h:575
enum UART_Echo_ UART_Echo
UART echo settings.
Definition: UARTCC26X2.h:442
UARTCC26X2_FifoThreshold rxIntFifoThr
Definition: UARTCC26X2.h:565
UARTCC26X2_ErrorCallback errorFxn
Definition: UARTCC26X2.h:567
size_t readCount
Definition: UARTCC26X2.h:622
enum UART_PAR_ UART_PAR
UART parity type settings.
Definition: UARTCC26X2.h:441
size_t ringBufSize
Definition: UARTCC26X2.h:553
struct UARTCC26X2_Object * UARTCC26X2_Handle
Power Manager.
enum UART_LEN_ UART_LEN
UART data length settings.
uint8_t rxPin
Definition: UARTCC26X2.h:555
enum UART_Mode_ UART_Mode
UART mode settings.
unsigned int powerMgrId
Definition: UARTCC26X2.h:642
HwiP_Struct hwi
Definition: UARTCC26X2.h:608
UARTCC26X2 Hardware attributes.
Definition: UARTCC26X2.h:535
UART_LEN dataLength
Definition: UARTCC26X2.h:613
unsigned char * ringBufPtr
Definition: UARTCC26X2.h:551
PIN_Handle hPin
Definition: UARTCC26X2.h:638
uint32_t status
Definition: UARTCC26X2.h:616
void(* UARTCC26X2_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: UARTCC26X2.h:458
UART Global configuration.
Definition: UART.h:678
uint8_t rtsPin
Definition: UARTCC26X2.h:561
SemaphoreP_Struct writeSem
Definition: UARTCC26X2.h:632
Definition: UARTCC26X2.h:440
size_t writeCount
Definition: UARTCC26X2.h:631
UART_STOP stopBits
Definition: UARTCC26X2.h:614
Device-specific pin & GPIO driver for CC26xx family [def].
unsigned int readTimeout
Definition: UARTCC26X2.h:624
RingBuf_Object ringBuffer
Definition: UARTCC26X2.h:619
UART_Callback writeCallback
Definition: UARTCC26X2.h:634
struct UARTCC26X2_HWAttrs UARTCC26X2_HWAttrs
UARTCC26X2 Hardware attributes.
uint8_t intPriority
Definition: UARTCC26X2.h:541
Definition: UARTCC26X2.h:444
UART_Callback readCallback
Definition: UARTCC26X2.h:625
struct UARTCC26X2_Object UARTCC26X2_Object
UARTCC26X2 Object.
ClockP_Struct timeoutClk
Definition: UARTCC26X2.h:611
The definition of a UART function table that contains the required set of functions to control a spec...
Definition: UART.h:635
Definition: UARTCC26X2.h:443
Definition: UARTCC26X2.h:445
Power notify object structure.
Definition: Power.h:443
const unsigned char * writeBuf
Definition: UARTCC26X2.h:629
Universal Asynchronous Receiver-Transmitter (UART) Driver.
uint32_t baseAddr
Definition: UARTCC26X2.h:537
int intNum
Definition: UARTCC26X2.h:539
uint32_t swiPriority
Swi priority. The higher the number, the higher the priority. The minimum priority is 0 and the maxim...
Definition: UARTCC26X2.h:547
underlying data structure for type PIN_State
Definition: PIN.h:707
UARTCC26X2_FifoThreshold
UART TX/RX interrupt FIFO threshold select.
Definition: UARTCC26X2.h:439
uint32_t flowControl
Definition: UARTCC26X2.h:549
enum UART_STOP_ UART_STOP
UART stop bit settings.
const UART_FxnTable UARTCC26X2_fxnTable
enum UART_ReturnMode_ UART_ReturnMode
UART return mode settings.
PIN_State pinState
Definition: UARTCC26X2.h:637
uint32_t baudRate
Definition: UARTCC26X2.h:612
Definition: RingBuf.h:44
SwiP_Struct writeSwi
Definition: UARTCC26X2.h:610
unsigned char * readBuf
Definition: UARTCC26X2.h:620
uint8_t txPin
Definition: UARTCC26X2.h:557
UARTCC26X2_FifoThreshold txIntFifoThr
Definition: UARTCC26X2.h:563
unsigned int writeTimeout
Definition: UARTCC26X2.h:633
size_t writeSize
Definition: UARTCC26X2.h:630
uint8_t ctsPin
Definition: UARTCC26X2.h:559
SemaphoreP_Struct readSem
Definition: UARTCC26X2.h:623
UART_PAR parityType
Definition: UARTCC26X2.h:615
bool readRetPartial
Definition: UARTCC26X2.h:626
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:421
enum UART_DataMode_ UART_DataMode
UART data mode settings.
Power_NotifyObj postNotify
Definition: UARTCC26X2.h:641
SwiP_Struct readSwi
Definition: UARTCC26X2.h:609
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale