#ifndef LAMP_I2C_WRITE_H
#define LAMP_I2C_WRITE_H
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
typedef enum {LIW_IDLE,LIW_TX,LIW_STOP,LIW_DONE,LIW_FAILED} lamp_i2c_write_state;
typedef struct {
 lamp_i2c_write_state state;
 uint32_t started,last_poll,completed,error_flags;
 uint8_t bytes[25],length,sent;bool valid;
} lamp_i2c_write;
/* One register+value (control 0..0x39/0x3f/0x40), or complete 24-channel
 * PWM/IREF burst (0x8a/0xa2). Caller must configure/verify MODE1 burst range
 * before bursts. This transport does not supply current/thermal permission.
 * No IRQ/DMA; use the same exclusive main-loop bus owner as the reader. */
void lamp_i2c_write_reset(lamp_i2c_write *w);
bool lamp_i2c_write_start(lamp_i2c_write *w,uint8_t addr,const uint8_t *bytes,size_t n,uint32_t now);
void lamp_i2c_write_poll(lamp_i2c_write *w,uint32_t now);
void lamp_i2c_write_cancel(lamp_i2c_write *w);
bool lamp_i2c_write_done(const lamp_i2c_write *w,uint32_t now);
#endif
