This is the firmware for the bridge between eTrex Legend serial and I2C bus
C
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
HAB-GPS2-Bridge.c
HAB-GPS2-Bridge.cproj
README.md
TWI_slave.c
TWI_slave.h
avrlibdefs.h
avrlibtypes.h
global.h
gps.c
gps.h
settings.c
settings.h
uart.c
uart.h

README.md

This application is a component of HAB, the high-altitude balloon flight controller. It provides a bridge between to incoming serial data from the backup GPS (an eTrex Legend) and the main flight computer's I2C bus. Rather than use a larger MCU to provide more on-board USARTs, we chose a bridge. Further the secondary control off-loads the GPS stream parsing from the primary controller.

Garmin Text Output Mode Description

FIELD DESCRIPTION:WIDTH:NOTES:
 Sentence start1Always '@'
T
I
M
E
Year2Last two digits of UTC year
Month2UTC month, "01".."12"
Day2UTC day of month, "01".."31"
Hour2UTC hour, "00".."23"
Minute2UTC minute, "00".."59"
Second2UTC second, "00".."59"
P
O
S
I
T
I
O
N
Latitude hemisphere1'N' or 'S'
Latitude position7WGS84 ddmmmmm, with an implied decimal after the 4th digit
Longitude hemishpere1'E' or 'W'
Longitude position8WGS84 dddmmmmm with an implied decimal after the 5th digit
Position status1'd' if current 2D differential GPS position
'D' if current 3D differential GPS position
'g' if current 2D GPS position
'G' if current 3D GPS position
'S' if simulated position
'_' if invalid position
Horizontal posn error3EPH in meters
Altitude sign1'+' or '-'
Altitude5Height above or below mean sea level in meters
V
E
L
O
C
I
T
Y
East/West velocity
direction
1'E' or 'W'
East/West velocity
magnitude
4 Meters per second in tenths, ("1234" = 123.4 m/s)
North/South velocity
direction
1'N' or 'S'
North/South velocity
magnitude
4Meters per second in tenths, ("1234" = 123.4 m/s)
Vertical velocity
direction
1'U' (up) or 'D' (down)
Vertical velocity
magnitude
4Meters per second in hundredths, ("1234" = 12.34 m/s)
  Sentence end2Carriage return, '0x0D', and line feed, '0x0A'

Target MCU

This code has been tested on an ATmega 328 AVR; but the code is compact enough to work with controllers with less flash memory - such as an ATmega 48 or ATmega 88. The optimized code is just under 4K; so an ATmega 48 may work acceptably.

To reduce the USART error, the clock frequency should be:

  • 1.8432 MHz
  • 3.6864 MHz
  • 7.3728 MHz
  • 14.7456 MHz
  • 16.5888 MHz

Project files

settings.h/.c

The settings files provide persistent settings functionality for the application. Additional settings can be added by modifying the settings_record_t struct.

gps.h/.c

The gps file mainly takes care of parsing the Garmin text strings from the GPS. Currently, it provides a limited amount of data.

To access coordinates components (lat/long) use the gps_data structure like:

gps_data.coordinate.latitude.degrees

TWI_slave.h/.c

The interface to the TWI/I2C bus. This code is provided by Atmel.


Operation

This device responds to the following operation codes:

E_W_DIR 0x20

Returns the diretion of the East-West velocity vector as single byte character (E/W)

E_W_VEL 0x21

Returns the magnitude of the East-West velocity vector as 2 bytes representing m/s * 100

N_S_DIR 0x22

Returns the direction of North-South velocity vector as single character (N/S)

N_S_VEL 0x23

Returns the magnitude of the North-South velocity vector as 2 bytes representing m/s * 100

VERT_DIR 0x24

Returns the direction of the vertical velocity vector as single character (U/D)

VERT_VEL 0x25

REturns the magnitude of the vertical velocity vector as 2 bytes representing m/s * 10

LAT 0x40

Returns four bytes of data in the following order: direction (N/S), degrees, minutes, seconds.

LON 0x41

Returns four bytes of data in the following order: direction (E/W), degrees, minutes, seconds.

FIX_TIME 0x50

Returns the time for the current fix as as fix_time_t object expressed in six bytes for year, month, day, hour, minute, second.

DEBUG_ON 0x60

Turns debugging on. This enables display of visual data at PB2. Returns I2C_DEBUG_CONFIRM_BYTE

DEBUG_OFF 0x61

Turns off debugging. Returns I2C_DEBUG_CONFIRM_BYTE.

TEST 0x02

Flashes diagnostic LED for testing purposes.