Last active
July 1, 2022 21:17
-
-
Save kichMan/294277e7b0464251a58a14ca426c1d12 to your computer and use it in GitHub Desktop.
ATtiny10. Hello World!
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 1000000UL | |
#include <avr/io.h> | |
#include <util/delay.h> | |
#define LED PB2 | |
#define ledOn() (PORTB |= _BV(LED)) | |
#define ledOff() (PORTB &= ~_BV(LED)) | |
int main (void) { | |
DDRB |= _BV(LED); | |
PORTB &= ledOff(); | |
while (1) | |
{ | |
PINB & (1 << LED) ? ledOff() : ledOn(); | |
_delay_ms(100); | |
} | |
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=attiny10 | |
PROG=avrispmkii | |
.PHONY: all flash build download clean | |
all: build | |
flash: build download clean | |
build: | |
avr-gcc -g -Os -mmcu=$(MCU) -c main.c && avr-gcc -g -mmcu=$(MCU) -o main.elf main.o && avr-objcopy -j .text -j .data -O ihex main.elf main.hex | |
download: | |
avrdude -p $(MCU) -c $(PROG) -U flash:w:main.hex | |
clean: | |
@rm -v *.hex *.o *.elf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment