diff --git a/src/Makefile b/src/Makefile index 8f1d328..4b8ab72 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ MCU = attiny85 F_CPU = 1000000UL -TARGET = main -SRCS = main.S +TARGET = clockinator +SRCS = clockinator.S CC = avr-gcc OBJCOPY = avr-objcopy PORT = /dev/tty.usbmodem101 diff --git a/src/clockinator.S b/src/clockinator.S new file mode 100644 index 0000000..61479ff --- /dev/null +++ b/src/clockinator.S @@ -0,0 +1,49 @@ +#define __SFR_OFFSET 0 +#include + +.include "timer.inc" +;.include "bpm.inc" +;.include "midi.inc" +;.include "led.inc" +.global main + +main: + ;cbi DDRB, PB1 ; Set EC11 clockwise on PB5 as input + ;cbi DDRB, PB2 ; Set EC11 counter-clockwise on PB3 as input + ;cbi DDRB, PB5 ; Set EC11 button (555 square wave) on PB4 as input + ldi r26, 60 ; Default BPM //TODO: save to eeprom not register, on runtime also ldi on r24 register + + rcall timer0_ld + rcall timer1_ld + + +; interrupts: +; button (tap tempo loop) tap_tempo: +; encoder (increase/decrease tempo by one) incr_temp: , decr_temp: +; timer 1 +; +; otherwise start from default bpm 60 (r26) + +; loop: calculate tempo (high priority!) and save, led blinking, segment led writing +loop: + ldi r24, 30 ; Load current BPM to register //NOTE: hardcoded temporary + ; TODO: compare two registers (current bpm and previous bpm) + rcall tempo_calc ; CHANGE: if BPM changed then rcall BPM calculation function else skip because ticks tempo is the value already in [OCR1C] + ; if this BPM != previous BPM then load this to another register (will be used as the 'previous register') + + ; final result stored in OCR1C as ticks + + ; TODO: look if there are alternatives to rcall + + ;rcall midi_send ; Send MIDI ping + + rcall blink_led + in r16, TIFR0 ; Check timer0 status + sbrc r16, OCF0A ; Skip stop_blink if clear + rcall stop_blink + + + + ;rcall segment_led ; Output current BPM to 3-digit 7-segment LED [r24] + + rjmp loop ; Loopback diff --git a/src/main.s b/src/main.s deleted file mode 100644 index 762ad81..0000000 --- a/src/main.s +++ /dev/null @@ -1,4 +0,0 @@ -#define __SFR_OFFSET 0 -#include - -.global main