From e618aa68cd7ab0ead21100842148f825347a19dd Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Wed, 1 Jun 2016 20:33:47 -0500 Subject: [PATCH] Poppin' more cruft out the repo 8) --- avr/Makefile | 2 +- avr/main.c | 48 +++++++++++++---------------------------- bin/main.c | 3 ++- include/tabby/clock.h | 16 -------------- include/tabby/command.h | 11 ---------- include/tabby/link.h | 10 --------- src/link.c | 6 +++++- src/printer.c | 4 ++++ 8 files changed, 27 insertions(+), 73 deletions(-) delete mode 100644 include/tabby/clock.h delete mode 100644 include/tabby/command.h diff --git a/avr/Makefile b/avr/Makefile index f8021be..66ea28a 100644 --- a/avr/Makefile +++ b/avr/Makefile @@ -19,7 +19,7 @@ HEADERS_LOCAL = HEADERS_BUILD = $(HEADERS_LOCAL) \ $(addprefix $(INCLUDE_PATH)/$(HEADER_SUBDIR)/,$(HEADERS)) -HEADERS = avr/buffer.h avr/uart.h clock.h command.h link.h +HEADERS = avr/buffer.h avr/uart.h link.h OBJS = main.o uart.o IMAGE_NAME = tabby diff --git a/avr/main.c b/avr/main.c index 053230e..5f81dda 100644 --- a/avr/main.c +++ b/avr/main.c @@ -4,10 +4,7 @@ #include #include -#include -#include #include - #include static volatile tabby_printer_packet header = { @@ -23,93 +20,78 @@ static volatile uint16_t i = 0, * SPI byte receipt interrupt vector */ ISR(SPI_STC_vect) { - uint8_t value = SPDR; + uint8_t in = SPDR, + out = 0x00; - uart_putchar(value, NULL); + uart_putchar(in, NULL); switch (i) { case 0: { - if (value == 0x88) { - header.data[0] = value; + if (in == 0x88) { + header.data[0] = in; i++; b = 0; } - SPDR = 0; - break; } case 1: { - if (value == 0x33) { - header.data[1] = value; + if (in == 0x33) { + header.data[1] = in; i++; } else { i = 0; } - SPDR = 0; - break; } case 2: { - header.type = value; + header.type = in; i++; - SPDR = 0; break; } case 3: { - header.compression = value; + header.compression = in; i++; - SPDR = 0; break; } case 4: { - header.size = value; + header.size = in; i++; - SPDR = 0; break; } case 5: { - header.size |= value << 8; + header.size |= in << 8; i++; - SPDR = 0; break; } default: { - if (b < header.size) { + if (b <= header.size) { b++; - - SPDR = 0; - } else if (b == header.size) { - b++; - - SPDR = 0; } else if (b == header.size + 1) { b++; - SPDR = 0x81; + out = 0x81; } else if (b == header.size + 2) { b++; - - SPDR = 0; } else if (b == header.size + 3) { i = 0; - - SPDR = 0; } } } + + SPDR = out; } static void setup_clock_external() { diff --git a/bin/main.c b/bin/main.c index f37ba0f..c25dedc 100644 --- a/bin/main.c +++ b/bin/main.c @@ -1,8 +1,9 @@ #include #include +#include #include #include -#include +#include #include #include diff --git a/include/tabby/clock.h b/include/tabby/clock.h deleted file mode 100644 index 5e0655c..0000000 --- a/include/tabby/clock.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _TABBY_CLOCK_H -#define _TABBY_CLOCK_H - -typedef enum { - TABBY_CLOCK_SOURCE_INTERNAL = 0x01, - TABBY_CLOCK_SOURCE_EXTERNAL = 0x02 -} tabby_clock_source; - -typedef enum { - TABBY_CLOCK_SPEED_8192HZ = 0x01, - TABBY_CLOCK_SPEED_16384HZ = 0x02, - TABBY_CLOCK_SPEED_262144HZ = 0x03, - TABBY_CLOCK_SPEED_524288HZ = 0x04 -} tabby_clock_speed; - -#endif /* _TABBY_CLOCK_H */ diff --git a/include/tabby/command.h b/include/tabby/command.h deleted file mode 100644 index a146c9d..0000000 --- a/include/tabby/command.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _TABBY_COMMAND_H -#define _TABBY_COMMAND_H - -typedef enum { - TABBY_COMMAND_NONE = 0x00, - TABBY_COMMAND_SEND = 0x01, - TABBY_COMMAND_CLOCK_SOURCE = 0x02, - TABBY_COMMAND_CLOCK_SPEED = 0x03 -} tabby_command; - -#endif /* _TABBY_COMMAND_H */ diff --git a/include/tabby/link.h b/include/tabby/link.h index e73c951..31497b8 100644 --- a/include/tabby/link.h +++ b/include/tabby/link.h @@ -1,16 +1,6 @@ #ifndef _TABBY_LINK_H #define _TABBY_LINK_H -#include -#include -#include -#include -#include -#include -#include - -#include - #define TABBY_LINK_BAUD B57600 int tabby_link_open(const char *dev); diff --git a/src/link.c b/src/link.c index 2708463..dd97039 100644 --- a/src/link.c +++ b/src/link.c @@ -1,7 +1,11 @@ #include +#include +#include +#include +#include +#include #include -#include int tabby_link_open(const char *dev) { int fd; diff --git a/src/printer.c b/src/printer.c index b0658b0..55fdc45 100644 --- a/src/printer.c +++ b/src/printer.c @@ -1,3 +1,7 @@ +#include +#include +#include +#include #include #include