avr/spi_test/main.c

37 lines
879 B
C

#include <avr/io.h>
#include <util/delay.h>
#include <base.h>
#include <spi.h>
int main(void) {
spi_t spi = (spi_t){
.clock = { .ddr = &DDRF, .port = &PORTF, .addr = 7 },
.data_out = { .ddr = &DDRF, .port = &PORTF, .addr = 6 },
.data_in = { .ddr = &DDRF, .port = &PORTF, .addr = 5 },
.chip_select = { .ddr = &DDRF, .port = &PORTF, .addr = 4 },
};
io_pin_t light = { .ddr = &DDRC, .port = &PORTC, .addr = 7 };
initialize_spi(&spi);
while (1) {
set_pin(&light);
transfer_byte(&spi, 0xaa);
_delay_ms(1000);
clear_pin(&light);
_delay_ms(1000);
}
/*
while(1) {
set_pin(&spi.clock);
set_pin(&spi.data_out);
_delay_ms(500);
clear_pin(&spi.clock);
clear_pin(&spi.data_out);
_delay_ms(500);
}
*/
}