1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-31 16:52:10 +01:00

OP-1477 - support for mag

This commit is contained in:
Alessio Morale 2014-09-07 22:29:30 +02:00
parent c28eb4fbca
commit b3a971e91d
4 changed files with 55 additions and 0 deletions

View File

@ -199,6 +199,55 @@ void PIOS_SPI_mag_flash_irq_handler(void)
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 */
#if defined(PIOS_INCLUDE_USART)

View File

@ -54,6 +54,7 @@ SRC += $(OPSYSTEM)/pios_board.c
SRC += $(OPUAVOBJ)/uavobjectmanager.c
SRC += $(OPUAVOBJ)/eventdispatcher.c
SRC += $(PIOSCOMMON)/pios_hmc5x83.c
## UAVObjects
SRC += $(OPUAVSYNTHDIR)/firmwareiapobj.c

View File

@ -83,6 +83,7 @@
//#define PIOS_MPU6000_ACCEL
/* #define PIOS_INCLUDE_HMC5843 */
/* #define PIOS_INCLUDE_HMC5883 */
#define PIOS_INCLUDE_HMC5X83
/* #define PIOS_HMC5883_HAS_GPIOS */
/* #define PIOS_INCLUDE_BMP085 */
/* #define PIOS_INCLUDE_MS5611 */

View File

@ -74,6 +74,10 @@ void PIOS_Board_Init(void)
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
/* Initialize the task monitor */