1/* 2 * lws-minimal-esp32 3 * 4 * Written in 2010-2020 by Andy Green <andy@warmcat.com> 5 * 6 * This file is made available under the Creative Commons CC0 1.0 7 * Universal Public Domain Dedication. 8 */ 9 10#include <stdint.h> 11#include <stddef.h> 12#include "i2c.h" 13#include "gpio-esp32.h" 14 15typedef struct lws_bb_i2c { 16 lws_i2c_ops_t bb_ops; /* init to lws_bb_i2c_ops */ 17 18 /* implementation-specific members */ 19 20 _lws_plat_gpio_t scl; 21 _lws_plat_gpio_t sda; 22 23 const lws_gpio_ops_t *gpio; 24 void (*delay)(void); 25} lws_bb_i2c_t; 26 27#define lws_bb_i2c_ops \ 28 { \ 29 .start = lws_bb_i2c_start, \ 30 .stop = lws_bb_i2c_stop, \ 31 .write = lws_bb_i2c_write, \ 32 .read = lws_bb_i2c_read, \ 33 .set_ack = lws_bb_i2c_set_ack, \ 34 } 35 36int 37lws_bb_i2c_start(lws_i2c_ops_t *octx); 38 39void 40lws_bb_i2c_stop(lws_i2c_ops_t *octx); 41 42int 43lws_bb_i2c_write(lws_i2c_ops_t *octx, uint8_t data); 44 45int 46lws_bb_i2c_read(lws_i2c_ops_t *octx); 47 48void 49lws_bb_i2c_set_ack(lws_i2c_ops_t *octx, int ack); 50 51 52