This commit is contained in:
XANTRONIX Development 2016-06-04 01:45:57 -05:00
parent 35d47901d6
commit 904bf866a6
2 changed files with 13 additions and 11 deletions

View file

@ -15,7 +15,7 @@ OBJCOPY = $(CROSS)objcopy
OBJCOPY_FLAGS = -S
AVRDUDE = avrdude
AVRDUDE_DEVICE = /dev/cu.usbmodem1421
AVRDUDE_DEVICE = /dev/ttyACM0
AVRDUDE_FLAGS = -c arduino -p atmega328p -b 115200 -D -P $(AVRDUDE_DEVICE)
HEADERS_LOCAL =

View file

@ -43,7 +43,7 @@ static void spi_init() {
/*
* Set output pins clear by default
*/
PORTB &= ~(1 << PORTB4);
PORTB &= ~((1 << PORTB5) | (1 << PORTB4));
}
static uint8_t spi_send_byte(uint8_t value) {
@ -51,27 +51,27 @@ static uint8_t spi_send_byte(uint8_t value) {
i = 0;
for (i=0; i<8; i++) {
PORTB |= (1 << PORTB5);
if (value & 0x80) {
PORTB |= (1 << PORTB4);
} else {
PORTB &= ~(1 << PORTB4);
}
value <<= 1;
PORTB |= (1 << PORTB5);
_delay_us(60);
_delay_us(140);
ret <<= 1;
PORTB &= ~(1 << PORTB5);
if (PINB & (1 << PINB3)) {
ret |= 1;
}
_delay_us(60);
PORTB &= ~(1 << PORTB5);
_delay_us(140);
value <<= 1;
}
return ret;
@ -91,7 +91,9 @@ static void spi_send_packet() {
(void)spi_send_byte( sum & 0x00ff);
(void)spi_send_byte((sum & 0xff00) >> 8);
status = spi_send_byte(0);
_delay_us(1200);
device = spi_send_byte(0);
status = spi_send_byte(0);
}