Commit 09a568486c9d386621e0fd6638abed590b74c3f2
authorMichel Pollet <buserror@gmail.com>
Tue, 15 Dec 2009 00:06:16 +0000 (00:06 +0000)
committerMichel Pollet <buserror@gmail.com>
Tue, 15 Dec 2009 00:06:16 +0000 (00:06 +0000)
Key maps etc..

Signed-off-by: Michel Pollet <buserror@gmail.com>
examples/board_ledramp/ledramp.c

index b96c0abe3158adab45efadffe1af5ef209fdb658..ca18c58474c6d96f298a2e34d2eaff06a6d9ca8c 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <libgen.h>
 
 #include <GL/glut.h>
 #include <pthread.h>
 #include "avr_ioport.h"
 #include "sim_elf.h"
 #include "sim_gdb.h"
+#include "sim_vcd_file.h"
 
 #include "button.h"
 
 button_t button;
 int do_button_press = 0;
 avr_t * avr = NULL;
+avr_vcd_t vcd_file;
 uint8_t        pin_state = 0;  // current port B
 
 float pixsize = 64;
@@ -93,6 +96,14 @@ void keyCB(unsigned char key, int x, int y)  /* called on key press */
                case ' ':
                        do_button_press++; // pass the message to the AVR thread
                        break;
+               case 'r':
+                       printf("Starting VCD trace\n");
+                       avr_vcd_start(&vcd_file);
+                       break;
+               case 's':
+                       printf("Stopping VCD trace\n");
+                       avr_vcd_stop(&vcd_file);
+                       break;
        }
 }
 
@@ -128,8 +139,11 @@ int main(int argc, char *argv[])
 {
        elf_firmware_t f;
        const char * fname =  "atmega48_ledramp.axf";
-       
-       elf_read_firmware(fname, &f);
+       char path[256];
+
+       sprintf(path, "%s/%s", dirname(argv[0]), fname);
+       printf("Firmware pathname is %s\n", path);
+       elf_read_firmware(path, &f);
 
        printf("firmware %s f=%d mmcu=%s\n", fname, (int)f.mmcu.f_cpu, f.mmcu.name);
 
@@ -147,8 +161,6 @@ int main(int argc, char *argv[])
        avr_connect_irq(
                button.irq + IRQ_BUTTON_OUT,
                avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 0));
-       // 'raise' it, it's a "pullup"
-       avr_raise_irq(button.irq + IRQ_BUTTON_OUT, 1);
 
        // connect all the pins on port B to our callback
        for (int i = 0; i < 8; i++)