TI-RTOS for SimpleLink Wireless MCUs  2.14.03.28
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 
384 typedef struct I2CCC26XX_HWAttrs {
386  I2CBaseAddrType baseAddr;
388  unsigned long powerMngrId;
390  int intNum;
404  uint8_t intPriority;
406  uint8_t sdaPin;
408  uint8_t sclPin;
410 
416 typedef struct I2CCC26XX_Object {
417  /* I2C control variables */
420  volatile I2CCC26XX_Mode mode;
421  uint32_t bitRate;
423  /* I2C SYS/BIOS objects */
424  ti_sysbios_family_arm_m3_Hwi_Struct hwi;
425  Semaphore_Struct mutex;
426  Semaphore_Struct transferComplete;
428  /* PIN driver state object and handle */
431 
432  /* I2C current transaction */
434  uint8_t *writeBufIdx;
435  unsigned int writeCountIdx;
436  uint8_t *readBufIdx;
437  unsigned int readCountIdx;
439  /* I2C transaction pointers for I2C_MODE_CALLBACK */
443  /* I2C power notification */
444  void *i2cPostFxn;
447  bool isOpen;
449 
450 /* Do not interfere with the app if they include the family Hwi module */
451 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
452 
453 #ifdef __cplusplus
454 }
455 #endif
456 
457 #endif /* ti_drivers_i2c_I2CCC26XX__include */
Semaphore_Struct transferComplete
Definition: I2CCC26XX.h:426
I2CBaseAddrType baseAddr
Definition: I2CCC26XX.h:386
I2C_CallbackFxn transferCallbackFxn
Definition: I2CCC26XX.h:419
uint8_t pinSDA
Definition: I2CCC26XX.h:334
struct I2CCC26XX_HWAttrs I2CCC26XX_HWAttrs
I2CCC26XX Hardware attributes.
uint8_t * writeBufIdx
Definition: I2CCC26XX.h:434
bool isOpen
Definition: I2CCC26XX.h:447
I2CCC26XX Hardware attributes.
Definition: I2CCC26XX.h:384
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:404
I2CCC26XX_Mode
I2CCC26XX mode.
Definition: I2CCC26XX.h:344
unsigned long powerMngrId
Definition: I2CCC26XX.h:388
I2CCC26XX Pin Configuration.
Definition: I2CCC26XX.h:333
Definition: I2CCC26XX.h:348
uint32_t bitRate
Definition: I2CCC26XX.h:421
I2C_Transaction * currentTransaction
Definition: I2CCC26XX.h:433
I2C_TransferMode transferMode
Definition: I2CCC26XX.h:418
Definition: I2CCC26XX.h:345
Power_NotifyObj i2cPostObj
Definition: I2CCC26XX.h:445
I2C_TransferMode
I2C transfer mode.
Definition: I2C.h:230
PIN_State pinState
Definition: I2CCC26XX.h:429
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:430
Device-specific pin & GPIO driver for CC26xx family [def].
Semaphore_Struct mutex
Definition: I2CCC26XX.h:425
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:436
const I2C_FxnTable I2CCC26XX_fxnTable
underlying data structure for type PIN_State
Definition: PIN.h:686
int intNum
Definition: I2CCC26XX.h:390
I2C_Transaction * tailPtr
Definition: I2CCC26XX.h:441
I2C_Transaction * headPtr
Definition: I2CCC26XX.h:440
uint8_t pinSCL
Definition: I2CCC26XX.h:335
volatile I2CCC26XX_Mode mode
Definition: I2CCC26XX.h:420
I2CCC26XX Object.
Definition: I2CCC26XX.h:416
unsigned int writeCountIdx
Definition: I2CCC26XX.h:435
ti_sysbios_family_arm_m3_Hwi_Struct hwi
Definition: I2CCC26XX.h:424
I2C transaction.
Definition: I2C.h:210
I2C driver interface.
unsigned long I2CDataType
Definition: I2CCC26XX.h:307
uint8_t sdaPin
Definition: I2CCC26XX.h:406
unsigned long I2CBaseAddrType
Definition: I2CCC26XX.h:305
void * i2cPostFxn
Definition: I2CCC26XX.h:444
uint8_t sclPin
Definition: I2CCC26XX.h:408
unsigned int readCountIdx
Definition: I2CCC26XX.h:437
Copyright 2015, Texas Instruments Incorporated