FreeBSD/sys/dev/iicbus/adt746x.c
/* i2c read/write functions. */
i2c read/write functions.
i2c read / write functions .
static int
adt746x_write(device_t dev, uint32_t addr, uint8_t reg, uint8_t *buff)
{
	uint8_t buf[4];
	int try = 0;
	struct iic_msg msg[] = {
		{addr, IIC_M_WR, 2, buf }
	};
	buf[0] = reg;
	memcpy(buf + 1, buff, 1);
	for (;;)
	{
		if (iicbus_transfer(dev, msg, 1) == 0)
			return (0);
		if (++try > 5) {
			device_printf(dev, "iicbus write failed\n");
			return (-1);
		}
		pause("adt746x_write", hz);
	}
	return (0);
}
static int adt746x_write ( device_t dev , uint32_t addr , uint8_t reg , uint8_t * buff ) { uint8_t buf [ 4 ] ; int try = 0 ; struct iic_msg msg [ ] = { { addr , IIC_M_WR , 2 , buf } } ; buf [ 0 ] = reg ; memcpy ( buf + 1 , buff , 1 ) ; for ( ; ; ) { if ( iicbus_transfer ( dev , msg , 1 ) == 0 ) return ( 0 ) ; if ( ++ try > 5 ) { device_printf ( dev , " \n " ) ; return ( -1 ) ; } pause ( " " , hz ) ; } return ( 0 ) ; }
i2c read/write functions.
i2c read / write functions .
/* Prepare the write msg. */