Commit 224f9dacd14a39a06d4c93dd1106a7883d59cdff
authorMichel Pollet <buserror@gmail.com>
Tue, 22 Feb 2011 17:25:43 +0000 (17:25 +0000)
committerMichel Pollet <buserror@gmail.com>
Tue, 22 Feb 2011 17:25:43 +0000 (17:25 +0000)
First bits of the system that provide names for the IRQs

Signed-off-by: Michel Pollet <buserror@gmail.com>
8 files changed:
examples/parts/ac_input.c
examples/parts/button.c
examples/parts/button.h
examples/parts/hc595.c
examples/parts/hc595.h
examples/parts/hd44780.c
examples/parts/hd44780.h
examples/parts/uart_udp.c

index a363f6bc91e220681c5a90bfabf29fee819ef950..ef30b82f29182464e3a3b2ebd9f02b47ec5022b8 100644 (file)
@@ -34,9 +34,10 @@ switch_auto(struct avr_t * avr,
        return when + avr_usec_to_cycles(avr, 100000 / 50);
 }
 
-void ac_input_init(struct avr_t *avr, ac_input_t *b)
+void ac_input_init(avr_t *avr, ac_input_t *b)
 {
-       b->irq = avr_alloc_irq(0, IRQ_AC_COUNT);
+       const char * name = ">ac_input";
+       b->irq = avr_alloc_irq(&avr->irq_pool, 0, IRQ_AC_COUNT, &name);
        b->avr = avr;
        b->value = 0;
        avr_cycle_timer_register_usec(avr, 100000 / 50, switch_auto, b);
index 2b89683a7e60be7a5be0227287720537823e40c9..0cdf30b3187c5c50a7291922ea2b21cdebece02d 100644 (file)
 #include "sim_avr.h"
 #include "button.h"
 
-static avr_cycle_count_t button_auto_release(struct avr_t * avr, avr_cycle_count_t when, void * param)
+static avr_cycle_count_t
+button_auto_release(
+               avr_t * avr,
+               avr_cycle_count_t when,
+               void * param)
 {
        button_t * b = (button_t *)param;
        avr_raise_irq(b->irq + IRQ_BUTTON_OUT, 1);
@@ -42,7 +46,10 @@ static avr_cycle_count_t button_auto_release(struct avr_t * avr, avr_cycle_count
  * button press. set the "pin" to zerok and register a timer
  * that will reset it in a few usecs
  */
-void button_press(button_t * b, uint32_t duration_usec)
+void
+button_press(
+               button_t * b,
+               uint32_t duration_usec)
 {
        avr_cycle_timer_cancel(b->avr, button_auto_release, b);
        avr_raise_irq(b->irq + IRQ_BUTTON_OUT, 0);// press
@@ -50,9 +57,13 @@ void button_press(button_t * b, uint32_t duration_usec)
        avr_cycle_timer_register_usec(b->avr, duration_usec, button_auto_release, b);
 }
 
-void button_init(struct avr_t *avr, button_t * b)
+void
+button_init(
+               avr_t *avr,
+               button_t * b,
+               const char * name)
 {
-       b->irq = avr_alloc_irq(0, IRQ_BUTTON_COUNT);    
+       b->irq = avr_alloc_irq(&avr->irq_pool, 0, IRQ_BUTTON_COUNT, &name);
        b->avr = avr;
 }
 
index 51cecc8acd9839f6b3c94cdf26c954d8db16fbd5..4df476795f0b938d280d874a29e5fbb61ae33e71 100644 (file)
@@ -41,7 +41,15 @@ typedef struct button_t {
        uint8_t value;
 } button_t;
 
-void button_init(struct avr_t * avr, button_t * b);
+void
+button_init(
+               struct avr_t * avr,
+               button_t * b,
+               const char * name);
+
+void
+button_press(
+               button_t * b,
+               uint32_t duration_usec);
 
-void button_press(button_t * b, uint32_t duration_usec);
 #endif /* __BUTTON_H__*/
index 7d9e5e09903f999b9116932e2415701803cdb176..b0441dba8ef6bf90e842b920aef87a88b5209282 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include "sim_avr.h"
 #include "hc595.h"
 
 /*
@@ -62,9 +63,20 @@ static void hc595_reset_hook(struct avr_irq_t * irq, uint32_t value, void * para
                p->latch = p->value = 0;
 }
 
-void hc595_init(hc595_t *p)
+const char * irq_names[IRQ_HC595_COUNT] = {
+               [IRQ_HC595_SPI_BYTE_IN] = "8<hc595.in",
+               [IRQ_HC595_SPI_BYTE_OUT] = "8>hc595.chain",
+               [IRQ_HC595_IN_LATCH] = "<hc595.latch",
+               [IRQ_HC595_IN_RESET] = "<hc595.reset",
+               [IRQ_HC595_OUT] = "8>hc595.out",
+};
+
+void
+hc595_init(
+               struct avr_t * avr,
+               hc595_t *p)
 {
-       p->irq = avr_alloc_irq(0, IRQ_HC595_COUNT);
+       p->irq = avr_alloc_irq(&avr->irq_pool, 0, IRQ_HC595_COUNT, irq_names);
        avr_irq_register_notify(p->irq + IRQ_HC595_SPI_BYTE_IN, hc595_spi_in_hook, p);
        avr_irq_register_notify(p->irq + IRQ_HC595_IN_LATCH, hc595_latch_hook, p);
        avr_irq_register_notify(p->irq + IRQ_HC595_IN_RESET, hc595_reset_hook, p);
index 22d5844f22b0e3b595a4ae68c8208ed729f11b3f..9f5b88761a2f3c4ae6b1b9db76fb3c460116cfde 100644 (file)
@@ -52,6 +52,9 @@ typedef struct hc595_t {
        uint32_t        value;          // value shifted in
 } hc595_t;
 
-void hc595_init(hc595_t *p);
+void
+hc595_init(
+               struct avr_t * avr,
+               hc595_t *p);
 
 #endif
index f5ed19ba1c2ce313832386c7a88f05b16e2cb6af..b6c73ff25d488c1c7d96ded0bbf965a62c158f43 100644 (file)
@@ -345,6 +345,26 @@ hd44780_pin_changed_hook(
                avr_cycle_timer_register(b->avr, 1, _hd44780_process_e_pinchange, b);
 }
 
+const char * irq_names[IRQ_HD44780_COUNT] = {
+       [IRQ_HD44780_ALL] = "7=hd44780.pins",
+       [IRQ_HD44780_RS] = "<hd44780.RS",
+       [IRQ_HD44780_RW] = "<hd44780.RW",
+       [IRQ_HD44780_E] = "<hd44780.E",
+       [IRQ_HD44780_D0] = "=hd44780.D0",
+       [IRQ_HD44780_D1] = "=hd44780.D1",
+       [IRQ_HD44780_D2] = "=hd44780.D2",
+       [IRQ_HD44780_D3] = "=hd44780.D3",
+       [IRQ_HD44780_D4] = "=hd44780.D4",
+       [IRQ_HD44780_D5] = "=hd44780.D5",
+       [IRQ_HD44780_D6] = "=hd44780.D6",
+       [IRQ_HD44780_D7] = "=hd44780.D7",
+
+       [IRQ_HD44780_BUSY] = ">hd44780.BUSY",
+       [IRQ_HD44780_ADDR] = "7>hd44780.ADDR",
+       [IRQ_HD44780_DATA_IN] = "8>hd44780.DATA_IN",
+       [IRQ_HD44780_DATA_OUT] = "8>hd44780.DATA_OUT",
+};
+
 void
 hd44780_init(
                struct avr_t *avr,
@@ -359,7 +379,7 @@ hd44780_init(
        /*
         * Register callbacks on all our IRQs
         */
-       b->irq = avr_alloc_irq(0, IRQ_HD44780_COUNT);
+       b->irq = avr_alloc_irq(&avr->irq_pool, 0, IRQ_HD44780_COUNT, irq_names);
        for (int i = 0; i < IRQ_HD44780_INPUT_COUNT; i++)
                avr_irq_register_notify(b->irq + i, hd44780_pin_changed_hook, b);
 
index e3f1dd0985a70905a183004ec2e6ed332bc7683c..39353e53a7a3ff825d2624fbb77099a9fe17e606 100644 (file)
@@ -60,7 +60,7 @@ enum {
     IRQ_HD44780_D4,IRQ_HD44780_D5,IRQ_HD44780_D6,IRQ_HD44780_D7,
     IRQ_HD44780_INPUT_COUNT,
 
-    IRQ_HD44780_BUSY,  // for VCD traces sake...
+    IRQ_HD44780_BUSY = IRQ_HD44780_INPUT_COUNT,        // for VCD traces sake...
     IRQ_HD44780_ADDR,
     IRQ_HD44780_DATA_IN,
     IRQ_HD44780_DATA_OUT,
index 83dee89dae8ca905a25d9889fffaad5a672ca825..a0fe7e9e2078b6746072a8b56cb3db9a38857255 100644 (file)
@@ -124,11 +124,15 @@ static void * uart_udp_thread(void * param)
        }
 }
 
+const char * irq_names[IRQ_UART_UDP_COUNT] = {
+       [IRQ_UART_UDP_BYTE_IN] = "8<uart_udp.in",
+       [IRQ_UART_UDP_BYTE_OUT] = "8>uart_udp.out",
+};
 
 void uart_udp_init(struct avr_t * avr, uart_udp_t * p)
 {
        p->avr = avr;
-       p->irq = avr_alloc_irq(0, IRQ_UART_UDP_COUNT);
+       p->irq = avr_alloc_irq(&avr->irq_pool, 0, IRQ_UART_UDP_COUNT, irq_names);
        avr_irq_register_notify(p->irq + IRQ_UART_UDP_BYTE_IN, uart_udp_in_hook, p);
 
        if ((p->s = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {