初级会员
- 积分
- 141
- 金钱
- 141
- 注册时间
- 2013-8-19
- 在线时间
- 0 小时
|
楼主 |
发表于 2013-10-1 17:43:11
|
显示全部楼层
回复【11楼】xiaoyan:
---------------------------------
蓝牙范例确定可以执行跟变成connect....,底下是完整的程序:
#include "includes.h"
void HC05_Sta_Show(void)
{
if(HC05_LED)LCD_ShowString(30,110,"STA:Connected ");
else LCD_ShowString(30,110,"STAisconnect");
}
int main(void)
{
u8 i,t;
u8 sendmask;
u8 sendcnt=0;
u8 sendbuf[20];
u8 reclen=0;
Stm32_Clock_Init(9);//系统时钟设置
delay_init(72); //延时初始化
uart_init(72,9600); //串口1初始化
LCD_Init(); //初始化液晶
KEY_Init(); //按键扫描初始化
LED_Init(); //LED初始化
SPI_Flash_Init(); //SPI FLASH初始化
usmart_dev.init(72);
POINT_COLOR=RED;
LCD_ShowString(60,70,"Font checking...");
//字体更新
if(Font_Init())//字库不存在,则更新字库
{
POINT_COLOR=RED;
LCD_Clear(WHITE);
LCD_ShowString(60,50,"Mini STM32");
LCD_ShowString(60,60,"Font Updating...");
//字体更新
SD_Initialize(); //初始化SD卡
while(FAT_Init())//FAT 错误
{
LCD_ShowString(60,90,"FAT SYS ERROR");
i= SD_Initialize();
if(i)//SD卡初始化
{
LCD_ShowString(60,110,"SD_CARD ERROR");
}
delay_ms(500);
LCD_Fill(60,130,240,126,WHITE);//清除显示
delay_ms(500);
LED0=!LED0;
}
LCD_Fill(60,130,240,126,WHITE);//清除显示
while(Update_Font()!=0)//字体更新出错
{
LCD_ShowString(60,90,"SYSTEM FILE LOST");
delay_ms(500);
LCD_ShowString(60,90,"lease Check !");
delay_ms(500);
LED0=!LED0;
};
LCD_Clear(WHITE);
}
LCD_Clear(WHITE);
Show_Str(30,30,"STM32 BT & MP3 TEST",16,0);
POINT_COLOR=BLUE;
while(HC05_Init()) //蓝牙初始化
{
LCD_ShowString(30,70,"ATK-HC05 Error!");
delay_ms(500);
LCD_ShowString(30,70,"lease Check!!!");
delay_ms(100);
}
LCD_ShowString(30,70,"BlueTooth Standby!");
if (HC05_Get_Role()!=1){
LCD_ShowString(30,90,"ROLE:Slave");
while(1){
if(t==50)
{
if(sendmask)
{
sprintf((char*)sendbuf,"ALIENTEK HC05 %d\r\n",sendcnt);
u2_printf("ALIENTEK HC05 %d\r\n",sendcnt);
sendcnt++;
if(sendcnt>99)
{
sendcnt=0;
}
}
t=0;
}
t++;
break;
}
HC05_Sta_Show();
}
SD_Initialize(); //初始化SD卡
while(FAT_Init()) //FAT 错误
{
LCD_ShowString(60,90,"FAT SYS ERROR");
i= SD_Initialize();
if(i) //SD卡初始化
{
LCD_ShowString(60,110,"SD_CARD ERROR");
}
delay_ms(500);
LCD_Fill(60,130,240,126,WHITE); //清除显示
delay_ms(500);
LED0=!LED0;
}
POINT_COLOR=RED;
VS_Init();
while(1)
{
Show_Str(60,130,"存储器测试...",16,0);
LED0=0;
VS_Ram_Test();
Show_Str(60,130,"正弦波测试...",16,0);
LED1=0;
VS_Sine_Test();
Show_Str(60,90,"<<MP3播放器>>",16,0);
Play_Music();
}
} |
|