diff --git a/C/attiny10-test/.envrc b/C/attiny10-test/.envrc new file mode 100644 index 0000000..cbde1db --- /dev/null +++ b/C/attiny10-test/.envrc @@ -0,0 +1 @@ +use flake ../..#avr diff --git a/C/attiny10-test/.gitignore b/C/attiny10-test/.gitignore new file mode 100644 index 0000000..20596b5 --- /dev/null +++ b/C/attiny10-test/.gitignore @@ -0,0 +1,2 @@ +*.o +*.elf diff --git a/C/attiny10-test/Makefile b/C/attiny10-test/Makefile new file mode 100644 index 0000000..f327d5e --- /dev/null +++ b/C/attiny10-test/Makefile @@ -0,0 +1,12 @@ +AVRDUDE ?= avrdude -p t10 -c atmelice_tpi +CC = avr-gcc +CFLAGS = -mmcu=attiny10 -Wall -std=c11 -Os -DF_CPU=1000000 -L$(LIBC)/avr/lib/avrtiny -B$(LIBC)/avr/lib/avrtiny + +%.o: %.c + $(CC) -c $(CFLAGS) $< -o $@ + +main.elf: main.o + $(CC) $(CFLAGS) main.o -o main.elf + +flash: main.elf + $(AVRDUDE) -U flash:w:main.elf:e diff --git a/C/attiny10-test/main.c b/C/attiny10-test/main.c new file mode 100644 index 0000000..8d91cdc --- /dev/null +++ b/C/attiny10-test/main.c @@ -0,0 +1,10 @@ +#include +#include + +int main(void) { + DDRB = 1 << 2; + while(1) { + PORTB ^= 1 << 2; + _delay_ms(500); + } +} diff --git a/flake.nix b/flake.nix index 4fa2efd..c450873 100644 --- a/flake.nix +++ b/flake.nix @@ -82,7 +82,14 @@ ]; RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library"; }; + devShells.avr = with pkgs; pkgsCross.avr.mkShell { + packages = [ + avrdude + gnumake + ]; + LIBC = pkgsCross.avr.avrlibc; + }; devShells.typst = with pkgs; mkShell { packages = [ typst ]; }; formatter = pkgs.nixfmt; });