mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Added GPIO functions for accelerometer full-scale selection.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@625 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
73b5e29e02
commit
5991a93739
@ -95,6 +95,7 @@ SRC += $(PIOSSTM32F10X)/pios_usart.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_irq.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_adc.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_i2c.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_gpio.c
|
||||
#SRC += $(PIOSSTM32F10X)/pios_spi.c
|
||||
|
||||
## PIOS Hardware (Common)
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
/* Function Prototypes */
|
||||
|
||||
|
||||
/**
|
||||
* AHRS Main function
|
||||
*/
|
||||
@ -54,6 +55,10 @@ int main()
|
||||
PIOS_I2C_Init();
|
||||
PIOS_HMC5843_Init();
|
||||
|
||||
/* Setup the Accelerometer FS (Full-Scale) GPIO */
|
||||
PIOS_GPIO_Enable(0);
|
||||
SET_ACCEL_2G;
|
||||
|
||||
/* Configure the HMC5843 Sensor */
|
||||
PIOS_HMC5843_ConfigTypeDef HMC5843_InitStructure;
|
||||
HMC5843_InitStructure.M_ODR = PIOS_HMC5843_ODR_10;
|
||||
@ -82,12 +87,13 @@ int main()
|
||||
if(heading < 0) heading += 360;
|
||||
|
||||
// Output Heading data to
|
||||
PIOS_COM_SendFormattedString(COM_USART1, "Chip ID: %s\rHeading: %d\rRaw Mag Values: X=%d Y=%d Y=%d\r", id, heading, data[0], data[1], data[2]);
|
||||
PIOS_COM_SendFormattedString(COM_USART1, "HMC5843 Chip ID: %s\rHeading: %d\rRaw Mag Values: X=%d Y=%d Y=%d\r", id, heading, data[0], data[1], data[2]);
|
||||
|
||||
// Test ADC
|
||||
PIOS_COM_SendFormattedString(COM_USART1, "ADC Values: %d,%d,%d,%d,%d,%d\r\n", PIOS_ADC_PinGet(0), PIOS_ADC_PinGet(1), PIOS_ADC_PinGet(2), PIOS_ADC_PinGet(3), PIOS_ADC_PinGet(4), PIOS_ADC_PinGet(5));
|
||||
|
||||
PIOS_DELAY_WaitmS(250);
|
||||
// Delay until next reading
|
||||
PIOS_DELAY_WaitmS(500);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -302,4 +302,17 @@ TIM8 | | | |
|
||||
/* (1 / (ADCCLK / CYCLES)) = Sample Time (<28>S) */
|
||||
#define PIOS_ADC_IRQ_PRIO PIOS_IRQ_PRIO_HIGH
|
||||
|
||||
//-------------------------
|
||||
// GPIO
|
||||
//-------------------------
|
||||
#define PIOS_GPIO_1_PORT GPIOB
|
||||
#define PIOS_GPIO_1_PIN GPIO_Pin_9
|
||||
#define PIOS_GPIO_1_GPIO_CLK RCC_APB2Periph_GPIOB
|
||||
#define PIOS_GPIO_PORTS { PIOS_GPIO_1_PORT }
|
||||
#define PIOS_GPIO_PINS { PIOS_GPIO_1_PIN }
|
||||
#define PIOS_GPIO_CLKS { PIOS_GPIO_1_GPIO_CLK }
|
||||
#define PIOS_GPIO_NUM 1
|
||||
#define SET_ACCEL_2G PIOS_GPIO_On(0);
|
||||
#define SET_ACCEL_6G PIOS_GPIO_Off(0)
|
||||
|
||||
#endif /* PIOS_BOARD_H */
|
||||
|
@ -38,6 +38,7 @@
|
||||
#define PIOS_INCLUDE_USART
|
||||
#define PIOS_INCLUDE_COM
|
||||
#define PIOS_INCLUDE_HMC5843
|
||||
#define PIOS_INCLUDE_GPIO
|
||||
|
||||
|
||||
#endif /* PIOS_CONFIG_H */
|
||||
|
@ -41,7 +41,7 @@ static const uint32_t GPIO_CLK[PIOS_GPIO_NUM] = PIOS_GPIO_CLKS;
|
||||
|
||||
|
||||
/**
|
||||
* Initialises all the LED's
|
||||
* Initialises all the GPIO's
|
||||
*/
|
||||
void PIOS_GPIO_Init(void)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user