Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
fwatch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
8
Issues
8
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
fwatch
Commits
e18ed9d9
Commit
e18ed9d9
authored
Sep 30, 2014
by
Theodor-Adrian Stana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GPS parsing in task almost working
parent
d8f1e42f
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
54 additions
and
35 deletions
+54
-35
gps.c
sw/common/drivers/gps/gps.c
+11
-8
gps.h
sw/common/drivers/gps/gps.h
+13
-1
event.h
sw/common/event.h
+1
-3
application.h
sw/freertos/src/apps/application.h
+1
-0
gpsbkgrnd.c
sw/freertos/src/apps/gpsbkgrnd.c
+10
-9
gpscoord.c
sw/freertos/src/apps/gpscoord.c
+5
-2
status_bar.c
sw/freertos/src/apps/widgets/status_bar.c
+1
-1
irq_dispatcher.c
sw/freertos/src/irq_dispatcher.c
+8
-10
main.c
sw/freertos/src/main.c
+4
-1
No files found.
sw/common/drivers/gps/gps.c
View file @
e18ed9d9
...
...
@@ -49,11 +49,7 @@
#include <usbconfig.h>
#include <usbdbg.h>
#define GPS_OK_TO_SEND "$PSRF150,1*3E\r\n"
#define RXBUFSIZE 128
static
char
rxbuf
[
RXBUFSIZE
];
static
char
rxbuf
[
GPS_RXBUF_SIZE
];
static
volatile
int
idx
=
0
;
static
volatile
int
frame_rdy
=
0
;
...
...
@@ -69,6 +65,7 @@ void LEUART0_IRQHandler()
rxbuf
[
idx
]
=
'\0'
;
idx
=
0
;
frame_rdy
=
1
;
// gps_parse_nmea(rxbuf);
}
}
}
...
...
@@ -141,11 +138,17 @@ void gps_reset(int val)
val
?
GPIO_PinOutClear
(
gpioPortF
,
5
)
:
GPIO_PinOutSet
(
gpioPortF
,
5
);
}
void
gps_parse_nmea
()
int
gps_frame_rdy
()
{
return
frame_rdy
;
}
void
gps_parse_nmea
(
char
*
buf
)
{
// TODO: check return of nmea_parse
nmea_parse
(
&
parser
,
rxbuf
,
strlen
(
rxbuf
),
&
info
);
usbdbg_puts
(
rxbuf
);
nmea_parse
(
&
parser
,
buf
,
strlen
(
rxbuf
),
&
info
);
usbdbg_puts
(
buf
);
frame_rdy
=
0
;
}
int
gps_fixed
()
...
...
sw/common/drivers/gps/gps.h
View file @
e18ed9d9
...
...
@@ -39,6 +39,17 @@
#ifndef __GPS_H_
#define __GPS_H_
/*=============*/
/* GPS defines */
/*=============*/
#define GPS_OK_TO_SEND "$PSRF150,1*3E\r\n"
#define GPS_RXBUF_SIZE 128
/*=================*/
/* Data structures */
/*=================*/
struct
gps_coord
{
double
lat
;
double
lon
;
...
...
@@ -60,7 +71,8 @@ struct gps_utc {
void
gps_init
();
void
gps_on_off_pulse
();
void
gps_reset
(
int
val
);
void
gps_parse_nmea
();
int
gps_frame_rdy
();
void
gps_parse_nmea
(
char
*
buf
);
int
gps_fixed
();
void
gps_get_utc
(
struct
gps_utc
*
utc
);
void
gps_get_coord
(
struct
gps_coord
*
coord
,
int
format
);
...
...
sw/common/event.h
View file @
e18ed9d9
...
...
@@ -33,9 +33,7 @@
enum
event_type
{
BUTTON_PRESSED
,
SENSOR
,
RTC_TICK
,
GPS_FRAME_RDY
,
GPS_PARSE_RDY
RTC_TICK
};
/**
...
...
sw/freertos/src/apps/application.h
View file @
e18ed9d9
...
...
@@ -30,6 +30,7 @@
#include <FreeRTOS.h>
#include <task.h>
#include <queue.h>
#include <semphr.h>
#include <em_gpio.h>
#include <udelay.h>
...
...
sw/freertos/src/apps/gpsbkgrnd.c
View file @
e18ed9d9
...
...
@@ -27,6 +27,8 @@
#include "application.h"
#include <usbdbg.h>
#define dbg() \
int i; \
GPIO_PinOutSet(gpioPortE, 11); \
...
...
@@ -34,19 +36,18 @@
; \
GPIO_PinOutClear(gpioPortE, 11);
extern
volatile
char
gps_rxbuf
[
GPS_RXBUF_SIZE
];
extern
xSemaphoreHandle
sem_gps
;
void
gpsbkgrnd_main
(
void
*
params
)
{
(
void
)
params
;
struct
event
evt
;
/* suppress compiler warning */
(
void
)
params
;
while
(
1
)
{
if
(
xQueueReceive
(
appQueue
,
&
evt
,
portMAX_DELAY
))
{
if
(
evt
.
type
==
GPS_FRAME_RDY
)
{
gps_parse_nmea
();
evt
.
type
=
GPS_PARSE_RDY
;
xQueueSendToBack
(
appQueue
,
&
evt
,
0
);
}
if
(
xSemaphoreTake
(
sem_gps
,
portMAX_DELAY
))
{
gps_parse_nmea
(
gps_rxbuf
);
}
}
}
...
...
sw/freertos/src/apps/gpscoord.c
View file @
e18ed9d9
...
...
@@ -106,7 +106,7 @@ static void gps_redraw(struct ui_widget *w)
static
void
gps_event
(
struct
ui_widget
*
w
,
const
struct
event
*
evt
)
{
if
(
evt
->
type
==
GPS_PARSE_RDY
)
if
(
evt
->
type
==
RTC_TICK
)
w
->
flags
|=
WF_DIRTY
;
}
...
...
@@ -128,6 +128,9 @@ static struct ui_widget gps_screen = {
void
gpscoord_main
(
void
*
params
)
{
/* suppress compiler warning */
(
void
)
params
;
struct
event
evt
;
int
i
=
0
;
...
...
@@ -161,7 +164,7 @@ void gpscoord_main(void *params)
gpsscreen
%=
2
;
}
break
;
case
GPS_PARSE_RDY
:
case
RTC_TICK
:
ui_update
(
&
evt
);
default:
break
;
...
...
sw/freertos/src/apps/widgets/status_bar.c
View file @
e18ed9d9
...
...
@@ -36,7 +36,7 @@ static int gps_ico_blink = 0;
static
void
status_bar_event
(
struct
ui_widget
*
w
,
const
struct
event
*
evt
)
{
if
(
evt
->
type
==
GPS_PARSE_RDY
)
{
if
(
evt
->
type
==
RTC_TICK
)
{
w
->
flags
|=
WF_DIRTY
;
if
(
gps_fixed
())
{
memcpy
(
&
gps_ico
,
&
gps_receiving
,
...
...
sw/freertos/src/irq_dispatcher.c
View file @
e18ed9d9
...
...
@@ -29,6 +29,7 @@
#include <event.h>
#include <drivers/rtc.h>
#include <drivers/gps/gps.h>
#include <em_device.h>
#include <em_gpio.h>
...
...
@@ -110,24 +111,21 @@ void HardFault_Handler(void)
SCB
->
AIRCR
=
0x05FA0004
;
}
#define RXBUFSIZE 128
static
char
rxbuf
[
RXBUFSIZE
];
volatile
char
gps_rxbuf
[
GPS_RXBUF_SIZE
];
static
volatile
int
idx
=
0
;
extern
xSemaphoreHandle
sem_gps
;
void
LEUART0_IRQHandler
(
void
)
{
portBASE_TYPE
xHigherPriorityTaskWoken
=
pdFALSE
;
// Fill the event data
struct
event
evt
;
evt
.
type
=
GPS_FRAME_RDY
;
if
(
LEUART0
->
IF
&
LEUART_IF_RXDATAV
)
{
rxbuf
[
idx
++
]
=
LEUART_Rx
(
LEUART0
);
if
((
rxbuf
[
idx
-
2
]
==
'\r'
)
&&
(
rxbuf
[
idx
-
1
]
==
'\n'
))
{
rxbuf
[
idx
]
=
'\0'
;
gps_
rxbuf
[
idx
++
]
=
LEUART_Rx
(
LEUART0
);
if
((
gps_rxbuf
[
idx
-
2
]
==
'\r'
)
&&
(
gps_
rxbuf
[
idx
-
1
]
==
'\n'
))
{
gps_
rxbuf
[
idx
]
=
'\0'
;
idx
=
0
;
x
QueueSendFromISR
(
appQueue
,
&
evt
,
&
xHigherPriorityTaskWoken
);
x
SemaphoreGiveFromISR
(
sem_gps
,
&
xHigherPriorityTaskWoken
);
}
}
...
...
sw/freertos/src/main.c
View file @
e18ed9d9
...
...
@@ -36,6 +36,8 @@
#include <gfx/ui.h>
#include <drivers/gps/gps.h>
xSemaphoreHandle
sem_gps
;
int
main
(
void
)
{
// Chip errata
...
...
@@ -64,9 +66,10 @@ int main(void)
startMain
(
&
menu
);
vSemaphoreCreateBinary
(
sem_gps
);
/* Create background task for GPS */
if
(
xTaskCreate
(
gpsbkgrnd
.
main
,
(
const
signed
char
*
)
gpsbkgrnd
.
name
,
APP_STACK_SIZE
,
NULL
,
BKGRND_
APP_PRIORITY
,
NULL
)
!=
pdPASS
)
{
APP_STACK_SIZE
,
NULL
,
APP_PRIORITY
,
NULL
)
!=
pdPASS
)
{
// TODO oops..
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment