1.1 --- a/pkg/landfall-examples/ci20_i2c/ci20_i2c.c Mon Oct 30 17:21:26 2023 +0100
1.2 +++ b/pkg/landfall-examples/ci20_i2c/ci20_i2c.c Mon Oct 30 17:22:43 2023 +0100
1.3 @@ -62,7 +62,7 @@
1.4 return start - index;
1.5 }
1.6
1.7 -static long i2c_read(void *i2c_channel, uint8_t *buf, unsigned length,
1.8 +static int i2c_read(void *i2c_channel, uint8_t *buf, unsigned length,
1.9 int stop, l4_cap_idx_t irqcap)
1.10 {
1.11 l4_msgtag_t tag;
1.12 @@ -74,18 +74,21 @@
1.13 tag = l4_irq_receive(irqcap, l4_timeout(L4_IPC_TIMEOUT_NEVER, l4_timeout_from_us(1000)));
1.14
1.15 if (l4_ipc_error(tag, l4_utcb()))
1.16 - return 0;
1.17 + break;
1.18
1.19 if (jz4780_i2c_failed(i2c_channel))
1.20 - return 0;
1.21 + break;
1.22
1.23 jz4780_i2c_read(i2c_channel);
1.24 }
1.25
1.26 + if (stop)
1.27 + jz4780_i2c_stop(i2c_channel);
1.28 +
1.29 return jz4780_i2c_have_read(i2c_channel);
1.30 }
1.31
1.32 -static long i2c_write(void *i2c_channel, uint8_t *buf, unsigned length,
1.33 +static int i2c_write(void *i2c_channel, uint8_t *buf, unsigned length,
1.34 int stop, l4_cap_idx_t irqcap)
1.35 {
1.36 l4_msgtag_t tag;
1.37 @@ -98,14 +101,17 @@
1.38 tag = l4_irq_receive(irqcap, l4_timeout(L4_IPC_TIMEOUT_NEVER, l4_timeout_from_us(1000)));
1.39
1.40 if ((err = l4_ipc_error(tag, l4_utcb())))
1.41 - return 0;
1.42 + break;
1.43
1.44 if (jz4780_i2c_failed(i2c_channel))
1.45 - return 0;
1.46 + break;
1.47
1.48 jz4780_i2c_write(i2c_channel);
1.49 }
1.50
1.51 + if (stop)
1.52 + jz4780_i2c_stop(i2c_channel);
1.53 +
1.54 return jz4780_i2c_have_written(i2c_channel);
1.55 }
1.56