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
200e9d2f
Commit
200e9d2f
authored
Aug 25, 2014
by
Theodor-Adrian Stana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GPS now fixes to satellites
Implemented and tested some utility functions
parent
b2073475
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
41 deletions
+65
-41
gps.c
sw/gps/gps/gps.c
+43
-12
gps.h
sw/gps/gps/gps.h
+5
-1
main.c
sw/gps/main.c
+17
-28
No files found.
sw/gps/gps/gps.c
View file @
200e9d2f
...
...
@@ -50,26 +50,22 @@
#define GPS_OK_TO_SEND "$PSRF150,1*3E\r\n"
#define RXBUFSIZE 1
6
#define RXBUFSIZE 1
28
static
char
rxbuf
[
RXBUFSIZE
];
volatile
char
idx
=
0
;
volatile
int
idx
=
0
;
volatile
char
gps_rdy
=
0
;
static
nmeaINFO
gps_info
;
static
nmeaPARSER
gps_parser
;
void
LEUART0_IRQHandler
()
{
if
(
LEUART0
->
IF
&
LEUART_IF_RXDATAV
)
{
rxbuf
[
idx
++
]
=
LEUART_Rx
(
LEUART0
);
if
((
gps_rdy
==
0
)
&&
(
strncmp
(
rxbuf
,
GPS_OK_TO_SEND
,
strlen
(
GPS_OK_TO_SEND
))
==
0
))
{
gps_rdy
=
1
;
usbdbg_puts
(
"GPS ready to send!
\r\n
"
);
if
((
rxbuf
[
idx
-
2
]
==
'\r'
)
&&
(
rxbuf
[
idx
-
1
]
==
'\n'
))
{
rxbuf
[
idx
]
=
'\0'
;
idx
=
0
;
}
if
((
gps_rdy
)
&&
(
idx
==
RXBUFSIZE
))
{
idx
=
0
;
usbdbg_puts
(
rxbuf
);
nmea_parse
(
&
gps_parser
,
rxbuf
,
strlen
(
rxbuf
),
&
gps_info
);
}
}
}
...
...
@@ -116,6 +112,9 @@ void gps_init()
LEUART_Enable
(
LEUART0
,
leuartEnable
);
/* NMEA parser & info structure init */
nmea_zero_INFO
(
&
gps_info
);
nmea_parser_init
(
&
gps_parser
);
}
void
gps_on_off_pulse
()
...
...
@@ -166,3 +165,35 @@ int gps_nmea_crc(const char *nmeastr)
return
chksum
;
}
int
gps_fixed
()
{
return
gps_info
.
sig
;
}
void
gps_get_utc
(
int
*
yr
,
int
*
mon
,
int
*
day
,
int
*
hr
,
int
*
min
,
int
*
sec
)
{
*
yr
=
1900
+
gps_info
.
utc
.
year
;
*
mon
=
1
+
gps_info
.
utc
.
mon
;
*
day
=
gps_info
.
utc
.
day
;
*
hr
=
gps_info
.
utc
.
hour
;
*
min
=
gps_info
.
utc
.
min
;
*
sec
=
gps_info
.
utc
.
sec
;
}
void
gps_get_coord
(
double
*
lat
,
double
*
lon
,
double
*
elv
)
{
*
lat
=
gps_info
.
lat
;
*
lon
=
gps_info
.
lon
;
*
elv
=
gps_info
.
elv
;
}
void
gps_get_speed
(
double
*
spd
)
{
*
spd
=
gps_info
.
speed
;
}
void
gps_get_direction
(
double
*
dir
)
{
*
dir
=
gps_info
.
direction
;
}
sw/gps/gps/gps.h
View file @
200e9d2f
...
...
@@ -47,6 +47,10 @@ void gps_on_off_pulse();
void
gps_reset
(
int
val
);
int
gps_puts
(
char
*
s
);
int
gps_nmea_crc
(
const
char
*
nmeastr
);
int
gps_fixed
();
void
gps_get_utc
(
int
*
yr
,
int
*
mon
,
int
*
day
,
int
*
hr
,
int
*
min
,
int
*
sec
);
void
gps_get_coord
(
double
*
lat
,
double
*
lon
,
double
*
elv
);
void
gps_get_speed
(
double
*
spd
);
void
gps_get_direction
(
double
*
dir
);
#endif // __GPS_H_
sw/gps/main.c
View file @
200e9d2f
...
...
@@ -47,6 +47,7 @@
#include "usbdbg.h"
#include "gps.h"
int
main
()
{
...
...
@@ -62,40 +63,28 @@ int main()
usbdbg_puts
(
"init done!
\r\n
"
);
int
i
,
one
=
1
;
static
char
tmp
[
64
];
static
char
c
[
2
]
;
static
char
cmd
[
64
]
;
static
char
tmp
[
128
];
double
lat
,
lon
,
elv
;
double
spd
,
dir
;
for
(;;)
{
GPIO_PinInGet
(
gpioPortA
,
1
)
?
GPIO_PinOutSet
(
gpioPortE
,
11
)
:
GPIO_PinOutClear
(
gpioPortE
,
11
);
LEUART_Tx
(
LEUART0
,
0x54
);
// if (one) {
// one = 0;
// for (i = 0; i < 20000000; i++)
// ;
//// usbdbg_puts("\r\n\r\n\r\n\r\n"); //strcpy(tmp, "$PSRF105,1*");
//// sprintf(c, "%02X", nmea_crc(tmp));
//// strcat(tmp, c);
//// strcat(tmp, "\r\n");
//// usbdbg_puts(tmp);
//// gps_puts(tmp);
//// usbdbg_puts("\r\n\r\n\r\n\r\n");
// /* Send init command */
//// strcpy(tmp, "$PSRF104,46.22954,6.06156,100,0,55020,1807,12,1*");
// strcpy(tmp, "$PSRF125*");
// sprintf(c, "%02X", nmea_crc(tmp));
// strcpy(cmd, tmp);
// strcat(cmd, c);
// strcat(cmd, "\r\n");
// if (gps_puts(cmd)) {
// usbdbg_puts("\r\n\r\n\r\n\r\n");
// usbdbg_puts(cmd);
// usbdbg_puts("\r\n\r\n\r\n\r\n");
// }
// }
gps_get_coord
(
&
lat
,
&
lon
,
&
elv
);
gps_get_speed
(
&
spd
);
gps_get_direction
(
&
dir
);
sprintf
(
tmp
,
"%d: "
,
gps_fixed
());
sprintf
(
tmp
+
strlen
(
tmp
),
"%4.4f / %4.4f / %2.3f / "
,
lat
,
lon
,
elv
);
sprintf
(
tmp
+
strlen
(
tmp
),
"%3.2f / %3.2f"
,
spd
,
dir
);
sprintf
(
tmp
+
strlen
(
tmp
),
"
\r\n
"
);
usbdbg_puts
(
tmp
);
for
(
i
=
0
;
i
<
1000000
;
i
++
)
;
}
return
0
;
...
...
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