Changeset - 6060ac6db4a5
[Not reviewed]
default
0 5 0
ethanzonca@CL-SEC241-08.cedarville.edu - 12 years ago 2012-11-28 21:37:02
ethanzonca@CL-SEC241-08.cedarville.edu
Added error code functionality for error LED, added SD card errors.
5 files changed with 44 insertions and 27 deletions:
0 comments (0 inline, 0 general)
master/master/config.h
Show inline comments
 
@@ -13,6 +13,14 @@
 
#define MODULE_ID '1'
 
 
// --------------------------------------------------------------------------
 
// Error Codes config (led.c)
 
// --------------------------------------------------------------------------
 
 
// SD Card
 
#define ERROR_SD_INIT 2
 
#define ERROR_SD_PARTITION 3
 
 
// --------------------------------------------------------------------------
 
// Slave Sensors config (slavesensors.c)
 
// --------------------------------------------------------------------------
 
master/master/lib/led.c
Show inline comments
 
@@ -4,25 +4,46 @@
 
 * Created: 10/25/2012 3:34:03 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
#include "../config.h"
 
#include <avr/io.h>
 
#include <util/delay.h>
 
#include "led.h"
 
 
void led_setup() {
 
void led_setup() 
 
{
 
	// Configure ports/pins for LEDs
 
	DDRA = 0xff;
 
	//PORTA = 0x00;
 
}
 
 
void led_on(uint8_t led) {
 
void led_on(uint8_t led) 
 
{
 
	// Turn the specified LED on
 
	PORTA |= (1<<led);
 
}
 
 
void led_off(uint8_t led) {
 
void led_off(uint8_t led) 
 
{
 
	// Turn the specified LED off
 
	PORTA &= ~(1<<led);
 
}
 
 
void led_toggle(uint8_t led) {
 
void led_toggle(uint8_t led) 
 
{
 
	// Toggle the specified LED 
 
}
 
 
// Flashes error LED a set amount of times, then leaves it on
 
void led_errorcode(uint8_t code) 
 
{
 
	_delay_ms(400);
 
	for(int i=0; i<code; i++) 
 
	{
 
		led_on(ERROR);
 
		_delay_ms(150);
 
		led_off(ERROR);
 
		_delay_ms(150);
 
	}
 
	_delay_ms(400);
 
	led_on(ERROR);
 
}
 
\ No newline at end of file
master/master/lib/led.h
Show inline comments
 
@@ -18,6 +18,6 @@ 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);
 
 
#endif /* LED_H_ */
master/master/lib/logger.c
Show inline comments
 
@@ -19,17 +19,7 @@
 
#include "sd/sd_raw.h"
 
#include "sd/sd_raw_config.h"
 
#include "logger.h"
 
 
 
/* 
 
	//config edits
 
  * By changing the MCU* variables in the Makefile, you can use other Atmel
 
  * microcontrollers or different clock speeds. You might also want to change
 
  * the configuration defines in the files fat_config.h, partition_config.h,
 
  * sd_raw_config.h and sd-reader_config.h. For example, you could disable
 
  * write support completely if you only need read support.
 
 */
 
 
#include "led.h"
 
 
struct partition_struct* partition;
 
struct fat_fs_struct* fs;
 
@@ -42,7 +32,9 @@ void logger_setup()
 
 
	if(!sd_raw_init())
 
	{
 
		// initialization failed
 
		// Initializing SD card failed!
 
		// Error opening partition. MBR might be screwed up.
 
		led_errorcode(ERROR_SD_INIT);
 
		return;
 
	}
 
 
@@ -55,14 +47,9 @@ void logger_setup()
 
	// Check that partition was created correctly
 
	if(!partition)
 
	{
 
		// error
 
		// If the partition did not open, assume the storage device is a "superfloppy", i.e. has no MBR.
 
		partition = partition_open(sd_raw_read, sd_raw_read_interval, sd_raw_write, sd_raw_write_interval, -1);
 
		if(!partition)
 
		{
 
			// opening partition failed
 
			return;
 
		}
 
		// Error opening partition. MBR might be screwed up.
 
		led_errorcode(ERROR_SD_PARTITION);
 
		return;
 
	}
 
	
 
	
master/master/master.c
Show inline comments
 
@@ -51,7 +51,8 @@ int main(void)
 
	serial0_sendString("\r\n\r\n---------------------------------\r\nHAB Controller 1.0 - Initialized!\r\n---------------------------------\r\n\r\n");
 
	
 
	led_on(POWER);
 
		
 
	
 
	
 
	// Buffer for string operations
 
	char logbuf[32];
 
	const char* logBufPtr = logbuf;
0 comments (0 inline, 0 general)