From: Michel Pollet <buserror@gmail.com>
Date: Tue, 22 Feb 2011 17:25:43 +0000 (+0000)
Subject: parts: Updated to name their IRQs
X-Git-Tag: v1.0a7~22
X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=224f9dacd14a39a06d4c93dd1106a7883d59cdff;p=sx%2Fsimavr.git

parts: Updated to name their IRQs

First bits of the system that provide names for the IRQs

Signed-off-by: Michel Pollet <buserror@gmail.com>
---

diff --git a/examples/parts/ac_input.c b/examples/parts/ac_input.c
index a363f6b..ef30b82 100644
--- a/examples/parts/ac_input.c
+++ b/examples/parts/ac_input.c
@@ -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);
diff --git a/examples/parts/button.c b/examples/parts/button.c
index 2b89683..0cdf30b 100644
--- a/examples/parts/button.c
+++ b/examples/parts/button.c
@@ -30,7 +30,11 @@
 #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;
 }
 
diff --git a/examples/parts/button.h b/examples/parts/button.h
index 51cecc8..4df4767 100644
--- a/examples/parts/button.h
+++ b/examples/parts/button.h
@@ -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__*/
diff --git a/examples/parts/hc595.c b/examples/parts/hc595.c
index 7d9e5e0..b0441db 100644
--- a/examples/parts/hc595.c
+++ b/examples/parts/hc595.c
@@ -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);
diff --git a/examples/parts/hc595.h b/examples/parts/hc595.h
index 22d5844..9f5b887 100644
--- a/examples/parts/hc595.h
+++ b/examples/parts/hc595.h
@@ -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
diff --git a/examples/parts/hd44780.c b/examples/parts/hd44780.c
index f5ed19b..b6c73ff 100644
--- a/examples/parts/hd44780.c
+++ b/examples/parts/hd44780.c
@@ -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);
 
diff --git a/examples/parts/hd44780.h b/examples/parts/hd44780.h
index e3f1dd0..39353e5 100644
--- a/examples/parts/hd44780.h
+++ b/examples/parts/hd44780.h
@@ -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,
diff --git a/examples/parts/uart_udp.c b/examples/parts/uart_udp.c
index 83dee89..a0fe7e9 100644
--- a/examples/parts/uart_udp.c
+++ b/examples/parts/uart_udp.c
@@ -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) {