mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
OP-1403 - Support HMC5983 temperature sensor/compensation
This commit is contained in:
parent
3c1b689224
commit
2a8429320d
@ -135,6 +135,7 @@ static int32_t PIOS_HMC5x83_Config(const struct pios_hmc5x83_cfg *cfg)
|
|||||||
CTRLB = 0;
|
CTRLB = 0;
|
||||||
|
|
||||||
CTRLA |= (uint8_t)(cfg->M_ODR | cfg->Meas_Conf);
|
CTRLA |= (uint8_t)(cfg->M_ODR | cfg->Meas_Conf);
|
||||||
|
CTRLA |= cfg->TempCompensation ? PIOS_HMC5x83_CTRLA_TEMP : 0;
|
||||||
CTRLB |= (uint8_t)(cfg->Gain);
|
CTRLB |= (uint8_t)(cfg->Gain);
|
||||||
MODE |= (uint8_t)(cfg->Mode);
|
MODE |= (uint8_t)(cfg->Mode);
|
||||||
|
|
||||||
|
@ -76,6 +76,8 @@
|
|||||||
#define PIOS_HMC5x83_GAIN_5_6 0xC0
|
#define PIOS_HMC5x83_GAIN_5_6 0xC0
|
||||||
#define PIOS_HMC5x83_GAIN_8_1 0xE0
|
#define PIOS_HMC5x83_GAIN_8_1 0xE0
|
||||||
|
|
||||||
|
#define PIOS_HMC5x83_CTRLA_TEMP 0x40
|
||||||
|
|
||||||
/* Modes */
|
/* Modes */
|
||||||
#define PIOS_HMC5x83_MODE_CONTINUOUS 0x00
|
#define PIOS_HMC5x83_MODE_CONTINUOUS 0x00
|
||||||
#define PIOS_HMC5x83_MODE_SINGLE 0x01
|
#define PIOS_HMC5x83_MODE_SINGLE 0x01
|
||||||
@ -109,10 +111,11 @@ struct pios_hmc5x83_cfg {
|
|||||||
#ifdef PIOS_HMC5x83_HAS_GPIOS
|
#ifdef PIOS_HMC5x83_HAS_GPIOS
|
||||||
const struct pios_exti_cfg *exti_cfg; /* Pointer to the EXTI configuration */
|
const struct pios_exti_cfg *exti_cfg; /* Pointer to the EXTI configuration */
|
||||||
#endif
|
#endif
|
||||||
uint8_t M_ODR; /* OUTPUT DATA RATE --> here below the relative define (See datasheet page 11 for more details) */
|
uint8_t M_ODR; // OUTPUT DATA RATE --> here below the relative define (See datasheet page 11 for more details) */
|
||||||
uint8_t Meas_Conf; /* Measurement Configuration,: Normal, positive bias, or negative bias --> here below the relative define */
|
uint8_t Meas_Conf; // Measurement Configuration,: Normal, positive bias, or negative bias --> here below the relative define */
|
||||||
uint8_t Gain; /* Gain Configuration, select the full scale --> here below the relative define (See datasheet page 11 for more details) */
|
uint8_t Gain; // Gain Configuration, select the full scale --> here below the relative define (See datasheet page 11 for more details) */
|
||||||
uint8_t Mode;
|
uint8_t Mode;
|
||||||
|
bool TempCompensation; // enable temperature sensor on HMC5983 for temperature gain compensation
|
||||||
const struct pios_hmc5x83_io_driver *Driver;
|
const struct pios_hmc5x83_io_driver *Driver;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user