1.1 --- a/pkg/devices/lib/i2c/include/i2c-jz4780.h Sun Jul 21 19:17:00 2019 +0200
1.2 +++ b/pkg/devices/lib/i2c/include/i2c-jz4780.h Sun Jul 21 21:10:24 2019 +0200
1.3 @@ -1,5 +1,5 @@
1.4 /*
1.5 - * Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk>
1.6 + * Copyright (C) 2017, 2018, 2019 Paul Boddie <paul@boddie.org.uk>
1.7 *
1.8 * This program is free software; you can redistribute it and/or
1.9 * modify it under the terms of the GNU General Public License as
1.10 @@ -37,33 +37,45 @@
1.11 Hw::Register_block<32> _regs;
1.12 Cpm_jz4780_chip *_cpm;
1.13 uint32_t _frequency;
1.14 - unsigned queued, _pos, _reqpos, _total;
1.15 +
1.16 + // Buffer management.
1.17 +
1.18 + unsigned int _pos, _reqpos, _total;
1.19 uint8_t *_buf;
1.20 - int _fail, _stop, _last;
1.21 +
1.22 + // Status conditions.
1.23 +
1.24 + int _fail;
1.25
1.26 public:
1.27 I2c_jz4780_channel(l4_addr_t start, Cpm_jz4780_chip *cpm,
1.28 uint32_t frequency);
1.29
1.30 void set_target(uint8_t addr);
1.31 - void start_read(uint8_t buf[], unsigned total);
1.32 + void start_read(uint8_t buf[], unsigned int total);
1.33 void read();
1.34 + void write(uint8_t buf[], unsigned int total);
1.35 +
1.36 + // Transaction control.
1.37 +
1.38 + void stop();
1.39 + void disable();
1.40 +
1.41 + // Specific status conditions.
1.42 +
1.43 + unsigned int have_read();
1.44 int read_done();
1.45 - unsigned have_read();
1.46 int read_incomplete();
1.47 - void write(uint8_t buf[], unsigned total);
1.48 - void stop();
1.49 + int read_failed();
1.50 + int write_failed();
1.51
1.52 private:
1.53 - void disable();
1.54 void enable();
1.55
1.56 int active();
1.57 int have_input();
1.58 int have_output();
1.59 int can_send();
1.60 - int read_failed();
1.61 - int write_failed();
1.62
1.63 void reset_flags();
1.64 void init_parameters();
1.65 @@ -71,7 +83,7 @@
1.66
1.67 void set_read_threshold();
1.68 void queue_reads();
1.69 - void queue_writes(uint8_t buf[], unsigned *pos, unsigned total);
1.70 + void queue_writes(uint8_t buf[], unsigned int *pos, unsigned int total);
1.71 void store_reads();
1.72 };
1.73
1.74 @@ -102,15 +114,24 @@
1.75 void *jz4780_i2c_init(l4_addr_t start, l4_addr_t end, void *cpm,
1.76 uint32_t frequency);
1.77
1.78 +void jz4780_i2c_disable(void *i2c_channel);
1.79 +
1.80 void *jz4780_i2c_get_channel(void *i2c, uint8_t channel);
1.81
1.82 void jz4780_i2c_set_target(void *i2c_channel, uint8_t addr);
1.83 -void jz4780_i2c_start_read(void *i2c_channel, uint8_t buf[], unsigned total);
1.84 +
1.85 +void jz4780_i2c_start_read(void *i2c_channel, uint8_t buf[], unsigned int total);
1.86 +
1.87 void jz4780_i2c_read(void *i2c_channel);
1.88 +
1.89 int jz4780_i2c_read_done(void *i2c_channel);
1.90 -unsigned jz4780_i2c_have_read(void *i2c_channel);
1.91 +
1.92 +unsigned int jz4780_i2c_have_read(void *i2c_channel);
1.93 +
1.94 int jz4780_i2c_read_incomplete(void *i2c_channel);
1.95 -void jz4780_i2c_write(void *i2c_channel, uint8_t buf[], unsigned total);
1.96 +
1.97 +void jz4780_i2c_write(void *i2c_channel, uint8_t buf[], unsigned int total);
1.98 +
1.99 void jz4780_i2c_stop(void *i2c_channel);
1.100
1.101 EXTERN_C_END