avr: clockticks missing in long_options
[avr-sim.git] / test / eeprom_test.c
blob6681d630357f55dd57977fbe97a1f3f4705ee8a9
1 #include <avr/io.h>
2 #include <avr/interrupt.h>
3 #include <stdio.h>
4 #include "eeprom.h"
5 #ifdef HAVE_SPI
6 #include "spi.h"
7 #endif
9 int main(void) {
10 #ifdef HAVE_SPI
11 spi_init();
12 #endif
14 sei(); // enable interrupts
16 internal_eeprom_write8(0xDE, 0);
17 internal_eeprom_write8(0xAD, 1);
19 uint8_t de = internal_eeprom_read8(0);
20 uint8_t ad = internal_eeprom_read8(1);
22 if( de < ad )
23 PORTB |= PB1;
25 spieeprom_write(0xBE, 0);
26 spieeprom_write(0xEF, 1);
27 return 0;
30 void io_init() {
31 DDRA = 0xFF; // Data
32 PORTA = 0x00;
34 DDRB = 0xB9; // spi_clk, spi_in, spi_out, NC, TX, RX, clock in, clock
35 PORTB = 0x02;
37 DDRC = 0xFF; // Address
38 PORTC = 0x00;
40 DDRD = 0xFA; // NC, NC, NC, NC, NC, CAN_INT, MIDI TX & RX
41 PORTD = 0x00;
43 DDRE = 0xFF;
44 PORTE = 0x00;