Skip to main content

USB CDC and USB Charging

1 month ago

USB CDC and USB Charging

Posted bySubramanyan95 points 15 replies
0 upvotes

Hi,

I am working on custom hardware with Dialog's DA14695 bluetooth chip. I am using the ble_social_distancing_tag example to flash on my custom hardware.

I am using WiRa SDK 10.440.8.6.

I am trying to enable USB so that I can send some commands over USB serial terminal. I have enabled dg_configUSE_SYS_CHARGER and dg_configUSE_USB_ENUMERATION. If I connect my hardware to the PC over USB, it is not getting detected. Only if I disable dg_configUSE_SYS_CHARGER, can I see the PC detecting my hardware over USB.

Also, if I have enabled dg_configUSE_USB_ENUMERATION and disabled dg_configUSE_SYS_CHARGER, the PC is able to detect it only once on boot up. If I detach the USB cable and attach it back to the PC, the device is not detected and Windows reports an error saying it is not able to get Device details.

I have referred to the linkhttp://lpccs-docs.dialog-semiconductor.com/um-b-092-da1469x_software_platform_reference/User_guides/User_guides.html#the-usb-framework.

Also, I have tested with usb_cdc and usb_cdc_smsd which is working find. I think both _usb_cdc and usb_cdc_smsd don't have USB charging functionality implemented, so it works fine.

Whereas ble_social_distancing_tag has USB charging enabled and that appears to be causing issues with a USB CDC solution.

Any help regarding this is deeply appreciated.

Thanks and Regards,

Subbu

1 month ago

PM_Dialog

Hi Subramanyan,

Thanks for your question. We got a similar question from one of your colleagues please see below :

//www.xmece.com/products/bluetooth-low-energy?post_id=11735#tab-support_tab_content

>>>Whereas ble_social_distancing_tag has USB charging enabled and that appears to be causing issues with a USB CDC solution.

So, have you imported the USB CDC from the usb_cdc SDk project to the ble_social_distancing_tag?

Thanks, PM_Dialog

1 month ago

Subramanyan 95 points

Hi PM_Dialog,

I checked the answer provided to my colleague. So, from the answer, I gather that USB charging and USB enumeration should be able to exist and work side by side. There should be no issue.

I have imported the usb_cdc.c from usb-cdc project and removed the suousb_cdc.c from the ble_social_distancing_tag project since we not looking at firmware update over USB.

With importing the usb_cdc.c to my project and with USB charging enabled, the device should be able to be detected via USB and we can open a serial terminal to transfer content over USB. Is my understanding correct?

Thanks and Regards,

Subramanyan

1 month ago

Subramanyan 95 points

Hi PM_Dialog,

I wanted to check with you if my approach mentioned in my earlier post is correct.

With the ble_social_distancing_tag example, I am removing suousb_cdc.c and including usb_cdc.c (from usb_cdc project). The USB charging is also enabled.

This is so that when I connect the device to a PC, the PC will recognize the device as a USB device and open a COM port. Using this COM port, I can transfer any content or configuration to the device using any serial application.

Please let me know if what I have done should work or will not work?

Thanks and Regards,

Subbu

1 month ago

PM_Dialog

Hi Subbu,

Let me check this and I'll get back to you.

Thanks, PM_Dialog

1 month ago

Subramanyan 95 points

Hi PM_Dialog,

That will be great. If you can check the attach and detach the USB device functionality, that will be great since that does not work if I use usb_cdc on the ble_social_distancing_tag project.

If I use usb_cdc in the ble_social_distancing_tag code and disable USB charging, I see that for the first time (after reset), the device is detected as a COM port by the PC and I can send data.

If I detach and attach it, I can no longer communicate to the device. I have not tried to debug it yet.

While you are checking this solution, if you can check this as well, that will be great.

I am using a custom board for testing and not the DA14695 development kit.

Thanks and Regards,

Subramanyan

1 month ago

PM_Dialog

Hi Subbu,

I'll escalate this question to our Team internally to check this out. I'll keep you posted on this.

Thanks, PM_Dialog

1 month ago

PM_Dialog

Hi Subbu,

Please find below feedback from our Team internally.

SDK project : /projects/dk_apps/features/usb_cdc

Please use the USB_CDC project as provided by the SDK and do the following modifications:

1. Add the sys charger in the custom_config_qspi.h – see the diff file below:

projects/dk_apps/features/usb_cdc/config/custom_config_qspi.h @@ -37,7 +37,7 @@ #define dg_configFLASH_POWER_DOWN (0) +#define dg_configUSE_SYS_CHARGER (1) #define dg_configUSE_HW_TRNG (1)

2. Add the custom_config_charger.h in the config folder – see attached.

3. Add the charger init in the system_init function – see the diff file below:

/projects/dk_apps/features/usb_cdc/src/main.c @@ -21,6 +21,9 @@ #include "sys_power_mgr.h" #include "sys_watchdog.h" #include "sys_usb.h" +#include "sys_charger.h" +#include "custom_charging_profile.h" + #if dg_configUSE_WDOG __RETAINED_RW int8_t idle_task_wdog_id = -1; @@ -71,6 +74,7 @@ static void system_init(void *pvParameters) pm_sleep_mode_set(pm_mode_extended_sleep); sys_usb_init(); + sys_charger_init(&sys_charger_conf); /* the work of the SysInit task is done */ OS_TASK_DELETE(OS_GET_CURRENT_TASK());

It's being properly detected with that changes. Could you please test this with your custom board and with the Pro-DK?

Thanks, PM_Dialog

Attachment Size
step_2.png 21.41 KB

1 month ago

Subramanyan 95 points

Hi PM_Dialog,
Thanks. I will test this and let you know.
Regards,
Subbu

4 weeks ago

PM_Dialog

Hi Subbu,

Please test this in the Pro-DK and your custom board and let me know.

Thansk, PM_Dialog

1 month ago

Subramanyan 95 points

Hi PM_Dialog,

While I check the usb_cdc change that you are suggesting, while working with the ble_social_distancing_tag example, I see that the sys_usb_process_detach() function in sys_usb_da1469x.c causes issues. The firmware hangs when this function is called during the detach process.

Can you confirm if for attaching and detaching the USB, sys_usb_process_attach() and sys_usb_process_detach() works correctly if the USB enumeration and USB charging is enabled ?

我不确定如果sys_usb_process_att功能ach() and sys_usb_process_detach() are called in the usb_cdc example for me to compare the behavior.

Thanks and Regards,

Subbu

4 weeks ago

PM_Dialog

Hi Subbu,

Could you please run it in debug mode and share a screenshot showing where the code hangs?

你做了任何修改the ble_social_distancing_tag example?

P.S. : Since this is not related to the USB CDC and Changing functionality (as described in the initial post), I would recommend to raise a new forum ticket for the de-attaching issue. This will help us to best track all of the issues.

Thanks, PM_Dialog

4 weeks ago

Subramanyan 95 points

Hi PM_Dialog,

I will raise a separate ticket for the ble_social_distancing_tag detach issue.

On the USB_CDC, I did the changes ie enabling the charging functionality. I see it working intermittently.

It always works first time when I restart the device and I am able to see the device as a COM device.

However, on detach and attach, I sometimes see that Windows does not show up the device as a COM device. Again, I say sometimes because when I restart and try again it works. Detaching and attaching works fine and Windows is able to recognize it. I am not sure what the reason could be.

Thanks and Regards,

Subbu

accepted answer!

3 weeks ago

PM_Dialog

Hi Subbu,

So, do you need any further support on the USB_CDC project? Did you raise a new ticket for the ble_social_distancing_tag issue?

Thanks, PM_Dialog

3 weeks ago

Subramanyan 95 points

Hi PM_Dialog,

Thanks for the detailed responses. I will test this further and raise a separate ticket if required.

Thanks and Regards,

Subbu

3 weeks ago

PM_Dialog

Hi Subbu,

Thanks for the update. Please raise a new forum ticket if you have any follow up question regarding the SDT application.

Thanks, PM_Dialog