2323#include "si5351c.h"
2424#include "clkin.h"
2525#include "platform_detect.h"
26+ #include "platform_gpio.h"
2627#include "platform_scu.h"
27- #include "gpio_lpc.h"
2828#include "hackrf_core.h"
2929#include "selftest.h"
3030
31- /* HackRF One r9 clock control */
32- // clang-format off
33- static struct gpio_t gpio_h1r9_clkin_en = GPIO (5 , 15 );
34- static struct gpio_t gpio_h1r9_clkout_en = GPIO (0 , 9 );
35- static struct gpio_t gpio_h1r9_mcu_clk_en = GPIO (0 , 8 );
36- // clang-format on
37-
3831#include <stdbool.h>
3932
4033static enum pll_sources active_clock_source = PLL_SOURCE_UNINITIALIZED ;
@@ -195,6 +188,7 @@ void si5351c_configure_clock_control(
195188 uint8_t clkout_ctrl ;
196189
197190 board_id_t board_id = detected_platform ();
191+ const platform_gpio_t * gpio = platform_gpio ();
198192
199193 if (board_id == BOARD_ID_RAD1O ) {
200194 /* PLLA on XTAL */
@@ -215,13 +209,13 @@ void si5351c_configure_clock_control(
215209 * but externally switches that input to CLKIN.
216210 */
217211 pll = SI5351C_CLK_PLL_SRC_A ;
218- gpio_set (& gpio_h1r9_clkin_en );
212+ gpio_set (gpio -> h1r9_clkin_en );
219213 }
220214 } else {
221215 /* PLLA on XTAL */
222216 pll = SI5351C_CLK_PLL_SRC_A ;
223217 if (board_id == BOARD_ID_HACKRF1_R9 ) {
224- gpio_clear (& gpio_h1r9_clkin_en );
218+ gpio_clear (gpio -> h1r9_clkin_en );
225219 }
226220 }
227221 break ;
@@ -298,6 +292,7 @@ void si5351c_enable_clock_outputs(si5351c_driver_t* const drv)
298292 /* 3: External clock output is deactivated by default */
299293
300294 board_id_t board_id = detected_platform ();
295+ const platform_gpio_t * gpio = platform_gpio ();
301296
302297 uint8_t value ;
303298 if (board_id != BOARD_ID_PRALINE ) {
@@ -327,10 +322,12 @@ void si5351c_enable_clock_outputs(si5351c_driver_t* const drv)
327322 uint8_t data [] = {SI5351C_REG_OUTPUT_EN , value };
328323 si5351c_write (drv , data , sizeof (data ));
329324
330- if ((clkout_enabled ) && (detected_platform () == BOARD_ID_HACKRF1_R9 )) {
331- gpio_set (& gpio_h1r9_clkout_en );
332- } else {
333- gpio_clear (& gpio_h1r9_clkout_en );
325+ if (detected_platform () == BOARD_ID_HACKRF1_R9 ) {
326+ if (clkout_enabled ) {
327+ gpio_set (gpio -> h1r9_clkout_en );
328+ } else {
329+ gpio_clear (gpio -> h1r9_clkout_en );
330+ }
334331 }
335332}
336333
@@ -424,22 +421,23 @@ void si5351c_init(si5351c_driver_t* const drv)
424421 }
425422
426423 if (detected_platform () == BOARD_ID_HACKRF1_R9 ) {
424+ const platform_gpio_t * gpio = platform_gpio ();
427425 const platform_scu_t * scu = platform_scu ();
428426
429427 /* CLKIN_EN */
430428 scu_pinmux (scu -> H1R9_CLKIN_EN , SCU_GPIO_FAST | SCU_CONF_FUNCTION4 );
431- gpio_clear (& gpio_h1r9_clkin_en );
432- gpio_output (& gpio_h1r9_clkin_en );
429+ gpio_clear (gpio -> h1r9_clkin_en );
430+ gpio_output (gpio -> h1r9_clkin_en );
433431
434432 /* CLKOUT_EN */
435433 scu_pinmux (scu -> H1R9_CLKOUT_EN , SCU_GPIO_FAST | SCU_CONF_FUNCTION0 );
436- gpio_clear (& gpio_h1r9_clkout_en );
437- gpio_output (& gpio_h1r9_clkout_en );
434+ gpio_clear (gpio -> h1r9_clkout_en );
435+ gpio_output (gpio -> h1r9_clkout_en );
438436
439437 /* MCU_CLK_EN */
440438 scu_pinmux (scu -> H1R9_MCU_CLK_EN , SCU_GPIO_FAST | SCU_CONF_FUNCTION0 );
441- gpio_clear (& gpio_h1r9_mcu_clk_en );
442- gpio_output (& gpio_h1r9_mcu_clk_en );
439+ gpio_clear (gpio -> h1r9_mcu_clk_en );
440+ gpio_output (gpio -> h1r9_mcu_clk_en );
443441 }
444442 (void ) drv ;
445443}
0 commit comments