PDK API Guide for J721E
UART.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2019, 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  */
32 
38 /* @} */
39 
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 
138 
139 #define UART_SUCCESS ((int32_t)(0))
140 #define UART_ERROR (-((int32_t)1))
141 
149 #define UART_ERRNO_BASE (0)
150 
154 #define UART_EINVAL (UART_ERRNO_BASE-1)
155 
160 #define UART_EINUSE (UART_ERRNO_BASE-2)
161 
165 #define UART_ENOTIMPL (UART_ERRNO_BASE-3)
166 
172 typedef struct UART_Config_s *UART_Handle;
173 
184 typedef void (*UART_Callback) (UART_Handle handle, void *buf, size_t count);
185 
189 #define UART_NO_WAIT ((uint32_t)0U)
190 #define UART_WAIT_FOREVER (~((uint32_t)0U))
191 
195 typedef enum UART_TransferApiVer_s {
198 
200 
204 typedef enum UART_TransferStatus_s {
206  UART_TRANSFER_STATUS_TIMEOUT, /* Time out error */
207  UART_TRANSFER_STATUS_ERROR_BI, /* Break condition error */
208  UART_TRANSFER_STATUS_ERROR_FE, /* Framing error */
209  UART_TRANSFER_STATUS_ERROR_PE, /* Parity error */
210  UART_TRANSFER_STATUS_ERROR_OE, /* Overrun error */
212 
214 
219 typedef struct UART_Transaction_s {
220  /* User input (write-only) fields */
221  void *buf;
222  uint32_t timeout;
224  /* User input (write-only) and output (read-only) fields */
225  uint32_t count;
227  /* User output (read-only) fields */
230  /* Driver-use only fields */
232 
247 typedef void (*UART_Callback2) (UART_Handle handle, UART_Transaction *transaction);
248 
255 typedef enum UART_Mode_e {
261 
267 } UART_Mode;
268 
278 typedef enum UART_ReturnMode_e {
281 
285 
295 typedef enum UART_DataMode_e {
298 } UART_DataMode;
299 
313 typedef enum UART_Echo_e {
316 } UART_Echo;
317 
324 typedef enum UART_LEN_e {
329 #ifdef PRU_ICSS_FW // PRU UART FW SW IP only
330  UART_LEN_9 = 4
331 #endif
332 } UART_LEN;
333 
339 typedef enum UART_STOP_e {
342 #ifdef PRU_ICSS_FW // PRU UART FW SW IP only, currently unsupported by HW IP driver
343  UART_STOP_ONEP5 = 2
344 #endif
345 } UART_STOP;
346 
352 typedef enum UART_PAR_e {
358 } UART_PAR;
359 
365 typedef enum UART_FC_TYPE_e {
368 } UART_FC_TYPE;
369 
373 typedef struct UART_Params_s {
376  uint32_t readTimeout;
377  uint32_t writeTimeout;
384  uint32_t baudRate;
392 } UART_Params;
393 
398 typedef void (*UART_CloseFxn) (UART_Handle handle);
399 
404 typedef int32_t (*UART_ControlFxn) (UART_Handle handle,
405  uint32_t cmd,
406  void *arg);
407 
412 typedef void (*UART_InitFxn) (UART_Handle handle);
413 
419  const UART_Params *params);
424 typedef int32_t (*UART_ReadFxn) (UART_Handle handle, void *buffer,
425  size_t size);
426 
431 typedef int32_t (*UART_ReadPollingFxn) (UART_Handle handle, void *buffer,
432  size_t size);
433 
438 typedef void (*UART_ReadCancelFxn) (UART_Handle handle);
439 
444 typedef int32_t (*UART_WriteFxn) (UART_Handle handle,
445  const void *buffer,
446  size_t size);
447 
452 typedef int32_t (*UART_WritePollingFxn) (UART_Handle handle,
453  const void *buffer,
454  size_t size);
455 
460 typedef void (*UART_WriteCancelFxn) (UART_Handle handle);
461 
466 typedef int32_t (*UART_ReadFxn2) (UART_Handle handle,
467  UART_Transaction *transaction);
472 typedef int32_t (*UART_WriteFxn2) (UART_Handle handle,
473  UART_Transaction *transaction);
474 
480 typedef struct UART_FxnTable_s {
505 
506 } UART_FxnTable;
507 
519 typedef struct UART_Config_s {
522 
524  void *object;
525 
527  void const *hwAttrs;
528 } UART_Config;
529 
530 #define UART_MAX_CONFIG_CNT (14U)
532 
543 extern void UART_close(UART_Handle uartHnd);
544 
562 extern int32_t UART_control(UART_Handle uartHnd, uint32_t cmd, void *arg);
563 
572 extern void UART_init(void);
573 
592 extern UART_Handle UART_open(uint32_t idx, UART_Params *uartParams);
593 
614 extern void UART_Params_init(UART_Params *uartParams);
615 
616 
638 extern int32_t UART_write(UART_Handle uartHnd, const void *buffer, size_t size);
639 
657 extern int32_t UART_writePolling(UART_Handle uartHnd, const void *buffer,
658  size_t size);
659 
668 extern void UART_writeCancel(UART_Handle handle);
669 
691 extern int32_t UART_read(UART_Handle handle, void *buffer, size_t size);
692 
710 extern int32_t UART_readPolling(UART_Handle handle, void *buffer, size_t size);
711 
720 extern void UART_readCancel(UART_Handle handle);
721 
750 extern int32_t UART_read2(UART_Handle handle, UART_Transaction *uartTrans);
751 
780 extern int32_t UART_write2(UART_Handle handle, UART_Transaction *uartTrans);
781 
793 extern void UART_transactionInit(UART_Transaction *uartTrans);
794 
795 #ifdef __cplusplus
796 }
797 #endif
798 
799 #endif /* ti_drivers_UART__include */
800 
801 /* @} */
Definition: UART.h:209
UART_InitFxn uartInitFxn
Definition: UART.h:486
Definition: UART.h:260
Definition: UART.h:207
int32_t(* UART_ReadFxn)(UART_Handle handle, void *buffer, size_t size)
A function pointer to a driver specific implementation of UART_ReadFxn().
Definition: UART.h:424
UART_Callback2 writeCallback2
Definition: UART.h:389
UART_ReadFxn2 readFxn2
Definition: UART.h:502
UART_Echo
UART echo settings.
Definition: UART.h:313
void * object
Definition: UART.h:524
Definition: UART.h:327
UART_OpenFxn openFxn
Definition: UART.h:488
Definition: UART.h:341
UART_Handle(* UART_OpenFxn)(UART_Handle handle, const UART_Params *params)
A function pointer to a driver specific implementation of UART_OpenFxn().
Definition: UART.h:418
void UART_writeCancel(UART_Handle handle)
Function that cancels a UART_write function call.
#define UART_MAX_CONFIG_CNT
Definition: UART.h:530
UART_TransferStatus status
Definition: UART.h:228
Definition: UART.h:205
uint32_t count
Definition: tisci_rm_ra.h:166
Definition: UART.h:357
Definition: UART.h:355
Definition: UART.h:210
Definition: UART.h:326
UART_Config UART_config_list[UART_MAX_CONFIG_CNT]
Definition: UART.h:531
int32_t UART_write(UART_Handle uartHnd, const void *buffer, size_t size)
Function that writes data to a UART.
UART_STOP
UART stop bit settings.
Definition: UART.h:339
UART_LEN
UART data length settings.
Definition: UART.h:324
uint8_t hwFlowControlThr
Definition: UART.h:391
UART_STOP stopBits
Definition: UART.h:386
void(* UART_CloseFxn)(UART_Handle handle)
A function pointer to a driver specific implementation of UART_CloseFxn().
Definition: UART.h:398
The definition of a UART function table that contains the required set of functions to control a spec...
Definition: UART.h:480
void UART_transactionInit(UART_Transaction *uartTrans)
Function to initialize the UART_Transaction struct to its defaults.
Definition: UART.h:197
void UART_close(UART_Handle uartHnd)
Function to closes a given UART peripheral specified by the UART handle.
Definition: UART.h:328
UART_WriteFxn2 writeFxn2
Definition: UART.h:504
void * buf
Definition: UART.h:221
struct UART_Config_s * UART_Handle
A handle that is returned from a UART_open() call.
Definition: UART.h:172
Definition: UART.h:208
UART_WriteCancelFxn writeCancelFxn
Definition: UART.h:500
UART_FC_TYPE flowControlType
Definition: UART.h:390
UART_DataMode readDataMode
Definition: UART.h:381
Definition: UART.h:314
uint32_t readTimeout
Definition: UART.h:376
uint32_t writeTimeout
Definition: UART.h:377
UART_Callback writeCallback
Definition: UART.h:379
int32_t UART_read(UART_Handle handle, void *buffer, size_t size)
Function that read data from a UART.
UART_TransferApiVer
Transfer API version.
Definition: UART.h:195
int32_t(* UART_ReadFxn2)(UART_Handle handle, UART_Transaction *transaction)
A function pointer to a driver specific implementation of UART_ReadFxn2().
Definition: UART.h:466
UART_WritePollingFxn writePollingFxn
Definition: UART.h:498
int32_t(* UART_ReadPollingFxn)(UART_Handle handle, void *buffer, size_t size)
A function pointer to a driver specific implementation of UART_ReadPollingFxn().
Definition: UART.h:431
Definition: UART.h:206
UART_FC_TYPE
UART flow control settings.
Definition: UART.h:365
Definition: UART.h:297
void(* UART_Callback2)(UART_Handle handle, UART_Transaction *transaction)
The definition of a callback2 function used by the UART driver when used in UART_MODE_CALLBACK.
Definition: UART.h:247
Definition: UART.h:315
Definition: UART.h:354
int32_t(* UART_WriteFxn2)(UART_Handle handle, UART_Transaction *transaction)
A function pointer to a driver specific implementation of UART_WriteFxn2().
Definition: UART.h:472
uint32_t timeout
Definition: UART.h:222
Definition: UART.h:266
int32_t UART_writePolling(UART_Handle uartHnd, const void *buffer, size_t size)
Function that writes data to a UART.
uint32_t count
Definition: UART.h:225
Definition: UART.h:211
int32_t UART_read2(UART_Handle handle, UART_Transaction *uartTrans)
Extended function that read data from a UART.
UART_FxnTable const * fxnTablePtr
Definition: UART.h:521
UART_DataMode writeDataMode
Definition: UART.h:382
int32_t(* UART_ControlFxn)(UART_Handle handle, uint32_t cmd, void *arg)
A function pointer to a driver specific implementation of UART_ControlFxn().
Definition: UART.h:404
UART_DataMode
UART data mode settings.
Definition: UART.h:295
Definition: UART.h:367
UART_PAR parityType
Definition: UART.h:387
UART_LEN dataLength
Definition: UART.h:385
Definition: UART.h:283
UART_Handle UART_open(uint32_t idx, UART_Params *uartParams)
Function to initialize a given UART peripheral specified by the particular index value....
int32_t(* UART_WriteFxn)(UART_Handle handle, const void *buffer, size_t size)
A function pointer to a driver specific implementation of UART_CloseFxn().
Definition: UART.h:444
UART_TransferStatus
Transfer status codes that are set by the UART driver.
Definition: UART.h:204
UART_ReadCancelFxn readCancelFxn
Definition: UART.h:494
Definition: UART.h:366
UART_Callback2 readCallback2
Definition: UART.h:388
Definition: UART.h:325
void const * hwAttrs
Definition: UART.h:527
UART_ReturnMode readReturnMode
Definition: UART.h:380
UART Global configuration.
Definition: UART.h:519
UART_PAR
UART parity type settings.
Definition: UART.h:352
A UART_Transaction data structure is used with UART_read2(), UART_write2() and UART_Callback2()
Definition: UART.h:219
int32_t UART_write2(UART_Handle handle, UART_Transaction *uartTrans)
Extended function that writes data to a UART.
UART_Mode writeMode
Definition: UART.h:375
UART_Echo readEcho
Definition: UART.h:383
UART_ReadPollingFxn readPollingFxn
Definition: UART.h:492
uint32_t baudRate
Definition: UART.h:384
UART_WriteFxn writeFxn
Definition: UART.h:496
Basic UART Parameters.
Definition: UART.h:373
int32_t(* 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:452
uint16_t size
Definition: tisci_boardcfg.h:112
void(* UART_WriteCancelFxn)(UART_Handle handle)
A function pointer to a driver specific implementation of UART_WriteCancelFxn().
Definition: UART.h:460
UART_Mode
UART mode settings.
Definition: UART.h:255
void(* UART_ReadCancelFxn)(UART_Handle handle)
A function pointer to a driver specific implementation of UART_ReadCancelFxn().
Definition: UART.h:438
Definition: UART.h:296
UART_ReturnMode
UART return mode settings.
Definition: UART.h:278
UART_CloseFxn closeFxn
Definition: UART.h:482
UART_ReadFxn readFxn
Definition: UART.h:490
Definition: UART.h:280
UART_Callback readCallback
Definition: UART.h:378
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.
Definition: UART.h:184
Definition: UART.h:353
UART_Mode readMode
Definition: UART.h:374
Definition: UART.h:196
void UART_readCancel(UART_Handle handle)
Function that cancels a UART_read function call.
int32_t UART_readPolling(UART_Handle handle, void *buffer, size_t size)
Function that reads data from a UART.
void UART_init(void)
Function to initializes the UART module.
UART_ControlFxn controlFxn
Definition: UART.h:484
Definition: UART.h:356
int32_t UART_control(UART_Handle uartHnd, uint32_t cmd, void *arg)
Function performs implementation specific features on a given UART_Handle.
void UART_Params_init(UART_Params *uartParams)
Function to initialize the UART_Params struct to its defaults.
Definition: UART.h:340
void(* UART_InitFxn)(UART_Handle handle)
A function pointer to a driver specific implementation of UART_InitFxn().
Definition: UART.h:412