MCU: STM32F103VET6
库函数:3.50
之前把串口1配置完成了,串口1确实能够收发数据。现在用strtok函数对一个字符串进行解析,想打印出来却不可以?单独拿出来放到C环境可以,请做过GPS解析的给点儿经验吧!#include "stm32f10x.h"
#include <stdio.h>
#include "usart_config.h"
#include "stdlib.h"
#include "string.h"
int main(void)
{
//char *gpsinfo= "$GPRMC,175056.000,A,3402.1525,N,11710.8684,W,0.00,306.36,221006,,,A*79";
char *gpsinfo = "0x24,0x45,0x66,0x75";
char *split = ",";
char *result;
Rcc_Configuration();
UsartGPIO_Configuration();
Usart_Configuration();
USART_NVIC_Config();
result = strtok(gpsinfo,split);
while(result != NULL)
{
USART_ClearFlag(USART1,USART_FLAG_TC);
USART_SendData(USART1, (u8)result);
while(USART_GetFlagStatus(USART1,USART_FLAG_TC) == RESET);
USART_ClearFlag(USART1,USART_FLAG_TC);
result = strtok(NULL,split);
}
}
|