Lines 275-299
Link Here
|
275 |
static int |
275 |
static int |
276 |
cyapa_read_bytes(device_t dev, uint8_t reg, uint8_t *val, int cnt) |
276 |
cyapa_read_bytes(device_t dev, uint8_t reg, uint8_t *val, int cnt) |
277 |
{ |
277 |
{ |
278 |
uint16_t addr = iicbus_get_addr(dev); |
278 |
return (iicdev_readfrom(dev, reg, val, cnt, IIC_INTRWAIT)); |
279 |
struct iic_msg msgs[] = { |
|
|
280 |
{ addr, IIC_M_WR | IIC_M_NOSTOP, 1, ® }, |
281 |
{ addr, IIC_M_RD, cnt, val }, |
282 |
}; |
283 |
|
284 |
return (iicbus_transfer(dev, msgs, nitems(msgs))); |
285 |
} |
279 |
} |
286 |
|
280 |
|
287 |
static int |
281 |
static int |
288 |
cyapa_write_bytes(device_t dev, uint8_t reg, const uint8_t *val, int cnt) |
282 |
cyapa_write_bytes(device_t dev, uint8_t reg, const uint8_t *val, int cnt) |
289 |
{ |
283 |
{ |
290 |
uint16_t addr = iicbus_get_addr(dev); |
284 |
return (iicdev_writeto(dev, reg, val, cnt, IIC_INTRWAIT)); |
291 |
struct iic_msg msgs[] = { |
|
|
292 |
{ addr, IIC_M_WR | IIC_M_NOSTOP, 1, ® }, |
293 |
{ addr, IIC_M_WR | IIC_M_NOSTART, cnt, __DECONST(uint8_t *, val) }, |
294 |
}; |
295 |
|
296 |
return (iicbus_transfer(dev, msgs, nitems(msgs))); |
297 |
} |
285 |
} |
298 |
|
286 |
|
299 |
static void |
287 |
static void |