/*==============================================================================
 * i2c_manager.h - HW / SW I2C mutex control
 *
 * Manages the mutually-exclusive HW TWI and SW bit-bang I2C modes.
 * Only one mode may be active at a time.
 *
 * Flags:
 *   HW_I2C_FRQ : true when HW TWI mode is active
 *   SW_I2C_FRQ : true when SW bit-bang mode is active
 *============================================================================*/
#ifndef __I2C_MANAGER_H__
#define __I2C_MANAGER_H__

#include <stdbool.h>
#include "app_error.h"

extern bool HW_I2C_FRQ;
extern bool SW_I2C_FRQ;

/* Initialise HW I2C (TWI) mode. If SW mode is active it is released first.
 * No-op if HW mode is already active. Call before ICM42670P IMU access. */
void hw_i2c_init_once(void);

/* Initialise SW I2C (bit-bang) mode (legacy, currently unused).
 * If HW mode is active it is released first. */
void sw_i2c_init_once(void);

/* Reset both mode flags to false, forcing re-initialisation on next call. */
void i2c_reset_state(void);

#endif
