diff options
author | justanothercatgirl <sotov2070@gmail.com> | 2025-05-11 22:21:06 +0300 |
---|---|---|
committer | justanothercatgirl <sotov2070@gmail.com> | 2025-05-11 22:21:06 +0300 |
commit | 90a4d4a1353dd7b514fe4ef10c1ed2c6f24cadbe (patch) | |
tree | c0b032e839bcc7f78e560253ecee1dbe943b4600 | |
parent | dbf6176481b6421517c612a9042f0c6d6e773046 (diff) |
-rw-r--r-- | Makefile | 23 | ||||
-rw-r--r-- | def.s | 19 | ||||
-rw-r--r-- | i2c.s | 15 | ||||
-rw-r--r-- | timer.s | 23 |
4 files changed, 48 insertions, 32 deletions
@@ -12,25 +12,28 @@ DUDEFLAGS += -c $(PROGRAMMER) -p $(MCU) -P $(MCUPATH) # timer.s file TARGET ?= timer -.PHONY: flash dump-timer clean all - all: $(TARGET).hex +.PHONY: flash dump clean all +.SUFFIXES: + +.PRECIOUS: $(TARGET).o $(TARGET).elf + flash: $(TARGET).hex test $(shell id -u) = 0 $(DUDE) $(DUDEFLAGS) -U flash:w:$< -%.hex: % - $(OBJ)copy -O ihex $< $@ +%.o: %.s + $(AS) -mmcu=$(MCU) -o $@ $< -%: %.o +%.elf: %.o $(LD) $(LDFLAGS) -o $@ $< -%.o: %.s - $(AS) -mmcu=$(MCU) -o $@ $< +%.hex: %.elf + $(OBJ)copy -O ihex $< $@ -dump-%: % - $(OBJ)dump -d timer +dump: $(TARGET).elf + $(OBJ)dump -d clean: - rm *.o *.hex *.elf *.bin timer + $(RM) *.o *.hex *.elf *.bin timer @@ -0,0 +1,19 @@ +.equ PINB, 0x03 +.equ DDRB, 0x04 +.equ PORTB, 0x05 +.equ PIND, 0x09 +.equ DDRD, 0x0A +.equ PORTD, 0x0B +.equ TIFR0, 0x15 +.equ ADDR, 0x256 +.equ SPL, 0x3D +.equ SPH, 0x3E +.equ SREG, 0x3F +.equ TCCR0A, 0x0024 +.equ TCCR0B, 0x0025 +.equ TCNT0, 0x0026 +.equ OCR0A, 0x0027 +.equ TIMSK0, 0x006E +.equ STOFL, 0xFF +.equ STOFH, 0x08 +.equ TOIE0, 1 @@ -0,0 +1,15 @@ +i2cwait: + in r17, TWCR + sbrs r17, TWINT + rjmp i2cwait +; r16 : addr +i2cstart: + ldi r17, (1 << TWSTA) | (1 << TWEN) | (1 << TWINT) + out TWCR, r17 + rcall i2cwait + out TWDR, r16 + andi r17, ~(1 << TWSTA) + out TWCR, r17 + rcall i2cwait +; r16: data +writebyte: @@ -1,22 +1,4 @@ -.equ PINB, 0x03 -.equ DDRB, 0x04 -.equ PORTB, 0x05 -.equ PIND, 0x09 -.equ DDRD, 0x0A -.equ PORTD, 0x0B -.equ TIFR0, 0x15 -.equ ADDR, 0x256 -.equ SPL, 0x3D -.equ SPH, 0x3E -.equ SREG, 0x3F -.equ TCCR0A, 0x0024 -.equ TCCR0B, 0x0025 -.equ TCNT0, 0x0026 -.equ OCR0A, 0x0027 -.equ TIMSK0, 0x006E -.equ STOFL, 0xFF -.equ STOFH, 0x08 -.equ TOIE0, 1 +.include "def.s" .equ LOC, 0x128 .equ FREQ, 0x80 @@ -71,7 +53,6 @@ tmrint: eor r20, r20 .stt: sts LOC, r20 -.exit: pop r21 pop r20 pop r19 @@ -94,7 +75,6 @@ main: sts ADDR, r1 rjmp .loop .finloop: - in r13, PINB in r14, PORTB @@ -107,4 +87,3 @@ main: rjmp main - |