void hc05_init() { // Configure GPIO qk_gpio_set_mode(BT_MODE, QK_GPIO_MODE_OUTPUT); qk_gpio_set_mode(BT_RST, QK_GPIO_MODE_OUTPUT); qk_gpio_set_mode(COMM_TX, QK_GPIO_MODE_OUTPUT); qk_gpio_set_mode(COMM_RX, QK_GPIO_MODE_INPUT); // Enable UART qk_uart_enable(COMM_UART_ID); //qk_gpio_set_pin(BT_MODE, HIGH); //qk_gpio_set_pin(BT_RST, HIGH) // Reset with MODE=1 qk_gpio_set_pin(BT_MODE, HIGH); qk_gpio_set_pin(BT_RST, LOW); delay_ms(50); qk_gpio_set_pin(BT_RST, HIGH); delay_ms(80); // Configure serial port parameters (38400, 1 stop bit, no parity) //qk_uart_write(QK_UART_1, "AT+UART=38400,1,0\r\n", 19); //delay_ms(200); // Reset with MODE=0 qk_gpio_set_pin(BT_MODE, LOW); qk_gpio_set_pin(BT_RST, LOW); delay_ms(50); qk_gpio_set_pin(BT_RST, HIGH); delay_ms(80); }
void qk_setup() { qk_board_set_name("Bluetooth 2.0"); qk_core_register_callback(QK_CORE_CALLBACK_APP, core_callback_app); qk_protocol_register_callback(qk_protocol_comm, QK_PROTOCOL_CALLBACK_SENDBYTES, protocol_callback_send_bytes); qk_peripheral_setup(); qk_gpio_set_mode(QK_GPIO_PC0, QK_GPIO_MODE_INPUT); qk_gpio_set_mode(QK_GPIO_PC1, QK_GPIO_MODE_OUTPUT); qk_uart_set_baudrate(QK_UART_1, 38400); qk_uart_enable(QK_UART_1, true); // qk_protocol_comm->callback.send_packet = comm_send_packet; // qk_protocol_comm->callback.process_packet = comm_process_packet; // qk_comm_set_callback(QK_COMM_CALLBACK_SENDPACKET, comm_send_packet); // qk_comm_set_callback(QK_COMM_CALLBACK_PROCESSRXPACKET, comm_process_rx_packet); // _hal_uart2.rx_callback = bluetooth_spp_processRxByte; }