Hello,
I merged the two projects usbd_cdc_acm_pca10056 (A) and ble_app_hids_mouse_pca10056_s140 (B).
Currently, I'm trying to make it running again by line by line add the code of A's main function into B's.
I had to adjust some event handlers, reorder some function calls and everything worked fine so far until the debugger hits the call
ret = nrf_drv_clock_init();
APP_ERROR_CHECK(ret);
from A, which produces a fatal error which I, unfortunately, am not able to debug by myself.
Maybe it has something to do with merging a project that does not use softdevice into one that uses it (140) as some code sections of nrf_drv_clock_init() compile with annotations regarding SOFTDEVICE_PRESENT?
Any ideas on how to solve this issue?
main() code:
int main(void)
{
ret_code_t ret;
static const app_usbd_config_t usbd_config = {
.ev_state_proc = usbd_user_ev_handler
};
bool erase_bonds;
// Initialize.
log_init();
timers_init();
buttons_leds_init(&erase_bonds);
#if NRF_CLI_ENABLED
init_cli();
#endif
power_management_init();
ble_stack_init();
scheduler_init();
gap_params_init();
gatt_init();
advertising_init();
services_init();
sensor_simulator_init();
conn_params_init();
peer_manager_init();
// Start execution.
NRF_LOG_INFO("HID Mouse example started.");
timers_start();
advertising_start(erase_bonds);
/* // Enter main loop.
for (;;)
{
idle_state_handle();
}
*/
ret = nrf_drv_clock_init();
APP_ERROR_CHECK(ret);
nrf_drv_clock_lfclk_request(NULL);
while(!nrf_drv_clock_lfclk_is_running())
{
//Just waiting
}
app_usbd_serial_num_generate();
ret = app_usbd_init(&usbd_config);
APP_ERROR_CHECK(ret);
NRF_LOG_INFO("USBD CDC ACM example started.");
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);
if (USBD_POWER_DETECTION)
{
ret = app_usbd_power_events_enable();
APP_ERROR_CHECK(ret);
}
else
{
NRF_LOG_INFO("No USB power detection enabled\r\nStarting USB now");
app_usbd_enable();
app_usbd_start();
}
while (true)
{
while (app_usbd_event_queue_process())
{
//* Nothing to do
}
if(m_send_flag)
{
static int frame_counter;
size_t size = 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, size);
if (ret == NRF_SUCCESS)
{
++frame_counter;
}
}
#if NRF_CLI_ENABLED
nrf_cli_process(&m_cli_uart);
#endif
UNUSED_RETURN_VALUE(NRF_LOG_PROCESS());
// Sleep CPU only if there was no interrupt since last loop processing
__WFE();
}
/**/
}
Full Project: