The nrf52840 usbd examples of peripheral in SDK 13.0.0 worked fine. I want usb work with BLE softdevice and there are lots of conflicts between nrf drv and softdevice. Is there any example of usbd working together with ble softdevice?
The nrf52840 usbd examples of peripheral in SDK 13.0.0 worked fine. I want usb work with BLE softdevice and there are lots of conflicts between nrf drv and softdevice. Is there any example of usbd working together with ble softdevice?
Hi,
I just tested this without any problems. Only thing I had to do was to comment out the buttons_leds_init()
function used in the ble_app_uart code, so it didn’t overwrite the button functionality used for the USBD part of the code.
My main code looks like this:
int main(void)
{
uint32_t err_code = 0;
bool erase_bonds;
uint32_t ret = 0;
// Initialize.
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
uart_init();
err_code = NRF_LOG_INIT(NULL);
APP_ERROR_CHECK(err_code);
NRF_LOG_INFO("\r\nUART Start!\r\n");
ret = nrf_drv_power_init(NULL);
APP_ERROR_CHECK(ret);
ret = nrf_drv_clock_init();
APP_ERROR_CHECK(ret);
NRF_LOG_INFO("Hello USB!\r\n");
/* Configure LEDs */
bsp_board_leds_init();
bsp_board_buttons_init();
serial_number_string_create();
ret = app_usbd_init();
APP_ERROR_CHECK(ret);
app_usbd_class_inst_t const * class_cdc_acm = app_usbd_cdc_acm_class_inst_get(&m_app_cdc_acm);
ret = app_usbd_class_append(class_cdc_acm);
APP_ERROR_CHECK(ret);
bool last_usb_conn_status = false;
usb_start();
NRF_LOG_INFO("Enabling BLE part!\r\n");
//buttons_leds_init(&erase_bonds);
ble_stack_init();
gap_params_init();
services_init();
advertising_init();
conn_params_init();
err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);
// Enter main loop.
for (;;)
{
last_usb_conn_status = usb_connection_handle(last_usb_conn_status);
if (bsp_board_button_state_get(BTN_CDC_DATA_SEND))
{
static int frame_counter;
sprintf(m_tx_buffer, "Hello USB CDC FA demo: %u\r\n", frame_counter);
ret = app_usbd_cdc_acm_write(&m_app_cdc_acm, m_tx_buffer, sizeof(m_tx_buffer));
if (ret == NRF_SUCCESS)
{
++frame_counter;
}
}
if (bsp_board_button_state_get(BTN_CDC_NOTIFY_SEND))
{
ret = app_usbd_cdc_acm_serial_state_notify(&m_app_cdc_acm,
APP_USBD_CDC_ACM_SERIAL_STATE_BREAK,
false);
UNUSED_VARIABLE(ret);
}
UNUSED_RETURN_VALUE(NRF_LOG_PROCESS());
power_manage();
}
}
Hi, the reason for this is that the NRF_POWER interrupts that is set with the usb_start()
/nrf_power_int_enable()
function are cleared/removed when the SoftDevice is enabled. These interrupts are used to detect when the USB-cable is plugged in and out.
The application has restricted access to the NRF_POWER peripheral after the SoftDevice is enabled, so it cannot set-up the interrupts after the SoftDevice is enabled. A new SoftDevice version is soon coming that will have the functionality to set-up these interrupts after the SoftDevice is enabled.
Hi, are there any updates on the above? I am currently facing the same issue as this thread author. I am using nRF5 SDK 17.1.0 with 7.2 SoftDevide and couldn't get USB_MSC example working combined with BLE CENTRAL UART example.
Hi Jev,
This case is from 2017. Please open a new case if you are having issues.
Hi Jev,
This case is from 2017. Please open a new case if you are having issues.