From edf5f145013aa28ffbc7f19f874cd489a92f8449 Mon Sep 17 00:00:00 2001 From: rodri Date: Sat, 5 Jun 2021 11:10:23 +0000 Subject: public release. --- asm/blink/avrdasm | 2 + asm/blink/blink.s | 12 ++ asm/blink/dat.h | 20 +++ asm/blink/makefile | 17 ++ asm/blinkdelay/avrdasm | 2 + asm/blinkdelay/blink.s | 24 +++ asm/blinkdelay/dat.h | 20 +++ asm/blinkdelay/makefile | 17 ++ asm/blinkdelay2/avr.map | 404 +++++++++++++++++++++++++++++++++++++++++++++++ asm/blinkdelay2/avrdasm | 2 + asm/blinkdelay2/blink.s | 67 ++++++++ asm/blinkdelay2/dat.h | 25 +++ asm/blinkdelay2/link.ld | 56 +++++++ asm/blinkdelay2/m328p.ld | 8 + asm/blinkdelay2/makefile | 19 +++ asm/dht11/avrdasm | 2 + asm/dht11/blink.s | 71 +++++++++ asm/dht11/dat.h | 25 +++ asm/dht11/link.ld | 34 ++++ asm/dht11/makefile | 19 +++ c/blink/blink.c | 23 +++ c/timer/timer.c | 23 +++ c/timer/timerctc.c | 26 +++ readme.md | 3 + 24 files changed, 921 insertions(+) create mode 100755 asm/blink/avrdasm create mode 100644 asm/blink/blink.s create mode 100644 asm/blink/dat.h create mode 100644 asm/blink/makefile create mode 100755 asm/blinkdelay/avrdasm create mode 100644 asm/blinkdelay/blink.s create mode 100644 asm/blinkdelay/dat.h create mode 100644 asm/blinkdelay/makefile create mode 100644 asm/blinkdelay2/avr.map create mode 100755 asm/blinkdelay2/avrdasm create mode 100644 asm/blinkdelay2/blink.s create mode 100644 asm/blinkdelay2/dat.h create mode 100644 asm/blinkdelay2/link.ld create mode 100644 asm/blinkdelay2/m328p.ld create mode 100644 asm/blinkdelay2/makefile create mode 100755 asm/dht11/avrdasm create mode 100644 asm/dht11/blink.s create mode 100644 asm/dht11/dat.h create mode 100644 asm/dht11/link.ld create mode 100644 asm/dht11/makefile create mode 100644 c/blink/blink.c create mode 100644 c/timer/timer.c create mode 100644 c/timer/timerctc.c create mode 100644 readme.md diff --git a/asm/blink/avrdasm b/asm/blink/avrdasm new file mode 100755 index 0000000..ea0707b --- /dev/null +++ b/asm/blink/avrdasm @@ -0,0 +1,2 @@ +#!/bin/sh +avr-objdump -D *.elf diff --git a/asm/blink/blink.s b/asm/blink/blink.s new file mode 100644 index 0000000..8577db3 --- /dev/null +++ b/asm/blink/blink.s @@ -0,0 +1,12 @@ +.include "dat.h" + +.globl main +main: + ldi r16, 1<text + .data : + { + *(.data) + . = ALIGN(2); + _edata = . ; + } >data AT>text + .bss ADDR(.data) + SIZEOF (.data) : AT (ADDR (.bss)) + { + *(.bss) + *(.bss*) + *(COMMON) + . = ALIGN(2); + } >data + .eeprom : + { + KEEP(*(.eeprom*)) + } >eeprom + .fuse : + { + KEEP(*(.fuse)) + KEEP(*(.lfuse)) + KEEP(*(.hfuse)) + KEEP(*(.efuse)) + } >fuse + .lock : + { + KEEP(*(.lock*)) + } >lock + .signature : + { + KEEP(*(.signature*)) + } >signature + _end = .; +} diff --git a/asm/blinkdelay2/m328p.ld b/asm/blinkdelay2/m328p.ld new file mode 100644 index 0000000..cc16198 --- /dev/null +++ b/asm/blinkdelay2/m328p.ld @@ -0,0 +1,8 @@ +SECTIONS +{ + . = 0x0; + .text : { *(.text) } + . = 0x8000000; + .data : { *(.data) } + .bss : { *(.bss) } +} diff --git a/asm/blinkdelay2/makefile b/asm/blinkdelay2/makefile new file mode 100644 index 0000000..063bd39 --- /dev/null +++ b/asm/blinkdelay2/makefile @@ -0,0 +1,19 @@ +AS=avr-as +LD=avr-ld +LDSCRIPT=link.ld + +PORT=/dev/ttyACM0 +TARG=blink + +all: build + +build: + $(AS) -mmcu=atmega328p -c -o $(TARG).o $(TARG).s + $(LD) -T$(LDSCRIPT) -o $(TARG).elf $(TARG).o + avr-objcopy -j .text -j .data -O ihex $(TARG).elf $(TARG).hex + +burn: + avrdude -v -p atmega328p -c arduino -P $(PORT) -b 115200 -D -U flash:w:$(TARG).hex + +clean: + rm -f $(TARG).elf $(TARG).o $(TARG).hex diff --git a/asm/dht11/avrdasm b/asm/dht11/avrdasm new file mode 100755 index 0000000..ea0707b --- /dev/null +++ b/asm/dht11/avrdasm @@ -0,0 +1,2 @@ +#!/bin/sh +avr-objdump -D *.elf diff --git a/asm/dht11/blink.s b/asm/dht11/blink.s new file mode 100644 index 0000000..5fe337f --- /dev/null +++ b/asm/dht11/blink.s @@ -0,0 +1,71 @@ +.include "dat.h" + +vectors: + jmp start + jmp badirq ; IRQ0 + jmp badirq ; IRQ1 + jmp badirq ; PCINT0 + jmp badirq ; PCINT1 + jmp badirq ; PCINT2 + jmp badirq ; Watchdog Timeout + jmp badirq ; Timer2 CompareA + jmp badirq ; Timer2 CompareB + jmp badirq ; Timer2 Overflow + jmp badirq ; Timer1 Capture + jmp badirq ; Timer1 CompareA + jmp badirq ; Timer1 CompareB + jmp badirq ; Timer1 Overflow + jmp badirq ; Timer0 CompareA + jmp badirq ; Timer0 CompareB + jmp badirq ; Timer0 Overflow + jmp badirq ; SPI Transfer Complete + jmp badirq ; USART RX Complete + jmp badirq ; USART UDR Empty + jmp badirq ; USART TX Complete + jmp badirq ; ADC Conversion Complete + jmp badirq ; EEPROM Ready + jmp badirq ; Analog Comparator + jmp badirq ; 2-wire Serial + jmp badirq ; SPM Ready + +start: + eor r1, r1 + out SREG, r1 + ldi r28, 0xff + ldi r29, 0x8 + out SPL, r28 + out SPH, r29 + call main +halt: + rjmp halt + +badirq: + jmp vectors + +.globl delayloop +delayloop: + ldi r18, 82 + ldi r19, 43 + ldi r20, 0 +l1: + dec r20 + brne l1 + dec r19 + brne l1 + dec r18 + brne l1 + ret + +.globl main +main: + ldi r16, 1<text + .data : + { + *(.data) + . = ALIGN(2); + _edata = . ; + } >data AT>text + .bss ADDR(.data) + SIZEOF (.data) : AT (ADDR (.bss)) + { + *(.bss) + *(COMMON) + . = ALIGN(2); + } >data + .eeprom : + { + *(.eeprom*) + } >eeprom + _end = .; +} diff --git a/asm/dht11/makefile b/asm/dht11/makefile new file mode 100644 index 0000000..063bd39 --- /dev/null +++ b/asm/dht11/makefile @@ -0,0 +1,19 @@ +AS=avr-as +LD=avr-ld +LDSCRIPT=link.ld + +PORT=/dev/ttyACM0 +TARG=blink + +all: build + +build: + $(AS) -mmcu=atmega328p -c -o $(TARG).o $(TARG).s + $(LD) -T$(LDSCRIPT) -o $(TARG).elf $(TARG).o + avr-objcopy -j .text -j .data -O ihex $(TARG).elf $(TARG).hex + +burn: + avrdude -v -p atmega328p -c arduino -P $(PORT) -b 115200 -D -U flash:w:$(TARG).hex + +clean: + rm -f $(TARG).elf $(TARG).o $(TARG).hex diff --git a/c/blink/blink.c b/c/blink/blink.c new file mode 100644 index 0000000..bb4495a --- /dev/null +++ b/c/blink/blink.c @@ -0,0 +1,23 @@ +#include +#define F_CPU 16000000UL +#include + +enum{ + Delay = 300 +}; + +int +main() +{ + int led; + + led = 1< + +enum{ + Dcnt = 62499 +}; + +int +main() +{ + int led; + + led = 1<= Dcnt){ + PORTB ^= led; + TCNT1 = 0; + } + } +} + diff --git a/c/timer/timerctc.c b/c/timer/timerctc.c new file mode 100644 index 0000000..7e65b52 --- /dev/null +++ b/c/timer/timerctc.c @@ -0,0 +1,26 @@ +#include + +enum{ + Dcnt = 62499 /* 1Hz */ +}; + +int +main() +{ + int led; + + led = 1<