Use the correct register and bit flag to enable the correct timer counter compare interrupt
This commit is contained in:
parent
8f06f6abc8
commit
66f62e972a
2 changed files with 12 additions and 14 deletions
20
avr/send.c
20
avr/send.c
|
@ -52,14 +52,9 @@ static void spi_start() {
|
||||||
DDRB |= (1 << DDB5);
|
DDRB |= (1 << DDB5);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enable timer interrupt vector
|
* Set timer clock divider to 1/1
|
||||||
*/
|
*/
|
||||||
TIMSK0 = (1 << TOIE0);
|
TCCR1B = (1 << CS10);
|
||||||
|
|
||||||
/*
|
|
||||||
* Reset timer counter to zero
|
|
||||||
*/
|
|
||||||
TCNT1 = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set timer interval
|
* Set timer interval
|
||||||
|
@ -67,14 +62,19 @@ static void spi_start() {
|
||||||
OCR1A = TIMER1_INTERVAL;
|
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() {
|
static void spi_end() {
|
||||||
DDRB &= ~((1 << DDB5) | (1 << DDB4) | (1 << DDB3));
|
DDRB &= ~((1 << DDB5) | (1 << DDB4) | (1 << DDB3));
|
||||||
TIMSK0 &= ~(1 << TOIE0);
|
TIMSK0 &= ~(1 << OCIE1A);
|
||||||
TCNT1 = 0;
|
TCNT1 = 0;
|
||||||
OCR1A = TIMER1_INTERVAL;
|
OCR1A = TIMER1_INTERVAL;
|
||||||
TCCR1B = (1 << CS10);
|
TCCR1B = (1 << CS10);
|
||||||
|
|
|
@ -29,8 +29,6 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
tabby_printer_packet header;
|
tabby_printer_packet header;
|
||||||
|
|
||||||
uint16_t checksum;
|
|
||||||
|
|
||||||
uint8_t body[TABBY_PRINTER_MAX_PACKET_SIZE];
|
uint8_t body[TABBY_PRINTER_MAX_PACKET_SIZE];
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
|
@ -45,7 +43,7 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
status = tabby_printer_packet_recv(fd, &header, &body, &checksum);
|
status = tabby_printer_packet_recv(fd, &header, &body);
|
||||||
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
fprintf(stderr, "%s: %s: %s\n",
|
fprintf(stderr, "%s: %s: %s\n",
|
||||||
|
|
Loading…
Add table
Reference in a new issue