Rename and change file extension. Add callbacks to timer func
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
MCU = attiny85
|
MCU = attiny85
|
||||||
F_CPU = 1000000UL
|
F_CPU = 1000000UL
|
||||||
TARGET = main
|
TARGET = clockinator
|
||||||
SRCS = main.S
|
SRCS = clockinator.S
|
||||||
CC = avr-gcc
|
CC = avr-gcc
|
||||||
OBJCOPY = avr-objcopy
|
OBJCOPY = avr-objcopy
|
||||||
PORT = /dev/tty.usbmodem101
|
PORT = /dev/tty.usbmodem101
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#define __SFR_OFFSET 0
|
||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
.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
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#define __SFR_OFFSET 0
|
|
||||||
#include <avr/io.h>
|
|
||||||
|
|
||||||
.global main
|
|
||||||
Reference in New Issue
Block a user