stm32藍牙hc05的使用
單片機源程序如下:
- #include "led.h"
- #include "delay.h"
- #include "key.h"
- #include "pwm.h"
- #include "input.h"
- #include "adc.h"
- #include "sys.h"
- #include "lcd.h"
- #include "usart.h"
- #include "hc05.h"
- #include "usart3.h"
- #include "string.h"
- #include "usmart.h"
- #include "MsgCommun.h"
- #include "CMcontrol.h"
- int main(void)
- {
- delay_init(); //延時函數(shù)初始化
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //設置NVIC中斷分組2:2位搶占優(yōu)先級,2位響應優(yōu)先級
- uart_init(115200); //串口初始化為115200
- LED_Init(); //初始化與LED連接的硬件接口
- ADCx_Init();
- TIM3_CH1_PWM_Init(500,2840);//2khz
- KEY_Init(); //初始化按鍵
- LCD_Init(); //初始化LCD
- TIM5_CH1_Input_Init(0xffff,71); //以1M頻率計數(shù)
- usmart_dev.init(72); //初始化USMART
-
- POINT_COLOR=RED;
- LCD_ShowString(30,30,200,16,16,"ALIENTEK STM32F1 ^_^");
- LCD_ShowString(30,50,200,16,16,"HC05 BLUETOOTH COM TEST");
- LCD_ShowString(30,70,200,16,16,"ATOM@ALIENTEK");
- delay_ms(1000); //等待藍牙模塊上電穩(wěn)定
- HC05_Init(); //初始化ATK-HC05模塊
-
- LCD_ShowString(30,90,210,16,16,"KEY1:ROLE KEY0:SEND/STOP");
- LCD_ShowString(30,110,200,16,16,"ATK-HC05 Standby!");
- LCD_ShowString(30,160,200,16,16,"Send:");
- LCD_ShowString(30,180,200,16,16,"Receive:");
- POINT_COLOR=BLUE;
- HC05_Role_Show();
- delay_ms(100);
- USART3_RX_STA=0;
- while(1)
- {
- MsgControlLoop();
- CMcontrolLoop();
- }
- }
復制代碼
所有資料51hei提供下載:
藍牙可用.rar
(400.15 KB, 下載次數(shù): 136)
2018-11-11 00:34 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|