ALMOST compiling...

This commit is contained in:
XANTRONIX Development 2016-05-27 12:23:00 -05:00
parent d4dfd3e34e
commit 8d1561bfe3
3 changed files with 116 additions and 20 deletions

View file

@ -1,10 +1,11 @@
#include <stdio.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <tabby/clock.h>
#include <tabby/packet.h>
#include <tabby/command.h>
#include <tabby/avr/uart.h>
#include <tabby/avr/buffer.h>
@ -28,7 +29,7 @@ static tabby_clock_speed speed = TABBY_CLOCK_SPEED_8192HZ;
/*
* Internal clock source interrupt vector
*/
ISR(TIM0_COMPB_vect) {
ISR(TIMER0_COMPB_vect) {
value_in >>= 1;
if (PORTB & (1 << PORTB2)) {
@ -68,7 +69,7 @@ ISR(TIM0_COMPB_vect) {
* SPI byte receipt interrupt vector
*/
ISR(SPI_STC_vect) {
uart_putchar(SPDR);
uart_putchar(SPDR, NULL);
if (buffer.cur < buffer.len) {
SPDR = buffer.data[buffer.cur++];
@ -83,22 +84,22 @@ static void setup_clock_internal(tabby_clock_speed speed) {
/*
* Configure MISO as output
*/
DDB3 |= (1 << PORTB3);
DDRB |= (1 << DDB3);
/*
* Configure MOSI as input
*/
DDB2 &= ~(1 << PORTB2);
DDRB &= ~(1 << DDB2);
/*
* Configure SCK pin as output
*/
DDB1 |= (1 << PORTB1);
DDRB |= (1 << DDB1);
/*
* Enable timer interrupt vector
*/
TIMSK = (1 << TOIE1);
TIMSK0 = (1 << TOIE1);
/*
* Reset timer counter to zero
@ -122,17 +123,17 @@ static void setup_clock_external() {
*/
TCCR1B = 0;
OCR1A = 0;
TIMSK = 0;
TIMSK0 = 0;
/*
* Configure MISO as output
*/
DDB3 |= (1 << PORTB3);
DDRB |= (1 << DDB3);
/*
* Configure MOSI as input
*/
DDB2 &= ~(1 << PORTB2);
DDRB &= ~(1 << DDB3);
/*
* Set SPI slave mode, and shift in/out most significant bit first
@ -149,22 +150,20 @@ static void setup_clock_external() {
*/
SPDR = 0;
buf.len = 0;
buf.cur = 0;
buffer.len = 0;
buffer.cur = 0;
}
static void snooze() {
/*static void snooze() {
set_sleep_mode(mode);
sleep_enable();
sleep_mode();
sleep_disable();
}
}*/
int main() {
tabby_command state = TABBY_COMMAND_NONE;
uint8_t last = 0x00;
int received = 0;
/*
@ -250,13 +249,10 @@ int main() {
goto reset;
}
last = c;
continue;
reset:
state = TABBY_COMMAND_NONE;
last = 0;
received = 0;
buffer.len = 0;

100
configure vendored Executable file
View file

@ -0,0 +1,100 @@
#! /bin/sh
OS=`uname -s`
DEBUG=0
create_linux_config_h() {
cat <<EOF > src/config.h
#ifndef _CONFIG_H
#define _CONFIG_H
#include <endian.h>
#endif /* _CONFIG_H */
EOF
}
create_darwin_config_h() {
cat <<EOF > src/config.h
#ifndef _CONFIG_H
#define _CONFIG_H
#include <architecture/byte_order.h>
#ifdef __LITTLE_ENDIAN__
#define __DO_SWAP_BYTES
#endif /* _DO_SWAP_BYTES */
#endif /* _CONFIG_H */
EOF
}
create_common_build_mk() {
if [ "$DEBUG" = 1 ]; then
cat <<'EOF' > mk/build.mk
CGFLAGS = -g -fno-inline
EOF
else
cat <<'EOF' > mk/build.mk
CGFLAGS =
EOF
fi
cat <<'EOF' >> mk/build.mk
CWFLAGS = -Wall
COFLAGS = -O2
CFLAGS = $(CGFLAGS) $(CWFLAGS) $(COFLAGS)
EOF
}
create_linux_build_mk() {
create_common_build_mk $@
cat <<'EOF' >> mk/build.mk
LLFLAGS = -shared -Wl,-soname=$(SONAME)
STATIC = lib$(LIBNAME).a
SONAME_SHORT = lib$(LIBNAME).so
SONAME = $(SONAME_SHORT).$(VERSION_MAJOR)
SONAME_FULL = $(SONAME_SHORT).$(VERSION)
PREFIX = /usr/local
EOF
}
create_darwin_build_mk() {
create_common_build_mk $@
cat <<'EOF' >> mk/build.mk
LLFLAGS = -dynamiclib -current_version $(VERSION)
STATIC = lib$(LIBNAME).a
SONAME_SHORT = lib$(LIBNAME).dylib
SONAME = lib$(LIBNAME).$(VERSION_MAJOR).dylib
SONAME_FULL = lib$(LIBNAME).$(VERSION).dylib
PREFIX = /usr/local
EOF
}
for arg in $@; do
case $arg in
"--enable-debug")
DEBUG=1
;;
esac
done
if [ ! -d "mk" ]; then
mkdir -m 0755 mk
fi
case $OS in
Linux)
create_linux_config_h
create_linux_build_mk
;;
Darwin)
create_darwin_config_h
create_darwin_build_mk
;;
esac

View file

@ -4,7 +4,7 @@
typedef enum {
TABBY_CLOCK_SOURCE_INTERNAL = 0x01,
TABBY_CLOCK_SOURCE_EXTERNAL = 0x02
} tabby_clock_mode;
} tabby_clock_source;
typedef enum {
TABBY_CLOCK_SPEED_8192HZ = 0x01,