协议栈:simplelink_cc2640r2_sdk_1_40_00_45

-----------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------

*  | Generic API Function | API Function             | Description                                                     |
 *  |---------------------  |------------------------- |---------------------------------------------------|
 *  | I2C_init()                 | I2CCC26XX_init()         | Initialize I2C driver                                             |
 *  | I2C_open()              | I2CCC26XX_open()       | Initialize I2C HW and set system dependencies     |
 *  | I2C_close()              | I2CCC26XX_close()       | Disable I2C HW and release system dependencies    |
 *  | I2C_transfer()         | I2CCC26XX_transfer()    | Start I2C transfer

--------------------------------------------------------------------------------I2C.h

typedef struct I2C_Config_    *I2C_Handle;

typedef struct I2C_Transaction_ {
    void    *writeBuf;    /*!< Buffer containing data to be written */
    size_t   writeCount;  /*!< Number of bytes to be written to the slave */
    void    *readBuf;     /*!< Buffer to which data is to be read into */
    size_t   readCount;   /*!< Number of bytes to be read from the slave */
    uint_least8_t slaveAddress; /*!< Address of the I2C slave peripheral */
    void    *arg;         /*!< Argument to be passed to the callback function */
    void    *nextPtr;     /*!< Used for queuing in I2C_MODE_CALLBACK mode */

} I2C_Transaction;

typedef enum I2C_TransferMode_ {
    I2C_MODE_BLOCKING,  /*!< I2C_transfer() blocks execution */
    I2C_MODE_CALLBACK   /*!< I2C_transfer() does not block */

} I2C_TransferMode;

typedef void (*I2C_CallbackFxn)(I2C_Handle handle, I2C_Transaction *transaction, bool transferStatus);

typedef enum I2C_BitRate_ {
    I2C_100kHz = 0,
    I2C_400kHz = 1
} I2C_BitRate;

typedef struct I2C_Params_ {
    I2C_TransferMode transferMode;        /*!< Blocking or Callback mode */
    I2C_CallbackFxn  transferCallbackFxn; /*!< Callback function pointer */
    I2C_BitRate      bitRate;                       /*!< I2C bus bit rate */
    void            *custom;                       /*!< Custom argument used by driver implementation */

} I2C_Params;

typedef struct I2C_FxnTable_ {
    /*! Cancel all I2C data transfers */
    I2C_CancelFxn   cancelFxn;
    /*! Close the specified peripheral */
    I2C_CloseFxn    closeFxn;
    /*! Implementation-specific control function */
    I2C_ControlFxn  controlFxn;
    /*! Initialize the given data object */
    I2C_InitFxn     initFxn;
    /*! Open the specified peripheral */
    I2C_OpenFxn     openFxn;
    /*! Initiate an I2C data transfer */
    I2C_TransferFxn transferFxn;

} I2C_FxnTable;

typedef struct I2C_Config_ {
    /*! Pointer to a table of driver-specific implementations of I2C APIs */
    I2C_FxnTable const *fxnTablePtr;
    /*! Pointer to a driver-specific data object */
    void               *object;
    /*! Pointer to a driver-specific hardware attributes structure */
    void         const *hwAttrs;
} I2C_Config;

--------------------------------------------------------------------------------I2C.c

/* Default I2C parameters structure */
const I2C_Params I2C_defaultParams = {
    I2C_MODE_BLOCKING,  /* transferMode */
    NULL,               /* transferCallbackFxn */
    I2C_100kHz,         /* bitRate */
    NULL                /* custom */
};

void I2C_cancel(I2C_Handle handle)

void I2C_close(I2C_Handle handle)

int_fast16_t I2C_control(I2C_Handle handle, uint_fast16_t cmd, void *controlArg)

void I2C_init(void)

I2C_Handle I2C_open(uint_least8_t index, I2C_Params *params)

void I2C_Params_init(I2C_Params *params)

bool I2C_transfer(I2C_Handle handle, I2C_Transaction *transaction)

--------------------------------------------------------------------------------I2CCC2640XX.h

typedef struct I2CCC26XX_I2CPinCfg {
    uint8_t pinSDA;
    uint8_t pinSCL;

} I2CCC26XX_I2CPinCfg;

typedef enum I2CCC26XX_Mode {
    I2CCC26XX_IDLE_MODE = 0,  /* I2C is not performing a transaction */
    I2CCC26XX_WRITE_MODE,     /* I2C is currently performing write operations */
    I2CCC26XX_READ_MODE,      /* I2C is currently performing read operations */
    I2CCC26XX_BUSBUSY_MODE,   /* I2C Bus is currently busy */
    I2CCC26XX_ERROR = 0xFF    /* I2C error has occurred, exit gracefully */

} I2CCC26XX_Mode;

typedef struct I2CCC26XX_HWAttrsV1 {
    I2CBaseAddrType     baseAddr;     /*! I2C peripheral's base address */
    unsigned long       powerMngrId;  /*! I2C peripheral's Power driver ID */
    int                 intNum;   /*! I2C peripheral's interrupt number */

/*! @brief I2C Peripheral's interrupt priority. The CC26xx uses three of the priority bits,  meaning

~0 has the same effect as (7 << 5).

(7 << 5) will apply the lowest priority.
        (1 << 5) will apply the highest priority.
        Setting the priority to 0 is not supported by this driver.
       Hwi's with priority 0 ignore the Hwi dispatcher to support zero-latency interrupts, thus invalidating the critical sections in this driver.*/
    uint8_t             intPriority;
    /*! @brief I2C Swi priority.The higher the number, the higher the priority.The minimum is 0 and the maximum is 15 by default. The maximum can be reduced to save RAM by adding or modifying Swi.numPriorities in the kernel configuration file. */
    uint32_t            swiPriority;
    uint8_t             sdaPin; /*! I2C SDA pin mapping */
    uint8_t             sclPin;/*! I2C SCL pin mapping */

} I2CCC26XX_HWAttrsV1;

typedef struct I2CCC26XX_Object {
    /* I2C control variables */
    I2C_TransferMode    transferMode;        /*!< Blocking or Callback mode */
    I2C_CallbackFxn     transferCallbackFxn; /*!< Callback function pointer */
    volatile I2CCC26XX_Mode mode;            /*!< Stores the I2C state */
    uint32_t            bitRate;             /*!< Bitrate of the I2C module */
    /* I2C SYS/BIOS objects */
    HwiP_Struct hwi;/*!< Hwi object handle */
    SwiP_Struct          swi;                /*!< Swi object */
    SemaphoreP_Struct    mutex;              /*!< Grants exclusive access to I2C */
    SemaphoreP_Struct    transferComplete;   /*!< Signal I2C transfer complete */
    /* PIN driver state object and handle */
    PIN_State           pinState;
    PIN_Handle          hPin;
    /* I2C current transaction */
    I2C_Transaction     *currentTransaction; /*!< Ptr to current I2C transaction */
    uint8_t             *writeBufIdx;        /*!< Internal inc. writeBuf index */
    unsigned int        writeCountIdx;       /*!< Internal dec. writeCounter */
    uint8_t             *readBufIdx;         /*!< Internal inc. readBuf index */
    unsigned int        readCountIdx;        /*!< Internal dec. readCounter */
    /* I2C transaction pointers for I2C_MODE_CALLBACK */
    I2C_Transaction     *headPtr;            /*!< Head ptr for queued transactions */
    I2C_Transaction     *tailPtr;            /*!< Tail ptr for queued transactions */
    /* I2C power notification */
    void                *i2cPostFxn;        /*!< I2C post-notification Function pointer */
    Power_NotifyObj     i2cPostObj;         /*!< I2C post-notification object */
    bool                isOpen;             /*!< flag to indicate module is open */
} I2CCC26XX_Object;

--------------------------------------------------------------------------------I2CCC2640XX.c

/* I2C function table for I2CCC26XX implementation */
const I2C_FxnTable I2CCC26XX_fxnTable = {
    I2CCC26XX_cancel,  //  void I2CCC26XX_cancel(I2C_Handle handle)
    I2CCC26XX_close,   //  void I2CCC26XX_close(I2C_Handle handle)
    I2CCC26XX_control, //  int_fast16_t I2CCC26XX_control(I2C_Handle handle, uint_fast16_t cmd, void *arg)
    I2CCC26XX_init,     //  void I2CCC26XX_init(I2C_Handle handle)
    I2CCC26XX_open,    //  I2C_Handle I2CCC26XX_open(I2C_Handle handle, I2C_Params *params)
    I2CCC26XX_transfer //  bool I2CCC26XX_transfer(I2C_Handle handle, I2C_Transaction *transaction)

};

void         I2CCC26XX_init(I2C_Handle handle);
I2C_Handle   I2CCC26XX_open(I2C_Handle handle, I2C_Params *params);
bool         I2CCC26XX_transfer(I2C_Handle handle, I2C_Transaction *transaction);
void         I2CCC26XX_cancel(I2C_Handle handle);
void         I2CCC26XX_close(I2C_Handle handle);

int_fast16_t I2CCC26XX_control(I2C_Handle handle, uint_fast16_t cmd, void *arg);

==============================硬件平台特性========================

--------------------------------------------------------------------------------CC2640R2_LAUNCHXL.h

typedef enum CC2640R2_LAUNCHXL_I2CName {
    CC2640R2_LAUNCHXL_I2C0 = 0,
    CC2640R2_LAUNCHXL_I2CCOUNT

} CC2640R2_LAUNCHXL_I2CName;

/* I2C */
#define CC2640R2_LAUNCHXL_I2C0_SCL0              IOID_4
#define CC2640R2_LAUNCHXL_I2C0_SDA0             IOID_5

--------------------------------------------------------------------------------CC2640R2_LAUNCHXL.c

I2CCC26XX_Object i2cCC26xxObjects[CC2640R2_LAUNCHXL_I2CCOUNT];

const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[CC2640R2_LAUNCHXL_I2CCOUNT] = {
    {
        .baseAddr    = I2C0_BASE,
        .powerMngrId = PowerCC26XX_PERIPH_I2C0,
        .intNum      = INT_I2C_IRQ,
        .intPriority = ~0,
        .swiPriority = 0,
        .sdaPin      = CC2640R2_LAUNCHXL_I2C0_SDA0,
        .sclPin      = CC2640R2_LAUNCHXL_I2C0_SCL0,
    }

};

const I2C_Config I2C_config[CC2640R2_LAUNCHXL_I2CCOUNT] = {
    {
        .fxnTablePtr = &I2CCC26XX_fxnTable,
        .object      = &i2cCC26xxObjects[CC2640R2_LAUNCHXL_I2C0],
        .hwAttrs     = &i2cCC26xxHWAttrs[CC2640R2_LAUNCHXL_I2C0]
    },
};

const uint_least8_t I2C_count = CC2640R2_LAUNCHXL_I2CCOUNT;

CC2640R2F ble蓝牙 I2C解析相关推荐

  1. BLE 蓝牙网关与蓝牙定位

    参考:[IoT]BLE 蓝牙网关与蓝牙定位技术解析 地址:https://blog.csdn.net/liwei16611/article/details/85245109?spm=1001.2014 ...

  2. C# BLE蓝牙开发之使用Windows.Devices.Bluetooth获取小米体重秤的体重

    目录 前言 准备工作 新建.net Framework 4.6 工程 微软BLE方法介绍 构建代码 如何连接小米体重秤 小米体重秤历史记录解析 结语 前言 最近天天再减肥,每天起床第一件事就是去小米体 ...

  3. MDK5 nRF BLE(蓝牙低功耗)

    BLE(蓝牙低功耗) 1 什么是蓝牙低功耗? BLE是蓝牙低功耗的简称(Bluetooth Low Energy).BLE技术是低成本.短距离.可互操作的鲁棒性无线技术,工作在免许可的2.4GHz I ...

  4. Anroid BLE蓝牙(手机分别作为中心设备和外围设备)

    蓝牙是一种短距的无线通讯技术,可实现固定设备.移动设备之间的数据交换.一般将蓝牙3.0之前的BR/EDR蓝牙称为传统蓝牙,而将蓝牙4.0规范下的LE蓝牙称为低功耗蓝牙. BLE蓝牙模块主要应用领域 1 ...

  5. React Native BLE蓝牙通信

    由于项目需要,基于React Native 开发的App要跟BLE蓝牙设备通信. 在js.coach上搜索React Native BLE蓝牙组件,只找到三个组件: react-native-ble- ...

  6. 深入剖析BLE蓝牙数据收发处理

    **深入剖析BLE蓝牙数据收发处理** 简介 蓝牙基本架构 1 开启BLE的广播 2 常见芯片的基本架构 3 基带的功能 4 基带封装广播的空口数据包 简介 我将通过一个BLE蓝牙广播的例子,深入的解 ...

  7. Android Ble蓝牙开发

    BLE Android 应用 开发 1.权限设置 2.获取蓝牙设备管理器 3.设备搜索 3.1 停止搜索 4.设备连接 5.设备的重连 6.设备的断开与服务关闭 7.通知的注册与接收 8.数据的主动读 ...

  8. 乐鑫Esp32学习之旅 19 重磅开源,如何在微信小程序上ble蓝牙配网esp32,blufi的那些事!

    本系列博客学习由非官方人员 半颗心脏 潜心所力所写,仅仅做个人技术交流分享,不做任何商业用途.如有不对之处,请留言,本人及时更改. 1. 爬坑学习新旅程,虚拟机搭建esp32开发环境,打印 " ...

  9. Android BLE蓝牙4.0开发详解

    这篇博客主要讲解 蓝牙 BLE 的用法.在讲解之前先讲一些概念性的东西,对于之前没接触过蓝牙开发,现在手上又有个蓝牙BLE项目需要做的人,先看下这些概念还是很重要的.因为我之前就是这样,之前没有接触过 ...

最新文章

  1. 导师:CNN 开山之作 AlexNet 都复现不了,延毕吧!
  2. 沃丰报告:物联网的未来
  3. wxWidgets:wxIconizeEvent类用法
  4. ASP+COM 组件开发
  5. 网络流--最大流--POJ 1273 Drainage Ditches
  6. 阿里巴巴指东打西,PC之后卖盒饭?
  7. mysql填写账户远程_mysql账户添加远程访问
  8. dijkstra堆优化(multiset实现-大大减小代码量)
  9. python做一个本地搜索工具_用Python打造一款文件搜索工具,所有功能自己定义!...
  10. 我自定义安装office 但在ATA计算机考试系统考试时出现“没有正确的安装office” 怎么解决 求解
  11. 零基础学python电子书-零基础学Python(全彩版)
  12. nginx源码安装及配置https自签名
  13. 爬虫:爬取网页表格内容,写入scv文件并绘图
  14. 小米路由3c padavan固件
  15. linux-arm下如何开启tftp传输,linux-arm间tftp命令的安装、使用
  16. RabbitMQ队列声明channel.queueDeclare()参数解析
  17. 编译过程 多个.c文件 . h文件 和main文件的 联系
  18. HEVC代码学习——帧间预测:预测MV获取(xEstimateMvPredAMVP、fillMVPCand)
  19. c语言void翻译,C语言中,void 怎么读?给个准却的中文翻译。
  20. 让dropout在图像超分辨领域大放异彩![2022 CVPR]

热门文章

  1. 基于图像处理的水果品质检测方法的研究任务书
  2. 南京大学计算机科学与技术系罗金宇,2017年南京大学计算机科学与技术系硕士研究生复试名单...
  3. 计算机网络纠错码,计算机网络:纠错
  4. BERT预训练模型学习笔记
  5. 教你快速给多段视频删除片尾的同时添加图片LOGO
  6. 我们的世界 文/江湖一劍客
  7. wasp模型建模经验
  8. 注意!这些设备禁止使用!物联卡网速慢、没信号的朋友请自行排查!
  9. 雕刻机主轴正确的选型指引
  10. python方法之间加点_python中技巧