Adjust tuning API to use a single 64-bit integer for frequency in Hz, since the Cortex-M4F has good support for uint64_t.
This commit is contained in:
@ -40,13 +40,13 @@
|
|||||||
|
|
||||||
static uint32_t max2837_freq_nominal_hz=2560000000;
|
static uint32_t max2837_freq_nominal_hz=2560000000;
|
||||||
|
|
||||||
uint32_t freq_mhz_cache=100, freq_hz_cache=0;
|
uint64_t freq_cache = 100000000;
|
||||||
/*
|
/*
|
||||||
* Set freq/tuning between 5MHz to 6800 MHz (less than 16bits really used)
|
* Set freq/tuning between 5MHz to 6800 MHz (less than 16bits really used)
|
||||||
* hz between 0 to 999999 Hz (not checked)
|
* hz between 0 to 999999 Hz (not checked)
|
||||||
* return false on error or true if success.
|
* return false on error or true if success.
|
||||||
*/
|
*/
|
||||||
bool set_freq(uint32_t freq_mhz, uint32_t freq_hz)
|
bool set_freq(const uint64_t freq)
|
||||||
{
|
{
|
||||||
bool success;
|
bool success;
|
||||||
uint32_t RFFC5071_freq_mhz;
|
uint32_t RFFC5071_freq_mhz;
|
||||||
@ -54,6 +54,9 @@ bool set_freq(uint32_t freq_mhz, uint32_t freq_hz)
|
|||||||
uint32_t real_RFFC5071_freq_hz;
|
uint32_t real_RFFC5071_freq_hz;
|
||||||
uint32_t tmp_hz;
|
uint32_t tmp_hz;
|
||||||
|
|
||||||
|
const uint32_t freq_mhz = freq / 1000000;
|
||||||
|
const uint32_t freq_hz = freq % 1000000;
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
|
|
||||||
const max2837_mode_t prior_max2837_mode = max2837_mode();
|
const max2837_mode_t prior_max2837_mode = max2837_mode();
|
||||||
@ -107,8 +110,7 @@ bool set_freq(uint32_t freq_mhz, uint32_t freq_hz)
|
|||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
max2837_set_mode(prior_max2837_mode);
|
max2837_set_mode(prior_max2837_mode);
|
||||||
freq_mhz_cache = freq_mhz;
|
freq_cache = freq;
|
||||||
freq_hz_cache = freq_hz;
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +118,7 @@ bool set_freq_if(const uint32_t freq_if_hz) {
|
|||||||
bool success = false;
|
bool success = false;
|
||||||
if( (freq_if_hz >= MIN_BYPASS_FREQ_MHZ) && (freq_if_hz <= MAX_BYPASS_FREQ_MHZ) ) {
|
if( (freq_if_hz >= MIN_BYPASS_FREQ_MHZ) && (freq_if_hz <= MAX_BYPASS_FREQ_MHZ) ) {
|
||||||
max2837_freq_nominal_hz = freq_if_hz;
|
max2837_freq_nominal_hz = freq_if_hz;
|
||||||
success = set_freq(freq_mhz_cache, freq_hz_cache);
|
success = set_freq(freq_cache);
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
bool set_freq(uint32_t freq_mhz, uint32_t freq_hz);
|
bool set_freq(const uint64_t freq);
|
||||||
bool set_freq_if(const uint32_t freq_if_hz);
|
bool set_freq_if(const uint32_t freq_if_hz);
|
||||||
|
|
||||||
#endif/*__TUNING_H__*/
|
#endif/*__TUNING_H__*/
|
||||||
|
@ -75,7 +75,8 @@ usb_request_status_t usb_vendor_request_set_freq(
|
|||||||
return USB_REQUEST_STATUS_OK;
|
return USB_REQUEST_STATUS_OK;
|
||||||
} else if (stage == USB_TRANSFER_STAGE_DATA)
|
} else if (stage == USB_TRANSFER_STAGE_DATA)
|
||||||
{
|
{
|
||||||
if( set_freq(set_freq_params.freq_mhz, set_freq_params.freq_hz) )
|
const uint64_t freq = set_freq_params.freq_mhz * 1000000 + set_freq_params.freq_hz;
|
||||||
|
if( set_freq(freq) )
|
||||||
{
|
{
|
||||||
usb_transfer_schedule_ack(endpoint->in);
|
usb_transfer_schedule_ack(endpoint->in);
|
||||||
return USB_REQUEST_STATUS_OK;
|
return USB_REQUEST_STATUS_OK;
|
||||||
|
Reference in New Issue
Block a user