From 66f62e972aa769f834df88a8f7e9785aa0c2e5e2 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Thu, 2 Jun 2016 22:51:17 +0000 Subject: [PATCH] Use the correct register and bit flag to enable the correct timer counter compare interrupt --- avr/send.c | 22 +++++++++++----------- bin/main.c | 4 +--- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/avr/send.c b/avr/send.c index 84f3653..c6f0bf8 100644 --- a/avr/send.c +++ b/avr/send.c @@ -6,7 +6,7 @@ #include #include -#define TIMER1_INTERVAL 1953 +#define TIMER1_INTERVAL 1953 enum { TABBY_SEND_READING = 0, @@ -52,14 +52,9 @@ static void spi_start() { DDRB |= (1 << DDB5); /* - * Enable timer interrupt vector + * Set timer clock divider to 1/1 */ - TIMSK0 = (1 << TOIE0); - - /* - * Reset timer counter to zero - */ - TCNT1 = 0; + TCCR1B = (1 << CS10); /* * Set timer interval @@ -67,14 +62,19 @@ static void spi_start() { OCR1A = TIMER1_INTERVAL; /* - * Set timer clock divider to 1/1 + * Reset timer counter to zero */ - TCCR1B = (1 << CS10); + TCNT1 = 0; + + /* + * Enable timer interrupt vector for match on OCR1A + */ + TIMSK0 = (1 << OCIE1A); } static void spi_end() { DDRB &= ~((1 << DDB5) | (1 << DDB4) | (1 << DDB3)); - TIMSK0 &= ~(1 << TOIE0); + TIMSK0 &= ~(1 << OCIE1A); TCNT1 = 0; OCR1A = TIMER1_INTERVAL; TCCR1B = (1 << CS10); diff --git a/bin/main.c b/bin/main.c index c25dedc..e99b635 100644 --- a/bin/main.c +++ b/bin/main.c @@ -29,8 +29,6 @@ int main(int argc, char **argv) { tabby_printer_packet header; - uint16_t checksum; - uint8_t body[TABBY_PRINTER_MAX_PACKET_SIZE]; if (argc != 2) { @@ -45,7 +43,7 @@ int main(int argc, char **argv) { } while (1) { - status = tabby_printer_packet_recv(fd, &header, &body, &checksum); + status = tabby_printer_packet_recv(fd, &header, &body); if (status < 0) { fprintf(stderr, "%s: %s: %s\n",