Commit 2b4e9a38 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

More trials with GPS optimization

A bug was fixed in gps_parse_nmea(), whereby the wrong buffer was
given as a param to strlen(), which is used in gps_parse_nmea() to
provide a buffer size parameter to nmea_parse.

After this, the processor now enters a hard fault ,probably due to
segmentation fault. More debug is needed probably with a different
board to find out why.
parent e18ed9d9
......@@ -51,7 +51,7 @@
static char rxbuf[GPS_RXBUF_SIZE];
static volatile int idx = 0;
static volatile int frame_rdy = 0;
static volatile int framerdy = 0;
static nmeaINFO info;
static nmeaPARSER parser;
......@@ -64,7 +64,7 @@ void LEUART0_IRQHandler()
if ((rxbuf[idx-2] == '\r') && (rxbuf[idx-1] == '\n')) {
rxbuf[idx] = '\0';
idx = 0;
frame_rdy = 1;
gps_set_framerdy(1);
// gps_parse_nmea(rxbuf);
}
}
......@@ -138,17 +138,30 @@ void gps_reset(int val)
val ? GPIO_PinOutClear(gpioPortF, 5) : GPIO_PinOutSet(gpioPortF, 5);
}
int gps_frame_rdy()
int gps_get_framerdy()
{
return frame_rdy;
return framerdy;
}
void gps_parse_nmea(char *buf)
void gps_set_framerdy(int param)
{
framerdy = param;
}
static void dbg()
{
int i;
GPIO_PinOutSet(gpioPortE, 11);
for (i = 0; i < 100000; i++) ;
GPIO_PinOutClear(gpioPortE, 11);
}
void gps_parse_nmea(const char *buf)
{
// TODO: check return of nmea_parse
nmea_parse(&parser, buf, strlen(rxbuf), &info);
nmea_parse(&parser, buf, strlen(buf), &info);
dbg();
usbdbg_puts(buf);
frame_rdy = 0;
}
int gps_fixed()
......@@ -199,7 +212,7 @@ void gps_get_direction(double *dir)
*dir = info.direction;
}
int gps_puts(char *s)
int gps_puts(const char *s)
{
while (*s++) {
if (*s == EOF)
......
......@@ -71,14 +71,15 @@ struct gps_utc {
void gps_init();
void gps_on_off_pulse();
void gps_reset(int val);
int gps_frame_rdy();
void gps_parse_nmea(char *buf);
int gps_get_framerdy();
void gps_set_framerdy();
void gps_parse_nmea(const char *buf);
int gps_fixed();
void gps_get_utc(struct gps_utc *utc);
void gps_get_coord(struct gps_coord *coord, int format);
void gps_get_speed(double *spd);
void gps_get_direction(double *dir);
int gps_puts(char *s);
int gps_puts(const char *s);
int gps_nmea_crc(const char *nmeastr);
#endif // __GPS_H_
......@@ -29,16 +29,9 @@
#include <usbdbg.h>
#define dbg() \
int i; \
GPIO_PinOutSet(gpioPortE, 11); \
for (i = 0; i < 1000000; i++) \
; \
GPIO_PinOutClear(gpioPortE, 11);
extern char gps_rxbuf[GPS_RXBUF_SIZE];
extern volatile char gps_rxbuf[GPS_RXBUF_SIZE];
extern xSemaphoreHandle sem_gps;
extern xSemaphoreHandle semGps;
void gpsbkgrnd_main(void *params)
{
......@@ -46,7 +39,7 @@ void gpsbkgrnd_main(void *params)
(void) params;
while (1) {
if (xSemaphoreTake(sem_gps, portMAX_DELAY)) {
if (xSemaphoreTake(semGps, portMAX_DELAY)) {
gps_parse_nmea(gps_rxbuf);
}
}
......
......@@ -111,10 +111,10 @@ void HardFault_Handler(void)
SCB->AIRCR = 0x05FA0004;
}
volatile char gps_rxbuf[GPS_RXBUF_SIZE];
char gps_rxbuf[GPS_RXBUF_SIZE];
static volatile int idx = 0;
extern xSemaphoreHandle sem_gps;
extern xSemaphoreHandle semGps;
void LEUART0_IRQHandler(void)
{
......@@ -125,7 +125,7 @@ void LEUART0_IRQHandler(void)
if ((gps_rxbuf[idx-2] == '\r') && (gps_rxbuf[idx-1] == '\n')) {
gps_rxbuf[idx] = '\0';
idx = 0;
xSemaphoreGiveFromISR(sem_gps, &xHigherPriorityTaskWoken);
xSemaphoreGiveFromISR(semGps, &xHigherPriorityTaskWoken);
}
}
......
......@@ -36,7 +36,7 @@
#include <gfx/ui.h>
#include <drivers/gps/gps.h>
xSemaphoreHandle sem_gps;
xSemaphoreHandle semGps;
int main(void)
{
......@@ -66,7 +66,7 @@ int main(void)
startMain(&menu);
vSemaphoreCreateBinary(sem_gps);
vSemaphoreCreateBinary(semGps);
/* Create background task for GPS */
if (xTaskCreate(gpsbkgrnd.main, (const signed char *)gpsbkgrnd.name,
APP_STACK_SIZE, NULL, APP_PRIORITY, NULL) != pdPASS) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment