你好,
We would like to read a sensor over i2c periodically, preferably when the da14585 wakes up to do the BLE advertising.
To read the sensor, we must first wake up the sensor by driving a pin high, wait ~1ms, then read 8 bytes of data over i2c.
This sequence works by itself, but when I try to do it in either the callback user_app_main_loop_callbacks.app_on_system_powered or user_app_main_loop_callbacks.app_before_sleep I get stuck somehow.
The sequence to initialize the i2c which is called from periph_init:
void init_acc_i2c(void)
{
setBits16(CLK_PER_REG,I2C_ENABLE,1);//为i2c启用时钟
setword16(i2c_enable_reg,0x0);//禁用I2C控制器
SetWord16(I2C_CON_REG,0x0063); //12c master, 7bit slave address, 100kbit
SetWord16(I2C_TAR_REG,ACCELEROMETER_I2C_ADDR);
SetWord16(I2C_ENABLE_REG, 0x1); // Enable the I2C controller
}
要读取传感器数据的代码,我尝试从上面描述的回调调用:
void read_sensor_seequentient(void)
{
int i;
uint8_t data[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 ++)
{
WAIT_WHILE_I2C_FIFO_IS_FULL();
SetWord16(I2C_DATA_CMD_REG,0x0100);
}
GLOBAL_INT_RESTORE();
for(i = 0; i <7; i ++)
{
WAIT_FOR_RECEIVED_BYTE(); // Wait for received data
data[i]=(0xFF & GetWord16(I2C_DATA_CMD_REG)); // Get the received byte
}
GPIO_SetInactive(ACCELEROMETER_ENABLE_PORT,ACCELEROMETER_ENABLE_PIN);
WAIT_UNTIL_I2C_FIFO_IS_EMPTY(); // Wait until Tx FIFO is empty
WAIT_UNTIL_NO_MASTER_ACTIVITY(); // wait until no master activity
}
有可能使用任何回调的疼痛吗ive this?
最好的祝福
Martin

嗨Mapart,
阅读传感器定期你的计谋ld use the app_easy_timer() API. Every time that the timer expired, the registered callback will be triggered, so you need to register the callback that you are reading the sensor. In case of reading the sensor every time that the DA1458, could you please share more details? The device enters the sleep mode between adverting or connection intervals. Did you configure it to enter the deep sleep mode, as it is demonstrated in the ble_app_sleepmode example of the SDK?
Thanks, PM_Dialog
你好,
To provide some context:
SDK版本,6.0.10.511。
We've used ble_app_security as the base in this project, but configured it to use extended sleep mode. This makes the device enter sleep between advertising.
Ideally, we would like to read this sensor each time the da14585 wakes up to do the advertising.
If we would use the app_easy_timer(), the device would wake up from sleep just to do the sensor reading, correct?
The best for us would be to do the sensor reading when the device is already awake.
最好的祝福
Martin
嗨Mapart,
通过使用App_easy_timer()的使用,您可以在定期读取传感器。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.
Thanks, PM_Dialog
你好,
Yes I would like to read the sensor in every advertising interval (687.5 ms).
我想我设法使用回调来获得这个工作:
user_app_main_loop_callbacks.app_on_system_powered.谢谢您的帮助。
Best Regards
Martin
嗨Mapart,
Glad the you figured you issue out and thanks for accepting the answer.
Thanks, PM_Dialog
你好对话框,
与另一个工作流程类似的例子 -
Sensor >> i2c >> DA14586.
RTC >> GPIOx / WKUP中断>> DA14586
根据具有SDK的示例应用程序,BLE的正常操作将进行广告。雷竞技安卓下载
When an interrupt is raised from RTC and BLE is still in Advertising mode -
Record time stamp; Record sensor data; store sensor data in flash;
当ble连接到对等 -
禁用RTC中断;将闪光数据传输到中央设备(USUULALLY SMART PHONE);
Can you help me out with code insertion and handling for -
1. RTC interrupt handling (Active and sleep state)
2。使用DSP从对话框中传输。
Thanks
嗨rajucoolsuraj,
如果我能够正确理解,您想在获得中断正确时唤醒设备?因此,设备将处于睡眠模式,并且当您从RTC获取中断时(请澄清RTC是什么)设备将唤醒并启动广告。如果您想遵循此实现,我建议您查看SDK的BLE_APP_SLEEPMODE示例。唯一的区别是,在此示例中,DA14585 / 6从中断唤醒,该中断由按钮按压生成。您是否使用DSPS应用程序代码或者您已开发自定义应用程序?请从DSPS应用程序代码检查User_send_ble_data()。此外,我建议您查看DSP用户手册并检查图6和7。
https://support.dialog-semiconductor.com/system/files/resources/UM-B-038%20DA14580%20Serial%20Port%20Service%20reference%20application_v2.0.pdf
Thanks, PM_Dialog
Thanks Dialog,
I would like to evaluate and post back here.
I have also raised another post on I2C controller interface with sensor.
在在SDA线上传输从设备地址,控制器似乎不会在SDA设备地址之后发送Salve设备的寄存器地址。
Can I get an assistance on that?
Thanks
Raju
HONEYWELL
嗨rajucoolsuraj,
I have already replied you in this forum thread:
https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bluetooth-low-energy-%E2%80%93-software/rtc-pcf85063a-i2c-using-i2ceeprom-api
Thanks, PM_Dialog
Thanks Dialog,
But, When I want a GPIO IRQ enabled without sleep modes.
When should I handle the interrupt before the connection with peer; when the periph is advertising?
THanks
Raju
嗨rajucoolsuraj,
You could enable the IRQ upon the initialization (.app_on_init) or in the user_app_adv_start. But be aware that you have to not use any of the sleep modes in order to detect the interrupt. If you would like to have any of the sleep mode configuration, you should use the wakeup controller.
Thanks, PM_Dialog
Thanks Dialog,
我将利用唤醒IRQ,了解有效和睡眠模式。GPIO似乎更好。
If there are any erroneous encounters that might result of using WakeUp IRQ via GPIO, I would like to know of it
THanks
嗨rajucoolsuraj,
我强烈建议看看SDK的BLE_APP_SLEEPMODE示例,以便了解如何使用唤醒控制器。
Thanks, PM_Dialog
你好对话框,
The WakeUp controller usage upon connection in custom message handlers for button callback is the best usecase example.
在实施期间,我将恢复任何逻辑故障的Incase。
Thanks
嗨rajucoolsuraj,
如果您希望有任何睡眠模式,则解决方案是使用唤醒控制器以检测中断并唤醒。请检查App_Button_Enable()函数,在设备进入睡眠模式之前,可以启用唤醒控制器。您可以选择您可以使用WKUPCT_ENABLE_IRQ()函数检测唤醒中断的GPIO。您还可以配置极性和拆除时间。由于设备进入睡眠状态并向唤醒控制器发送中断,因此将触发已注册到WKUPCT_REGISTER_CALLBACK()的回调函数。
Thanks, PM_Dialog
你好对话框,
I have registered multiple callbacks using WakeUp controller callback registration, how are the interrupts from several GPIO's serviced ?
Is it the last one that triggered among the registered GPIO's ?
Thanks
问候
Raju
嗨rajucoolsuraj,
Could you please clarify what you have done? If I am able to understand correctly, you configured the firmware to wake up from different GPIOs? If yes, the first on will wake your chip up.
Thanks, PM_Dialog
你好对话框,
Thanks.
此外,如何检查通过唤醒控制器触发中断的GPIO引脚源?
Is there any register or any mechanism in the SDK that allows me to validate the interrupt source ?
Thanks
Raju
嗨rajucoolsuraj,
There is no register that will indicate the port/pin that the interrupt occurred, what you can do in order to check the source of the pulse is to read the status of the pin right after the device has been awaken. So, according to the pin status you will have to decide which callback function will be triggered. Please kindly try to not duplicate your questions on the forum, you have created a similar forum thread and I have replied you there:
https://support.dialog-seminile.com/forums/post/dialog-smartbond-bluetooth-low-energy -%e2%80%93-software/multiple-code-space-wkupenableirq.
谢谢,PM_DIALOG.
你好对话框,
抱歉重复。是的,谢谢你的支持。
Also, I have raised another concern on that thread.
问候
Raju
嗨rajucoolsuraj,
No problem! Let’s continue the conversation in your other forum thread.
Thanks, PM_Dialog