![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
dongyanzhi gps
Revision 0:3ba942901d6e, committed 2017-06-09
- Comitter:
- dongyanzhi
- Date:
- Fri Jun 09 02:45:45 2017 +0000
- Commit message:
- dongyanzhi gps
Changed in this revision
diff -r 000000000000 -r 3ba942901d6e main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 09 02:45:45 2017 +0000 @@ -0,0 +1,42 @@ +#include "mbed.h" +#include <cstring> + +Serial pc(SERIAL_TX, SERIAL_RX); //USART2 +Serial gps(D1,D0); //USART1 +DigitalOut myled(LED1); +char buffer[256]; +void getline(); +void callback() +{ + getline(); +} +volatile int sig=0; +volatile int i=0; +int main() +{ + pc.printf("start test!\r\n"); + gps.attach(&callback); + + while(1) + { + hal_sleep(); + if(sig == 7) + { + sig=0; + i=0; + pc.printf("%s",buffer); + memset(buffer,0,sizeof(buffer)); + } + } +} + + +void getline() +{ + buffer[i] = gps.getc(); + if(buffer[i] == 0x0a) + { + sig++; + } + i++; +}
diff -r 000000000000 -r 3ba942901d6e mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jun 09 02:45:45 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/86740a56073b \ No newline at end of file
diff -r 000000000000 -r 3ba942901d6e mbed_config.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed_config.h Fri Jun 09 02:45:45 2017 +0000 @@ -0,0 +1,13 @@ +// Automatically generated configuration file. +// DO NOT EDIT, content will be overwritten. + +#ifndef __MBED_CONFIG_DATA__ +#define __MBED_CONFIG_DATA__ + +// Configuration parameters +#define MBED_CONF_PLATFORM_STDIO_BAUD_RATE 9600 // set by library:platform +#define MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE 9600 // set by library:platform +#define MBED_CONF_PLATFORM_STDIO_FLUSH_AT_EXIT 1 // set by library:platform +#define MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES 0 // set by library:platform + +#endif
diff -r 000000000000 -r 3ba942901d6e usart.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usart.c Fri Jun 09 02:45:45 2017 +0000 @@ -0,0 +1,28 @@ +#include "usart.h" + +void UsartConfig() +{ + USART_InitTypeDef UsartInitStruct; + USART_HandleTypeDef UsartHandleStruct; + + UsartInitStruct.BaudRate = 9600; + UsartInitStruct.CLKLastBit = USART_LASTBIT_DISABLE; + UsartInitStruct.CLKPhase = USART_PHASE_1EDGE; + UsartInitStruct.CLKPolarity = USART_PHASE_1EDGE; + UsartInitStruct.Mode = USART_MODE_TX_RX; + UsartInitStruct.Parity = USART_PARITY_NONE; + UsartInitStruct.StopBits = USART_STOPBITS_1; + UsartInitStruct.WordLength = USART_WORDLENGTH_8B; + + UsartHandleStruct.Init = UsartInitStruct; + UsartHandleStruct.Instance = USART2; + UsartHandleStruct.Lock = HAL_LOCKED; + UsartHandleStruct.pRxBuffPtr =NULL ; + UsartHandleStruct.pTxBuffPtr =NULL; + UsartHandleStruct.RxXferCount =NULL ; + UsartHandleStruct.RxXferSize =NULL ; + UsartHandleStruct.TxXferCount =NULL ; + UsartHandleStruct.TxXferSize =NULL ; + UsartHandleStruct.State = HAL_USART_STATE_READY; + +} \ No newline at end of file
diff -r 000000000000 -r 3ba942901d6e usart.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usart.h Fri Jun 09 02:45:45 2017 +0000 @@ -0,0 +1,7 @@ +#ifndef __USART_H +#define __USART_H + +#include "stm32l4xx.h" + + +#endif \ No newline at end of file