Beispiel #1
0
int main(void)
{
	clock_setup();
	gpio_setup();
	hal_tick_init();
	debug_usart_setup();
	bluetooth_setup();

	// start with BTstack init - especially configure HCI Transport
    btstack_memory_init();
    run_loop_init(RUN_LOOP_EMBEDDED);
    
    // init HCI
    hci_transport_t    * transport = hci_transport_h4_dma_instance();
    bt_control_t       * control   = bt_control_cc256x_instance();
    remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
    hci_init(transport, (void*) &hci_uart_config_cc256x, control, remote_db);

    // enable eHCILL
    bt_control_cc256x_enable_ehcill(1);

	// hand over to btstack embedded code 
    btstack_main();

    // go
    run_loop_execute();

	return 0;
}
Beispiel #2
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
}
Beispiel #3
0
int main(void){

    // stop watchdog timer
    WDTCTL = WDTPW + WDTHOLD;

    //Initialize clock and peripherals 
    halBoardInit();  
    halBoardStartXT1();	
    halBoardSetSystemClock(SYSCLK_16MHZ);
    
    // Debug UART
    halUsbInit();

    // show off
    doLCD();
    
   // init LEDs
    LED_PORT_OUT |= LED_1 | LED_2;
    LED_PORT_DIR |= LED_1 | LED_2;
    
	/// GET STARTED ///
	btstack_memory_init();
    run_loop_init(RUN_LOOP_EMBEDDED);

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

    // use eHCILL
    bt_control_cc256x_enable_ehcill(1);

    // init L2CAP
    l2cap_init();
    l2cap_register_packet_handler(packet_handler);
		
    // ready - enable irq used in h4 task
    __enable_interrupt();   
 	
    // turn on!
	hci_power_control(HCI_POWER_ON);
	
    // go!
    run_loop_execute();	
    
    return 0;
}
Beispiel #4
0
void BTSTACK_Initialize ( void )
{
    printf("\n\nBTstack_Initialize()\n");

    btstack_memory_init();
    run_loop_init(RUN_LOOP_EMBEDDED);

    hci_dump_open(NULL, HCI_DUMP_STDOUT);

    hci_transport_t * transport = hci_transport_h4_dma_instance();
    bt_control_t    * control   = bt_control_csr_instance();
    hci_init(transport, (void*) &hci_uart_config_csr, control, NULL);

    // hci_power_control(HCI_POWER_ON);
    btstack_main(0, NULL);
}
Beispiel #5
0
static void btstack_setup(){
    /// GET STARTED with BTstack ///
    btstack_memory_init();
    run_loop_init(RUN_LOOP_EMBEDDED);
    
    // init HCI
    hci_transport_t    * transport = hci_transport_h4_dma_instance();
    bt_control_t       * control   = bt_control_cc256x_instance();
    hci_uart_config_t  * config    = hci_uart_config_cc256x_instance();
    remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
    hci_init(transport, config, control, remote_db);
    
    // use eHCILL
    bt_control_cc256x_enable_ehcill(1);
    
    // init L2CAP
    l2cap_init();
    l2cap_register_packet_handler(packet_handler);
}
Beispiel #6
0
// main
int main(void)
{
    // stop watchdog timer
    WDTCTL = WDTPW + WDTHOLD;

    //Initialize clock and peripherals 
    halBoardInit();  
    halBoardStartXT1();	
    halBoardSetSystemClock(SYSCLK_16MHZ);
    
    // init debug UART
    halUsbInit();

    // init LEDs
    LED_PORT_OUT |= LED_1 | LED_2;
    LED_PORT_DIR |= LED_1 | LED_2;
    
	/// GET STARTED with BTstack ///
	btstack_memory_init();
    run_loop_init(RUN_LOOP_EMBEDDED);
	
    // init HCI
	hci_transport_t    * transport = hci_transport_h4_dma_instance();
	bt_control_t       * control   = bt_control_cc256x_instance();
    hci_uart_config_t  * config    = hci_uart_config_cc256x_instance();
    remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
	hci_init(transport, config, control, remote_db);
	
    // use eHCILL
    bt_control_cc256x_enable_ehcill(1);
    
    // init L2CAP
    l2cap_init();
    l2cap_register_packet_handler(packet_handler);
    
    // init RFCOMM
    rfcomm_init();
    rfcomm_register_packet_handler(packet_handler);
    rfcomm_register_service_with_initial_credits_internal(NULL, rfcomm_channel_nr, 100, 1);  // reserved channel, mtu=100, 1 credit

    // init SDP, create record for SPP and register with SDP
    sdp_init();
	memset(spp_service_buffer, 0, sizeof(spp_service_buffer));
    service_record_item_t * service_record_item = (service_record_item_t *) spp_service_buffer;
    sdp_create_spp_service( (uint8_t*) &service_record_item->service_record, 1, "SPP Counter");
    printf("SDP service buffer size: %u\n\r", (uint16_t) (sizeof(service_record_item_t) + de_get_len((uint8_t*) &service_record_item->service_record)));
    sdp_register_service_internal(NULL, service_record_item);
    
    // set one-shot timer
    timer_source_t heartbeat;
    heartbeat.process = &heartbeat_handler;
    run_loop_set_timer(&heartbeat, HEARTBEAT_PERIOD_MS);
    run_loop_add_timer(&heartbeat);
    
    
    puts("SPP FlowControl Demo: simulates processing on received data...\n\r");

    // ready - enable irq used in h4 task
    __enable_interrupt();   

 	// turn on!
	hci_power_control(HCI_POWER_ON);

    // go!
    run_loop_execute();	
    
    // happy compiler!
    return 0;
}
Beispiel #7
0
// main
int main(void)
{
    // stop watchdog timer
    WDTCTL = WDTPW + WDTHOLD;

    //Initialize clock and peripherals
    halBoardInit();
    halBoardStartXT1();
    halBoardSetSystemClock(SYSCLK_16MHZ);

    // init debug UART
    halUsbInit();

    // init LEDs
    P1OUT |= LED_1 | LED_2;
    P1DIR |= LED_1 | LED_2;

    /*//init linkLED
    P1OUT &= ~BIT0;
    P1DIR |= BIT0;*/

    //Setup Input Port 2
    initSwitch(2, BIT0);
    initSwitch(2, BIT1);
    initSwitch(2, BIT2);
    initSwitch(2, BIT3);

    //tie port3 and unused pins of port 2
    /*P3OUT = 0;
    P3DIR = 0xFF;
    P3SEL = 0;
    P2OUT &= 0x0F;
    P2DIR |= 0xF0;
    P2SEL &= 0x0F;*/


	/// GET STARTED with BTstack ///
	btstack_memory_init();
    run_loop_init(RUN_LOOP_EMBEDDED);

    // add gpio port 2 to run loop
    // default values
    port2_status = P2IN & 0x0F;

    data_source_t data_src_port2;
    data_src_port2.process = port2_poll;
    data_src_port2.fd = 0;
    run_loop_add_data_source(&data_src_port2);


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

    // use eHCILL
    bt_control_cc256x_enable_ehcill(1);

    // init L2CAP
    l2cap_init();
    l2cap_register_packet_handler(bt_packet_handler);
    l2cap_register_service_internal(NULL, l2cap_packet_handler, 0x1001, L2CAP_MINIMAL_MTU);

    // ready - enable irq used in h4 task
    __enable_interrupt();

 	// turn on!
	if(hci_power_control(HCI_POWER_ON))
		printf("power on failed");

	//init i2c
	initi2c();

    // go!
    run_loop_execute();

    // happy compiler!
    return 0;
}