Commit 82f36e2c5b3436a12499b7d8ca3b09f0e0ab1b85
authorMichel Pollet <buserror@gmail.com>
Fri, 6 Apr 2012 15:31:10 +0000 (16:31 +0100)
committerMichel Pollet <buserror@gmail.com>
Fri, 6 Apr 2012 15:31:10 +0000 (16:31 +0100)
Just need one of these

Signed-off-by: Michel Pollet <buserror@gmail.com>
8 files changed:
examples/board_i2ctest/Makefile
examples/board_i2ctest/atmega1280_i2ctest.c [new file with mode: 0644]
examples/board_i2ctest/atmega48_i2ctest.c [deleted file]
examples/board_i2ctest/i2ctest.c
examples/board_i2ctest_atmega1280/Makefile [deleted file]
examples/board_i2ctest_atmega1280/README [deleted file]
examples/board_i2ctest_atmega1280/atmega1280_i2ctest.c [deleted file]
examples/board_i2ctest_atmega1280/i2ctest.c [deleted file]

index 689d113a417db07b1cb3b8dc2ac21581f3b3b6ce..651f0810e9ba5e61e072cc88f78a68aa6e1fbf86 100644 (file)
 target=        i2ctest
 firm_src = ${wildcard at*${board}.c}
 firmware = ${firm_src:.c=.axf}
-simavr = ../../
+simavr = ../..
 
 SHELL   = /bin/bash
 
 IPATH = .
-IPATH += ../parts
+IPATH += ${simavr}/examples/shared
+IPATH += ${simavr}/examples/parts
 IPATH += ${simavr}/include
 IPATH += ${simavr}/simavr/sim
 
 VPATH = .
-VPATH += ../parts
-VPATH += ../shared
+VPATH += ${simavr}/examples/shared
+VPATH += ${simavr}/examples/parts
 
 
-all: obj atmega48_${target}.axf ${target} 
+all: obj ${firmware} ${target} 
 
 include ${simavr}/Makefile.common
 
-atmega48_${target}.axf: atmega48_${target}.c
-atmega48_${target}.axf: avr_twi_master.c avr_twi_master.h
+atmega1280_${target}.axf: atmega1280_${target}.c
+atmega1280_${target}.axf: ${simavr}/examples/shared/avr_twi_master.c
+atmega1280_${target}.axf: ${simavr}/examples/shared/avr_twi_master.h
 
 board = ${OBJ}/${target}.elf
 
diff --git a/examples/board_i2ctest/atmega1280_i2ctest.c b/examples/board_i2ctest/atmega1280_i2ctest.c
new file mode 100644 (file)
index 0000000..e40e73f
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+       atmega48_i2ctest.c
+
+       Copyright 2008-2011 Michel Pollet <buserror@gmail.com>
+
+       This file is part of simavr.
+
+       simavr is free software: you can redistribute it and/or modify
+       it under the terms of the GNU General Public License as published by
+       the Free Software Foundation, either version 3 of the License, or
+       (at your option) any later version.
+
+       simavr is distributed in the hope that it will be useful,
+       but WITHOUT ANY WARRANTY; without even the implied warranty of
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+       GNU General Public License for more details.
+
+       You should have received a copy of the GNU General Public License
+       along with simavr.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <avr/sleep.h>
+
+// for linker, emulator, and programmer's sake
+#include "avr_mcu_section.h"
+AVR_MCU(F_CPU, "atmega1280");
+
+#include "../shared/avr_twi_master.h"
+
+#include <stdio.h>
+
+static int uart_putchar(char c, FILE *stream) {
+  if (c == '\n')
+    uart_putchar('\r', stream);
+  loop_until_bit_is_set(UCSR0A, UDRE0);
+  UDR0 = c;
+  return 0;
+}
+
+static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL,
+                                         _FDEV_SETUP_WRITE);
+
+int main()
+{
+       stdout = &mystdout;
+
+       sei();
+
+       TWI_Master_Initialise();
+
+       {       // write 2 bytes at some random address
+               uint8_t msg[8] = {
+                               0xa0, // TWI address,
+                               0xaa, 0x01, // eeprom address, in little endian
+                               0xde, 0xad,     // data bytes
+               };
+               TWI_Start_Transceiver_With_Data(msg, 5, 1);
+
+               while (TWI_Transceiver_Busy())
+                       sleep_mode();
+       }
+       {
+               uint8_t msg[8] = {
+                               0xa0, // TWI address,
+                               0xa8, 0x01, // eeprom address, in little endian
+               };
+               TWI_Start_Transceiver_With_Data(msg, 3, 0); // dont send stop!
+
+               while (TWI_Transceiver_Busy())
+                       sleep_mode();
+       }
+       {
+               uint8_t msg[9] = {
+                               0xa0 + 1, // TWI address,
+               };
+               TWI_Start_Transceiver_With_Data(msg, 9, 1); // write 1 byte, read 8, send stop
+
+               while (TWI_Transceiver_Busy())
+                       sleep_mode();
+       }
+       cli();
+       sleep_mode();
+}
+
diff --git a/examples/board_i2ctest/atmega48_i2ctest.c b/examples/board_i2ctest/atmega48_i2ctest.c
deleted file mode 100644 (file)
index 5a91326..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-       atmega48_i2ctest.c
-
-       Copyright 2008-2011 Michel Pollet <buserror@gmail.com>
-
-       This file is part of simavr.
-
-       simavr is free software: you can redistribute it and/or modify
-       it under the terms of the GNU General Public License as published by
-       the Free Software Foundation, either version 3 of the License, or
-       (at your option) any later version.
-
-       simavr is distributed in the hope that it will be useful,
-       but WITHOUT ANY WARRANTY; without even the implied warranty of
-       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-       GNU General Public License for more details.
-
-       You should have received a copy of the GNU General Public License
-       along with simavr.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <avr/sleep.h>
-
-// for linker, emulator, and programmer's sake
-#include "avr_mcu_section.h"
-AVR_MCU(F_CPU, "atmega48");
-
-#include "avr_twi_master.h"
-
-#include <stdio.h>
-
-static int uart_putchar(char c, FILE *stream) {
-  if (c == '\n')
-    uart_putchar('\r', stream);
-  loop_until_bit_is_set(UCSR0A, UDRE0);
-  UDR0 = c;
-  return 0;
-}
-
-static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL,
-                                         _FDEV_SETUP_WRITE);
-
-int main()
-{
-       stdout = &mystdout;
-
-       sei();
-       TWI_Master_Initialise();
-
-       {       // write 2 bytes at some random address
-               uint8_t msg[8] = {
-                               0xa0, // TWI address,
-                               0xaa, 0x01, // eeprom address, in little endian
-                               0xde, 0xad,     // data bytes
-               };
-               TWI_Start_Transceiver_With_Data(msg, 5, 1);
-
-               while (TWI_Transceiver_Busy())
-                       sleep_mode();
-       }
-       {
-               uint8_t msg[8] = {
-                               0xa0, // TWI address,
-                               0xa8, 0x01, // eeprom address, in little endian
-               };
-               TWI_Start_Transceiver_With_Data(msg, 3, 0); // dont send stop!
-
-               while (TWI_Transceiver_Busy())
-                       sleep_mode();
-       }
-       {
-               uint8_t msg[9] = {
-                               0xa0 + 1, // TWI address,
-               };
-               TWI_Start_Transceiver_With_Data(msg, 9, 1); // write 1 byte, read 8, send stop
-
-               while (TWI_Transceiver_Busy())
-                       sleep_mode();
-       }
-       cli();
-       sleep_mode();
-}
-
index 7cb80d35cd387fd3c6242b4120baabf2081b6a6c..7d191de155a43a1c47019c2827faa907d9e21993 100644 (file)
@@ -39,7 +39,7 @@ i2c_eeprom_t ee;
 int main(int argc, char *argv[])
 {
        elf_firmware_t f;
-       const char * fname =  "atmega48_i2ctest.axf";
+       const char * fname =  "atmega1280_i2ctest.axf";
 
        printf("Firmware pathname is %s\n", fname);
        elf_read_firmware(fname, &f);
@@ -74,16 +74,17 @@ int main(int argc, char *argv[])
         *      Pressing "r" and "s" during the demo will start and stop recording
         *      the pin changes
         */
-       avr_vcd_init(avr, "gtkwave_output.vcd", &vcd_file, 100000 /* usec */);
-       avr_vcd_add_signal(&vcd_file,
-               avr_io_getirq(avr, AVR_IOCTL_TWI_GETIRQ(0), TWI_IRQ_STATUS), 8 /* bits */ ,
-               "TWSR" );
+//     avr_vcd_init(avr, "gtkwave_output.vcd", &vcd_file, 100000 /* usec */);
+//     avr_vcd_add_signal(&vcd_file,
+//             avr_io_getirq(avr, AVR_IOCTL_TWI_GETIRQ(0), TWI_IRQ_STATUS), 8 /* bits */ ,
+//             "TWSR" );
 
-       printf( "Demo launching:\n");
+       printf( "\nDemo launching:\n");
 
-       while (1) {
-               int state = avr_run(avr);
-               if ( state == cpu_Done || state == cpu_Crashed)
-                       break;
-       }
+       int state = cpu_Running;
+       while((state!= cpu_Done)&&(state != cpu_Crashed ))
+               state = avr_run(avr);
+
+       printf("\n\nPress enter to terminate the program.");
+       getchar();
 }
diff --git a/examples/board_i2ctest_atmega1280/Makefile b/examples/board_i2ctest_atmega1280/Makefile
deleted file mode 100644 (file)
index 0cbef69..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-# 
-#      Copyright 2008-2012 Michel Pollet <buserror@gmail.com>
-#
-#      This file is part of simavr.
-#
-#      simavr is free software: you can redistribute it and/or modify
-#      it under the terms of the GNU General Public License as published by
-#      the Free Software Foundation, either version 3 of the License, or
-#      (at your option) any later version.
-#
-#      simavr is distributed in the hope that it will be useful,
-#      but WITHOUT ANY WARRANTY; without even the implied warranty of
-#      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#      GNU General Public License for more details.
-#
-#      You should have received a copy of the GNU General Public License
-#      along with simavr.  If not, see <http://www.gnu.org/licenses/>.
-
-target=        i2ctest
-firm_src = ${wildcard at*${board}.c}
-firmware = ${firm_src:.c=.axf}
-simavr = ../..
-#simavr = /usr/local/lib/simavr
-
-SHELL   = /bin/bash
-
-IPATH = .
-#IPATH += ../parts
-IPATH += ${simavr}/examples/parts
-IPATH += ${simavr}/include
-IPATH += ${simavr}/simavr/sim
-
-VPATH = .
-VPATH += ../parts
-VPATH += ../shared
-
-
-all: obj atmega1280_${target}.axf ${target} 
-
-include ${simavr}/Makefile.common
-
-atmega1280_${target}.axf: atmega1280_${target}.c
-atmega1280_${target}.axf: avr_twi_master.c avr_twi_master.h
-
-board = ${OBJ}/${target}.elf
-
-${board} : ${OBJ}/${target}.o
-${board} : ${OBJ}/i2c_eeprom.o
-${board} : ${simavr}/simavr/${OBJ}/libsimavr.a
-
-${target}: ${board}
-       @echo $@ done
-
-clean: clean-${OBJ}
-       rm -rf *.hex *.a *.axf ${target} *.vcd .*.swo .*.swp .*.swm .*.swn
diff --git a/examples/board_i2ctest_atmega1280/README b/examples/board_i2ctest_atmega1280/README
deleted file mode 100644 (file)
index f65bc4e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-
-This contains a sample program to demonstrate the use of simavr
-using 'custom' code, and own "peripherals". It shows how it is
-possible to "hook" code to the AVR pins, and also how to make
-"peripherals" and also hook them up to AVR pins.
-
-This demo demonstrate how to write a i2c/twi "peripheral" and hook it to
-an AVR, and then run a firmware that behaves as a TWI "master" to talk to it.
-
-The code uses a generic i2c "eeprom" were the AVR writes some bytes,
-then read them again. The AVR code is based on the Atmel reference
-implementation, with quite a few changes to make it more functional.
-
-Thid "board" doesn't use opengl, the eeprom will display what the
-transactions are.
\ No newline at end of file
diff --git a/examples/board_i2ctest_atmega1280/atmega1280_i2ctest.c b/examples/board_i2ctest_atmega1280/atmega1280_i2ctest.c
deleted file mode 100644 (file)
index 168bda7..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
-       atmega48_i2ctest.c
-
-       Copyright 2008-2011 Michel Pollet <buserror@gmail.com>
-
-       This file is part of simavr.
-
-       simavr is free software: you can redistribute it and/or modify
-       it under the terms of the GNU General Public License as published by
-       the Free Software Foundation, either version 3 of the License, or
-       (at your option) any later version.
-
-       simavr is distributed in the hope that it will be useful,
-       but WITHOUT ANY WARRANTY; without even the implied warranty of
-       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-       GNU General Public License for more details.
-
-       You should have received a copy of the GNU General Public License
-       along with simavr.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <avr/sleep.h>
-
-// for linker, emulator, and programmer's sake
-#include "avr_mcu_section.h"
-AVR_MCU(F_CPU, "atmega1280");
-
-#include "avr_twi_master.h"
-
-#include <stdio.h>
-
-static int uart_putchar(char c, FILE *stream) {
-  if (c == '\n')
-    uart_putchar('\r', stream);
-  loop_until_bit_is_set(UCSR0A, UDRE0);
-  UDR0 = c;
-  return 0;
-}
-
-static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL,
-                                         _FDEV_SETUP_WRITE);
-
-int main()
-{
-       stdout = &mystdout;
-
-       sei();
-
-       TWI_Master_Initialise();
-
-       {       // write 2 bytes at some random address
-               uint8_t msg[8] = {
-                               0xa0, // TWI address,
-                               0xaa, 0x01, // eeprom address, in little endian
-                               0xde, 0xad,     // data bytes
-               };
-               TWI_Start_Transceiver_With_Data(msg, 5, 1);
-
-               while (TWI_Transceiver_Busy())
-                       sleep_mode();
-       }
-       {
-               uint8_t msg[8] = {
-                               0xa0, // TWI address,
-                               0xa8, 0x01, // eeprom address, in little endian
-               };
-               TWI_Start_Transceiver_With_Data(msg, 3, 0); // dont send stop!
-
-               while (TWI_Transceiver_Busy())
-                       sleep_mode();
-       }
-       {
-               uint8_t msg[9] = {
-                               0xa0 + 1, // TWI address,
-               };
-               TWI_Start_Transceiver_With_Data(msg, 9, 1); // write 1 byte, read 8, send stop
-
-               while (TWI_Transceiver_Busy())
-                       sleep_mode();
-       }
-       cli();
-       sleep_mode();
-}
-
diff --git a/examples/board_i2ctest_atmega1280/i2ctest.c b/examples/board_i2ctest_atmega1280/i2ctest.c
deleted file mode 100644 (file)
index 7d191de..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-       i2ctest.c
-
-       Copyright 2008-2011 Michel Pollet <buserror@gmail.com>
-
-       This file is part of simavr.
-
-       simavr is free software: you can redistribute it and/or modify
-       it under the terms of the GNU General Public License as published by
-       the Free Software Foundation, either version 3 of the License, or
-       (at your option) any later version.
-
-       simavr is distributed in the hope that it will be useful,
-       but WITHOUT ANY WARRANTY; without even the implied warranty of
-       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-       GNU General Public License for more details.
-
-       You should have received a copy of the GNU General Public License
-       along with simavr.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <libgen.h>
-#include <pthread.h>
-
-#include "sim_avr.h"
-#include "avr_twi.h"
-#include "sim_elf.h"
-#include "sim_gdb.h"
-#include "sim_vcd_file.h"
-#include "i2c_eeprom.h"
-
-avr_t * avr = NULL;
-avr_vcd_t vcd_file;
-
-i2c_eeprom_t ee;
-
-int main(int argc, char *argv[])
-{
-       elf_firmware_t f;
-       const char * fname =  "atmega1280_i2ctest.axf";
-
-       printf("Firmware pathname is %s\n", fname);
-       elf_read_firmware(fname, &f);
-
-       printf("firmware %s f=%d mmcu=%s\n", fname, (int)f.frequency, f.mmcu);
-
-       avr = avr_make_mcu_by_name(f.mmcu);
-       if (!avr) {
-               fprintf(stderr, "%s: AVR '%s' now known\n", argv[0], f.mmcu);
-               exit(1);
-       }
-       avr_init(avr);
-       avr_load_firmware(avr, &f);
-
-       // initialize our 'peripheral'
-       i2c_eeprom_init(avr, &ee, 0xa0, 0xfe, NULL, 1024);
-
-       i2c_eeprom_attach(avr, &ee, AVR_IOCTL_TWI_GETIRQ(0));
-       ee.verbose = 1;
-
-       // even if not setup at startup, activate gdb if crashing
-       avr->gdb_port = 1234;
-       if (0) {
-               //avr->state = cpu_Stopped;
-               avr_gdb_init(avr);
-       }
-
-       /*
-        *      VCD file initialization
-        *
-        *      This will allow you to create a "wave" file and display it in gtkwave
-        *      Pressing "r" and "s" during the demo will start and stop recording
-        *      the pin changes
-        */
-//     avr_vcd_init(avr, "gtkwave_output.vcd", &vcd_file, 100000 /* usec */);
-//     avr_vcd_add_signal(&vcd_file,
-//             avr_io_getirq(avr, AVR_IOCTL_TWI_GETIRQ(0), TWI_IRQ_STATUS), 8 /* bits */ ,
-//             "TWSR" );
-
-       printf( "\nDemo launching:\n");
-
-       int state = cpu_Running;
-       while((state!= cpu_Done)&&(state != cpu_Crashed ))
-               state = avr_run(avr);
-
-       printf("\n\nPress enter to terminate the program.");
-       getchar();
-}