#ifndef LAMP_I2C_READ_H
#define LAMP_I2C_READ_H
#include <stdbool.h>
#include <stdint.h>
typedef enum {LIR_IDLE,LIR_TX_POINTER,LIR_WAIT_TC,LIR_RX_BYTE,LIR_WAIT_STOP,LIR_DONE,LIR_FAILED} lamp_i2c_read_state;
typedef struct {
    lamp_i2c_read_state state;
    uint32_t started,last_poll,completed,error_flags;
    uint8_t address,reg,value;
    bool bound,valid;
} lamp_i2c_read;
/* Qualified setup owner must provide verified timing/filter/clock/PE. This
 * reader does not select timing or enable PE and must not run alongside HAL,
 * IRQ/DMA or other I2C1 owners. Readable candidate registers are 0..0x39
 * and 0x3f..0x46; group/address registers are excluded. No register data writes or output permission. */
void lamp_i2c_read_reset(lamp_i2c_read *r);
bool lamp_i2c_read_start(lamp_i2c_read *r,uint8_t address,uint8_t reg,uint32_t now);
void lamp_i2c_read_cancel(lamp_i2c_read *r);
void lamp_i2c_read_poll(lamp_i2c_read *r,uint32_t now);
bool lamp_i2c_read_get(const lamp_i2c_read *r,uint32_t now,uint8_t *value);
#endif
