I2C during ble advertising

⚠️
嗨,...感谢您来论坛。令人兴奋的消息!我们现在正在迁至我们的新论坛平台,将提供更好的功能,并包含在主对话框网站中。所有帖子和帐户都已迁移。我们现在只接受新论坛上的流量 - 请发布任何新线程https://www.dialog-seminile.com/support.。我们将在未来几天修复错误/优化搜索和标记。
22 posts / 0 new
最后一篇
Mapart.
离线
Last seen:1个月3周前
加入:2018-11-30 15:58
I2C during ble advertising

你好,

我们希望定期读取传感器,优选地,当DA14585唤醒以进行BLE广告时。
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_sequentient(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();//等待收到的数据
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

}

Is it possible to use any of the callbacks to acheive this?

此致
Martin

Device:
PM_Dialog
离线
Last seen:1天6小时前
职员
加入:2018-02-08 11:03
嗨Mapart,

嗨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

Mapart.
离线
Last seen:1个月3周前
加入:2018-11-30 15:58
你好,

你好,

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.
如果我们将使用app_easy_timer(),那么设备将从睡眠中唤醒,只是为了做传感器读取,正确?
当设备已经醒来时,我们最好的是要做传感器读数。

此致
Martin

PM_Dialog
离线
Last seen:1天6小时前
职员
加入:2018-02-08 11:03
嗨Mapart,

嗨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

Mapart.
离线
Last seen:1个月3周前
加入:2018-11-30 15:58
你好,

你好,
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

PM_Dialog
离线
Last seen:1天6小时前
职员
加入:2018-02-08 11:03
嗨Mapart,

嗨Mapart,

Glad the you figured you issue out and thanks for accepting the answer.

Thanks, PM_Dialog

Rajucoolsuraj.
离线
Last seen:6 months 3 weeks ago
加入:2018-12-12 16:09
你好对话框,

你好对话框,
与另一个工作流程的类似示例 -
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中断;将闪光数据传输到中央设备(USUSIVALLY智能手机);

你能帮我解决代码插入和处理 -
1. RTC interrupt handling (Active and sleep state)
2。使用dsps从对话框中传输。

Thanks

PM_Dialog
离线
Last seen:1天6小时前
职员
加入:2018-02-08 11:03
嗨rajucoolsuraj,

嗨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

Rajucoolsuraj.
离线
Last seen:6 months 3 weeks ago
加入:2018-12-12 16:09
Thanks Dialog,

Thanks Dialog,

I would like to evaluate and post back here.

我还在带有传感器的I2C控制器接口上提出了另一个帖子。

在在SDA线上传输从设备地址,控制器似乎不会在SDA设备地址发送ALVE设备的寄存器地址。

我可以得到帮助吗?

Thanks

raju.

HONEYWELL

PM_Dialog
离线
Last seen:1天6小时前
职员
加入:2018-02-08 11:03
嗨rajucoolsuraj,
Rajucoolsuraj.
离线
Last seen:6 months 3 weeks ago
加入:2018-12-12 16:09
Thanks 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.

PM_Dialog
离线
Last seen:1天6小时前
职员
加入:2018-02-08 11:03
嗨rajucoolsuraj,

嗨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

Rajucoolsuraj.
离线
Last seen:6 months 3 weeks ago
加入:2018-12-12 16:09
Thanks 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

PM_Dialog
离线
Last seen:1天6小时前
职员
加入:2018-02-08 11:03
嗨rajucoolsuraj,

嗨rajucoolsuraj,

我强烈建议看看SDK的BLE_APP_SLEEPMODE示例,以便了解如何使用唤醒控制器。

Thanks, PM_Dialog

Rajucoolsuraj.
离线
Last seen:6 months 3 weeks ago
加入:2018-12-12 16:09
你好对话框,

你好对话框,
The WakeUp controller usage upon connection in custom message handlers for button callback is the best usecase example.

在实施期间,我将恢复反过来的任何逻辑故障。

Thanks

PM_Dialog
离线
Last seen:1天6小时前
职员
加入:2018-02-08 11:03
嗨rajucoolsuraj,

嗨rajucoolsuraj,

如果您想拥有任何睡眠模式,则解决方案是使用唤醒控制器以检测中断并唤醒。请检查app_button_enable()函数,在设备进入睡眠模式之前,可以启用唤醒控制器。您可以选择与WKUPCT_ENABLE_IRQ()函数检测唤醒中断的GPIO。您还可以配置极性和拆除时间。由于设备进入睡眠状态,并且向唤醒控制器发送中断,因此将触发注册到WKUPCT_REGISTER_CALLBACK()的回调函数。

Thanks, PM_Dialog

Rajucoolsuraj.
离线
Last seen:6 months 3 weeks ago
加入:2018-12-12 16:09
你好对话框,

你好对话框,

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.

PM_Dialog
离线
Last seen:1天6小时前
职员
加入:2018-02-08 11:03
嗨rajucoolsuraj,

嗨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

Rajucoolsuraj.
离线
Last seen:6 months 3 weeks ago
加入:2018-12-12 16:09
你好对话框,

你好对话框,
谢谢。

此外,如何检查通过唤醒控制器触发中断的GPIO引脚源?

Is there any register or any mechanism in the SDK that allows me to validate the interrupt source ?

Thanks

raju.

PM_Dialog
离线
Last seen:1天6小时前
职员
加入:2018-02-08 11:03
嗨rajucoolsuraj,

嗨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-semicondiondiondiondum/forums/post/dialog-smartbond-bluetooth-low-energy -%e2%80%93-software/multpreipre-code-space-wkupenableirq.

谢谢,PM_DIALOG.

Rajucoolsuraj.
离线
Last seen:6 months 3 weeks ago
加入:2018-12-12 16:09
你好对话框,

你好对话框,

抱歉重复。是的,谢谢你的支持。

此外,我对该线程提出了另一个问题。

问候

raju.

PM_Dialog
离线
Last seen:1天6小时前
职员
加入:2018-02-08 11:03
嗨rajucoolsuraj,

嗨rajucoolsuraj,

No problem! Let’s continue the conversation in your other forum thread.

Thanks, PM_Dialog