What else could I possibly be missing?
This commit is contained in:
parent
c675fc1f54
commit
be7b8d0f66
1 changed files with 13 additions and 10 deletions
23
avr/main.c
23
avr/main.c
|
@ -10,14 +10,14 @@
|
|||
#include <tabby/avr/uart.h>
|
||||
#include <tabby/avr/buffer.h>
|
||||
|
||||
static volatile uint8_t bits = 0;
|
||||
static volatile uint8_t value_in = 0x00; /* Data coming in from Game Boy */
|
||||
static volatile uint8_t value_out = 0x00; /* Data going out to Game Boy */
|
||||
|
||||
static const uint16_t timer_counter_intervals[4] = {
|
||||
1953, 977, 61, 31
|
||||
};
|
||||
|
||||
static volatile uint8_t bits = 0;
|
||||
static volatile uint8_t value_in = 0x00; /* Data coming in from Game Boy */
|
||||
static volatile uint8_t value_out = 0x00; /* Data going out to Game Boy */
|
||||
|
||||
static volatile tabby_avr_buffer buffer = {
|
||||
.len = 0,
|
||||
.cur = 0,
|
||||
|
@ -48,9 +48,9 @@ ISR(TIMER0_COMPB_vect) {
|
|||
if (--bits == 0) {
|
||||
uart_putchar(value_in, NULL);
|
||||
|
||||
if (buffer.cur < buffer.len) {
|
||||
if (buffer.cur < buffer.read) {
|
||||
value_out = buffer.data[buffer.cur++];
|
||||
} else {
|
||||
} else if (buffer.cur == buffer.len) {
|
||||
buffer.len = 0;
|
||||
buffer.cur = 0;
|
||||
buffer.read = 0;
|
||||
|
@ -70,11 +70,11 @@ ISR(TIMER0_COMPB_vect) {
|
|||
* SPI byte receipt interrupt vector
|
||||
*/
|
||||
ISR(SPI_STC_vect) {
|
||||
uart_putchar(SPDR, NULL);
|
||||
uart_putchar(SPDR);
|
||||
|
||||
if (buffer.cur < buffer.len) {
|
||||
if (buffer.cur < buffer.read) {
|
||||
SPDR = buffer.data[buffer.cur++];
|
||||
} else {
|
||||
} else if (buffer.cur == buffer.len) {
|
||||
buffer.len = 0;
|
||||
buffer.cur = 0;
|
||||
buffer.read = 0;
|
||||
|
@ -198,7 +198,10 @@ int main() {
|
|||
buffer.data[buffer.read++] = c;
|
||||
|
||||
if (buffer.read == buffer.len) {
|
||||
goto reset;
|
||||
state = TABBY_COMMAND_NONE;
|
||||
received = 0;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue