Browse Source

stale changes (> 2 years)

master
heck 7 months ago
parent
commit
a241446b46
  1. 5
      .gitignore
  2. 5
      LICENSE
  3. 8
      Makefile
  4. 6
      README.md
  5. 27
      led.c

5
.gitignore

@ -0,0 +1,5 @@
.idea
/led.elf
/led.hex
/led.o

5
LICENSE

@ -1,5 +0,0 @@
Copyright (C) YEAR by AUTHOR EMAIL
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

8
Makefile

@ -1,14 +1,12 @@
MMCU=atmega32u4
MMCU_DUDE=m32u4
.PHONY: all clean
all: flash
compile:
avr-gcc -g -Os -mmcu=$(MMCU) -c led.c
avr-gcc -g -O1 -mmcu=$(MMCU) -c led.c
link: compile
avr-gcc -g -mmcu=$(MMCU) -o led.elf led.o
@ -17,7 +15,7 @@ assemble: link
avr-objcopy -j .text -j .data -O ihex led.elf led.hex
flash: assemble
avrdude -p $(MMCU_DUDE) -c stk500 -P /dev/cu.usbserial-1220 -U flash:w:led.hex:i
avrdude -p $(MMCU_DUDE) -c stk500 -P /dev/cu.usbserial-114230 -U flash:w:led.hex:i
clean:
rm *.o

6
README.md

@ -1,2 +1,6 @@
# Hecks AVR project template
port install:
* avr-gcc
* avr-libc
* avr-dude

27
led.c

@ -1,18 +1,21 @@
#ifndef F_CPU
#define F_CPU 16000000UL // or whatever may be your frequency
#endif
#include <avr/io.h>
//#include <avr/uart.h>
#include <util/delay.h> // for _delay_ms()
int main(void) {
DDRD = 0xff;
#define F_CPU 1600000
#include <util/delay.h>
void setup() { DDRB |= (1 << PB0); }
void loop() {
while (1) {
PORTD = 0xff;
_delay_ms(100);
PORTB = PORTB ^ (1 << PORTB0);
_delay_ms(1000);
PORTD = 0x00;
_delay_ms(100);
for (long i = 0; i < 80000; i++) {
}
}
}
int main() {
setup();
loop();
}

Loading…
Cancel
Save