whatever
This commit is contained in:
parent
35d47901d6
commit
904bf866a6
2 changed files with 13 additions and 11 deletions
|
@ -15,7 +15,7 @@ OBJCOPY = $(CROSS)objcopy
|
||||||
OBJCOPY_FLAGS = -S
|
OBJCOPY_FLAGS = -S
|
||||||
|
|
||||||
AVRDUDE = avrdude
|
AVRDUDE = avrdude
|
||||||
AVRDUDE_DEVICE = /dev/cu.usbmodem1421
|
AVRDUDE_DEVICE = /dev/ttyACM0
|
||||||
AVRDUDE_FLAGS = -c arduino -p atmega328p -b 115200 -D -P $(AVRDUDE_DEVICE)
|
AVRDUDE_FLAGS = -c arduino -p atmega328p -b 115200 -D -P $(AVRDUDE_DEVICE)
|
||||||
|
|
||||||
HEADERS_LOCAL =
|
HEADERS_LOCAL =
|
||||||
|
|
22
avr/send.c
22
avr/send.c
|
@ -43,7 +43,7 @@ static void spi_init() {
|
||||||
/*
|
/*
|
||||||
* Set output pins clear by default
|
* Set output pins clear by default
|
||||||
*/
|
*/
|
||||||
PORTB &= ~(1 << PORTB4);
|
PORTB &= ~((1 << PORTB5) | (1 << PORTB4));
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t spi_send_byte(uint8_t value) {
|
static uint8_t spi_send_byte(uint8_t value) {
|
||||||
|
@ -51,27 +51,27 @@ static uint8_t spi_send_byte(uint8_t value) {
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
for (i=0; i<8; i++) {
|
for (i=0; i<8; i++) {
|
||||||
|
PORTB |= (1 << PORTB5);
|
||||||
|
|
||||||
if (value & 0x80) {
|
if (value & 0x80) {
|
||||||
PORTB |= (1 << PORTB4);
|
PORTB |= (1 << PORTB4);
|
||||||
} else {
|
} else {
|
||||||
PORTB &= ~(1 << PORTB4);
|
PORTB &= ~(1 << PORTB4);
|
||||||
}
|
}
|
||||||
|
|
||||||
value <<= 1;
|
_delay_us(140);
|
||||||
|
|
||||||
PORTB |= (1 << PORTB5);
|
|
||||||
|
|
||||||
_delay_us(60);
|
|
||||||
|
|
||||||
ret <<= 1;
|
ret <<= 1;
|
||||||
|
|
||||||
PORTB &= ~(1 << PORTB5);
|
|
||||||
|
|
||||||
if (PINB & (1 << PINB3)) {
|
if (PINB & (1 << PINB3)) {
|
||||||
ret |= 1;
|
ret |= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_delay_us(60);
|
PORTB &= ~(1 << PORTB5);
|
||||||
|
|
||||||
|
_delay_us(140);
|
||||||
|
|
||||||
|
value <<= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -91,7 +91,9 @@ static void spi_send_packet() {
|
||||||
(void)spi_send_byte( sum & 0x00ff);
|
(void)spi_send_byte( sum & 0x00ff);
|
||||||
(void)spi_send_byte((sum & 0xff00) >> 8);
|
(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);
|
status = spi_send_byte(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue