#ifndef SOFT_I2C_H
#define SOFT_I2C_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
typedef enum {SI_OK,SI_ARGUMENT,SI_BUSY,SI_STRETCH_TIMEOUT,SI_DEADLINE,SI_NACK,SI_DATA_HELD,SI_TIMER_STALLED} si_status;
typedef struct {
 void*ctx;void(*scl)(void*,bool);void(*sda)(void*,bool);
 bool(*read_scl)(void*);bool(*read_sda)(void*);uint16_t(*ticks)(void*);
 si_status status;uint16_t started;uint32_t polls;
} si_bus;
/* All pin bools mean true=release open-drain, false=pull low. Never drive high.
   Single master, maximum17 payload bytes, 5us low/high minimum candidate.
   Timer1MHz required. No automatic bus clear clocks or retry. */
bool si_write(si_bus*b,uint8_t address,const uint8_t*data,size_t count);
#endif
