Changeset - dc66341db814
[Not reviewed]
default
0 5 2
ethanzonca@CL-SEC241-08.cedarville.edu - 12 years ago 2012-11-19 20:10:19
ethanzonca@CL-SEC241-08.cedarville.edu
Added watchdog timer library, additional logger testing
7 files changed with 74 insertions and 28 deletions:
0 comments (0 inline, 0 general)
master/master/lib/afsk.c
Show inline comments
 
@@ -218,16 +218,9 @@ void afsk_setup() {
 
	DDRD = 0xff;
 
	PORTD = 0xff;
 
	
 
	// todo: init radio, maybe in main
 
	
 
	sei();
 
}
 

	
 

	
 
void afsk_test() {
 
	uint8_t flap[26] = {"abcdefghijklmnopqrstuvwxyz"};
 
	afsk_send(flap, sizeof(flap)*8);
 
	afsk_start();
 
	while(afsk_busy());
 
	_delay_ms(500);
 
}
 
}
 
\ No newline at end of file
master/master/lib/led.c
Show inline comments
 
@@ -12,17 +12,17 @@ void led_setup() {
 
	DDRA = 0xff;
 
	PORTA = 0x00;
 
}
 
 
void led_on(uint8_t led) {
 
	// Turn the specified LED on
 
	PORTA |= led;
 
	PORTA |= (1<<led);
 
}
 
 
void led_off(uint8_t led) {
 
	// Turn the specified LED off
 
	PORTA &= ~(led);
 
	PORTA &= ~(1<<led);
 
}
 
 
void led_toggle(uint8_t led) {
 
	// Toggle the specified LED 
 
}
 
\ No newline at end of file
master/master/lib/led.h
Show inline comments
 
@@ -6,15 +6,15 @@
 
 */ 
 
 
 
#ifndef LED_H_
 
#define LED_H_
 
 
#define POWER 1
 
#define ERROR 2
 
#define STAT 2
 
#define POWER PB2
 
#define ERROR PB1
 
#define STAT PB0
 
#define OK 2
 
 
void led_setup();
 
void led_on(uint8_t led);
 
void led_off(uint8_t led);
 
void led_toggle(uint8_t led);
master/master/lib/watchdog.c
Show inline comments
 
new file 100644
 
/*
 
 * watchdog.c
 
 *
 
 * Created: 11/19/2012 6:50:51 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
 
#include <avr/io.h>
 
#include <avr/interrupt.h>
 
#include <avr/wdt.h>
 
 
//initialize watchdog
 
void watchdog_setup(void)
 
{
 
	
 
	cli();
 
	wdt_reset();
 
	// Set change enable bit, enable the WDT
 
	WDTCSR = (1<<WDCE)|(1<<WDE);
 
	// Start watchdog, 4 second timeout
 
	WDTCSR = (1<<WDE)|(1<<WDP3)|(1<<WDP0);
 
	sei();
 
}
 
 
// ISR for watchdog timeout. Not currently used, interrupt is disabled.
 
ISR(WDT_vect)
 
{
 
	PORTA = 0xff;
 
}
master/master/lib/watchdog.h
Show inline comments
 
new file 100644
 
/*
 
 * watchdog.h
 
 *
 
 * Created: 11/19/2012 6:50:58 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
#ifndef WATCHDOG_H
 
#define WATCHDOG_H
 
 
void watchdog_setup(void);
 
 
#endif
 
\ No newline at end of file
master/master/master.c
Show inline comments
 
@@ -12,51 +12,55 @@
 

	
 

	
 
#include "config.h"
 

	
 
#include <avr/io.h>
 
#include <util/delay.h>
 
#include <avr/wdt.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"
 

	
 
void micro_setup() {
 
	// Generic microcontroller config options
 

	
 
}
 

	
 

	
 
int main(void)
 
{
 
	// Initialize
 
	// Initialize. If this takes more than 4 seconds, be sure to reset the WDT
 
	micro_setup();
 
	watchdog_setup();
 
	led_setup();
 

	
 
	//serial_setup(); // Config serial ports
 
	serial_setup(); // Config serial ports
 
	logger_setup(); // this takes a few ms
 
	afsk_setup(); // can take a few ms
 
	
 
	logger_setup(); // this takes a few ms
 
	led_on(POWER);
 
	
 
	afsk_setup();
 
	while(afsk_busy());
 
	uint16_t ctr1 = 0;
 
	uint16_t ctr2 = 255;
 
    
 
	led_on(4);
 
	char logbuf[32];
 
	
 
	while(1)
 
    {
 
		led_on(2);
 
		logger_log("123,43,1,2,4,3\n");
 
		led_off(2);
 
		led_on(STAT);
 
		sprintf(logbuf, "%d,%d,%d,%d,%d,%d\n", ctr1,5*ctr1,ctr2, 12*ctr2,43*ctr1,5*ctr2);
 
		logger_log(logbuf);
 
		led_off(STAT);
 
		
 
		// Wait for transmission to complete before starting another.
 
		// Hopefully this will never delay because it should issue on a timed schedule. Software timers!
 
		while(afsk_busy());
 
		aprs_send();
 
		aprs_send(); // non-blocking
 

	
 
        //serial_SendCommand('0','A',0,0);
 
		
 
		ctr1++;
 
		ctr2-=6;
 
		wdt_reset();
 
    }
 
}
 
\ No newline at end of file
master/master/master.cproj
Show inline comments
 
@@ -198,12 +198,18 @@
 
    <Compile Include="lib\trackuinoGPS\gpsMKa.c">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\trackuinoGPS\gpsMKa.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\watchdog.c">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\watchdog.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="master.c">
 
      <SubType>compile</SubType>
 
    </Compile>
 
  </ItemGroup>
 
  <ItemGroup>
 
    <Folder Include="lib" />
0 comments (0 inline, 0 general)