mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-30 11:37:06 +08:00
merged init_hw.h and interrupt_hw.h into mcu.h - added battery voltage monitoring for fixedwing on stm32
This commit is contained in:
@@ -54,6 +54,8 @@ ap.ARCHDIR = $(ARCH)
|
|||||||
ap.CFLAGS += $(ROTORCRAFT_INC)
|
ap.CFLAGS += $(ROTORCRAFT_INC)
|
||||||
ap.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG) -DPERIPHERALS_AUTO_INIT
|
ap.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG) -DPERIPHERALS_AUTO_INIT
|
||||||
ap.srcs = $(SRC_FIRMWARE)/main.c
|
ap.srcs = $(SRC_FIRMWARE)/main.c
|
||||||
|
ap.srcs += mcu.c
|
||||||
|
ap.srcs += $(SRC_ARCH)/mcu_arch.c
|
||||||
|
|
||||||
ifeq ($(ARCH), stm32)
|
ifeq ($(ARCH), stm32)
|
||||||
ap.srcs += lisa/plug_sys.c
|
ap.srcs += lisa/plug_sys.c
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
# temporary hack for ADCs
|
# temporary hack for ADCs
|
||||||
ifeq ($(ARCH), stm32)
|
ifeq ($(ARCH), stm32)
|
||||||
$(TARGET).CFLAGS += -DSTM32
|
# FIXME : this is for the battery
|
||||||
$(TARGET).CFLAGS += -DUSE_AD1_3
|
$(TARGET).CFLAGS += -DUSE_AD1_3
|
||||||
endif
|
endif
|
||||||
#
|
#
|
||||||
@@ -37,8 +37,12 @@ endif
|
|||||||
#
|
#
|
||||||
|
|
||||||
$(TARGET).CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
|
$(TARGET).CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
|
||||||
|
$(TARGET).CFLAGS += -DPERIPHERALS_AUTO_INIT
|
||||||
$(TARGET).CFLAGS += $(FIXEDWING_INC)
|
$(TARGET).CFLAGS += $(FIXEDWING_INC)
|
||||||
|
|
||||||
|
$(TARGET).srcs += mcu.c
|
||||||
|
$(TARGET).srcs += $(SRC_ARCH)/mcu_arch.c
|
||||||
|
|
||||||
#
|
#
|
||||||
# Common Options
|
# Common Options
|
||||||
#
|
#
|
||||||
@@ -54,7 +58,7 @@ $(TARGET).CFLAGS += -DTRAFFIC_INFO
|
|||||||
# LEDs
|
# LEDs
|
||||||
#
|
#
|
||||||
|
|
||||||
$(TARGET).CFLAGS += -DLED
|
$(TARGET).CFLAGS += -DUSE_LED
|
||||||
ifneq ($(ARCH), lpc21)
|
ifneq ($(ARCH), lpc21)
|
||||||
ifneq ($(ARCH), jsbsim)
|
ifneq ($(ARCH), jsbsim)
|
||||||
$(TARGET).srcs += $(SRC_ARCH)/led_hw.c
|
$(TARGET).srcs += $(SRC_ARCH)/led_hw.c
|
||||||
@@ -135,9 +139,6 @@ ns_srcs += $(SRC_ARCH)/uart_hw.c
|
|||||||
ns_CFLAGS += -DADC
|
ns_CFLAGS += -DADC
|
||||||
#ifeq ($(ARCH), lpc21)
|
#ifeq ($(ARCH), lpc21)
|
||||||
ns_srcs += $(SRC_ARCH)/adc_hw.c
|
ns_srcs += $(SRC_ARCH)/adc_hw.c
|
||||||
#else ifeq ($(ARCH), stm32)
|
|
||||||
# ns_srcs += lisa/lisa_analog_plug.c
|
|
||||||
#endif
|
|
||||||
ifeq ($(ARCH), stm32)
|
ifeq ($(ARCH), stm32)
|
||||||
ns_CFLAGS += -DUSE_ADC1_2_IRQ_HANDLER
|
ns_CFLAGS += -DUSE_ADC1_2_IRQ_HANDLER
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ ADC_IR2 = 2
|
|||||||
ADC_IR2_CHAN = 1
|
ADC_IR2_CHAN = 1
|
||||||
endif
|
endif
|
||||||
ifndef ADC_IR3
|
ifndef ADC_IR3
|
||||||
ADC_IR_TOP = 3
|
ADC_IR_TOP = 4
|
||||||
ADC_IR_TOP_CHAN = 2
|
ADC_IR_TOP_CHAN = 3
|
||||||
endif
|
endif
|
||||||
ifndef ADC_IR_NB_SAMPLES
|
ifndef ADC_IR_NB_SAMPLES
|
||||||
ADC_IR_NB_SAMPLES = 16
|
ADC_IR_NB_SAMPLES = 16
|
||||||
|
|||||||
+1
-1
@@ -58,7 +58,7 @@
|
|||||||
See @ref adc_buf_channel.
|
See @ref adc_buf_channel.
|
||||||
*/
|
*/
|
||||||
struct adc_buf {
|
struct adc_buf {
|
||||||
uint16_t sum; /* Sum of samples in buffer (avg = sum / av_nb_sample) */
|
uint32_t sum; /* Sum of samples in buffer (avg = sum / av_nb_sample) */
|
||||||
uint16_t values[MAX_AV_NB_SAMPLE]; /* Buffer for sample values from ADC */
|
uint16_t values[MAX_AV_NB_SAMPLE]; /* Buffer for sample values from ADC */
|
||||||
uint8_t head; /* Position index of write head in buffer */
|
uint8_t head; /* Position index of write head in buffer */
|
||||||
uint8_t av_nb_sample; /* Number of samples to use in buffer (used for avg) */
|
uint8_t av_nb_sample; /* Number of samples to use in buffer (used for avg) */
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* Paparazzi lpc21 arch dependant microcontroller initialisation function
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 The Paparazzi team
|
||||||
|
*
|
||||||
|
* This file is part of Paparazzi.
|
||||||
|
*
|
||||||
|
* Paparazzi is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Paparazzi is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Paparazzi; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mcu.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include BOARD_CONFIG
|
||||||
|
#include "LPC21xx.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* declare functions and values from crt0.S & the linker control file */
|
||||||
|
extern void reset(void);
|
||||||
|
|
||||||
|
void mcu_arch_init(void) {
|
||||||
|
|
||||||
|
/* set PLL multiplier & divisor. */
|
||||||
|
/* values computed from config.h */
|
||||||
|
PLLCFG = PLLCFG_MSEL | PLLCFG_PSEL;
|
||||||
|
/* enable PLL */
|
||||||
|
PLLCON = PLLCON_PLLE;
|
||||||
|
/* commit changes */
|
||||||
|
PLLFEED = 0xAA;
|
||||||
|
PLLFEED = 0x55;
|
||||||
|
|
||||||
|
/* wait for PLL lock */
|
||||||
|
while (!(PLLSTAT & PLLSTAT_LOCK))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* enable & connect PLL */
|
||||||
|
PLLCON = PLLCON_PLLE | PLLCON_PLLC;
|
||||||
|
/* commit changes */
|
||||||
|
PLLFEED = 0xAA;
|
||||||
|
PLLFEED = 0x55;
|
||||||
|
|
||||||
|
/* setup & enable the MAM */
|
||||||
|
MAMTIM = MAMTIM_CYCLES;
|
||||||
|
MAMCR = MAMCR_FULL;
|
||||||
|
|
||||||
|
/* set the peripheral bus speed */
|
||||||
|
/* value computed from config.h */
|
||||||
|
VPBDIV = VPBDIV_VALUE;
|
||||||
|
|
||||||
|
/* set the interrupt controller to flash */
|
||||||
|
MEMMAP = MEMMAP_FLASH;
|
||||||
|
|
||||||
|
/* clear all interrupts */
|
||||||
|
VICIntEnClear = 0xFFFFFFFF;
|
||||||
|
/* clear all FIQ selections */
|
||||||
|
VICIntSelect = 0x00000000;
|
||||||
|
/* point unvectored IRQs to reset() */
|
||||||
|
VICDefVectAddr = (uint32_t)reset;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Paparazzi lpc21 arch dependant microcontroller initialisation functions
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 The Paparazzi team
|
||||||
|
*
|
||||||
|
* This file is part of Paparazzi.
|
||||||
|
*
|
||||||
|
* Paparazzi is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Paparazzi is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Paparazzi; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LPC21_MCU_ARCH_H
|
||||||
|
#define LPC21_MCU_ARCH_H
|
||||||
|
|
||||||
|
extern void mcu_arch_init(void);
|
||||||
|
|
||||||
|
#include "armVIC.h"
|
||||||
|
|
||||||
|
#define mcu_int_enable() enableIRQ()
|
||||||
|
#define mcu_int_disable() disableIRQ()
|
||||||
|
|
||||||
|
#endif /* LPC21_MCU_ARCH_H */
|
||||||
@@ -125,16 +125,16 @@ static inline void adc_init_irq( void );
|
|||||||
// {{{
|
// {{{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
GPIO mapping for ADC1 pins (PA.B, PB.1, PC.3, PC.5).
|
GPIO mapping for ADC1 pins (PB.1, PB.0, PC.5, PC.3).
|
||||||
Can be changed by predefining ADC1_GPIO_INIT.
|
Can be changed by predefining ADC1_GPIO_INIT.
|
||||||
*/
|
*/
|
||||||
#ifdef USE_AD1
|
#ifdef USE_AD1
|
||||||
#ifndef ADC1_GPIO_INIT
|
#ifndef ADC1_GPIO_INIT
|
||||||
#define ADC1_GPIO_INIT(gpio) { \
|
#define ADC1_GPIO_INIT(gpio) { \
|
||||||
(gpio).GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; \
|
(gpio).GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0; \
|
||||||
(gpio).GPIO_Mode = GPIO_Mode_AIN; \
|
(gpio).GPIO_Mode = GPIO_Mode_AIN; \
|
||||||
GPIO_Init(GPIOB, (&gpio)); \
|
GPIO_Init(GPIOB, (&gpio)); \
|
||||||
(gpio).GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_5; \
|
(gpio).GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_3; \
|
||||||
GPIO_Init(GPIOC, (&gpio)); \
|
GPIO_Init(GPIOC, (&gpio)); \
|
||||||
}
|
}
|
||||||
#endif // ADC1_GPIO_INIT
|
#endif // ADC1_GPIO_INIT
|
||||||
@@ -387,7 +387,9 @@ void adc_init( void ) {
|
|||||||
// using defines.
|
// using defines.
|
||||||
adc_channel_map[0] = ADC_Channel_8;
|
adc_channel_map[0] = ADC_Channel_8;
|
||||||
adc_channel_map[1] = ADC_Channel_9;
|
adc_channel_map[1] = ADC_Channel_9;
|
||||||
adc_channel_map[2] = ADC_Channel_13;
|
// adc_channel_map[2] = ADC_Channel_13;
|
||||||
|
// FIXME for now we get battery voltage this way
|
||||||
|
adc_channel_map[2] = ADC_Channel_0;
|
||||||
adc_channel_map[3] = ADC_Channel_15;
|
adc_channel_map[3] = ADC_Channel_15;
|
||||||
|
|
||||||
adc_init_rcc();
|
adc_init_rcc();
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Paparazzi stm32 arch dependant microcontroller initialisation function
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 The Paparazzi team
|
||||||
|
*
|
||||||
|
* This file is part of Paparazzi.
|
||||||
|
*
|
||||||
|
* Paparazzi is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Paparazzi is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Paparazzi; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mcu.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <stm32/gpio.h>
|
||||||
|
#include <stm32/rcc.h>
|
||||||
|
#include <stm32/flash.h>
|
||||||
|
#include <stm32/misc.h>
|
||||||
|
|
||||||
|
#include BOARD_CONFIG
|
||||||
|
|
||||||
|
void mcu_arch_init(void) {
|
||||||
|
|
||||||
|
#ifdef HSE_TYPE_EXT_CLK
|
||||||
|
/* Setup the microcontroller system.
|
||||||
|
* Initialize the Embedded Flash Interface,
|
||||||
|
* initialize the PLL and update the SystemFrequency variable.
|
||||||
|
*/
|
||||||
|
/* RCC system reset(for debug purpose) */
|
||||||
|
RCC_DeInit();
|
||||||
|
/* Enable HSE with external clock ( HSE_Bypass ) */
|
||||||
|
RCC_HSEConfig( RCC_HSE_Bypass );
|
||||||
|
/* Wait till HSE is ready */
|
||||||
|
ErrorStatus HSEStartUpStatus = RCC_WaitForHSEStartUp();
|
||||||
|
if (HSEStartUpStatus != SUCCESS) {
|
||||||
|
/* block if something went wrong */
|
||||||
|
while(1) {}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Enable Prefetch Buffer */
|
||||||
|
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
|
||||||
|
/* Flash 2 wait state */
|
||||||
|
FLASH_SetLatency(FLASH_Latency_2);
|
||||||
|
/* HCLK = SYSCLK */
|
||||||
|
RCC_HCLKConfig(RCC_SYSCLK_Div1);
|
||||||
|
/* PCLK2 = HCLK */
|
||||||
|
RCC_PCLK2Config(RCC_HCLK_Div1);
|
||||||
|
/* PCLK1 = HCLK/2 */
|
||||||
|
RCC_PCLK1Config(RCC_HCLK_Div2);
|
||||||
|
/* PLLCLK = 8MHz * 9 = 72 MHz */
|
||||||
|
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
|
||||||
|
/* Enable PLL */
|
||||||
|
RCC_PLLCmd(ENABLE);
|
||||||
|
/* Wait till PLL is ready */
|
||||||
|
while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) {}
|
||||||
|
/* Select PLL as system clock source */
|
||||||
|
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
|
||||||
|
/* Wait till PLL is used as system clock source */
|
||||||
|
while(RCC_GetSYSCLKSource() != 0x08) {}
|
||||||
|
}
|
||||||
|
#else /* HSE_TYPE_EXT_CLK */
|
||||||
|
SystemInit();
|
||||||
|
#endif /* HSE_TYPE_EXT_CLK */
|
||||||
|
/* Set the Vector Table base location at 0x08000000 */
|
||||||
|
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Paparazzi stm32 arch dependant microcontroller initialisation function
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 The Paparazzi team
|
||||||
|
*
|
||||||
|
* This file is part of Paparazzi.
|
||||||
|
*
|
||||||
|
* Paparazzi is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Paparazzi is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Paparazzi; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STM32_MCU_ARCH_H
|
||||||
|
#define STM32_MCU_ARCH_H
|
||||||
|
|
||||||
|
extern void mcu_arch_init(void);
|
||||||
|
|
||||||
|
|
||||||
|
/* should probably not be here
|
||||||
|
* a couple of macros to use the rev instruction
|
||||||
|
*/
|
||||||
|
#define MyByteSwap16(in, out) { \
|
||||||
|
asm volatile ( \
|
||||||
|
"rev16 %0, %1\n\t" \
|
||||||
|
: "=r" (out) \
|
||||||
|
: "r"(in) \
|
||||||
|
); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define mcu_int_enable() {}
|
||||||
|
#define mcu_int_disable() {}
|
||||||
|
|
||||||
|
#endif /* STM32_MCU_ARCH_H */
|
||||||
@@ -20,8 +20,8 @@
|
|||||||
#define IMU_ACC_DRDY_GPIO_PORTSOURCE GPIO_PortSourceGPIOD
|
#define IMU_ACC_DRDY_GPIO_PORTSOURCE GPIO_PortSourceGPIOD
|
||||||
|
|
||||||
|
|
||||||
#define ADC_CHANNEL_VSUPPLY 4
|
#define ADC_CHANNEL_VSUPPLY 2
|
||||||
#define DefaultVoltageOfAdc(adc) (0.01787109375*adc)
|
#define DefaultVoltageOfAdc(adc) (0.0059*adc)
|
||||||
|
|
||||||
|
|
||||||
#endif /* CONFIG_LISA_V1_0_H */
|
#endif /* CONFIG_LISA_V1_0_H */
|
||||||
|
|||||||
@@ -34,9 +34,8 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "firmwares/fixedwing/main_ap.h"
|
#include "firmwares/fixedwing/main_ap.h"
|
||||||
|
#include "mcu.h"
|
||||||
|
|
||||||
#include "interrupt_hw.h"
|
|
||||||
#include "init_hw.h"
|
|
||||||
#include "adc.h"
|
#include "adc.h"
|
||||||
#include "firmwares/fixedwing/stabilization/stabilization_attitude.h"
|
#include "firmwares/fixedwing/stabilization/stabilization_attitude.h"
|
||||||
#include "firmwares/fixedwing/guidance/guidance_v.h"
|
#include "firmwares/fixedwing/guidance/guidance_v.h"
|
||||||
@@ -60,13 +59,6 @@
|
|||||||
#include "rc_settings.h"
|
#include "rc_settings.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LED
|
|
||||||
#include "led.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined USE_I2C0 || USE_I2C1
|
|
||||||
#include "i2c.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_SPI
|
#ifdef USE_SPI
|
||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
@@ -480,12 +472,9 @@ void periodic_task_ap( void ) {
|
|||||||
|
|
||||||
void init_ap( void ) {
|
void init_ap( void ) {
|
||||||
#ifndef SINGLE_MCU /** init done in main_fbw in single MCU */
|
#ifndef SINGLE_MCU /** init done in main_fbw in single MCU */
|
||||||
hw_init();
|
mcu_init();
|
||||||
sys_time_init();
|
sys_time_init();
|
||||||
|
|
||||||
#ifdef LED
|
|
||||||
led_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ADC
|
#ifdef ADC
|
||||||
adc_init();
|
adc_init();
|
||||||
@@ -502,35 +491,11 @@ void init_ap( void ) {
|
|||||||
#ifdef USE_GPS
|
#ifdef USE_GPS
|
||||||
gps_init();
|
gps_init();
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_UART0
|
|
||||||
Uart0Init();
|
|
||||||
#endif
|
|
||||||
#ifdef USE_UART1
|
|
||||||
Uart1Init();
|
|
||||||
#endif
|
|
||||||
#ifdef USE_UART2
|
|
||||||
Uart2Init();
|
|
||||||
#endif
|
|
||||||
#ifdef USE_UART3
|
|
||||||
Uart3Init();
|
|
||||||
#endif
|
|
||||||
#ifdef USE_USB_SERIAL
|
|
||||||
VCOM_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_GPIO
|
#ifdef USE_GPIO
|
||||||
GpioInit();
|
GpioInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_I2C0
|
|
||||||
i2c0_init();
|
|
||||||
#endif
|
|
||||||
#ifdef USE_I2C1
|
|
||||||
i2c1_init();
|
|
||||||
#endif
|
|
||||||
#ifdef USE_I2C2
|
|
||||||
i2c2_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************* Links initialization ***************/
|
/************* Links initialization ***************/
|
||||||
#if defined USE_SPI
|
#if defined USE_SPI
|
||||||
@@ -555,7 +520,7 @@ void init_ap( void ) {
|
|||||||
modules_init();
|
modules_init();
|
||||||
|
|
||||||
/** - start interrupt task */
|
/** - start interrupt task */
|
||||||
int_enable();
|
mcu_int_enable();
|
||||||
|
|
||||||
/** wait 0.5s (historical :-) */
|
/** wait 0.5s (historical :-) */
|
||||||
sys_time_usleep(500000);
|
sys_time_usleep(500000);
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* Paparazzi $Id$
|
* Paparazzi $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2003-2006 Pascal Brisset, Antoine Drouin
|
* Copyright (C) 2003-2010 The Paparazzi Team
|
||||||
*
|
*
|
||||||
* This file is part of paparazzi.
|
* This file is part of Paparazzi.
|
||||||
*
|
*
|
||||||
* paparazzi is free software; you can redistribute it and/or modify
|
* Paparazzi is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2, or (at your option)
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
* any later version.
|
* any later version.
|
||||||
*
|
*
|
||||||
* paparazzi is distributed in the hope that it will be useful,
|
* Paparazzi is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with paparazzi; see the file COPYING. If not, write to
|
* along with Paparazzi; see the file COPYING. If not, write to
|
||||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
@@ -31,11 +31,11 @@
|
|||||||
* ( for parameters like the supply )
|
* ( for parameters like the supply )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "firmwares/fixedwing/main_fbw.h"
|
|
||||||
#include "generated/airframe.h"
|
#include "generated/airframe.h"
|
||||||
|
|
||||||
#include "init_hw.h"
|
#include "firmwares/fixedwing/main_fbw.h"
|
||||||
#include "interrupt_hw.h"
|
#include "mcu.h"
|
||||||
|
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
@@ -84,33 +84,17 @@ uint8_t fbw_mode;
|
|||||||
|
|
||||||
/********** INIT *************************************************************/
|
/********** INIT *************************************************************/
|
||||||
void init_fbw( void ) {
|
void init_fbw( void ) {
|
||||||
hw_init();
|
mcu_init();
|
||||||
sys_time_init();
|
sys_time_init();
|
||||||
#ifdef LED
|
|
||||||
led_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_UART0
|
|
||||||
uart0_init();
|
|
||||||
#endif
|
|
||||||
#ifdef USE_UART1
|
|
||||||
uart1_init();
|
|
||||||
#endif
|
|
||||||
#ifdef USE_UART2
|
|
||||||
uart2_init();
|
|
||||||
#endif
|
|
||||||
#ifdef USE_UART3
|
|
||||||
uart3_init();
|
|
||||||
#endif
|
|
||||||
// FIXME: remove STM32 flag
|
|
||||||
#ifdef ADC
|
#ifdef ADC
|
||||||
adc_init();
|
adc_init();
|
||||||
#ifndef STM32
|
#ifdef ADC_CHANNEL_VSUPPLY
|
||||||
adc_buf_channel(ADC_CHANNEL_VSUPPLY, &vsupply_adc_buf, DEFAULT_AV_NB_SAMPLE);
|
adc_buf_channel(ADC_CHANNEL_VSUPPLY, &vsupply_adc_buf, DEFAULT_AV_NB_SAMPLE);
|
||||||
# ifdef ADC_CHANNEL_CURRENT
|
#endif
|
||||||
|
#ifdef ADC_CHANNEL_CURRENT
|
||||||
adc_buf_channel(ADC_CHANNEL_CURRENT, ¤t_adc_buf, DEFAULT_AV_NB_SAMPLE);
|
adc_buf_channel(ADC_CHANNEL_CURRENT, ¤t_adc_buf, DEFAULT_AV_NB_SAMPLE);
|
||||||
# endif
|
#endif
|
||||||
#endif /* ! STM32 */
|
|
||||||
#endif /* ADC */
|
#endif /* ADC */
|
||||||
|
|
||||||
#ifdef ACTUATORS
|
#ifdef ACTUATORS
|
||||||
@@ -229,10 +213,12 @@ void periodic_task_fbw( void ) {
|
|||||||
if (!_10Hz)
|
if (!_10Hz)
|
||||||
{
|
{
|
||||||
#ifdef ADC
|
#ifdef ADC
|
||||||
|
#ifdef ADC_CHANNEL_VSUPPLY
|
||||||
fbw_vsupply_decivolt = VoltageOfAdc((10*(vsupply_adc_buf.sum/vsupply_adc_buf.av_nb_sample)));
|
fbw_vsupply_decivolt = VoltageOfAdc((10*(vsupply_adc_buf.sum/vsupply_adc_buf.av_nb_sample)));
|
||||||
# ifdef ADC_CHANNEL_CURRENT
|
#endif
|
||||||
|
#ifdef ADC_CHANNEL_CURRENT
|
||||||
fbw_current_milliamp = MilliAmpereOfAdc((current_adc_buf.sum/current_adc_buf.av_nb_sample));
|
fbw_current_milliamp = MilliAmpereOfAdc((current_adc_buf.sum/current_adc_buf.av_nb_sample));
|
||||||
# endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ((! defined ADC_CHANNEL_CURRENT) && defined MILLIAMP_AT_FULL_THROTTLE)
|
#if ((! defined ADC_CHANNEL_CURRENT) && defined MILLIAMP_AT_FULL_THROTTLE)
|
||||||
|
|||||||
@@ -25,10 +25,9 @@
|
|||||||
#define MODULES_C
|
#define MODULES_C
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "init_hw.h"
|
#include "mcu.h"
|
||||||
#include "sys_time.h"
|
#include "sys_time.h"
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
#include "interrupt_hw.h"
|
|
||||||
|
|
||||||
#include "downlink.h"
|
#include "downlink.h"
|
||||||
#include "firmwares/rotorcraft/telemetry.h"
|
#include "firmwares/rotorcraft/telemetry.h"
|
||||||
@@ -95,7 +94,7 @@ STATIC_INLINE void main_init( void ) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hw_init();
|
mcu_init();
|
||||||
|
|
||||||
sys_time_init();
|
sys_time_init();
|
||||||
|
|
||||||
@@ -130,7 +129,7 @@ STATIC_INLINE void main_init( void ) {
|
|||||||
|
|
||||||
modules_init();
|
modules_init();
|
||||||
|
|
||||||
int_enable();
|
mcu_int_enable();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
|
* Copyright (C) 2008-2010 The Paparazzi Team
|
||||||
*
|
*
|
||||||
* This file is part of paparazzi.
|
* This file is part of paparazzi.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* Paparazzi microcontroller initialisation function
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 The Paparazzi team
|
||||||
|
*
|
||||||
|
* This file is part of Paparazzi.
|
||||||
|
*
|
||||||
|
* Paparazzi is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Paparazzi is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Paparazzi; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mcu.h"
|
||||||
|
|
||||||
|
#ifdef PERIPHERALS_AUTO_INIT
|
||||||
|
#ifdef USE_LED
|
||||||
|
#include "led.h"
|
||||||
|
#endif
|
||||||
|
#if defined RADIO_CONTROL
|
||||||
|
#if defined RADIO_CONTROL_LINK || defined RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT
|
||||||
|
#include "subsystems/radio_control.h"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if defined USE_UART0 || defined USE_UART1 || defined USE_UART2 || defined USE_UART3 || defined USE_UART4 || defined USE_UART5
|
||||||
|
#include "uart.h"
|
||||||
|
#endif
|
||||||
|
#if defined USE_I2C1 || defined USE_I2C2
|
||||||
|
#include "i2c.h"
|
||||||
|
#endif
|
||||||
|
#endif /* PERIPHERALS_AUTO_INIT */
|
||||||
|
|
||||||
|
void mcu_init(void) {
|
||||||
|
|
||||||
|
mcu_arch_init();
|
||||||
|
|
||||||
|
#ifdef PERIPHERALS_AUTO_INIT
|
||||||
|
#ifdef USE_LED
|
||||||
|
led_init();
|
||||||
|
#endif
|
||||||
|
/* for now this means using spektrum */
|
||||||
|
#if defined RADIO_CONTROL & defined RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT & defined RADIO_CONTROL_BIND_IMPL_FUNC
|
||||||
|
RADIO_CONTROL_BIND_IMPL_FUNC();
|
||||||
|
#endif
|
||||||
|
#ifdef USE_UART0
|
||||||
|
uart0_init();
|
||||||
|
#endif
|
||||||
|
#ifdef USE_UART1
|
||||||
|
uart1_init();
|
||||||
|
#endif
|
||||||
|
#ifdef USE_UART2
|
||||||
|
uart2_init();
|
||||||
|
#endif
|
||||||
|
#ifdef USE_UART3
|
||||||
|
uart3_init();
|
||||||
|
#endif
|
||||||
|
#ifdef USE_UART4
|
||||||
|
uart4_init();
|
||||||
|
#endif
|
||||||
|
#ifdef USE_UART5
|
||||||
|
uart5_init();
|
||||||
|
#endif
|
||||||
|
#ifdef USE_I2C0
|
||||||
|
i2c0_init();
|
||||||
|
#endif
|
||||||
|
#ifdef USE_I2C1
|
||||||
|
i2c1_init();
|
||||||
|
#endif
|
||||||
|
#ifdef USE_I2C2
|
||||||
|
i2c2_init();
|
||||||
|
#endif
|
||||||
|
#ifdef USE_USB_SERIAL
|
||||||
|
VCOM_init();
|
||||||
|
#endif
|
||||||
|
#endif /* PERIPHERALS_AUTO_INIT */
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Paparazzi microcontroller functions
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 The Paparazzi team
|
||||||
|
*
|
||||||
|
* This file is part of Paparazzi.
|
||||||
|
*
|
||||||
|
* Paparazzi is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Paparazzi is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Paparazzi; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file mcu.h
|
||||||
|
* \brief arch independant mcu ( Micro Controller Unit ) utilities
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MCU_H
|
||||||
|
#define MCU_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <mcu_arch.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Microcontroller initialisation
|
||||||
|
* This function is responisble for setting up the microcontroller
|
||||||
|
* after Reset.
|
||||||
|
*/
|
||||||
|
extern void mcu_init(void);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* MCU_H */
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user