This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2340R5:需要电池监控示例代码

Guru**** 2533560 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1562055/cc2340r5-need-battery-monitoring-example-code

器件型号:CC2340R5


工具/软件:

您好论坛、

 我想监控电池电量、我 正在 查找 API 文档。 我看到 4 个文件、需要参考哪个文件? 令人困惑的是、两个文件都有一组不同的 API。

此外、您能否分享示例代码或此流程应该是怎样的?

有没有需要获得电池电量(无需回拨)?

此致

Vaibhav

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Vaibhav:

    这些是电池监控器 TI 驱动程序源文件。  您应该能够在该目录的“drivers"文件夹“文件夹中找到 BatteryMontior.h。

    您基本上要重新利用 temperatureNotify 示例来支持 BatteryMonitor API

    下面是我之前开发的一个项目的一些伪代码:

    #include <ti/drivers/BatteryMonitor.h>
    //...
    #define THRESHOLD_DELTA_MILLIVOLT 200
    BatteryMonitor_NotifyObj rangeNotifyObject;
    //...
    void deltaNotificationFxn(uint16_t currentVoltage,
                              uint16_t thresholdVoltage,
                              uintptr_t clientArg,
                              BatteryMonitor_NotifyObj *notifyObject) 
    {
        int_fast16_t voltageStatus;
        voltageStatus = BatteryMonitor_registerNotifyRange(notifyObject,
                                            currentVoltage + THRESHOLD_DELTA_MILLIVOLT,
                                            currentVoltage - THRESHOLD_DELTA_MILLIVOLT,
                                            deltaNotificationFxn,
                                            (uintptr_t)NULL);
        if (voltageStatus != BatteryMonitor_STATUS_SUCCESS) {
            while(1);
        }
    }
    //...
    /* Configure the Battery Monitor */
    uint16_t batVoltage;                        // Initial battery voltage level 
    
    BatteryMonitor_init();
    batVoltage = BatteryMonitor_getVoltage();
    deltaNotificationFxn(batVoltage, 0,(uintptr_t)NULL, &rangeNotifyObject);

     当用户需要而不是 使用“deltaNotificationFxn"回“回调时、绝对可以使用 BatteryMonitor_getVoltage。

    此致、
    Ryan

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    谢谢 Ryan。