PDK API Guide for J721E
common.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (c) 2019 Texas Instruments Incorporated - http://www.ti.com
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * 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
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  *****************************************************************************/
33 
42 #ifndef _COMMON_H_
43 #define _COMMON_H_
44 
57 /* @} */
58 
59 #include <ti/drv/uart/UART.h>
60 #include <ti/drv/uart/UART_stdio.h>
61 
62 #include <ti/drv/i2c/I2C.h>
63 #include <ti/drv/i2c/soc/I2C_soc.h>
64 
65 #include <ti/board/board.h>
66 
67 #include <ti/osal/osal.h>
68 #include <stdio.h>
69 #include <stdint.h>
70 #include <stdlib.h>
71 #include <string.h>
72 
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
76 
87 #define BOARD_DEVICES_CONFIG_END (-1)
88 
89 /* Define below macros to enable the debug logs from board device library */
90 /* Enables status logs */
91 #undef BOARD_DEVICES_ENABLE_STATUS_LOGS
92 /* Enables error logs which are displayed during function execution failure */
93 #undef BOARD_DEVICES_ENABLE_ERROR_LOGS
94 
95 #if defined(BOARD_DEVICES_ENABLE_STATUS_LOGS)
96 #define BOARD_DEVICES_STS_LOG UART_printf
97 #else
98 #define BOARD_DEVICES_STS_LOG(x, ...)
99 #endif /* #if defined(BOARD_DEVICES_ENABLE_STATUS_LOGS) */
100 
101 #if defined(BOARD_DEVICES_ENABLE_ERROR_LOGS)
102 #define BOARD_DEVICES_ERR_LOG UART_printf
103 #else
104 #define BOARD_DEVICES_ERR_LOG(x, ...)
105 #endif /* #if defined(BOARD_DEVICES_ENABLE_ERROR_LOGS) */
106 
107 #define BOARD_FPD_MAX_REMOTE_SENSOR_DEVICES (8U)
108 
110 #define BOARD_FPD_MODE_DISABLE (0U)
111 
112 #define BOARD_FPD_MODE_ENABLE (1U)
113 
115 #define BOARD_FPD_MODE_NORMAL (0U)
116 
117 #define BOARD_FPD_MODE_RESET (1U)
118 
120 #define BOARD_FPD_KBPS_100 (0x64U)
121 
122 #define BOARD_FPD_KBPS_400 (0x32U)
123 
125 #define BOARD_I2C_REG_ADDR_MSB_FIRST (0x0U)
126 
128 #define BOARD_I2C_REG_ADDR_LSB_FIRST (0x1U)
129 
130 #define ONE_MILLI_SEC (1U)
131 
133 #define BOARD_FPD_I2C_CFG_DELAY (5 * ONE_MILLI_SEC)
134 
136 #define BOARD_I2C_TRANSACTION_TIMEOUT (2000U)
137 
141 typedef struct Board_FpdRmtDevObj_s
142 {
144  uint32_t i2cDevAddr;
146  uint32_t i2cDevAliasAddr;
148 
152 typedef struct Board_FpdModuleObj_s
153 {
155  uint32_t desSlvAddr;
157  uint32_t serSlvAddr;
159  uint32_t serDesAliasAddr;
161 
165 typedef struct Board_I2cRegProgObj_s
166 {
168  int32_t regAddr;
170  uint32_t regData;
172  uint32_t i2cDelay;
174 
175 /* @} */
176 
196 void Board_delay(uint32_t delayCycles);
197 
214 Board_STATUS Board_i2c16BitRegRd(void *handle,
215  uint32_t slaveAddr,
216  uint16_t regAddr,
217  uint8_t *regData,
218  uint8_t numOfBytes,
219  uint8_t byteOrdSel,
220  uint32_t i2cTimeout);
221 
238 Board_STATUS Board_i2c16BitRegWr(void *handle,
239  uint32_t slaveAddr,
240  uint16_t regAddr,
241  uint8_t *regData,
242  uint8_t numOfBytes,
243  uint8_t byteOrdSel,
244  uint32_t i2cTimeout);
245 
261 Board_STATUS Board_i2c8BitRegRd(void *handle,
262  uint32_t slaveAddr,
263  uint8_t regAddr,
264  uint8_t *regData,
265  uint8_t numOfBytes,
266  uint32_t i2cTimeout);
267 
283 Board_STATUS Board_i2c8BitRegWr(void *handle,
284  uint32_t slaveAddr,
285  uint8_t regAddr,
286  uint8_t *regData,
287  uint8_t numOfBytes,
288  uint32_t i2cTimeout);
289 
304 Board_STATUS Board_i2c10bit16bitRegRd(void *handle,
305  uint32_t slaveAddr,
306  uint16_t regAddr,
307  uint16_t *regData,
308  uint32_t i2cTimeout);
309 
324 Board_STATUS Board_i2c10bit16bitRegWr(void *handle,
325  uint32_t slaveAddr,
326  uint16_t regAddr,
327  uint16_t regData,
328  uint32_t i2cTimeout);
329 #ifdef __cplusplus
330 }
331 #endif /* __cplusplus */
332 
333 #endif /* _COMMON_H_ */
334 
335 /* @} */
This header file contains function prototypes which interface interactively with the user through the...
Board_STATUS Board_i2c16BitRegRd(void *handle, uint32_t slaveAddr, uint16_t regAddr, uint8_t *regData, uint8_t numOfBytes, uint8_t byteOrdSel, uint32_t i2cTimeout)
I2C 16-bit register read function.
OS Abstraction Layer header.
int32_t regAddr
Definition: common.h:168
Board_STATUS Board_i2c16BitRegWr(void *handle, uint32_t slaveAddr, uint16_t regAddr, uint8_t *regData, uint8_t numOfBytes, uint8_t byteOrdSel, uint32_t i2cTimeout)
I2C 16-bit register write function.
FPD remote device object structure.
Definition: common.h:165
uint32_t i2cDevAliasAddr
Definition: common.h:146
Board_STATUS Board_i2c10bit16bitRegWr(void *handle, uint32_t slaveAddr, uint16_t regAddr, uint16_t regData, uint32_t i2cTimeout)
I2C 10-bit slave address register write function.
I2C driver interface.
Board_STATUS Board_i2c8BitRegWr(void *handle, uint32_t slaveAddr, uint8_t regAddr, uint8_t *regData, uint8_t numOfBytes, uint32_t i2cTimeout)
I2C 8-bit register write function.
Board_STATUS Board_i2c8BitRegRd(void *handle, uint32_t slaveAddr, uint8_t regAddr, uint8_t *regData, uint8_t numOfBytes, uint32_t i2cTimeout)
I2C 8-bit register read function.
Board_STATUS Board_i2c10bit16bitRegRd(void *handle, uint32_t slaveAddr, uint16_t regAddr, uint16_t *regData, uint32_t i2cTimeout)
I2C 10-bit slave address register read function.
uint32_t serSlvAddr
Definition: common.h:157
FPD module object structure.
Definition: common.h:152
uint32_t regData
Definition: common.h:170
uint32_t i2cDelay
Definition: common.h:172
uint32_t desSlvAddr
Definition: common.h:155
FPD remote device object structure.
Definition: common.h:141
void Board_delay(uint32_t delayCycles)
Delay generation function.
UART driver interface.
The Board Library is a thin utility layer on top of CSL and other board utilities....
uint32_t i2cDevAddr
Definition: common.h:144
uint32_t serDesAliasAddr
Definition: common.h:159