mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-12 02:54:15 +01:00
OP-1477 - support for mag
This commit is contained in:
parent
c28eb4fbca
commit
b3a971e91d
@ -199,6 +199,55 @@ void PIOS_SPI_mag_flash_irq_handler(void)
|
|||||||
PIOS_SPI_IRQ_Handler(pios_spi_mag_flash_id);
|
PIOS_SPI_IRQ_Handler(pios_spi_mag_flash_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_HMC5X83)
|
||||||
|
#include "pios_hmc5x83.h"
|
||||||
|
#ifdef PIOS_HMC5x83_HAS_GPIOS
|
||||||
|
static const struct pios_exti_cfg pios_exti_mag_cfg __exti_config = {
|
||||||
|
.vector = PIOS_HMC5x83_IRQHandler,
|
||||||
|
.line = EXTI_Line7,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_7,
|
||||||
|
.GPIO_Speed = GPIO_Speed_100MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_IN,
|
||||||
|
.GPIO_OType = GPIO_OType_OD,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = EXTI9_5_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.exti = {
|
||||||
|
.init = {
|
||||||
|
.EXTI_Line = EXTI_Line7, // matches above GPIO pin
|
||||||
|
.EXTI_Mode = EXTI_Mode_Interrupt,
|
||||||
|
.EXTI_Trigger = EXTI_Trigger_Rising,
|
||||||
|
.EXTI_LineCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const struct pios_hmc5x83_cfg pios_mag_cfg = {
|
||||||
|
#ifdef PIOS_HMC5x83_HAS_GPIOS
|
||||||
|
.exti_cfg = &pios_exti_mag_cfg,
|
||||||
|
#endif
|
||||||
|
.M_ODR = PIOS_HMC5x83_ODR_75,
|
||||||
|
.Meas_Conf = PIOS_HMC5x83_MEASCONF_NORMAL,
|
||||||
|
.Gain = PIOS_HMC5x83_GAIN_1_9,
|
||||||
|
.Mode = PIOS_HMC5x83_MODE_CONTINUOUS,
|
||||||
|
.Driver = &PIOS_HMC5x83_SPI_DRIVER,
|
||||||
|
};
|
||||||
|
#endif /* PIOS_INCLUDE_HMC5883 */
|
||||||
|
|
||||||
|
|
||||||
#endif /* PIOS_INCLUDE_SPI */
|
#endif /* PIOS_INCLUDE_SPI */
|
||||||
|
|
||||||
#if defined(PIOS_INCLUDE_USART)
|
#if defined(PIOS_INCLUDE_USART)
|
||||||
|
@ -54,6 +54,7 @@ SRC += $(OPSYSTEM)/pios_board.c
|
|||||||
SRC += $(OPUAVOBJ)/uavobjectmanager.c
|
SRC += $(OPUAVOBJ)/uavobjectmanager.c
|
||||||
SRC += $(OPUAVOBJ)/eventdispatcher.c
|
SRC += $(OPUAVOBJ)/eventdispatcher.c
|
||||||
|
|
||||||
|
SRC += $(PIOSCOMMON)/pios_hmc5x83.c
|
||||||
|
|
||||||
## UAVObjects
|
## UAVObjects
|
||||||
SRC += $(OPUAVSYNTHDIR)/firmwareiapobj.c
|
SRC += $(OPUAVSYNTHDIR)/firmwareiapobj.c
|
||||||
|
@ -83,6 +83,7 @@
|
|||||||
//#define PIOS_MPU6000_ACCEL
|
//#define PIOS_MPU6000_ACCEL
|
||||||
/* #define PIOS_INCLUDE_HMC5843 */
|
/* #define PIOS_INCLUDE_HMC5843 */
|
||||||
/* #define PIOS_INCLUDE_HMC5883 */
|
/* #define PIOS_INCLUDE_HMC5883 */
|
||||||
|
#define PIOS_INCLUDE_HMC5X83
|
||||||
/* #define PIOS_HMC5883_HAS_GPIOS */
|
/* #define PIOS_HMC5883_HAS_GPIOS */
|
||||||
/* #define PIOS_INCLUDE_BMP085 */
|
/* #define PIOS_INCLUDE_BMP085 */
|
||||||
/* #define PIOS_INCLUDE_MS5611 */
|
/* #define PIOS_INCLUDE_MS5611 */
|
||||||
|
@ -74,6 +74,10 @@ void PIOS_Board_Init(void)
|
|||||||
PIOS_Assert(0);
|
PIOS_Assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PIOS_INCLUDE_HMC5X83
|
||||||
|
PIOS_SPI_SetPrescalar(pios_spi_mag_flash_id, SPI_BaudRatePrescaler_16);
|
||||||
|
PIOS_HMC5x83_Init(&pios_mag_cfg, pios_spi_mag_flash_id, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* Initialize the task monitor */
|
/* Initialize the task monitor */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user