libwebsockets
Lightweight C library for HTML5 websockets
lws-bb-i2c.h
Go to the documentation of this file.
1 /*
2  * I2C - bitbanged generic gpio implementation
3  *
4  * Copyright (C) 2019 - 2020 Andy Green <andy@warmcat.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  *
24  * This is like an abstract class for gpio, a real implementation provides
25  * functions for the ops that use the underlying OS gpio arrangements.
26  */
27 
28 typedef struct lws_bb_i2c {
29  lws_i2c_ops_t bb_ops; /* init to lws_bb_i2c_ops */
30 
31  /* implementation-specific members */
32 
35 
37  void (*delay)(void);
39 
40 #define lws_bb_i2c_ops \
41  { \
42  .init = lws_bb_i2c_init, \
43  .start = lws_bb_i2c_start, \
44  .stop = lws_bb_i2c_stop, \
45  .write = lws_bb_i2c_write, \
46  .read = lws_bb_i2c_read, \
47  .set_ack = lws_bb_i2c_set_ack, \
48  }
49 
50 int
52 
53 int
55 
56 void
58 
59 int
61 
62 int
64 
65 void
66 lws_bb_i2c_set_ack(const lws_i2c_ops_t *octx, int ack);
unsigned char uint8_t
struct lws_bb_i2c lws_bb_i2c_t
int lws_bb_i2c_init(const lws_i2c_ops_t *octx)
int lws_bb_i2c_write(const lws_i2c_ops_t *octx, uint8_t data)
void lws_bb_i2c_stop(const lws_i2c_ops_t *octx)
void lws_bb_i2c_set_ack(const lws_i2c_ops_t *octx, int ack)
int lws_bb_i2c_start(const lws_i2c_ops_t *octx)
int lws_bb_i2c_read(const lws_i2c_ops_t *octx)
int _lws_plat_gpio_t
Definition: lws-gpio.h:31
const lws_gpio_ops_t * gpio
Definition: lws-bb-i2c.h:36
lws_i2c_ops_t bb_ops
Definition: lws-bb-i2c.h:29
void(* delay)(void)
Definition: lws-bb-i2c.h:37
_lws_plat_gpio_t scl
Definition: lws-bb-i2c.h:33
_lws_plat_gpio_t sda
Definition: lws-bb-i2c.h:34