Last active
April 21, 2018 10:37
-
-
Save kichMan/4e4769e90efa7ca6752d793ba001ed62 to your computer and use it in GitHub Desktop.
Project build for ATmega
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define F_CPU 16000000UL | |
#include <avr/io.h> | |
#include <util/delay.h> | |
int main (void) | |
{ | |
DDRB |= _BV(PB5); | |
PORTB &= ~_BV(PB5); | |
while (1) | |
{ | |
if (PINB & (1 << PB5)) { | |
PORTB &= ~_BV(PB5); | |
} else { | |
PORTB |= _BV(PB5); | |
} | |
_delay_ms(500); | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MCU=m168p | |
MMCU=atmega168pa | |
DEVICE=avrisp2 | |
.PHONY: all flash build download clean | |
all: build | |
flash: build download clean | |
build: | |
avr-gcc -g -Os -mmcu=$(MMCU) -c main.c && avr-gcc -g -mmcu=$(MMCU) -o main.elf main.o && avr-objcopy -j .text -j .data -O ihex main.elf main.hex | |
download: | |
avrdude -p $(MCU) -c $(DEVICE) -U flash:w:main.hex | |
clean: | |
@rm -v *.hex *.o *.elf | |
erase: | |
avrdude -p $(MCU) -c $(DEVICE) -e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment