summaryrefslogtreecommitdiff
path: root/src/modem.cc
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-01-20 12:27:20 +0100
committerDaniel Friesel <derf@finalrewind.org>2016-01-20 12:27:20 +0100
commitc8f52f8271c5f2a048d8849efe656c5391da29ba (patch)
tree76aa844d0776e317c56ef2b34182d19dfc2a1fc5 /src/modem.cc
parentabf69bd53f86300d263d3abeeae81a9e1c3cd5c0 (diff)
move display and modem code from ISR to class functions
Diffstat (limited to 'src/modem.cc')
-rw-r--r--src/modem.cc50
1 files changed, 27 insertions, 23 deletions
diff --git a/src/modem.cc b/src/modem.cc
index 2eae685..0a89586 100644
--- a/src/modem.cc
+++ b/src/modem.cc
@@ -45,9 +45,31 @@ uint8_t Modem::buffer_get() {
}
/*
- * Pin Change Interrupt Vector. This is The Modem.
+ * Start the modem by enabling Pin Change Interrupts & Timer
*/
-ISR(PCINT3_vect) {
+void Modem::enable() {
+ /* Enable R1 */
+ DDRA |= _BV(PA3);
+ PORTA |= _BV(PA3);
+
+ /* Modem pin as input */
+ MODEM_DDR &= ~_BV(MODEM_PIN);
+
+ /* Enable Pin Change Interrupts and PCINT for MODEM_PIN */
+ MODEM_PCMSK |= _BV(MODEM_PCINT);
+ PCICR |= _BV(MODEM_PCIE);
+
+ /* Timer: TCCR1: CS10 and CS11 bits: 8MHz clock with Prescaler 64 = 125kHz timer clock */
+ TCCR1B = _BV(CS11) | _BV(CS10);
+}
+
+void Modem::disable()
+{
+ PORTA &= ~_BV(PA3);
+ DDRA &= ~_BV(PA3);
+}
+
+void Modem::receive() {
/* Static variables instead of globals to keep scope inside ISR */
static uint8_t modem_bit = 0;
static uint8_t modem_bitlen = 0;
@@ -81,26 +103,8 @@ ISR(PCINT3_vect) {
}
/*
- * Start the modem by enabling Pin Change Interrupts & Timer
+ * Pin Change Interrupt Vector. This is The Modem.
*/
-void Modem::enable() {
- /* Enable R1 */
- DDRA |= _BV(PA3);
- PORTA |= _BV(PA3);
-
- /* Modem pin as input */
- MODEM_DDR &= ~_BV(MODEM_PIN);
-
- /* Enable Pin Change Interrupts and PCINT for MODEM_PIN */
- MODEM_PCMSK |= _BV(MODEM_PCINT);
- PCICR |= _BV(MODEM_PCIE);
-
- /* Timer: TCCR1: CS10 and CS11 bits: 8MHz clock with Prescaler 64 = 125kHz timer clock */
- TCCR1B = _BV(CS11) | _BV(CS10);
-}
-
-void Modem::disable()
-{
- PORTA &= ~_BV(PA3);
- DDRA &= ~_BV(PA3);
+ISR(PCINT3_vect) {
+ modem.receive();
}