/************************************************************************************************ * Include * ************************************************************************************************/ #include "ble_core.h" #include "hal_systick.h" #include "hal_uart.h" #include "stm32f4xx_gpio.h" #include /************************************************************************************************ * Config * ************************************************************************************************/ /************************************************************************************************ * Data structs * ************************************************************************************************/ void ble_init(void) { RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); GPIO_InitTypeDef GPIO_StructInit; GPIO_StructInit.GPIO_Mode = GPIO_Mode_OUT; GPIO_StructInit.GPIO_OType = GPIO_OType_PP; GPIO_StructInit.GPIO_Speed = GPIO_Speed_100MHz; GPIO_StructInit.GPIO_PuPd = GPIO_PuPd_UP; GPIO_StructInit.GPIO_Pin = BT_RST_PIN; GPIO_Init(BT_RST_PORT, &GPIO_StructInit); GPIO_ResetBits(BT_RST_PORT, BT_RST_PIN); ms_delay(1); GPIO_SetBits(BT_RST_PORT, BT_RST_PIN); GPIO_StructInit.GPIO_Mode = GPIO_Mode_IN; GPIO_StructInit.GPIO_OType = GPIO_OType_PP; GPIO_StructInit.GPIO_Speed = GPIO_Speed_100MHz; GPIO_StructInit.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_StructInit.GPIO_Pin = BT_BUSY_IND_PIN; GPIO_Init(BT_BUSY_IND_PORT, &GPIO_StructInit); GPIO_StructInit.GPIO_Mode = GPIO_Mode_IN; GPIO_StructInit.GPIO_OType = GPIO_OType_PP; GPIO_StructInit.GPIO_Speed = GPIO_Speed_100MHz; GPIO_StructInit.GPIO_PuPd = GPIO_PuPd_UP; GPIO_StructInit.GPIO_Pin = BT_CONN_IND_PIN; GPIO_Init(BT_CONN_IND_PORT, &GPIO_StructInit); } uint8_t conn_sta = 0; uint8_t busy_sta = 0; void ble_send(void) { conn_sta = GPIO_ReadInputDataBit(BT_CONN_IND_PORT, BT_CONN_IND_PIN); busy_sta = GPIO_ReadInputDataBit(BT_BUSY_IND_PORT, BT_BUSY_IND_PIN); uint8_t a[5] = {0}; a[0] = 0x01; a[1] = 0xFC; a[2] = 0x00; a[3] = 0x01; a[4] = 0x01; usart_send_it(&usart2_context, a, 5); } /************************************************************************************************ * implements * ************************************************************************************************/