4 Copyright 2008-2011 Michel Pollet <buserror@gmail.com>
6 This file is part of simavr.
8 simavr is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 simavr is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with simavr. If not, see <http://www.gnu.org/licenses/>.
23 #include <avr/interrupt.h>
24 #include <avr/sleep.h>
26 // for linker, emulator, and programmer's sake
27 #include "avr_mcu_section.h"
28 AVR_MCU(F_CPU, "atmega1280");
30 #include "../shared/avr_twi_master.h"
34 static int uart_putchar(char c, FILE *stream) {
36 uart_putchar('\r', stream);
37 loop_until_bit_is_set(UCSR0A, UDRE0);
42 static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL,
51 TWI_Master_Initialise();
53 { // write 2 bytes at some random address
56 0xaa, 0x01, // eeprom address, in little endian
57 0xde, 0xad, // data bytes
59 TWI_Start_Transceiver_With_Data(msg, 5, 1);
61 while (TWI_Transceiver_Busy())
67 0xa8, 0x01, // eeprom address, in little endian
69 TWI_Start_Transceiver_With_Data(msg, 3, 0); // dont send stop!
71 while (TWI_Transceiver_Busy())
76 0xa0 + 1, // TWI address,
78 TWI_Start_Transceiver_With_Data(msg, 9, 1); // write 1 byte, read 8, send stop
80 while (TWI_Transceiver_Busy())