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
33e53813
Commit
33e53813
authored
Aug 24, 2014
by
Theodor-Adrian Stana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gps: Further trials to get it to fix
parent
ca039748
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
9 deletions
+86
-9
main.c
sw/gps/main.c
+86
-9
No files found.
sw/gps/main.c
View file @
33e53813
...
...
@@ -37,6 +37,7 @@
*/
#include <string.h>
#include <stdio.h>
#include "em_device.h"
#include "em_cmu.h"
...
...
@@ -46,24 +47,39 @@
#include "usbdbg.h"
#define RXBUFSIZE 8
#define GPS_OK_TO_SEND "$PSRF150,1*3E\r\n"
#define RXBUFSIZE 16
static
char
rxbuf
[
RXBUFSIZE
];
volatile
char
idx
=
0
;
static
void
gps_init
();
static
void
gps_on_off_pulse
();
volatile
char
gps_rdy
=
0
;
void
gps_init
();
void
gps_on_off_pulse
();
int
gps_puts
(
char
*
);
void
gps_reset
(
int
val
);
int
nmea_crc
(
const
char
*
);
void
LEUART0_IRQHandler
()
{
if
(
LEUART0
->
IF
&
LEUART_IF_RXDATAV
)
{
rxbuf
[
idx
++
]
=
LEUART_Rx
(
LEUART0
);
if
(
idx
==
RXBUFSIZE
)
{
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
"
);
idx
=
0
;
}
if
((
gps_rdy
)
&&
(
idx
==
RXBUFSIZE
))
{
idx
=
0
;
usbdbg_puts
(
rxbuf
);
}
}
}
int
main
()
{
CMU_ClockSelectSet
(
cmuClock_HF
,
cmuSelect_HFXO
);
...
...
@@ -77,18 +93,74 @@ int main()
gps_init
();
usbdbg_puts
(
"init done!
\r\n
"
);
int
i
;
int
i
,
one
=
1
;
static
char
tmp
[
64
];
static
char
c
[
2
];
static
char
cmd
[
64
];
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");
// }
// }
}
return
0
;
}
static
void
gps_init
()
int
gps_puts
(
char
*
s
)
{
while
(
*
s
++
)
{
if
(
*
s
==
EOF
)
return
EOF
;
LEUART_Tx
(
LEUART0
,
*
s
);
}
return
1
;
}
int
nmea_crc
(
const
char
*
nmea_str
)
{
int
chksum
=
0
;
int
i
=
0
;
int
n
=
0
;
char
buf
[
128
];
while
(
*
nmea_str
!=
'*'
)
buf
[
n
++
]
=
*
nmea_str
++
;
for
(
i
=
1
;
i
<
n
;
i
++
)
chksum
^=
(
int
)
buf
[
i
];
return
chksum
;
}
void
gps_init
()
{
int
i
;
/* Init GPS control pins & delay before ON_OFF pulse */
...
...
@@ -96,7 +168,7 @@ static void gps_init()
GPIO_PinModeSet
(
gpioPortF
,
5
,
gpioModePushPull
,
1
);
GPIO_PinModeSet
(
gpioPortA
,
1
,
gpioModeInput
,
0
);
GPIO_PinModeSet
(
gpioPortE
,
13
,
gpioModePushPull
,
0
);
for
(
i
=
0
;
i
<
10000000
0
;
i
++
)
for
(
i
=
0
;
i
<
10000000
;
i
++
)
;
gps_on_off_pulse
();
...
...
@@ -124,14 +196,14 @@ static void gps_init()
LEUART_IntClear
(
LEUART0
,
LEUART_IF_RXDATAV
);
NVIC_ClearPendingIRQ
(
LEUART0_IRQn
);
LEUART_IntEnable
(
LEUART0
,
LEUART_IF_RXDATAV
);
NVIC_EnableIRQ
(
LEUART0_IRQn
);
LEUART_Enable
(
LEUART0
,
leuartEnable
);
}
static
void
gps_on_off_pulse
()
void
gps_on_off_pulse
()
{
int
i
;
...
...
@@ -146,3 +218,8 @@ static void gps_on_off_pulse()
for
(
i
=
0
;
i
<
100000
;
i
++
)
;
}
void
gps_reset
(
int
val
)
{
val
?
GPIO_PinOutClear
(
gpioPortF
,
5
)
:
GPIO_PinOutSet
(
gpioPortF
,
5
);
}
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