# HG changeset patch # User Paul Boddie # Date 1714778856 -7200 # Node ID c4c278adb02affb537cd33a16d72b63bdb95ccc4 # Parent 6e9cf17d54cb9535997b4f48cc86aecaafe8c767 Fixed I2C operations by reinstating IRQ binding to the main thread for I2C IRQs. diff -r 6e9cf17d54cb -r c4c278adb02a pkg/landfall-examples/hw_info/hw_info.c --- a/pkg/landfall-examples/hw_info/hw_info.c Sat May 04 00:28:29 2024 +0200 +++ b/pkg/landfall-examples/hw_info/hw_info.c Sat May 04 01:27:36 2024 +0200 @@ -103,6 +103,21 @@ return 0; } +/* Attach ourselves to the interrupt handler. */ + +static int bind_irq(int num, l4_cap_idx_t irq) +{ + long err = l4_error(l4_rcv_ep_bind_thread(irq, l4re_env()->main_thread, num)); + + if (err) + { + printf("Could not attach to IRQ: %ld\n", err); + return 1; + } + + return 0; +} + static const char *delimiters = " \n"; static char *read_token(const char *message) @@ -934,6 +949,11 @@ if (init_irq(num, irqcap, i2c_irq_start, i2c_irq_end)) return; + /* Bind to the IRQ so that we may use it in this program directly. */ + + if (bind_irq(num, irqcap)) + return; + i2c_channels[num] = i2c_get_channel(i2c, num); i2c_irqs[num] = irqcap; }