Files @ 9e3e1986377f
Branch filter:

Location: seniordesign-firmware/master/master/lib/led.c

ethanzonca@CL-ENS241-08.cedarville.edu
Fixed LED for AT mode OK identification
/*
 * Master Firmware: Status and Error LED Handler
 *
 * Wireless Observational Modular Aerial Network
 * 
 * Ethan Zonca
 * Matthew Kanning
 * Kyle Ripperger
 * Matthew Kroening
 *
 */

#include "../config.h"
#include <avr/io.h>
#include <util/delay.h>
#include "led.h"

// Configure port direction and initial state of LEDs
void led_setup() 
{
	for(int i=0; i<NUM_LEDS; i++)  {
		*(ledList[i].direction) |= (1<<ledList[i].pin); // set pin to output
		*(ledList[i].port) &= ~(1<<ledList[i].pin); // set pin low
	}
}

// Turn the specified LED on
void led_on(uint8_t led) 
{
	*(ledList[led].port) |= (1<<ledList[led].pin);
}

	// Turn the specified LED off
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++) 
	{
		led_on(LED_ERROR);
		_delay_ms(150);
		led_off(LED_ERROR);
		_delay_ms(150);
	}
	_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;
}