You know what? This, right here, fucking works
This commit is contained in:
parent
ee796c04e2
commit
68852d460b
4 changed files with 8 additions and 10 deletions
|
@ -44,6 +44,8 @@ static inline uint16_t checksum() {
|
|||
ISR(SPI_STC_vect) {
|
||||
uint8_t value = SPDR;
|
||||
|
||||
uart_putchar(value, NULL);
|
||||
|
||||
switch (i) {
|
||||
case 0: {
|
||||
if (value == 0x88) {
|
||||
|
@ -131,8 +133,6 @@ ISR(SPI_STC_vect) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
uart_putchar(value, NULL);
|
||||
}
|
||||
|
||||
static void setup_clock_external() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef _TABBY_AVR_UART_H
|
||||
#define _TABBY_AVR_UART_H
|
||||
|
||||
#define TABBY_AVR_UART_BAUD 115200
|
||||
#define TABBY_AVR_UART_BAUD 57600
|
||||
|
||||
void uart_init();
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include <tabby/clock.h>
|
||||
|
||||
#define TABBY_LINK_BAUD B115200
|
||||
#define TABBY_LINK_BAUD B57600
|
||||
|
||||
int tabby_link_open(const char *dev);
|
||||
|
||||
|
|
|
@ -36,22 +36,19 @@ int tabby_printer_packet_recv(int fd, tabby_printer_packet_header *header,
|
|||
|
||||
while ((len = tabby_link_recv(fd, &value, 1)) >= 0) {
|
||||
if (i == 0) {
|
||||
if (value == 0x83) {
|
||||
if (value == 0x88) {
|
||||
header->preamble[0] = value;
|
||||
i++;
|
||||
} else {
|
||||
errno = EIO;
|
||||
|
||||
goto error_io;
|
||||
continue;
|
||||
}
|
||||
} else if (i == 1) {
|
||||
if (value == 0x33) {
|
||||
header->preamble[1] = value;
|
||||
i++;
|
||||
} else {
|
||||
errno = EIO;
|
||||
i = 0;
|
||||
goto error_io;
|
||||
continue;
|
||||
}
|
||||
} else if (i == 2) {
|
||||
header->type = value;
|
||||
|
@ -65,6 +62,7 @@ int tabby_printer_packet_recv(int fd, tabby_printer_packet_header *header,
|
|||
} else if (i == 5) {
|
||||
header->size |= value << 8;
|
||||
i++;
|
||||
|
||||
b = 0;
|
||||
} else if (b < header->size) {
|
||||
((uint8_t *)body)[b++] = value;
|
||||
|
|
Loading…
Add table
Reference in a new issue