Use vendor request to start scan mode
This commit is contained in:

committed by
Mike Walters

parent
9f2d6cdbea
commit
2e17b7e884
@ -42,6 +42,7 @@ set(SRC_M4
|
||||
usb_api_register.c
|
||||
usb_api_spiflash.c
|
||||
usb_api_transceiver.c
|
||||
usb_api_scan.c
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/usb_queue.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/fault_handler.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/cpld_jtag.c"
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "usb_api_cpld.h"
|
||||
#include "usb_api_register.h"
|
||||
#include "usb_api_spiflash.h"
|
||||
#include "usb_api_scan.h"
|
||||
|
||||
#include "usb_api_transceiver.h"
|
||||
#include "sgpio_isr.h"
|
||||
@ -142,6 +143,7 @@ static const usb_request_handler_fn vendor_request_handler[] = {
|
||||
#endif
|
||||
usb_vendor_request_set_freq_explicit,
|
||||
usb_vendor_request_read_wcid, // USB_WCID_VENDOR_REQ
|
||||
usb_vendor_request_init_scan,
|
||||
};
|
||||
|
||||
static const uint32_t vendor_request_handler_count =
|
||||
@ -241,13 +243,8 @@ int main(void) {
|
||||
rf_path_init(&rf_path);
|
||||
|
||||
unsigned int phase = 0;
|
||||
|
||||
unsigned int blocks_queued = 0;
|
||||
const uint64_t scan_freq_min = 100000000;
|
||||
const uint64_t scan_freq_max = 6000000000;
|
||||
const uint64_t scan_freq_step = 20000000;
|
||||
uint64_t scan_freq = scan_freq_min;
|
||||
set_freq(scan_freq);
|
||||
|
||||
while(true) {
|
||||
// Check whether we need to initiate a CPLD update
|
||||
if (start_cpld_update)
|
||||
@ -286,11 +283,7 @@ int main(void) {
|
||||
}
|
||||
|
||||
if (blocks_queued > 2) {
|
||||
scan_freq += scan_freq_step;
|
||||
if (scan_freq > scan_freq_max) {
|
||||
scan_freq = scan_freq_min;
|
||||
}
|
||||
set_freq(scan_freq);
|
||||
scan_callback();
|
||||
blocks_queued = 0;
|
||||
}
|
||||
}
|
||||
|
53
firmware/hackrf_usb/usb_api_scan.c
Normal file
53
firmware/hackrf_usb/usb_api_scan.c
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2016 Mike Walters, Dominic Spill
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "usb_api_scan.h"
|
||||
#include "usb_queue.h"
|
||||
#include <stddef.h>
|
||||
//#include <hackrf_core.h>
|
||||
#include "tuning.h"
|
||||
|
||||
volatile bool scan_mode = false;
|
||||
static uint64_t scan_freq;
|
||||
static uint64_t scan_freq_min;
|
||||
static uint64_t scan_freq_max;
|
||||
static uint64_t scan_freq_step;
|
||||
|
||||
usb_request_status_t usb_vendor_request_init_scan(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
// DGS set scan frequencies here
|
||||
scan_freq = scan_freq_min;
|
||||
set_freq(scan_freq);
|
||||
scan_mode = true;
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
|
||||
void scan_callback(void) {
|
||||
scan_freq += scan_freq_step;
|
||||
if (scan_freq > scan_freq_max) {
|
||||
scan_freq = scan_freq_min;
|
||||
}
|
||||
set_freq(scan_freq);
|
||||
}
|
36
firmware/hackrf_usb/usb_api_scan.h
Normal file
36
firmware/hackrf_usb/usb_api_scan.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2016 Mike Walters, Dominic Spill
|
||||
*
|
||||
* 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 __USB_API_SCAN_H__
|
||||
#define __USB_API_SCAN_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <usb_type.h>
|
||||
#include <usb_request.h>
|
||||
|
||||
extern volatile bool scan_mode;
|
||||
|
||||
usb_request_status_t usb_vendor_request_init_scan(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
|
||||
void scan_callback(void);
|
||||
|
||||
#endif /* __USB_API_SPCAN_H__ */
|
Reference in New Issue
Block a user