arduino-0018-windows
This commit is contained in:
parent
157fd6f1a1
commit
f39fc49523
5182 changed files with 950586 additions and 0 deletions
|
@ -0,0 +1,145 @@
|
|||
PRG = demo
|
||||
OBJ = demo.o
|
||||
#MCU_TARGET = at90s2313
|
||||
#MCU_TARGET = at90s2333
|
||||
#MCU_TARGET = at90s4414
|
||||
#MCU_TARGET = at90s4433
|
||||
#MCU_TARGET = at90s4434
|
||||
#MCU_TARGET = at90s8515
|
||||
#MCU_TARGET = at90s8535
|
||||
#MCU_TARGET = atmega128
|
||||
#MCU_TARGET = atmega1280
|
||||
#MCU_TARGET = atmega1281
|
||||
#MCU_TARGET = atmega1284p
|
||||
#MCU_TARGET = atmega16
|
||||
#MCU_TARGET = atmega163
|
||||
#MCU_TARGET = atmega164p
|
||||
#MCU_TARGET = atmega165
|
||||
#MCU_TARGET = atmega165p
|
||||
#MCU_TARGET = atmega168
|
||||
#MCU_TARGET = atmega169
|
||||
#MCU_TARGET = atmega169p
|
||||
#MCU_TARGET = atmega2560
|
||||
#MCU_TARGET = atmega2561
|
||||
#MCU_TARGET = atmega32
|
||||
#MCU_TARGET = atmega324p
|
||||
#MCU_TARGET = atmega325
|
||||
#MCU_TARGET = atmega3250
|
||||
#MCU_TARGET = atmega329
|
||||
#MCU_TARGET = atmega3290
|
||||
#MCU_TARGET = atmega48
|
||||
#MCU_TARGET = atmega64
|
||||
#MCU_TARGET = atmega640
|
||||
#MCU_TARGET = atmega644
|
||||
#MCU_TARGET = atmega644p
|
||||
#MCU_TARGET = atmega645
|
||||
#MCU_TARGET = atmega6450
|
||||
#MCU_TARGET = atmega649
|
||||
#MCU_TARGET = atmega6490
|
||||
MCU_TARGET = atmega8
|
||||
#MCU_TARGET = atmega8515
|
||||
#MCU_TARGET = atmega8535
|
||||
#MCU_TARGET = atmega88
|
||||
#MCU_TARGET = attiny2313
|
||||
#MCU_TARGET = attiny24
|
||||
#MCU_TARGET = attiny25
|
||||
#MCU_TARGET = attiny26
|
||||
#MCU_TARGET = attiny261
|
||||
#MCU_TARGET = attiny44
|
||||
#MCU_TARGET = attiny45
|
||||
#MCU_TARGET = attiny461
|
||||
#MCU_TARGET = attiny84
|
||||
#MCU_TARGET = attiny85
|
||||
#MCU_TARGET = attiny861
|
||||
OPTIMIZE = -O2
|
||||
|
||||
DEFS =
|
||||
LIBS =
|
||||
|
||||
# You should not have to change anything below here.
|
||||
|
||||
CC = avr-gcc
|
||||
|
||||
# Override is only needed by avr-lib build system.
|
||||
|
||||
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
|
||||
override LDFLAGS = -Wl,-Map,$(PRG).map
|
||||
|
||||
OBJCOPY = avr-objcopy
|
||||
OBJDUMP = avr-objdump
|
||||
|
||||
all: $(PRG).elf lst text eeprom
|
||||
|
||||
$(PRG).elf: $(OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
# dependency:
|
||||
demo.o: demo.c iocompat.h
|
||||
|
||||
clean:
|
||||
rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak
|
||||
rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
|
||||
|
||||
lst: $(PRG).lst
|
||||
|
||||
%.lst: %.elf
|
||||
$(OBJDUMP) -h -S $< > $@
|
||||
|
||||
# Rules for building the .text rom images
|
||||
|
||||
text: hex bin srec
|
||||
|
||||
hex: $(PRG).hex
|
||||
bin: $(PRG).bin
|
||||
srec: $(PRG).srec
|
||||
|
||||
%.hex: %.elf
|
||||
$(OBJCOPY) -j .text -j .data -O ihex $< $@
|
||||
|
||||
%.srec: %.elf
|
||||
$(OBJCOPY) -j .text -j .data -O srec $< $@
|
||||
|
||||
%.bin: %.elf
|
||||
$(OBJCOPY) -j .text -j .data -O binary $< $@
|
||||
|
||||
# Rules for building the .eeprom rom images
|
||||
|
||||
eeprom: ehex ebin esrec
|
||||
|
||||
ehex: $(PRG)_eeprom.hex
|
||||
ebin: $(PRG)_eeprom.bin
|
||||
esrec: $(PRG)_eeprom.srec
|
||||
|
||||
%_eeprom.hex: %.elf
|
||||
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ \
|
||||
|| { echo empty $@ not generated; exit 0; }
|
||||
|
||||
%_eeprom.srec: %.elf
|
||||
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ \
|
||||
|| { echo empty $@ not generated; exit 0; }
|
||||
|
||||
%_eeprom.bin: %.elf
|
||||
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ \
|
||||
|| { echo empty $@ not generated; exit 0; }
|
||||
|
||||
# Every thing below here is used by avr-libc's build system and can be ignored
|
||||
# by the casual user.
|
||||
|
||||
FIG2DEV = fig2dev
|
||||
EXTRA_CLEAN_FILES = *.hex *.bin *.srec
|
||||
|
||||
dox: eps png pdf
|
||||
|
||||
eps: $(PRG).eps
|
||||
png: $(PRG).png
|
||||
pdf: $(PRG).pdf
|
||||
|
||||
%.eps: %.fig
|
||||
$(FIG2DEV) -L eps $< $@
|
||||
|
||||
%.pdf: %.fig
|
||||
$(FIG2DEV) -L pdf $< $@
|
||||
|
||||
%.png: %.fig
|
||||
$(FIG2DEV) -L png $< $@
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <joerg@FreeBSD.ORG> wrote this file. As long as you retain this notice you
|
||||
* can do whatever you want with this stuff. If we meet some day, and you think
|
||||
* this stuff is worth it, you can buy me a beer in return. Joerg Wunsch
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* Simple AVR demonstration. Controls a LED that can be directly
|
||||
* connected from OC1/OC1A to GND. The brightness of the LED is
|
||||
* controlled with the PWM. After each period of the PWM, the PWM
|
||||
* value is either incremented or decremented, that's all.
|
||||
*
|
||||
* $Id: demo.c,v 1.9 2006/01/05 21:30:10 joerg_wunsch Exp $
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/sleep.h>
|
||||
|
||||
#include "iocompat.h" /* Note [1] */
|
||||
|
||||
enum { UP, DOWN };
|
||||
|
||||
ISR (TIMER1_OVF_vect) /* Note [2] */
|
||||
{
|
||||
static uint16_t pwm; /* Note [3] */
|
||||
static uint8_t direction;
|
||||
|
||||
switch (direction) /* Note [4] */
|
||||
{
|
||||
case UP:
|
||||
if (++pwm == TIMER1_TOP)
|
||||
direction = DOWN;
|
||||
break;
|
||||
|
||||
case DOWN:
|
||||
if (--pwm == 0)
|
||||
direction = UP;
|
||||
break;
|
||||
}
|
||||
|
||||
OCR = pwm; /* Note [5] */
|
||||
}
|
||||
|
||||
void
|
||||
ioinit (void) /* Note [6] */
|
||||
{
|
||||
/* Timer 1 is 10-bit PWM (8-bit PWM on some ATtinys). */
|
||||
TCCR1A = TIMER1_PWM_INIT;
|
||||
/*
|
||||
* Start timer 1.
|
||||
*
|
||||
* NB: TCCR1A and TCCR1B could actually be the same register, so
|
||||
* take care to not clobber it.
|
||||
*/
|
||||
TCCR1B |= TIMER1_CLOCKSOURCE;
|
||||
/*
|
||||
* Run any device-dependent timer 1 setup hook if present.
|
||||
*/
|
||||
#if defined(TIMER1_SETUP_HOOK)
|
||||
TIMER1_SETUP_HOOK();
|
||||
#endif
|
||||
|
||||
/* Set PWM value to 0. */
|
||||
OCR = 0;
|
||||
|
||||
/* Enable OC1 as output. */
|
||||
DDROC = _BV (OC1);
|
||||
|
||||
/* Enable timer 1 overflow interrupt. */
|
||||
TIMSK = _BV (TOIE1);
|
||||
sei ();
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
|
||||
ioinit ();
|
||||
|
||||
/* loop forever, the interrupts are doing the rest */
|
||||
|
||||
for (;;) /* Note [7] */
|
||||
sleep_mode();
|
||||
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <joerg@FreeBSD.ORG> wrote this file. As long as you retain this notice you
|
||||
* can do whatever you want with this stuff. If we meet some day, and you think
|
||||
* this stuff is worth it, you can buy me a beer in return. Joerg Wunsch
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* IO feature compatibility definitions for various AVRs.
|
||||
*
|
||||
* $Id: iocompat.h,v 1.6.2.1 2008/03/17 22:08:46 joerg_wunsch Exp $
|
||||
*/
|
||||
|
||||
#if !defined(IOCOMPAT_H)
|
||||
#define IOCOMPAT_H 1
|
||||
|
||||
/*
|
||||
* Device-specific adjustments:
|
||||
*
|
||||
* Supply definitions for the location of the OCR1[A] port/pin, the
|
||||
* name of the OCR register controlling the PWM, and adjust interrupt
|
||||
* vector names that differ from the one used in demo.c
|
||||
* [TIMER1_OVF_vect].
|
||||
*/
|
||||
#if defined(__AVR_AT90S2313__)
|
||||
# define OC1 PB3
|
||||
# define OCR OCR1
|
||||
# define DDROC DDRB
|
||||
# define TIMER1_OVF_vect TIMER1_OVF1_vect
|
||||
#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__)
|
||||
# define OC1 PB1
|
||||
# define DDROC DDRB
|
||||
# define OCR OCR1
|
||||
#elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || \
|
||||
defined(__AVR_AT90S4434__) || defined(__AVR_AT90S8535__) || \
|
||||
defined(__AVR_ATmega163__) || defined(__AVR_ATmega8515__) || \
|
||||
defined(__AVR_ATmega8535__) || \
|
||||
defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || \
|
||||
defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || \
|
||||
defined(__AVR_ATmega1284P__)
|
||||
# define OC1 PD5
|
||||
# define DDROC DDRD
|
||||
# define OCR OCR1A
|
||||
# if !defined(TIMSK) /* new ATmegas */
|
||||
# define TIMSK TIMSK1
|
||||
# endif
|
||||
#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega48__) || \
|
||||
defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__)
|
||||
# define OC1 PB1
|
||||
# define DDROC DDRB
|
||||
# define OCR OCR1A
|
||||
# if !defined(TIMSK) /* ATmega48/88/168 */
|
||||
# define TIMSK TIMSK1
|
||||
# endif /* !defined(TIMSK) */
|
||||
#elif defined(__AVR_ATtiny2313__)
|
||||
# define OC1 PB3
|
||||
# define OCR OCR1A
|
||||
# define DDROC DDRB
|
||||
#elif defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || \
|
||||
defined(__AVR_ATtiny84__)
|
||||
# define OC1 PA6
|
||||
# define DDROC DDRA
|
||||
# if !defined(OCR1A)
|
||||
# /* work around misspelled name in avr-libc 1.4.[0..1] */
|
||||
# define OCR OCRA1
|
||||
# else
|
||||
# define OCR OCR1A
|
||||
# endif
|
||||
# define TIMSK TIMSK1
|
||||
# define TIMER1_OVF_vect TIM1_OVF_vect /* XML and datasheet mismatch */
|
||||
#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || \
|
||||
defined(__AVR_ATtiny85__)
|
||||
/* Timer 1 is only an 8-bit timer on these devices. */
|
||||
# define OC1 PB1
|
||||
# define DDROC DDRB
|
||||
# define OCR OCR1A
|
||||
# define TCCR1A TCCR1
|
||||
# define TCCR1B TCCR1
|
||||
# define TIMER1_OVF_vect TIM1_OVF_vect
|
||||
# define TIMER1_TOP 255 /* only 8-bit PWM possible */
|
||||
# define TIMER1_PWM_INIT _BV(PWM1A) | _BV(COM1A1)
|
||||
# define TIMER1_CLOCKSOURCE _BV(CS12) /* use 1/8 prescaler */
|
||||
#elif defined(__AVR_ATtiny26__)
|
||||
/* Rather close to ATtinyX5 but different enough for its own section. */
|
||||
# define OC1 PB1
|
||||
# define DDROC DDRB
|
||||
# define OCR OCR1A
|
||||
# define TIMER1_OVF_vect TIMER1_OVF1_vect
|
||||
# define TIMER1_TOP 255 /* only 8-bit PWM possible */
|
||||
# define TIMER1_PWM_INIT _BV(PWM1A) | _BV(COM1A1)
|
||||
# define TIMER1_CLOCKSOURCE _BV(CS12) /* use 1/8 prescaler */
|
||||
/*
|
||||
* Without setting OCR1C to TOP, the ATtiny26 does not trigger an
|
||||
* overflow interrupt in PWM mode.
|
||||
*/
|
||||
# define TIMER1_SETUP_HOOK() OCR1C = 255
|
||||
#elif defined(__AVR_ATtiny261__) || defined(__AVR_ATtiny461__) || \
|
||||
defined(__AVR_ATtiny861__)
|
||||
# define OC1 PB1
|
||||
# define DDROC DDRB
|
||||
# define OCR OCR1A
|
||||
# define TIMER1_PWM_INIT _BV(WGM10) | _BV(PWM1A) | _BV(COM1A1)
|
||||
/*
|
||||
* While timer 1 could be operated in 10-bit mode on these devices,
|
||||
* the handling of the 10-bit IO registers is more complicated than
|
||||
* that of the 16-bit registers of other AVR devices (no combined
|
||||
* 16-bit IO operations possible), so we restrict this demo to 8-bit
|
||||
* mode which is pretty standard.
|
||||
*/
|
||||
# define TIMER1_TOP 255
|
||||
# define TIMER1_CLOCKSOURCE _BV(CS12) /* use 1/8 prescaler */
|
||||
#elif defined(__AVR_ATmega32__) || defined(__AVR_ATmega16__)
|
||||
# define OC1 PD5
|
||||
# define DDROC DDRD
|
||||
# define OCR OCR1A
|
||||
#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) || \
|
||||
defined(__AVR_ATmega165__) || defined(__AVR_ATmega169__) || \
|
||||
defined(__AVR_ATmega325__) || defined(__AVR_ATmega3250__) || \
|
||||
defined(__AVR_ATmega645__) || defined(__AVR_ATmega6450__) || \
|
||||
defined(__AVR_ATmega329__) || defined(__AVR_ATmega3290__) || \
|
||||
defined(__AVR_ATmega649__) || defined(__AVR_ATmega6490__) || \
|
||||
defined(__AVR_ATmega640__) || \
|
||||
defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \
|
||||
defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
|
||||
# define OC1 PB5
|
||||
# define DDROC DDRB
|
||||
# define OCR OCR1A
|
||||
# if !defined(PB5) /* work around missing bit definition */
|
||||
# define PB5 5
|
||||
# endif
|
||||
# if !defined(TIMSK) /* new ATmegas */
|
||||
# define TIMSK TIMSK1
|
||||
# endif
|
||||
#else
|
||||
# error "Don't know what kind of MCU you are compiling for"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Map register names for older AVRs here.
|
||||
*/
|
||||
#if !defined(COM1A1)
|
||||
# define COM1A1 COM11
|
||||
#endif
|
||||
|
||||
#if !defined(WGM10)
|
||||
# define WGM10 PWM10
|
||||
# define WGM11 PWM11
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Provide defaults for device-specific macros unless overridden
|
||||
* above.
|
||||
*/
|
||||
#if !defined(TIMER1_TOP)
|
||||
# define TIMER1_TOP 1023 /* 10-bit PWM */
|
||||
#endif
|
||||
|
||||
#if !defined(TIMER1_PWM_INIT)
|
||||
# define TIMER1_PWM_INIT _BV(WGM10) | _BV(WGM11) | _BV(COM1A1)
|
||||
#endif
|
||||
|
||||
#if !defined(TIMER1_CLOCKSOURCE)
|
||||
# define TIMER1_CLOCKSOURCE _BV(CS10) /* full clock */
|
||||
#endif
|
||||
|
||||
#endif /* !defined(IOCOMPAT_H) */
|
Reference in a new issue