Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 173 → Rev 174

/avr/simple-flasher/simple-flasher.c
0,0 → 1,108
/****************************************************************************
*
* Copyright (c) 2008 Dave Hylands <dhylands@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Alternatively, this software may be distributed under the terms of BSD
* license.
*
* See README and COPYING for more details.
*
****************************************************************************/
/**
*
* @file simple-flasher.c
*
* @brief Simple LED flasher for the robostix
*
****************************************************************************/
 
/* ---- Include Files ---------------------------------------------------- */
 
#define F_CPU 16000000UL
 
#include <avr/io.h>
#include <util/delay.h>
 
/* ---- Public Variables ------------------------------------------------- */
 
/* ---- Private Constants and Types -------------------------------------- */
 
//--------------------------------------------------------------------------
// LED Constants
 
#define RED_LED_PIN 4
#define RED_LED_MASK ( 1 << RED_LED_PIN )
#define RED_LED_DDR DDRG
#define RED_LED_PORT PORTG
 
#define BLUE_LED_PIN 3
#define BLUE_LED_MASK ( 1 << BLUE_LED_PIN )
#define BLUE_LED_DDR DDRG
#define BLUE_LED_PORT PORTG
 
#define YELLOW_LED_PIN 4
#define YELLOW_LED_MASK ( 1 << YELLOW_LED_PIN )
#define YELLOW_LED_DDR DDRB
#define YELLOW_LED_PORT PORTB
 
//--------------------------------------------------------------------------
// Some convenience macros to turn the LEDs on/off.
//
// Usage: LED_ON( BLUE );
//
// to turn on the blue LED.
//
// Note: Setting the pin to 0 turns the LED on.
 
#define LED_ON( color ) do { color ## _LED_PORT &= ~color ## _LED_MASK; } while (0)
#define LED_OFF( color ) do { color ## _LED_PORT |= color ## _LED_MASK; } while (0)
 
/* ---- Private Variables ------------------------------------------------ */
 
/* ---- Functions -------------------------------------------------------- */
 
//***************************************************************************
/**
* Simple LED flasher
*/
 
int main( void )
{
int i;
int led = 0;
 
// Initialize the two LED pins
 
RED_LED_DDR |= RED_LED_MASK;
YELLOW_LED_DDR |= YELLOW_LED_MASK;
BLUE_LED_DDR |= BLUE_LED_MASK;
 
while ( 1 )
{
// Turn all of the LEDs off
 
LED_OFF( RED );
LED_OFF( BLUE );
LED_OFF( YELLOW );
 
switch ( led )
{
case 0: LED_ON( RED ); break;
case 1: LED_ON( BLUE ); break;
case 2: LED_ON( YELLOW ); break;
}
if ( ++led > 2 )
{
led = 0;
}
 
for ( i = 0; i < 100; i++ )
{
_delay_ms( 1 );
}
}
}
/avr/simple-flasher/Makefile
0,0 → 1,21
###########################################################################
#
# flasher-m168 Makefile
#
###########################################################################
 
MK_OS = avr
MK_AVR_MCU = m128
MK_AVR_FREQ = 16MHz
MK_AVR_PROGRAMMER ?= avrdude
MK_avrdude_PORT ?= /dev/ttyS0
MK_avrdude_PROG ?= avrispv2
 
# Extended fuse byte should be FB for standalone, FA for bootloader-stk500
MK_AVR_FUSES_m128 = FF C9 BF
MK_HEX_TARGET = simple-flasher
MK_SRC_FILES = simple-flasher.c
 
include ../../rules/mkRules.mk