如题,问题是串口5不通了,指纹程序,本来用的是串口2,但是串口2一个io是以太网的控制脚,另一个复用也用不了,所以就改为串口5,只有串口5不占用别的脚,改完之后指纹模块初始化就不通了, 所以问题就是串口5不通,求各位坛友相助。[mw_shl_code=c,true]
UART_HandleTypeDef UART5_Handler;//UART¾ä±ú
//3õê¼»ˉIO ′®¿ú2
//bound:2¨ìØÂê
void uart5_init(u32 bound)
{
GPIO_InitTypeDef GPIO_Initure;
__HAL_RCC_GPIOD_CLK_ENABLE(); //ê1ÄüGPIOcê±Öó
__HAL_RCC_GPIOC_CLK_ENABLE(); //ê1ÄüGPIOdê±Öó
__HAL_RCC_UART5_CLK_ENABLE(); //ê1ÄüUSART5ê±Öó
//GPIO¶Ë¿úéèÖÃ
GPIO_Initure.Pin=GPIO_PIN_12;
GPIO_Initure.Mode=GPIO_MODE_AF_PP;//¸′óÃíÆíìêä3ö
GPIO_Initure.Pull=GPIO_PULLUP; //éÏà-
GPIO_Initure.Speed=GPIO_SPEED_FAST;//¸ßËù
GPIO_Initure.Alternate=GPIO_AF7_UART5; //¸′óÃÎaUSART5
HAL_GPIO_Init(GPIOC,&GPIO_Initure);
GPIO_Initure.Pin=GPIO_PIN_2;
GPIO_Initure.Mode=GPIO_MODE_AF_PP;//¸′óÃíÆíìêä3ö
GPIO_Initure.Pull=GPIO_PULLUP; //éÏà-
GPIO_Initure.Speed=GPIO_SPEED_FAST;//¸ßËù
GPIO_Initure.Alternate=GPIO_AF7_UART5; //¸′óÃÎaUSART5
HAL_GPIO_Init(GPIOD,&GPIO_Initure);
//UART 3õê¼»ˉéèÖÃ
UART5_Handler.Instance=UART5; //USART5
UART5_Handler.Init.BaudRate=bound; //2¨ìØÂê
UART5_Handler.Init.WordLength=UART_WORDLENGTH_8B; //×Ö3¤Îa8λêy¾Y¸ñê½
UART5_Handler.Init.StopBits=UART_STOPBITS_1; //ò»¸öí£Ö1λ
UART5_Handler.Init.Parity=UART_PARITY_NONE; //ÎTÆæżD£Ñéλ
UART5_Handler.Init.HwFlowCtl=UART_HWCONTROL_NONE; //ÎTó2¼tá÷¿Ø
UART5_Handler.Init.Mode=UART_MODE_TX_RX; //êÕ·¢Ä£ê½
HAL_UART_Init(&UART5_Handler); //ê1Äü
__HAL_UART_ENABLE_IT(&UART5_Handler,UART_IT_RXNE);//¿aÆô½óêÕÖD¶Ï
HAL_NVIC_EnableIRQ(UART5_IRQn); //ê1ÄüUART5ÖD¶Ïí¨μà
HAL_NVIC_SetPriority(UART5_IRQn,1,0); //ÇàÕ¼óÅÏ輶1£¬×óóÅÏ輶0
TIM7_Init(100-1,9000-1); //10msÖD¶Ï
__HAL_TIM_DISABLE(&TIM7_Handler);//1رն¨ê±Æ÷7
UART5_RX_STA=0; //Çåáã
}
//′®¿ú·¢Ëí»o′æÇø
__align(8) u8 UART5_TX_BUF[UART5_MAX_SEND_LEN]; //·¢Ëí»o3å,×î′óUSART2_MAX_SEND_LEN×Ö½ú
#ifdef UART5_RX_EN //èç1ûê1Äüá˽óêÕ
//′®¿ú½óêÕ»o′æÇø
u8 UART5_RX_BUF[UART5_MAX_RECV_LEN]; //½óêÕ»o3å,×î′óUSART2_MAX_RECV_LEN¸ö×Ö½ú.
//í¨1yÅD¶Ï½óêÕá¬Dø2¸ö×Ö·ûÖ®¼äμÄê±¼ä2î2»′óóú100msà′¾ö¶¨êÇ2»êÇò»′Îá¬DøμÄêy¾Y.
//èç1û2¸ö×Ö·û½óêÕ¼ä¸ô3¬1y100ms,ÔòèÏÎa2»êÇ1′Îá¬Døêy¾Y.ò2¾íêÇ3¬1y100msûóD½óêÕμ½
//èÎoÎêy¾Y,Ôò±íê¾′Ë′νóêÕíê±Ï.
//½óêÕμ½μÄêy¾Y×′ì¬
//[15]:0,ûóD½óêÕμ½êy¾Y;1,½óêÕμ½áËò»Åúêy¾Y.
//[14:0]:½óêÕμ½μÄêy¾Y3¤¶è
u16 UART5_RX_STA=0;
void UART5_IRQHandler(void)
{
u8 Res;
if((__HAL_UART_GET_FLAG(&UART5_Handler,UART_FLAG_RXNE)!=RESET))//½óêÕμ½êy¾Y
{
HAL_UART_Receive(&UART5_Handler,&Res,1,1000);
if((UART5_RX_STA&0x8000)==0)//½óêÕíêμÄò»Åúêy¾Y,»1ûóD±»′|àí,Ôò2»Ôù½óêÕÆäËûêy¾Y
{
if(UART5_RX_STA<UART5_MAX_RECV_LEN) //»1¿éòÔ½óêÕêy¾Y
{
__HAL_TIM_SET_COUNTER(&TIM7_Handler,0);//¼ÆêyÆ÷Çå¿Õ
if(UART5_RX_STA==0)
__HAL_TIM_ENABLE(&TIM7_Handler); //ê1Äü¶¨ê±Æ÷7
UART5_RX_BUF[UART5_RX_STA++]=Res; //¼Ç¼½óêÕμ½μÄÖμ
}else
{
UART5_RX_STA|=1<<15; //Ç¿ÖƱê¼Ç½óêÕíê3é
}
}
}
}
//′®¿ú2,printf oˉêy
//è·±£ò»′η¢Ëíêy¾Y2»3¬1yUSART2_MAX_SEND_LEN×Ö½ú
void u5_printf(char* fmt,...)
{
u16 i,j;
va_list ap;
va_start(ap,fmt);
vsprintf((char*)UART5_TX_BUF,fmt,ap);
va_end(ap);
i=strlen((const char*)UART5_TX_BUF);//′Ë′η¢Ëíêy¾YμÄ3¤¶è
for(j=0;j<i;j++)//Ñ-»··¢Ëíêy¾Y
{
while((UART5->ISR&0X40)==0);//Ñ-»··¢Ëí,Ö±μ½·¢Ëííê±Ï
UART5->TDR=UART5_TX_BUF[j];
}
}
#endif
[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
这一段是as608指纹模块的代码,usart2的部分均已改为uart5,不知道这个hal库版本的修改串口还要改哪里文件,主函数的调用也改啦[mw_shl_code=c,true]#include <string.h>
[mw_shl_code=c,true]#include <string.h>
#include <stdio.h>
#include "delay.h"
#include "usart2.h"
#include "as608.h"
u32 AS608Addr = 0XFFFFFFFF; //ĬèÏ
//3õê¼»ˉPA6ÎaÏÂà-êäèë
//¶áÃt3ö¸Dó|×′ì¬(′¥Ãt¸Dó|ê±êä3ö¸ßμçƽDÅoÅ)
void PS_StaGPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
__HAL_RCC_GPIOC_CLK_ENABLE();
//3õê¼»ˉ¶á×′ì¬òy½ÅGPIOA
GPIO_InitStructure.Pin = GPIO_PIN_10;
GPIO_InitStructure.Mode = GPIO_MODE_INPUT; //êäèëÄ£ê½
GPIO_InitStructure.Pull = GPIO_PULLDOWN; //ÏÂà-Ä£ê½
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;//¸ßËùÄ£ê½
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure); //3õê¼»ˉGPIO
}
//′®¿ú·¢Ëíò»¸ö×Ö½ú
static void MYUSART_SendData(u8 data)
{
while((UART5->ISR&0X40)==0);
UART5->TDR = data;
}
//·¢Ëí°üí·
static void SendHead(void)
{
MYUSART_SendData(0xEF);
MYUSART_SendData(0x01);
}
//·¢ËíμØÖ·
static void SendAddr(void)
{
MYUSART_SendData(AS608Addr>>24);
MYUSART_SendData(AS608Addr>>16);
MYUSART_SendData(AS608Addr>>8);
MYUSART_SendData(AS608Addr);
}
//·¢Ëí°ü±êê¶,
static void SendFlag(u8 flag)
{
MYUSART_SendData(flag);
}
//·¢Ëí°ü3¤¶è
static void SendLength(int length)
{
MYUSART_SendData(length>>8);
MYUSART_SendData(length);
}
//·¢ËíÖ¸áîÂë
static void Sendcmd(u8 cmd)
{
MYUSART_SendData(cmd);
}
//·¢ËíD£Ñéoí
static void SendCheck(u16 check)
{
MYUSART_SendData(check>>8);
MYUSART_SendData(check);
}
//ÅD¶ÏÖD¶Ï½óêÕμÄêy×éóDûóDó|′e°ü
//waittimeÎaμè′yÖD¶Ï½óêÕêy¾YμÄ걼䣨μ¥λ1ms£©
//·μ»ØÖμ£oêy¾Y°üê×μØÖ·
static u8 *JudgeStr(u16 waittime)
{
char *data;
u8 str[8];
str[0]=0xef; str[1]=0x01;
str[2]=AS608Addr>>24; str[3]=AS608Addr>>16;
str[4]=AS608Addr>>8; str[5]=AS608Addr;
str[6]=0x07; str[7]=' ';
while(--waittime)
{
delay_ms(1);
if(UART5_RX_STA&0X8000)//½óêÕμ½ò»′Îêy¾Y
{
UART5_RX_STA=0;
data=strstr((const char*)UART5_RX_BUF,(const char*)str);
if(data)
return (u8*)data;
}
}
return 0;
}
//¼èëí¼Ïñ PS_GetImage
//1|Äü:ì½2aêÖÖ¸£¬ì½2aμ½oó¼èëÖ¸ÎÆí¼Ïñ′æóúImageBuffer¡£
//Ä£¿é·μ»Øè·èÏ×Ö
u8 PS_GetImage(void)
{
u16 temp;
u8 ensure;
u8 *data;
SendHead();
SendAddr();
SendFlag(0x01);//Ãüáî°ü±êê¶
SendLength(0x03);
Sendcmd(0x01);
temp = 0x01+0x03+0x01;
SendCheck(temp);
data=JudgeStr(2000);
if(data)
ensure=data[9];
else
ensure=0xff;
return ensure;
}
//éú3éìØÕ÷ PS_GenChar
//1|Äü:½«ImageBufferÖDμÄÔ-ê¼í¼Ïñéú3éÖ¸ÎÆìØÕ÷Îļt′æóúCharBuffer1»òCharBuffer2
//2Îêy:BufferID --> charBuffer1:0x01 charBuffer1:0x02
//Ä£¿é·μ»Øè·èÏ×Ö
u8 PS_GenChar(u8 BufferID)
{
u16 temp;
u8 ensure;
u8 *data;
SendHead();
SendAddr();
SendFlag(0x01);//Ãüáî°ü±êê¶
SendLength(0x04);
Sendcmd(0x02);
MYUSART_SendData(BufferID);
temp = 0x01+0x04+0x02+BufferID;
SendCheck(temp);
data=JudgeStr(2000);
if(data)
ensure=data[9];
else
ensure=0xff;
return ensure;
}
//¾«è·±è¶Ôá½Ã¶Ö¸ÎÆìØÕ÷ PS_Match
//1|Äü:¾«è·±è¶ÔCharBuffer1 óëCharBuffer2 ÖDμÄìØÕ÷Îļt
//Ä£¿é·μ»Øè·èÏ×Ö
u8 PS_Match(void)
{
u16 temp;
u8 ensure;
u8 *data;
SendHead();
SendAddr();
SendFlag(0x01);//Ãüáî°ü±êê¶
SendLength(0x03);
Sendcmd(0x03);
temp = 0x01+0x03+0x03;
SendCheck(temp);
data=JudgeStr(2000);
if(data)
ensure=data[9];
else
ensure=0xff;
return ensure;
}
//ËÑË÷Ö¸ÎÆ PS_Search
//1|Äü:òÔCharBuffer1»òCharBuffer2ÖDμÄìØÕ÷ÎļtËÑË÷Õû¸ö»ò2¿·ÖÖ¸ÎÆ¿a.èôËÑË÷μ½£¬Ôò·μ»Øò3Âë¡£
//2Îêy: BufferID @ref CharBuffer1 CharBuffer2
//ËμÃ÷: Ä£¿é·μ»Øè·èÏ×Ö£¬ò3Â루ÏàÅäÖ¸ÎÆÄ£°å£©
u8 PS_Search(u8 BufferID,u16 StartPage,u16 PageNum,SearchResult *p)
{
u16 temp;
u8 ensure;
u8 *data;
SendHead();
SendAddr();
SendFlag(0x01);//Ãüáî°ü±êê¶
SendLength(0x08);
Sendcmd(0x04);
MYUSART_SendData(BufferID);
MYUSART_SendData(StartPage>>8);
MYUSART_SendData(StartPage);
MYUSART_SendData(PageNum>>8);
MYUSART_SendData(PageNum);
temp = 0x01+0x08+0x04+BufferID
+(StartPage>>8)+(u8)StartPage
+(PageNum>>8)+(u8)PageNum;
SendCheck(temp);
data=JudgeStr(2000);
if(data)
{
ensure = data[9];
p->pageID =(data[10]<<8)+data[11];
p->mathscore=(data[12]<<8)+data[13];
}
else
ensure = 0xff;
return ensure;
}
//oÏ2¢ìØÕ÷£¨éú3éÄ£°å£©S_RegModel
//1|Äü:½«CharBuffer1óëCharBuffer2ÖDμÄìØÕ÷ÎļtoÏ2¢éú3é Ä£°å,½á1û′æóúCharBuffer1óëCharBuffer2
//ËμÃ÷: Ä£¿é·μ»Øè·èÏ×Ö
u8 PS_RegModel(void)
{
u16 temp;
u8 ensure;
u8 *data;
SendHead();
SendAddr();
SendFlag(0x01);//Ãüáî°ü±êê¶
SendLength(0x03);
Sendcmd(0x05);
temp = 0x01+0x03+0x05;
SendCheck(temp);
data=JudgeStr(2000);
if(data)
ensure=data[9];
else
ensure=0xff;
return ensure;
}
//′¢′æÄ£°å PS_StoreChar
//1|Äü:½« CharBuffer1 »ò CharBuffer2 ÖDμÄÄ£°åÎļt′æμ½ PageID oÅflashêy¾Y¿aλÖá£
//2Îêy: BufferID @ref charBuffer1:0x01 charBuffer1:0x02
// PageID£¨Ö¸ÎÆ¿aλÖÃoÅ£©
//ËμÃ÷: Ä£¿é·μ»Øè·èÏ×Ö
u8 PS_StoreChar(u8 BufferID,u16 PageID)
{
u16 temp;
u8 ensure;
u8 *data;
SendHead();
SendAddr();
SendFlag(0x01);//Ãüáî°ü±êê¶
SendLength(0x06);
Sendcmd(0x06);
MYUSART_SendData(BufferID);
MYUSART_SendData(PageID>>8);
MYUSART_SendData(PageID);
temp = 0x01+0x06+0x06+BufferID
+(PageID>>8)+(u8)PageID;
SendCheck(temp);
data=JudgeStr(2000);
if(data)
ensure=data[9];
else
ensure=0xff;
return ensure;
}
//é¾3yÄ£°å PS_DeletChar
//1|Äü: é¾3yflashêy¾Y¿aÖDÖ¸¶¨IDoÅ¿aê¼μÄN¸öÖ¸ÎÆÄ£°å
//2Îêy: PageID(Ö¸ÎÆ¿aÄ£°åoÅ)£¬Né¾3yμÄÄ£°å¸öêy¡£
//ËμÃ÷: Ä£¿é·μ»Øè·èÏ×Ö
u8 PS_DeletChar(u16 PageID,u16 N)
{
u16 temp;
u8 ensure;
u8 *data;
SendHead();
SendAddr();
SendFlag(0x01);//Ãüáî°ü±êê¶
SendLength(0x07);
Sendcmd(0x0C);
MYUSART_SendData(PageID>>8);
MYUSART_SendData(PageID);
MYUSART_SendData(N>>8);
MYUSART_SendData(N);
temp = 0x01+0x07+0x0C
+(PageID>>8)+(u8)PageID
+(N>>8)+(u8)N;
SendCheck(temp);
data=JudgeStr(2000);
if(data)
ensure=data[9];
else
ensure=0xff;
return ensure;
}
//Çå¿ÕÖ¸ÎÆ¿a PS_Empty
//1|Äü: é¾3yflashêy¾Y¿aÖDËùóDÖ¸ÎÆÄ£°å
//2Îêy: ÎT
//ËμÃ÷: Ä£¿é·μ»Øè·èÏ×Ö
u8 PS_Empty(void)
{
u16 temp;
u8 ensure;
u8 *data;
SendHead();
SendAddr();
SendFlag(0x01);//Ãüáî°ü±êê¶
SendLength(0x03);
Sendcmd(0x0D);
temp = 0x01+0x03+0x0D;
SendCheck(temp);
data=JudgeStr(2000);
if(data)
ensure=data[9];
else
ensure=0xff;
return ensure;
}
//D′Ïμí3¼Ä′æÆ÷ PS_WriteReg
//1|Äü: D′Ä£¿é¼Ä′æÆ÷
//2Îêy: ¼Ä′æÆ÷DòoÅRegNum:456
//ËμÃ÷: Ä£¿é·μ»Øè·èÏ×Ö
u8 PS_WriteReg(u8 RegNum,u8 DATA)
{
u16 temp;
u8 ensure;
u8 *data;
SendHead();
SendAddr();
SendFlag(0x01);//Ãüáî°ü±êê¶
SendLength(0x05);
Sendcmd(0x0E);
MYUSART_SendData(RegNum);
MYUSART_SendData(DATA);
temp = RegNum+DATA+0x01+0x05+0x0E;
SendCheck(temp);
data=JudgeStr(2000);
if(data)
ensure=data[9];
else
ensure=0xff;
if(ensure==0)
printf(" éèÖÃ2Îêy3é1|£¡");
else
printf(" %s",EnsureMessage(ensure));
return ensure;
}
//¶áÏμí3»ù±¾2Îêy PS_ReadSysPara
//1|Äü: ¶áè¡Ä£¿éμÄ»ù±¾2Îêy£¨2¨ìØÂ꣬°ü′óD¡μè)
//2Îêy: ÎT
//ËμÃ÷: Ä£¿é·μ»Øè·èÏ×Ö + »ù±¾2Îêy£¨16bytes£©
u8 PS_ReadSysPara(SysPara *p)
{
u16 temp;
u8 ensure;
u8 *data;
SendHead();
SendAddr();
SendFlag(0x01);//Ãüáî°ü±êê¶
SendLength(0x03);
Sendcmd(0x0F);
temp = 0x01+0x03+0x0F;
SendCheck(temp);
data=JudgeStr(1000);
if(data)
{
ensure = data[9];
p->S_max = (data[14]<<8)+data[15];
p->S_level = data[17];
p->S_addr=(data[18]<<24)+(data[19]<<16)+(data[20]<<8)+data[21];
p->S_size = data[23];
p->S_N = data[25];
}
else
ensure=0xff;
if(ensure==0x00)
{
printf(" Ä£¿é×î′óÖ¸ÎÆèYá¿=%d",p->S_max);
printf(" ¶Ô±èμ輶=%d",p->S_level);
printf(" μØÖ·=%x",p->S_addr);
printf(" 2¨ìØÂê=%d",p->S_N*9600);
}
else
printf(" %s",EnsureMessage(ensure));
return ensure;
}
//éèÖÃÄ£¿éμØÖ· PS_SetAddr
//1|Äü: éèÖÃÄ£¿éμØÖ·
//2Îêy: PS_addr
//ËμÃ÷: Ä£¿é·μ»Øè·èÏ×Ö
u8 PS_SetAddr(u32 PS_addr)
{
u16 temp;
u8 ensure;
u8 *data;
SendHead();
SendAddr();
SendFlag(0x01);//Ãüáî°ü±êê¶
SendLength(0x07);
Sendcmd(0x15);
MYUSART_SendData(PS_addr>>24);
MYUSART_SendData(PS_addr>>16);
MYUSART_SendData(PS_addr>>8);
MYUSART_SendData(PS_addr);
temp = 0x01+0x07+0x15
+(u8)(PS_addr>>24)+(u8)(PS_addr>>16)
+(u8)(PS_addr>>8) +(u8)PS_addr;
SendCheck(temp);
AS608Addr=PS_addr;//·¢ËííêÖ¸á¸ü»»μØÖ·
data=JudgeStr(2000);
if(data)
ensure=data[9];
else
ensure=0xff;
AS608Addr = PS_addr;
if(ensure==0x00)
printf(" éèÖÃμØÖ·3é1|£¡");
else
printf(" %s",EnsureMessage(ensure));
return ensure;
}
//1|Äü£o Ä£¿éÄú2¿Îaóû§¿a±ùáË256bytesμÄFLASH¿Õ¼äóÃóú′æóû§¼Çê±¾,
// ¸Ã¼Çê±¾Âß¼-éϱ»·Ö3é 16 ¸öò3¡£
//2Îêy: NotePageNum(0~15),Byte32(òaD′èëÄúèY£¬32¸ö×Ö½ú)
//ËμÃ÷: Ä£¿é·μ»Øè·èÏ×Ö
u8 PS_WriteNotepad(u8 NotePageNum,u8 *Byte32)
{
u16 temp;
u8 ensure,i;
u8 *data;
SendHead();
SendAddr();
SendFlag(0x01);//Ãüáî°ü±êê¶
SendLength(36);
Sendcmd(0x18);
MYUSART_SendData(NotePageNum);
for(i=0;i<32;i++)
{
MYUSART_SendData(Byte32);
temp += Byte32;
}
temp =0x01+36+0x18+NotePageNum+temp;
SendCheck(temp);
data=JudgeStr(2000);
if(data)
ensure=data[9];
else
ensure=0xff;
return ensure;
}
//¶á¼ÇêÂPS_ReadNotepad
//1|Äü£o ¶áè¡FLASHóû§ÇøμÄ128bytesêy¾Y
//2Îêy: NotePageNum(0~15)
//ËμÃ÷: Ä£¿é·μ»Øè·èÏ×Ö+óû§DÅÏ¢
u8 PS_ReadNotepad(u8 NotePageNum,u8 *Byte32)
{
u16 temp;
u8 ensure,i;
u8 *data;
SendHead();
SendAddr();
SendFlag(0x01);//Ãüáî°ü±êê¶
SendLength(0x04);
Sendcmd(0x19);
MYUSART_SendData(NotePageNum);
temp = 0x01+0x04+0x19+NotePageNum;
SendCheck(temp);
data=JudgeStr(2000);
if(data)
{
ensure=data[9];
for(i=0;i<32;i++)
{
Byte32=data[10+i];
}
}
else
ensure=0xff;
return ensure;
}
//¸ßËùËÑË÷PS_HighSpeedSearch
//1|Äü£oòÔ CharBuffer1»òCharBuffer2ÖDμÄìØÕ÷Îļt¸ßËùËÑË÷Õû¸ö»ò2¿·ÖÖ¸ÎÆ¿a¡£
// èôËÑË÷μ½£¬Ôò·μ»Øò3Âë,¸ÃÖ¸áî¶ÔóúμÄè·′æÔúóúÖ¸ÎÆ¿aÖD £¬ÇòμǼê±Öêá¿
// oüoÃμÄÖ¸ÎÆ£¬»áoü¿ì¸ø3öËÑË÷½á1û¡£
//2Îêy: BufferID£¬ StartPage(Æeê¼ò3)£¬PageNum£¨ò3êy£©
//ËμÃ÷: Ä£¿é·μ»Øè·èÏ×Ö+ò3Â루ÏàÅäÖ¸ÎÆÄ£°å£©
u8 PS_HighSpeedSearch(u8 BufferID,u16 StartPage,u16 PageNum,SearchResult *p)
{
u16 temp;
u8 ensure;
u8 *data;
SendHead();
SendAddr();
SendFlag(0x01);//Ãüáî°ü±êê¶
SendLength(0x08);
Sendcmd(0x1b);
MYUSART_SendData(BufferID);
MYUSART_SendData(StartPage>>8);
MYUSART_SendData(StartPage);
MYUSART_SendData(PageNum>>8);
MYUSART_SendData(PageNum);
temp = 0x01+0x08+0x1b+BufferID
+(StartPage>>8)+(u8)StartPage
+(PageNum>>8)+(u8)PageNum;
SendCheck(temp);
data=JudgeStr(2000);
if(data)
{
ensure=data[9];
p->pageID =(data[10]<<8) +data[11];
p->mathscore=(data[12]<<8) +data[13];
}
else
ensure=0xff;
return ensure;
}
//¶áóDD§Ä£°å¸öêy PS_ValidTempleteNum
//1|Äü£o¶áóDD§Ä£°å¸öêy
//2Îêy: ÎT
//ËμÃ÷: Ä£¿é·μ»Øè·èÏ×Ö+óDD§Ä£°å¸öêyValidN
u8 PS_ValidTempleteNum(u16 *ValidN)
{
u16 temp;
u8 ensure;
u8 *data;
SendHead();
SendAddr();
SendFlag(0x01);//Ãüáî°ü±êê¶
SendLength(0x03);
Sendcmd(0x1d);
temp = 0x01+0x03+0x1d;
SendCheck(temp);
data=JudgeStr(2000);
if(data)
{
ensure=data[9];
*ValidN = (data[10]<<8) +data[11];
}
else
ensure=0xff;
if(ensure==0x00)
{
printf(" óDD§Ö¸ÎƸöêy=%d",(data[10]<<8)+data[11]);
}
else
printf(" %s",EnsureMessage(ensure));
return ensure;
}
//óëAS608ÎÕêÖ PS_HandShake
//2Îêy: PS_AddrμØÖ·Ö¸Õë
//ËμÃ÷: Ä£¿é·μDÂμØÖ·£¨Õyè·μØÖ·£©
u8 PS_HandShake(u32 *PS_Addr)
{
SendHead();
SendAddr();
MYUSART_SendData(0X01);
MYUSART_SendData(0X00);
MYUSART_SendData(0X00);
delay_ms(200);
if(UART5_RX_STA&0X8000)//½óêÕμ½êy¾Y
{
if(//ÅD¶ÏêÇ2»êÇÄ£¿é·μ»ØμÄó|′e°ü
UART5_RX_BUF[0]==0XEF
&&UART5_RX_BUF[1]==0X01
&&UART5_RX_BUF[6]==0X07
)
{
*PS_Addr=(UART5_RX_BUF[2]<<24) + (UART5_RX_BUF[3]<<16)
+(UART5_RX_BUF[4]<<8) + (UART5_RX_BUF[5]);
UART5_RX_STA=0;
return 0;
}
UART5_RX_STA=0;
}
return 1;
}
//Ä£¿éó|′e°üè·èÏÂëDÅÏ¢½aÎö
//1|Äü£o½aÎöè·èÏÂë′íÎóDÅÏ¢·μ»ØDÅÏ¢
//2Îêy: ensure
const char *EnsureMessage(u8 ensure)
{
const char *p;
switch(ensure)
{
case 0x00:
p="OK";break;
case 0x01:
p="êy¾Y°ü½óêÕ′íÎó";break;
case 0x02:
p="′«¸DÆ÷éÏûóDêÖÖ¸";break;
case 0x03:
p="¼èëÖ¸ÎÆí¼Ïñ꧰ü";break;
case 0x04:
p="Ö¸ÎÆí¼Ïñ쫸é¡¢ì«μ-¶øéú2»3éìØÕ÷";break;
case 0x05:
p="Ö¸ÎÆí¼Ïñì«êa¡¢ì«oy¶øéú2»3éìØÕ÷";break;
case 0x06:
p="Ö¸ÎÆí¼Ïñì«Âò¶øéú2»3éìØÕ÷";break;
case 0x07:
p="Ö¸ÎÆí¼ÏñÕy3££¬μ«ìØÕ÷μãì«éù£¨»òÃæ»yì«D¡£©¶øéú2»3éìØÕ÷";break;
case 0x08:
p="Ö¸ÎÆ2»Æ¥Åä";break;
case 0x09:
p="ûËÑË÷μ½Ö¸ÎÆ";break;
case 0x0a:
p="ìØÕ÷oÏ2¢꧰ü";break;
case 0x0b:
p="·ÃÎêÖ¸ÎÆ¿aê±μØÖ·DòoÅ3¬3öÖ¸ÎÆ¿a·¶Î§";
case 0x10:
p="é¾3yÄ£°å꧰ü";break;
case 0x11:
p="Çå¿ÕÖ¸ÎÆ¿a꧰ü";break;
case 0x15:
p="»o3åÇøÄúûóDóDD§Ô-ê¼í¼¶øéú2»3éí¼Ïñ";break;
case 0x18:
p="¶áD′ FLASH 3ö′í";break;
case 0x19:
p="Î′¶¨òå′íÎó";break;
case 0x1a:
p="ÎTD§¼Ä′æÆ÷oÅ";break;
case 0x1b:
p="¼Ä′æÆ÷é趨ÄúèY′íÎó";break;
case 0x1c:
p="¼Çê±¾ò3ÂëÖ¸¶¨′íÎó";break;
case 0x1f:
p="Ö¸ÎÆ¿aÂú";break;
case 0x20:
p="μØÖ·′íÎó";break;
default :
p="Ä£¿é·μ»Øè·èÏÂëóDÎó";break;
}
return p;
}[/mw_shl_code]
一周热门 更多>