TI-RTOS Drivers  tidrivers_full_2_20_00_08
I2CCC26XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, 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  */
289 #ifndef ti_drivers_i2c_I2CCC26XX__include
290 #define ti_drivers_i2c_I2CCC26XX__include
291 
292 #ifdef __cplusplus
293 extern "C" {
294 #endif
295 
296 #include <stdint.h>
297 #include <stdbool.h>
298 #include <ti/drivers/I2C.h>
300 #include <ti/drivers/Power.h>
301 
302 #define ti_sysbios_family_arm_m3_Hwi__nolocalnames
303 #include <ti/sysbios/family/arm/m3/Hwi.h>
304 #include <ti/sysbios/knl/Swi.h>
305 #include <ti/sysbios/knl/Semaphore.h>
306 
317 /* Add I2CCC26XX_STATUS_* macros here */
318 
331 /* Add I2CCC26XX_CMD_* macros here */
332 
336 typedef unsigned long I2CBaseAddrType;
338 typedef unsigned long I2CDataType;
339 
341 extern const I2C_FxnTable I2CCC26XX_fxnTable;
342 
364 typedef struct I2CCC26XX_I2CPinCfg {
365  uint8_t pinSDA;
366  uint8_t pinSCL;
368 
375 typedef enum I2CCC26XX_Mode {
376  I2CCC26XX_IDLE_MODE = 0, /* I2C is not performing a transaction */
377  I2CCC26XX_WRITE_MODE, /* I2C is currently performing write operations */
378  I2CCC26XX_READ_MODE, /* I2C is currently performing read operations */
379  I2CCC26XX_BUSBUSY_MODE, /* I2C Bus is currently busy */
380  I2CCC26XX_ERROR = 0xFF /* I2C error has occurred, exit gracefully */
382 
414 typedef struct I2CCC26XX_HWAttrsV1 {
416  I2CBaseAddrType baseAddr;
418  unsigned long powerMngrId;
420  int intNum;
434  uint8_t intPriority;
440  uint32_t swiPriority;
442  uint8_t sdaPin;
444  uint8_t sclPin;
446 
452 typedef struct I2CCC26XX_Object {
453  /* I2C control variables */
456  volatile I2CCC26XX_Mode mode;
457  uint32_t bitRate;
459  /* I2C SYS/BIOS objects */
460  ti_sysbios_family_arm_m3_Hwi_Struct hwi;
461  Swi_Struct swi;
462  Semaphore_Struct mutex;
463  Semaphore_Struct transferComplete;
465  /* PIN driver state object and handle */
468 
469  /* I2C current transaction */
471  uint8_t *writeBufIdx;
472  unsigned int writeCountIdx;
473  uint8_t *readBufIdx;
474  unsigned int readCountIdx;
476  /* I2C transaction pointers for I2C_MODE_CALLBACK */
480  /* I2C power notification */
481  void *i2cPostFxn;
484  bool isOpen;
486 
487 /* Do not interfere with the app if they include the family Hwi module */
488 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
489 
490 #ifdef __cplusplus
491 }
492 #endif
493 
494 #endif /* ti_drivers_i2c_I2CCC26XX__include */
Semaphore_Struct transferComplete
Definition: I2CCC26XX.h:463
I2C_CallbackFxn transferCallbackFxn
Definition: I2CCC26XX.h:455
uint8_t pinSDA
Definition: I2CCC26XX.h:365
int intNum
Definition: I2CCC26XX.h:420
uint8_t * writeBufIdx
Definition: I2CCC26XX.h:471
bool isOpen
Definition: I2CCC26XX.h:484
Definition: I2CCC26XX.h:379
Definition: I2CCC26XX.h:377
struct I2CCC26XX_I2CPinCfg I2CCC26XX_I2CPinCfg
I2CCC26XX Pin Configuration.
void(* I2C_CallbackFxn)(I2C_Handle, I2C_Transaction *, bool)
I2C callback function.
Definition: I2C.h:268
I2CCC26XX_Mode
I2CCC26XX mode.
Definition: I2CCC26XX.h:375
struct I2CCC26XX_HWAttrsV1 I2CCC26XX_HWAttrsV1
I2CCC26XX Hardware attributes.
I2CCC26XX Pin Configuration.
Definition: I2CCC26XX.h:364
Definition: I2CCC26XX.h:380
uint32_t bitRate
Definition: I2CCC26XX.h:457
Power manager interface.
I2C_Transaction * currentTransaction
Definition: I2CCC26XX.h:470
I2C_TransferMode transferMode
Definition: I2CCC26XX.h:454
I2CCC26XX Hardware attributes.
Definition: I2CCC26XX.h:414
Definition: I2CCC26XX.h:376
Power_NotifyObj i2cPostObj
Definition: I2CCC26XX.h:482
I2C_TransferMode
I2C transfer mode.
Definition: I2C.h:250
uint8_t sclPin
Definition: I2CCC26XX.h:444
PIN_State pinState
Definition: I2CCC26XX.h:466
The definition of an I2C function table that contains the required set of functions to control a spec...
Definition: I2C.h:354
unsigned long powerMngrId
Definition: I2CCC26XX.h:418
PIN_Handle hPin
Definition: I2CCC26XX.h:467
I2CBaseAddrType baseAddr
Definition: I2CCC26XX.h:416
Device-specific pin & GPIO driver for CC26xx family [def].
Semaphore_Struct mutex
Definition: I2CCC26XX.h:462
Definition: I2CCC26XX.h:378
struct I2CCC26XX_Object I2CCC26XX_Object
I2CCC26XX Object.
Power notify object structure.
Definition: Power.h:112
uint8_t * readBufIdx
Definition: I2CCC26XX.h:473
const I2C_FxnTable I2CCC26XX_fxnTable
underlying data structure for type PIN_State
Definition: PIN.h:687
I2C_Transaction * tailPtr
Definition: I2CCC26XX.h:478
I2C_Transaction * headPtr
Definition: I2CCC26XX.h:477
uint8_t pinSCL
Definition: I2CCC26XX.h:366
volatile I2CCC26XX_Mode mode
Definition: I2CCC26XX.h:456
Swi_Struct swi
Definition: I2CCC26XX.h:461
I2CCC26XX Object.
Definition: I2CCC26XX.h:452
unsigned int writeCountIdx
Definition: I2CCC26XX.h:472
ti_sysbios_family_arm_m3_Hwi_Struct hwi
Definition: I2CCC26XX.h:460
I2C transaction.
Definition: I2C.h:230
uint8_t sdaPin
Definition: I2CCC26XX.h:442
uint32_t swiPriority
I2C SWI priority. The higher the number, the higher the priority. The minimum is 0 and the maximum is...
Definition: I2CCC26XX.h:440
I2C driver interface.
unsigned long I2CDataType
Definition: I2CCC26XX.h:338
unsigned long I2CBaseAddrType
Definition: I2CCC26XX.h:336
void * i2cPostFxn
Definition: I2CCC26XX.h:481
uint8_t intPriority
I2C Peripheral's interrupt priority.
Definition: I2CCC26XX.h:434
unsigned int readCountIdx
Definition: I2CCC26XX.h:474
Copyright 2016, Texas Instruments Incorporated