Skip to content

Commit

Permalink
fix(sgpio): Update rad1o update_q_invert gpio access
Browse files Browse the repository at this point in the history
  • Loading branch information
schneider42 committed Jan 27, 2017
1 parent fb2057c commit f063f87
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions firmware/common/sgpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <sgpio.h>

#ifdef RAD1O
static void update_q_invert(void);
static void update_q_invert(sgpio_config_t* const config);
#endif

void sgpio_configure_pin_functions(sgpio_config_t* const config) {
Expand Down Expand Up @@ -95,7 +95,7 @@ void sgpio_configure(
#ifdef RAD1O
// The data direction might have changed. Check if we need to
// adjust the q inversion.
update_q_invert();
update_q_invert(config);
#endif

// Enable SGPIO pin outputs.
Expand Down Expand Up @@ -291,22 +291,20 @@ static bool sgpio_invert = false;
* Called when TX/RX changes od sgpio_cpld_stream_rx_set_q_invert
* gets called.
*/
static void update_q_invert(void) {
#if 0 //XXX
static void update_q_invert(sgpio_config_t* const config) {
/* 1=Output SGPIO11 High(TX mode), 0=Output SGPIO11 Low(RX mode)*/
bool tx_mode = (SGPIO_GPIO_OUTREG & (1 << 11)) > 0;

// 0.13: P1_18
if( !sgpio_invert & !tx_mode) {
GPIO_SET(GPIO0) = GPIOPIN13;
gpio_write(config->gpio_rx_q_invert, 1);
} else if( !sgpio_invert & tx_mode) {
GPIO_CLR(GPIO0) = GPIOPIN13;
gpio_write(config->gpio_rx_q_invert, 0);
} else if( sgpio_invert & !tx_mode) {
GPIO_CLR(GPIO0) = GPIOPIN13;
gpio_write(config->gpio_rx_q_invert, 0);
} else if( sgpio_invert & tx_mode) {
GPIO_SET(GPIO0) = GPIOPIN13;
gpio_write(config->gpio_rx_q_invert, 1);
}
#endif
}

void sgpio_cpld_stream_rx_set_q_invert(sgpio_config_t* const config, const uint_fast8_t invert) {
Expand All @@ -316,7 +314,7 @@ void sgpio_cpld_stream_rx_set_q_invert(sgpio_config_t* const config, const uint_
sgpio_invert = false;
}

update_q_invert();
update_q_invert(config);
}

#else
Expand Down

0 comments on commit f063f87

Please sign in to comment.