Changeset - fb9fb20b39da
[Not reviewed]
default
0 8 0
ethanzonca@CL-ENS241-08.cedarville.edu - 12 years ago 2013-01-18 16:53:44
ethanzonca@CL-ENS241-08.cedarville.edu
Fixed issue where timeouts were not functional, number of discovered nodes now displayed on center LEDs.
8 files changed with 69 insertions and 64 deletions:
0 comments (0 inline, 0 general)
master/master/config.h
Show inline comments
 
@@ -17,7 +17,7 @@
 
// Module config (master.c)
 
// --------------------------------------------------------------------------
 
 
#define DEBUG_OUTPUT
 
//#define DEBUG_OUTPUT
 
 
#define F_CPU 11059200
 
#define MODULE_ID '1'
master/master/lib/boardtemp.c
Show inline comments
 
@@ -14,7 +14,7 @@
 
#include "boardtemp.h"
 
#include "i2c.h"
 
 
int8_t	boardTemp;	// Board Temperature (from i2c)
 
int8_t	boardTemp = 255;	// Board Temperature (from i2c)
 

	
 
void sensors_readBoardTemp()
 
{
master/master/lib/gps.c
Show inline comments
 
@@ -13,8 +13,6 @@
 
#include "../config.h"
 
#include "led.h"
 

	
 

	
 
 
// Circular buffer for incoming data
 
uint8_t nmeaBuffer[NMEABUFFER_SIZE];
 
 
@@ -24,15 +22,6 @@ uint8_t nmeaBufferParsePosition = 0;
 
// Location of receive byte interrupt in the buffer
 
volatile uint16_t nmeaBufferDataPosition = 0;
 
 

	
 
/*
 
volatile uint8_t charTest;
 
ISR(USART1_RX_vect)
 
{
 
	serial0_sendChar(UDR1);
 
	
 
}*/
 

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

	
 
@@ -101,9 +90,6 @@ char variation[9];	//xxx.xb
 
int calculatedChecksum;
 
int receivedChecksum;
 

	
 
char convertBuf1[15];
 
char convertBuf2[15];
 

	
 
// transmission state machine
 
enum decodeState {
 
	//shared fields
 
@@ -279,15 +265,6 @@ void parse_gps_transmission(void){
 
				
 
				latitude[7] = 0x00; // null terminate
 
				
 
				
 
				// First 2 bytes
 
				//convertBuf1[0] = latitude[0];
 
				//convertBuf1[1] = latitude[1];
 
				//convertBuf1[2] = '\0';
 
				//strncpy(convertBuf2, latitude, 7);
 
				//convertBuf2[7] = '\0';
 
				
 
				
 
				setParserState(GGA_LONGITUDE);
 
				skipBytes = 0; //prep for next phase of parse
 
				numBytes = 0;
master/master/lib/led.c
Show inline comments
 
@@ -36,9 +36,15 @@ void led_off(uint8_t led)
 
	*(ledList[led].port) &= ~(1<<ledList[led].pin);
 
}
 
 
void led_toggle(uint8_t led)
 
{
 
	*(ledList[led].port) ^= (1<<ledList[led].pin);
 
}
 
 
// Flashes error LED a set amount of times, then leaves it on
 
void led_errorcode(uint8_t code) 
 
{
 
	led_off(LED_ERROR);
 
	_delay_ms(400);
 
	for(int i=0; i<code; i++) 
 
	{
 
@@ -49,4 +55,35 @@ void led_errorcode(uint8_t code)
 
	}
 
	_delay_ms(400);
 
	led_on(LED_ERROR);
 
}
 
 

	
 
uint8_t ctr = 0;
 
void led_spin() {
 
	
 
	if(ctr == 0) {
 
		led_on(LED_ACT0);
 
		led_off(LED_ACT1);
 
		led_off(LED_ACT2);
 
		led_off(LED_ACT3);
 
	}
 
	else if (ctr == 1) {
 
		led_on(LED_ACT1);
 
		led_off(LED_ACT0);
 
		led_off(LED_ACT2);
 
		led_off(LED_ACT3);
 
	}
 
	else if (ctr == 2) {
 
		led_on(LED_ACT2);
 
		led_off(LED_ACT1);
 
		led_off(LED_ACT0);
 
		led_off(LED_ACT3);
 
	}
 
	else if (ctr == 3) {
 
		led_on(LED_ACT3);
 
		led_off(LED_ACT1);
 
		led_off(LED_ACT2);
 
		led_off(LED_ACT0);
 
	}
 
	ctr = (ctr + 1) % 4;
 
}
 
\ No newline at end of file
master/master/lib/led.h
Show inline comments
 
@@ -61,6 +61,8 @@ static led_t ledList[] = {
 
void led_setup();
 
void led_on(uint8_t led);
 
void led_off(uint8_t led);
 
void led_toggle(uint8_t led);
 
void led_errorcode(uint8_t code);
 
void led_spin();
 
 
#endif /* LED_H_ */
master/master/lib/logger.c
Show inline comments
 
@@ -38,7 +38,10 @@ void logger_setup()
 
	if(!sd_raw_init())
 
	{
 
		// Initializing SD card failed!
 
		#ifdef DEBUG_OUTPUT
 
		serial0_sendString("SD> Error initializing.\r\n");
 
		#endif
 
		
 
		led_errorcode(ERROR_SD_INIT);
 
		return;
 
	}
 
@@ -52,7 +55,10 @@ void logger_setup()
 
	// Check that partition was created correctly
 
	if(!partition)
 
	{
 
		#ifdef DEBUG_OUTPUT
 
		serial0_sendString("SD> Error opening partition.\r\n");
 
		#endif
 
		
 
		// Error opening partition. MBR might be screwed up.
 
		led_errorcode(ERROR_SD_PARTITION);
 
		return;
master/master/lib/slavesensors.c
Show inline comments
 
@@ -17,6 +17,7 @@
 
#include "serparser.h"
 
#include "slavesensors.h"
 
#include "led.h"
 
#include "looptime.h"
 
#include <util/delay.h>
 
#include <avr/wdt.h>
 

	
 
@@ -74,11 +75,14 @@ void slavesensors_network_scan() {
 
	
 
	int atOK;
 
	
 
	#ifdef DEBUG_OUTPUT
 
	serial0_sendString("Beginning network scan...\r\n\r\n");
 
	#endif
 
	
 
	_delay_ms(500); // xbee warmup
 
	wdt_reset();
 
	
 
	led_on(LED_ACTIVITY);
 
	atOK = slavesensors_enterAT();
 
		
 
	char nameString[20] = "NONE";
 
@@ -91,6 +95,7 @@ void slavesensors_network_scan() {
 
	//todo
 
	if(atOK == 0)
 
	{
 
		led_on(LED_STATUS);
 
		serial0_sendString("ATND");
 
		serial0_sendChar(0x0D);
 
		
 
@@ -103,7 +108,6 @@ void slavesensors_network_scan() {
 
			}
 
			wdt_reset();
 
		}
 
		
 
		// Scan data end when newline by itself ("")	
 
		int lineCount = 0;	
 
	
 
@@ -142,11 +146,26 @@ void slavesensors_network_scan() {
 

	
 
	}
 
	
 
	// Display number of found nodes on spinning indicator
 
	switch(nodeCount) {
 
		case 0:
 
			break;
 
		case 3:
 
			led_on(LED_ACT2);
 
			_delay_ms(100);
 
		case 2:
 
			led_on(LED_ACT1);
 
			_delay_ms(100);	
 
		case 1:
 
			led_on(LED_ACT0);
 
			_delay_ms(100);
 
	}
 
	
 
	led_on(LED_SIDEBOARD);
 
	_delay_ms(200);
 
	led_off(LED_SIDEBOARD);
 

	
 
	#ifdef DEBUG_NETWORKSCAN
 
	#ifdef DEBUG_OUTPUT
 
	serial0_sendString("Discovered: \r\n");
 
	for(int i=0; i<nodeCount; i++) {
 
		snprintf(debugBuf, 64, "  %s - %s%s\r\n", slaveNames[i],slaveAddressHigh,slaveAddressLow[i]);
 
@@ -158,13 +177,6 @@ void slavesensors_network_scan() {
 
	}
 
	#endif
 
	
 
	
 
	// Wait for response
 
	// will be multiple values separated by <CR>
 
	// 9 data lines per node, <CR> terminated, followed by a new line with only <CR> at the end of all nodes.
 
	
 
	// <CR> followed by another <CR> signifies end of scan data
 
	
 
	for(int i=0; i<nodeCount; i++) 
 
	{
 
		if(strcmp(slaveNames[i], XBEE_LOGDEST_NAME) == 0) 
master/master/master.c
Show inline comments
 
@@ -79,35 +79,6 @@ int main(void)
 
	// Write CSV header to SD card
 
	logger_log("ProgramTime,LastAprsBroadcast,LastLog\n");
 
	
 
	uint8_t ctr = 0;
 
	void spin() {
 
		
 
		if(ctr == 0) {
 
			led_on(LED_ACT0);
 
			led_off(LED_ACT1);
 
			led_off(LED_ACT2);
 
			led_off(LED_ACT3);
 
		}			
 
		else if (ctr == 1) {
 
			led_on(LED_ACT1);
 
			led_off(LED_ACT0);
 
			led_off(LED_ACT2);
 
			led_off(LED_ACT3);
 
		}			
 
		else if (ctr == 2) {
 
			led_on(LED_ACT2);
 
			led_off(LED_ACT1);
 
			led_off(LED_ACT0);
 
			led_off(LED_ACT3);
 
		}			
 
		else if (ctr == 3) {
 
			led_on(LED_ACT3);
 
			led_off(LED_ACT1);
 
			led_off(LED_ACT2);
 
			led_off(LED_ACT0);
 
		}			
 
		ctr = (ctr + 1) % 4;
 
	}
 
	
 
	serial1_ioff();
 
	
 
@@ -116,7 +87,7 @@ int main(void)
 
		
 
		// Periodic: LED execution indicator
 
		if(time_millis() - lastLedCycle > LEDCYCLE_RATE) {
 
			spin();
 
			led_spin();
 
			
 
			if(!afsk_busy())
 
				serial1_ion();
0 comments (0 inline, 0 general)