TI-RTOS for SimpleLink Wireless MCUs  2.14.02.22
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 
389 typedef struct UARTCC26XX_HWAttrs {
390  uint32_t baseAddr;
391  uint32_t powerMngrId;
392  int intNum;
399  uint8_t intPriority;
400  uint8_t txPin;
401  uint8_t rxPin;
402  uint8_t ctsPin;
403  uint8_t rtsPin;
405 
411 typedef enum UART_Status {
412  UART_TIMED_OUT = 0x10,
413  UART_PARITY_ERROR = UART_RXERROR_PARITY,
414  UART_BRAKE_ERROR = UART_RXERROR_BREAK,
415  UART_OVERRUN_ERROR = UART_RXERROR_OVERRUN,
416  UART_FRAMING_ERROR = UART_RXERROR_FRAMING,
417  UART_OK = 0x0
418 } UART_Status;
419 
425 typedef enum UART_FifoThreshold {
432 
438 typedef struct UARTCC26XX_Object {
439  /* UART control variables */
440  bool opened;
443  unsigned int readTimeout;
444  unsigned int writeTimeout;
457  uint32_t baudRate;
463  /* UART write variables */
464  const void *writeBuf;
465  size_t writeCount;
466  size_t writeSize;
467  bool writeCR;
469  /* UART receive variables */
471  void *readBuf;
472  size_t readCount;
473  size_t readSize;
477  /* PIN driver state object and handle */
480 
482  void *uartPostFxn;
485 
486  /* UART SYS/BIOS objects */
487  ti_sysbios_family_arm_m3_Hwi_Struct hwi;
488  Semaphore_Struct writeSem;
489  Semaphore_Struct readSem;
490  Clock_Struct txFifoEmptyClk;
492 
493 
494 
495 /* Do not interfere with the app if they include the family Hwi module */
496 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
497 
498 #ifdef __cplusplus
499 }
500 #endif
501 
502 #endif /* ti_drivers_uart_UARTCC26XX__include */
uint8_t txPin
Definition: UARTCC26XX.h:400
UART_STOP
UART stop bit settings.
Definition: UART.h:379
UART_Mode readMode
Definition: UARTCC26XX.h:441
Definition: UARTCC26XX.h:412
Power_NotifyObj uartPostObj
Definition: UARTCC26XX.h:484
uint32_t baudRate
Baud rate for CC26xx UART.
Definition: UARTCC26XX.h:457
const void * writeBuf
Definition: UARTCC26XX.h:464
size_t writeSize
Definition: UARTCC26XX.h:466
Definition: UARTCC26XX.h:430
uint8_t rxPin
Definition: UARTCC26XX.h:401
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:426
uint8_t writeFifoThreshold
Definition: UARTCC26XX.h:475
size_t readSize
Definition: UARTCC26XX.h:473
Definition: UARTCC26XX.h:414
UART_DataMode
UART data mode settings.
Definition: UART.h:339
unsigned int readTimeout
Definition: UARTCC26XX.h:443
uint32_t baseAddr
Definition: UARTCC26XX.h:390
UART_ReturnMode
UART return mode settings.
Definition: UART.h:324
bool readRetPartial
Definition: UARTCC26XX.h:470
void * uartPostFxn
Definition: UARTCC26XX.h:482
UART_ReturnMode readReturnMode
Definition: UARTCC26XX.h:447
UART_Status
UART status.
Definition: UARTCC26XX.h:411
Semaphore_Struct writeSem
Definition: UARTCC26XX.h:488
Definition: UARTCC26XX.h:416
UARTCC26XX Object.
Definition: UARTCC26XX.h:438
uint8_t ctsPin
Definition: UARTCC26XX.h:402
UART_Callback readCallback
Definition: UARTCC26XX.h:445
UART_PAR parityType
Definition: UARTCC26XX.h:460
Definition: UARTCC26XX.h:415
size_t readCount
Definition: UARTCC26XX.h:472
UART_LEN dataLength
Definition: UARTCC26XX.h:458
ti_sysbios_family_arm_m3_Hwi_Struct hwi
Definition: UARTCC26XX.h:487
Definition: UARTCC26XX.h:428
UART_FifoThreshold readFifoThreshold
Definition: UARTCC26XX.h:474
Device-specific pin & GPIO driver for CC26xx family [def].
Semaphore_Struct readSem
Definition: UARTCC26XX.h:489
struct UARTCC26XX_HWAttrs UARTCC26XX_HWAttrs
UARTCC26XX Hardware attributes.
UART_Status status
Definition: UARTCC26XX.h:461
Definition: UARTCC26XX.h:417
size_t writeCount
Definition: UARTCC26XX.h:465
unsigned int writeTimeout
Definition: UARTCC26XX.h:444
Power notify object structure.
Definition: Power.h:112
bool opened
Definition: UARTCC26XX.h:440
UART driver interface.
uint8_t rtsPin
Definition: UARTCC26XX.h:403
int intNum
Definition: UARTCC26XX.h:392
UART_STOP stopBits
Definition: UARTCC26XX.h:459
bool writeCR
Definition: UARTCC26XX.h:467
Definition: UARTCC26XX.h:413
Definition: UARTCC26XX.h:429
underlying data structure for type PIN_State
Definition: PIN.h:686
UART_Mode writeMode
Definition: UARTCC26XX.h:442
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:389
void * readBuf
Definition: UARTCC26XX.h:471
UART_LEN
UART data length settings.
Definition: UART.h:367
UART_DataMode readDataMode
Definition: UARTCC26XX.h:448
struct UARTCC26XX_Object * UARTCC26XX_Handle
uint32_t powerMngrId
Definition: UARTCC26XX.h:391
UART_DataMode writeDataMode
Definition: UARTCC26XX.h:449
PIN_State pinState
Definition: UARTCC26XX.h:478
struct UARTCC26XX_Object UARTCC26XX_Object
UARTCC26XX Object.
Definition: UARTCC26XX.h:427
UART_Callback writeCallback
Definition: UARTCC26XX.h:446
Clock_Struct txFifoEmptyClk
Definition: UARTCC26XX.h:490
uint8_t intPriority
UART Peripheral's interrupt priority.
Definition: UARTCC26XX.h:399
PIN_Handle hPin
Definition: UARTCC26XX.h:479
UART_FifoThreshold
UART FIFO threshold.
Definition: UARTCC26XX.h:425
Copyright 2015, Texas Instruments Incorporated