From 42523e4bcb59f794cdb5458b48baf7259d7f0220 Mon Sep 17 00:00:00 2001 From: 4712 <4712@outlook.de> Date: Thu, 5 Nov 2015 00:28:49 +0100 Subject: [PATCH] Revert "Fix 1wire pass through for F3 + target config changes" This reverts commit c2b1dd32598c08310e7bc83b4dcf8066ba38b5ce. --- docs/Board - RMDO.md | 2 +- src/main/io/serial_1wire.c | 19 +++++----------- src/main/io/serial_msp.c | 27 ++++------------------- src/main/target/RMDO/target.h | 3 --- src/main/target/STM32F3DISCOVERY/target.h | 12 +++++----- 5 files changed, 16 insertions(+), 47 deletions(-) diff --git a/docs/Board - RMDO.md b/docs/Board - RMDO.md index b90ccf5f3d..abd4cf6454 100644 --- a/docs/Board - RMDO.md +++ b/docs/Board - RMDO.md @@ -4,7 +4,7 @@ The DoDo board is a clone of the SPRacingF3 board in terms of CPU pin mappings. Hardware differences compared to SPRacingF3 are as follows: -* Rev 1 and Rev 2: the CPU is the cheaper version of the F3 with only 128KB FLASH. Rev 3: the CPU is a F3 version with 256KB FLASH. +* The CPU is the cheaper version of the F3 with only 128KB FLASH. * The external flash rom is the same size as found on the Naze32 (2MBit) * The barometer is the cheaper BMP280. * It does not have any compass sensor. diff --git a/src/main/io/serial_1wire.c b/src/main/io/serial_1wire.c index c1d08d20e7..7fe12aebc4 100644 --- a/src/main/io/serial_1wire.c +++ b/src/main/io/serial_1wire.c @@ -26,6 +26,7 @@ #include "drivers/gpio.h" #include "drivers/light_led.h" +#include "drivers/system.h" #include "io/serial_1wire.h" const escHardware_t escHardware[ESC_COUNT] = { @@ -96,7 +97,7 @@ void usb1WireInitialize() #ifdef BEEPER // fix for buzzer often starts beeping continuously when the ESCs are read // switch beeper off until reboot - gpio_set_mode(BEEP_GPIO, BEEP_PIN, Mode_IN_FLOATING); // set input no pull up or down + gpio_set_mode(BEEP_GPIO, BEEP_PIN, Mode_IN_FLOATING); //GPIO_Mode_IPU #endif } @@ -137,6 +138,8 @@ static void gpioSetOne(uint32_t escIndex, GPIO_Mode mode) { } #endif +#define disable_hardware_uart __disable_irq() +#define enable_hardware_uart __enable_irq() #define ESC_HI(escIndex) ((escHardware[escIndex].gpio->IDR & (1U << escHardware[escIndex].pinpos)) != (uint32_t)Bit_RESET) #define RX_HI ((S1W_RX_GPIO->IDR & S1W_RX_PIN) != (uint32_t)Bit_RESET) #define ESC_SET_HI(escIndex) escHardware[escIndex].gpio->BSRR = (1U << escHardware[escIndex].pinpos) @@ -187,7 +190,7 @@ void usb1WirePassthrough(uint8_t escIndex) #endif //Disable all interrupts - __disable_irq(); + disable_hardware_uart; // reset all the pins GPIO_ResetBits(S1W_RX_GPIO, S1W_RX_PIN); @@ -222,11 +225,7 @@ void usb1WirePassthrough(uint8_t escIndex) // Wait for programmer to go 0 -> 1 uint32_t ct=3333; while(!RX_HI) { -<<<<<<< HEAD if (ct > 0) ct--; //count down until 0; -======= - if (ct > 0) ct--; // count down until 0; ->>>>>>> 9be5abf... Fix 1wire pass through for F3 + target config changes // check for low time ->ct=3333 ~600uS //byte LO time for 0 @ 19200 baud -> 9*52 uS => 468.75uS // App must send a 0 at 9600 baud (or lower) which has a LO time of at 104uS (or more) > 0 = 937.5uS LO // BLHeliSuite will use 4800 baud @@ -250,7 +249,6 @@ void usb1WirePassthrough(uint8_t escIndex) } } } -<<<<<<< HEAD // we get here in case ct reached zero TX_SET_HIGH; @@ -262,13 +260,6 @@ void usb1WirePassthrough(uint8_t escIndex) // Wait a bit more to let App read the 0 byte and switch baudrate // 2ms will most likely do the job, but give some grace time delay(10); -======= - // we get here in case ct reached zero - TX_SET_HIGH; - RX_LED_OFF; - // Enable all irq (for Hardware UART) - __enable_irq(); ->>>>>>> 9be5abf... Fix 1wire pass through for F3 + target config changes return; } diff --git a/src/main/io/serial_msp.c b/src/main/io/serial_msp.c index 3831512f7d..bebc1c5cd3 100644 --- a/src/main/io/serial_msp.c +++ b/src/main/io/serial_msp.c @@ -1799,32 +1799,13 @@ static bool processInCommand(void) headSerialReply(0); tailSerialReply(); // wait for all data to send - waitForSerialPortToFinishTransmitting(currentPort->port); + while (!isSerialTransmitBufferEmpty(mspSerialPort)) { + delay(50); + } // Start to activate here // motor 1 => index 0 - - // search currentPort portIndex - /* next lines seems to be unnecessary, because the currentPort always point to the same mspPorts[portIndex] - uint8_t portIndex; - for (portIndex = 0; portIndex < MAX_MSP_PORT_COUNT; portIndex++) { - if (currentPort == &mspPorts[portIndex]) { - break; - } - } - */ - mspReleasePortIfAllocated(mspSerialPort); // CloseSerialPort also marks currentPort as UNUSED_PORT usb1WirePassthrough(i); - // Wait a bit more to let App read the 0 byte and switch baudrate - // 2ms will most likely do the job, but give some grace time - delay(10); - // rebuild/refill currentPort structure, does openSerialPort if marked UNUSED_PORT - used ports are skiped - mspAllocateSerialPorts(&masterConfig.serialConfig); - /* restore currentPort and mspSerialPort - setCurrentPort(&mspPorts[portIndex]); // not needed same index will be restored - */ - // former used MSP uart is active again - // restore MSP_SET_1WIRE as current command for correct headSerialReply(0) - currentPort->cmdMSP = MSP_SET_1WIRE; + // MPS uart is active again } else { // ESC channel higher than max. allowed // rem: BLHeliSuite will not support more than 8 diff --git a/src/main/target/RMDO/target.h b/src/main/target/RMDO/target.h index 43da0ebee3..da112034b5 100644 --- a/src/main/target/RMDO/target.h +++ b/src/main/target/RMDO/target.h @@ -162,10 +162,7 @@ // USART3, #define BIND_PORT GPIOB #define BIND_PIN Pin_11 -<<<<<<< HEAD -======= ->>>>>>> 9be5abf... Fix 1wire pass through for F3 + target config changes #define USE_SERIAL_1WIRE #define ESC_COUNT 8 #define S1W_TX_GPIO GPIOA diff --git a/src/main/target/STM32F3DISCOVERY/target.h b/src/main/target/STM32F3DISCOVERY/target.h index 844949ed3c..12e0aa39a6 100644 --- a/src/main/target/STM32F3DISCOVERY/target.h +++ b/src/main/target/STM32F3DISCOVERY/target.h @@ -102,9 +102,9 @@ #define USE_SERIAL_1WIRE // How many escs does this board support? #define ESC_COUNT 6 -// STM32F3DISCOVERY TX - PD5 connects to UART RX -#define S1W_TX_GPIO GPIOD -#define S1W_TX_PIN GPIO_Pin_5 -// STM32F3DISCOVERY RX - PD6 connects to UART TX -#define S1W_RX_GPIO GPIOD -#define S1W_RX_PIN GPIO_Pin_6 +// STM32F3DISCOVERY TX - PC3 connects to UART RX +#define S1W_TX_GPIO GPIOC +#define S1W_TX_PIN GPIO_Pin_3 +// STM32F3DISCOVERY RX - PC1 connects to UART TX +#define S1W_RX_GPIO GPIOC +#define S1W_RX_PIN GPIO_Pin_1