| 1 | /** |
|---|
| 2 | Copyright (C) 2008 NXP B.V., All Rights Reserved. |
|---|
| 3 | This source code and any compilation or derivative thereof is the proprietary |
|---|
| 4 | information of NXP B.V. and is confidential in nature. Under no circumstances |
|---|
| 5 | is this software to be exposed to or placed under an Open Source License of |
|---|
| 6 | any type without the expressed written permission of NXP B.V. |
|---|
| 7 | * |
|---|
| 8 | * \file tmdlI2C.h |
|---|
| 9 | * %version: 4 % |
|---|
| 10 | * |
|---|
| 11 | * \date %date_modified% |
|---|
| 12 | * |
|---|
| 13 | * \brief Describe briefly the purpose of this file. |
|---|
| 14 | * |
|---|
| 15 | * REFERENCE DOCUMENTS : |
|---|
| 16 | * |
|---|
| 17 | * Detailed description may be added here. |
|---|
| 18 | * |
|---|
| 19 | * \section info Change Information |
|---|
| 20 | * |
|---|
| 21 | * \verbatim |
|---|
| 22 | Date Modified by CRPRNr TASKNr Maintenance description |
|---|
| 23 | -------------|-----------|-------|-------|----------------------------------- |
|---|
| 24 | 9-JULY-2007 | A.TANT | | | CREATION OF I2C ARCHITECTURE 2.0.0 |
|---|
| 25 | -------------|-----------|-------|-------|----------------------------------- |
|---|
| 26 | | | | | |
|---|
| 27 | -------------|-----------|-------|-------|----------------------------------- |
|---|
| 28 | \endverbatim |
|---|
| 29 | * |
|---|
| 30 | */ |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | #ifndef TMDLI2C_H |
|---|
| 34 | #define TMDLI2C_H |
|---|
| 35 | |
|---|
| 36 | #ifdef __cplusplus |
|---|
| 37 | extern "C" { |
|---|
| 38 | #endif |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | /*============================================================================*/ |
|---|
| 42 | /* INCLUDE FILES */ |
|---|
| 43 | /*============================================================================*/ |
|---|
| 44 | |
|---|
| 45 | /*============================================================================*/ |
|---|
| 46 | /* MACRO DEFINITION */ |
|---|
| 47 | /*============================================================================*/ |
|---|
| 48 | |
|---|
| 49 | /* SW Error codes */ |
|---|
| 50 | #define I2C_ERR_BASE (CID_COMP_PARPORT | CID_LAYER_HWAPI) |
|---|
| 51 | #define I2C_ERR_COMP (CID_COMP_PARPORT | CID_LAYER_HWAPI | TM_ERR_COMP_UNIQUE_START) |
|---|
| 52 | |
|---|
| 53 | #define I2C_ERR_BAD_UNIT_NUMBER (I2C_ERR_BASE + TM_ERR_BAD_UNIT_NUMBER) |
|---|
| 54 | #define I2C_ERR_NOT_INITIALIZED (I2C_ERR_BASE + TM_ERR_NOT_INITIALIZED) |
|---|
| 55 | //#define I2C_ERR_INIT_FAILED (I2C_ERR_BASE + TM_ERR_INIT_FAILED) |
|---|
| 56 | #define I2C_ERR_BAD_PARAMETER (I2C_ERR_BASE + TM_ERR_BAD_PARAMETER) |
|---|
| 57 | #define I2C_ERR_NOT_SUPPORTED (I2C_ERR_BASE + TM_ERR_NOT_SUPPORTED) |
|---|
| 58 | #define I2C_ERR_NOT_INSTALLED (I2C_ERR_COMP + 0x0001) |
|---|
| 59 | #define I2C_ERR_FAILED (I2C_ERR_COMP + 0x0002) |
|---|
| 60 | #define I2C_ERR_HW (I2C_ERR_COMP + 0x0003) |
|---|
| 61 | //#define I2C_ERR_NOT_READY (I2C_ERR_COMP + 0x0002) |
|---|
| 62 | //#define I2C_ERR_BAD_CRC (I2C_ERR_COMP + 0x0003) |
|---|
| 63 | //#define I2C_ERR_BAD_VERSION (I2C_ERR_COMP + 0x0004) |
|---|
| 64 | |
|---|
| 65 | typedef enum _tmI2CInterfaceType_t { |
|---|
| 66 | tmI2CInterfaceUnknown = 0, /* No I2C Interface Defined */ |
|---|
| 67 | tmI2CInterfaceURTParallel, /* URT Parallel I2C Interface */ |
|---|
| 68 | tmI2CInterfaceURTUSB, /* URT USB I2C Interface */ |
|---|
| 69 | tmI2CInterfaceMMPParallel, /* MMP Parallel I2C Interface */ |
|---|
| 70 | tmI2CInterfaceCypressUSB, /* Cypress USB I2C Interface */ |
|---|
| 71 | tmI2CInterfaceNxpCyI2c, /* NXP USB I2C Interface based on Cypress */ |
|---|
| 72 | tmI2CInterfaceCH341USB, /* CH341 USB I2C Interface */ |
|---|
| 73 | tmI2CInterfaceFTDI, /* FTDI USB I2C Interface */ |
|---|
| 74 | tmI2CInterfaceCustomer, /* Customer I2C Interface */ |
|---|
| 75 | tmI2CInterfaceSimuSamba, /* Simu Samba I2C Interface */ |
|---|
| 76 | tmI2CInterfaceMax |
|---|
| 77 | } tmI2CInterfaceType_t, *ptmI2CInterfaceType_t; |
|---|
| 78 | |
|---|
| 79 | typedef enum _tmI2CPortType_t { |
|---|
| 80 | tmI2CPortUnknown = 0, /* No Port Type Defined */ |
|---|
| 81 | tmI2CPortLPT1, /* LPT1 Port Type */ |
|---|
| 82 | tmI2CPortLPT2, /* LPT2 Port Type */ |
|---|
| 83 | tmI2CPortLPT3, /* LPT3 Port Type */ |
|---|
| 84 | tmI2CPortUSB, /* USB Port Type */ |
|---|
| 85 | tmI2CPortMax |
|---|
| 86 | } tmI2CPortType_t, *ptmI2CPortType_t; |
|---|
| 87 | |
|---|
| 88 | typedef enum _tmI2CAction_t |
|---|
| 89 | { |
|---|
| 90 | tmI2CActionUnknown, |
|---|
| 91 | tmI2CActionWrite = 0, |
|---|
| 92 | tmI2CActionRead, |
|---|
| 93 | tmI2CActionMax |
|---|
| 94 | } tmI2CAction_t, *ptmI2CAction_t; |
|---|
| 95 | |
|---|
| 96 | typedef enum |
|---|
| 97 | { |
|---|
| 98 | tmI2CIdentModeUnknown = 0, |
|---|
| 99 | tmI2CIdentModePosition, |
|---|
| 100 | tmI2CIdentModeInstanceIndex, |
|---|
| 101 | tmI2CIdentModeSerialNumber, |
|---|
| 102 | tmI2CIdentModeMax |
|---|
| 103 | } tmI2CIdentMode_t, *ptmI2CIdentMode_t; |
|---|
| 104 | |
|---|
| 105 | typedef enum _tmI2CStartStop_t |
|---|
| 106 | { |
|---|
| 107 | tmI2CStartStop_NoStart_NoStop = 0, |
|---|
| 108 | tmI2CStartStop_Start_NoStop, |
|---|
| 109 | tmI2CStartStop_NoStart_Stop, |
|---|
| 110 | tmI2CStartStop_Start_Stop |
|---|
| 111 | } tmI2CStartStop_t, *ptmI2CStartStop_t; |
|---|
| 112 | |
|---|
| 113 | typedef struct _tmI2CLLDriverVersion |
|---|
| 114 | { |
|---|
| 115 | UInt32 major; |
|---|
| 116 | UInt32 minor; |
|---|
| 117 | UInt32 build; |
|---|
| 118 | UInt32 revision; |
|---|
| 119 | } tmI2CLLDriverVersion, *ptmI2CLLDriverVersion; |
|---|
| 120 | |
|---|
| 121 | // Serial Number |
|---|
| 122 | typedef struct _tmI2CSerialNumber |
|---|
| 123 | { |
|---|
| 124 | Bool biSerialNumberAvailable; |
|---|
| 125 | UInt8 iSerialNumber[32]; |
|---|
| 126 | UInt32 dwInstanceIndex; |
|---|
| 127 | } tmI2CSerialNumber, *ptmI2CSerialNumber; |
|---|
| 128 | |
|---|
| 129 | // Enumeration |
|---|
| 130 | typedef struct _tmI2CEnumDevices |
|---|
| 131 | { |
|---|
| 132 | UInt32 dwInstanceCount; |
|---|
| 133 | tmI2CSerialNumber devices[8]; |
|---|
| 134 | } tmI2CEnumDevices, *ptmI2CEnumDevices; |
|---|
| 135 | |
|---|
| 136 | typedef struct _tmI2CInterfaceConfig_t |
|---|
| 137 | { |
|---|
| 138 | tmI2CInterfaceType_t eInterfaceType; /* Interface Type */ |
|---|
| 139 | tmI2CPortType_t ePortType; /* Port Type */ |
|---|
| 140 | tmI2CIdentMode_t tIdentificationMode; |
|---|
| 141 | union |
|---|
| 142 | { |
|---|
| 143 | UInt8 position; |
|---|
| 144 | UInt32 dwInstanceIndex; |
|---|
| 145 | UInt8 serialNumber[32]; |
|---|
| 146 | }Identification; |
|---|
| 147 | UInt32 dwAdditionalDataSize; /* Additional Data Size */ |
|---|
| 148 | void* pAdditionalData; /* Additional Data Pointer */ |
|---|
| 149 | } tmI2CInterfaceConfig_t, *ptmI2CInterfaceConfig_t; |
|---|
| 150 | |
|---|
| 151 | // Callback for I2C Log |
|---|
| 152 | typedef tmErrorCode_t (*w_tmdlI2CCallBack) (tmUnitSelect_t tUnit, CUInt32 uHwAddress, CUInt32 addrSize, CUInt8* pAddr, CUInt32 dataSize, CUInt8* pData, tmErrorCode_t err, tmI2CAction_t i2cAction, Bool bHwAddrAsWriteAddr); |
|---|
| 153 | |
|---|
| 154 | #ifdef TMFL_NEWSPI |
|---|
| 155 | |
|---|
| 156 | typedef enum _tmSpiChipSelect_t |
|---|
| 157 | { |
|---|
| 158 | tmSpiChipSelect_Port1 = 0, |
|---|
| 159 | tmSpiChipSelect_Port2, |
|---|
| 160 | tmSpiChipSelect_Port3, |
|---|
| 161 | tmSpiChipSelect_Port4, |
|---|
| 162 | tmSpiChipSelect_Invalid |
|---|
| 163 | } tmSpiChipSelect_t, *ptmSpiChipSelect_t; |
|---|
| 164 | |
|---|
| 165 | typedef enum |
|---|
| 166 | { |
|---|
| 167 | tmSpiCsPolarityActiveHigh = 0, |
|---|
| 168 | tmSpiCsPolarityActiveLow |
|---|
| 169 | } tmSpiCsPolarityDef, *ptmSpiCsPolarityDef; |
|---|
| 170 | |
|---|
| 171 | typedef enum |
|---|
| 172 | { |
|---|
| 173 | tmSpiModeThreeLines = 0, |
|---|
| 174 | tmSpiModeFourLines |
|---|
| 175 | } tmSpiModeDef, *ptmSpiModeDef; |
|---|
| 176 | |
|---|
| 177 | #else |
|---|
| 178 | |
|---|
| 179 | typedef enum _tmSpiChipSelect_t |
|---|
| 180 | { |
|---|
| 181 | tmSpiChipSelect_PortD_Bit4 = 0, |
|---|
| 182 | tmSpiChipSelect_PortD_Bit5, |
|---|
| 183 | tmSpiChipSelect_PortD_Bit6, |
|---|
| 184 | tmSpiChipSelect_PortD_Bit7, |
|---|
| 185 | tmSpiChipSelect_Invalid |
|---|
| 186 | } tmSpiChipSelect_t, *ptmSpiChipSelect_t; |
|---|
| 187 | |
|---|
| 188 | #endif |
|---|
| 189 | |
|---|
| 190 | /*============================================================================*/ |
|---|
| 191 | /* EXTERN FUNCTION PROTOTYPES */ |
|---|
| 192 | /*============================================================================*/ |
|---|
| 193 | |
|---|
| 194 | extern tmErrorCode_t |
|---|
| 195 | tmdlI2CGetSWVersion |
|---|
| 196 | ( |
|---|
| 197 | ptmSWVersion_t pSWVersion /* O: Receives SW Version */ |
|---|
| 198 | ); |
|---|
| 199 | |
|---|
| 200 | extern tmErrorCode_t |
|---|
| 201 | tmdlI2CGetLowLevelSWVersion |
|---|
| 202 | ( |
|---|
| 203 | tmUnitSelect_t tUnit, |
|---|
| 204 | ptmSWVersion_t pSWVersion, /* O: Receives SW Version */ |
|---|
| 205 | ptmI2CLLDriverVersion pLLSWVersion /* O: Receives LL SW Version */ |
|---|
| 206 | ); |
|---|
| 207 | |
|---|
| 208 | extern tmErrorCode_t |
|---|
| 209 | tmdlI2CGetLowLevelDevices |
|---|
| 210 | ( |
|---|
| 211 | tmUnitSelect_t tUnit, |
|---|
| 212 | ptmI2CEnumDevices pDevices /* O: Receives LL Devices */ |
|---|
| 213 | ); |
|---|
| 214 | |
|---|
| 215 | extern tmErrorCode_t |
|---|
| 216 | tmdlI2CInit |
|---|
| 217 | ( |
|---|
| 218 | tmUnitSelect_t tUnit, /* I: FrontEnd unit number */ |
|---|
| 219 | tmbslFrontEndDependency_t* psSrvFunc |
|---|
| 220 | ); |
|---|
| 221 | |
|---|
| 222 | extern tmErrorCode_t |
|---|
| 223 | tmdlI2CDeInit |
|---|
| 224 | ( |
|---|
| 225 | tmUnitSelect_t tUnit |
|---|
| 226 | ); |
|---|
| 227 | |
|---|
| 228 | extern tmErrorCode_t |
|---|
| 229 | tmdlI2CSetInterface |
|---|
| 230 | ( |
|---|
| 231 | tmUnitSelect_t tUnit, |
|---|
| 232 | ptmI2CInterfaceConfig_t psI2CInterface |
|---|
| 233 | ); |
|---|
| 234 | |
|---|
| 235 | extern tmErrorCode_t |
|---|
| 236 | tmdlI2CSetPath |
|---|
| 237 | ( |
|---|
| 238 | tmUnitSelect_t tUnit, |
|---|
| 239 | int pPath_length, |
|---|
| 240 | wchar_t* My_path |
|---|
| 241 | ); |
|---|
| 242 | |
|---|
| 243 | extern tmErrorCode_t |
|---|
| 244 | tmdlI2CGetInterface |
|---|
| 245 | ( |
|---|
| 246 | tmUnitSelect_t tUnit, |
|---|
| 247 | ptmI2CInterfaceConfig_t psI2CInterface |
|---|
| 248 | ); |
|---|
| 249 | |
|---|
| 250 | extern tmErrorCode_t |
|---|
| 251 | tmdlI2CSetGPIO |
|---|
| 252 | ( |
|---|
| 253 | tmUnitSelect_t tUnit, |
|---|
| 254 | UInt8 Port, |
|---|
| 255 | UInt8 Mask, |
|---|
| 256 | UInt8 Value |
|---|
| 257 | ); |
|---|
| 258 | |
|---|
| 259 | extern tmErrorCode_t |
|---|
| 260 | tmdlI2CWrite |
|---|
| 261 | ( |
|---|
| 262 | tmUnitSelect_t tUnit, |
|---|
| 263 | UInt32 uHwAddress, |
|---|
| 264 | UInt32 AddrSize, |
|---|
| 265 | UInt8* pAddr, |
|---|
| 266 | UInt32 WriteLen, |
|---|
| 267 | UInt8* pData |
|---|
| 268 | ); |
|---|
| 269 | |
|---|
| 270 | extern tmErrorCode_t |
|---|
| 271 | tmdlI2CRead |
|---|
| 272 | ( |
|---|
| 273 | tmUnitSelect_t tUnit, |
|---|
| 274 | UInt32 uHwAddress, |
|---|
| 275 | UInt32 AddrSize, |
|---|
| 276 | UInt8* pAddr, |
|---|
| 277 | UInt32 ReadLen, |
|---|
| 278 | UInt8* pData |
|---|
| 279 | ); |
|---|
| 280 | |
|---|
| 281 | extern tmErrorCode_t |
|---|
| 282 | tmdlI2CReadAllI2cMap |
|---|
| 283 | ( |
|---|
| 284 | tmUnitSelect_t tUnit, |
|---|
| 285 | UInt32 uHwAddress, |
|---|
| 286 | UInt32 ReadLen, |
|---|
| 287 | UInt8* pData |
|---|
| 288 | ); |
|---|
| 289 | |
|---|
| 290 | extern tmErrorCode_t |
|---|
| 291 | tmdlI2CSetErrorEnable |
|---|
| 292 | ( |
|---|
| 293 | tmUnitSelect_t tUnit, |
|---|
| 294 | Bool bErrorEnable |
|---|
| 295 | ); |
|---|
| 296 | |
|---|
| 297 | extern tmErrorCode_t |
|---|
| 298 | tmdlI2CGetErrorEnable |
|---|
| 299 | ( |
|---|
| 300 | tmUnitSelect_t tUnit, |
|---|
| 301 | Bool* pbErrorEnable |
|---|
| 302 | ); |
|---|
| 303 | |
|---|
| 304 | extern tmErrorCode_t |
|---|
| 305 | tmdlI2CSetPortType |
|---|
| 306 | ( |
|---|
| 307 | tmUnitSelect_t tUnit, |
|---|
| 308 | tmI2CPortType_t dwPortType |
|---|
| 309 | ); |
|---|
| 310 | |
|---|
| 311 | extern tmErrorCode_t |
|---|
| 312 | tmdlI2CGetPortType |
|---|
| 313 | ( |
|---|
| 314 | tmUnitSelect_t tUnit, |
|---|
| 315 | ptmI2CPortType_t pdwPortType |
|---|
| 316 | ); |
|---|
| 317 | |
|---|
| 318 | extern tmErrorCode_t |
|---|
| 319 | tmdlI2CSetBitrate |
|---|
| 320 | ( |
|---|
| 321 | tmUnitSelect_t tUnit, |
|---|
| 322 | UInt32 dwBitrate |
|---|
| 323 | ); |
|---|
| 324 | |
|---|
| 325 | extern tmErrorCode_t |
|---|
| 326 | tmdlI2CGetBitrate |
|---|
| 327 | ( |
|---|
| 328 | tmUnitSelect_t tUnit, |
|---|
| 329 | UInt32* pdwBitrate |
|---|
| 330 | ); |
|---|
| 331 | |
|---|
| 332 | extern tmErrorCode_t |
|---|
| 333 | tmdlI2CSetHwAddrAsWriteAddr |
|---|
| 334 | ( |
|---|
| 335 | tmUnitSelect_t tUnit, |
|---|
| 336 | Bool bHwAddrAsWriteAddr |
|---|
| 337 | ); |
|---|
| 338 | |
|---|
| 339 | extern tmErrorCode_t |
|---|
| 340 | tmdlI2CGetHwAddrAsWriteAddr |
|---|
| 341 | ( |
|---|
| 342 | tmUnitSelect_t tUnit, |
|---|
| 343 | Bool* pbHwAddrAsWriteAddr |
|---|
| 344 | ); |
|---|
| 345 | extern tmErrorCode_t |
|---|
| 346 | tmdlI2CDeviceWrite |
|---|
| 347 | ( |
|---|
| 348 | tmUnitSelect_t tUnit, |
|---|
| 349 | UInt32 uHwAddress, |
|---|
| 350 | UInt32 WriteLen, |
|---|
| 351 | UInt8* pData, |
|---|
| 352 | tmI2CStartStop_t uStartStop |
|---|
| 353 | ); |
|---|
| 354 | extern tmErrorCode_t |
|---|
| 355 | tmdlI2CDeviceRead |
|---|
| 356 | ( |
|---|
| 357 | tmUnitSelect_t tUnit, |
|---|
| 358 | UInt32 uHwAddress, |
|---|
| 359 | UInt32 ReadLen, |
|---|
| 360 | UInt8* pData, |
|---|
| 361 | tmI2CStartStop_t uStartStop |
|---|
| 362 | ); |
|---|
| 363 | #ifdef TMFL_NEWSPI |
|---|
| 364 | |
|---|
| 365 | extern tmErrorCode_t |
|---|
| 366 | tmdlSpiWrite |
|---|
| 367 | ( |
|---|
| 368 | tmUnitSelect_t tUnit, |
|---|
| 369 | tmSpiChipSelect_t eCS, |
|---|
| 370 | UInt32 dwDataLengthInBits, |
|---|
| 371 | UInt8* pData |
|---|
| 372 | ); |
|---|
| 373 | |
|---|
| 374 | extern tmErrorCode_t |
|---|
| 375 | tmdlSpiRead |
|---|
| 376 | ( |
|---|
| 377 | tmUnitSelect_t tUnit, |
|---|
| 378 | tmSpiChipSelect_t eCS, |
|---|
| 379 | UInt32 dwDataLengthInBits, |
|---|
| 380 | UInt8* pData |
|---|
| 381 | ); |
|---|
| 382 | |
|---|
| 383 | extern tmErrorCode_t |
|---|
| 384 | tmdlSpiWriteRead |
|---|
| 385 | ( |
|---|
| 386 | tmUnitSelect_t tUnit, |
|---|
| 387 | tmSpiChipSelect_t eCS, |
|---|
| 388 | UInt32 dwWriteDataLengthInBits, |
|---|
| 389 | UInt8* pWriteData, |
|---|
| 390 | UInt32 dwReadDataLengthInBits, |
|---|
| 391 | UInt8* pReadData |
|---|
| 392 | ); |
|---|
| 393 | |
|---|
| 394 | extern tmErrorCode_t |
|---|
| 395 | tmdlSpiSetConfig |
|---|
| 396 | ( |
|---|
| 397 | tmUnitSelect_t tUnit, |
|---|
| 398 | tmSpiCsPolarityDef eCsPolarity, |
|---|
| 399 | tmSpiModeDef eSpiMode |
|---|
| 400 | ); |
|---|
| 401 | |
|---|
| 402 | extern tmErrorCode_t |
|---|
| 403 | tmdlSpiGetConfig |
|---|
| 404 | ( |
|---|
| 405 | tmUnitSelect_t tUnit, |
|---|
| 406 | tmSpiCsPolarityDef *eCsPolarity, |
|---|
| 407 | tmSpiModeDef *eSpiMode |
|---|
| 408 | ); |
|---|
| 409 | |
|---|
| 410 | #else |
|---|
| 411 | |
|---|
| 412 | extern tmErrorCode_t |
|---|
| 413 | tmdlSpiWrite |
|---|
| 414 | ( |
|---|
| 415 | tmUnitSelect_t tUnit, |
|---|
| 416 | tmSpiChipSelect_t eCS, |
|---|
| 417 | UInt32 DataLenthInBits, |
|---|
| 418 | UInt8* pData |
|---|
| 419 | ); |
|---|
| 420 | |
|---|
| 421 | extern tmErrorCode_t |
|---|
| 422 | tmdlSpiRead |
|---|
| 423 | ( |
|---|
| 424 | tmUnitSelect_t tUnit, |
|---|
| 425 | tmSpiChipSelect_t eCS, |
|---|
| 426 | UInt32 DataLenthInBits, |
|---|
| 427 | UInt8* pData |
|---|
| 428 | ); |
|---|
| 429 | |
|---|
| 430 | #endif |
|---|
| 431 | |
|---|
| 432 | #ifdef __cplusplus |
|---|
| 433 | } |
|---|
| 434 | #endif |
|---|
| 435 | |
|---|
| 436 | #endif /* TMDLI2C_H */ |
|---|
| 437 | /*============================================================================*/ |
|---|
| 438 | /* END OF FILE */ |
|---|
| 439 | /*============================================================================*/ |
|---|
| 440 | |
|---|