Poppin' more cruft out the repo 8)

This commit is contained in:
XANTRONIX Development 2016-06-01 20:33:47 -05:00
parent 85404e606b
commit e618aa68cd
8 changed files with 27 additions and 73 deletions

View file

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

View file

@ -4,10 +4,7 @@
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <tabby/clock.h>
#include <tabby/command.h>
#include <tabby/printer.h>
#include <tabby/avr/uart.h>
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() {

View file

@ -1,8 +1,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <tabby/link.h>

View file

@ -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 */

View file

@ -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 */

View file

@ -1,16 +1,6 @@
#ifndef _TABBY_LINK_H
#define _TABBY_LINK_H
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <tabby/clock.h>
#define TABBY_LINK_BAUD B57600
int tabby_link_open(const char *dev);

View file

@ -1,7 +1,11 @@
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <tabby/link.h>
#include <tabby/command.h>
int tabby_link_open(const char *dev) {
int fd;

View file

@ -1,3 +1,7 @@
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <tabby/link.h>