diff options
Diffstat (limited to 'src/arch/blinkenrocket/driver/stdout.cc')
-rw-r--r-- | src/arch/blinkenrocket/driver/stdout.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/arch/blinkenrocket/driver/stdout.cc b/src/arch/blinkenrocket/driver/stdout.cc new file mode 100644 index 0000000..961cf46 --- /dev/null +++ b/src/arch/blinkenrocket/driver/stdout.cc @@ -0,0 +1,35 @@ +#include "driver/stdout.h" +#include <avr/io.h> +#include <avr/interrupt.h> + +void StandardOutput::setup() +{ + PORTC |= _BV(PC1); + DDRC |= _BV(DDC1); +} + +void StandardOutput::put(char c) +{ + unsigned char i = 1; + PORTC &= ~_BV(PC1); + __builtin_avr_delay_cycles(59); + while (i < 0x80) { + if (c & i) { + PORTC |= _BV(PC1); + } else { + PORTC &= ~_BV(PC1); + } + i <<= 1; + __builtin_avr_delay_cycles(54); + } + __builtin_avr_delay_cycles(6); + PORTC &= ~_BV(PC1); + __builtin_avr_delay_cycles(67); + PORTC |= _BV(PC1); + __builtin_avr_delay_cycles(150); + if (c == '\n') { + put('\r'); + } +} + +StandardOutput kout; |