From fc230a39cab5b6e317d963f5eab8c9be69c8eb46 Mon Sep 17 00:00:00 2001 From: Alastair D'Silva Date: Sun, 15 May 2016 10:15:20 +1000 Subject: [PATCH] Fix tx_enable init logic save a couple of branches --- serial/serbridge.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/serial/serbridge.c b/serial/serbridge.c index 5b8b53b..80357f5 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -461,20 +461,25 @@ serbridgeInitPins() system_uart_de_swap(); } - // set both pins to 1 before turning them on so we don't cause a reset - if (mcu_isp_pin >= 0) GPIO_OUTPUT_SET(mcu_isp_pin, 1); - if (mcu_reset_pin >= 0) GPIO_OUTPUT_SET(mcu_reset_pin, 1); + /* set both pins to 1 before turning them on (so we don't cause a reset) + * then switch pin mux to make these pins GPIO pins + */ + if (mcu_isp_pin >= 0) { + GPIO_OUTPUT_SET(mcu_isp_pin, 1); + makeGpio(mcu_isp_pin); + } + + if (mcu_reset_pin >= 0) { + GPIO_OUTPUT_SET(mcu_reset_pin, 1); + makeGpio(mcu_reset_pin); + } + // set TX_ENABLE to 0 so we start up listening - if (mcu_reset_pin >= 0) GPIO_OUTPUT_SET(uart0_tx_enable_pin, 0); - // switch pin mux to make these pins GPIO pins - if (mcu_reset_pin >= 0) makeGpio(mcu_reset_pin); - if (mcu_isp_pin >= 0) makeGpio(mcu_isp_pin); if (uart0_tx_enable_pin >= 0) { + GPIO_OUTPUT_SET(uart0_tx_enable_pin, 0); makeGpio(uart0_tx_enable_pin); uart0_set_tx_enable_pin(uart0_tx_enable_pin); } - - } // Start transparent serial bridge TCP server on specified port (typ. 23)