Merge branch 'portapack_ui'
This commit is contained in:
@ -18,9 +18,6 @@ submodule:
|
||||
$ cd ..
|
||||
$ git submodule init
|
||||
$ git submodule update
|
||||
$ cd firmware/libopencm3
|
||||
$ make
|
||||
|
||||
|
||||
To build and install a standard firmware image for HackRF One:
|
||||
|
||||
|
@ -29,29 +29,73 @@ static refill_buffer_cb refill_buffer;
|
||||
static uint32_t xsvf_buffer_len, xsvf_pos;
|
||||
static unsigned char* xsvf_buffer;
|
||||
|
||||
void cpld_jtag_setup(jtag_t* const jtag) {
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TDO, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION4);
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TCK, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
|
||||
void cpld_jtag_init(jtag_t* const jtag) {
|
||||
/* Initialize pin GPIOs in "released" state. */
|
||||
cpld_jtag_release(jtag);
|
||||
|
||||
/* TDI and TMS pull-ups are required in all JTAG-compliant devices.
|
||||
*
|
||||
* The HackRF CPLD is always present, so let the CPLD pull up its TDI and TMS.
|
||||
*
|
||||
* The PortaPack may not be present, so pull up the PortaPack TMS pin from the
|
||||
* microcontroller.
|
||||
*
|
||||
* TCK is recommended to be held low, so use microcontroller pull-down.
|
||||
*
|
||||
* TDO is undriven except when in Shift-IR or Shift-DR phases.
|
||||
* Use the microcontroller to pull down to keep from floating.
|
||||
*
|
||||
* LPC43xx pull-up and pull-down resistors are approximately 53K.
|
||||
*/
|
||||
#ifdef USER_INTERFACE_PORTAPACK
|
||||
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);
|
||||
|
||||
gpio_input(jtag->gpio->gpio_tdo);
|
||||
gpio_output(jtag->gpio->gpio_tck);
|
||||
gpio_output(jtag->gpio->gpio_tms);
|
||||
gpio_output(jtag->gpio->gpio_tdi);
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TDO, SCU_GPIO_PDN | SCU_CONF_FUNCTION4);
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TCK, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
|
||||
}
|
||||
|
||||
/* set pins as inputs so we don't interfere with an external JTAG device */
|
||||
void cpld_jtag_release(jtag_t* const jtag) {
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TDO, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION4);
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TCK, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TMS, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TDI, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
|
||||
void cpld_jtag_take(jtag_t* const jtag) {
|
||||
const jtag_gpio_t* const gpio = jtag->gpio;
|
||||
|
||||
gpio_input(jtag->gpio->gpio_tdo);
|
||||
gpio_input(jtag->gpio->gpio_tck);
|
||||
gpio_input(jtag->gpio->gpio_tms);
|
||||
gpio_input(jtag->gpio->gpio_tdi);
|
||||
#ifdef USER_INTERFACE_PORTAPACK
|
||||
/* 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);
|
||||
gpio_input(gpio->gpio_tdo);
|
||||
}
|
||||
|
||||
void cpld_jtag_release(jtag_t* const jtag) {
|
||||
const jtag_gpio_t* const gpio = jtag->gpio;
|
||||
|
||||
/* Make all pins inputs when JTAG interface not active.
|
||||
* Let the pull-ups/downs do the work.
|
||||
*/
|
||||
#ifdef USER_INTERFACE_PORTAPACK
|
||||
/* 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);
|
||||
gpio_input(gpio->gpio_tdo);
|
||||
|
||||
/* Set initial GPIO state to the voltages of the internal or external pull-ups/downs,
|
||||
* to avoid any glitches.
|
||||
*/
|
||||
#ifdef USER_INTERFACE_PORTAPACK
|
||||
gpio_set(gpio->gpio_pp_tms);
|
||||
#endif
|
||||
gpio_set(gpio->gpio_tms);
|
||||
gpio_set(gpio->gpio_tdi);
|
||||
gpio_clear(gpio->gpio_tck);
|
||||
}
|
||||
|
||||
/* return 0 if success else return error code see xsvfExecute() */
|
||||
@ -62,7 +106,7 @@ int cpld_jtag_program(
|
||||
refill_buffer_cb refill
|
||||
) {
|
||||
int error;
|
||||
cpld_jtag_setup(jtag);
|
||||
cpld_jtag_take(jtag);
|
||||
xsvf_buffer = buffer;
|
||||
xsvf_buffer_len = buffer_length;
|
||||
refill_buffer = refill;
|
||||
|
@ -31,6 +31,10 @@ typedef struct jtag_gpio_t {
|
||||
gpio_t gpio_tck;
|
||||
gpio_t gpio_tdi;
|
||||
gpio_t gpio_tdo;
|
||||
#ifdef USER_INTERFACE_PORTAPACK
|
||||
gpio_t gpio_pp_tms;
|
||||
gpio_t gpio_pp_tdo;
|
||||
#endif
|
||||
} jtag_gpio_t;
|
||||
|
||||
typedef struct jtag_t {
|
||||
@ -39,6 +43,8 @@ typedef struct jtag_t {
|
||||
|
||||
typedef void (*refill_buffer_cb)(void);
|
||||
|
||||
void cpld_jtag_init(jtag_t* const jtag);
|
||||
void cpld_jtag_take(jtag_t* const jtag);
|
||||
void cpld_jtag_release(jtag_t* const jtag);
|
||||
|
||||
/* Return 0 if success else return error code see xsvfExecute() see micro.h.
|
||||
|
@ -14,4 +14,8 @@ void hackrf_ui_setBBLNAGain(const uint32_t gain_db) __attribute__((weak));
|
||||
void hackrf_ui_setBBVGAGain(const uint32_t gain_db) __attribute__((weak));
|
||||
void hackrf_ui_setBBTXVGAGain(const uint32_t gain_db) __attribute__((weak));
|
||||
|
||||
void hackrf_ui_setFirstIFFrequency(const uint64_t freq) __attribute__((weak));
|
||||
void hackrf_ui_setFilter(const rf_path_filter_t filter) __attribute__((weak));
|
||||
void hackrf_ui_setAntennaBias(bool antenna_bias) __attribute__((weak));
|
||||
|
||||
#endif
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "w25q80bv_target.h"
|
||||
#include "i2c_bus.h"
|
||||
#include "i2c_lpc.h"
|
||||
#include "cpld_jtag.h"
|
||||
#include <libopencm3/lpc43xx/cgu.h>
|
||||
#include <libopencm3/lpc43xx/ccu.h>
|
||||
#include <libopencm3/lpc43xx/scu.h>
|
||||
@ -123,6 +124,11 @@ static struct gpio_t gpio_cpld_tms = GPIO(3, 1);
|
||||
static struct gpio_t gpio_cpld_tdi = GPIO(3, 4);
|
||||
#endif
|
||||
|
||||
#ifdef USER_INTERFACE_PORTAPACK
|
||||
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);
|
||||
|
||||
@ -270,6 +276,10 @@ jtag_gpio_t jtag_gpio_cpld = {
|
||||
.gpio_tck = &gpio_cpld_tck,
|
||||
.gpio_tdi = &gpio_cpld_tdi,
|
||||
.gpio_tdo = &gpio_cpld_tdo,
|
||||
#ifdef USER_INTERFACE_PORTAPACK
|
||||
.gpio_pp_tms = &gpio_cpld_pp_tms,
|
||||
.gpio_pp_tdo = &gpio_cpld_pp_tdo,
|
||||
#endif
|
||||
};
|
||||
|
||||
jtag_t jtag_cpld = {
|
||||
@ -750,16 +760,10 @@ void ssp1_set_mode_max5864(void)
|
||||
}
|
||||
|
||||
void pin_setup(void) {
|
||||
/* Release CPLD JTAG pins */
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TDO, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION4);
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TCK, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TMS, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TDI, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
|
||||
/* Configure all GPIO as Input (safe state) */
|
||||
gpio_init();
|
||||
|
||||
gpio_input(&gpio_cpld_tdo);
|
||||
gpio_input(&gpio_cpld_tck);
|
||||
gpio_input(&gpio_cpld_tms);
|
||||
gpio_input(&gpio_cpld_tdi);
|
||||
cpld_jtag_init(&jtag_cpld);
|
||||
|
||||
/* Configure SCU Pin Mux as GPIO */
|
||||
scu_pinmux(SCU_PINMUX_LED1, SCU_GPIO_NOPULL);
|
||||
@ -769,17 +773,12 @@ void pin_setup(void) {
|
||||
scu_pinmux(SCU_PINMUX_LED4, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION4);
|
||||
#endif
|
||||
|
||||
scu_pinmux(SCU_PINMUX_EN1V8, SCU_GPIO_NOPULL);
|
||||
|
||||
/* Configure USB indicators */
|
||||
#ifdef JAWBREAKER
|
||||
scu_pinmux(SCU_PINMUX_USB_LED0, SCU_CONF_FUNCTION3);
|
||||
scu_pinmux(SCU_PINMUX_USB_LED1, SCU_CONF_FUNCTION3);
|
||||
#endif
|
||||
|
||||
/* Configure all GPIO as Input (safe state) */
|
||||
gpio_init();
|
||||
|
||||
gpio_output(&gpio_led[0]);
|
||||
gpio_output(&gpio_led[1]);
|
||||
gpio_output(&gpio_led[2]);
|
||||
@ -787,7 +786,9 @@ void pin_setup(void) {
|
||||
gpio_output(&gpio_led[3]);
|
||||
#endif
|
||||
|
||||
disable_1v8_power();
|
||||
gpio_output(&gpio_1v8_enable);
|
||||
scu_pinmux(SCU_PINMUX_EN1V8, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
|
||||
|
||||
#ifdef HACKRF_ONE
|
||||
/* Safe state: start with VAA turned off: */
|
||||
@ -796,18 +797,20 @@ void pin_setup(void) {
|
||||
/* Configure RF power supply (VAA) switch control signal as output */
|
||||
gpio_output(&gpio_vaa_disable);
|
||||
|
||||
#ifndef USER_INTERFACE_PORTAPACK
|
||||
/* Not sure why this is necessary for stock HackRF. Just "rhyming" with the RAD1O code? */
|
||||
scu_pinmux(SCU_PINMUX_GPIO3_10, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(SCU_PINMUX_GPIO3_11, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef RAD1O
|
||||
/* Configure RF power supply (VAA) switch control signal as output */
|
||||
gpio_output(&gpio_vaa_enable);
|
||||
|
||||
/* Safe state: start with VAA turned off: */
|
||||
disable_rf_power();
|
||||
|
||||
/* Configure RF power supply (VAA) switch control signal as output */
|
||||
gpio_output(&gpio_vaa_enable);
|
||||
|
||||
/* Disable unused clock outputs. They generate noise. */
|
||||
scu_pinmux(CLK0, SCU_CLK_IN | SCU_CONF_FUNCTION7);
|
||||
scu_pinmux(CLK2, SCU_CLK_IN | SCU_CONF_FUNCTION7);
|
||||
|
@ -77,8 +77,16 @@ 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 */
|
||||
#ifdef USER_INTERFACE_PORTAPACK
|
||||
#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 */
|
||||
#define SCU_PINMUX_PP_LCD_WRX (P2_9) /* GPIO1[10] on P2_9 */
|
||||
#define SCU_PINMUX_PP_DIR (P2_13) /* GPIO1[13] on P2_13 */
|
||||
#else
|
||||
#define SCU_PINMUX_BOOT2 (P2_8) /* GPIO5[7] on P2_8 */
|
||||
#define SCU_PINMUX_BOOT3 (P2_9) /* GPIO1[10] on P2_9 */
|
||||
#endif
|
||||
|
||||
/* USB peripheral */
|
||||
#ifdef JAWBREAKER
|
||||
@ -206,6 +214,14 @@ extern "C"
|
||||
#define SCU_RX_LNA (P6_7) /* GPIO5[15] on P6_7 */
|
||||
#endif
|
||||
|
||||
#define SCU_PINMUX_PP_D0 (P7_0) /* GPIO3[8] */
|
||||
#define SCU_PINMUX_PP_D1 (P7_1) /* GPIO3[9] */
|
||||
#define SCU_PINMUX_PP_D2 (P7_2) /* GPIO3[10] */
|
||||
#define SCU_PINMUX_PP_D3 (P7_3) /* GPIO3[11] */
|
||||
#define SCU_PINMUX_PP_D4 (P7_4) /* GPIO3[12] */
|
||||
#define SCU_PINMUX_PP_D5 (P7_5) /* GPIO3[13] */
|
||||
#define SCU_PINMUX_PP_D6 (P7_6) /* GPIO3[14] */
|
||||
#define SCU_PINMUX_PP_D7 (P7_7) /* GPIO3[15] */
|
||||
/* TODO add other Pins */
|
||||
#define SCU_PINMUX_GPIO3_8 (P7_0) /* GPIO3[8] */
|
||||
#define SCU_PINMUX_GPIO3_9 (P7_1) /* GPIO3[9] */
|
||||
@ -216,8 +232,10 @@ extern "C"
|
||||
#define SCU_PINMUX_GPIO3_14 (P7_6) /* GPIO3[14] */
|
||||
#define SCU_PINMUX_GPIO3_15 (P7_7) /* GPIO3[15] */
|
||||
|
||||
#define SCU_PINMUX_PP_TDO (P1_5) /* GPIO1[8] */
|
||||
#define SCU_PINMUX_SD_POW (P1_5) /* GPIO1[8] */
|
||||
#define SCU_PINMUX_SD_CMD (P1_6) /* GPIO1[9] */
|
||||
#define SCU_PINMUX_PP_TMS (P1_8) /* GPIO1[1] */
|
||||
#define SCU_PINMUX_SD_VOLT0 (P1_8) /* GPIO1[1] */
|
||||
#define SCU_PINMUX_SD_DAT0 (P1_9) /* GPIO1[2] */
|
||||
#define SCU_PINMUX_SD_DAT1 (P1_10) /* GPIO1[3] */
|
||||
@ -225,6 +243,8 @@ extern "C"
|
||||
#define SCU_PINMUX_SD_DAT3 (P1_12) /* GPIO1[5] */
|
||||
#define SCU_PINMUX_SD_CD (P1_13) /* GPIO1[6] */
|
||||
|
||||
#define SCU_PINMUX_PP_IO_STBX (P2_0) /* GPIO5[0] */
|
||||
#define SCU_PINMUX_PP_ADDR (P2_1) /* GPIO5[1] */
|
||||
#define SCU_PINMUX_U0_TXD (P2_0) /* GPIO5[0] */
|
||||
#define SCU_PINMUX_U0_RXD (P2_1) /* GPIO5[1] */
|
||||
|
||||
|
@ -66,3 +66,14 @@ void i2c_lpc_transfer(i2c_bus_t* const bus,
|
||||
|
||||
i2c_stop(port);
|
||||
}
|
||||
|
||||
bool i2c_probe(i2c_bus_t* const bus, const uint_fast8_t device_address) {
|
||||
const uint32_t port = (uint32_t)bus->obj;
|
||||
|
||||
i2c_tx_start(port);
|
||||
i2c_tx_byte(port, (device_address << 1) | I2C_WRITE);
|
||||
const bool detected = (I2C_STAT(port) == 0x18);
|
||||
i2c_stop(port);
|
||||
|
||||
return detected;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "i2c_bus.h"
|
||||
|
||||
@ -38,5 +39,6 @@ void i2c_lpc_transfer(i2c_bus_t* const bus,
|
||||
const uint8_t* const data_tx, const size_t count_tx,
|
||||
uint8_t* const data_rx, const size_t count_rx
|
||||
);
|
||||
bool i2c_probe(i2c_bus_t* const bus, const uint_fast8_t device_address);
|
||||
|
||||
#endif/*__I2C_LPC_H__*/
|
||||
|
@ -415,6 +415,8 @@ void rf_path_set_filter(rf_path_t* const rf_path, const rf_path_filter_t filter)
|
||||
}
|
||||
|
||||
switchctrl_set(rf_path, rf_path->switchctrl);
|
||||
|
||||
hackrf_ui_setFilter(filter);
|
||||
}
|
||||
|
||||
void rf_path_set_lna(rf_path_t* const rf_path, const uint_fast8_t enable) {
|
||||
@ -447,4 +449,6 @@ void rf_path_set_antenna(rf_path_t* const rf_path, const uint_fast8_t enable) {
|
||||
}
|
||||
|
||||
switchctrl_set(rf_path, rf_path->switchctrl);
|
||||
|
||||
hackrf_ui_setAntennaBias(enable);
|
||||
}
|
||||
|
@ -116,7 +116,9 @@ bool set_freq(const uint64_t freq)
|
||||
if( success ) {
|
||||
freq_cache = freq;
|
||||
hackrf_ui_setFrequency(freq);
|
||||
#ifndef USER_INTERFACE_PORTAPACK
|
||||
operacake_set_range(freq_mhz);
|
||||
#endif
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
1100
firmware/common/ui_portapack.c
Normal file
1100
firmware/common/ui_portapack.c
Normal file
File diff suppressed because it is too large
Load Diff
87
firmware/common/ui_portapack.h
Normal file
87
firmware/common/ui_portapack.h
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2018 Jared Boone
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __UI_PORTAPACK_H__
|
||||
#define __UI_PORTAPACK_H__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct ui_color_t {
|
||||
uint16_t v;
|
||||
} ui_color_t;
|
||||
|
||||
typedef struct ui_point_t {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
} ui_point_t;
|
||||
|
||||
typedef struct ui_size_t {
|
||||
int16_t width;
|
||||
int16_t height;
|
||||
} ui_size_t;
|
||||
|
||||
typedef struct ui_rect_t {
|
||||
ui_point_t point;
|
||||
ui_size_t size;
|
||||
} ui_rect_t;
|
||||
|
||||
typedef struct ui_bitmap_t {
|
||||
ui_size_t size;
|
||||
const uint8_t* const data;
|
||||
} ui_bitmap_t;
|
||||
|
||||
typedef struct ui_font_t {
|
||||
const ui_size_t glyph_size;
|
||||
const uint8_t* const data;
|
||||
char c_start;
|
||||
size_t c_count;
|
||||
size_t data_stride;
|
||||
} ui_font_t;
|
||||
|
||||
typedef void (*hackrf_ui_init_fn)(void);
|
||||
typedef void (*hackrf_ui_set_frequency_fn)(uint64_t frequency);
|
||||
typedef void (*hackrf_ui_set_sample_rate_fn)(uint32_t sample_rate);
|
||||
typedef void (*hackrf_ui_set_direction_fn)(const rf_path_direction_t direction);
|
||||
typedef void (*hackrf_ui_set_filter_bw_fn)(uint32_t bandwidth);
|
||||
typedef void (*hackrf_ui_set_lna_power_fn)(bool lna_on);
|
||||
typedef void (*hackrf_ui_set_bb_lna_gain_fn)(const uint32_t gain_db);
|
||||
typedef void (*hackrf_ui_set_bb_vga_gain_fn)(const uint32_t gain_db);
|
||||
typedef void (*hackrf_ui_set_bb_tx_vga_gain_fn)(const uint32_t gain_db);
|
||||
typedef void (*hackrf_ui_set_first_if_frequency_fn)(const uint64_t frequency);
|
||||
typedef void (*hackrf_ui_set_filter_fn)(const rf_path_filter_t filter);
|
||||
typedef void (*hackrf_ui_set_antenna_bias_fn)(bool antenna_bias);
|
||||
|
||||
typedef struct {
|
||||
hackrf_ui_init_fn init;
|
||||
hackrf_ui_set_frequency_fn set_frequency;
|
||||
hackrf_ui_set_sample_rate_fn set_sample_rate;
|
||||
hackrf_ui_set_direction_fn set_direction;
|
||||
hackrf_ui_set_filter_bw_fn set_filter_bw;
|
||||
hackrf_ui_set_lna_power_fn set_lna_power;
|
||||
hackrf_ui_set_bb_lna_gain_fn set_bb_lna_gain;
|
||||
hackrf_ui_set_bb_vga_gain_fn set_bb_vga_gain;
|
||||
hackrf_ui_set_bb_tx_vga_gain_fn set_bb_tx_vga_gain;
|
||||
hackrf_ui_set_first_if_frequency_fn set_first_if_frequency;
|
||||
hackrf_ui_set_filter_fn set_filter;
|
||||
hackrf_ui_set_antenna_bias_fn set_antenna_bias;
|
||||
} hackrf_ui_t;
|
||||
|
||||
#endif/*__UI_PORTAPACK_H__*/
|
2079
firmware/cpld/sgpio_if/default.svf
Normal file
2079
firmware/cpld/sgpio_if/default.svf
Normal file
File diff suppressed because it is too large
Load Diff
@ -27,10 +27,11 @@
|
||||
|
||||
enable_language(C CXX ASM)
|
||||
|
||||
SET(PATH_HACKRF ../..)
|
||||
SET(PATH_HACKRF_FIRMWARE ${PATH_HACKRF}/firmware)
|
||||
SET(PATH_HACKRF_FIRMWARE ${CMAKE_CURRENT_LIST_DIR})
|
||||
SET(PATH_HACKRF ${PATH_HACKRF_FIRMWARE}/..)
|
||||
SET(PATH_HACKRF_FIRMWARE_COMMON ${PATH_HACKRF_FIRMWARE}/common)
|
||||
SET(LIBOPENCM3 ${PATH_HACKRF_FIRMWARE}/libopencm3)
|
||||
SET(PATH_DFU_PY ${PATH_HACKRF_FIRMWARE}/dfu.py)
|
||||
|
||||
include(${PATH_HACKRF_FIRMWARE}/dfu-util.cmake)
|
||||
|
||||
@ -61,11 +62,19 @@ else()
|
||||
set(MCU_PARTNO LPC4330)
|
||||
endif()
|
||||
|
||||
if(BOARD STREQUAL "RAD1O")
|
||||
set(USER_INTERFACE RAD1O)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED USER_INTERFACE)
|
||||
set(USER_INTERFACE NONE)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED SRC_M0)
|
||||
set(SRC_M0 "${PATH_HACKRF_FIRMWARE_COMMON}/m0_sleep.c")
|
||||
endif()
|
||||
|
||||
SET(HACKRF_OPTS "-D${BOARD} -DLPC43XX -D${MCU_PARTNO} -DTX_ENABLE -D'VERSION_STRING=\"${VERSION}\"'")
|
||||
SET(HACKRF_OPTS "-D${BOARD} -DUSER_INTERFACE_${USER_INTERFACE} -DLPC43XX -D${MCU_PARTNO} -DTX_ENABLE -D'VERSION_STRING=\"${VERSION}\"'")
|
||||
|
||||
SET(LDSCRIPT_M4 "-T${PATH_HACKRF_FIRMWARE_COMMON}/${MCU_PARTNO}_M4_memory.ld -Tlibopencm3_lpc43xx_rom_to_ram.ld -T${PATH_HACKRF_FIRMWARE_COMMON}/LPC43xx_M4_M0_image_from_text.ld")
|
||||
|
||||
@ -89,7 +98,11 @@ SET(CPUFLAGS_M4 "-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16")
|
||||
SET(CFLAGS_M4 "-std=gnu99 ${CFLAGS_COMMON} ${CPUFLAGS_M4} -DLPC43XX_M4")
|
||||
SET(CXXFLAGS_M4 "-std=gnu++0x ${CFLAGS_COMMON} ${CPUFLAGS_M4} -DLPC43XX_M4")
|
||||
SET(LDFLAGS_M4 "${LDFLAGS_COMMON} ${CPUFLAGS_M4} ${LDSCRIPT_M4} -Xlinker -Map=m4.map")
|
||||
SET(CFLAGS_M4_DFU "-std=gnu99 ${CFLAGS_COMMON} ${CPUFLAGS_M4} -DLPC43XX_M4 -DDFU_MODE")
|
||||
|
||||
SET(CFLAGS_M4_DFU "-std=gnu99 ${CFLAGS_COMMON} ${CPUFLAGS_M4} -DLPC43XX_M4")
|
||||
if(NOT USER_INTERFACE STREQUAL "PORTAPACK")
|
||||
SET(CFLAGS_M4_DFU "${CFLAGS_M4_DFU} -DDFU_MODE")
|
||||
endif()
|
||||
SET(LDFLAGS_M4_DFU "${LDFLAGS_COMMON} ${CPUFLAGS_M4} ${LDSCRIPT_M4_DFU} -Xlinker -Map=m4.map")
|
||||
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
@ -97,6 +110,15 @@ set(BUILD_SHARED_LIBS OFF)
|
||||
include_directories("${LIBOPENCM3}/include/")
|
||||
include_directories("${PATH_HACKRF_FIRMWARE_COMMON}")
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(libopencm3
|
||||
SOURCE_DIR "${LIBOPENCM3}"
|
||||
BUILD_IN_SOURCE true
|
||||
DOWNLOAD_COMMAND ""
|
||||
CONFIGURE_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
macro(DeclareTargets)
|
||||
SET(SRC_M4
|
||||
${SRC_M4}
|
||||
@ -132,6 +154,13 @@ macro(DeclareTargets)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(USER_INTERFACE STREQUAL "PORTAPACK")
|
||||
SET(SRC_M4
|
||||
${SRC_M4}
|
||||
${PATH_HACKRF_FIRMWARE_COMMON}/ui_portapack.c
|
||||
)
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
${PATH_HACKRF_FIRMWARE_COMMON}/m0_bin.s.cmake
|
||||
m0_bin.s
|
||||
@ -145,6 +174,7 @@ macro(DeclareTargets)
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME}_m0.elf ${SRC_M0})
|
||||
add_dependencies(${PROJECT_NAME}_m0.elf libopencm3)
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}_m0.elf
|
||||
@ -167,6 +197,7 @@ macro(DeclareTargets)
|
||||
set_target_properties(${PROJECT_NAME}_objects PROPERTIES COMPILE_FLAGS "${CFLAGS_M4}")
|
||||
add_dependencies(${PROJECT_NAME}_objects ${PROJECT_NAME}_m0.bin)
|
||||
add_executable(${PROJECT_NAME}.elf $<TARGET_OBJECTS:${PROJECT_NAME}_objects>)
|
||||
add_dependencies(${PROJECT_NAME}.elf libopencm3)
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}.elf
|
||||
@ -190,6 +221,7 @@ macro(DeclareTargets)
|
||||
set_target_properties(${PROJECT_NAME}_dfu_objects PROPERTIES COMPILE_FLAGS "${CFLAGS_M4_DFU}")
|
||||
add_dependencies(${PROJECT_NAME}_dfu_objects ${PROJECT_NAME}_m0.bin)
|
||||
add_executable(${PROJECT_NAME}_dfu.elf $<TARGET_OBJECTS:${PROJECT_NAME}_dfu_objects>)
|
||||
add_dependencies(${PROJECT_NAME}_dfu.elf libopencm3)
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}_dfu.elf
|
||||
@ -213,7 +245,7 @@ macro(DeclareTargets)
|
||||
COMMAND rm -f _tmp.dfu _header.bin
|
||||
COMMAND cp ${PROJECT_NAME}_dfu.bin _tmp.dfu
|
||||
COMMAND dfu-suffix --vid=0x1fc9 --pid=0x000c --did=0x0 -a _tmp.dfu
|
||||
COMMAND python ../../dfu.py ${PROJECT_NAME}
|
||||
COMMAND python ${PATH_DFU_PY} ${PROJECT_NAME}
|
||||
COMMAND cat _header.bin _tmp.dfu >${PROJECT_NAME}.dfu
|
||||
COMMAND rm -f _tmp.dfu _header.bin
|
||||
)
|
||||
|
@ -42,7 +42,6 @@ set(SRC_M4
|
||||
usb_api_register.c
|
||||
usb_api_spiflash.c
|
||||
usb_api_transceiver.c
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/operacake.c"
|
||||
usb_api_operacake.c
|
||||
usb_api_sweep.c
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/usb_queue.c"
|
||||
@ -52,6 +51,7 @@ set(SRC_M4
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/xapp058/micro.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/xapp058/ports.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/rom_iap.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/operacake.c"
|
||||
)
|
||||
|
||||
DeclareTargets()
|
||||
|
@ -48,7 +48,51 @@
|
||||
|
||||
#include "hackrf-ui.h"
|
||||
|
||||
static const usb_request_handler_fn vendor_request_handler[] = {
|
||||
// TODO: Duplicate code/knowledge, copied from /host/libhackrf/src/hackrf.c
|
||||
// TODO: Factor this into a shared #include so that firmware can use
|
||||
// the same values.
|
||||
typedef enum {
|
||||
HACKRF_VENDOR_REQUEST_SET_TRANSCEIVER_MODE = 1,
|
||||
HACKRF_VENDOR_REQUEST_MAX2837_WRITE = 2,
|
||||
HACKRF_VENDOR_REQUEST_MAX2837_READ = 3,
|
||||
HACKRF_VENDOR_REQUEST_SI5351C_WRITE = 4,
|
||||
HACKRF_VENDOR_REQUEST_SI5351C_READ = 5,
|
||||
HACKRF_VENDOR_REQUEST_SAMPLE_RATE_SET = 6,
|
||||
HACKRF_VENDOR_REQUEST_BASEBAND_FILTER_BANDWIDTH_SET = 7,
|
||||
HACKRF_VENDOR_REQUEST_RFFC5071_WRITE = 8,
|
||||
HACKRF_VENDOR_REQUEST_RFFC5071_READ = 9,
|
||||
HACKRF_VENDOR_REQUEST_SPIFLASH_ERASE = 10,
|
||||
HACKRF_VENDOR_REQUEST_SPIFLASH_WRITE = 11,
|
||||
HACKRF_VENDOR_REQUEST_SPIFLASH_READ = 12,
|
||||
_HACKRF_VENDOR_REQUEST_WRITE_CPLD = 13,
|
||||
HACKRF_VENDOR_REQUEST_BOARD_ID_READ = 14,
|
||||
HACKRF_VENDOR_REQUEST_VERSION_STRING_READ = 15,
|
||||
HACKRF_VENDOR_REQUEST_SET_FREQ = 16,
|
||||
HACKRF_VENDOR_REQUEST_AMP_ENABLE = 17,
|
||||
HACKRF_VENDOR_REQUEST_BOARD_PARTID_SERIALNO_READ = 18,
|
||||
HACKRF_VENDOR_REQUEST_SET_LNA_GAIN = 19,
|
||||
HACKRF_VENDOR_REQUEST_SET_VGA_GAIN = 20,
|
||||
HACKRF_VENDOR_REQUEST_SET_TXVGA_GAIN = 21,
|
||||
_HACKRF_VENDOR_REQUEST_SET_IF_FREQ = 22,
|
||||
HACKRF_VENDOR_REQUEST_ANTENNA_ENABLE = 23,
|
||||
HACKRF_VENDOR_REQUEST_SET_FREQ_EXPLICIT = 24,
|
||||
HACKRF_VENDOR_REQUEST_USB_WCID_VENDOR_REQ = 25,
|
||||
HACKRF_VENDOR_REQUEST_INIT_SWEEP = 26,
|
||||
HACKRF_VENDOR_REQUEST_OPERACAKE_GET_BOARDS = 27,
|
||||
HACKRF_VENDOR_REQUEST_OPERACAKE_SET_PORTS = 28,
|
||||
HACKRF_VENDOR_REQUEST_SET_HW_SYNC_MODE = 29,
|
||||
HACKRF_VENDOR_REQUEST_RESET = 30,
|
||||
HACKRF_VENDOR_REQUEST_OPERACAKE_SET_RANGES = 31,
|
||||
HACKRF_VENDOR_REQUEST_CLKOUT_ENABLE = 32,
|
||||
HACKRF_VENDOR_REQUEST_SPIFLASH_STATUS = 33,
|
||||
HACKRF_VENDOR_REQUEST_SPIFLASH_CLEAR_STATUS = 34,
|
||||
HACKRF_VENDOR_REQUEST_OPERACAKE_GPIO_TEST = 35,
|
||||
|
||||
/* Update to be the next integer after the highest-numbered request. */
|
||||
_HACKRF_VENDOR_REQUEST_ARRAY_SIZE
|
||||
} hackrf_vendor_request;
|
||||
|
||||
static usb_request_handler_fn vendor_request_handler[] = {
|
||||
NULL,
|
||||
usb_vendor_request_set_transceiver_mode,
|
||||
usb_vendor_request_write_max2837,
|
||||
@ -198,7 +242,10 @@ int main(void) {
|
||||
usb_run(&usb_device);
|
||||
|
||||
rf_path_init(&rf_path);
|
||||
|
||||
#ifndef USER_INTERFACE_PORTAPACK
|
||||
operacake_init();
|
||||
#endif
|
||||
|
||||
unsigned int phase = 0;
|
||||
|
||||
|
@ -73,7 +73,7 @@ typedef enum {
|
||||
HACKRF_VENDOR_REQUEST_SET_TXVGA_GAIN = 21,
|
||||
HACKRF_VENDOR_REQUEST_ANTENNA_ENABLE = 23,
|
||||
HACKRF_VENDOR_REQUEST_SET_FREQ_EXPLICIT = 24,
|
||||
// USB_WCID_VENDOR_REQ = 25
|
||||
HACKRF_VENDOR_REQUEST_USB_WCID_VENDOR_REQ = 25,
|
||||
HACKRF_VENDOR_REQUEST_INIT_SWEEP = 26,
|
||||
HACKRF_VENDOR_REQUEST_OPERACAKE_GET_BOARDS = 27,
|
||||
HACKRF_VENDOR_REQUEST_OPERACAKE_SET_PORTS = 28,
|
||||
|
Reference in New Issue
Block a user