Other Parts Discussed in Thread: CC2541
大家好、
我使用的是具有 BLE 堆栈1.5.1.1的 CC2541、需要在应用中显示电池百分比。 我使用的是3.7V 6000 mAh 电池。 ADC 值的代码后执行该操作。 我得到的值是64、而不是其他值。
我确定这里有问题、我需要有关这方面的帮助。
此致、
Yatin Baluja
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.
您好、Yatin、
1)
首先、您需要验证正确的 ADC 设置。 也许您还可以使用隔离式 ADC 示例进行测试、以确保正确配置:
https://www.ti.com/lit/zip/swrc257
此外、此主题可能也有用:
https://e2e.ti.com/support/wireless-connectivity/bluetooth/f/538/p/910759/3366592
2) 2)是的、应该可以创建类似于秒表的东西。 也许您可以从中找到灵感
16 TimeApp- BLE 监视 并使用 osal_timers.c (osal_start_timerEx/osal_stop_timerEx)。 您还可以尝试直接使用硬件计时器。
已尝试在另 一个重复的帖子中帮助您。
是的、YK Chen
我要确认的事情很少。
首先、添加第8个蓝牙特性、我会得到"太多初始化器值"。
其次、我有一个按钮、因此按下该按钮2秒钟-器件将打开、再次按下该按钮后、一个 LED 将打开、再次按下该按钮第二个 LED 将打开。 那么、如何在我已经尝试但不确定是否正确的情况下实现它。
//*********
IF (事件和 SBP_KEY_EVT)
{
如果(key=0)
{
key_dptr ++;
if ((key_dptr >=2)&&(device_start_stop =device_stop))
{
if (key == key_low)
{
电源= 1;
key_dptr = 0;
DEVICE_START_STOP = DEVICE_START;
LED=1;
FIRST_Part (0、0);
second_Part (0、0);
third_Part (0、0);
第四部分(0、0);
第5部分(0、0);
//osal_stop_timerEx (simpleBLEPeripheral_TaskID、SBP_KEY_EVT);
OSAL_SET_EVENT (simpleBLEPeripheral_TaskID、SBP_Periode_EVT);
返回(事件^ SBP_KEY_EVT);
}
}
否则、如果((key_dptr >=1)&&(device_start_stop =device_stop))
{
if (key == key_low)
{
key_dptr = 0;
DEVICE_START_STOP = DEVICE_START;
FIRST_Part (1、0);
second_Part (1、0);
third_Part (1、0);
第四部分(1、0);
第5部分(1、0);
OSAL_STOP_timerEx (simpleBLEPeripheral_TaskID、SBP_Period_EVT);
// osal_stop_timerEx (simpleBLEPeripheral_TaskID、SBP_KEY_EVT);
返回(事件^ SBP_KEY_EVT);
}
}
否则、如果((key_dptr >=1)&&(device_start_stop =device_stop))
{
if (key == key_low)
{
key_dptr = 0;
DEVICE_START_STOP = DEVICE_START;
FIRST_Part (0、1);
second_Part (0、1);
third_Part (0、1);
第四部分(0、1);
第5部分(0、1);
OSAL_STOP_timerEx (simpleBLEPeripheral_TaskID、SBP_Period_EVT);
//osal_stop_timerEx (simpleBLEPeripheral_TaskID、SBP_KEY_EVT);
返回(事件^ SBP_KEY_EVT);
}
}
否则、如果((key_dptr >=1)&&(device_start_stop =device_start))
{
if (key == key_low)
{
key_dptr = 0;
DEVICE_START_STOP = DEVICE_STOP;
FIRST_Part (0、0);
second_Part (0、0);
third_Part (0、0);
第四部分(0、0);
第5部分(0、0);
电源= 0;
OSAL_STOP_timerEx (simpleBLEPeripheral_TaskID、SBP_Period_EVT);
//osal_stop_timerEx (simpleBLEPeripheral_TaskID、SBP_KEY_EVT);
返回(事件^ SBP_KEY_EVT);
}
}
}
其他
{
OSAL_START_timerEx (simpleBLEPeripheral_TaskID、SBP_KEY_EVT、SBP_KEY_EVT_PERIOD);
返回(事件^ SBP_KEY_EVT);
}
}
//周期性事件
if (事件和 SBP_Periode_EVT)
{
if (IN_5V = 1)//如果电池正在充电
{
LED = 1;
FIRST_Part (0、0);
second_Part (0、0);
third_Part (0、0);
第四部分(0、0);
第5部分(0、0);
}
adc_handle();
OSAL_START_timerEx (simpleBLEPeripheral_TaskID、SBP_PERIOD_EVT、SBP_PERIOD_EVT_PERIOD);
返回(事件^ SBP_Periode_EVT);
adc_handle();
IEN2 |= 0x10;
如果(IN_5V = 0)
{
功率= 1;
LED = 0;
}
OSAL_START_timerEx (simpleBLEPeripheral_TaskID、SBP_PERIOD_EVT、SBP_PERIOD_EVT_PERIOD);
返回(事件^ SBP_Periode_EVT);
}
//丢弃未知事件
返回0;
}