Changeset - 70abc5d16090
[Not reviewed]
default
0 6 0
ethanzonca@CL-SEC241-08.cedarville.edu - 13 years ago 2012-11-27 19:18:07
ethanzonca@CL-SEC241-08.cedarville.edu
Added working USART library
6 files changed with 92 insertions and 44 deletions:
0 comments (0 inline, 0 general)
master/master/config.h
Show inline comments
 
/*
 
 * config.h
 
 *
 
 * Created: 10/25/2012 3:28:22 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
 
#ifndef CONFIG_H_
 
#define CONFIG_H_
 
 
#define F_CPU 11059200
 
#define MODULE_ID '1'
 
 
 
 
// --------------------------------------------------------------------------
 
// USART config (serial.c)
 
// --------------------------------------------------------------------------
 
 
#define USART0_BAUDRATE 115200
 
#define USART1_BAUDRATE 115200
 
 
// --------------------------------------------------------------------------
 
// AX.25 config (ax25.c)
 
// --------------------------------------------------------------------------
 

	
 
// TX delay in milliseconds
 
#define TX_DELAY      300
 

	
 
// Maximum packet delay
 
#define MAX_PACKET_LEN 512  // bytes
 
 

	
 
// --------------------------------------------------------------------------
 
// APRS config (aprs.c)
 
// --------------------------------------------------------------------------
 

	
 
// Set your callsign and SSID here. Common values for the SSID are
 
// (from http://zlhams.wikidot.com/aprs-ssidguide):
 
//
 
// - Balloons:  11
 
// - Cars:       9
 
// - Home:       0
 
// - IGate:      5
 
#define S_CALLSIGN      "MYCALL"
 
#define S_CALLSIGN_ID   11
 

	
 
// Destination callsign: APRS (with SSID=0) is usually okay.
 
#define D_CALLSIGN      "APRS"
 
#define D_CALLSIGN_ID   0
 

	
 
// Digipeating paths:
 
// (read more about digipeating paths here: http://wa8lmf.net/DigiPaths/ )
 
// The recommended digi path for a balloon is WIDE2-1 or pathless. The default
 
// is pathless. Uncomment the following two lines for WIDE2-1 path:
 
#define DIGI_PATH1      "WIDE2"
 
#define DIGI_PATH1_TTL  1
 

	
 
// APRS comment: this goes in the comment portion of the APRS message. You
 
// might want to keep this short. The longer the packet, the more vulnerable
 
// it is to noise.
 
#define APRS_COMMENT    "Trackuino reminder: replace callsign with your own"
 
 
 

	
 
// --------------------------------------------------------------------------
 
// Logger config (logger.c)
 
// --------------------------------------------------------------------------
 
 
#define LOGGER_ID_EEPROM_ADDR 0x10
 
 
// Written to the beginning of every log file
 
#define LOGGER_HEADERTEXT "HAB Control Master - 1.0\n"
 
 
#endif /* CONFIG_H_ */
 
\ No newline at end of file
master/master/lib/serial.c
Show inline comments
 
/*
 
 * serial.c
 
 *
 
 * Created: 10/25/2012 3:19:49 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
#include "serial.h"
 
#include "../config.h"
 
#include <avr/io.h>
 
 
 
void serial_setup() {
 
	// Set registers!
 
	
 
	// from mnl
 
	// uart
 
	//UBRRH = (BAUD_PRESCALE >> 8); // 0
 
	//UBRRL = BAUD_PRESCALE; // 8
 
	//UCSRA = 0;
 
	//UCSRB = 0x18;
 
	//UCSRC = 0x06;
 
	//OCR0B = 0xff;
 
	//OCR0A = 0xff;
 
	//OCR1AL = 0xff;
 
	//OCR1BL = 0xff;
 
 
 
void serial0_setup() {
 
	/* Set baud rate */
 
	UBRR0H = (unsigned char)(BAUD_PRESCALE>>8);
 
	UBRR0L = (unsigned char)BAUD_PRESCALE;
 
	UBRR0H = (unsigned char)(USART0_BAUD_PRESCALE>>8);
 
	UBRR0L = (unsigned char)USART0_BAUD_PRESCALE;
 
	/* Enable receiver and transmitter */
 
	UCSR0B = (1<<RXEN0)|(1<<TXEN0);
 
	/* Set frame format: 8data, 2stop bit */
 
	UCSR0C = (3<<UCSZ00);
 
 
	/* Set frame format: 8data, 1stop bit */
 
	UCSR0C = (3<<UCSZ00); // - 1 stop bit
 
}
 
 
void serial1_setup() {
 
	/* Set baud rate */
 
	UBRR1H = (unsigned char)(USART1_BAUD_PRESCALE>>8);
 
	UBRR1L = (unsigned char)USART1_BAUD_PRESCALE;
 
	/* Enable receiver and transmitter */
 
	UCSR1B = (1<<RXEN1)|(1<<TXEN1);
 
	/* Set frame format: 8data, 1stop bit */
 
	UCSR1C = (3<<UCSZ10); // - 1 stop bit
 
}
 
 
void serial_SendChar( char byte )
 
void serial0_sendChar( unsigned char byte )
 
{
 
	while (!(UCSR0A & (1<<UDRE0)));
 
	UDR0 = byte;
 
}
 
 
void serial_SendCommand( char moduleID, char sensorID, uint8_t dataLength, char* data )
 
void serial1_sendChar( unsigned char byte )
 
{
 
	while (!(UCSR1A & (1<<UDRE1)));
 
	UDR1 = byte;
 
}
 
 
void serial0_sendString(char* stringPtr){
 
	while(*stringPtr != 0x00){
 
		serial0_sendChar(*stringPtr);
 
		stringPtr++;
 
	}
 
}
 
 
void serial1_sendString(char* stringPtr){
 
	while(*stringPtr != 0x00){
 
		serial1_sendChar(*stringPtr);
 
		stringPtr++;
 
	}
 
}
 
 
 
void serial_sendCommand( char moduleID, char sensorID, uint8_t dataLength, char* data )
 
{
 
	char checkSum = 0x00; //initialize checksum
 
	
 
	serial_SendChar('['); //bracket indicates start of command
 
	serial_SendChar(moduleID);
 
	serial0_sendChar('['); //bracket indicates start of command
 
	serial0_sendChar(moduleID);
 
	checkSum+=moduleID;
 
	
 
	serial_SendChar(sensorID);
 
	serial0_sendChar(sensorID);
 
	checkSum+=sensorID;
 
	
 
	//send each character of data individually
 
	for (int i=0; i<dataLength; i++)
 
	{
 
		serial_SendChar(data[i]);
 
		serial0_sendChar(data[i]);
 
		checkSum+=data[i];
 
	}
 
	
 
	serial_SendChar(checkSum);
 
	serial_SendChar(']'); //bracket indicates end of command
 
	serial0_sendChar(checkSum);
 
	serial0_sendChar(']'); //bracket indicates end of command
 
}
 
 
void serial_SendResponseData(){
 
void serial_sendResponseData(){
 
	
 
}
 
master/master/lib/serial.h
Show inline comments
 
/*
 
 * serial.h
 
 *
 
 * Created: 10/25/2012 3:19:42 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
 
#ifndef SERIAL_H_
 
#define SERIAL_H_
 
 
#include <inttypes.h>
 
 
#define USART_BAUDRATE 19200
 
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) -1 )
 
#define USART0_BAUD_PRESCALE (((F_CPU / (USART0_BAUDRATE * 16UL))) -1 )
 
#define USART1_BAUD_PRESCALE (((F_CPU / (USART1_BAUDRATE * 16UL))) -1 )
 
 
void serial0_sendChar( unsigned char byte );
 
void serial1_sendChar( unsigned char byte );
 
 
void serial_SendChar( char byte );
 
void serial_SendCommand( char moduleID, char sensorID, uint8_t dataLength, char* data );
 
void serial_SendResponseData();
 
void serial_setup();
 
void serial0_setup();
 
void serial1_setup();
 
 
void serial0_sendString(char* stringPtr);
 
void serial1_sendString(char* stringPtr);
 
 
void serial_sendCommand( char moduleID, char sensorID, uint8_t dataLength, char* data );
 
void serial_sendResponseData();
 
 
 
#endif /* SERIAL_H_ */
 
\ No newline at end of file
master/master/lib/trackuinoGPS/config.h
Show inline comments
 
/* trackuino copyright (C) 2010  EA5HAV Javi
 
 *
 
 * This program is free software; you can redistribute it and/or
 
 * modify it under the terms of the GNU General Public License
 
 * as published by the Free Software Foundation; either version 2
 
 * of the License, or (at your option) any later version.
 
 *
 
 * This program is distributed in the hope that it will be useful,
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 * GNU General Public License for more details.
 
 *
 
 * You should have received a copy of the GNU General Public License
 
 * along with this program; if not, write to the Free Software
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 */
 

	
 
#ifndef __CONFIG_H__
 
#define __CONFIG_H__
 

	
 

	
 
// --------------------------------------------------------------------------
 
// THIS IS THE TRACKUINO FIRMWARE CONFIGURATION FILE. YOUR CALLSIGN AND
 
// OTHER SETTINGS GO HERE.
 
//
 
// NOTE: all pins are Arduino based, not the Atmega chip. Mapping: this could be an issue !! ??
 
// http://www.arduino.cc/en/Hacking/PinMapping
 
// --------------------------------------------------------------------------
 

	
 

	
 
// --------------------------------------------------------------------------
 
// APRS config (aprs.c)
 
// --------------------------------------------------------------------------
 

	
 
// Set your callsign and SSID here. Common values for the SSID are
 
// (from http://zlhams.wikidot.com/aprs-ssidguide):
 
//
 
// - Balloons:  11
 
// - Cars:       9
 
// - Home:       0
 
// - IGate:      5
 
#define S_CALLSIGN      "MYCALL"
 
#define S_CALLSIGN_ID   11
 

	
 
// Destination callsign: APRS (with SSID=0) is usually okay.
 
#define D_CALLSIGN      "APRS"
 
#define D_CALLSIGN_ID   0
 

	
 
// Digipeating paths:
 
// (read more about digipeating paths here: http://wa8lmf.net/DigiPaths/ )
 
// The recommended digi path for a balloon is WIDE2-1 or pathless. The default
 
// is pathless. Uncomment the following two lines for WIDE2-1 path:
 
#define DIGI_PATH1      "WIDE2"
 
#define DIGI_PATH1_TTL  1
 

	
 
// APRS comment: this goes in the comment portion of the APRS message. You
 
// might want to keep this short. The longer the packet, the more vulnerable
 
// it is to noise. 
 
#define APRS_COMMENT    "Trackuino reminder: replace callsign with your own"
 

	
 

	
 
// --------------------------------------------------------------------------
 
// AX.25 config (ax25.cpp)
 
// --------------------------------------------------------------------------
 

	
 
// TX delay in milliseconds
 
#define TX_DELAY      300
 

	
 
// --------------------------------------------------------------------------
 
// Tracker config (trackuino.pde)
 
// --------------------------------------------------------------------------
 

	
 
// APRS packets are slotted so that multiple trackers can be used without
 
// them stepping on one another. The transmission times are governed by
 
// the formula:
 
//
 
//         APRS_SLOT (seconds) + n * APRS_PERIOD (seconds)
 
//
 
// When launching multiple balloons, use the same APRS_PERIOD in all balloons
 
// and set APRS_SLOT so that the packets are spaced equally in time.
 
// Eg. for two balloons and APRS_PERIOD = 60, set APRS_SLOT to 0 and 30, 
 
// E.g. for two balloons and APRS_PERIOD = 60, set APRS_SLOT to 0 and 30, 
 
// respectively. The first balloon will transmit at 00:00:00, 00:01:00, 
 
// 00:02:00, etc. amd the second balloon will transmit at 00:00:30, 00:01:30,
 
// 00:02:00, etc. and the second balloon will transmit at 00:00:30, 00:01:30,
 
// 00:02:30, etc.
 
#define APRS_SLOT     0     // seconds. -1 disables slotted transmissions
 
#define APRS_PERIOD   60    // seconds
 
#define APRS_PERIOD   5    // seconds
 

	
 
// GPS baud rate (in bits per second). This is also the baud rate at which
 
// debug data will be printed out the serial port.
 
#define GPS_BAUDRATE  9600
 

	
 

	
 
// --------------------------------------------------------------------------
 
// Modem config (afsk.cpp)
 
// --------------------------------------------------------------------------
 

	
 
// AUDIO_PIN is the audio-out pin. The audio is generated by timer 2 using
 
// PWM, so the only two options are pins 3 and 11.
 
// Pin 11 doubles as MOSI, so I suggest using pin 3 for PWM and leave 11 free
 
// in case you ever want to interface with an SPI device.
 
#define AUDIO_PIN       3
 

	
 
// --------------------------------------------------------------------------
 
// Radio config (radio_hx1.cpp)
 
// --------------------------------------------------------------------------
 

	
 
// This is the PTT pin
 
#define PTT_PIN           4
 

	
 
// --------------------------------------------------------------------------
 
// Sensors config (sensors.cpp)
 
// --------------------------------------------------------------------------
 

	
 
// Most of the sensors.cpp functions use internal reference voltages (either
 
// AVCC or 1.1V). If you want to use an external reference, you should
 
// uncomment the following line:
 
//
 
// #define USE_AREF
 
//
 
// BEWARE! If you hook up an external voltage to the AREF pin and 
 
// accidentally set the ADC to any of the internal references, YOU WILL
 
// FRY YOUR AVR.
 
//
 
// It is always advised to connect the AREF pin through a pull-up resistor,
 
// whose value is defined here in ohms (set to 0 if no pull-up):
 
//
 
#define AREF_PULLUP           4700
 
//
 
// Since there is already a 32K resistor at the ADC pin, the actual
 
// voltage read will be VREF * 32 / (32 + AREF_PULLUP)
 
//
 
// Read more in the Arduino reference docs:
 
// http://arduino.cc/en/Reference/AnalogReference?from=Reference.AREF
 

	
 
// Pin mappings for the internal / external temperature sensors. VS refers
 
// to (arduino) digital pins, whereas VOUT refers to (arduino) analog pins.
 
#define INTERNAL_LM60_VS_PIN     6
 
#define INTERNAL_LM60_VOUT_PIN   0
 
#define EXTERNAL_LM60_VS_PIN     7
 
#define EXTERNAL_LM60_VOUT_PIN   1
 

	
 
// Units for temperature sensors (Added by: Kyle Crockett)
 
// 1 = Celsius, 2 = Kelvin, 3 = Fahrenheit
 
#define TEMP_UNIT 1
 

	
 
// Calibration value in the units selected. Use integer only.
 
#define CALIBRATION_VAL 0
 

	
 
// Resistors divider for the voltage meter (ohms)
 
#define VMETER_R1       10000
 
#define VMETER_R2       3300
 

	
 
// Voltage meter analog pin
 
#define VMETER_PIN      2
 

	
 
// --------------------------------------------------------------------------
 
// Buzzer config (buzzer.cpp)
 
// --------------------------------------------------------------------------
 

	
 
// Type of buzzer (0=active, 1=passive). An active buzzer is driven by a
 
// DC voltage. A passive buzzer needs a PWM signal.
 
#define BUZZER_TYPE             0
 

	
 
// When using a passive buzzer, specify the PWM frequency here. Choose one
 
// that maximizes the volume according to the buzzer's datasheet. Not all
 
// the frequencies are valid, check out the buzzer_*.cpp code. On Arduino,
 
// it must be between L and 65535, where L = F_CPU / 65535 and F_CPU is the
 
// clock rate in hertzs. For 16 MHz Arduinos, this gives a lower limit of 
 
// 245 Hz.
 
#define BUZZER_FREQ             895     // Hz
 

	
 
// These are the number of seconds the buzzer will stay on/off alternately
 
#define BUZZER_ON_TIME          1       // secs
 
#define BUZZER_OFF_TIME         2       // secs
 

	
 
// This option disables the buzzer above BUZZER_ALTITUDE meters. This is a
 
// float value, so make it really high (eg. 1000000.0 = 1 million meters)
 
// if you want it to never stop buzzing.
 
#define BUZZER_ALTITUDE         3000.0  // meters (1 ft = 0.3048 m)
 

	
 
// The options here are pin 9 or 10
 
#define BUZZER_PIN              9
 

	
 
// --------------------------------------------------------------------------
 
// Debug
 
// --------------------------------------------------------------------------
 

	
 
// This is the LED pin (13 on Arduinos). The LED will be on while the AVR is
 
// running and off while it's sleeping, so its brightness gives an indication
 
// of the CPU activity.
 
#define LED_PIN                 13
 

	
 
// Debug info includes printouts from different modules to aid in testing and
 
// debugging.
 
// 
 
// 1. To properly receive debug information, only connect the Arduino RX pin 
 
//    to the GPS TX pin, and leave the Arduino TX pin disconnected. 
 
//
 
// 2. On the serial monitor, set the baudrate to GPS_BAUDRATE (above),
 
//    usually 9600.
 
//
 
// 3. When flashing the firmware, disconnect the GPS from the RX pin or you
 
//    will get errors.
 

	
 
// #define DEBUG_GPS    // GPS sentence dump and checksum validation
 
// #define DEBUG_AX25   // AX.25 frame dump
 
// #define DEBUG_MODEM  // Modem ISR overrun and profiling
 
// #define DEBUG_RESET  // AVR reset
 
// #define DEBUG_SENS   // Sensors
 

	
 

	
 
#endif
 

	
master/master/lib/trackuinoGPS/gpsMKa.c
Show inline comments
 
/*
 
* gpsMKa.c
 
*
 
* Created: 11/15/2012 12:02:38 PM
 
*  Author: mkanning
 
*/
 
/*
 
#include <stdbool.h>
 
#include <avr/io.h>
 
#include "gpsMKa.h"
 

	
 
// holds the byte ALREADY PARSED. includes starting character
 
int bytesReceived = 0;
 

	
 
//data (and checksum) of most recent transmission
 
char data[16];
 

	
 
//used to skip over bytes during parse
 
int skipBytes = 0;
 

	
 
//used to index data arrays during data collection
 
int numBytes = 0;
 

	
 
//variables to store data from transmission
 
//least significant digit is stored at location 0 of arrays
 
uint8_t tramsmissionType;
 
uint8_t timestamp[9];	//hhmmss.ss
 
uint8_t latitude[8];	//lllll.lla
 
uint8_t longitude[8];	//yyyyy.yya
 
uint8_t quality;		//quality for GGA and validity for RMC
 
uint8_t numSatellites[2];
 
uint8_t hdop[4];		//xx.x
 
uint8_t altitude[8];	//xxxxxx.x
 
uint8_t wgs84Height[6];	//sxxx.x
 
uint8_t lastUpdated[6];	//blank - included for testing
 
uint8_t stationID[6];	//blank - included for testing
 
uint8_t checksum;		//xx
 

	
 

	
 
// transmission state machine
 
enum decodeState {
 
	//shared fields
 
	INITIALIZE=0,
 
	GET_TYPE,
 
	GPS_CHECKSUM,	//need to find out how this is calculated/compared
 
	//GGA data fields
 
	GGA_TIME,
 
	GGA_LATITUDE,
 
	GGA_LONGITUDE,
 
	GGA_QUALITY,
 
	GGA_SATELLITES,
 
	GGA_HDOP,
 
	GGA_ALTITUDE,
 
	GGA_WGS84,
 
	GGA_LAST_UPDATE,
 
	GGA_STATION_ID,
 
	//RMC data fields
 
	RMC_TIME,
 
	RMC_WARNING,
 
	RMC_LATITUDE,
 
	RMC_LONGITUDE,
 
	RMC_KNOTS,
 
	RMC_COURSE,
 
	RMC_DATE,
 
	RMC_MAG_VERIATION,
 
	
 
}decodeState;
 

	
 
/// MKa GPS transmission parser START
 
void parse_gps_transmission(void){
 
	bytesReceived++;
 
	
 
	// Pull byte off of the buffer
 
	char byte = uart_getchar();
 
	
 
	// $--GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx
 
	//        ^8        ^18       ^28
 
	if(byte == '$') //start of transmission sentence
 
	{
 
		bytesReceived = 1; //resets transmission if '$' is found
 
		decodeState = GET_TYPE;
 
		numBytes = 0;
 
	}
 
	
 
	//parse transmission type
 
	else if (decodeState == GET_TYPE)
 
	{
 
		if (bytesReceived == 4 ) //check 4th byte
 
		{
 
			tramsmissionType = byte;
 
		}
 
		
 
		if(byte = ',') //end of type data
 
		{
 
			if (tramsmissionType == 'G')
 
			{
 
				decodeState = GGA_TIME;
 
			}
 
			else if(tramsmissionType == 'R')
 
			{
 
				decodeState = RMC_TIME; //not implemented
 
			}
 
			else
 
			{
 
				//reset
 
				decodeState = INITIALIZE;
 
				bytesReceived = 0;
 
			}
 
		}
 
	}
 
	
 
	//parse GGA timestamp
 
	else if (decodeState == GGA_TIME)
 
	{
 
		if (byte = ',')//end of timestamp data
 
		{
 
			decodeState = GGA_LATITUDE;
 
			skipBytes = 0; //prep for next phase of parse
 
			numBytes = 0;
 
		}
 
		else //store the byte of timestamp data
 
		{
 
			timestamp[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
		}
 
	}
 
	
 
	//parse GGA latitude data
 
	else if (decodeState == GGA_LATITUDE)
 
	{
 
		if (byte == ',' && skipBytes == 0) //discard this byte
 
		{
 
			skipBytes = 1;
 
		}
 
		else if (byte == ',') //end of latitude data
 
		{
 
			decodeState = GGA_LONGITUDE;
 
			skipBytes = 0; //prep for next phase of parse
 
			numBytes = 0;
 
		}
 
		else
 
		{
 
			latitude[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
		}
 
	}
 
	
 
	//parse GGA longitude data
 
	else if (decodeState == GGA_LONGITUDE)
 
	{
 
		if (byte == ',' && skipBytes == 0) //discard this byte
 
		{
 
			skipBytes = 1;
 
		}
 
		else if (byte == ',') //end of latitude data
 
		{
 
			decodeState = GGA_QUALITY;
 
			numBytes = 0;
 
		}
 
		else
 
		{
 
			longitude[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
		}
 
	}
 
	
 
	//parse GGA quality data
 
	else if (decodeState = GGA_QUALITY)
 
	{
 
		if (byte = ',')//end of quality data
 
		{
 
			decodeState = GGA_SATELLITES;
 
			skipBytes = 0; //prep for next phase of parse
 
		}
 
		else
 
		{
 
			quality = byte; //maybe reset if invalid data ??
 
		}
 
	}
 
	
 
	//parse GGA number of satellites data
 
	else if (decodeState = GGA_SATELLITES)
 
	{
 
		if (byte = ',')//end of data
 
		{
 
			decodeState = GGA_HDOP;
 
			skipBytes = 0; //prep for next phase of parse
 
			numBytes = 0;
 
		}
 
		else //store data
 
		{
 
			numSatellites[numBytes] = byte;
 
			numBytes++;
 
		}
 
	}
 
	
 
	//parse GGA HDOP data
 
	else if (decodeState = GGA_HDOP)
 
	{
 
		if (byte = ',')//end of data
 
		{
 
			decodeState = GGA_ALTITUDE;
 
			skipBytes = 0; //prep for next phase of parse
 
			numBytes = 0;
 
		}
 
		else //store data
 
		{
 
			hdop[numBytes] = byte; //store byte of data
 
			numBytes++;
 
		}
 
	}
 
	
 
	//parse GGA altitude data
 
	else if (decodeState = GGA_ALTITUDE)
 
	{
 
		if (byte = ',')//end of data
 
		{
 
			decodeState = GGA_WGS84;
 
			skipBytes = 0; //prep for next phase of parse
 
			numBytes = 0;
 
		}
 
		else //store data
 
		{
 
			altitude[numBytes] = byte;
 
			numBytes++;
 
		}
 
	}
 
	
 
	//parse GGA WGS84 Height data
 
	else if (decodeState = GGA_WGS84)
 
	{
 
		if (byte = ',')//end of data
 
		{
 
			decodeState = GGA_LAST_UPDATE;
 
			skipBytes = 0; //prep for next phase of parse
 
			numBytes = 0;
 
		}
 
		else //store data
 
		{
 
			wgs84Height[numBytes] = byte;
 
			numBytes++;
 
		}
 
	}
 
	
 
	//parse GGA last DGPS update data
 
	else if (decodeState = GGA_LAST_UPDATE)
 
	{
 
		if (byte = ',')//end of data
 
		{
 
			decodeState = GGA_STATION_ID;
 
			skipBytes = 0; //prep for next phase of parse
 
			numBytes = 0;
 
		}
 
		else //store data - this should be blank
 
		{
 
			lastUpdated[numBytes] = byte;
 
			numBytes++;
 
		}
 
	}
 
	
 
	//parse GGA DGPS station ID data
 
	else if (decodeState = GGA_STATION_ID)
 
	{
 
		if (byte = ',')//end of data
 
		{
 
			decodeState = GGA_CHECKSUM;
 
			skipBytes = 0; //prep for next phase of parse
 
			numBytes = 0;
 
		}
 
		else //store data - this should be blank
 
		{
 
			stationID[numBytes] = byte;
 
			numBytes++;
 
		}
 
	}
 
	
 
	//parse GGA checksum data
 
	else if (decodeState = GGA_CHECKSUM)
 
	{
 
		if (byte = ',')//end of data - terminating character ??
 
		{
 
			decodeState = INITIALIZE;
 
			skipBytes = 0; //prep for next phase of parse
 
			numBytes = 0;
 
		}
 
		else //store data
 
		{
 
			checksum[numBytes] = byte;
 
			numBytes++;
 
		}
 
	}
 
	
 
}
 

	
 
*/
 
/// MKa GPS transmission parser END
 
\ No newline at end of file
master/master/master.c
Show inline comments
 
/*
 
 * Master Firmware
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 

	
 

	
 
#include "config.h"
 

	
 
#include <avr/io.h>
 
#include <util/delay.h>
 
#include <avr/wdt.h>
 
#include <avr/interrupt.h>
 

	
 
#include "lib/serial.h"
 
#include "lib/aprs.h"
 
#include "lib/afsk.h"
 
#include "lib/led.h"
 
#include "lib/logger.h"
 
#include "lib/watchdog.h"
 
#include "lib/sd/sd_raw_config.h"
 
#include "lib/looptime.h"
 

	
 
void micro_setup() {
 

	
 
}
 

	
 
int main(void)
 
{
 
    
 
	// Initialize. If this takes more than 4 seconds, be sure to reset the WDT
 
	time_setup();
 
	micro_setup();
 
	watchdog_setup();
 
	led_setup();
 
	serial_setup(); // Config serial ports
 
	serial0_setup(); // Config serial ports
 
	serial1_setup(); // Config serial ports
 
	logger_setup(); // this takes a few ms
 
	afsk_setup(); // can take a few ms
 
	
 
	
 
	//led_on(POWER);
 
	led_on(POWER);
 
	
 
	uint16_t ctr1 = 0;
 
	uint16_t ctr2 = 255;
 
		
 
	char logbuf[32];
 
	
 
	uint32_t lastAprsBroadcast = 0;
 
	uint32_t lastLog = 0;
 
	
 
	while(1)
 
    {
 
		
 
		if(time_millis() - lastLog > 1000) {
 
		led_on(STAT);
 
		//sprintf(logbuf, "%d,%d,%d,%d,%d,%d\n", time_millis(),5*ctr1,ctr2, 12*ctr2,43*ctr1,5*ctr2);
 
		sprintf(logbuf, "%d,\n", time_millis());
 
			sprintf(logbuf, "%lu,%u,%u,%u,%u,%u\r\n", time_millis(),5*ctr1,ctr2, 12*ctr2,43*ctr1,5*ctr2);
 
		logger_log(logbuf);
 
			serial0_sendString("I am serial port 0!\r\n");
 
			serial1_sendString("I am serial port 1!\r\n");
 
		led_off(STAT);
 
			lastLog = time_millis();
 
		}		
 
		
 
		// Wait for transmission to complete before starting another.
 
		// Hopefully this will never delay because it should issue on a timed schedule. Software timers!
 
		
 
		// 8 second periodic for APRS transmission
 
		// for some reason this seems to lock up and the WDT resets everything when the period exceeds 8 seconds. Which is the WDTimeout. Weird.
 
		// If we want ~8+ seconds, then we'll need to do something fun here. Maybe reset the wdt...
 
		if(time_millis() - lastAprsBroadcast > 10000) {
 
		while(afsk_busy());
 
		aprs_send(); // non-blocking
 
			lastAprsBroadcast = time_millis();
 
		}			
 
		
 
		ctr1++;
 
		ctr2-=6;
 
		wdt_reset();
 
    }
 
}
 
\ No newline at end of file
0 comments (0 inline, 0 general)