Skip to content

Commit

Permalink
Merge branch 'mossmann-master' into firmware_cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicgs committed Feb 22, 2017
2 parents 0a48dcc + c4d7d30 commit e7f890e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
8 changes: 8 additions & 0 deletions firmware/common/hackrf_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ void cpu_clock_init(void)
CGU_BASE_SSP1_CLK = CGU_BASE_SSP1_CLK_AUTOBLOCK(1)
| CGU_BASE_SSP1_CLK_CLK_SEL(CGU_SRC_PLL1);

#if (defined JAWBREAKER || defined HACKRF_ONE)
/* Disable unused clocks */
/* Start with PLLs */
CGU_PLL0AUDIO_CTRL = CGU_PLL0AUDIO_CTRL_PD(1);
Expand Down Expand Up @@ -665,6 +666,13 @@ void cpu_clock_init(void)
// CCU2_CLK_APB2_USART3_CFG = 0;
// CCU2_CLK_APLL_CFG = 0;
// CCU2_CLK_SDIO_CFG = 0;
#endif

#ifdef RAD1O
/* 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);
#endif
}


Expand Down
19 changes: 14 additions & 5 deletions host/hackrf-tools/src/hackrf_sweep.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ int gettimeofday(struct timeval *tv, void* ignored) {
#define TUNE_STEP (DEFAULT_SAMPLE_RATE_HZ / FREQ_ONE_MHZ)
#define OFFSET 7500000

#define DEFAULT_SAMPLE_COUNT 0x2000
#define BLOCKS_PER_TRANSFER 16
#define THROWAWAY_BLOCKS 2

#if defined _WIN32
#define sleep(a) Sleep( (a*1000) )
#endif

uint32_t num_samples = SAMPLES_PER_BLOCK;
int num_ranges = 0;
uint16_t frequencies[MAX_SWEEP_RANGES*2];

Expand Down Expand Up @@ -202,11 +203,13 @@ int rx_callback(hackrf_transfer* transfer) {
int i, j;
struct tm *fft_time;
char time_str[50];
struct timeval usb_transfer_time;

if(NULL == fd) {
return -1;
}

gettimeofday(&usb_transfer_time, NULL);
byte_count += transfer->valid_length;
buf = (int8_t*) transfer->buffer;
for(j=0; j<BLOCKS_PER_TRANSFER; j++) {
Expand All @@ -224,7 +227,14 @@ int rx_callback(hackrf_transfer* transfer) {
do_exit = true;
}
sweep_started = true;
gettimeofday(&time_stamp, NULL);
time_stamp = usb_transfer_time;
time_stamp.tv_usec +=
(uint64_t)(num_samples + THROWAWAY_BLOCKS * SAMPLES_PER_BLOCK)
* j * FREQ_ONE_MHZ / DEFAULT_SAMPLE_RATE_HZ;
if(999999 < time_stamp.tv_usec) {
time_stamp.tv_usec = time_stamp.tv_usec % 1000000;
time_stamp.tv_sec += time_stamp.tv_usec / 1000000;
}
}
if(do_exit) {
return 0;
Expand Down Expand Up @@ -270,7 +280,7 @@ int rx_callback(hackrf_transfer* transfer) {
strftime(time_str, 50, "%Y-%m-%d, %H:%M:%S", fft_time);
fprintf(fd, "%s.%06ld, %" PRIu64 ", %" PRIu64 ", %.2f, %u",
time_str,
time_stamp.tv_usec,
(long int)time_stamp.tv_usec,
(uint64_t)(frequency),
(uint64_t)(frequency+DEFAULT_SAMPLE_RATE_HZ/4),
fft_bin_width,
Expand All @@ -281,7 +291,7 @@ int rx_callback(hackrf_transfer* transfer) {
fprintf(fd, "\n");
fprintf(fd, "%s.%06ld, %" PRIu64 ", %" PRIu64 ", %.2f, %u",
time_str,
time_stamp.tv_usec,
(long int)time_stamp.tv_usec,
(uint64_t)(frequency+(DEFAULT_SAMPLE_RATE_HZ/2)),
(uint64_t)(frequency+((DEFAULT_SAMPLE_RATE_HZ*3)/4)),
fft_bin_width,
Expand Down Expand Up @@ -341,7 +351,6 @@ int main(int argc, char** argv) {
struct timeval t_end;
float time_diff;
unsigned int lna_gain=16, vga_gain=20;
uint32_t num_samples = DEFAULT_SAMPLE_COUNT;
int step_count;
uint32_t freq_min = 0;
uint32_t freq_max = 6000;
Expand Down

0 comments on commit e7f890e

Please sign in to comment.