From 5ca4ec79342e42b45e46bb947d32dc3a1d25e5d8 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Mon, 16 Apr 2012 14:33:28 -0400 Subject: [PATCH 1/3] ppm: adjust min frame pulse width for 8ch x 18ms frames All channels at max when using the FrSKY 4ch D4FR in PPM mode results in the frame pulse shrinking well below our threshold of 3800us and we lose frame. With all 8 channels at max, the frame pulse becomes indistinguishable from the other channels. Using all 8 channels with the FrSKY in PPM mode is NOT recommended even after this change. Recommend using at most 7 active channels in this mode so we can still find the frame pulse. --- flight/PiOS/STM32F10x/pios_ppm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flight/PiOS/STM32F10x/pios_ppm.c b/flight/PiOS/STM32F10x/pios_ppm.c index aea1016d3..64d1196f9 100644 --- a/flight/PiOS/STM32F10x/pios_ppm.c +++ b/flight/PiOS/STM32F10x/pios_ppm.c @@ -44,7 +44,7 @@ const struct pios_rcvr_driver pios_ppm_rcvr_driver = { #define PIOS_PPM_IN_MIN_NUM_CHANNELS 4 #define PIOS_PPM_IN_MAX_NUM_CHANNELS PIOS_PPM_NUM_INPUTS #define PIOS_PPM_STABLE_CHANNEL_COUNT 25 // frames -#define PIOS_PPM_IN_MIN_SYNC_PULSE_US 3800 // microseconds +#define PIOS_PPM_IN_MIN_SYNC_PULSE_US 3000 // microseconds #define PIOS_PPM_IN_MIN_CHANNEL_PULSE_US 750 // microseconds #define PIOS_PPM_IN_MAX_CHANNEL_PULSE_US 2250 // microseconds From 62fb009acd97a10e477256c3a8fe0df567d88cc0 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Mon, 16 Apr 2012 14:41:25 -0400 Subject: [PATCH 2/3] gpio: stop enabling pull-ups on all GPIOs in bootloader The bootloader has been enabling pull-ups on all GPIO pins during early init. These pull-ups are disabled immediately before jumping to the firmware. This transition results in all servos seeing a wide pulse as the board resets making them jerk sideways aggresively and then snap back to neutral. --- flight/PiOS/STM32F10x/pios_sys.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/flight/PiOS/STM32F10x/pios_sys.c b/flight/PiOS/STM32F10x/pios_sys.c index 632be2426..04d79c45b 100644 --- a/flight/PiOS/STM32F10x/pios_sys.c +++ b/flight/PiOS/STM32F10x/pios_sys.c @@ -55,20 +55,10 @@ void PIOS_SYS_Init(void) RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE); - /* Activate pull-ups on all pins by default */ - GPIO_InitTypeDef GPIO_InitStructure; - GPIO_StructInit(&GPIO_InitStructure); - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; - GPIO_InitStructure.GPIO_Pin = 0xffff; - GPIO_Init(GPIOB, &GPIO_InitStructure); - GPIO_Init(GPIOD, &GPIO_InitStructure); -#if (PIOS_USB_ENABLED) - GPIO_InitStructure.GPIO_Pin = 0xffff & ~GPIO_Pin_11 & ~GPIO_Pin_12; /* Exclude USB pins */ -#endif - GPIO_Init(GPIOA, &GPIO_InitStructure); - #if (PIOS_USB_ENABLED) /* Ensure that pull-up is active on detect pin */ + GPIO_InitTypeDef GPIO_InitStructure; + GPIO_StructInit(&GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_InitStructure.GPIO_Pin = PIOS_USB_DETECT_GPIO_PIN; GPIO_Init(PIOS_USB_DETECT_GPIO_PORT, &GPIO_InitStructure); From 7f03a7749219dcb5e6eb0deafe0fd19db030f4e1 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Mon, 16 Apr 2012 15:09:10 -0400 Subject: [PATCH 3/3] bu: remove LED support from bootloader updaters Bootloader updaters were all broken due to recent changes in LED configuration handling. Removing LED support from the BU loads allows them to build again, but they provide no feedback about when they're finished writing flash. --- Makefile | 8 ------- flight/Bootloaders/BootloaderUpdater/main.c | 24 +++++---------------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 48cd52cf6..aa5a8fbfc 100644 --- a/Makefile +++ b/Makefile @@ -461,14 +461,6 @@ BU_BOARDS := $(ALL_BOARDS) BL_BOARDS := $(filter-out ins, $(BL_BOARDS)) BU_BOARDS := $(filter-out ins, $(BU_BOARDS)) -# FIXME: The CC bootloader updaters don't work anymore due to -# differences between CC and CC3D -BU_BOARDS := $(filter-out coptercontrol, $(BU_BOARDS)) - -# FIXME: PipXtreme bootloader updater doesn't work due to missing -# definitions for LEDs -BU_BOARDS := $(filter-out pipxtreme, $(BU_BOARDS)) - # Generate the targets for whatever boards are left in each list FW_TARGETS := $(addprefix fw_, $(FW_BOARDS)) BL_TARGETS := $(addprefix bl_, $(BL_BOARDS)) diff --git a/flight/Bootloaders/BootloaderUpdater/main.c b/flight/Bootloaders/BootloaderUpdater/main.c index 195a25b33..0d475a395 100644 --- a/flight/Bootloaders/BootloaderUpdater/main.c +++ b/flight/Bootloaders/BootloaderUpdater/main.c @@ -33,7 +33,7 @@ /* Prototype of PIOS_Board_Init() function */ extern void PIOS_Board_Init(void); extern void FLASH_Download(); -void error(int); +void error(void); /* The ADDRESSES of the _binary_* symbols are the important * data. This is non-intuitive for _binary_size where you @@ -50,14 +50,11 @@ int main() { PIOS_SYS_Init(); PIOS_Board_Init(); - PIOS_LED_On(PIOS_LED_HEARTBEAT); - PIOS_DELAY_WaitmS(3000); - PIOS_LED_Off(PIOS_LED_HEARTBEAT); /// Self overwrite check uint32_t base_address = SCB->VTOR; if ((0x08000000 + embedded_image_size) > base_address) - error(PIOS_LED_HEARTBEAT); + error(); /// FLASH_Unlock(); @@ -82,7 +79,7 @@ int main() { } if (fail == true) - error(PIOS_LED_HEARTBEAT); + error(); /// @@ -90,7 +87,6 @@ int main() { /// Bootloader programing for (uint32_t offset = 0; offset < embedded_image_size/sizeof(uint32_t); ++offset) { bool result = false; - PIOS_LED_Toggle(PIOS_LED_HEARTBEAT); for (uint8_t retry = 0; retry < MAX_WRI_RETRYS; ++retry) { if (result == false) { result = (FLASH_ProgramWord(0x08000000 + (offset * 4), embedded_image_start[offset]) @@ -98,15 +94,9 @@ int main() { } } if (result == false) - error(PIOS_LED_HEARTBEAT); + error(); } /// - for (uint8_t x = 0; x < 3; ++x) { - PIOS_LED_On(PIOS_LED_HEARTBEAT); - PIOS_DELAY_WaitmS(1000); - PIOS_LED_Off(PIOS_LED_HEARTBEAT); - PIOS_DELAY_WaitmS(1000); - } /// Invalidate the bootloader updater so we won't run /// the update again on the next power cycle. @@ -119,11 +109,7 @@ int main() { } -void error(int led) { +void error(void) { for (;;) { - PIOS_LED_On(led); - PIOS_DELAY_WaitmS(500); - PIOS_LED_Off(led); - PIOS_DELAY_WaitmS(500); } }