Use the correct register and bit flag to enable the correct timer counter compare interrupt

This commit is contained in:
XANTRONIX Development 2016-06-02 22:51:17 +00:00
parent 8f06f6abc8
commit 66f62e972a
2 changed files with 12 additions and 14 deletions

View file

@ -6,7 +6,7 @@
#include <tabby/printer.h>
#include <tabby/avr/uart.h>
#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);

View file

@ -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",