標(biāo)題:
STM32單片機(jī)串口代碼移植 HC-05藍(lán)牙模塊收發(fā)程序
[打印本頁]
作者:
二貨道士
時(shí)間:
2020-12-6 20:42
標(biāo)題:
STM32單片機(jī)串口代碼移植 HC-05藍(lán)牙模塊收發(fā)程序
單片機(jī)源程序如下:
#include "led.h"
#include "delay.h"
#include "key.h"
#include "sys.h"
#include "usart.h"
#include "exti.h"
#include "oled.h"
#include "mpu6050.h"
#include "inv_mpu.h"
#include "inv_mpu_dmp_motion_driver.h"
#include "bmp.h"
#include "timer.h"
// OLED_ShowPicture(32,0,96,4,BMP_go);
// OLED_ShowPicture(32,4,96,8,BMP_back);
//
// OLED_ShowPicture(0,0,32,8,BMP_left);
// OLED_ShowPicture(96,0,128,8,BMP_right);
float i=0,pitch=0,roll=0,yaw=0; //滾,仰,偏
int main(void)
{
delay_init(); //延時(shí)函數(shù)初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //設(shè)置NVIC中斷分組2:2位搶占優(yōu)先級(jí),2位響應(yīng)優(yōu)先級(jí)
uart_init(115200); //串口初始化為
LED_Init(); //LED端口初始化
EXTIX_KEY_Init();
MPU_Init();
OLED_Init();
while(mpu_dmp_init())
{
delay_ms(10);
}
while(1)
{
delay_ms(2);
if(mpu_dmp_get_data(&pitch,&roll,&yaw)==0)
{
LED=~LED;
}
if(pitch > 15 ) //右
{
OLED_ShowPicture(96,0,128,8,BMP_right);
USART_SendData(USART1, 4 );
}
else if(pitch < -15 ) //左
{
OLED_ShowPicture(0,0,32,8,BMP_left);
USART_SendData(USART1, 3 );
}
else if(roll < -15 ) //go
{
OLED_ShowPicture(32,0,96,4,BMP_go);
USART_SendData(USART1, 1 );
}
else if(roll > 15 ) //back
{
OLED_ShowPicture(32,4,96,8,BMP_back);
USART_SendData(USART1, 2 );
}
else
{
OLED_Clear();
USART_SendData(USART1, 5 );
}
}
}
復(fù)制代碼
全部資料51hei下載地址:
單片機(jī)串口代碼移植.7z
(261.71 KB, 下載次數(shù): 40)
2020-12-6 23:21 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1