1.1 --- a/pkg/landfall-examples/ci20_i2c/ci20_i2c.c Sat Oct 28 01:15:45 2023 +0200
1.2 +++ b/pkg/landfall-examples/ci20_i2c/ci20_i2c.c Sun Oct 29 16:14:38 2023 +0100
1.3 @@ -63,19 +63,18 @@
1.4 }
1.5
1.6 static long i2c_read(void *i2c_channel, uint8_t *buf, unsigned length,
1.7 - l4_cap_idx_t irqcap)
1.8 + int stop, l4_cap_idx_t irqcap)
1.9 {
1.10 l4_msgtag_t tag;
1.11 - long err;
1.12
1.13 - jz4780_i2c_start_read(i2c_channel, buf, length);
1.14 + jz4780_i2c_start_read(i2c_channel, buf, length, stop);
1.15
1.16 while (!jz4780_i2c_read_done(i2c_channel))
1.17 {
1.18 - tag = l4_irq_receive(irqcap, l4_timeout(L4_IPC_TIMEOUT_NEVER, l4_timeout_rel(1, 20)));
1.19 + tag = l4_irq_receive(irqcap, l4_timeout(L4_IPC_TIMEOUT_NEVER, l4_timeout_from_us(1000)));
1.20
1.21 - if ((err = l4_ipc_error(tag, l4_utcb())))
1.22 - return err;
1.23 + if (l4_ipc_error(tag, l4_utcb()))
1.24 + return 0;
1.25
1.26 if (jz4780_i2c_failed(i2c_channel))
1.27 return 0;
1.28 @@ -87,19 +86,19 @@
1.29 }
1.30
1.31 static long i2c_write(void *i2c_channel, uint8_t *buf, unsigned length,
1.32 - l4_cap_idx_t irqcap)
1.33 + int stop, l4_cap_idx_t irqcap)
1.34 {
1.35 l4_msgtag_t tag;
1.36 long err;
1.37
1.38 - jz4780_i2c_start_write(i2c_channel, buf, length);
1.39 + jz4780_i2c_start_write(i2c_channel, buf, length, stop);
1.40
1.41 while (!jz4780_i2c_write_done(i2c_channel))
1.42 {
1.43 - tag = l4_irq_receive(irqcap, l4_timeout(L4_IPC_TIMEOUT_NEVER, l4_timeout_rel(1, 20)));
1.44 + tag = l4_irq_receive(irqcap, l4_timeout(L4_IPC_TIMEOUT_NEVER, l4_timeout_from_us(1000)));
1.45
1.46 if ((err = l4_ipc_error(tag, l4_utcb())))
1.47 - return err;
1.48 + return 0;
1.49
1.50 if (jz4780_i2c_failed(i2c_channel))
1.51 return 0;
1.52 @@ -115,9 +114,7 @@
1.53 long pos;
1.54
1.55 memset(buffer, 0, length);
1.56 - pos = i2c_read(i2c_channel, buffer, length, irqcap);
1.57 -
1.58 - jz4780_i2c_stop(i2c_channel);
1.59 + pos = i2c_read(i2c_channel, buffer, length, 1, irqcap);
1.60
1.61 return pos;
1.62 }
1.63 @@ -125,7 +122,7 @@
1.64 static long i2c_get_reg(void *i2c_channel, uint8_t reg, uint8_t *buffer, long length, l4_cap_idx_t irqcap)
1.65 {
1.66 buffer[0] = reg;
1.67 - i2c_write(i2c_channel, buffer, 1, irqcap);
1.68 + i2c_write(i2c_channel, buffer, 1, 0, irqcap);
1.69
1.70 return i2c_get(i2c_channel, buffer, length, irqcap);
1.71 }
1.72 @@ -137,9 +134,7 @@
1.73
1.74 buf[0] = reg;
1.75 memcpy(buf + 1, buffer, length);
1.76 - pos = i2c_write(i2c_channel, buf, length + 1, irqcap);
1.77 -
1.78 - jz4780_i2c_stop(i2c_channel);
1.79 + pos = i2c_write(i2c_channel, buf, length + 1, 1, irqcap);
1.80
1.81 return pos;
1.82 }
1.83 @@ -459,8 +454,8 @@
1.84 sleep(1);
1.85 }
1.86
1.87 - jz4780_i2c_disable(i2c0);
1.88 - jz4780_i2c_disable(i2c4);
1.89 + //jz4780_i2c_disable(i2c0);
1.90 + //jz4780_i2c_disable(i2c4);
1.91
1.92 /* Detach from the interrupt. */
1.93