Rename scan to sweep

This commit is contained in:
Dominic Spill
2016-07-27 07:24:59 +01:00
committed by Mike Walters
parent 8c08d99879
commit 57e0924e0d
6 changed files with 31 additions and 31 deletions

View File

@ -42,7 +42,7 @@ set(SRC_M4
usb_api_register.c usb_api_register.c
usb_api_spiflash.c usb_api_spiflash.c
usb_api_transceiver.c usb_api_transceiver.c
usb_api_scan.c usb_api_sweep.c
"${PATH_HACKRF_FIRMWARE_COMMON}/usb_queue.c" "${PATH_HACKRF_FIRMWARE_COMMON}/usb_queue.c"
"${PATH_HACKRF_FIRMWARE_COMMON}/fault_handler.c" "${PATH_HACKRF_FIRMWARE_COMMON}/fault_handler.c"
"${PATH_HACKRF_FIRMWARE_COMMON}/cpld_jtag.c" "${PATH_HACKRF_FIRMWARE_COMMON}/cpld_jtag.c"

View File

@ -40,7 +40,7 @@
#include "usb_api_cpld.h" #include "usb_api_cpld.h"
#include "usb_api_register.h" #include "usb_api_register.h"
#include "usb_api_spiflash.h" #include "usb_api_spiflash.h"
#include "usb_api_scan.h" #include "usb_api_sweep.h"
#include "usb_api_transceiver.h" #include "usb_api_transceiver.h"
#include "usb_bulk_buffer.h" #include "usb_bulk_buffer.h"
@ -76,7 +76,7 @@ static const usb_request_handler_fn vendor_request_handler[] = {
#endif #endif
usb_vendor_request_set_freq_explicit, usb_vendor_request_set_freq_explicit,
usb_vendor_request_read_wcid, // USB_WCID_VENDOR_REQ usb_vendor_request_read_wcid, // USB_WCID_VENDOR_REQ
usb_vendor_request_init_scan, usb_vendor_request_init_sweep,
}; };
static const uint32_t vendor_request_handler_count = static const uint32_t vendor_request_handler_count =
@ -182,9 +182,9 @@ int main(void) {
if (start_cpld_update) if (start_cpld_update)
cpld_update(); cpld_update();
// Check whether we need to initiate scan mode // Check whether we need to initiate sweep mode
if (start_scan_mode) if (start_sweep_mode)
scan_mode(); sweep_mode();
// Set up IN transfer of buffer 0. // Set up IN transfer of buffer 0.
if ( usb_bulk_buffer_offset >= 16384 if ( usb_bulk_buffer_offset >= 16384

View File

@ -19,7 +19,7 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#include "usb_api_scan.h" #include "usb_api_sweep.h"
#include "usb_queue.h" #include "usb_queue.h"
#include <stddef.h> #include <stddef.h>
#include <hackrf_core.h> #include <hackrf_core.h>
@ -34,39 +34,39 @@
#define MIN_FREQ 1 #define MIN_FREQ 1
#define MAX_FREQ 6000 #define MAX_FREQ 6000
volatile bool start_scan_mode = false; volatile bool start_sweep_mode = false;
static uint64_t scan_freq; static uint64_t sweep_freq;
struct init_scan_params { struct init_sweep_params {
uint16_t min_freq_mhz; uint16_t min_freq_mhz;
uint16_t max_freq_mhz; uint16_t max_freq_mhz;
uint16_t step_freq_mhz; uint16_t step_freq_mhz;
}; };
struct init_scan_params scan_params; struct init_sweep_params sweep_params;
usb_request_status_t usb_vendor_request_init_scan( usb_request_status_t usb_vendor_request_init_sweep(
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage) usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
{ {
if ((stage == USB_TRANSFER_STAGE_SETUP) && if ((stage == USB_TRANSFER_STAGE_SETUP) &&
(endpoint->setup.length == 6)) { (endpoint->setup.length == 6)) {
usb_transfer_schedule_block(endpoint->out, &scan_params, usb_transfer_schedule_block(endpoint->out, &sweep_params,
sizeof(struct init_scan_params), sizeof(struct init_sweep_params),
NULL, NULL); NULL, NULL);
} else if (stage == USB_TRANSFER_STAGE_DATA) { } else if (stage == USB_TRANSFER_STAGE_DATA) {
/* Limit to min/max frequency without warning (possible FIXME) */ /* Limit to min/max frequency without warning (possible FIXME) */
scan_params.min_freq_mhz = MAX(MIN_FREQ, scan_params.min_freq_mhz); sweep_params.min_freq_mhz = MAX(MIN_FREQ, sweep_params.min_freq_mhz);
scan_params.max_freq_mhz = MIN(MAX_FREQ, scan_params.max_freq_mhz); sweep_params.max_freq_mhz = MIN(MAX_FREQ, sweep_params.max_freq_mhz);
scan_freq = scan_params.min_freq_mhz; sweep_freq = sweep_params.min_freq_mhz;
set_freq(scan_freq*FREQ_GRANULARITY); set_freq(sweep_freq*FREQ_GRANULARITY);
start_scan_mode = true; start_sweep_mode = true;
usb_transfer_schedule_ack(endpoint->in); usb_transfer_schedule_ack(endpoint->in);
} }
return USB_REQUEST_STATUS_OK; return USB_REQUEST_STATUS_OK;
} }
void scan_mode(void) { void sweep_mode(void) {
unsigned int blocks_queued = 0; unsigned int blocks_queued = 0;
unsigned int phase = 0; unsigned int phase = 0;
@ -92,7 +92,7 @@ void scan_mode(void) {
if (transfer) { if (transfer) {
*(uint16_t*)buffer = 0x7F7F; *(uint16_t*)buffer = 0x7F7F;
*(uint16_t*)(buffer+2) = scan_freq; *(uint16_t*)(buffer+2) = sweep_freq;
usb_transfer_schedule_block( usb_transfer_schedule_block(
&usb_endpoint_bulk_in, &usb_endpoint_bulk_in,
buffer, buffer,
@ -103,11 +103,11 @@ void scan_mode(void) {
} }
if (blocks_queued > 2) { if (blocks_queued > 2) {
scan_freq += scan_params.step_freq_mhz; sweep_freq += sweep_params.step_freq_mhz;
if (scan_freq > scan_params.max_freq_mhz) { if (sweep_freq > sweep_params.max_freq_mhz) {
scan_freq = scan_params.min_freq_mhz; sweep_freq = sweep_params.min_freq_mhz;
} }
set_freq(scan_freq*FREQ_GRANULARITY); set_freq(sweep_freq*FREQ_GRANULARITY);
blocks_queued = 0; blocks_queued = 0;
} }
} }

View File

@ -26,11 +26,11 @@
#include <usb_type.h> #include <usb_type.h>
#include <usb_request.h> #include <usb_request.h>
extern volatile bool start_scan_mode; extern volatile bool start_sweep_mode;
usb_request_status_t usb_vendor_request_init_scan( usb_request_status_t usb_vendor_request_init_sweep(
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage); usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
void scan_mode(void); void sweep_mode(void);
#endif /* __USB_API_SPCAN_H__ */ #endif /* __USB_API_SPCAN_H__ */

View File

@ -50,8 +50,8 @@ install(TARGETS hackrf_cpldjtag RUNTIME DESTINATION ${INSTALL_DEFAULT_BINDIR})
add_executable(hackrf_info hackrf_info.c) add_executable(hackrf_info hackrf_info.c)
install(TARGETS hackrf_info RUNTIME DESTINATION ${INSTALL_DEFAULT_BINDIR}) install(TARGETS hackrf_info RUNTIME DESTINATION ${INSTALL_DEFAULT_BINDIR})
add_executable(hackrf_scan hackrf_scan.c) add_executable(hackrf_sweep hackrf_sweep.c)
install(TARGETS hackrf_scan RUNTIME DESTINATION ${INSTALL_DEFAULT_BINDIR}) install(TARGETS hackrf_sweep RUNTIME DESTINATION ${INSTALL_DEFAULT_BINDIR})
if(NOT libhackrf_SOURCE_DIR) if(NOT libhackrf_SOURCE_DIR)
include_directories(${LIBHACKRF_INCLUDE_DIR}) include_directories(${LIBHACKRF_INCLUDE_DIR})
@ -72,4 +72,4 @@ target_link_libraries(hackrf_rffc5071 ${TOOLS_LINK_LIBS})
target_link_libraries(hackrf_spiflash ${TOOLS_LINK_LIBS}) target_link_libraries(hackrf_spiflash ${TOOLS_LINK_LIBS})
target_link_libraries(hackrf_cpldjtag ${TOOLS_LINK_LIBS}) target_link_libraries(hackrf_cpldjtag ${TOOLS_LINK_LIBS})
target_link_libraries(hackrf_info ${TOOLS_LINK_LIBS}) target_link_libraries(hackrf_info ${TOOLS_LINK_LIBS})
target_link_libraries(hackrf_scan ${TOOLS_LINK_LIBS}) target_link_libraries(hackrf_sweep ${TOOLS_LINK_LIBS})