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);
#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);
* 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
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;
}
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__*/
#include <stdlib.h>
#include <stdio.h>
+#include "sim_avr.h"
#include "hc595.h"
/*
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);
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
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,
/*
* 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);
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,
}
}
+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) {