初级会员
- 积分
- 83
- 金钱
- 83
- 注册时间
- 2015-9-22
- 在线时间
- 76 小时
|
1金钱
贴代码
[mw_shl_code=applescript,true]int main()
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//éèÖÃÏμí3ÖD¶ÏóÅÏ輶·Ö×é4
spi_init();
LED_Init();
uart_init(9600);
mpu_init();
delay_ms(10);
TIM3_Int_Init(49999,84-1); //¶¨ê±Æ÷ê±Öó84M£¬·ÖÆμÏμêy8400£¬ËùòÔ84M/8400=10KhzμļÆêyÆμÂ꣬¸ù¾Y2éÑùÂê¼ÆËãÖüÆú
incPIDinit(); //3õê¼»ˉPID2Îêy
PID_set(0.8,1.85,0.0); //é趨PID±èày»y·Ö΢·ÖμÄÏμêy¡£
usart3_init(38400); //3õê¼»ˉ′®¿ú32¨ìØÂêÎa38400
os_sys_init(taskcreat); //// ĬèÏóÅÏ輶Îa1
os_tsk_delete_self();
}
__task void taskcreat() ///////////////////////////////////////′′½¨èÎÎñ
{
gpstask=os_tsk_create(gps,17); ///////////////////////////////////ÏèÖ′DDÕa¸öèÎÎñ
Ledtask=os_tsk_create(Led,2);
moror_controltask=os_tsk_create(moror_control,3);
MPU9250task=os_tsk_create(MPU9250,4);
boundary_signaltask=os_tsk_create(boundary_signal,5);
gpstask=os_tsk_create(gps,17); ///////////////////////////////////ÏèÖ′DDÕa¸öèÎÎñ
//message_solvetask=os_tsk_create(message_solve,55);
os_tsk_delete_self();
}[/mw_shl_code]
[mw_shl_code=applescript,true]__task void gps() ///////////////////////////GPSμÄé趨óë′|àíóÅÏ輶 6 /////////////////
{
float tmp1,tmp2;
u16 i,rxlen;
u16 lenx;
u8 key=0XFF;
u8 upload=0;
printf("666666666666");
if(Ublox_Cfg_Rate(10000,1)!=0) //éèÖö¨Î»DÅÏ¢¸üDÂËù¶èÎa10000ms,Ë3±ãÅD¶ÏGPSÄ£¿éêÇ·ñÔúλ. //¡¢GPSË¢DÂËùÂê
{
while((Ublox_Cfg_Rate(10000,1)!=0)&&key) //3ÖDøÅD¶Ï,Ö±μ½¿éòÔ¼ì2éμ½NEO-6M,Çòêy¾Y±£′æ3é1|
{
LED0=1;
printf("000");
usart3_init(9600); //3õê¼»ˉ′®¿ú32¨ìØÂêÎa9600(EEPROMûóD±£′æêy¾YμÄê±oò,2¨ìØÂêÎa9600.)
printf("111");
Ublox_Cfg_Prt(38400); //ÖØDÂéèÖÃÄ£¿éμÄ2¨ìØÂêÎa38400
usart3_init(38400); //3õê¼»ˉ′®¿ú32¨ìØÂêÎa38400
Ublox_Cfg_Tp(1000000,100000,1); //éèÖÃPSÎa1ÃëÖóêä3ö1′Î,Âö3å¿í¶èÎa100ms μÆ
printf("2222");
key=Ublox_Cfg_Cfg_Save(); //±£′æÅäÖÃ
if(key!=0)printf("»1ûóD±£′æÅäÖÃ");delay_ms(100);
if(key==0)printf("òѾ-±£′æÅäÖÃ\n\r");delay_ms(10);
LED0=0;
}
}
os_tsk_prio_self(6); //////¸Ä±äGPSμÄèÎÎñóÅÏ輶
while(1)
{
delay_ms(1);
if(USART3_RX_STA&0X8000) //½óêÕμ½ò»′Îêy¾YáË
{
rxlen=USART3_RX_STA&0X7FFF; //μÃμ½êy¾Y3¤¶è
for(i=0;i<rxlen;i++)USART1_TX_BUF=USART3_RX_BUF;
USART3_RX_STA=0; //Æô¶ˉÏÂò»′νóêÕ
USART1_TX_BUF=0; //×Ô¶ˉìí¼ó½áêø·û
GPS_Analysis(&gpsx,(u8*)USART1_TX_BUF);//·ÖÎö×Ö·û′® °Ñ×Ö·û′®·Åμ½áË′®¿úò»μÄbuf
tmp1=gpsx.longitude, tmp2=gpsx.latitude;
printf("%f %f \n\r",tmp1/100000,tmp2/100000);
}
printf("666666666666");
}
}[/mw_shl_code]
|
|