mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
parent
3a35bfbabf
commit
3e73b3de53
3 changed files with 17 additions and 15 deletions
|
@ -113,9 +113,9 @@
|
|||
|
||||
static float magGain[3] = { 1.0f, 1.0f, 1.0f };
|
||||
|
||||
static hmc5883Config_t *hmc5883Config = NULL;
|
||||
static const hmc5883Config_t *hmc5883Config = NULL;
|
||||
|
||||
bool hmc5883lDetect(mag_t* mag, hmc5883Config_t *hmc5883ConfigToUse)
|
||||
bool hmc5883lDetect(mag_t* mag, const hmc5883Config_t *hmc5883ConfigToUse)
|
||||
{
|
||||
bool ack = false;
|
||||
uint8_t sig = 0;
|
||||
|
|
|
@ -28,6 +28,6 @@ typedef struct hmc5883Config_s {
|
|||
GPIO_TypeDef *gpioPort;
|
||||
} hmc5883Config_t;
|
||||
|
||||
bool hmc5883lDetect(mag_t* mag, hmc5883Config_t *hmc5883ConfigToUse);
|
||||
bool hmc5883lDetect(mag_t* mag, const hmc5883Config_t *hmc5883ConfigToUse);
|
||||
void hmc5883lInit(void);
|
||||
void hmc5883lRead(int16_t *magData);
|
||||
|
|
|
@ -457,26 +457,28 @@ static void detectMag(magSensor_e magHardwareToUse)
|
|||
magSensor_e magHardware;
|
||||
|
||||
#ifdef USE_MAG_HMC5883
|
||||
hmc5883Config_t *hmc5883Config = 0;
|
||||
const hmc5883Config_t *hmc5883Config = 0;
|
||||
|
||||
#ifdef NAZE
|
||||
static hmc5883Config_t nazeHmc5883Config;
|
||||
|
||||
static const hmc5883Config_t nazeHmc5883Config_v1_v4 = {
|
||||
.gpioAPB2Peripherals = RCC_APB2Periph_GPIOB,
|
||||
.gpioPin = Pin_12,
|
||||
.gpioPort = GPIOB
|
||||
};
|
||||
static const hmc5883Config_t nazeHmc5883Config_v5 = {
|
||||
.gpioAPB2Peripherals = RCC_APB2Periph_GPIOC,
|
||||
.gpioPin = Pin_14,
|
||||
.gpioPort = GPIOC
|
||||
};
|
||||
if (hardwareRevision < NAZE32_REV5) {
|
||||
nazeHmc5883Config.gpioAPB2Peripherals = RCC_APB2Periph_GPIOB;
|
||||
nazeHmc5883Config.gpioPin = Pin_12;
|
||||
nazeHmc5883Config.gpioPort = GPIOB;
|
||||
hmc5883Config = &nazeHmc5883Config_v1_v4;
|
||||
} else {
|
||||
nazeHmc5883Config.gpioAPB2Peripherals = RCC_APB2Periph_GPIOC;
|
||||
nazeHmc5883Config.gpioPin = Pin_14;
|
||||
nazeHmc5883Config.gpioPort = GPIOC;
|
||||
hmc5883Config = &nazeHmc5883Config_v5;
|
||||
}
|
||||
|
||||
hmc5883Config = &nazeHmc5883Config;
|
||||
#endif
|
||||
|
||||
#ifdef SPRACINGF3
|
||||
static hmc5883Config_t spRacingF3Hmc5883Config = {
|
||||
static const hmc5883Config_t spRacingF3Hmc5883Config = {
|
||||
.gpioAHBPeripherals = RCC_AHBPeriph_GPIOC,
|
||||
.gpioPin = Pin_14,
|
||||
.gpioPort = GPIOC
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue