Hello developers,
I would like to combine BLE Central with USB HID. I am using the SDK example "BLE_Central_multilink", I can get signal from BLE modules.
Now I want to send data to PC through USB HID Protocol. I followed the example "usbd_hid_generic" and got finally no error from build.
However, the code go into hardfault while the initialising "err_code = nrf_drv_clock_init();" If I change the sequence, then from the other initialising.
If I debug it, this message is printed out "UNKNOWN FAULT at 0x0002DDE6".
If you help me to explain or solve the problem, I will very thank you.
I attatch my main code below
int main(void)
{
// Initialize.
log_init();
timer_init();
leds_init();
buttons_init();
power_management_init();
ble_stack_init();
gatt_init();
db_discovery_init();
lbs_c_init();
ble_conn_state_init();
scan_init();
/* USB HID Intialization */
ret_code_t err_code;
static const app_usbd_config_t usbd_config = {
.ev_state_proc = usbd_user_ev_handler
};
err_code = nrf_drv_clock_init();
APP_ERROR_CHECK(err_code);
nrf_drv_clock_lfclk_request(NULL);
while(!nrf_drv_clock_lfclk_is_running())
{
} /* Waiting till running */
//err_code = app_timer_init();
//APP_ERROR_CHECK(ret);
err_code = app_timer_create(&m_usb_hid_timer, APP_TIMER_MODE_REPEATED, data_transfer_timer_handler);
APP_ERROR_CHECK(err_code);
init_bsp();
#if NRF_CLI_ENABLED
init_cli();
#endif
printf("Hello USB!\n");
err_code = app_usbd_init(&usbd_config);
APP_ERROR_CHECK(err_code);
printf("USBD HID generic example started\n");
app_usbd_class_inst_t const * class_inst_generic;
class_inst_generic = app_usbd_hid_generic_class_inst_get(&m_app_hid_generic);
err_code = hid_generic_idle_handler_set(class_inst_generic, idle_handle);
APP_ERROR_CHECK(err_code);
err_code = app_usbd_class_append(class_inst_generic);
APP_ERROR_CHECK(err_code);
if(USBD_POWER_DETECTION)
{
err_code = app_usbd_power_events_enable();
APP_ERROR_CHECK(err_code);
}else
{
printf("No USB power detection enabled\r\nStarting USB now");
app_usbd_enable();
app_usbd_start();
}
// Start execution.
printf("Multilink example started.\n");
scan_start();
for (;;)
{
idle_state_handle();
}
}
Program information:
Segger Embedded Studio for ARM v5.50b
nRF52 SDK 17.0.2
Softdevice s140
codes based on PCA10056
Best regards
it0406