void setup(void){ /// GET STARTED with BTstack /// btstack_memory_init(); run_loop_init(RUN_LOOP_POSIX); // use logger: format HCI_DUMP_PACKETLOGGER, HCI_DUMP_BLUEZ or HCI_DUMP_STDOUT hci_dump_open("/tmp/gatt_browser.pklg", HCI_DUMP_PACKETLOGGER); // init HCI remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory; bt_control_t * control = NULL; #ifndef HAVE_UART_CC2564 hci_transport_t * transport = hci_transport_usb_instance(); #else hci_transport_t * transport = hci_transport_h4_instance(); control = bt_control_cc256x_instance(); // config.device_name = "/dev/tty.usbserial-A600eIDu"; // 5438 config.device_name = "/dev/tty.usbserial-A800cGd0"; // 5529 config.baudrate_init = 115200; config.baudrate_main = 0; config.flowcontrol = 1; #endif hci_init(transport, &config, control, remote_db); l2cap_init(); l2cap_register_packet_handler(&handle_hci_event); gatt_client_init(); gatt_client_register_packet_handler(&handle_gatt_client_event); sm_init(); sm_set_io_capabilities(IO_CAPABILITY_NO_INPUT_NO_OUTPUT); }
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; }
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 }
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; }
void setup(void){ /// GET STARTED with BTstack /// btstack_memory_init(); run_loop_init(RUN_LOOP_POSIX); // use logger: format HCI_DUMP_PACKETLOGGER, HCI_DUMP_BLUEZ or HCI_DUMP_STDOUT hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER); // init HCI #ifdef HAVE_UART_CSR hci_transport_t * transport = hci_transport_h4_instance(); hci_uart_config_t * config = &hci_uart_config; bt_control_t * control = bt_control_csr_instance(); #elif defined(HAVE_UART_CC256x) hci_transport_t * transport = hci_transport_h4_instance(); hci_uart_config_t * config = &hci_uart_config; bt_control_t * control = bt_control_cc256x_instance(); #else hci_transport_t * transport = hci_transport_usb_instance(); hci_uart_config_t * config = NULL; bt_control_t * control = NULL; #endif remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory; hci_init(transport, config, control, remote_db); // set up l2cap_le l2cap_init(); // setup central device db central_device_db_init(); // setup SM: Display only sm_init(); sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_ONLY); sm_set_authentication_requirements( SM_AUTHREQ_BONDING | SM_AUTHREQ_MITM_PROTECTION); // setup ATT server att_server_init(profile_data, att_read_callback, att_write_callback); att_write_queue_init(); att_attributes_init(); att_server_register_packet_handler(app_packet_handler); att_dump_attributes(); }
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); }
// 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; }
// 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; }