diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index 6e2f8382a..235edc6c0 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -57,7 +57,7 @@ FLASH_TOOL = OPENOCD USE_THUMB_MODE = YES # List of modules to include -MODULES = Telemetry CCAttitude +MODULES = Telemetry ManualControl Actuator CCAttitude #Stabilization #Actuator Telemetry ManualControl Stabilization FirmwareIAP #MODULES = Telemetry Example @@ -362,7 +362,7 @@ LINKERSCRIPTPATH = $(PIOSSTM32F10X) # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) ifeq ($(DEBUG),YES) -OPT = 0 +OPT = 1 else OPT = s endif @@ -427,11 +427,16 @@ CFLAGS += -mcpu=$(MCU) -mthumb CFLAGS += $(CDEFS) CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I. +#CFLAGS += -fno-cprop-registers -fno-defer-pop -fno-guess-branch-probability -fno-section-anchors +#CFLAGS += -fno-if-conversion -fno-if-conversion2 -fno-ipa-pure-const -fno-ipa-reference -fno-merge-constants +#CFLAGS += -fno-split-wide-types -fno-tree-ccp -fno-tree-ch -fno-tree-copy-prop -fno-tree-copyrename +#CFLAGS += -fno-tree-dce -fno-tree-dominator-opts -fno-tree-dse -fno-tree-fre -fno-tree-sink -fno-tree-sra +#CFLAGS += -fno-tree-ter +#CFLAGS += -g$(DEBUGF) -DDEBUG + CFLAGS += -mapcs-frame CFLAGS += -fomit-frame-pointer -ifeq ($(CODE_SOURCERY), YES) CFLAGS += -fpromote-loop-indices -endif CFLAGS += -Wall CFLAGS += -Werror diff --git a/flight/CopterControl/System/inc/FreeRTOSConfig.h b/flight/CopterControl/System/inc/FreeRTOSConfig.h index e032c78f8..4096b62f6 100644 --- a/flight/CopterControl/System/inc/FreeRTOSConfig.h +++ b/flight/CopterControl/System/inc/FreeRTOSConfig.h @@ -29,8 +29,8 @@ #define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 ) #define configTICK_RATE_HZ ( ( portTickType ) 1000 ) #define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 ) -#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 64 ) -#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 15 * 1024 ) ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 128 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 13 * 1024 ) ) #define configMAX_TASK_NAME_LEN ( 16 ) #define configUSE_TRACE_FACILITY 0 #define configUSE_16_BIT_TICKS 0 diff --git a/flight/CopterControl/System/inc/pios_config.h b/flight/CopterControl/System/inc/pios_config.h index eed4bf861..0c58fae92 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 #define PIOS_INCLUDE_ADXL345 diff --git a/flight/CopterControl/System/pios_board.c b/flight/CopterControl/System/pios_board.c index 1688e65e7..1d9f0976c 100644 --- a/flight/CopterControl/System/pios_board.c +++ b/flight/CopterControl/System/pios_board.c @@ -68,7 +68,6 @@ void PIOS_Board_Init(void) { /* Remap AFIO pin */ GPIO_PinRemapConfig( GPIO_Remap_SWJ_NoJTRST, ENABLE); - GPIO_PinRemapConfig( GPIO_PartialRemap_TIM3, ENABLE); PIOS_Servo_Init(); PIOS_ADC_Init(); @@ -78,14 +77,14 @@ void PIOS_Board_Init(void) { PIOS_PWM_Init(); #endif #if defined(PIOS_INCLUDE_PPM) - //PIOS_PPM_Init(); + PIOS_PPM_Init(); #endif #if defined(PIOS_INCLUDE_USB_HID) - PIOS_USB_HID_Init(0); + //PIOS_USB_HID_Init(0); #endif - PIOS_I2C_Init(); - PIOS_IAP_Init(); - PIOS_WDG_Init(); + //PIOS_I2C_Init(); + //PIOS_IAP_Init(); + //PIOS_WDG_Init(); } /* Flash/Accel Interface @@ -543,6 +542,7 @@ const struct pios_servo_cfg pios_servo_cfg = { .GPIO_Mode = GPIO_Mode_AF_PP, .GPIO_Speed = GPIO_Speed_2MHz, }, + .remap = GPIO_PartialRemap_TIM3, .channels = pios_servo_channels, .num_channels = NELEMENTS(pios_servo_channels), }; diff --git a/flight/Modules/Actuator/actuator.c b/flight/Modules/Actuator/actuator.c index 27aa0af6d..b4b60c982 100644 --- a/flight/Modules/Actuator/actuator.c +++ b/flight/Modules/Actuator/actuator.c @@ -44,8 +44,8 @@ // Private constants #define MAX_QUEUE_SIZE 2 -#define STACK_SIZE configMINIMAL_STACK_SIZE -#define TASK_PRIORITY (tskIDLE_PRIORITY+4) +#define STACK_SIZE configMINIMAL_STACK_SIZE+200 +#define TASK_PRIORITY (tskIDLE_PRIORITY+0) #define FAILSAFE_TIMEOUT_MS 100 #define MAX_MIX_ACTUATORS ACTUATORCOMMAND_CHANNEL_NUMELEM diff --git a/flight/Modules/CCAttitude/ccattitude.c b/flight/Modules/CCAttitude/ccattitude.c index 9e6443aa0..e5ba6112f 100644 --- a/flight/Modules/CCAttitude/ccattitude.c +++ b/flight/Modules/CCAttitude/ccattitude.c @@ -60,10 +60,9 @@ // Private constants #define STACK_SIZE_BYTES 740 -#define STACK_SIZE_BYTES 540 -#define TASK_PRIORITY (tskIDLE_PRIORITY+4) +#define TASK_PRIORITY (tskIDLE_PRIORITY+0) -#define UPDATE_RATE 10 /* ms */ +#define UPDATE_RATE 100 /* ms */ #define GYRO_NEUTRAL 1665 #define GYRO_SCALE 0.010f @@ -122,6 +121,7 @@ static void CCAttitudeTask(void *parameters) /* Wait for the next update interval */ vTaskDelayUntil(&lastSysTime, UPDATE_RATE / portTICK_RATE_MS); + //vTaskDelay(UPDATE_RATE / portTICK_RATE_MS); } } @@ -130,11 +130,11 @@ void updateInput() { ManualControlCommandData manual; ManualControlCommandGet(&manual); - manual.Throttle = (PIOS_PWM_Get(0) - 1100) / 900; - manual.Roll = (PIOS_PWM_Get(1) - 1500) / 500; - manual.Pitch = (PIOS_PWM_Get(2) - 1500) / 500; - manual.Yaw = (PIOS_PWM_Get(3) - 1500) / 500; - manual.FlightMode = (PIOS_PWM_Get(4) - 1500) / 500; + manual.Throttle = (float) (PIOS_PWM_Get(0) - 1100.0f) / 900.0f; + manual.Roll = (float) (PIOS_PWM_Get(1) - 1500.0f) / 500.0f; + manual.Pitch = (float) (PIOS_PWM_Get(2) - 1500.0f) / 500.0f; + manual.Yaw = (float) (PIOS_PWM_Get(3) - 1500.0f) / 500.0f; + manual.FlightMode = (float) (PIOS_PWM_Get(4) - 1500) / 500; ManualControlCommandSet(&manual); } diff --git a/flight/OpenPilot/System/pios_board.c b/flight/OpenPilot/System/pios_board.c index 8ef1a0690..4b1a8a732 100644 --- a/flight/OpenPilot/System/pios_board.c +++ b/flight/OpenPilot/System/pios_board.c @@ -682,6 +682,7 @@ const struct pios_servo_cfg pios_servo_cfg = { .GPIO_Mode = GPIO_Mode_AF_PP, .GPIO_Speed = GPIO_Speed_2MHz, }, + .remap = 0, .channels = pios_servo_channels, .num_channels = NELEMENTS(pios_servo_channels), }; diff --git a/flight/PiOS/STM32F10x/pios_servo.c b/flight/PiOS/STM32F10x/pios_servo.c index 84e3c1785..f65747813 100644 --- a/flight/PiOS/STM32F10x/pios_servo.c +++ b/flight/PiOS/STM32F10x/pios_servo.c @@ -113,6 +113,12 @@ void PIOS_Servo_Init(void) TIM_Cmd(channel.timer, ENABLE); } + + if(pios_servo_cfg.remap) { + /* Warning, I don't think this will work for multiple remaps at once */ + GPIO_PinRemapConfig(pios_servo_cfg.remap, ENABLE); + } + #endif // PIOS_INCLUDE_SERVO #endif // PIOS_ENABLE_DEBUG_PINS diff --git a/flight/PiOS/inc/pios_servo_priv.h b/flight/PiOS/inc/pios_servo_priv.h index b260f0616..a1136c46d 100644 --- a/flight/PiOS/inc/pios_servo_priv.h +++ b/flight/PiOS/inc/pios_servo_priv.h @@ -45,6 +45,7 @@ struct pios_servo_cfg { TIM_TimeBaseInitTypeDef tim_base_init; TIM_OCInitTypeDef tim_oc_init; GPIO_InitTypeDef gpio_init; + uint32_t remap; const struct pios_servo_channel *const channels; uint8_t num_channels; }; diff --git a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj index ff2086622..525b0d880 100644 --- a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj +++ b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj @@ -149,6 +149,7 @@ 650D8ECE12DFE17500D05CC9 /* watchdogstatus.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = watchdogstatus.c; sourceTree = ""; }; 650D8ED112DFE17500D05CC9 /* uavtalk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uavtalk.h; sourceTree = ""; }; 650D8ED212DFE17500D05CC9 /* uavtalk.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = uavtalk.c; sourceTree = ""; }; + 65173C9F12EBFD1700D6A7CB /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; name = Makefile; path = ../../../Makefile; sourceTree = SOURCE_ROOT; }; 651913371256C5240039C0A3 /* ahrs_comm_objects.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ahrs_comm_objects.c; sourceTree = ""; }; 651913381256C5240039C0A3 /* ahrs_spi_comm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ahrs_spi_comm.c; sourceTree = ""; }; 6519133A1256C52B0039C0A3 /* ahrs_comm_objects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ahrs_comm_objects.h; sourceTree = ""; }; @@ -2961,6 +2962,7 @@ 08FB7794FE84155DC02AAC07 /* OpenPilotOSX */ = { isa = PBXGroup; children = ( + 65173C9F12EBFD1700D6A7CB /* Makefile */, 657CEEB5121DBC49007A1FBE /* flight */, 65B35D7D121C261E003EAD18 /* ground */, ); diff --git a/flight/UAVObjects/uavobjectsinit_cc.c b/flight/UAVObjects/uavobjectsinit_cc.c index e3414975c..4c8e03aa1 100644 --- a/flight/UAVObjects/uavobjectsinit_cc.c +++ b/flight/UAVObjects/uavobjectsinit_cc.c @@ -70,7 +70,6 @@ #include "velocitydesired.h" #include "watchdogstatus.h" - /** * Function used to initialize the first instance of each object. * This file is automatically updated by the UAVObjectGenerator. @@ -93,11 +92,11 @@ void UAVObjectsInitializeAll() I2CStatsInitialize(); WatchdogStatusInitialize(); TelemetrySettingsInitialize(); - //StabilizationSettingsInitialize(); - //ActuatorSettingsInitialize(); + StabilizationSettingsInitialize(); + ActuatorSettingsInitialize(); RateDesiredInitialize(); //AHRSSettingsInitialize(); - //ManualControlSettingsInitialize(); - //MixerSettingsInitialize(); - //MixerStatusInitialize(); + ManualControlSettingsInitialize(); + MixerSettingsInitialize(); + MixerStatusInitialize(); }