Hi,
我们希望定期读取传感器,优选地,当DA14585唤醒以进行BLE广告时。
要读取传感器,我们必须首先通过驱动引脚唤醒传感器,等待〜1ms,然后通过I2C读取8字节的数据。
此序列本身工作,但是当我尝试在回调user_app_main_loop_callbacks.app_on_system_powered或user_app_main_loop_callbacks.app_before_sleep中时,我会以某种方式卡住。
初始化从periph_init调用的i2c的序列:
void init_acc_i2c(void)
{
SetBits16(CLK_PER_REG, I2C_ENABLE, 1); // enable clock for I2C
SetWord16(I2C_ENABLE_REG, 0x0); // Disable the I2C controller
setword16(i2c_con_reg,0x0063);// 12c主站,7bit从地址,100kbit
setword16(i2c_tar_reg,Accelerometer_i2c_addr);
setword16(i2c_enable_reg,0x1);//启用I2C控制器
}
The code to read the sensor data, which I try to call from the callback described above:
void read_sensor_sequentially(void)
{
INT I;
UINT8_T数据[8];
gpio_setactive(Accelerometer_Enable_port,Accelerometer_Enable_pin);
systick_wait(1000);
global_int_disable();
setword16(i2c_data_cmd_reg,0x00);
for(i=0;i<7;i++)
{
等待_while_i2c_fifo_is_full();
setword16(i2c_data_cmd_reg,0x0100);
}
global_int_restore();
for(i=0;i<7;i++)
{
wait_for_received_byte();//等待收到的数据
数据[i] =(0xff&getword16(i2c_data_cmd_reg));//获取收到的字节
}
gpio_setinactive(Accelerometer_Enable_port,Accelerometer_Enable_pin);
wait_until_i2c_fifo_is_empty();//等到TX FIFO是空的
wait_until_no_master_actity();//等到没有主活动
}
是否有可能使用任何回调来实现这一点?
Best regards
马丁

Hi mapart,
如果定期读取传感器,您可以使用app_easy_timer()API。每次计时器到期时,都会触发注册的回调,因此您需要注册读取传感器的回调。在每次DA1458每次读取传感器的情况下,您可以分享更多细节吗?该设备在Adverting或连接间隔之间进入睡眠模式。您是否配置了进入深度睡眠模式,因为它在SDK的BLE_APP_SLEEPMODE示例中展示了它?
谢谢,PM_DIALOG.
Hi,
提供一些上下文:
SDK version, 6.0.10.511.
我们已经将BLE_APP_SECURITY作为此项目中的基础,但配置为使用扩展睡眠模式。这使得设备在广告之间进入睡眠。
理想情况下,我们希望每次DA14585醒来做广告时都阅读这个传感器。
如果我们将使用app_easy_timer(),那么设备将从睡眠中唤醒,只是为了做传感器读取,正确?
当设备已经醒来时,我们最好的是要做传感器读数。
Best regards
马丁
Hi mapart,
With the usage of the use the app_easy_timer(), you could implement the periodically reading of the sensor. Your device is initially advertising and while it’s adverting the sensor should be read periodically by the application, After an amount of time, you stop adverting and when the device wakes up by configuring the wake up controller, the application should start reading again the sensor periodically. Is that correct? Or you would like to read the sensor in every advertising interval? Please let me know and share what you exactly want to accomplish. It would be very helpful in order to provide you the correct guidelines.
谢谢,PM_DIALOG.
Hi,
是的,我想在每一个广告间隔内读取传感器(687.5毫秒)。
I think I managed to get this working by using the callback:
user_app_main_loop_callbacks.app_on_system_poweredThank you for your help.
此致
马丁
Hi mapart,
很高兴你想到了你发出问题,谢谢你接受答案。
谢谢,PM_DIALOG.
Hello Dialog,
A similar example with another workflow -
传感器>> I2C >> DA14586。
RTC >> GPIOx / WKUP interrupt >> DA14586
Normal operations of BLE would proceed for advertising as per sample applications provided with SDK.
从RTC升高中断时,BLE仍处于广告模式 -
记录时间戳;记录传感器数据;在闪存中存储传感器数据;
When BLE is connected to peer -
Disable RTC interrupt; Transfer Flash data over BLE to a Central Device (Ususally smart phone);
你能帮我解决代码插入和处理 -
1. RTC中断处理(主动和睡眠状态)
2 . BLE transmission using DSPS from Dialog.
谢谢
Hi rajucoolsuraj,
If I am able to understand correctly you would like to wake the device up when getting an interrupt correct? So, the device will be in sleep mode and when you get the interrupt from RTC (please clarify what the RTC is) the device will wake up and start advertising. If you would like to follow this implementation, I would suggest you to have a look at the ble_app_sleepmode example of the SDK. The only difference is that in this example the DA14585/6 wakes up from an interrupt which is generated by a button pressing. Are you using the DSPS application code or you have developed a custom application? Please check the user_send_ble_data() from the DSPS application code. Also, I would recommend you to have a look at the DSPS user manual and check figure 6 & 7.
https://support.dialog-seminile.com/system/files/resources/um-b-038%20da14580%20serial%20port%20service%20reference%20application_v2.0.pdf.
谢谢,PM_DIALOG.
谢谢对话框,
我想评估并张贴在这里。
我还在带有传感器的I2C控制器接口上提出了另一个帖子。
It seems that the controller does not send the salve device's register address after transmitting slave device address on SDA wire.
我可以得到帮助吗?
谢谢
raju.
霍尼韦尔
Hi rajucoolsuraj,
我已经在这个论坛线程中回复了你:
https://support.dialog-seminile.com/forums/post/dialog-smartbond-bluetooth-low-energy-%2%80%93-software/rtc-pcf85063a-i2c-using-i2ceeeprom-api.
谢谢,PM_DIALOG.
谢谢对话框,
但是,当我想要GPIO IRQ时,没有睡眠模式。
我应该在与对等方连接之前处理中断;当Periph是广告?
谢谢
raju.
Hi rajucoolsuraj,
您可以在初始化(.app_on_init)或user_app_adv_start中启用IRQ。但请注意,您必须不使用任何睡眠模式以检测中断。如果您想拥有任何睡眠模式配置,则应使用唤醒控制器。
谢谢,PM_DIALOG.
谢谢对话框,
I shall make use of WakeUp IRQ for both active and sleep modes. It seems better over GPIO.
如果有任何错误的遭遇可能会通过GPIO使用Wakeup Irq,我想知道它
谢谢
Hi rajucoolsuraj,
I would strongly recommend to have a look at the ble_app_sleepmode example of the SDK in order to understand how to use the wake-up controller.
谢谢,PM_DIALOG.
Hello Dialog,
唤醒控制器使用时在Custom Message处理程序中使用按钮回调是最佳的useCase示例。
I shall revert back incase of any logical breakdown during implementation.
谢谢
Hi rajucoolsuraj,
如果你想要任何的睡眠国防部es, the solution is to use the wake-up controller in order to detect the interrupt and wake up. Please check the app_button_enable() function which enables the wake-up controller before the device enters the sleep mode. You can select the GPIO that you could detect the wake-up interrupt with the wkupct_enable_irq() function. You can also configure the polarity and the debouncing time as well. Since the device goes into sleep and you send an interrupt to the wake-up controller, the callback function which is registered into wkupct_register_callback() will be triggered.
谢谢,PM_DIALOG.
Hello Dialog,
我使用Wakeup Controller回调注册注册了多个回调,如何从几个GPIO服务中的中断?
是在注册的GPIO中触发的最后一个吗?
谢谢
Regards
raju.
Hi rajucoolsuraj,
你能澄清你所做的一切吗?如果我能够正确理解,您将固件配置为从不同的GPIO唤醒?如果是,则首先将唤醒您的芯片。
谢谢,PM_DIALOG.
Hello Dialog,
谢谢。
Also, How to check for the GPIO pin source that triggered the interrupt via the WakeUp controller ?
SDK是否有任何寄存器或任何机制,允许我验证中断源?
谢谢
raju.
Hi rajucoolsuraj,
没有寄存器,指示中断发生的端口/引脚,您可以做的是检查脉冲的源,在设备唤醒后立即读取引脚的状态。因此,根据PIN状态,您必须确定将触发哪个回调函数。请尽量在论坛上尝试复制您的问题,您已创建类似的论坛线程,我已经回复了你:
https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bluetooth-low-energy-%E2%80%93-software/multiple-code-space-wkupenableirq
谢谢, PM_DIalog
Hello Dialog,
Sorry for the duplicates. Yes, thanks for the support.
此外,我对该线程提出了另一个问题。
Regards
raju.
Hi rajucoolsuraj,
没问题!让我们继续在您的其他论坛线程中进行对话。
谢谢,PM_DIALOG.