Porting tinyusb to nrf52840 (USBD_IRQHandler not being called) #731
-
Hello, I'm porting tinyusb into existing big nrf52840 project (Segger IDE) by replacing nrfx_usbd* implementation with tinyusb. I have disabled all USBD modules in sdk_config.h and added tusb_config.h + usb_descriptors.c. Also I implemented the following function in main.c:
but it never being called. But as far as I understand tusb_init() has to enable this interrupt by itself, so the function has to be called, e.g. when device is plugged\unplugged from USB. Am I missing something here? Thank you! P.S.: I understand it's more likely problem in my project setup and the fact that I don't understand exactly how interrupts are working in NRF family devices, but I didn't find anything useful in their documentation. So perhaps someone could point me out where is the problem ;) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
you need to call the tusb_hal_nrf_power_event() on the power event to trigger enable usb controller. Check out the stock example with nrf board bsp here for hint https://github.com/hathach/tinyusb/blob/master/hw/bsp/nrf/family.c Note: the power handle is different with and without softdevice enabled, when SD inited/started after usb, you also need to uninit the nrfx_power() and hooked up/ check the power using sd api as well. Here is the code used in adafruit arduino nrf52 https://github.com/adafruit/Adafruit_nRF52_Arduino/blob/master/libraries/Bluefruit52Lib/src/bluefruit.cpp#L67 |
Beta Was this translation helpful? Give feedback.
-
Hi, @oleh-hordiichuk :
|
Beta Was this translation helpful? Give feedback.
you need to call the tusb_hal_nrf_power_event() on the power event to trigger enable usb controller. Check out the stock example with nrf board bsp here for hint https://github.com/hathach/tinyusb/blob/master/hw/bsp/nrf/family.c
Note: the power handle is different with and without softdevice enabled, when SD inited/started after usb, you also need to uninit the nrfx_power() and hooked up/ check the power using sd api as well. Here is the code used in adafruit arduino nrf52 https://github.com/adafruit/Adafruit_nRF52_Arduino/blob/master/libraries/Bluefruit52Lib/src/bluefruit.cpp#L67