THERE IS NO GOD

This commit is contained in:
XANTRONIX Development 2016-05-29 01:12:51 -05:00
parent 550623ee5d
commit 3223228e0b

View file

@ -19,8 +19,9 @@ static const uint16_t timer_counter_intervals[4] = {
}; };
static volatile tabby_avr_buffer buffer = { static volatile tabby_avr_buffer buffer = {
.len = 0, .len = 0,
.cur = 0 .cur = 0,
.read = 0
}; };
static tabby_clock_source source = TABBY_CLOCK_SOURCE_INTERNAL; static tabby_clock_source source = TABBY_CLOCK_SOURCE_INTERNAL;
@ -50,8 +51,8 @@ ISR(TIMER0_COMPB_vect) {
if (buffer.cur < buffer.len) { if (buffer.cur < buffer.len) {
value_out = buffer.data[buffer.cur++]; value_out = buffer.data[buffer.cur++];
} else { } else {
buffer.len = 0; buffer.len = 0;
buffer.cur = 0; buffer.cur = 0;
buffer.read = 0; buffer.read = 0;
} }
@ -74,6 +75,8 @@ ISR(SPI_STC_vect) {
if (buffer.cur < buffer.len) { if (buffer.cur < buffer.len) {
SPDR = buffer.data[buffer.cur++]; SPDR = buffer.data[buffer.cur++];
} else { } else {
SPDR = 0xff;
buffer.len = 0; buffer.len = 0;
buffer.cur = 0; buffer.cur = 0;
buffer.read = 0; buffer.read = 0;
@ -84,17 +87,17 @@ static void setup_clock_internal(tabby_clock_speed speed) {
/* /*
* Configure MISO as output * Configure MISO as output
*/ */
DDRB |= (1 << DDB3); DDRB |= (1 << DDB4);
/* /*
* Configure MOSI as input * Configure MOSI as input
*/ */
DDRB &= ~(1 << DDB2); DDRB &= ~(1 << DDB3);
/* /*
* Configure SCK pin as output * Configure SCK pin as output
*/ */
DDRB |= (1 << DDB1); DDRB |= (1 << DDB5);
/* /*
* Enable timer interrupt vector * Enable timer interrupt vector
@ -128,12 +131,12 @@ static void setup_clock_external() {
/* /*
* Configure MISO as output * Configure MISO as output
*/ */
DDRB |= (1 << DDB3); DDRB |= (1 << DDB4);
/* /*
* Configure MOSI as input * Configure SS as input
*/ */
DDRB &= ~(1 << DDB3); DDRB &= ~(1 << DDB2);
/* /*
* Set SPI slave mode, and shift in/out most significant bit first * Set SPI slave mode, and shift in/out most significant bit first
@ -150,8 +153,9 @@ static void setup_clock_external() {
*/ */
SPDR = 0; SPDR = 0;
buffer.len = 0; buffer.len = 0;
buffer.cur = 0; buffer.cur = 0;
buffer.read = 0;
} }
/*static void snooze() { /*static void snooze() {
@ -210,7 +214,7 @@ int main() {
break; break;
} }
case TABBY_COMMAND_CLOCK_SOURCE: case TABBY_COMMAND_CLOCK_SOURCE: {
switch (c) { switch (c) {
case TABBY_CLOCK_SOURCE_INTERNAL: { case TABBY_CLOCK_SOURCE_INTERNAL: {
source = c; source = c;
@ -232,6 +236,7 @@ int main() {
goto reset; goto reset;
} }
} }
}
case TABBY_COMMAND_CLOCK_SPEED: { case TABBY_COMMAND_CLOCK_SPEED: {
switch (c) { switch (c) {
@ -254,7 +259,7 @@ int main() {
} }
default: { default: {
break; goto reset;
} }
} }