Changeset - b6a1b8d502cc
[Not reviewed]
default
0 22 0
ethanzonca@CL-SEC241-08.cedarville.edu - 12 years ago 2012-11-28 21:54:02
ethanzonca@CL-SEC241-08.cedarville.edu
Significant commenting and reformatting of documents, no functional changes. [reindented APRS generator]
22 files changed with 306 insertions and 173 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
 
 */ 
 
 
/*
 
 * Master Firmware: Configuration
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
#ifndef CONFIG_H_
 
#define CONFIG_H_
 
 
// --------------------------------------------------------------------------
 
// Module config (master.c)
 
// --------------------------------------------------------------------------
 
 
#define F_CPU 11059200
 
#define MODULE_ID '1'
 
 
 
// --------------------------------------------------------------------------
 
// Error Codes config (led.c)
 
// --------------------------------------------------------------------------
 
@@ -20,6 +29,7 @@
 
#define ERROR_SD_INIT 2
 
#define ERROR_SD_PARTITION 3
 
 
 
// --------------------------------------------------------------------------
 
// Slave Sensors config (slavesensors.c)
 
// --------------------------------------------------------------------------
 
@@ -33,6 +43,7 @@
 
#define SLAVE6_SENSORS NONE
 
#define SLAVE7_SENSORS NONE
 
 
 
// --------------------------------------------------------------------------
 
// USART config (serial.c)
 
// --------------------------------------------------------------------------
 
@@ -40,6 +51,7 @@
 
#define USART0_BAUDRATE 115200
 
#define USART1_BAUDRATE 115200
 
 
 
// --------------------------------------------------------------------------
 
// AX.25 config (ax25.c)
 
// --------------------------------------------------------------------------
 
@@ -62,7 +74,7 @@
 
// - Cars:       9
 
// - Home:       0
 
// - IGate:      5
 
#define S_CALLSIGN      "MYCALL"
 
#define S_CALLSIGN      "KD8TDF"
 
#define S_CALLSIGN_ID   11
 

	
 
// Destination callsign: APRS (with SSID=0) is usually okay.
 
@@ -79,11 +91,12 @@
 
// 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"
 
#define APRS_COMMENT    "Custom payload data here, eventually..."
 
 
// Transmit the APRS sentence every X milliseconds
 
#define APRS_TRANSMIT_PERIOD 5000
 

	
 

	
 
// --------------------------------------------------------------------------
 
// Logger config (logger.c)
 
// --------------------------------------------------------------------------
master/master/lib/afsk.c
Show inline comments
 
/*
 
 * fsk.c
 
 *
 
 * Created: 10/29/2012 7:40:34 PM
 
 *  Author: ethanzonca
 
/*
 
 * Master Firmware: AFSK Generation
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 

	
 

	
 
#include "../config.h"
 
#include "afsk.h"
 

	
 
#include <stdint.h>
 
#include <stdbool.h>
 
@@ -75,35 +81,26 @@ volatile bool go = false;
 

	
 
volatile unsigned int packet_pos;                 // Next bit to be sent out
 

	
 

	
 
volatile unsigned int afsk_packet_size = 10;
 
volatile const uint8_t *afsk_packet;
 

	
 

	
 

	
 

	
 

	
 

	
 
void afsk_ptt_off() {
 
void afsk_ptt_off() 
 
{
 
	// turn ptt off
 
}
 

	
 
void afsk_ptt_on() {
 
void afsk_ptt_on() 
 
{
 
	// turn the ptt on... possibly delay based on spec
 
}
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 
ISR(TIMER2_OVF_vect) 
 
{
 
	if (go) {
 

	
 
		// If done sending packet
 
		if (packet_pos == afsk_packet_size) {
 
		if (packet_pos == afsk_packet_size) 
 
		{
 
			go = false;         // End of transmission
 
			afsk_timer_stop();  // Disable modem
 
			afsk_ptt_off();    // Release PTT
 
@@ -111,14 +108,18 @@ ISR(TIMER2_OVF_vect)
 
		}
 

	
 
		// If sent SAMPLES_PER_BAUD already, go to the next bit
 
		if (current_sample_in_baud == 0) {    // Load up next bit
 
			if ((packet_pos & 7) == 0) {          // Load up next byte
 
		if (current_sample_in_baud == 0)  // Load up next bit
 
		{   
 
			if ((packet_pos & 7) == 0) // Load up next byte
 
			{          
 
				current_byte = afsk_packet[packet_pos >> 3];
 
			}				
 
			else {
 
			else 
 
			{
 
				current_byte = current_byte / 2;  // ">>1" forces int conversion
 
			}			
 
			if ((current_byte & 1) == 0) {
 
			if ((current_byte & 1) == 0) 
 
			{
 
				// Toggle tone (1200 <> 2200)
 
				phasedelta ^= (PHASE_DELTA_1200 ^ PHASE_DELTA_2200);
 
			}
 
@@ -128,8 +129,8 @@ ISR(TIMER2_OVF_vect)
 
		uint8_t s = afsk_read_sample((phase >> 7) & (TABLE_SIZE - 1));
 
		afsk_output_sample(s);
 

	
 
		if(++current_sample_in_baud == SAMPLES_PER_BAUD) {
 
			// sounds fun when this is commented out... but why??!?!
 
		if(++current_sample_in_baud == SAMPLES_PER_BAUD) 
 
		{
 
			current_sample_in_baud = 0;
 
			packet_pos++;
 
		}
 
@@ -137,7 +138,8 @@ ISR(TIMER2_OVF_vect)
 
	}
 
}	
 

	
 
void afsk_output_sample(uint8_t s) {
 
void afsk_output_sample(uint8_t s) 
 
{
 
	OCR2B = s;
 
}
 

	
 
@@ -194,7 +196,8 @@ void afsk_send(const uint8_t *buffer, in
 
}
 

	
 

	
 
void afsk_setup() {
 
void afsk_setup() 
 
{
 
	
 
	// Source timer2 from clkIO (datasheet p.164)
 
	ASSR &= ~(_BV(EXCLK) | _BV(AS2));
master/master/lib/afsk.h
Show inline comments
 
/*
 
 * afsk.h
 
 *
 
 * Created: 10/29/2012 7:43:03 PM
 
 *  Author: ethanzonca
 
 */ 
 
/*
 
 * Master Firmware: AFSK Generation
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
 
#ifndef AFSK_H_
 
#define AFSK_H_
 
 
#include <inttypes.h>
 
 
// Private
 
void afsk_output_sample(uint8_t s);
 
void afsk_timer_start();
 
void afsk_timer_stop();
 
 
// Public
master/master/lib/aprs.c
Show inline comments
 
/*
 
 * aprs.c
 
 *
 
 * Created: 11/8/2012 3:40:57 PM
 
 *  Author: ethanzonca
 
 */ 
 
/*
 
 * Master Firmware: APRS
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
#include "../config.h"
 
#include "aprs.h"
master/master/lib/aprs.h
Show inline comments
 
/*
 
 * aprs.h
 
 *
 
 * Created: 11/8/2012 3:41:04 PM
 
 *  Author: ethanzonca
 
 */ 
 
/*
 
 * Master Firmware: APRS
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
 
#ifndef APRS_H_
master/master/lib/ax25.c
Show inline comments
 
/*
 
 * ax25.c
 
 *
 
 * Created: 10/30/2012 12:16:41 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
//Licensing: Library from the Trackuino project
 
/*
 
 * Master Firmware: AX25 Protocol
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 * Used under the GPL from the Trackuino project
 
 */
 

	
 
#include <inttypes.h>
 
#include "../config.h"
 
#include "ax25.h"
 
@@ -30,11 +35,13 @@ void update_crc(uint8_t a_bit)
 
void send_byte(uint8_t a_byte)
 
{
 
	uint8_t i = 0;
 
	while (i++ < 8) {
 
	while (i++ < 8) 
 
	{
 
		uint8_t a_bit = a_byte & 1;
 
		a_byte >>= 1;
 
		update_crc(a_bit);
 
		if (a_bit) {
 
		if (a_bit) 
 
		{
 
			// Next bit is a '1'
 
			if (packet_size >= MAX_PACKET_LEN * 8)  // Prevent buffer overrun
 
			return;
 
@@ -62,7 +69,8 @@ void ax25_send_flag()
 
{
 
	uint8_t flag = 0x7e;
 
	int i;
 
	for (i = 0; i < 8; i++, packet_size++) {
 
	for (i = 0; i < 8; i++, packet_size++) 
 
	{
 
		if (packet_size >= MAX_PACKET_LEN * 8)  // Prevent buffer overrun
 
		return;
 
		if ((flag >> i) & 1)
 
@@ -75,7 +83,8 @@ void ax25_send_flag()
 
void ax25_send_string(const char *string)
 
{
 
	int i;
 
	for (i = 0; string[i]; i++) {
 
	for (i = 0; string[i]; i++) 
 
	{
 
		ax25_send_byte(string[i]);
 
	}
 
}
 
@@ -88,11 +97,13 @@ void ax25_send_header(const struct s_add
 
	crc = 0xffff;
 
	
 
	// Send flags during TX_DELAY milliseconds (8 bit-flag = 8000/1200 ms)
 
	for (i = 0; i < TX_DELAY * 3 / 20; i++) {
 
	for (i = 0; i < TX_DELAY * 3 / 20; i++) 
 
	{
 
		ax25_send_flag();
 
	}
 
	
 
	for (i = 0; i < num_addresses; i++) {
 
	for (i = 0; i < num_addresses; i++) 
 
	{
 
		// Transmit callsign
 
		for (j = 0; addresses[i].callsign[j]; j++)
 
		send_byte(addresses[i].callsign[j] << 1);
master/master/lib/ax25.h
Show inline comments
 
/*
 
 * ax25.h
 
 *
 
 * Created: 10/30/2012 12:14:05 PM
 
 *  Author: ethanzonca
 
 */ 
 
/*
 
 * Master Firmware: AX25 Protocol
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 * Used under the GPL from the Trackuino project
 
 */
 
 
 
#ifndef AX25_H_
master/master/lib/led.c
Show inline comments
 
/*
 
 * led.c
 
 *
 
 * Created: 10/25/2012 3:34:03 PM
 
 *  Author: ethanzonca
 
 */ 
 
/*
 
 * Master Firmware: Status and Error LED Handler
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
#include "../config.h"
 
#include <avr/io.h>
 
#include <util/delay.h>
master/master/lib/led.h
Show inline comments
 
/*
 
 * led.h
 
 *
 
 * Created: 10/25/2012 3:34:10 PM
 
 *  Author: ethanzonca
 
 */ 
 
/*
 
 * Master Firmware: Status and Error LED Handler
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
 
#ifndef LED_H_
master/master/lib/logger.c
Show inline comments
 
/*
 
 * CFile1.c
 
 *
 
 * Created: 11/7/2012 8:05:44 PM
 
 *  Author: mkanning
 
 */ 
 
/*
 
 * Master Firmware: SD Card Data Logger
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
#include "../config.h"
 
#include <util/delay.h>
 
@@ -110,7 +115,8 @@ void logger_setup()
 
 
}	
 
 
void logger_log(char *buffer) {
 
void logger_log(char *buffer) 
 
{
 
	uint8_t len = strlen(buffer);
 
	if(fat_write_file(fd, (uint8_t*) buffer, len) != len)
 
	{
 
@@ -119,7 +125,8 @@ void logger_log(char *buffer) {
 
	}
 
}
 
 
void logger_closeLog() {
 
void logger_closeLog() 
 
{
 
	fat_close_file(fd);
 
	fat_close_dir(dd);
 
	fat_close(fs);
master/master/lib/logger.h
Show inline comments
 
/*
 
 * logger.h
 
 *
 
 * Created: 11/7/2012 8:06:16 PM
 
 *  Author: mkanning
 
 */ 
 
/*
 
 * Master Firmware: Status and Error LED Handler
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
 
#ifndef LOGGER_H_
master/master/lib/looptime.c
Show inline comments
 
/*
 
 * looptime.c
 
 *
 
 * Created: 11/19/2012 8:56:42 PM
 
 *  Author: ethanzonca
 
 */ 
 
/*
 
 * Master Firmware: Program Timer
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
#include "../config.h"
 
#include <avr/io.h>
 
@@ -13,7 +18,8 @@ volatile uint32_t millis = 0; // Millise
 

	
 

	
 

	
 
void time_setup() {
 
void time_setup() 
 
{
 
	DDRA = 0xff;
 
	
 
	// Generic microcontroller config options
 
@@ -26,10 +32,12 @@ void time_setup() {
 
}
 

	
 

	
 
ISR(TIMER0_OVF_vect) {
 
ISR(TIMER0_OVF_vect) 
 
{
 
	millis = millis + 1;
 
}
 

	
 
uint32_t time_millis() {
 
uint32_t time_millis() 
 
{
 
	return millis; // meh accuracy, but that's OK
 
}
master/master/lib/looptime.h
Show inline comments
 
/*
 
 * looptime.h
 
 *
 
 * Created: 11/19/2012 8:56:49 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
/*
 
 * Master Firmware: Program Timer
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
#ifndef LOOPTIME_H_
 
#define LOOPTIME_H_
master/master/lib/serial.c
Show inline comments
 
/*
 
 * serial.c
 
 *
 
 * Created: 10/25/2012 3:19:49 PM
 
 *  Author: ethanzonca
 
 */ 
 
/*
 
 * Master Firmware: USART Send/Recieve
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
#include "serial.h"
 
#include "../config.h"
 
@@ -54,14 +59,16 @@ unsigned char serial1_readChar()
 
}
 
 
void serial0_sendString(const char* stringPtr){
 
	while(*stringPtr != 0x00){
 
	while(*stringPtr != 0x00)
 
	{
 
		serial0_sendChar(*stringPtr);
 
		stringPtr++;
 
	}
 
}
 
 
void serial1_sendString(const char* stringPtr){
 
	while(*stringPtr != 0x00){
 
	while(*stringPtr != 0x00)
 
	{
 
		serial1_sendChar(*stringPtr);
 
		stringPtr++;
 
	}
 
@@ -80,7 +87,8 @@ void serial_sendCommand( char moduleID, 
 
	checkSum+=sensorID;
 
	
 
	// send data, null-terminated
 
	while(*data != 0x00){
 
	while(*data != 0x00)
 
	{
 
		serial0_sendChar(*data);
 
		checkSum += *data;
 
		data++;
 
@@ -90,7 +98,8 @@ void serial_sendCommand( char moduleID, 
 
	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
 
 */ 
 
/*
 
 * Master Firmware: USART Send/Recieve
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
 
#ifndef SERIAL_H_
master/master/lib/serparser.c
Show inline comments
 
/*
 
* serparser.c
 
*
 
* Created: 10/25/2012 8:11:43 PM
 
*  Author: ethanzonca
 
*/
 
 
/*
 
 * Master Firmware: Serial Parser
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
// ************* Macros ***************
 
#define SERIAL_RX_HASBYTES UCSR0A & _BV(RXC0)
master/master/lib/serparser.h
Show inline comments
 
/*
 
 * serparser.h
 
 *
 
 * Created: 10/25/2012 8:11:49 PM
 
 *  Author: ethanzonca
 
 */ 
 
/*
 
 * Master Firmware: Serial Parser
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
 
#ifndef SERPARSER_H_
master/master/lib/slavesensors.c
Show inline comments
 
/*
 
 * slavesensors.c
 
 *
 
 * Created: 11/27/2012 9:02:12 PM
 
 *  Author: ethanzonca
 
 */ 
 
/*
 
 * Master Firmware: Slave Sensor Data Aquisition
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
#include <avr/io.h>
 
#include <stdbool.h>
master/master/lib/slavesensors.h
Show inline comments
 
/*
 
 * slavesensors.h
 
 *
 
 * Created: 11/27/2012 9:05:47 PM
 
 *  Author: ethanzonca
 
 */ 
 
/*
 
 * Master Firmware: Slave Sensor Data Aquisition
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
 
#ifndef SLAVESENSORS_H_
master/master/lib/watchdog.c
Show inline comments
 
/*
 
 * watchdog.c
 
 *
 
 * Created: 11/19/2012 6:50:51 PM
 
 *  Author: ethanzonca
 
 */ 
 
/*
 
 * Master Firmware: Watchdog Timer
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
 
#include <avr/io.h>
master/master/lib/watchdog.h
Show inline comments
 
/*
 
 * watchdog.h
 
 *
 
 * Created: 11/19/2012 6:50:58 PM
 
 *  Author: ethanzonca
 
 */ 
 
/*
 
 * Master Firmware: Watchdog Timer
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
 
#ifndef WATCHDOG_H
 
#define WATCHDOG_H
master/master/master.c
Show inline comments
 
@@ -30,7 +30,8 @@
 
#include "lib/looptime.h"
 
#include "lib/slavesensors.h"
 

	
 
void micro_setup() {
 
void micro_setup() 
 
{
 

	
 
}
 

	
 
@@ -71,7 +72,8 @@ int main(void)
 
    {
 
		
 
		// Periodic: Logging
 
		if(time_millis() - lastLog > LOGGER_RATE) {
 
		if(time_millis() - lastLog > LOGGER_RATE) 
 
		{
 
			
 
			// TODO: Acquire data from daughterboards
 
			//       This will be complicated because we need timeouts / unreliable transmission, etc
 
@@ -91,7 +93,8 @@ int main(void)
 
		}		
 
		
 
		// Periodic: APRS transmission
 
		if(time_millis() - lastAprsBroadcast > APRS_TRANSMIT_PERIOD) {
 
		if(time_millis() - lastAprsBroadcast > APRS_TRANSMIT_PERIOD) 
 
		{
 
			while(afsk_busy());
 
			aprs_send(); // non-blocking
 
			serial0_sendString("Initiating APRS transmission...\r\n");
0 comments (0 inline, 0 general)