想要实现的功能是电脑通过串口2给开发板发送数据,然后开发板将收到的数据通过串口1发送给语音合成芯片进行语音合成,
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "beep.h"
#include "key.h"
//ALIENTEK ì½Ë÷ÕßSTM32F407¿a·¢°å êμÑé4
//′®¿úí¨DÅêμÑé -¿aoˉêy°æ±¾
//¼¼êõÖ§3Ö£o
www.openedv.com
//ìÔ±|μêÆì£o
http://eboard.taobao.com
//1ãÖYêDDÇòíμç×ó¿Æ¼¼óDÏT1«Ë¾
//×÷ÕߣoÕyμãÔ-×ó @ALIENTEK
/**************D¾Æ¬éèÖÃÃüáî*********************/
uint8_t XFS_StopCom[]={0xFD,0X00,0X01,0X02};//í£Ö1oÏ3é
uint8_t XFS_SuspendCom[]={0XFD,0X00,0X01,0X03};//ÔYí£oÏ3é
uint8_t XFS_RecoverCom[]={0XFD,0X00,0X01,0X04};//»Ö¸′oÏ3é
uint8_t XFS_ChackCom[]={0XFD,0X00,0X01,0X21};//×′ì¬2éÑˉ
uint8_t XFS_PowerDownCom[]={0XFD,0X00,0X01,0X88};//½øèë
OWER DOWN ×′ì¬Ãüáî
/***********************************************/
void PrintCom(u8 *buffer,unsigned int len)
{
int i = 0;
for(i=0;i<len;i++)
{
USART_SendData(USART1,USART_ReceiveData(USART2) ); //Ïò′®¿ú1·¢Ëíêy¾Y
while(USART_GetFlagStatus(USART1,USART_FLAG_TC)!=SET);//μè′y·¢Ëí½áêø
}
}
void XFS_FrameInfo(uint8_t *HZdata)
{
/****************Dèòa·¢ËíμÄÎı¾**********************************/
unsigned char Frame_Info[50]; //¶¨òåμÄÎı¾3¤¶è
unsigned int HZ_Length;
unsigned int i=0;
HZ_Length =strlen(HZdata); //Dèòa·¢ËíÎı¾μÄ3¤¶è
/*****************Ö¡1춨ÅäÖÃDÅÏ¢**************************************/
Frame_Info[0] = 0xFD ; //11ÔìÖ¡í·FD
Frame_Info[1] = 0x00 ; //11Ôìêy¾YÇø3¤¶èμĸß×Ö½ú
Frame_Info[2] = HZ_Length+2; //11Ôìêy¾YÇø3¤¶èμÄμí×Ö½ú
Frame_Info[3] = 0x01 ; //11ÔìÃüáî×Ö£ooÏ3é2¥·ÅÃüáî
Frame_Info[4] = 0x01; //Îı¾±àÂë¸ñê½£oGBK
/*******************·¢ËíÖ¡DÅÏ¢***************************************/
memcpy(&Frame_Info[5], HZdata, HZ_Length);
PrintCom(Frame_Info,5+HZ_Length); //·¢ËíÖ¡ÅäÖÃ
}
int sendflag = 0;
int sendflag1= 0;
int sendflag2= 0;
int main(void)
{
u16 t;
u16 rx;
u8 len;
u16 times=0;
//USART_SendData(USART2, USART2_RX_BUF[t]); //Ïò′®¿ú2·¢Ëíêy¾Y
USART_ReceiveData(USART2); //Ïò′®¿ú2·¢Ëíêy¾Y
//while(USART_GetFlagStatus(USART2,USART_FLAG_TC)!=SET);//μè′y·¢Ëí½áêø
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//éèÖÃÏμí3ÖD¶ÏóÅÏ輶·Ö×é2
delay_init(168); //Ñóê±3õê¼»ˉ
uart_init(9600); //′®¿ú3õê¼»ˉ2¨ìØÂêÎa115200
LED_Init(); //3õê¼»ˉóëLEDᬽóμÄó2¼t½ó¿ú
while(1)
{
XFS_FrameInfo("[v1][m3]·¢Ëí");
delay_ms(1000);
if(QueueMemDataDel(&rx)==0)
{
if(rx == 0x41)
{
sendflag = 1;
}
}
if(sendflag == 1)
{
XFS_FrameInfo("[v1][m54]·¢Ëí");
//XFS_FrameInfo("[m55][v1]ÄãoÃÄãoÃ");
if(times%300==0)LED0=!LED0;//éá˸LED,ìáê¾Ïμí3ÕyÔúÔËDD.
}
delay_ms(1000);
}
}
一周热门 更多>