TI-RTOS Drivers  tidrivers_tivac_2_16_00_08
UART.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  */
128 #ifndef ti_drivers_UART__include
129 #define ti_drivers_UART__include
130 
131 #ifdef __cplusplus
132 extern "C" {
133 #endif
134 
135 #include <stdint.h>
136 #include <stddef.h>
137 
155 #define UART_CMD_RESERVED 32
156 
169 #define UART_STATUS_RESERVED -32
170 
184 #define UART_STATUS_SUCCESS 0
185 
192 #define UART_STATUS_ERROR -1
193 
201 #define UART_STATUS_UNDEFINEDCMD -2
202 
220 #define UART_CMD_PEEK 0
221 
231 #define UART_CMD_ISAVAILABLE 1
232 
242 #define UART_CMD_GETRXCOUNT 2
243 
254 #define UART_CMD_RXENABLE 3
255 
267 #define UART_CMD_RXDISABLE 4
268 
272 #define UART_ERROR UART_STATUS_ERROR
273 
277 #define UART_WAIT_FOREVER (~0)
278 
282 typedef struct UART_Config *UART_Handle;
283 
301 typedef void (*UART_Callback) (UART_Handle, void *buf, size_t count);
302 
308 typedef enum UART_Mode {
314 
321 } UART_Mode;
322 
341 typedef enum UART_ReturnMode {
344 
348 
356 typedef enum UART_DataMode {
359 } UART_DataMode;
360 
374 typedef enum UART_Echo {
377 } UART_Echo;
378 
384 typedef enum UART_LEN {
389 } UART_LEN;
390 
396 typedef enum UART_STOP {
399 } UART_STOP;
400 
406 typedef enum UART_PAR {
412 } UART_PAR;
413 
422 typedef struct UART_Params {
425  unsigned int readTimeout;
426  unsigned int writeTimeout;
433  uint32_t baudRate;
437  uintptr_t custom;
439 } UART_Params;
440 
445 typedef void (*UART_CloseFxn) (UART_Handle handle);
446 
451 typedef int (*UART_ControlFxn) (UART_Handle handle,
452  unsigned int cmd,
453  void *arg);
454 
459 typedef void (*UART_InitFxn) (UART_Handle handle);
460 
465 typedef UART_Handle (*UART_OpenFxn) (UART_Handle handle,
466  UART_Params *params);
471 typedef int (*UART_ReadFxn) (UART_Handle handle, void *buffer,
472  size_t size);
473 
478 typedef int (*UART_ReadPollingFxn) (UART_Handle handle, void *buffer,
479  size_t size);
480 
485 typedef void (*UART_ReadCancelFxn) (UART_Handle handle);
486 
491 typedef int (*UART_WriteFxn) (UART_Handle handle,
492  const void *buffer,
493  size_t size);
494 
499 typedef int (*UART_WritePollingFxn) (UART_Handle handle,
500  const void *buffer,
501  size_t size);
502 
507 typedef void (*UART_WriteCancelFxn) (UART_Handle handle);
508 
514 typedef struct UART_FxnTable {
517 
520 
523 
526 
529 
532 
535 
538 
541 
544 } UART_FxnTable;
545 
557 typedef struct UART_Config {
560 
562  void *object;
563 
565  void const *hwAttrs;
566 } UART_Config;
567 
577 extern void UART_close(UART_Handle handle);
578 
616 extern int UART_control(UART_Handle handle, unsigned int cmd, void *arg);
617 
625 extern void UART_init(void);
626 
648 extern UART_Handle UART_open(unsigned int index, UART_Params *params);
649 
672 extern void UART_Params_init(UART_Params *params);
673 
705 extern int UART_write(UART_Handle handle, const void *buffer, size_t size);
706 
730 extern int UART_writePolling(UART_Handle handle, const void *buffer,
731  size_t size);
732 
741 extern void UART_writeCancel(UART_Handle handle);
742 
771 extern int UART_read(UART_Handle handle, void *buffer, size_t size);
772 
793 extern int UART_readPolling(UART_Handle handle, void *buffer, size_t size);
794 
803 extern void UART_readCancel(UART_Handle handle);
804 
805 #ifdef __cplusplus
806 }
807 #endif
808 
809 #endif /* ti_drivers_UART__include */
struct UART_Params UART_Params
UART Parameters.
Definition: UART.h:407
UART_STOP
UART stop bit settings.
Definition: UART.h:396
struct UART_Config UART_Config
UART Global configuration.
void(* UART_CloseFxn)(UART_Handle handle)
A function pointer to a driver specific implementation of UART_CloseFxn().
Definition: UART.h:445
UART_Callback writeCallback
Definition: UART.h:428
int(* UART_ReadFxn)(UART_Handle handle, void *buffer, size_t size)
A function pointer to a driver specific implementation of UART_ReadFxn().
Definition: UART.h:471
void const * hwAttrs
Definition: UART.h:565
Definition: UART.h:320
UART_LEN dataLength
Definition: UART.h:434
Definition: UART.h:409
The definition of a UART function table that contains the required set of functions to control a spec...
Definition: UART.h:514
Definition: UART.h:388
UART_Callback readCallback
Definition: UART.h:427
int UART_writePolling(UART_Handle handle, const void *buffer, size_t size)
Function that writes data to a UART, polling the peripheral to wait until new data can be written...
UART_PAR
UART parity type settings.
Definition: UART.h:406
Definition: UART.h:375
unsigned int writeTimeout
Definition: UART.h:426
UART_ControlFxn controlFxn
Definition: UART.h:519
UART_Mode
UART mode settings.
Definition: UART.h:308
Definition: UART.h:411
Definition: UART.h:358
UART_Handle UART_open(unsigned int index, UART_Params *params)
Function to initialize a given UART peripheral.
UART_PAR parityType
Definition: UART.h:436
UART_DataMode
UART data mode settings.
Definition: UART.h:356
UART_Echo readEcho
Definition: UART.h:432
UART_ReturnMode
UART return mode settings.
Definition: UART.h:341
UART_WritePollingFxn writePollingFxn
Definition: UART.h:540
struct UART_Config * UART_Handle
A handle that is returned from a UART_open() call.
Definition: UART.h:282
struct UART_FxnTable UART_FxnTable
The definition of a UART function table that contains the required set of functions to control a spec...
void UART_close(UART_Handle handle)
Function to close a UART peripheral specified by the UART handle.
Definition: UART.h:313
void UART_readCancel(UART_Handle handle)
Function that cancels a UART_read() function call.
UART_Echo
UART echo settings.
Definition: UART.h:374
int(* UART_ReadPollingFxn)(UART_Handle handle, void *buffer, size_t size)
A function pointer to a driver specific implementation of UART_ReadPollingFxn().
Definition: UART.h:478
int UART_read(UART_Handle handle, void *buffer, size_t size)
Function that reads data from a UART with interrupt enabled. This API must be used mutually exclusive...
Definition: UART.h:397
UART_Mode writeMode
Definition: UART.h:424
int(* UART_ControlFxn)(UART_Handle handle, unsigned int cmd, void *arg)
A function pointer to a driver specific implementation of UART_ControlFxn().
Definition: UART.h:451
UART_STOP stopBits
Definition: UART.h:435
UART_ReturnMode readReturnMode
Definition: UART.h:429
UART_CloseFxn closeFxn
Definition: UART.h:516
Definition: UART.h:346
void UART_init(void)
Function to initialize the UART module.
int UART_control(UART_Handle handle, unsigned int cmd, void *arg)
Function performs implementation specific features on a given UART_Handle.
uint32_t baudRate
Definition: UART.h:433
UART_Handle(* UART_OpenFxn)(UART_Handle handle, UART_Params *params)
A function pointer to a driver specific implementation of UART_OpenFxn().
Definition: UART.h:465
int(* UART_WriteFxn)(UART_Handle handle, const void *buffer, size_t size)
A function pointer to a driver specific implementation of UART_WriteFxn().
Definition: UART.h:491
Definition: UART.h:357
Definition: UART.h:410
void UART_Params_init(UART_Params *params)
Function to initialize the UART_Params struct to its defaults.
void UART_writeCancel(UART_Handle handle)
Function that cancels a UART_write() function call.
uintptr_t custom
Definition: UART.h:437
Definition: UART.h:385
Definition: UART.h:386
UART_DataMode readDataMode
Definition: UART.h:430
UART_WriteCancelFxn writeCancelFxn
Definition: UART.h:543
Definition: UART.h:376
Definition: UART.h:398
void(* UART_InitFxn)(UART_Handle handle)
A function pointer to a driver specific implementation of UART_InitFxn().
Definition: UART.h:459
Definition: UART.h:387
UART_ReadPollingFxn readPollingFxn
Definition: UART.h:531
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:301
Definition: UART.h:408
unsigned int readTimeout
Definition: UART.h:425
UART_ReadCancelFxn readCancelFxn
Definition: UART.h:534
int UART_readPolling(UART_Handle handle, void *buffer, size_t size)
Function that reads data from a UART without interrupts. This API must be used mutually exclusive wit...
UART_LEN
UART data length settings.
Definition: UART.h:384
void(* UART_ReadCancelFxn)(UART_Handle handle)
A function pointer to a driver specific implementation of UART_ReadCancelFxn().
Definition: UART.h:485
UART Parameters.
Definition: UART.h:422
UART_FxnTable const * fxnTablePtr
Definition: UART.h:559
UART_ReadFxn readFxn
Definition: UART.h:528
UART_OpenFxn openFxn
Definition: UART.h:525
void(* UART_WriteCancelFxn)(UART_Handle handle)
A function pointer to a driver specific implementation of UART_WriteCancelFxn().
Definition: UART.h:507
Definition: UART.h:343
UART_DataMode writeDataMode
Definition: UART.h:431
UART_Mode readMode
Definition: UART.h:423
UART_WriteFxn writeFxn
Definition: UART.h:537
int(* UART_WritePollingFxn)(UART_Handle handle, const void *buffer, size_t size)
A function pointer to a driver specific implementation of UART_WritePollingFxn(). ...
Definition: UART.h:499
void * object
Definition: UART.h:562
UART Global configuration.
Definition: UART.h:557
UART_InitFxn initFxn
Definition: UART.h:522
int UART_write(UART_Handle handle, const void *buffer, size_t size)
Function that writes data to a UART with interrupts enabled. Usage of this API is mutually exclusive ...
Copyright 2016, Texas Instruments Incorporated