rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
sense_i2c.h
Go to the documentation of this file.
1
52#ifndef RCBENCH_SENSE_I2C_H
53#define RCBENCH_SENSE_I2C_H
54
55#include <stdbool.h>
56#include <stddef.h>
57#include <stdint.h>
58
59#include "sense_bus.h"
60
64#define SENSE_I2C_HZ 400000u
71#define SENSE_I2C_TIMEOUT_US 1000u
75#define SENSE_I2C_IDLE_US 10u
84#define SENSE_I2C_PROBE_US 50u
88#define SENSE_I2C_CLEAR_HALF_US 5u
93#define SENSE_I2C_CLEAR_STRETCH_US 100u
94
105bool sense_i2c_open(uint8_t sda, uint8_t scl);
106
113void sense_i2c_close(void);
114
126sense_err_t sense_i2c_read(void *ctx, uint8_t addr, uint8_t reg,
127 uint8_t *buf, size_t n);
128
140sense_err_t sense_i2c_write(void *ctx, uint8_t addr, uint8_t reg,
141 const uint8_t *buf, size_t n);
142
150sense_err_t sense_i2c_ask(uint8_t addr);
151
158void sense_i2c_recover(void);
159
160#endif /* RCBENCH_SENSE_I2C_H */
The sensor bus: one I2C (Inter-Integrated Circuit) bus with current monitors on it,...
sense_err_t
What a transaction came to.
Definition sense_bus.h:62
void sense_i2c_recover(void)
The bus clear: the block reset, SCL clocked 9 times as an open-drain GPIO, so a part that was sending...
Definition sense_i2c.c:271
sense_err_t sense_i2c_write(void *ctx, uint8_t addr, uint8_t reg, const uint8_t *buf, size_t n)
sense_i2c_t's write: the register pointer and n bytes.
Definition sense_i2c.c:204
bool sense_i2c_open(uint8_t sda, uint8_t scl)
The block on sda and scl.
Definition sense_i2c.c:61
void sense_i2c_close(void)
The block reset and its pins back to plain inputs, pulled down as at reset.
Definition sense_i2c.c:94
sense_err_t sense_i2c_read(void *ctx, uint8_t addr, uint8_t reg, uint8_t *buf, size_t n)
sense_i2c_t's read: the register pointer, a repeated START and n bytes, most significant first.
Definition sense_i2c.c:181
sense_err_t sense_i2c_ask(uint8_t addr)
Whether addr acknowledges: the address and one byte read.
Definition sense_i2c.c:228