TI-RTOS for SimpleLink Wireless MCUs  2.14.03.28
UARTCC26XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, 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  */
325 #ifndef ti_drivers_uart_UARTCC26XX__include
326 #define ti_drivers_uart_UARTCC26XX__include
327 
328 #ifdef __cplusplus
329 extern "C" {
330 #endif
331 
332 #include <stdint.h>
333 #include <stdbool.h>
334 #include <ti/drivers/UART.h>
336 #include <ti/sysbios/family/arm/cc26xx/Power.h>
337 #include <driverlib/uart.h>
338 
339 /*
340  * The following allows this header file to be included in an application file
341  * which also includes ti/sysbios/hal/Hwi.h.
342  */
343 #define ti_sysbios_family_arm_m3_Hwi__nolocalnames
344 #include <ti/sysbios/family/arm/m3/Hwi.h>
345 #include <ti/sysbios/knl/Clock.h>
346 #include <ti/sysbios/knl/Semaphore.h>
347 
349 #define UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE UART_CMD_RESERVED + 0
350 
351 #define UARTCC26XX_CMD_RETURN_PARTIAL_DISABLE UART_CMD_RESERVED + 1
352 
353 #define UARTCC26XX_FIFO_SIZE 32
354 
355 /* BACKWARDS COMPATIBILITY */
356 #define UARTCC26XX_RETURN_PARTIAL_ENABLE UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE
357 #define UARTCC26XX_RETURN_PARTIAL_DISABLE UARTCC26XX_CMD_RETURN_PARTIAL_DISABLE
358 /* END BACKWARDS COMPATIBILITY */
359 
360 /* UART function table pointer */
362 
400 typedef struct UARTCC26XX_HWAttrs {
401  uint32_t baseAddr;
402  uint32_t powerMngrId;
403  int intNum;
416  uint8_t intPriority;
417  uint8_t txPin;
418  uint8_t rxPin;
419  uint8_t ctsPin;
420  uint8_t rtsPin;
422 
428 typedef enum UART_Status {
429  UART_TIMED_OUT = 0x10,
430  UART_PARITY_ERROR = UART_RXERROR_PARITY,
431  UART_BRAKE_ERROR = UART_RXERROR_BREAK,
432  UART_OVERRUN_ERROR = UART_RXERROR_OVERRUN,
433  UART_FRAMING_ERROR = UART_RXERROR_FRAMING,
434  UART_OK = 0x0
435 } UART_Status;
436 
442 typedef enum UART_FifoThreshold {
449 
455 typedef struct UARTCC26XX_Object {
456  /* UART control variables */
457  bool opened;
460  unsigned int readTimeout;
461  unsigned int writeTimeout;
474  uint32_t baudRate;
480  /* UART write variables */
481  const void *writeBuf;
482  size_t writeCount;
483  size_t writeSize;
484  bool writeCR;
486  /* UART receive variables */
488  void *readBuf;
489  size_t readCount;
490  size_t readSize;
494  /* PIN driver state object and handle */
497 
499  void *uartPostFxn;
502 
503  /* UART SYS/BIOS objects */
504  ti_sysbios_family_arm_m3_Hwi_Struct hwi;
505  Semaphore_Struct writeSem;
506  Semaphore_Struct readSem;
507  Clock_Struct txFifoEmptyClk;
509 
510 
511 
512 /* Do not interfere with the app if they include the family Hwi module */
513 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
514 
515 #ifdef __cplusplus
516 }
517 #endif
518 
519 #endif /* ti_drivers_uart_UARTCC26XX__include */
uint8_t txPin
Definition: UARTCC26XX.h:417
UART_STOP
UART stop bit settings.
Definition: UART.h:379
UART_Mode readMode
Definition: UARTCC26XX.h:458
Definition: UARTCC26XX.h:429
Power_NotifyObj uartPostObj
Definition: UARTCC26XX.h:501
uint32_t baudRate
Baud rate for CC26xx UART.
Definition: UARTCC26XX.h:474
const void * writeBuf
Definition: UARTCC26XX.h:481
size_t writeSize
Definition: UARTCC26XX.h:483
Definition: UARTCC26XX.h:447
uint8_t rxPin
Definition: UARTCC26XX.h:418
The definition of a UART function table that contains the required set of functions to control a spec...
Definition: UART.h:497
UART_PAR
UART parity type settings.
Definition: UART.h:389
const UART_FxnTable UARTCC26XX_fxnTable
UART_Mode
UART mode settings.
Definition: UART.h:291
Definition: UARTCC26XX.h:443
uint8_t writeFifoThreshold
Definition: UARTCC26XX.h:492
size_t readSize
Definition: UARTCC26XX.h:490
Definition: UARTCC26XX.h:431
UART_DataMode
UART data mode settings.
Definition: UART.h:339
unsigned int readTimeout
Definition: UARTCC26XX.h:460
uint32_t baseAddr
Definition: UARTCC26XX.h:401
UART_ReturnMode
UART return mode settings.
Definition: UART.h:324
bool readRetPartial
Definition: UARTCC26XX.h:487
void * uartPostFxn
Definition: UARTCC26XX.h:499
UART_ReturnMode readReturnMode
Definition: UARTCC26XX.h:464
UART_Status
UART status.
Definition: UARTCC26XX.h:428
Semaphore_Struct writeSem
Definition: UARTCC26XX.h:505
Definition: UARTCC26XX.h:433
UARTCC26XX Object.
Definition: UARTCC26XX.h:455
uint8_t ctsPin
Definition: UARTCC26XX.h:419
UART_Callback readCallback
Definition: UARTCC26XX.h:462
UART_PAR parityType
Definition: UARTCC26XX.h:477
Definition: UARTCC26XX.h:432
size_t readCount
Definition: UARTCC26XX.h:489
UART_LEN dataLength
Definition: UARTCC26XX.h:475
ti_sysbios_family_arm_m3_Hwi_Struct hwi
Definition: UARTCC26XX.h:504
Definition: UARTCC26XX.h:445
UART_FifoThreshold readFifoThreshold
Definition: UARTCC26XX.h:491
Device-specific pin & GPIO driver for CC26xx family [def].
Semaphore_Struct readSem
Definition: UARTCC26XX.h:506
struct UARTCC26XX_HWAttrs UARTCC26XX_HWAttrs
UARTCC26XX Hardware attributes.
UART_Status status
Definition: UARTCC26XX.h:478
Definition: UARTCC26XX.h:434
size_t writeCount
Definition: UARTCC26XX.h:482
unsigned int writeTimeout
Definition: UARTCC26XX.h:461
Power notify object structure.
Definition: Power.h:112
bool opened
Definition: UARTCC26XX.h:457
UART driver interface.
uint8_t rtsPin
Definition: UARTCC26XX.h:420
int intNum
Definition: UARTCC26XX.h:403
UART_STOP stopBits
Definition: UARTCC26XX.h:476
bool writeCR
Definition: UARTCC26XX.h:484
Definition: UARTCC26XX.h:430
Definition: UARTCC26XX.h:446
underlying data structure for type PIN_State
Definition: PIN.h:686
UART_Mode writeMode
Definition: UARTCC26XX.h:459
void(* UART_Callback)(UART_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:284
UARTCC26XX Hardware attributes.
Definition: UARTCC26XX.h:400
void * readBuf
Definition: UARTCC26XX.h:488
UART_LEN
UART data length settings.
Definition: UART.h:367
UART_DataMode readDataMode
Definition: UARTCC26XX.h:465
struct UARTCC26XX_Object * UARTCC26XX_Handle
uint32_t powerMngrId
Definition: UARTCC26XX.h:402
UART_DataMode writeDataMode
Definition: UARTCC26XX.h:466
PIN_State pinState
Definition: UARTCC26XX.h:495
struct UARTCC26XX_Object UARTCC26XX_Object
UARTCC26XX Object.
Definition: UARTCC26XX.h:444
UART_Callback writeCallback
Definition: UARTCC26XX.h:463
Clock_Struct txFifoEmptyClk
Definition: UARTCC26XX.h:507
uint8_t intPriority
UART Peripheral's interrupt priority.
Definition: UARTCC26XX.h:416
PIN_Handle hPin
Definition: UARTCC26XX.h:496
UART_FifoThreshold
UART FIFO threshold.
Definition: UARTCC26XX.h:442
Copyright 2015, Texas Instruments Incorporated