GY-63_MS5611/libraries/hmc6352/hmc6352.h

95 lines
1.9 KiB
C
Raw Normal View History

2020-11-27 05:16:22 -05:00
#pragma once
//
2013-09-30 11:00:55 -04:00
// FILE: hmc6352.h
// AUTHOR: Rob Tillaart
2020-11-27 05:16:22 -05:00
// VERSION: 0.2.0
2013-09-30 11:00:55 -04:00
// PURPOSE: HMC6352 library for Arduino
//
2020-11-27 05:16:22 -05:00
// HISTORY: see cpp file
2013-09-30 11:00:55 -04:00
2020-11-27 05:16:22 -05:00
#include "Wire.h"
#include "Arduino.h"
2020-11-27 05:16:22 -05:00
#define HMC6352_LIB_VERSION "0.2.0"
2020-11-27 05:16:22 -05:00
/* ERROR CODES ALL FUNCTIONS
//
// * twi_writeTo codes (== endTransmission commands)
// 0 .. OK
// -1 .. length to long for buffer
// -2 .. address send, NACK received
// -3 .. data send, NACK received
// -4 .. other twi error (lost bus arbitration, bus error, ..)
//
// * requestFrom
// -10 .. not enough values returned
//
// * function calls
// 0 .. OK
// -20 .. error param1
// -21 .. error param2
// -22 .. error param3
//
*/
2013-09-30 11:00:55 -04:00
enum hmcMode { STANDBY=0, QUERY=1, CONT=2, ERROR};
class hmc6352
{
public:
hmc6352(uint8_t device);
2013-09-30 11:00:55 -04:00
2020-11-27 05:16:22 -05:00
#if defined (ESP8266) || defined(ESP32)
void begin(uint8_t sda, uint8_t scl);
#endif
void begin();
// BASIC CALLS FOR STANDBY MODE
int getHeading(void); // just a merge of ask & read
int askHeading(void);
int readHeading(void);
int wakeUp(void);
int sleep(void);
// EXPERT CALLS
int factoryReset();
int setOperationalModus(hmcMode m, uint8_t freq, bool periodicReset);
int getOperationalModus();
int setOutputModus(uint8_t om);
int getOutputModus();
int callibrationOn(void);
int callibrationOff(void);
int setI2CAddress(uint8_t address);
int getI2CAddress();
2013-09-30 11:00:55 -04:00
int writeEEPROM(uint8_t address, uint8_t data);
int readEEPROM(uint8_t address);
int writeRAM(uint8_t address, uint8_t data);
int readRAM(uint8_t address);
2013-09-30 11:00:55 -04:00
2020-11-27 05:16:22 -05:00
// allow power users to set operational mode flags
int saveOpMode(byte OpMode);
// NOT TESTED / UNKNOWN
int setTimeDelay(uint8_t msec);
int getTimeDelay();
int setMeasurementSumming(uint8_t ms);
int getMeasurementSumming();
int updateOffsets(void);
2013-09-30 11:00:55 -04:00
private:
int cmd(uint8_t c);
int readCmd(uint8_t c, uint8_t address);
int writeCmd(uint8_t c, uint8_t address, uint8_t data);
2013-09-30 11:00:55 -04:00
uint8_t _device;
2013-09-30 11:00:55 -04:00
};
2020-11-27 05:16:22 -05:00
// -- END OF FILE --