diff --git a/avr/Makefile b/avr/Makefile index c1277a8..9daccfe 100644 --- a/avr/Makefile +++ b/avr/Makefile @@ -8,7 +8,7 @@ CROSS = avr- CC = $(CROSS)gcc CFLAGS = $(CGFLAGS) -Wall -Os -mmcu=atmega328p -I$(INCLUDE_PATH) \ - -DF_CPU=$(CLOCK_SPEED) + -DF_CPU=$(CLOCK_SPEED) -DUSE_2X LDFLAGS = OBJCOPY = $(CROSS)objcopy diff --git a/avr/send.c b/avr/send.c index be6442f..c0dac07 100644 --- a/avr/send.c +++ b/avr/send.c @@ -68,10 +68,10 @@ static uint8_t spi_send_byte(uint8_t value) { PORTB &= ~(1 << PORTB4); } - value <<= 1; - ret <<= 1; + _delay_us(61); - _delay_us(60); + ret <<= 1; + value <<= 1; if (PINB & (1 << PINB3)) { ret |= 1; @@ -79,11 +79,9 @@ static uint8_t spi_send_byte(uint8_t value) { PORTB |= (1 << PORTB5); - _delay_us(60); + _delay_us(61); } - _delay_us(150); - return ret; } @@ -104,22 +102,7 @@ static void spi_send_packet() { response.device = spi_send_byte(0); response.status = spi_send_byte(0); - _delay_us(270); -} - -static uint16_t checksum() { - uint16_t sum = 0; - size_t i; - - for (i=2; i<6; i++) { - sum += header.data[i]; - } - - for (i=0; i