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 77 insertions and 31 deletions:
0 comments (0 inline, 0 general)
master/master/lib/afsk.c
Show inline comments
 
@@ -212,22 +212,15 @@ void afsk_setup() {
 
	TCCR2B = (TCCR2B & ~(_BV(CS22) | _BV(CS21))) | _BV(CS20);
 
	
 
	// Enable interrupt when TCNT2 reaches TOP (0xFF) (p.151, 163)
 
	//TIMSK2 |= _BV(TOIE2);
 
	TIMSK2 |= 0b00000001;
 
	
 
	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
 
@@ -6,23 +6,23 @@
 
 */ 
 
 
#include <avr/io.h>
 
 
void led_setup() {
 
	// Configure ports/pins for LEDs
 
	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
 
/*
 
 * led.h
 
 *
 
 * Created: 10/25/2012 3:34:10 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
 
#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);
 
 
 
#endif /* LED_H_ */
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
 
@@ -6,57 +6,61 @@
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 

	
 

	
 
#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
 
    
 
	led_on(POWER);
 
	
 
	logger_setup(); // this takes a few ms
 
	
 
	afsk_setup();
 
	while(afsk_busy());
 
    
 
	led_on(4);
 
	uint16_t ctr1 = 0;
 
	uint16_t ctr2 = 255;
 
		
 
	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();
 

	
 
        //serial_SendCommand('0','A',0,0);
 
		aprs_send(); // non-blocking
 
		
 
		ctr1++;
 
		ctr2-=6;
 
		wdt_reset();
 
    }
 
}
 
\ No newline at end of file
master/master/master.cproj
Show inline comments
 
@@ -192,23 +192,29 @@
 
    <Compile Include="lib\serparser.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\trackuinoGPS\config.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <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" />
 
    <Folder Include="lib\trackuinoGPS" />
 
    <Folder Include="lib\sd" />
 
  </ItemGroup>
 
  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
 
</Project>
 
\ No newline at end of file
0 comments (0 inline, 0 general)