1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-23 00:00:06 +01:00
libwebsockets/minimal-examples/embedded/esp32/esp-c3dev/main/i2c.c
Andy Green 06e881aad6 esp32c3
Add
2021-08-31 05:45:40 +01:00

32 lines
440 B
C

#include "i2c.h"
int
lws_i2c_command(lws_i2c_ops_t *ctx, uint8_t ads, uint8_t c)
{
if (ctx->start(ctx))
return 1;
if (ctx->write(ctx, ads << 1)) {
ctx->stop(ctx);
return 1;
}
ctx->write(ctx, 0);
ctx->write(ctx, c);
ctx->stop(ctx);
return 0;
}
int
lws_i2c_command_list(lws_i2c_ops_t *ctx, uint8_t ads, const uint8_t *buf, size_t len)
{
while (len--)
if (lws_i2c_command(ctx, ads, *buf++))
return 1;
return 0;
}