; enable uart + rx complete interrupt
ldi tmp,51 ; 9600 baud, 0,2% error @ 8mhz
out UBRR,tmp
-ldi tmp,((1<<RXCIE)|(1<<RXEN))
+ldi tmp,((1<<RXCIE)|(1<<RXEN)|(1<<TXEN))
out UCR,tmp
; init registers
ldi tmp,1
breq CM_ACTION
reti
+;
+; specify action
+;
+
+
;
; continuous mode action
;
; receive from uart
;
UART_RECEIVE:
+cp uart_count,zero
+breq GET_MODE
+cpi uart_count,1
+breq GET_R_VALUE
+cpi uart_count,2
+breq GET_G_VALUE
+cpi uart_count,3
+breq GET_B_VALUE
+
+;
+; get mode
+;
+GET_MODE:
+in tmp,UDR
+cpi tmp,0x63 ; 0x63 = 'c'
+breq SET_CONTINUOUS_MODE
+cpi tmp,0x73 ; 0x73 = 's'
+breq SET_SPECIFY_MODE
+ldi uart_count,0
+reti
+
+;
+; set cmode
+;
+SET_CONTINUOUS_MODE:
+ldi mode,cm
+ldi uart_count,0
+reti
+
+;
+; set specify mode
+;
+SET_SPECIFY_MODE:
+ldi mode,rgb
+add uart_count,one
+; check
+out UDR,mode
+reti
+
+;
+; get red value
+;
+GET_R_VALUE:
+in RED,UDR
+add uart_count,one
+; check
+out UDR,RED
+reti
+
+;
+; get green value
+;
+GET_G_VALUE:
+in GREEN,UDR
+add uart_count,one
+; check
+out UDR,GREEN
+reti
+
+;
+; get blue value
+;
+GET_B_VALUE:
+in BLUE,UDR
+mov uart_count,zero
+; check
+out UDR,BLUE
reti
.include "../include/2313def.inc"
; baudrate einstellen
-ldi r16, 11 ; "38400 bps wert" in r16
+ldi r16, 51 ; "9600 bps @ 8mhz" in r16
out UBRR, r16 ; write to uart baudrate register
sbi UCR, TXEN ; enable tx at uart control register