TI-RTOS for SimpleLink Wireless MCUs  2.14.02.22
I2CCC26XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, 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  */
287 #ifndef ti_drivers_i2c_I2CCC26XX__include
288 #define ti_drivers_i2c_I2CCC26XX__include
289 
290 #ifdef __cplusplus
291 extern "C" {
292 #endif
293 
294 #include <stdint.h>
295 #include <stdbool.h>
296 #include <ti/drivers/I2C.h>
298 #include <ti/sysbios/family/arm/cc26xx/Power.h>
299 
300 #define ti_sysbios_family_arm_m3_Hwi__nolocalnames
301 #include <ti/sysbios/family/arm/m3/Hwi.h>
302 #include <ti/sysbios/knl/Semaphore.h>
303 
305 typedef unsigned long I2CBaseAddrType;
307 typedef unsigned long I2CDataType;
308 
310 extern const I2C_FxnTable I2CCC26XX_fxnTable;
311 
333 typedef struct I2CCC26XX_I2CPinCfg {
334  uint8_t pinSDA;
335  uint8_t pinSCL;
337 
344 typedef enum I2CCC26XX_Mode {
345  I2CCC26XX_IDLE_MODE = 0, /* I2C is not performing a transaction */
346  I2CCC26XX_WRITE_MODE, /* I2C is currently performing write operations */
347  I2CCC26XX_READ_MODE, /* I2C is currently performing read operations */
348  I2CCC26XX_ERROR = 0xFF /* I2C error has occurred, exit gracefully */
350 
373 typedef struct I2CCC26XX_HWAttrs {
375  I2CBaseAddrType baseAddr;
377  unsigned long powerMngrId;
379  int intNum;
387  uint8_t intPriority;
389  uint8_t sdaPin;
391  uint8_t sclPin;
393 
399 typedef struct I2CCC26XX_Object {
400  /* I2C control variables */
403  volatile I2CCC26XX_Mode mode;
404  uint32_t bitRate;
406  /* I2C SYS/BIOS objects */
407  ti_sysbios_family_arm_m3_Hwi_Struct hwi;
408  Semaphore_Struct mutex;
409  Semaphore_Struct transferComplete;
411  /* PIN driver state object and handle */
414 
415  /* I2C current transaction */
417  uint8_t *writeBufIdx;
418  unsigned int writeCountIdx;
419  uint8_t *readBufIdx;
420  unsigned int readCountIdx;
422  /* I2C transaction pointers for I2C_MODE_CALLBACK */
426  /* I2C power notification */
427  void *i2cPostFxn;
430  bool isOpen;
432 
433 /* Do not interfere with the app if they include the family Hwi module */
434 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
435 
436 #ifdef __cplusplus
437 }
438 #endif
439 
440 #endif /* ti_drivers_i2c_I2CCC26XX__include */
Semaphore_Struct transferComplete
Definition: I2CCC26XX.h:409
I2CBaseAddrType baseAddr
Definition: I2CCC26XX.h:375
I2C_CallbackFxn transferCallbackFxn
Definition: I2CCC26XX.h:402
uint8_t pinSDA
Definition: I2CCC26XX.h:334
struct I2CCC26XX_HWAttrs I2CCC26XX_HWAttrs
I2CCC26XX Hardware attributes.
uint8_t * writeBufIdx
Definition: I2CCC26XX.h:417
bool isOpen
Definition: I2CCC26XX.h:430
I2CCC26XX Hardware attributes.
Definition: I2CCC26XX.h:373
Definition: I2CCC26XX.h:346
struct I2CCC26XX_I2CPinCfg I2CCC26XX_I2CPinCfg
I2CCC26XX Pin Configuration.
void(* I2C_CallbackFxn)(I2C_Handle, I2C_Transaction *, bool)
I2C callback function.
Definition: I2C.h:248
uint8_t intPriority
I2C Peripheral's interrupt priority.
Definition: I2CCC26XX.h:387
I2CCC26XX_Mode
I2CCC26XX mode.
Definition: I2CCC26XX.h:344
unsigned long powerMngrId
Definition: I2CCC26XX.h:377
I2CCC26XX Pin Configuration.
Definition: I2CCC26XX.h:333
Definition: I2CCC26XX.h:348
uint32_t bitRate
Definition: I2CCC26XX.h:404
I2C_Transaction * currentTransaction
Definition: I2CCC26XX.h:416
I2C_TransferMode transferMode
Definition: I2CCC26XX.h:401
Definition: I2CCC26XX.h:345
Power_NotifyObj i2cPostObj
Definition: I2CCC26XX.h:428
I2C_TransferMode
I2C transfer mode.
Definition: I2C.h:230
PIN_State pinState
Definition: I2CCC26XX.h:412
The definition of a I2C function table that contains the required set of functions to control a speci...
Definition: I2C.h:328
PIN_Handle hPin
Definition: I2CCC26XX.h:413
Device-specific pin & GPIO driver for CC26xx family [def].
Semaphore_Struct mutex
Definition: I2CCC26XX.h:408
Definition: I2CCC26XX.h:347
struct I2CCC26XX_Object I2CCC26XX_Object
I2CCC26XX Object.
Power notify object structure.
Definition: Power.h:112
uint8_t * readBufIdx
Definition: I2CCC26XX.h:419
const I2C_FxnTable I2CCC26XX_fxnTable
underlying data structure for type PIN_State
Definition: PIN.h:686
int intNum
Definition: I2CCC26XX.h:379
I2C_Transaction * tailPtr
Definition: I2CCC26XX.h:424
I2C_Transaction * headPtr
Definition: I2CCC26XX.h:423
uint8_t pinSCL
Definition: I2CCC26XX.h:335
volatile I2CCC26XX_Mode mode
Definition: I2CCC26XX.h:403
I2CCC26XX Object.
Definition: I2CCC26XX.h:399
unsigned int writeCountIdx
Definition: I2CCC26XX.h:418
ti_sysbios_family_arm_m3_Hwi_Struct hwi
Definition: I2CCC26XX.h:407
I2C transaction.
Definition: I2C.h:210
I2C driver interface.
unsigned long I2CDataType
Definition: I2CCC26XX.h:307
uint8_t sdaPin
Definition: I2CCC26XX.h:389
unsigned long I2CBaseAddrType
Definition: I2CCC26XX.h:305
void * i2cPostFxn
Definition: I2CCC26XX.h:427
uint8_t sclPin
Definition: I2CCC26XX.h:391
unsigned int readCountIdx
Definition: I2CCC26XX.h:420
Copyright 2015, Texas Instruments Incorporated