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  uint32_t procChrTimeoutInt;
393  uint16_t timeoutIntrVal;
394  uint32_t timeoutBehavior;
397 } UART_Params;
398 
403 typedef void (*UART_CloseFxn) (UART_Handle handle);
404 
409 typedef int32_t (*UART_ControlFxn) (UART_Handle handle,
410  uint32_t cmd,
411  void *arg);
412 
417 typedef void (*UART_InitFxn) (UART_Handle handle);
418 
424  const UART_Params *params);
429 typedef int32_t (*UART_ReadFxn) (UART_Handle handle, void *buffer,
430  size_t size);
431 
436 typedef int32_t (*UART_ReadPollingFxn) (UART_Handle handle, void *buffer,
437  size_t size);
438 
443 typedef void (*UART_ReadCancelFxn) (UART_Handle handle);
444 
449 typedef int32_t (*UART_WriteFxn) (UART_Handle handle,
450  const void *buffer,
451  size_t size);
452 
457 typedef int32_t (*UART_WritePollingFxn) (UART_Handle handle,
458  const void *buffer,
459  size_t size);
460 
465 typedef void (*UART_WriteCancelFxn) (UART_Handle handle);
466 
471 typedef int32_t (*UART_ReadFxn2) (UART_Handle handle,
472  UART_Transaction *transaction);
477 typedef int32_t (*UART_WriteFxn2) (UART_Handle handle,
478  UART_Transaction *transaction);
479 
485 typedef struct UART_FxnTable_s {
510 
511 } UART_FxnTable;
512 
524 typedef struct UART_Config_s {
527 
529  void *object;
530 
532  void const *hwAttrs;
533 } UART_Config;
534 
535 #define UART_MAX_CONFIG_CNT (14U)
537 
548 extern void UART_close(UART_Handle uartHnd);
549 
567 extern int32_t UART_control(UART_Handle uartHnd, uint32_t cmd, void *arg);
568 
577 extern void UART_init(void);
578 
597 extern UART_Handle UART_open(uint32_t idx, UART_Params *uartParams);
598 
619 extern void UART_Params_init(UART_Params *uartParams);
620 
621 
643 extern int32_t UART_write(UART_Handle uartHnd, const void *buffer, size_t size);
644 
662 extern int32_t UART_writePolling(UART_Handle uartHnd, const void *buffer,
663  size_t size);
664 
673 extern void UART_writeCancel(UART_Handle handle);
674 
696 extern int32_t UART_read(UART_Handle handle, void *buffer, size_t size);
697 
715 extern int32_t UART_readPolling(UART_Handle handle, void *buffer, size_t size);
716 
725 extern void UART_readCancel(UART_Handle handle);
726 
755 extern int32_t UART_read2(UART_Handle handle, UART_Transaction *uartTrans);
756 
785 extern int32_t UART_write2(UART_Handle handle, UART_Transaction *uartTrans);
786 
798 extern void UART_transactionInit(UART_Transaction *uartTrans);
799 
800 #ifdef __cplusplus
801 }
802 #endif
803 
804 #endif /* ti_drivers_UART__include */
805 
806 /* @} */
Definition: UART.h:209
UART_InitFxn uartInitFxn
Definition: UART.h:491
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:429
UART_Callback2 writeCallback2
Definition: UART.h:389
UART_ReadFxn2 readFxn2
Definition: UART.h:507
UART_Echo
UART echo settings.
Definition: UART.h:313
void * object
Definition: UART.h:529
Definition: UART.h:327
UART_OpenFxn openFxn
Definition: UART.h:493
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:423
void UART_writeCancel(UART_Handle handle)
Function that cancels a UART_write function call.
#define UART_MAX_CONFIG_CNT
Definition: UART.h:535
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:536
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:403
The definition of a UART function table that contains the required set of functions to control a spec...
Definition: UART.h:485
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:509
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:505
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:471
UART_WritePollingFxn writePollingFxn
Definition: UART.h:503
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:436
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
uint32_t timeoutBehavior
Definition: UART.h:394
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:477
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:526
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:409
uint16_t timeoutIntrVal
Definition: UART.h:393
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
gptp_ipc_command_t cmd
Definition: gptpipc.h:140
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:449
UART_TransferStatus
Transfer status codes that are set by the UART driver.
Definition: UART.h:204
UART_ReadCancelFxn readCancelFxn
Definition: UART.h:499
Definition: UART.h:366
uint32_t procChrTimeoutInt
Definition: UART.h:392
UART_Callback2 readCallback2
Definition: UART.h:388
Definition: UART.h:325
void const * hwAttrs
Definition: UART.h:532
UART_ReturnMode readReturnMode
Definition: UART.h:380
UART Global configuration.
Definition: UART.h:524
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:497
uint32_t baudRate
Definition: UART.h:384
UART_WriteFxn writeFxn
Definition: UART.h:501
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:457
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:465
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:443
Definition: UART.h:296
UART_ReturnMode
UART return mode settings.
Definition: UART.h:278
UART_CloseFxn closeFxn
Definition: UART.h:487
UART_ReadFxn readFxn
Definition: UART.h:495
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:489
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:417