新手上路
- 积分
- 33
- 金钱
- 33
- 注册时间
- 2016-5-1
- 在线时间
- 4 小时
|
发表于 2016-5-18 15:49:08
|
显示全部楼层
[mw_shl_code=c,true]void TTSPlay_1(void)
{
u8 SoundBuf[12]={0xFD, 0x00, 0x07, 0x01, 0x01, 0xC4, 0xE3, 0xBA, 0xC3, 0x0D, 0x0A, 0xAD };
u8 i,xorcrc=0;
for (i=0;i<12;i++)
{
xorcrc= xorcrc ^ (SoundBuf);
USART_Send_Byte(SoundBuf);
}
USART_Send_Byte(xorcrc);
}
/***************************
′®¿úÅäÖÃoˉêy
***************************/
void USART_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO, ENABLE);
// RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; //TX
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; //RX
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART2, &USART_InitStructure);
USART_Cmd(USART2, ENABLE);
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);//¿aÆô′®¿ú½óêüÖD¶Ï
USART_ClearFlag(USART2, USART_FLAG_TC);
}
/***************************************************************************
2ÎêyËμÃ÷:mydata′y·¢ËíμÄêy¾Y
·μ»ØËμÃ÷:ÎT
***************************************************************************/
void USART_Send_Byte(u8 mydata)
{
USART_ClearFlag(USART2,USART_FLAG_TC);
USART_SendData(USART2,mydata);
LCD_ShowxNum_color(80,40,mydata,16,16,0,BLACK);
while(USART_GetFlagStatus(USART2,USART_FLAG_TC)==RESET);
USART_ClearFlag(USART2,USART_FLAG_TC);
}
[/mw_shl_code] |
|