SimpleLink MCU SDK Driver APIs  tidrivers_cc13xx_cc26xx_3_01_01_03
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 /* \cond */
303 #define ti_sysbios_family_arm_m3_Hwi__nolocalnames
304 /* \endcond */
305 #include <ti/sysbios/family/arm/m3/Hwi.h>
306 #include <ti/sysbios/knl/Swi.h>
307 #include <ti/sysbios/knl/Semaphore.h>
308 
319 /* Add I2CCC26XX_STATUS_* macros here */
320 
333 /* Add I2CCC26XX_CMD_* macros here */
334 
338 typedef unsigned long I2CBaseAddrType;
339 /* \cond */
340 typedef unsigned long I2CDataType;
341 /* \endcond */
342 
344 extern const I2C_FxnTable I2CCC26XX_fxnTable;
345 
367 typedef struct I2CCC26XX_I2CPinCfg {
368  uint8_t pinSDA;
369  uint8_t pinSCL;
371 
379 typedef enum I2CCC26XX_Mode {
380  I2CCC26XX_IDLE_MODE = 0, /* I2C is not performing a transaction */
381  I2CCC26XX_WRITE_MODE, /* I2C is currently performing write operations */
382  I2CCC26XX_READ_MODE, /* I2C is currently performing read operations */
383  I2CCC26XX_BUSBUSY_MODE, /* I2C Bus is currently busy */
384  I2CCC26XX_ERROR = 0xFF /* I2C error has occurred, exit gracefully */
385 } I2CCC26XX_Mode;
429 typedef struct I2CCC26XX_HWAttrsV1 {
431  I2CBaseAddrType baseAddr;
433  unsigned long powerMngrId;
435  int intNum;
449  uint8_t intPriority;
455  uint32_t swiPriority;
457  uint8_t sdaPin;
459  uint8_t sclPin;
461 
467 typedef struct I2CCC26XX_Object {
468  /* I2C control variables */
469  I2C_TransferMode transferMode;
470  I2C_CallbackFxn transferCallbackFxn;
471  volatile I2CCC26XX_Mode mode;
472  uint32_t bitRate;
474  /* I2C SYS/BIOS objects */
475  ti_sysbios_family_arm_m3_Hwi_Struct hwi;
476  Swi_Struct swi;
477  Semaphore_Struct mutex;
478  Semaphore_Struct transferComplete;
480  /* PIN driver state object and handle */
481  PIN_State pinState;
482  PIN_Handle hPin;
483 
484  /* I2C current transaction */
485  I2C_Transaction *currentTransaction;
486  uint8_t *writeBufIdx;
487  unsigned int writeCountIdx;
488  uint8_t *readBufIdx;
489  unsigned int readCountIdx;
491  /* I2C transaction pointers for I2C_MODE_CALLBACK */
492  I2C_Transaction *headPtr;
493  I2C_Transaction *tailPtr;
495  /* I2C power notification */
496  void *i2cPostFxn;
497  Power_NotifyObj i2cPostObj;
499  bool isOpen;
500 } I2CCC26XX_Object;
501 
502 /* Do not interfere with the app if they include the family Hwi module */
503 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
504 
506 #ifdef __cplusplus
507 }
508 #endif
509 
510 #endif /* ti_drivers_i2c_I2CCC26XX__include */
uint8_t pinSDA
Definition: I2CCC26XX.h:368
int intNum
Definition: I2CCC26XX.h:435
I2C transaction.
Definition: I2C.h:465
struct I2CCC26XX_I2CPinCfg I2CCC26XX_I2CPinCfg
I2CCC26XX Pin Configuration.
struct I2CCC26XX_HWAttrsV1 I2CCC26XX_HWAttrsV1
I2CCC26XX Hardware attributes.
I2CCC26XX Pin Configuration.
Definition: I2CCC26XX.h:367
Power manager interface.
Power notify object structure.
Definition: Power.h:113
I2CCC26XX Hardware attributes.
Definition: I2CCC26XX.h:429
uint8_t sclPin
Definition: I2CCC26XX.h:459
enum I2C_TransferMode_ I2C_TransferMode
I2C transfer mode.
unsigned long powerMngrId
Definition: I2CCC26XX.h:433
I2CBaseAddrType baseAddr
Definition: I2CCC26XX.h:431
Device-specific pin & GPIO driver for CC26xx family [def].
The definition of an I2C function table that contains the required set of functions to control a spec...
Definition: I2C.h:594
const I2C_FxnTable I2CCC26XX_fxnTable
underlying data structure for type PIN_State
Definition: PIN.h:687
uint8_t pinSCL
Definition: I2CCC26XX.h:369
void(* I2C_CallbackFxn)(I2C_Handle handle, I2C_Transaction *transaction, bool transferStatus)
I2C callback function.
Definition: I2C.h:507
uint8_t sdaPin
Definition: I2CCC26XX.h:457
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:455
I2C driver interface.
unsigned long I2CBaseAddrType
Definition: I2CCC26XX.h:338
uint8_t intPriority
I2C Peripheral's interrupt priority.
Definition: I2CCC26XX.h:449
Copyright 2016, Texas Instruments Incorporated