Skip to content

Instantly share code, notes, and snippets.

@kichMan
Last active July 1, 2022 21:17
Show Gist options
  • Save kichMan/294277e7b0464251a58a14ca426c1d12 to your computer and use it in GitHub Desktop.
Save kichMan/294277e7b0464251a58a14ca426c1d12 to your computer and use it in GitHub Desktop.
ATtiny10. Hello World!
#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;
}
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