diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/iicbus/iiconf.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/sys/dev/iicbus/iiconf.c b/sys/dev/iicbus/iiconf.c index 47f1686..353a207 100644 --- a/sys/dev/iicbus/iiconf.c +++ b/sys/dev/iicbus/iiconf.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: iiconf.c,v 1.3 1998/11/22 22:01:42 nsouch Exp $ + * $Id: iiconf.c,v 1.4 1999/01/09 18:08:24 nsouch Exp $ * */ #include <sys/param.h> @@ -196,6 +196,28 @@ iicbus_start(device_t bus, u_char slave, int timeout) } /* + * iicbus_repeated_start() + * + * Send start condition to the slave addressed by 'slave' + */ +int +iicbus_repeated_start(device_t bus, u_char slave, int timeout) +{ + struct iicbus_softc *sc = (struct iicbus_softc *)device_get_softc(bus); + int error = 0; + + if (!sc->started) + return (EINVAL); /* bus should have been already started */ + + if (!(error = IICBUS_START(device_get_parent(bus), slave, timeout))) + sc->started = slave; + else + sc->started = 0; + + return (error); +} + +/* * iicbus_stop() * * Send stop condition to the bus @@ -254,6 +276,33 @@ iicbus_read(device_t bus, char *buf, int len, int *read, int last, int delay) } /* + * iicbus_write_byte() + * + * Write a byte to the slave previously started by iicbus_start() call + */ +int +iicbus_write_byte(device_t bus, char byte, int timeout) +{ + char data = byte; + int sent; + + return (iicbus_write(bus, &data, 1, &sent, timeout)); +} + +/* + * iicbus_read_byte() + * + * Read a byte from the slave previously started by iicbus_start() call + */ +int +iicbus_read_byte(device_t bus, char *byte, int timeout) +{ + int read; + + return (iicbus_read(bus, byte, 1, &read, IIC_LAST_READ, timeout)); +} + +/* * iicbus_block_write() * * Write a block of data to slave ; start/stop protocol managed |