From f259c9aad6b410d17604e223eccf91f5f1394f5a Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sat, 2 Mar 2019 20:43:19 -0800 Subject: [PATCH] PortaPack: Add HackRF One gates for PortaPack JTAG and OperaCake code. I think these #defines might finally be the right shape... --- firmware/common/cpld_jtag.c | 6 ++++++ firmware/common/cpld_jtag.h | 2 ++ firmware/common/hackrf_core.c | 6 ++++++ firmware/common/hackrf_core.h | 2 ++ firmware/common/tuning.c | 2 ++ 5 files changed, 18 insertions(+) diff --git a/firmware/common/cpld_jtag.c b/firmware/common/cpld_jtag.c index b07d9b54..f5a6cdb2 100644 --- a/firmware/common/cpld_jtag.c +++ b/firmware/common/cpld_jtag.c @@ -35,14 +35,18 @@ void cpld_jtag_take(jtag_t* const jtag) { /* Set initial GPIO state to the voltages of the internal or external pull-ups/downs, * to avoid any glitches. */ +#ifdef HACKRF_ONE gpio_set(gpio->gpio_pp_tms); +#endif gpio_set(gpio->gpio_tms); gpio_set(gpio->gpio_tdi); gpio_clear(gpio->gpio_tck); +#ifdef HACKRF_ONE /* Do not drive PortaPack-specific TMS pin initially, just to be cautious. */ gpio_input(gpio->gpio_pp_tms); gpio_input(gpio->gpio_pp_tdo); +#endif gpio_output(gpio->gpio_tms); gpio_output(gpio->gpio_tdi); gpio_output(gpio->gpio_tck); @@ -55,9 +59,11 @@ void cpld_jtag_release(jtag_t* const jtag) { /* Make all pins inputs when JTAG interface not active. * Let the pull-ups/downs do the work. */ +#ifdef HACKRF_ONE /* Do not drive PortaPack-specific pins, initially, just to be cautious. */ gpio_input(gpio->gpio_pp_tms); gpio_input(gpio->gpio_pp_tdo); +#endif gpio_input(gpio->gpio_tms); gpio_input(gpio->gpio_tdi); gpio_input(gpio->gpio_tck); diff --git a/firmware/common/cpld_jtag.h b/firmware/common/cpld_jtag.h index 1b62b474..e0a30364 100644 --- a/firmware/common/cpld_jtag.h +++ b/firmware/common/cpld_jtag.h @@ -31,8 +31,10 @@ typedef struct jtag_gpio_t { gpio_t gpio_tck; gpio_t gpio_tdi; gpio_t gpio_tdo; +#ifdef HACKRF_ONE gpio_t gpio_pp_tms; gpio_t gpio_pp_tdo; +#endif } jtag_gpio_t; typedef struct jtag_t { diff --git a/firmware/common/hackrf_core.c b/firmware/common/hackrf_core.c index fbc2191e..f55fdc2f 100644 --- a/firmware/common/hackrf_core.c +++ b/firmware/common/hackrf_core.c @@ -124,8 +124,10 @@ static struct gpio_t gpio_cpld_tms = GPIO(3, 1); static struct gpio_t gpio_cpld_tdi = GPIO(3, 4); #endif +#ifdef HACKRF_ONE static struct gpio_t gpio_cpld_pp_tms = GPIO(1, 1); static struct gpio_t gpio_cpld_pp_tdo = GPIO(1, 8); +#endif static struct gpio_t gpio_hw_sync_enable = GPIO(5,12); static struct gpio_t gpio_rx_q_invert = GPIO(0, 13); @@ -274,8 +276,10 @@ jtag_gpio_t jtag_gpio_cpld = { .gpio_tck = &gpio_cpld_tck, .gpio_tdi = &gpio_cpld_tdi, .gpio_tdo = &gpio_cpld_tdo, +#ifdef HACKRF_ONE .gpio_pp_tms = &gpio_cpld_pp_tms, .gpio_pp_tdo = &gpio_cpld_pp_tdo, +#endif }; jtag_t jtag_cpld = { @@ -773,8 +777,10 @@ void pin_setup(void) { * * LPC43xx pull-up and pull-down resistors are approximately 53K. */ +#ifdef HACKRF_ONE scu_pinmux(SCU_PINMUX_PP_TMS, SCU_GPIO_PUP | SCU_CONF_FUNCTION0); scu_pinmux(SCU_PINMUX_PP_TDO, SCU_GPIO_PDN | SCU_CONF_FUNCTION0); +#endif scu_pinmux(SCU_PINMUX_CPLD_TMS, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0); scu_pinmux(SCU_PINMUX_CPLD_TDI, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0); scu_pinmux(SCU_PINMUX_CPLD_TDO, SCU_GPIO_PDN | SCU_CONF_FUNCTION4); diff --git a/firmware/common/hackrf_core.h b/firmware/common/hackrf_core.h index 6ce543cc..90f20ad3 100644 --- a/firmware/common/hackrf_core.h +++ b/firmware/common/hackrf_core.h @@ -77,8 +77,10 @@ extern "C" /* GPIO Input PinMux */ #define SCU_PINMUX_BOOT0 (P1_1) /* GPIO0[8] on P1_1 */ #define SCU_PINMUX_BOOT1 (P1_2) /* GPIO0[9] on P1_2 */ +#ifndef HACKRF_ONE #define SCU_PINMUX_BOOT2 (P2_8) /* GPIO5[7] on P2_8 */ #define SCU_PINMUX_BOOT3 (P2_9) /* GPIO1[10] on P2_9 */ +#endif #define SCU_PINMUX_PP_LCD_TE (P2_3) /* GPIO5[3] on P2_3 */ #define SCU_PINMUX_PP_LCD_RDX (P2_4) /* GPIO5[4] on P2_4 */ #define SCU_PINMUX_PP_UNUSED (P2_8) /* GPIO5[7] on P2_8 */ diff --git a/firmware/common/tuning.c b/firmware/common/tuning.c index e584eaad..3c500eec 100644 --- a/firmware/common/tuning.c +++ b/firmware/common/tuning.c @@ -116,7 +116,9 @@ bool set_freq(const uint64_t freq) if( success ) { freq_cache = freq; hackrf_ui()->set_frequency(freq); +#ifdef HACKRF_ONE operacake_set_range(freq_mhz); +#endif } return success; }