diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index b218d02fc..1f5a07769 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -57,7 +57,8 @@ FLASH_TOOL = OPENOCD USE_THUMB_MODE = YES # List of modules to include -MODULES = Actuator Telemetry ManualControl Stabilization FirmwareIAP +MODULES = +#Actuator Telemetry ManualControl Stabilization FirmwareIAP #MODULES = Telemetry Example #MODULES = Telemetry MK/MKSerial @@ -71,8 +72,8 @@ MODULES = Actuator Telemetry ManualControl Stabilization FirmwareIAP # - BOARD just passed as define (optional) MCU = cortex-m3 CHIP = STM32F103RET -BOARD = STM3210E_CC_Rev1 -MODEL = HD +BOARD = STM32103CB_CC_Rev1 +MODEL = MD ifeq ($(USE_BOOTLOADER), YES) BOOT_MODEL = $(MODEL)_BL @@ -147,7 +148,7 @@ SRC += $(OPSYSTEM)/alarms.c SRC += $(OPSYSTEM)/taskmonitor.c SRC += $(OPUAVTALK)/uavtalk.c SRC += $(OPUAVOBJ)/uavobjectmanager.c -SRC += $(OPUAVOBJ)/uavobjectsinit.c +SRC += $(OPUAVOBJ)/uavobjectsinit_cc.c SRC += $(OPUAVOBJ)/eventdispatcher.c else ## TESTCODE @@ -160,10 +161,6 @@ endif ## UAVOBJECTS ifndef TESTAPP SRC += $(OPUAVOBJ)/objectpersistence.c -SRC += $(OPUAVOBJ)/positionactual.c -SRC += $(OPUAVOBJ)/gpsposition.c -SRC += $(OPUAVOBJ)/gpstime.c -SRC += $(OPUAVOBJ)/gpssatellites.c SRC += $(OPUAVOBJ)/gcstelemetrystats.c SRC += $(OPUAVOBJ)/flighttelemetrystats.c SRC += $(OPUAVOBJ)/systemstats.c @@ -171,35 +168,35 @@ SRC += $(OPUAVOBJ)/systemalarms.c SRC += $(OPUAVOBJ)/systemsettings.c SRC += $(OPUAVOBJ)/telemetrysettings.c SRC += $(OPUAVOBJ)/actuatorcommand.c -SRC += $(OPUAVOBJ)/actuatordesired.c -SRC += $(OPUAVOBJ)/actuatorsettings.c +#SRC += $(OPUAVOBJ)/actuatordesired.c +#SRC += $(OPUAVOBJ)/actuatorsettings.c SRC += $(OPUAVOBJ)/manualcontrolcommand.c -SRC += $(OPUAVOBJ)/manualcontrolsettings.c -SRC += $(OPUAVOBJ)/attitudedesired.c -SRC += $(OPUAVOBJ)/stabilizationsettings.c -SRC += $(OPUAVOBJ)/ahrsstatus.c +#SRC += $(OPUAVOBJ)/manualcontrolsettings.c +#SRC += $(OPUAVOBJ)/attitudedesired.c +#SRC += $(OPUAVOBJ)/stabilizationsettings.c +#SRC += $(OPUAVOBJ)/ahrsstatus.c SRC += $(OPUAVOBJ)/i2cstats.c -SRC += $(OPUAVOBJ)/baroaltitude.c -SRC += $(OPUAVOBJ)/ahrscalibration.c -SRC += $(OPUAVOBJ)/attitudeactual.c -SRC += $(OPUAVOBJ)/ahrssettings.c -SRC += $(OPUAVOBJ)/flightbatterystate.c -SRC += $(OPUAVOBJ)/attituderaw.c -SRC += $(OPUAVOBJ)/homelocation.c -SRC += $(OPUAVOBJ)/mixersettings.c -SRC += $(OPUAVOBJ)/mixerstatus.c -SRC += $(OPUAVOBJ)/positiondesired.c -SRC += $(OPUAVOBJ)/velocitydesired.c -SRC += $(OPUAVOBJ)/velocityactual.c -SRC += $(OPUAVOBJ)/guidancesettings.c -SRC += $(OPUAVOBJ)/firmwareiapobj.c -SRC += $(OPUAVOBJ)/ratedesired.c -SRC += $(OPUAVOBJ)/pipxtrememodemsettings.c -SRC += $(OPUAVOBJ)/pipxtrememodemstatus.c -SRC += $(OPUAVOBJ)/batterysettings.c -SRC += $(OPUAVOBJ)/flightplancontrol.c -SRC += $(OPUAVOBJ)/flightplanstatus.c -SRC += $(OPUAVOBJ)/flightplansettings.c +#SRC += $(OPUAVOBJ)/baroaltitude.c +#SRC += $(OPUAVOBJ)/ahrscalibration.c +#SRC += $(OPUAVOBJ)/attitudeactual.c +#SRC += $(OPUAVOBJ)/ahrssettings.c +#SRC += $(OPUAVOBJ)/flightbatterystate.c +#SRC += $(OPUAVOBJ)/attituderaw.c +#SRC += $(OPUAVOBJ)/homelocation.c +#SRC += $(OPUAVOBJ)/mixersettings.c +#SRC += $(OPUAVOBJ)/mixerstatus.c +#SRC += $(OPUAVOBJ)/positiondesired.c +#SRC += $(OPUAVOBJ)/velocitydesired.c +#SRC += $(OPUAVOBJ)/velocityactual.c +#SRC += $(OPUAVOBJ)/guidancesettings.c +#SRC += $(OPUAVOBJ)/firmwareiapobj.c +#SRC += $(OPUAVOBJ)/ratedesired.c +#SRC += $(OPUAVOBJ)/pipxtrememodemsettings.c +#SRC += $(OPUAVOBJ)/pipxtrememodemstatus.c +#SRC += $(OPUAVOBJ)/batterysettings.c +#SRC += $(OPUAVOBJ)/flightplancontrol.c +#SRC += $(OPUAVOBJ)/flightplanstatus.c +#SRC += $(OPUAVOBJ)/flightplansettings.c SRC += $(OPUAVOBJ)/taskinfo.c SRC += $(OPUAVOBJ)/watchdogstatus.c endif @@ -284,10 +281,6 @@ SRC += $(RTOSSRCDIR)/portable/MemMang/heap_2.c #SRC += $(DOSFSDIR)/dosfs.c #SRC += $(DOSFSDIR)/dfs_sdcard.c -## AHRS boot loader comms -SRC += $(AHRSBOOTLOADER)/ahrs_spi_program_master.c -SRC += $(AHRSBOOTLOADER)/ahrs_spi_program.c - ## PyMite files #SRC += $(wildcard ${PYMITEVM}/*.c) #SRC += $(wildcard ${PYMITEPLAT}/*.c) @@ -325,7 +318,7 @@ CPPSRCARM = # Even though the DOS/Win* filesystem matches both .s and .S the same, # it will preserve the spelling of the filenames, and gcc itself does # care about how the name is spelled on its command-line. -ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)_OP.S +ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL).S # List Assembler source files here which must be assembled in ARM-Mode.. ASRCARM = diff --git a/flight/CopterControl/System/inc/pios_config.h b/flight/CopterControl/System/inc/pios_config.h index a22a74d5d..3de35863f 100644 --- a/flight/CopterControl/System/inc/pios_config.h +++ b/flight/CopterControl/System/inc/pios_config.h @@ -54,7 +54,7 @@ #define PIOS_INCLUDE_FREERTOS #define PIOS_INCLUDE_GPIO #define PIOS_INCLUDE_EXTI -#define PIOS_INCLUDE_WDG +//#define PIOS_INCLUDE_WDG #define PIOS_INCLUDE_I2C_ESC /* Defaults for Logging */ diff --git a/flight/CopterControl/System/openpilot.c b/flight/CopterControl/System/openpilot.c index d8e77ba80..c1c730d0e 100644 --- a/flight/CopterControl/System/openpilot.c +++ b/flight/CopterControl/System/openpilot.c @@ -84,6 +84,10 @@ int main() /* Brings up System using CMSIS functions, enables the LEDs. */ PIOS_SYS_Init(); + for(;;) { + PIOS_LED_Toggle(LED1); + PIOS_DELAY_WaitmS(100); + } /* Initialize the system thread */ SystemModInitialize(); diff --git a/flight/CopterControl/System/pios_board.c b/flight/CopterControl/System/pios_board.c index 4c907cd5b..22ffc69d7 100644 --- a/flight/CopterControl/System/pios_board.c +++ b/flight/CopterControl/System/pios_board.c @@ -297,13 +297,13 @@ uint8_t pios_spi_num_devices = NELEMENTS(pios_spi_devs); void PIOS_SPI_sdcard_irq_handler(void) { /* Call into the generic code to handle the IRQ for this specific device */ - PIOS_SPI_IRQ_Handler(PIOS_SDCARD_SPI); +// PIOS_SPI_IRQ_Handler(PIOS_SDCARD_SPI); } void PIOS_SPI_ahrs_irq_handler(void) { /* Call into the generic code to handle the IRQ for this specific device */ - PIOS_SPI_IRQ_Handler(PIOS_OPAHRS_SPI); +// PIOS_SPI_IRQ_Handler(PIOS_OPAHRS_SPI); } /* diff --git a/flight/PiOS/Boards/STM32103CB_CC_Rev1.h b/flight/PiOS/Boards/STM32103CB_CC_Rev1.h index 074c11983..3e5401793 100644 --- a/flight/PiOS/Boards/STM32103CB_CC_Rev1.h +++ b/flight/PiOS/Boards/STM32103CB_CC_Rev1.h @@ -80,11 +80,21 @@ TIM8 | | | | #define BOARD_WRITABLA TRUE #define MAX_DEL_RETRYS 3 +//------------------------ +// WATCHDOG_SETTINGS +//------------------------ +#define PIOS_WATCHDOG_TIMEOUT 250 +#define PIOS_WDG_REGISTER BKP_DR4 +#define PIOS_WDG_ACTUATOR 0x0001 +#define PIOS_WDG_STABILIZATION 0x0002 +#define PIOS_WDG_AHRS 0x0004 +#define PIOS_WDG_MANUAL 0x0008 + //------------------------ // PIOS_LED //------------------------ #define PIOS_LED_LED1_GPIO_PORT GPIOA -#define PIOS_LED_LED1_GPIO_PIN GPIO_Pin_3 +#define PIOS_LED_LED1_GPIO_PIN GPIO_Pin_6 #define PIOS_LED_LED1_GPIO_CLK RCC_APB2Periph_GPIOA #define PIOS_LED_NUM 1 #define PIOS_LED_PORTS { PIOS_LED_LED1_GPIO_PORT } @@ -231,31 +241,111 @@ TIM8 | | | | #define PIOS_ADC_RATE (72.0e6 / 16 / 2 / 252 / (PIOS_ADC_NUM_PINS / 2)) #define EKF_RATE (PIOS_ADC_RATE / adc_oversampling / 2) +//------------------------- +// Receiver PWM inputs +//------------------------- +#define PIOS_PWM_CH1_GPIO_PORT GPIOA +#define PIOS_PWM_CH1_PIN GPIO_Pin_9 +#define PIOS_PWM_CH1_TIM_PORT TIM1 +#define PIOS_PWM_CH1_CH TIM_Channel_2 +#define PIOS_PWM_CH1_CCR TIM_IT_CC2 +#define PIOS_PWM_CH2_GPIO_PORT GPIOA +#define PIOS_PWM_CH2_PIN GPIO_Pin_10 +#define PIOS_PWM_CH2_TIM_PORT TIM1 +#define PIOS_PWM_CH2_CH TIM_Channel_3 +#define PIOS_PWM_CH2_CCR TIM_IT_CC3 +#define PIOS_PWM_CH3_GPIO_PORT GPIOA +#define PIOS_PWM_CH3_PIN GPIO_Pin_0 +#define PIOS_PWM_CH3_TIM_PORT TIM5 +#define PIOS_PWM_CH3_CH TIM_Channel_1 +#define PIOS_PWM_CH3_CCR TIM_IT_CC1 +#define PIOS_PWM_CH4_GPIO_PORT GPIOA +#define PIOS_PWM_CH4_PIN GPIO_Pin_8 +#define PIOS_PWM_CH4_TIM_PORT TIM1 +#define PIOS_PWM_CH4_CH TIM_Channel_1 +#define PIOS_PWM_CH4_CCR TIM_IT_CC1 +#define PIOS_PWM_CH5_GPIO_PORT GPIOB +#define PIOS_PWM_CH5_PIN GPIO_Pin_1 +#define PIOS_PWM_CH5_TIM_PORT TIM3 +#define PIOS_PWM_CH5_CH TIM_Channel_4 +#define PIOS_PWM_CH5_CCR TIM_IT_CC4 +#define PIOS_PWM_CH6_GPIO_PORT GPIOB +#define PIOS_PWM_CH6_PIN GPIO_Pin_0 +#define PIOS_PWM_CH6_TIM_PORT TIM3 +#define PIOS_PWM_CH6_CH TIM_Channel_3 +#define PIOS_PWM_CH6_CCR TIM_IT_CC3 +#define PIOS_PWM_CH7_GPIO_PORT GPIOB +#define PIOS_PWM_CH7_PIN GPIO_Pin_4 +#define PIOS_PWM_CH7_TIM_PORT TIM3 +#define PIOS_PWM_CH7_CH TIM_Channel_1 +#define PIOS_PWM_CH7_CCR TIM_IT_CC1 +#define PIOS_PWM_CH8_GPIO_PORT GPIOB +#define PIOS_PWM_CH8_PIN GPIO_Pin_5 +#define PIOS_PWM_CH8_TIM_PORT TIM3 +#define PIOS_PWM_CH8_CH TIM_Channel_2 +#define PIOS_PWM_CH8_CCR TIM_IT_CC2 +#define PIOS_PWM_GPIO_PORTS { PIOS_PWM_CH1_GPIO_PORT, PIOS_PWM_CH2_GPIO_PORT, PIOS_PWM_CH3_GPIO_PORT, PIOS_PWM_CH4_GPIO_PORT, PIOS_PWM_CH5_GPIO_PORT, PIOS_PWM_CH6_GPIO_PORT, PIOS_PWM_CH7_GPIO_PORT, PIOS_PWM_CH8_GPIO_PORT } +#define PIOS_PWM_GPIO_PINS { PIOS_PWM_CH1_PIN, PIOS_PWM_CH2_PIN, PIOS_PWM_CH3_PIN, PIOS_PWM_CH4_PIN, PIOS_PWM_CH5_PIN, PIOS_PWM_CH6_PIN, PIOS_PWM_CH7_PIN, PIOS_PWM_CH8_PIN } +#define PIOS_PWM_TIM_PORTS { PIOS_PWM_CH1_TIM_PORT, PIOS_PWM_CH2_TIM_PORT, PIOS_PWM_CH3_TIM_PORT, PIOS_PWM_CH4_TIM_PORT, PIOS_PWM_CH5_TIM_PORT, PIOS_PWM_CH6_TIM_PORT, PIOS_PWM_CH7_TIM_PORT, PIOS_PWM_CH8_TIM_PORT } +#define PIOS_PWM_TIM_CHANNELS { PIOS_PWM_CH1_CH, PIOS_PWM_CH2_CH, PIOS_PWM_CH3_CH, PIOS_PWM_CH4_CH, PIOS_PWM_CH5_CH, PIOS_PWM_CH6_CH, PIOS_PWM_CH7_CH, PIOS_PWM_CH8_CH } +#define PIOS_PWM_TIM_CCRS { PIOS_PWM_CH1_CCR, PIOS_PWM_CH2_CCR, PIOS_PWM_CH3_CCR, PIOS_PWM_CH4_CCR, PIOS_PWM_CH5_CCR, PIOS_PWM_CH6_CCR, PIOS_PWM_CH7_CCR, PIOS_PWM_CH8_CCR } +#define PIOS_PWM_TIMS { TIM1, TIM3, TIM5 } +#define PIOS_PWM_TIM_IRQS { TIM1_CC_IRQn, TIM3_IRQn, TIM5_IRQn } +#define PIOS_PWM_NUM_INPUTS 8 +#define PIOS_PWM_NUM_TIMS 3 +#define PIOS_PWM_SUPV_ENABLED 1 +#define PIOS_PWM_SUPV_TIMER TIM6 +#define PIOS_PWM_SUPV_TIMER_RCC_FUNC RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE) +#define PIOS_PWM_SUPV_HZ 25 +#define PIOS_PWM_SUPV_IRQ_CHANNEL TIM6_IRQn +#define PIOS_PWM_SUPV_IRQ_FUNC void TIM6_IRQHandler(void) + + +//------------------------- +// Servo outputs +//------------------------- +#define PIOS_SERVO_GPIO_PORT_1TO4 GPIOB +#define PIOS_SERVO_GPIO_PIN_1 GPIO_Pin_6 +#define PIOS_SERVO_GPIO_PIN_2 GPIO_Pin_7 +#define PIOS_SERVO_GPIO_PIN_3 GPIO_Pin_8 +#define PIOS_SERVO_GPIO_PIN_4 GPIO_Pin_9 +#define PIOS_SERVO_GPIO_PORT_5TO8 GPIOC +#define PIOS_SERVO_GPIO_PIN_5 GPIO_Pin_6 +#define PIOS_SERVO_GPIO_PIN_6 GPIO_Pin_7 +#define PIOS_SERVO_GPIO_PIN_7 GPIO_Pin_8 +#define PIOS_SERVO_GPIO_PIN_8 GPIO_Pin_9 +#define PIOS_SERVO_NUM_OUTPUTS 8 +#define PIOS_SERVO_NUM_TIMERS PIOS_SERVO_NUM_OUTPUTS +#define PIOS_SERVO_UPDATE_HZ 50 +#define PIOS_SERVOS_INITIAL_POSITION 0 /* dont want to start motors, have no pulse till settings loaded */ + //------------------------- // 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) - -//------------------------ -// PIOS_HMC5843 -//------------------------ -#define PIOS_HMC5843_DRDY_GPIO_PORT GPIOB -#define PIOS_HMC5843_DRDY_GPIO_PIN GPIO_Pin_8 -#define PIOS_HMC5843_DRDY_PORT_SOURCE GPIO_PortSourceGPIOB -#define PIOS_HMC5843_DRDY_PIN_SOURCE GPIO_PinSource8 -#define PIOS_HMC5843_DRDY_CLK RCC_APB2Periph_GPIOB -#define PIOS_HMC5843_DRDY_EXTI_LINE EXTI_Line8 -#define PIOS_HMC5843_DRDY_IRQn EXTI9_5_IRQn -#define PIOS_HMC5843_DRDY_PRIO PIOS_IRQ_PRIO_HIGH - +#define PIOS_GPIO_1_PORT GPIOC +#define PIOS_GPIO_1_PIN GPIO_Pin_0 +#define PIOS_GPIO_1_GPIO_CLK RCC_APB2Periph_GPIOC +#define PIOS_GPIO_2_PORT GPIOC +#define PIOS_GPIO_2_PIN GPIO_Pin_1 +#define PIOS_GPIO_2_GPIO_CLK RCC_APB2Periph_GPIOC +#define PIOS_GPIO_3_PORT GPIOC +#define PIOS_GPIO_3_PIN GPIO_Pin_2 +#define PIOS_GPIO_3_GPIO_CLK RCC_APB2Periph_GPIOC +#define PIOS_GPIO_4_PORT GPIOD +#define PIOS_GPIO_4_PIN GPIO_Pin_2 +#define PIOS_GPIO_4_GPIO_CLK RCC_APB2Periph_GPIOD +#define PIOS_GPIO_PORTS { PIOS_GPIO_1_PORT, PIOS_GPIO_2_PORT, PIOS_GPIO_3_PORT, PIOS_GPIO_4_PORT } +#define PIOS_GPIO_PINS { PIOS_GPIO_1_PIN, PIOS_GPIO_2_PIN, PIOS_GPIO_3_PIN, PIOS_GPIO_4_PIN } +#define PIOS_GPIO_CLKS { PIOS_GPIO_1_GPIO_CLK, PIOS_GPIO_2_GPIO_CLK, PIOS_GPIO_3_GPIO_CLK, PIOS_GPIO_4_GPIO_CLK } +#define PIOS_GPIO_NUM 4 +//------------------------- +// USB +//------------------------- +#define PIOS_USB_ENABLED 1 +#define PIOS_USB_DETECT_GPIO_PORT GPIOC +#define PIOS_USB_DETECT_GPIO_PIN GPIO_Pin_4 +#define PIOS_USB_DETECT_EXTI_LINE EXTI_Line4 +#define PIOS_IRQ_USB_PRIORITY PIOS_IRQ_PRIO_MID #endif /* STM32103CB_AHRS_H_ */ diff --git a/flight/PiOS/Boards/pios_board.h b/flight/PiOS/Boards/pios_board.h index 58ed6fe5c..2550f43f3 100644 --- a/flight/PiOS/Boards/pios_board.h +++ b/flight/PiOS/Boards/pios_board.h @@ -7,8 +7,8 @@ #include "STM3210E_OP.h" #elif USE_STM32103CB_PIPXTREME #include "STM32103CB_PIPXTREME_Rev1.h" -#elif USE_STM3210E_CC_Rev1 -#include "STM3210E_CC_Rev1.h" +#elif USE_STM32103CB_CC_Rev1 +#include "STM32103CB_CC_Rev1.h" #endif #endif /* PIOS_BOARD_H_ */