1#include "i2c.h" 2 3int 4lws_i2c_command(lws_i2c_ops_t *ctx, uint8_t ads, uint8_t c) 5{ 6 if (ctx->start(ctx)) 7 return 1; 8 9 if (ctx->write(ctx, ads << 1)) { 10 ctx->stop(ctx); 11 12 return 1; 13 } 14 15 ctx->write(ctx, 0); 16 ctx->write(ctx, c); 17 ctx->stop(ctx); 18 19 return 0; 20} 21 22int 23lws_i2c_command_list(lws_i2c_ops_t *ctx, uint8_t ads, const uint8_t *buf, size_t len) 24{ 25 while (len--) 26 if (lws_i2c_command(ctx, ads, *buf++)) 27 return 1; 28 29 return 0; 30} 31 32 33