aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-06-11 16:09:33 -0400
committerKevin O'Connor <kevin@koconnor.net>2016-06-14 14:00:57 -0400
commite59951c8ae87d6a958e3ef6bee102a35281b2833 (patch)
tree9ef616b4f63eb4e8300099824b3e2c3d981cb5ed /src
parentea5f825a916e3c1ba29ea172d94c2f7b8bcaf8dd (diff)
downloadkutter-e59951c8ae87d6a958e3ef6bee102a35281b2833.tar.gz
kutter-e59951c8ae87d6a958e3ef6bee102a35281b2833.tar.xz
kutter-e59951c8ae87d6a958e3ef6bee102a35281b2833.zip
avr/serial: Separate out low-level hardware manipulation to its own function
Introduce enable_tx_irq() for manipulating the AVR hardware. This keeps the low-level hardware code together. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r--src/avr/serial.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/avr/serial.c b/src/avr/serial.c
index 0a7a9508..c1882a5d 100644
--- a/src/avr/serial.c
+++ b/src/avr/serial.c
@@ -63,6 +63,13 @@ ISR(USART0_UDRE_vect)
UDR0 = transmit_buf[transmit_pos++];
}
+// Enable tx interrupts
+static void
+enable_tx_irq(void)
+{
+ UCSR0B |= 1<<UDRIE0;
+}
+
/****************************************************************
* Console access functions
@@ -124,7 +131,7 @@ console_get_output(uint8_t len)
writeb(&transmit_pos, 0);
barrier();
writeb(&transmit_max, tmax);
- UCSR0B |= 1<<UDRIE0;
+ enable_tx_irq();
return &transmit_buf[tmax];
}
@@ -133,6 +140,5 @@ void
console_push_output(uint8_t len)
{
writeb(&transmit_max, readb(&transmit_max) + len);
- // enable TX interrupt
- UCSR0B |= 1<<UDRIE0;
+ enable_tx_irq();
}