173 Commits

Author SHA1 Message Date
Jonathan Suite
dab548bf29 Firmware updates to allow fine-grained control of biast from command line (#1314)
* Initial commit of hackrf_biast

* Cleaned up hackrf_biast

* Cleaned up usage info

* Include getopt.h for non-GNU systems

* Add support for overriding HackRF's default antenna power behavior in firmware.  Add support for specifying antenna power behavior in libhackrf.

* Moved bias tee config routines into user_config.c, cleaned up operation of hackrf_biast

* hackrf_biast now calls usage() and exits when invoked with no arguments

* Fixed minor documentation error in usage()

* minor syntax cleanup

* Add some documentation to the host API call

* Add proper declaration magic in hackrf.h to hackrf_set_user_bias_t_opts() to appease Visual Studio

* Documentation changes suggested by @martinling

* Moved bias t setting above switch statement, removed line that explicit turned bias t off when entering OFF mode

* Change hackrf_set_user_bias_t_opts() to use a friendly struct() instead of a bitmask.  User friendliness fixes to hackrf_biast options.  More clang-format appeasement.

* Removed support for integer mode args from hackrf_biast

* clang-format error fixes

* Tweaked position of comment for clang-format v14

* Reformat files with clang-format v14 instead of 16

* Remove internal numeric modes for bias T settings

Co-authored-by: Martin Ling <martin-github@earth.li>

* Fix documentation error in hackrf_biast.c

---------

Co-authored-by: Martin Ling <martin-github@earth.li>
2023-09-13 11:15:30 -04:00
Jacob Graves
189b5bf693 wrap clkin init in r9 board check (#1307) 2023-04-19 13:32:32 -04:00
Michael Ossmann
c19f85ef24 h1r9: use single SSP configuration for MAX283x
During r9 hardware development it was thought that the MAX2839 would use
a different GPIO pin for chip select, but it ended up being the same pin
as is used for MAX2837 on other hardware revisions.

This takes the MAX283x abstraction a bit further and fixes a bug with
hackrf_debug -m.
2023-01-08 08:21:27 -05:00
Michael Ossmann
8aa79e9fe5 h1r9: use timer to detect external clock frequency 2023-01-06 12:45:46 +00:00
Michael Ossmann
173612ac77 add --led option to hackrf_debug
and corresponding changes to libhackrf and firmware
2022-12-18 07:22:17 -05:00
schneider
d8d3dc039d m0: reset M0 before starting it
The rad1o was not starting the M0 when powered up by inserting a USB
cable. Interestingly the M0 does start when toggling the power switch.

Resetting the M0 before starting it in `main()` solves this issue.
2022-10-26 20:03:39 +02:00
Michael Ossmann
06b9d7bee0 Clean up source code copyright notices. 2022-09-23 14:46:52 -04:00
Martin Ling
44511c6c3b Move RFFC5072 setup before enabling RF power. 2022-09-19 13:02:29 +01:00
Martin Ling
6d57709000 Move delay after enabling RF power to rad1o-specific code. 2022-09-19 10:46:01 +01:00
Michael Ossmann
9329c5e44e Detect hardware platform at run-time.
Firmware now detects the hardware it is running on at startup and
refuses to run if it is compiled for the wrong platform. The board ID
returned by firmware to the host is now derived from run-time detection
rather than a compile-time value. A separate method to retrieve
compile-time supported platform is added.

On HackRF One, pin straps are checked to determine hardware revision.
This is informational to aid troubleshooting and does not affect any
function.
2022-09-14 07:08:47 -04:00
Martin Ling
ba148ee047 Add a simpler way to check CLKIN status. 2022-08-05 09:37:38 +01:00
Martin Ling
c3fdf402d7 Reformat all code to new clang-format standard. 2022-08-03 23:46:44 +01:00
Martin Ling
1fe06b425a Rename m0_state.{c,h} to usb_api_m0_state.{c,h} 2022-02-13 17:53:34 +00:00
Martin Ling
5abc39c53a Add USB requests and host support to set TX/RX shortfall limits.
This adds `-T` and `-R` options to `hackrf_debug`, which set the TX
underrun and RX overrun limits in bytes.
2022-02-13 16:46:12 +00:00
Martin Ling
fd073e391f Add USB vendor request to read M0 state, and host support for doing so.
This adds a `hackrf_debug [-S|--state]` option, and the necessary
plumbing to libhackrf and the M4 firmware to support it.

The USB API and libhackrf versions are bumped to reflect the changes.
2022-02-13 16:46:12 +00:00
Martin Ling
361c4ac54f Move transceiver mode changes out of USB ISR.
This is a defensive change to make the transceiver code easier to reason
about, and to avoid the possibility of races such as that seen in #1042.

Previously, set_transceiver_mode() was called in the vendor request
handler for the SET_TRANSCEIVER_MODE request, as well in the callback
for a USB configuration change. Both these calls are made from the USB0
ISR, so could interrupt the rx_mode(), tx_mode() and sweep_mode()
functions at any point. It was hard to tell if this was safe.

Instead, set_transceiver_mode() has been removed, and its work is split
into three parts:

- request_transceiver_mode(), which is safe to call from ISR context.
  All this function does is update the requested mode and increment a
  sequence number. This builds on work already done in PR #1029, but
  the interface has been simplified to use a shared volatile structure.

- transceiver_startup(), which transitions the transceiver from an idle
  state to the configuration required for a specific mode, including
  setting up the RF path, configuring the M0, adjusting LEDs and UI etc.

- transceiver_shutdown(), which transitions the transceiver back to an
  idle state.

The *_mode() functions that implement the transceiver modes now call
transceiver_startup() before starting work, and transceiver_shutdown()
before returning, and all this happens in the main thread of execution.

As such, it is now guaranteed that all the steps involved happen in a
consistent order, with the transceiver starting from an idle state, and
being returned to an idle state before control returns to the main loop.

For consistency of interface, an off_mode() function has been added to
implement the behaviour of the OFF transceiver mode. Since the
transceiver is already guaranteed to be in an idle state when this is
called, the only work required is to set the UI mode and wait for a new
mode request.
2022-02-08 13:45:41 +00:00
Martin Ling
7057235a14 Increment a sequence number when transceiver mode changes.
This fixes bug #1042, which occured when an RX->OFF->RX sequence
happened quickly enough that the loop in rx_mode() did not see the
change. As a result, the enable_baseband_streaming() call at the start
of that function was not repeated for the new RX operation, so RX
progress stalled.

To solve this, the vendor request handler now increments a sequence
number when it changes the transceiver mode. Instead of the RX loop
checking whether the transceiver mode is still RX, it now checks whether
the current sequence number is the same as when it was started. If not,
there must have been at least one mode change, so the loop exits, and
the main loop starts the necessary loop for the new mode. The same
behaviour is implemented for the TX and sweep loops.

For this approach to be reliable, we must ensure that when deciding
which mode and sequence number to use, we take both values from the same
set_transceiver_mode request.

To achieve this, we briefly disable the USB0 interrupt to stop the
vendor request handler from running whilst reading the mode and sequence
number together. Then the loop dispatch proceeds using those pre-read
values.
2022-02-03 07:36:34 +00:00
Mike Walters
e41314f130 operacake: add API function to set port dwell times 2021-10-14 14:41:52 +01:00
Mike Walters
790b5d35cf operacake: add get/set switching mode functions 2021-10-14 14:36:18 +01:00
Mike Walters
7f21c93c33 Copy M0 image directly from ROM, instead of shadow region.
This changes m0_rom_to_ram to read directly from the ROM region, rather
than copying from where .text has been copied to RAM.

Previously the second .text section would be merged with the first one,
so the M0 image would be copied to RAM during `pre_main`. However, on
newer linkers the sections are not merged together so the second .text
section did not get copied to RAM.

fixes #936
2021-10-06 18:40:34 +01:00
Michael Ossmann
7d900268de fix compiler warnings 2020-02-11 16:59:59 +00:00
Michael Ossmann
c0aed2edb7 firmware: clean up transceiver modes 2020-02-11 16:59:59 +00:00
Mike Walters
d8250c6396 Don't re-init bulk endpoints on every set_transceiver_mode call
Previously the firmware would re-initialise the bulk endpoints on
every transceiver mode change including a USB data toggle reset,
which could cause the first bulk packet (512-bytes) to be dropped
by the host if the PID no longer matched.
2020-02-10 15:46:55 +00:00
Mike Walters
4aac303480 Add option to disable HackRF UI
Fixes #608
2020-01-22 21:23:30 +00:00
Mike Walters
c6e1a5f7f7 Fix Operacake GPIO mode initialisation 2020-01-22 14:21:03 +00:00
Mike Walters
05b1650a6a Rename hackrf-ui.[ch]
Every other source file uses underscores! :(
2020-01-22 14:20:23 +00:00
Mike Walters
e76eace09d Use the M0 to collect SGPIO samples 2020-01-20 14:22:30 +00:00
Mike Walters
3e2ca4e6c3 Bring up the M0 & blink TX LED 2020-01-20 14:22:30 +00:00
Michael Ossmann
208fae7538 Merge pull request #645 from jboone/master
Sync up PortaPack UI changes.
2020-01-06 16:31:28 -07:00
Michael Ossmann
1569737109 Merge pull request #607 from dominicgs/portapack_ui_opera_cake_coexistence
Allow portapack and opera cake to coexist and still enable the PP UI
2020-01-06 16:28:58 -07:00
Jared Boone
b4d8ee678e PortaPack: Lots of clean-up
Perform PortaPack initialization separately from and earlier than UI initialization. Track if PortaPack was detected, provide (mostly useless) pointer if so. Put "weak" declarations into respective headers. Moving #includes around.
2019-03-20 10:46:46 -07:00
Dominic Spill
e27038a098 Merge branch 'master' into cpld_sram_load 2019-03-04 12:40:14 +00:00
Dominic Spill
a4c1ab65c6 Merge pull request #602 from jboone/ui_restructuring
PortaPack and rad1o Ui restructuring, take 2
2019-03-03 22:27:57 +00:00
Jared Boone
5b5d82be56 Build rad1o UI wrapper to patch the portapack one
Also, fix building of blinky.
2019-03-02 21:12:31 -08:00
Jared Boone
c32d57158a PortaPack: Remove weak UI functions, detect and return UI function table.
TODO: Side effect was that now blinky has a lot of unreasonable dependencies.
TODO: rad1o breakage is likely...
2019-03-02 14:23:06 -08:00
Jared Boone
75adda314e LED: Refactor halt function from CPLD update to core API.
Also call if CPLD load fails.
2019-03-02 14:19:21 -08:00
Jared Boone
afb55e18dd CPLD: Load bitstream to SRAM at start-up. 2019-03-02 14:19:21 -08:00
Dominic Spill
e12866f81e Remove PLL1 low speed settings (it's out of spec) 2019-02-11 16:38:07 -07:00
Dominic Spill
b701579906 Allow portapack and opera cake to coexist and still enable the PP UI
The side effect of this is to disable GPIO mode for OC, but I2C still
works
Using both addons together is super unlikely
2019-02-01 12:04:40 -07:00
Jared Boone
fa2a9acd1a USB: initial CPLD checksum API support. 2019-01-31 21:19:21 +00:00
Jared Boone
7b86403ce8 PortaPack: If hardware not detected, try to init OperaCake. 2019-01-31 09:24:59 +00:00
Jared Boone
909066cdf8 PortaPack: Replace OperaCake handlers, they were tripping up host tools. Skip operacake_init if PortaPack compiled in, letting operacake_boards be all zero. Should be safe, right? 2019-01-14 20:42:39 -08:00
Jared Boone
e87b3f4fea PortaPack: Address some unused variable/function warnings. 2019-01-09 15:30:24 -08:00
Jared Boone
5e88bb8565 USB: Set Opera Cake USB handlers to null unless hardware is detected. 2019-01-07 15:30:32 -08:00
Jared Boone
0666dc961d USB: Bring in constants from host source code.
TODO: Deduplicate this when I'm not feeling so lazy.
2019-01-07 15:29:51 -08:00
Jared Boone
c7d761089f USB: Make vendor request handler table read/write (not const). 2019-01-07 15:29:18 -08:00
Jared Boone
0b46745aed OperaCake code conflicts with PortaPack code, make compile-time conditional. 2018-12-27 15:14:52 -08:00
Dominic Spill
82656b8f14 HackRF Opera Cake - GPIO test mode 2018-11-09 22:10:16 -07:00
Dominic Spill
bde5ca9f58 DFU serial number - avoid reading serial from flash chip
Set a DFU mode specific serial number
2018-03-27 18:08:49 -06:00
Dominic Spill
5f560d6ad3 Merge branch 'mossmann-master' into flash-investigation 2017-12-05 16:18:19 -07:00