Changeset - 6023002a8b9e
[Not reviewed]
default
0 4 0
ethanzonca@CL-SEC241-08.cedarville.edu - 12 years ago 2012-11-30 16:41:40
ethanzonca@CL-SEC241-08.cedarville.edu
Serial rate increased to 115.2, removed debug output causing freezes
4 files changed with 11 insertions and 10 deletions:
0 comments (0 inline, 0 general)
master/master/config.h
Show inline comments
 
@@ -57,14 +57,14 @@
 
#define BROADCAST_ADDR 0 
 
 
// --------------------------------------------------------------------------
 
// USART config (serial.c)
 
// --------------------------------------------------------------------------
 
 
#define USART0_BAUDRATE 9600
 
#define USART1_BAUDRATE 9600
 
#define USART0_BAUDRATE 115200
 
#define USART1_BAUDRATE 115200
 
 
 
// --------------------------------------------------------------------------
 
// AX.25 config (ax25.c)
 
// --------------------------------------------------------------------------
 

	
master/master/lib/looptime.c
Show inline comments
 
@@ -8,19 +8,19 @@
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
#include "../config.h"
 
#include "looptime.h"
 
#include <avr/io.h>
 
#include <avr/interrupt.h>
 
#include <util/delay.h>
 
 
volatile uint32_t millis = 0; // Milliseconds since initialization
 

	
 

	
 

	
 
void time_setup() 
 
{
 
	DDRA = 0xff;
 
	
 
	// Generic microcontroller config options
 
	OCR0A = 173; // Approx 172.7969 ticks per ms with 64 prescaler
 
@@ -28,13 +28,12 @@ void time_setup()
 
	TCCR0A |= (1 << WGM01) | (1 << WGM00); // Count until OCR0A, then overflow (wgm02 in the next line specifies this as well)
 
	TCCR0B |= (1 << CS01) | (1 << CS00) | (1 << WGM02); // clock div by 64
 
	TIFR0 |= ( 1 << TOV0 ); // clear pending interrupts
 
	TIMSK0 |= (1 << TOIE0); // enable overflow interrupt
 
}
 

	
 

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

	
 
uint32_t time_millis() 
master/master/lib/looptime.h
Show inline comments
 
@@ -10,12 +10,12 @@
 
 *
 
 */
 
 
#ifndef LOOPTIME_H_
 
#define LOOPTIME_H_
 
 
#include <inttypes.h>
 

	
 
void time_setup();
 

	
 
uint32_t time_millis();
 
 
#endif /* LOOPTIME_H_ */
 
\ No newline at end of file
master/master/lib/serparser.c
Show inline comments
 
@@ -29,13 +29,13 @@ volatile uint16_t bufferDataPosition = 0
 
 
// Parser state
 
uint8_t parserState = STATE_RESET;
 
uint8_t lastParserState = STATE_RESET;
 
 
// Length of current payload data (and checksum)
 
int dataLength = 0;
 
uint8_t dataLength = 0;
 
 
// Data and checksum of most recent transmission
 
char receivedPayload[MAX_PAYLOAD_LEN];
 
 
// Payload type ID of the sensor of most recent transmission
 
char receivedDataType = 0;
 
@@ -66,14 +66,14 @@ char buffmeh[16];
 
 
ISR(USART0__RX_vect)
 
{
 
	led_on(POWER);
 
	buffer[bufferDataPosition % BUFFER_SIZE] = UDR0;
 
	bufferDataPosition = (bufferDataPosition + 1) % BUFFER_SIZE;
 
	sprintf(buffmeh, "bdp: %d, bpp: %d \r\n", bufferDataPosition, bufferParsePosition);
 
	serial0_sendString((buffmeh));
 
	/*sprintf(buffmeh, "bdp: %d, bpp: %d \r\n", bufferDataPosition, bufferParsePosition);
 
	serial0_sendString((buffmeh)); */
 
}
 
 
 
 
#define DEBUG
 
 
@@ -143,12 +143,14 @@ int serparser_parse(void)
 
		else if(parserState == STATE_GETDATA)
 
		{		
 
			if (byte == ']') // End of frame
 
			{
 
				#ifdef DEBUG
 
				serial0_sendString("eof ok\r\n");
 
				sprintf(buffmeh, "recvd %d bytes data\r\n", dataLength);
 
				serial0_sendString((buffmeh));
 
				#endif
 
				if(bufferParsePosition == bufferDataPosition) 
 
				{
 
					// We are at the end of the line. No more data to parse.
 
					setParserState(STATE_RESET);
 
					return PARSERESULT_PARSEOK;
 
@@ -170,13 +172,13 @@ int serparser_parse(void)
 
				dataLength++;
 
				checksumCalc += byte;
 
				
 
				// Data buffer overrun protection
 
				if(dataLength > MAX_PAYLOAD_LEN) {
 
					#ifdef DEBUG
 
					serial0_sendString("buf ovf\r\n");
 
					serial0_sendString("data ovf\r\n");
 
					#endif
 
					setParserState(STATE_RESET);
 
					return PARSERESULT_FAIL;
 
				}
 
				else {
 
					// Set state. MUST call even though state is maintained to update parse position
0 comments (0 inline, 0 general)