summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2021-06-04 19:09:07 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2021-06-04 19:09:07 +0200
commit27321e05de35b494c2b282652e1c40a18435b68b (patch)
tree517ac03ec78902c608e6522ba1f58aebfff41d84 /src/main.c
parent3ead2db8d979bab8fd8848d24de430979698b16f (diff)
downloadanalog_instruments-27321e05de35b494c2b282652e1c40a18435b68b.tar.gz
implement uart
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index c0f35d7..a73e7ef 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2,24 +2,62 @@
#include <avr/interrupt.h>
#include <stdint.h>
+#include "uart.h"
+
+uint8_t t0_ovf_cnt = 0;
+
+uint8_t pb0_thresh = 128;
+
ISR(TIMER0_OVF_vect) {
cli();
+ /*TCNT0 = (1<<7);*/ /* Hack-increase Interrupt trigger freq */
+
+ t0_ovf_cnt ++;
+
+ if ( t0_ovf_cnt >= pb0_thresh )
+ PORTB &= ~(1<<PINB0);
+ else
+ PORTB |= (1<<PINB0);
sei();
}
+ISR(TIMER2_OVF_vect) {
+ cli();
+ pb0_thresh ++;
+ sei();
+}
+
int main(void) {
+ char c;
+
cli();
- /* Enable TIMER0 with interrupt */
+ /* Pins */
+ DDRB |= (1<<PINB0);
+
+ /* Enable TIMER0 with interrupt, no prescaler */
TCCR0 |= (1<<CS00);
TIMSK |= (1<<TOIE0);
+
+ /* Enable TIMER2 with interrupt, Clk divide by 1024 */
+ /*
+ TCCR2 |= (7<<CS20);
+ TIMSK |= (1<<TOIE2);
+ */
+
+ /* Uart */
+ uart_init();
/* Go! */
sei();
while(1){
+ if( uart_getchar(&c) )
+ continue;
+ uart_putchar(c);
+ pb0_thresh = c;
}
return 0;