#ifndef MAG_H
#define MAG_H

#include <stdint.h>

typedef enum {
    MAG_NONE    = 0,
    MAG_QMC5883L,   /* I2C 0x0D — most common on external compass modules */
    MAG_HMC5883L,   /* I2C 0x1E — legacy Honeywell part */
    MAG_IST8310,    /* I2C 0x0E — iSentek part, common on CUAV boards */
} mag_type_t;

/*
 * Auto-detect magnetometer on I2C1.
 * Returns detected type (MAG_NONE if nothing found).
 * Requires i2c1_init() before calling.
 */
mag_type_t mag_init(void);

/*
 * Read compass heading (degrees × 10, 0–3599).
 * Returns -1 if data not ready or no sensor.
 */
int16_t mag_read_heading(void);

#endif /* MAG_H */
