void main (void) { T_QUEUE queue = bsp_init (); pr_info (LOG_MODULE_MAIN, "BSP init done"); cfw_init (queue); pr_info (LOG_MODULE_MAIN, "CFW init done"); xloop_init_from_queue (&loop, queue); xloop_run (&loop); }
BleStatus ble_client_init(ble_client_gap_event_cb_t gap_event_cb, void *gap_event_param, ble_client_gatts_event_cb_t gatts_event_cb, void *gatts_event_param) { BleStatus status; uint32_t delay_until; cfw_platform_nordic_init(); client_handle = cfw_init(cfw_get_service_queue(), ble_core_client_handle_message, NULL); sync.response = 0; if (cfw_register_svc_available(client_handle, BLE_CORE_SERVICE_ID, NULL)) return BLE_STATUS_ERROR; /* Wait for response messages */ wait_for_condition(sync.response, status); if (status != BLE_STATUS_SUCCESS) return status; /* We need to wait for ~1 ms before continuing */ delay_until = get_uptime_32k() + TIMEOUT_TICKS_1MS; while (get_uptime_32k() < delay_until); sync.response = 0; cfw_open_service(client_handle, BLE_CORE_SERVICE_ID, NULL); /* Wait for response messages */ wait_for_condition(sync.response, status); if (status != BLE_STATUS_SUCCESS) return status; ble_client_gap_event_cb = gap_event_cb; ble_client_gap_event_param = gap_event_param; ble_client_gatts_event_cb = gatts_event_cb; ble_client_gatts_event_param = gatts_event_param; return sync.status; }
/* Application main entry point */ void main_task (void *param) { /* Init BSP (also init BSP on ARC core) */ queue = bsp_init (); /* start Quark watchdog */ wdt_start (WDT_MAX_TIMEOUT_MS); /* Init the CFW */ cfw_init (queue); jerry_start (); /* Loop to process message queue */ while (1) { OS_ERR_TYPE err = E_OS_OK; /* Process message with a given timeout */ queue_process_message_wait (queue, 5000, &err); /* Acknowledge the system watchdog to prevent panic and reset */ wdt_keepalive (); } }
void cproxy_init(T_QUEUE queue) { _queue = queue; _proxy_handle = cfw_init(_queue, _handle_client_message, NULL); }