Ejemplo n.º 1
0
void bluetooth_task(intptr_t unused) {
#if defined(DEBUG)
	syslog(LOG_DEBUG, "[bluetooth] Start main task.");
#endif

    run_loop_init(RUN_LOOP_EMBEDDED);

    // Initialize HCI
    bt_control_t             *control   = bt_control_cc256x_instance();
	hci_transport_t          *transport = hci_transport_h4_dma_instance();
	hci_uart_config_t        *config    = hci_uart_config_cc256x_instance();
	const remote_device_db_t *db        = &remote_device_db_memory;
	hci_init(transport, config, control, db);

    // Initialize SPP (Serial Port Profile)
    bluetooth_spp_initialize();

	// Power on
	bt_control_cc256x_enable_ehcill(false);
	hci_power_control(HCI_POWER_ON);

    run_loop_execute();
#if 0 // Code for debugging
        while(1) {
//        	bluetooth_uart_isr();
        	embedded_execute_once();
//        			if(rx_size > 0 && (UART2.IIR_FCR & 0x4)) // TODO: dirty hack
//        				AINTC.SISR = UART2_INT;
        	tslp_tsk(1); // TODO: Use interrupt instead of sleeping. -- ertl-liyixiao
        }
#endif
}
Ejemplo n.º 2
0
void BTSTACK_Tasks(){
    if (bytes_to_read && PLIB_USART_ReceiverDataIsAvailable(BT_USART_ID)) {
        *rx_buffer_ptr++ = PLIB_USART_ReceiverByteReceive(BT_USART_ID);
        bytes_to_read--;
        if (bytes_to_read == 0){
            (*rx_done_handler)();
        }
    }

    if (bytes_to_write && PLIB_USART_TransmitterIsEmpty(BT_USART_ID)){
        PLIB_USART_TransmitterByteSend(BT_USART_ID, *tx_buffer_ptr++);
        bytes_to_write--;
        if (bytes_to_write == 0){
            (*tx_done_handler)();
        }
    }

    // BTstack Run Loop
    embedded_execute_once();
}
Ejemplo n.º 3
0
/**
 * Execute run_loop
 */
void embedded_execute(void) {
    while (1) {
        embedded_execute_once();
        btstack_runloop_sleep(1); // TODO: Use interrupt instead of sleeping. -- ertl-liyixiao
    }
}
Ejemplo n.º 4
0
/**
 * Execute run_loop
 */
static void embedded_execute(void) {
    while (1) {
        embedded_execute_once();
    }
}
Ejemplo n.º 5
0
/**
 * Execute run_loop
 */
void embedded_execute(void) {
    while (1) {
        embedded_execute_once();
        tslp_tsk(1); // TODO: Use interrupt instead of sleeping. -- ertl-liyixiao
    }
}