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(); //延时函数初始化
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
- 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频率计数
- 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); //等待蓝牙模块上电稳定
- 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, 下载次数: 136)
|