Add braces to all control statements without them.
This commit is contained in:
@ -296,8 +296,9 @@ void delay(uint32_t duration)
|
|||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
for (i = 0; i < duration; i++)
|
for (i = 0; i < duration; i++) {
|
||||||
__asm__("nop");
|
__asm__("nop");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void delay_us_at_mhz(uint32_t us, uint32_t mhz)
|
void delay_us_at_mhz(uint32_t us, uint32_t mhz)
|
||||||
@ -317,20 +318,23 @@ static uint32_t gcd(uint32_t u, uint32_t v)
|
|||||||
{
|
{
|
||||||
int s;
|
int s;
|
||||||
|
|
||||||
if (!u || !v)
|
if (!u || !v) {
|
||||||
return u | v;
|
return u | v;
|
||||||
|
}
|
||||||
|
|
||||||
for (s = 0; !((u | v) & 1); s++) {
|
for (s = 0; !((u | v) & 1); s++) {
|
||||||
u >>= 1;
|
u >>= 1;
|
||||||
v >>= 1;
|
v >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!(u & 1))
|
while (!(u & 1)) {
|
||||||
u >>= 1;
|
u >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
while (!(v & 1))
|
while (!(v & 1)) {
|
||||||
v >>= 1;
|
v >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (u > v) {
|
if (u > v) {
|
||||||
uint32_t t;
|
uint32_t t;
|
||||||
@ -391,10 +395,11 @@ bool sample_rate_frac_set(uint32_t rate_num, uint32_t rate_denom)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Can we enable integer mode ? */
|
/* Can we enable integer mode ? */
|
||||||
if (a & 0x1 || b)
|
if (a & 0x1 || b) {
|
||||||
si5351c_set_int_mode(&clock_gen, 0, 0);
|
si5351c_set_int_mode(&clock_gen, 0, 0);
|
||||||
else
|
} else {
|
||||||
si5351c_set_int_mode(&clock_gen, 0, 1);
|
si5351c_set_int_mode(&clock_gen, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Final MS values */
|
/* Final MS values */
|
||||||
MSx_P1 = 128 * a + (128 * b / c) - 512;
|
MSx_P1 = 128 * a + (128 * b / c) - 512;
|
||||||
@ -485,8 +490,9 @@ bool baseband_filter_bandwidth_set(const uint32_t bandwidth_hz)
|
|||||||
{
|
{
|
||||||
uint32_t bandwidth_hz_real = max2837_set_lpf_bandwidth(&max2837, bandwidth_hz);
|
uint32_t bandwidth_hz_real = max2837_set_lpf_bandwidth(&max2837, bandwidth_hz);
|
||||||
|
|
||||||
if (bandwidth_hz_real)
|
if (bandwidth_hz_real) {
|
||||||
hackrf_ui()->set_filter_bw(bandwidth_hz_real);
|
hackrf_ui()->set_filter_bw(bandwidth_hz_real);
|
||||||
|
}
|
||||||
|
|
||||||
return bandwidth_hz_real != 0;
|
return bandwidth_hz_real != 0;
|
||||||
}
|
}
|
||||||
|
@ -329,8 +329,9 @@ bool max2837_set_lna_gain(max2837_driver_t* const drv, const uint32_t gain_db) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool max2837_set_vga_gain(max2837_driver_t* const drv, const uint32_t gain_db) {
|
bool max2837_set_vga_gain(max2837_driver_t* const drv, const uint32_t gain_db) {
|
||||||
if( (gain_db & 0x1) || gain_db > 62)/* 0b11111*2 */
|
if( (gain_db & 0x1) || gain_db > 62) {/* 0b11111*2 */
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
set_MAX2837_VGA(drv, 31-(gain_db >> 1) );
|
set_MAX2837_VGA(drv, 31-(gain_db >> 1) );
|
||||||
max2837_reg_commit(drv, 5);
|
max2837_reg_commit(drv, 5);
|
||||||
|
@ -147,8 +147,9 @@ uint8_t operacake_init(bool allow_gpio)
|
|||||||
|
|
||||||
bool operacake_is_board_present(uint8_t address)
|
bool operacake_is_board_present(uint8_t address)
|
||||||
{
|
{
|
||||||
if (address >= OPERACAKE_MAX_BOARDS)
|
if (address >= OPERACAKE_MAX_BOARDS) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return operacake_boards[address].present;
|
return operacake_boards[address].present;
|
||||||
}
|
}
|
||||||
@ -160,8 +161,9 @@ void operacake_get_boards(uint8_t* addresses)
|
|||||||
addresses[i] = OPERACAKE_ADDRESS_INVALID;
|
addresses[i] = OPERACAKE_ADDRESS_INVALID;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < OPERACAKE_MAX_BOARDS; i++) {
|
for (int i = 0; i < OPERACAKE_MAX_BOARDS; i++) {
|
||||||
if (operacake_is_board_present(i))
|
if (operacake_is_board_present(i)) {
|
||||||
addresses[count++] = i;
|
addresses[count++] = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,8 +223,9 @@ uint8_t operacake_activate_ports(uint8_t address, uint8_t PA, uint8_t PB)
|
|||||||
|
|
||||||
void operacake_set_mode(uint8_t address, uint8_t mode)
|
void operacake_set_mode(uint8_t address, uint8_t mode)
|
||||||
{
|
{
|
||||||
if (address >= OPERACAKE_MAX_BOARDS)
|
if (address >= OPERACAKE_MAX_BOARDS) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
operacake_boards[address].mode = mode;
|
operacake_boards[address].mode = mode;
|
||||||
current_range = INVALID_RANGE;
|
current_range = INVALID_RANGE;
|
||||||
@ -253,16 +256,18 @@ void operacake_set_mode(uint8_t address, uint8_t mode)
|
|||||||
// If any boards are in MODE_TIME, enable the sctimer events.
|
// If any boards are in MODE_TIME, enable the sctimer events.
|
||||||
bool enable_sctimer = false;
|
bool enable_sctimer = false;
|
||||||
for (int i = 0; i < OPERACAKE_MAX_BOARDS; i++) {
|
for (int i = 0; i < OPERACAKE_MAX_BOARDS; i++) {
|
||||||
if (operacake_boards[i].mode == MODE_TIME)
|
if (operacake_boards[i].mode == MODE_TIME) {
|
||||||
enable_sctimer = true;
|
enable_sctimer = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
operacake_sctimer_enable(enable_sctimer);
|
operacake_sctimer_enable(enable_sctimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t operacake_get_mode(uint8_t address)
|
uint8_t operacake_get_mode(uint8_t address)
|
||||||
{
|
{
|
||||||
if (address >= OPERACAKE_MAX_BOARDS)
|
if (address >= OPERACAKE_MAX_BOARDS) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return operacake_boards[address].mode;
|
return operacake_boards[address].mode;
|
||||||
}
|
}
|
||||||
@ -372,8 +377,9 @@ uint16_t gpio_test(uint8_t address)
|
|||||||
{
|
{
|
||||||
uint8_t i, reg, bit_mask, gpio_mask = 0x1F;
|
uint8_t i, reg, bit_mask, gpio_mask = 0x1F;
|
||||||
uint16_t result = 0;
|
uint16_t result = 0;
|
||||||
if (!allow_gpio_mode)
|
if (!allow_gpio_mode) {
|
||||||
return 0xFFFF;
|
return 0xFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
scu_pinmux(SCU_PINMUX_GPIO3_8, SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
|
scu_pinmux(SCU_PINMUX_GPIO3_8, SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
|
||||||
scu_pinmux(SCU_PINMUX_GPIO3_12, SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
|
scu_pinmux(SCU_PINMUX_GPIO3_12, SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
|
||||||
|
@ -148,8 +148,9 @@ void operacake_sctimer_set_dwell_times(struct operacake_dwell_times* times, int
|
|||||||
|
|
||||||
// Wrapping from SCT_LIMIT seems to add an extra cycle,
|
// Wrapping from SCT_LIMIT seems to add an extra cycle,
|
||||||
// so we reduce the counter value for the first event.
|
// so we reduce the counter value for the first event.
|
||||||
if (i == 0)
|
if (i == 0) {
|
||||||
counter -= 1;
|
counter -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
SCT_MATCHn(i) = counter;
|
SCT_MATCHn(i) = counter;
|
||||||
SCT_MATCHRELn(i) = counter;
|
SCT_MATCHRELn(i) = counter;
|
||||||
|
@ -150,10 +150,12 @@ static void switchctrl_set_hackrf_one(rf_path_t* const rf_path, uint8_t ctrl)
|
|||||||
* used to explicitly turn off power to the amplifiers while AMP_BYPASS
|
* used to explicitly turn off power to the amplifiers while AMP_BYPASS
|
||||||
* is unset:
|
* is unset:
|
||||||
*/
|
*/
|
||||||
if (ctrl & SWITCHCTRL_NO_TX_AMP_PWR)
|
if (ctrl & SWITCHCTRL_NO_TX_AMP_PWR) {
|
||||||
gpio_set(rf_path->gpio_no_tx_amp_pwr);
|
gpio_set(rf_path->gpio_no_tx_amp_pwr);
|
||||||
if (ctrl & SWITCHCTRL_NO_RX_AMP_PWR)
|
}
|
||||||
|
if (ctrl & SWITCHCTRL_NO_RX_AMP_PWR) {
|
||||||
gpio_set(rf_path->gpio_no_rx_amp_pwr);
|
gpio_set(rf_path->gpio_no_rx_amp_pwr);
|
||||||
|
}
|
||||||
|
|
||||||
if (ctrl & SWITCHCTRL_ANT_PWR) {
|
if (ctrl & SWITCHCTRL_ANT_PWR) {
|
||||||
mixer_set_gpo(&mixer, 0x00); /* turn on antenna power by clearing GPO1 */
|
mixer_set_gpo(&mixer, 0x00); /* turn on antenna power by clearing GPO1 */
|
||||||
|
@ -141,8 +141,9 @@ static void rffc5071_spi_write(rffc5071_driver_t* const drv, uint8_t r, uint16_t
|
|||||||
uint16_t rffc5071_reg_read(rffc5071_driver_t* const drv, uint8_t r)
|
uint16_t rffc5071_reg_read(rffc5071_driver_t* const drv, uint8_t r)
|
||||||
{
|
{
|
||||||
/* Readback register is not cached. */
|
/* Readback register is not cached. */
|
||||||
if (r == RFFC5071_READBACK_REG)
|
if (r == RFFC5071_READBACK_REG) {
|
||||||
return rffc5071_spi_read(drv, r);
|
return rffc5071_spi_read(drv, r);
|
||||||
|
}
|
||||||
|
|
||||||
/* Discard uncommited write when reading. This shouldn't
|
/* Discard uncommited write when reading. This shouldn't
|
||||||
* happen, and probably has not been tested. */
|
* happen, and probably has not been tested. */
|
||||||
|
@ -252,10 +252,11 @@ void si5351c_set_int_mode(
|
|||||||
data[0] = 16 + ms_number;
|
data[0] = 16 + ms_number;
|
||||||
data[1] = si5351c_read_single(drv, data[0]);
|
data[1] = si5351c_read_single(drv, data[0]);
|
||||||
|
|
||||||
if (on)
|
if (on) {
|
||||||
data[1] |= SI5351C_CLK_INT_MODE;
|
data[1] |= SI5351C_CLK_INT_MODE;
|
||||||
else
|
} else {
|
||||||
data[1] &= ~(SI5351C_CLK_INT_MODE);
|
data[1] &= ~(SI5351C_CLK_INT_MODE);
|
||||||
|
}
|
||||||
|
|
||||||
si5351c_write(drv, data, 2);
|
si5351c_write(drv, data, 2);
|
||||||
}
|
}
|
||||||
@ -279,10 +280,11 @@ void si5351c_clkout_enable(si5351c_driver_t* const drv, uint8_t enable)
|
|||||||
/* Set optput in output enable register */
|
/* Set optput in output enable register */
|
||||||
uint8_t output_enable = si5351c_read_single(drv, 3);
|
uint8_t output_enable = si5351c_read_single(drv, 3);
|
||||||
output_enable = output_enable & !SI5351C_CLK_DISABLE(3);
|
output_enable = output_enable & !SI5351C_CLK_DISABLE(3);
|
||||||
if (enable)
|
if (enable) {
|
||||||
output_enable = output_enable | SI5351C_CLK_ENABLE(3);
|
output_enable = output_enable | SI5351C_CLK_ENABLE(3);
|
||||||
else
|
} else {
|
||||||
output_enable = output_enable | SI5351C_CLK_DISABLE(3);
|
output_enable = output_enable | SI5351C_CLK_DISABLE(3);
|
||||||
|
}
|
||||||
uint8_t oe_data[] = {SI5351C_REG_OUTPUT_EN, output_enable};
|
uint8_t oe_data[] = {SI5351C_REG_OUTPUT_EN, output_enable};
|
||||||
si5351c_write(drv, oe_data, 2);
|
si5351c_write(drv, oe_data, 2);
|
||||||
|
|
||||||
@ -305,12 +307,13 @@ void si5351c_clkout_enable(si5351c_driver_t* const drv, uint8_t enable)
|
|||||||
pll = SI5351C_CLK_PLL_SRC_A;
|
pll = SI5351C_CLK_PLL_SRC_A;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (enable)
|
if (enable) {
|
||||||
clk3_ctrl = SI5351C_CLK_INT_MODE | SI5351C_CLK_PLL_SRC(pll) |
|
clk3_ctrl = SI5351C_CLK_INT_MODE | SI5351C_CLK_PLL_SRC(pll) |
|
||||||
SI5351C_CLK_SRC(SI5351C_CLK_SRC_MULTISYNTH_SELF) |
|
SI5351C_CLK_SRC(SI5351C_CLK_SRC_MULTISYNTH_SELF) |
|
||||||
SI5351C_CLK_IDRV(SI5351C_CLK_IDRV_8MA);
|
SI5351C_CLK_IDRV(SI5351C_CLK_IDRV_8MA);
|
||||||
else
|
} else {
|
||||||
clk3_ctrl = SI5351C_CLK_POWERDOWN | SI5351C_CLK_INT_MODE;
|
clk3_ctrl = SI5351C_CLK_POWERDOWN | SI5351C_CLK_INT_MODE;
|
||||||
|
}
|
||||||
uint8_t clk3_data[] = {SI5351C_REG_CLK3_CTRL, clk3_ctrl};
|
uint8_t clk3_data[] = {SI5351C_REG_CLK3_CTRL, clk3_ctrl};
|
||||||
si5351c_write(drv, clk3_data, 2);
|
si5351c_write(drv, clk3_data, 2);
|
||||||
}
|
}
|
||||||
|
@ -39,16 +39,18 @@ usb_queue_t* endpoint_queues[12] = {};
|
|||||||
static usb_queue_t* endpoint_queue(const usb_endpoint_t* const endpoint)
|
static usb_queue_t* endpoint_queue(const usb_endpoint_t* const endpoint)
|
||||||
{
|
{
|
||||||
uint32_t index = USB_ENDPOINT_INDEX(endpoint->address);
|
uint32_t index = USB_ENDPOINT_INDEX(endpoint->address);
|
||||||
if (endpoint_queues[index] == NULL)
|
if (endpoint_queues[index] == NULL) {
|
||||||
while (1) {}
|
while (1) {}
|
||||||
|
}
|
||||||
return endpoint_queues[index];
|
return endpoint_queues[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_queue_init(usb_queue_t* const queue)
|
void usb_queue_init(usb_queue_t* const queue)
|
||||||
{
|
{
|
||||||
uint32_t index = USB_ENDPOINT_INDEX(queue->endpoint->address);
|
uint32_t index = USB_ENDPOINT_INDEX(queue->endpoint->address);
|
||||||
if (endpoint_queues[index] != NULL)
|
if (endpoint_queues[index] != NULL) {
|
||||||
while (1) {}
|
while (1) {}
|
||||||
|
}
|
||||||
endpoint_queues[index] = queue;
|
endpoint_queues[index] = queue;
|
||||||
|
|
||||||
usb_transfer_t* t = queue->free_transfers;
|
usb_transfer_t* t = queue->free_transfers;
|
||||||
@ -65,8 +67,9 @@ static usb_transfer_t* allocate_transfer(usb_queue_t* const queue)
|
|||||||
{
|
{
|
||||||
bool aborted;
|
bool aborted;
|
||||||
usb_transfer_t* transfer;
|
usb_transfer_t* transfer;
|
||||||
if (queue->free_transfers == NULL)
|
if (queue->free_transfers == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
transfer = (void*) __ldrex((uint32_t*) &queue->free_transfers);
|
transfer = (void*) __ldrex((uint32_t*) &queue->free_transfers);
|
||||||
@ -99,8 +102,9 @@ static usb_transfer_t* endpoint_queue_transfer(usb_transfer_t* const transfer)
|
|||||||
transfer->next = NULL;
|
transfer->next = NULL;
|
||||||
if (queue->active != NULL) {
|
if (queue->active != NULL) {
|
||||||
usb_transfer_t* t = queue->active;
|
usb_transfer_t* t = queue->active;
|
||||||
while (t->next != NULL)
|
while (t->next != NULL) {
|
||||||
t = t->next;
|
t = t->next;
|
||||||
|
}
|
||||||
t->next = transfer;
|
t->next = transfer;
|
||||||
return t;
|
return t;
|
||||||
} else {
|
} else {
|
||||||
@ -134,8 +138,9 @@ int usb_transfer_schedule(
|
|||||||
{
|
{
|
||||||
usb_queue_t* const queue = endpoint_queue(endpoint);
|
usb_queue_t* const queue = endpoint_queue(endpoint);
|
||||||
usb_transfer_t* const transfer = allocate_transfer(queue);
|
usb_transfer_t* const transfer = allocate_transfer(queue);
|
||||||
if (transfer == NULL)
|
if (transfer == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
usb_transfer_descriptor_t* const td = &transfer->td;
|
usb_transfer_descriptor_t* const td = &transfer->td;
|
||||||
|
|
||||||
// Configure the transfer descriptor
|
// Configure the transfer descriptor
|
||||||
@ -195,8 +200,9 @@ int usb_transfer_schedule_ack(const usb_endpoint_t* const endpoint)
|
|||||||
void usb_queue_transfer_complete(usb_endpoint_t* const endpoint)
|
void usb_queue_transfer_complete(usb_endpoint_t* const endpoint)
|
||||||
{
|
{
|
||||||
usb_queue_t* const queue = endpoint_queue(endpoint);
|
usb_queue_t* const queue = endpoint_queue(endpoint);
|
||||||
if (queue == NULL)
|
if (queue == NULL) {
|
||||||
while (1) {} // Uh oh
|
while (1) {} // Uh oh
|
||||||
|
}
|
||||||
usb_transfer_t* transfer = queue->active;
|
usb_transfer_t* transfer = queue->active;
|
||||||
|
|
||||||
while (transfer != NULL) {
|
while (transfer != NULL) {
|
||||||
@ -211,8 +217,9 @@ void usb_queue_transfer_complete(usb_endpoint_t* const endpoint)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Still not finished
|
// Still not finished
|
||||||
if (status & USB_TD_DTD_TOKEN_STATUS_ACTIVE)
|
if (status & USB_TD_DTD_TOKEN_STATUS_ACTIVE) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Advance the head. We need to do this before invoking the completion
|
// Advance the head. We need to do this before invoking the completion
|
||||||
// callback as it might attempt to schedule a new transfer
|
// callback as it might attempt to schedule a new transfer
|
||||||
@ -224,8 +231,9 @@ void usb_queue_transfer_complete(usb_endpoint_t* const endpoint)
|
|||||||
(transfer->td.total_bytes & USB_TD_DTD_TOKEN_TOTAL_BYTES_MASK) >>
|
(transfer->td.total_bytes & USB_TD_DTD_TOKEN_TOTAL_BYTES_MASK) >>
|
||||||
USB_TD_DTD_TOKEN_TOTAL_BYTES_SHIFT;
|
USB_TD_DTD_TOKEN_TOTAL_BYTES_SHIFT;
|
||||||
unsigned int transferred = transfer->maximum_length - total_bytes;
|
unsigned int transferred = transfer->maximum_length - total_bytes;
|
||||||
if (transfer->completion_cb)
|
if (transfer->completion_cb) {
|
||||||
transfer->completion_cb(transfer->user_data, transferred);
|
transfer->completion_cb(transfer->user_data, transferred);
|
||||||
|
}
|
||||||
|
|
||||||
// Advance head and free transfer
|
// Advance head and free transfer
|
||||||
free_transfer(transfer);
|
free_transfer(transfer);
|
||||||
|
@ -97,8 +97,9 @@ bool usb_set_configuration(
|
|||||||
device->configuration = new_configuration;
|
device->configuration = new_configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usb_configuration_changed_cb)
|
if (usb_configuration_changed_cb) {
|
||||||
usb_configuration_changed_cb(device);
|
usb_configuration_changed_cb(device);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -146,12 +146,14 @@ static void w25q80bv_page_program(
|
|||||||
uint8_t* data)
|
uint8_t* data)
|
||||||
{
|
{
|
||||||
/* do nothing if asked to write beyond a page boundary */
|
/* do nothing if asked to write beyond a page boundary */
|
||||||
if (((addr & 0xFF) + len) > drv->page_len)
|
if (((addr & 0xFF) + len) > drv->page_len) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* do nothing if we would overflow the flash */
|
/* do nothing if we would overflow the flash */
|
||||||
if (addr > (drv->num_bytes - len))
|
if (addr > (drv->num_bytes - len)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
w25q80bv_wait_while_busy(drv);
|
w25q80bv_wait_while_busy(drv);
|
||||||
w25q80bv_write_enable(drv);
|
w25q80bv_write_enable(drv);
|
||||||
@ -184,13 +186,15 @@ void w25q80bv_program(
|
|||||||
|
|
||||||
/* do nothing if we would overflow the flash */
|
/* do nothing if we would overflow the flash */
|
||||||
if ((len > drv->num_bytes) || (addr > drv->num_bytes) ||
|
if ((len > drv->num_bytes) || (addr > drv->num_bytes) ||
|
||||||
((addr + len) > drv->num_bytes))
|
((addr + len) > drv->num_bytes)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* handle start not at page boundary */
|
/* handle start not at page boundary */
|
||||||
first_block_len = drv->page_len - (addr % drv->page_len);
|
first_block_len = drv->page_len - (addr % drv->page_len);
|
||||||
if (len < first_block_len)
|
if (len < first_block_len) {
|
||||||
first_block_len = len;
|
first_block_len = len;
|
||||||
|
}
|
||||||
if (first_block_len) {
|
if (first_block_len) {
|
||||||
w25q80bv_page_program(drv, addr, first_block_len, data);
|
w25q80bv_page_program(drv, addr, first_block_len, data);
|
||||||
addr += first_block_len;
|
addr += first_block_len;
|
||||||
@ -221,8 +225,9 @@ void w25q80bv_read(
|
|||||||
{
|
{
|
||||||
/* do nothing if we would overflow the flash */
|
/* do nothing if we would overflow the flash */
|
||||||
if ((len > drv->num_bytes) || (addr > drv->num_bytes) ||
|
if ((len > drv->num_bytes) || (addr > drv->num_bytes) ||
|
||||||
((addr + len) > drv->num_bytes))
|
((addr + len) > drv->num_bytes)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
w25q80bv_wait_while_busy(drv);
|
w25q80bv_wait_while_busy(drv);
|
||||||
|
|
||||||
|
@ -81,8 +81,9 @@ usb_request_status_t usb_vendor_request_read_partid_serialno(
|
|||||||
/* Read IAP Part Number Identification */
|
/* Read IAP Part Number Identification */
|
||||||
iap_cmd_res.cmd_param.command_code = IAP_CMD_READ_PART_ID_NO;
|
iap_cmd_res.cmd_param.command_code = IAP_CMD_READ_PART_ID_NO;
|
||||||
iap_cmd_call(&iap_cmd_res);
|
iap_cmd_call(&iap_cmd_res);
|
||||||
if (iap_cmd_res.status_res.status_ret != CMD_SUCCESS)
|
if (iap_cmd_res.status_res.status_ret != CMD_SUCCESS) {
|
||||||
return USB_REQUEST_STATUS_STALL;
|
return USB_REQUEST_STATUS_STALL;
|
||||||
|
}
|
||||||
|
|
||||||
read_partid_serialno.part_id[0] = iap_cmd_res.status_res.iap_result[0];
|
read_partid_serialno.part_id[0] = iap_cmd_res.status_res.iap_result[0];
|
||||||
read_partid_serialno.part_id[1] = iap_cmd_res.status_res.iap_result[1];
|
read_partid_serialno.part_id[1] = iap_cmd_res.status_res.iap_result[1];
|
||||||
@ -90,8 +91,9 @@ usb_request_status_t usb_vendor_request_read_partid_serialno(
|
|||||||
/* Read IAP Serial Number Identification */
|
/* Read IAP Serial Number Identification */
|
||||||
iap_cmd_res.cmd_param.command_code = IAP_CMD_READ_SERIAL_NO;
|
iap_cmd_res.cmd_param.command_code = IAP_CMD_READ_SERIAL_NO;
|
||||||
iap_cmd_call(&iap_cmd_res);
|
iap_cmd_call(&iap_cmd_res);
|
||||||
if (iap_cmd_res.status_res.status_ret != CMD_SUCCESS)
|
if (iap_cmd_res.status_res.status_ret != CMD_SUCCESS) {
|
||||||
return USB_REQUEST_STATUS_STALL;
|
return USB_REQUEST_STATUS_STALL;
|
||||||
|
}
|
||||||
|
|
||||||
read_partid_serialno.serial_no[0] = iap_cmd_res.status_res.iap_result[0];
|
read_partid_serialno.serial_no[0] = iap_cmd_res.status_res.iap_result[0];
|
||||||
read_partid_serialno.serial_no[1] = iap_cmd_res.status_res.iap_result[1];
|
read_partid_serialno.serial_no[1] = iap_cmd_res.status_res.iap_result[1];
|
||||||
|
@ -145,9 +145,11 @@ void sweep_mode(uint32_t seq)
|
|||||||
|
|
||||||
while (transceiver_request.seq == seq) {
|
while (transceiver_request.seq == seq) {
|
||||||
// Wait for M0 to finish receiving a buffer.
|
// Wait for M0 to finish receiving a buffer.
|
||||||
while (m0_state.active_mode != M0_MODE_WAIT)
|
while (m0_state.active_mode != M0_MODE_WAIT) {
|
||||||
if (transceiver_request.seq != seq)
|
if (transceiver_request.seq != seq) {
|
||||||
goto end;
|
goto end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set M0 to switch back to RX after two more buffers.
|
// Set M0 to switch back to RX after two more buffers.
|
||||||
m0_state.threshold += 0x8000;
|
m0_state.threshold += 0x8000;
|
||||||
@ -214,9 +216,11 @@ void sweep_mode(uint32_t seq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait for M0 to resume RX.
|
// Wait for M0 to resume RX.
|
||||||
while (m0_state.active_mode != M0_MODE_RX)
|
while (m0_state.active_mode != M0_MODE_RX) {
|
||||||
if (transceiver_request.seq != seq)
|
if (transceiver_request.seq != seq) {
|
||||||
goto end;
|
goto end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set M0 to switch back to WAIT after filling next buffer.
|
// Set M0 to switch back to WAIT after filling next buffer.
|
||||||
m0_state.threshold += 0x4000;
|
m0_state.threshold += 0x4000;
|
||||||
|
@ -165,8 +165,9 @@ usb_request_status_t usb_vendor_request_set_lna_gain(
|
|||||||
const uint8_t value =
|
const uint8_t value =
|
||||||
max2837_set_lna_gain(&max2837, endpoint->setup.index);
|
max2837_set_lna_gain(&max2837, endpoint->setup.index);
|
||||||
endpoint->buffer[0] = value;
|
endpoint->buffer[0] = value;
|
||||||
if (value)
|
if (value) {
|
||||||
hackrf_ui()->set_bb_lna_gain(endpoint->setup.index);
|
hackrf_ui()->set_bb_lna_gain(endpoint->setup.index);
|
||||||
|
}
|
||||||
usb_transfer_schedule_block(
|
usb_transfer_schedule_block(
|
||||||
endpoint->in,
|
endpoint->in,
|
||||||
&endpoint->buffer,
|
&endpoint->buffer,
|
||||||
@ -187,8 +188,9 @@ usb_request_status_t usb_vendor_request_set_vga_gain(
|
|||||||
const uint8_t value =
|
const uint8_t value =
|
||||||
max2837_set_vga_gain(&max2837, endpoint->setup.index);
|
max2837_set_vga_gain(&max2837, endpoint->setup.index);
|
||||||
endpoint->buffer[0] = value;
|
endpoint->buffer[0] = value;
|
||||||
if (value)
|
if (value) {
|
||||||
hackrf_ui()->set_bb_vga_gain(endpoint->setup.index);
|
hackrf_ui()->set_bb_vga_gain(endpoint->setup.index);
|
||||||
|
}
|
||||||
usb_transfer_schedule_block(
|
usb_transfer_schedule_block(
|
||||||
endpoint->in,
|
endpoint->in,
|
||||||
&endpoint->buffer,
|
&endpoint->buffer,
|
||||||
@ -209,8 +211,9 @@ usb_request_status_t usb_vendor_request_set_txvga_gain(
|
|||||||
const uint8_t value =
|
const uint8_t value =
|
||||||
max2837_set_txvga_gain(&max2837, endpoint->setup.index);
|
max2837_set_txvga_gain(&max2837, endpoint->setup.index);
|
||||||
endpoint->buffer[0] = value;
|
endpoint->buffer[0] = value;
|
||||||
if (value)
|
if (value) {
|
||||||
hackrf_ui()->set_bb_tx_vga_gain(endpoint->setup.index);
|
hackrf_ui()->set_bb_tx_vga_gain(endpoint->setup.index);
|
||||||
|
}
|
||||||
usb_transfer_schedule_block(
|
usb_transfer_schedule_block(
|
||||||
endpoint->in,
|
endpoint->in,
|
||||||
&endpoint->buffer,
|
&endpoint->buffer,
|
||||||
|
@ -111,20 +111,24 @@ void print_clk_control(uint16_t clk_ctrl)
|
|||||||
{
|
{
|
||||||
uint8_t clk_src, clk_pwr;
|
uint8_t clk_src, clk_pwr;
|
||||||
printf("\tclock control = ");
|
printf("\tclock control = ");
|
||||||
if (clk_ctrl & SI5351C_CLK_POWERDOWN)
|
if (clk_ctrl & SI5351C_CLK_POWERDOWN) {
|
||||||
printf("Down, ");
|
printf("Down, ");
|
||||||
else
|
} else {
|
||||||
printf("Up, ");
|
printf("Up, ");
|
||||||
if (clk_ctrl & SI5351C_CLK_INT_MODE)
|
}
|
||||||
|
if (clk_ctrl & SI5351C_CLK_INT_MODE) {
|
||||||
printf("Int Mode, ");
|
printf("Int Mode, ");
|
||||||
else
|
} else {
|
||||||
printf("Frac Mode, ");
|
printf("Frac Mode, ");
|
||||||
if (clk_ctrl & SI5351C_CLK_PLL_SRC)
|
}
|
||||||
|
if (clk_ctrl & SI5351C_CLK_PLL_SRC) {
|
||||||
printf("PLL src B, ");
|
printf("PLL src B, ");
|
||||||
else
|
} else {
|
||||||
printf("PLL src A, ");
|
printf("PLL src A, ");
|
||||||
if (clk_ctrl & SI5351C_CLK_INV)
|
}
|
||||||
|
if (clk_ctrl & SI5351C_CLK_INV) {
|
||||||
printf("Inverted, ");
|
printf("Inverted, ");
|
||||||
|
}
|
||||||
clk_src = (clk_ctrl >> 2) & 0x3;
|
clk_src = (clk_ctrl >> 2) & 0x3;
|
||||||
switch (clk_src) {
|
switch (clk_src) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -192,11 +196,12 @@ int si5351c_read_multisynth_config(hackrf_device* device, const uint_fast8_t ms_
|
|||||||
printf("\tp1 = %u\n", p1);
|
printf("\tp1 = %u\n", p1);
|
||||||
printf("\tp2 = %u\n", p2);
|
printf("\tp2 = %u\n", p2);
|
||||||
printf("\tp3 = %u\n", p3);
|
printf("\tp3 = %u\n", p3);
|
||||||
if (p3)
|
if (p3) {
|
||||||
printf("\tOutput (800Mhz PLL): %#.10f Mhz\n",
|
printf("\tOutput (800Mhz PLL): %#.10f Mhz\n",
|
||||||
((double) 800 /
|
((double) 800 /
|
||||||
(double) (((double) p1 * p3 + p2 + 512 * p3) / (double) (128 * p3))) /
|
(double) (((double) p1 * p3 + p2 + 512 * p3) / (double) (128 * p3))) /
|
||||||
div_lut[r_div]);
|
div_lut[r_div]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// MS6 and 7 are integer only
|
// MS6 and 7 are integer only
|
||||||
unsigned int parms;
|
unsigned int parms;
|
||||||
@ -214,9 +219,10 @@ int si5351c_read_multisynth_config(hackrf_device* device, const uint_fast8_t ms_
|
|||||||
(parameters[2] & 0x70) >> 4;
|
(parameters[2] & 0x70) >> 4;
|
||||||
parms = (ms_number == 6) ? parameters[0] : parameters[1];
|
parms = (ms_number == 6) ? parameters[0] : parameters[1];
|
||||||
printf("\tp1_int = %u\n", parms);
|
printf("\tp1_int = %u\n", parms);
|
||||||
if (parms)
|
if (parms) {
|
||||||
printf("\tOutput (800Mhz PLL): %#.10f Mhz\n",
|
printf("\tOutput (800Mhz PLL): %#.10f Mhz\n",
|
||||||
(800.0f / parms) / div_lut[r_div]);
|
(800.0f / parms) / div_lut[r_div]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("\toutput divider = %u\n", div_lut[r_div]);
|
printf("\toutput divider = %u\n", div_lut[r_div]);
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -342,9 +348,9 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (read) {
|
if (read) {
|
||||||
if (clock == CLOCK_UNDEFINED)
|
if (clock == CLOCK_UNDEFINED) {
|
||||||
si5351c_read_configuration(device);
|
si5351c_read_configuration(device);
|
||||||
else {
|
} else {
|
||||||
printf("%d\n", clock);
|
printf("%d\n", clock);
|
||||||
si5351c_read_multisynth_config(device, clock);
|
si5351c_read_multisynth_config(device, clock);
|
||||||
}
|
}
|
||||||
|
@ -175,20 +175,24 @@ void print_clk_control(uint16_t clk_ctrl)
|
|||||||
{
|
{
|
||||||
uint8_t clk_src, clk_pwr;
|
uint8_t clk_src, clk_pwr;
|
||||||
printf("\tclock control = \n");
|
printf("\tclock control = \n");
|
||||||
if (clk_ctrl & SI5351C_CLK_POWERDOWN)
|
if (clk_ctrl & SI5351C_CLK_POWERDOWN) {
|
||||||
printf("\t\tPower Down\n");
|
printf("\t\tPower Down\n");
|
||||||
else
|
} else {
|
||||||
printf("\t\tPower Up\n");
|
printf("\t\tPower Up\n");
|
||||||
if (clk_ctrl & SI5351C_CLK_INT_MODE)
|
}
|
||||||
|
if (clk_ctrl & SI5351C_CLK_INT_MODE) {
|
||||||
printf("\t\tInt Mode\n");
|
printf("\t\tInt Mode\n");
|
||||||
else
|
} else {
|
||||||
printf("\t\tFrac Mode\n");
|
printf("\t\tFrac Mode\n");
|
||||||
if (clk_ctrl & SI5351C_CLK_PLL_SRC)
|
}
|
||||||
|
if (clk_ctrl & SI5351C_CLK_PLL_SRC) {
|
||||||
printf("\t\tPLL src B\n");
|
printf("\t\tPLL src B\n");
|
||||||
else
|
} else {
|
||||||
printf("\t\tPLL src A\n");
|
printf("\t\tPLL src A\n");
|
||||||
if (clk_ctrl & SI5351C_CLK_INV)
|
}
|
||||||
|
if (clk_ctrl & SI5351C_CLK_INV) {
|
||||||
printf("\t\tInverted\n");
|
printf("\t\tInverted\n");
|
||||||
|
}
|
||||||
clk_src = (clk_ctrl >> 2) & 0x3;
|
clk_src = (clk_ctrl >> 2) & 0x3;
|
||||||
switch (clk_src) {
|
switch (clk_src) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -256,11 +260,12 @@ int si5351c_read_multisynth_config(hackrf_device* device, const uint_fast8_t ms_
|
|||||||
printf("\tp1 = %u\n", p1);
|
printf("\tp1 = %u\n", p1);
|
||||||
printf("\tp2 = %u\n", p2);
|
printf("\tp2 = %u\n", p2);
|
||||||
printf("\tp3 = %u\n", p3);
|
printf("\tp3 = %u\n", p3);
|
||||||
if (p3)
|
if (p3) {
|
||||||
printf("\tOutput (800Mhz PLL): %#.10f Mhz\n",
|
printf("\tOutput (800Mhz PLL): %#.10f Mhz\n",
|
||||||
((double) 800 /
|
((double) 800 /
|
||||||
(double) (((double) p1 * p3 + p2 + 512 * p3) / (double) (128 * p3))) /
|
(double) (((double) p1 * p3 + p2 + 512 * p3) / (double) (128 * p3))) /
|
||||||
div_lut[r_div]);
|
div_lut[r_div]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// MS6 and 7 are integer only
|
// MS6 and 7 are integer only
|
||||||
unsigned int parms;
|
unsigned int parms;
|
||||||
@ -278,9 +283,10 @@ int si5351c_read_multisynth_config(hackrf_device* device, const uint_fast8_t ms_
|
|||||||
(parameters[2] & 0x70) >> 4;
|
(parameters[2] & 0x70) >> 4;
|
||||||
parms = (ms_number == 6) ? parameters[0] : parameters[1];
|
parms = (ms_number == 6) ? parameters[0] : parameters[1];
|
||||||
printf("\tp1_int = %u\n", parms);
|
printf("\tp1_int = %u\n", parms);
|
||||||
if (parms)
|
if (parms) {
|
||||||
printf("\tOutput (800Mhz PLL): %#.10f Mhz\n",
|
printf("\tOutput (800Mhz PLL): %#.10f Mhz\n",
|
||||||
(800.0f / parms) / div_lut[r_div]);
|
(800.0f / parms) / div_lut[r_div]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("\toutput divider = %u\n", div_lut[r_div]);
|
printf("\toutput divider = %u\n", div_lut[r_div]);
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -412,20 +418,22 @@ static const char* mode_name(uint32_t mode)
|
|||||||
{
|
{
|
||||||
const char* mode_names[] = {"IDLE", "WAIT", "RX", "TX_START", "TX_RUN"};
|
const char* mode_names[] = {"IDLE", "WAIT", "RX", "TX_START", "TX_RUN"};
|
||||||
const uint32_t num_modes = sizeof(mode_names) / sizeof(mode_names[0]);
|
const uint32_t num_modes = sizeof(mode_names) / sizeof(mode_names[0]);
|
||||||
if (mode < num_modes)
|
if (mode < num_modes) {
|
||||||
return mode_names[mode];
|
return mode_names[mode];
|
||||||
else
|
} else {
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* error_name(uint32_t error)
|
static const char* error_name(uint32_t error)
|
||||||
{
|
{
|
||||||
const char* error_names[] = {"NONE", "RX_TIMEOUT", "TX_TIMEOUT"};
|
const char* error_names[] = {"NONE", "RX_TIMEOUT", "TX_TIMEOUT"};
|
||||||
const uint32_t num_errors = sizeof(error_names) / sizeof(error_names[0]);
|
const uint32_t num_errors = sizeof(error_names) / sizeof(error_names[0]);
|
||||||
if (error < num_errors)
|
if (error < num_errors) {
|
||||||
return error_names[error];
|
return error_names[error];
|
||||||
else
|
} else {
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_state(hackrf_m0_state* state)
|
static void print_state(hackrf_m0_state* state)
|
||||||
|
@ -60,14 +60,16 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < list->devicecount; i++) {
|
for (i = 0; i < list->devicecount; i++) {
|
||||||
if (i > 0)
|
if (i > 0) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
printf("Found HackRF\n");
|
printf("Found HackRF\n");
|
||||||
printf("Index: %d\n", i);
|
printf("Index: %d\n", i);
|
||||||
|
|
||||||
if (list->serial_numbers[i])
|
if (list->serial_numbers[i]) {
|
||||||
printf("Serial number: %s\n", list->serial_numbers[i]);
|
printf("Serial number: %s\n", list->serial_numbers[i]);
|
||||||
|
}
|
||||||
|
|
||||||
device = NULL;
|
device = NULL;
|
||||||
result = hackrf_device_list_open(list, i, &device);
|
result = hackrf_device_list_open(list, i, &device);
|
||||||
@ -139,8 +141,9 @@ int main(void)
|
|||||||
}
|
}
|
||||||
if (result == HACKRF_SUCCESS) {
|
if (result == HACKRF_SUCCESS) {
|
||||||
for (j = 0; j < 8; j++) {
|
for (j = 0; j < 8; j++) {
|
||||||
if (operacakes[j] == HACKRF_OPERACAKE_ADDRESS_INVALID)
|
if (operacakes[j] == HACKRF_OPERACAKE_ADDRESS_INVALID) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
printf("Opera Cake found, address: %d\n", operacakes[j]);
|
printf("Opera Cake found, address: %d\n", operacakes[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,8 +99,9 @@ int parse_port(char* str, uint8_t* port)
|
|||||||
if (str[0] == 'A' || str[0] == 'B') {
|
if (str[0] == 'A' || str[0] == 'B') {
|
||||||
// The port was specified as a side and number eg. A1 or B3
|
// The port was specified as a side and number eg. A1 or B3
|
||||||
result = parse_uint16(str + 1, &tmp_port);
|
result = parse_uint16(str + 1, &tmp_port);
|
||||||
if (result != HACKRF_SUCCESS)
|
if (result != HACKRF_SUCCESS) {
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if (tmp_port >= 5 || tmp_port <= 0) {
|
if (tmp_port >= 5 || tmp_port <= 0) {
|
||||||
fprintf(stderr, "invalid port: %s\n", str);
|
fprintf(stderr, "invalid port: %s\n", str);
|
||||||
@ -118,8 +119,9 @@ int parse_port(char* str, uint8_t* port)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result = parse_uint16(str, &tmp_port);
|
result = parse_uint16(str, &tmp_port);
|
||||||
if (result != HACKRF_SUCCESS)
|
if (result != HACKRF_SUCCESS) {
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*port = tmp_port & 0xFF;
|
*port = tmp_port & 0xFF;
|
||||||
// printf("Port: %d\n", *port);
|
// printf("Port: %d\n", *port);
|
||||||
@ -136,8 +138,9 @@ int parse_range(char* s, hackrf_operacake_freq_range* range)
|
|||||||
// Read frequency as a float here to support scientific notation (e.g: 1e6)
|
// Read frequency as a float here to support scientific notation (e.g: 1e6)
|
||||||
if (sscanf(s, "%15[^:]:%f:%f", port, &min, &max) == 3) {
|
if (sscanf(s, "%15[^:]:%f:%f", port, &min, &max) == 3) {
|
||||||
result = parse_port(port, &(range->port));
|
result = parse_port(port, &(range->port));
|
||||||
if (result != HACKRF_SUCCESS)
|
if (result != HACKRF_SUCCESS) {
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
range->freq_min = min;
|
range->freq_min = min;
|
||||||
range->freq_max = max;
|
range->freq_max = max;
|
||||||
@ -155,8 +158,9 @@ int parse_dwell(char* s, hackrf_operacake_dwell_time* dwell_time)
|
|||||||
// Read dwell as a float here to support scientific notation (e.g: 1e6)
|
// Read dwell as a float here to support scientific notation (e.g: 1e6)
|
||||||
if (sscanf(s, "%15[^:]:%f", port, &dwell) == 2) {
|
if (sscanf(s, "%15[^:]:%f", port, &dwell) == 2) {
|
||||||
result = parse_port(port, &dwell_time->port);
|
result = parse_port(port, &dwell_time->port);
|
||||||
if (result != HACKRF_SUCCESS)
|
if (result != HACKRF_SUCCESS) {
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if (dwell == 0) {
|
if (dwell == 0) {
|
||||||
fprintf(stderr, "dwell time cannot be 0\n");
|
fprintf(stderr, "dwell time cannot be 0\n");
|
||||||
@ -166,8 +170,9 @@ int parse_dwell(char* s, hackrf_operacake_dwell_time* dwell_time)
|
|||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
} else if (sscanf(s, "%15[^:]", port) == 1) {
|
} else if (sscanf(s, "%15[^:]", port) == 1) {
|
||||||
result = parse_port(port, &dwell_time->port);
|
result = parse_port(port, &dwell_time->port);
|
||||||
if (result != HACKRF_SUCCESS)
|
if (result != HACKRF_SUCCESS) {
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// This will be replaced with the default dwell time later.
|
// This will be replaced with the default dwell time later.
|
||||||
dwell_time->dwell = 0;
|
dwell_time->dwell = 0;
|
||||||
@ -385,8 +390,9 @@ int main(int argc, char** argv)
|
|||||||
operacake_count++;
|
operacake_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!operacake_count)
|
if (!operacake_count) {
|
||||||
printf("None");
|
printf("None");
|
||||||
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,8 +101,9 @@ int compatibility_check(uint8_t* data, int length, hackrf_device* device)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (match)
|
if (match) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -277,8 +278,9 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
fprintf(stderr, "Requested transfer of zero bytes.\n");
|
fprintf(stderr, "Requested transfer of zero bytes.\n");
|
||||||
if (infile != NULL)
|
if (infile != NULL) {
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
|
}
|
||||||
usage();
|
usage();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
@ -286,8 +288,9 @@ int main(int argc, char** argv)
|
|||||||
if ((length > MAX_LENGTH) || (address > MAX_LENGTH) ||
|
if ((length > MAX_LENGTH) || (address > MAX_LENGTH) ||
|
||||||
((address + length) > MAX_LENGTH)) {
|
((address + length) > MAX_LENGTH)) {
|
||||||
fprintf(stderr, "Request exceeds size of flash memory.\n");
|
fprintf(stderr, "Request exceeds size of flash memory.\n");
|
||||||
if (infile != NULL)
|
if (infile != NULL) {
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
|
}
|
||||||
usage();
|
usage();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
@ -363,10 +366,11 @@ int main(int argc, char** argv)
|
|||||||
tmp_length = length;
|
tmp_length = length;
|
||||||
while (tmp_length) {
|
while (tmp_length) {
|
||||||
xfer_len = (tmp_length > 256) ? 256 : tmp_length;
|
xfer_len = (tmp_length > 256) ? 256 : tmp_length;
|
||||||
if (verbose)
|
if (verbose) {
|
||||||
printf("Reading %d bytes from 0x%06x.\n",
|
printf("Reading %d bytes from 0x%06x.\n",
|
||||||
xfer_len,
|
xfer_len,
|
||||||
address);
|
address);
|
||||||
|
}
|
||||||
result = hackrf_spiflash_read(device, address, xfer_len, pdata);
|
result = hackrf_spiflash_read(device, address, xfer_len, pdata);
|
||||||
if (result != HACKRF_SUCCESS) {
|
if (result != HACKRF_SUCCESS) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@ -423,14 +427,16 @@ int main(int argc, char** argv)
|
|||||||
infile = NULL;
|
infile = NULL;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if (!verbose)
|
if (!verbose) {
|
||||||
printf("Writing %d bytes at 0x%06x.\n", length, address);
|
printf("Writing %d bytes at 0x%06x.\n", length, address);
|
||||||
|
}
|
||||||
while (length) {
|
while (length) {
|
||||||
xfer_len = (length > 256) ? 256 : length;
|
xfer_len = (length > 256) ? 256 : length;
|
||||||
if (verbose)
|
if (verbose) {
|
||||||
printf("Writing %d bytes at 0x%06x.\n",
|
printf("Writing %d bytes at 0x%06x.\n",
|
||||||
xfer_len,
|
xfer_len,
|
||||||
address);
|
address);
|
||||||
|
}
|
||||||
result = hackrf_spiflash_write(device, address, xfer_len, pdata);
|
result = hackrf_spiflash_write(device, address, xfer_len, pdata);
|
||||||
if (result != HACKRF_SUCCESS) {
|
if (result != HACKRF_SUCCESS) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -151,17 +151,20 @@ int parse_u32_range(char* s, uint32_t* const value_min, uint32_t* const value_ma
|
|||||||
int result;
|
int result;
|
||||||
|
|
||||||
char* sep = strchr(s, ':');
|
char* sep = strchr(s, ':');
|
||||||
if (!sep)
|
if (!sep) {
|
||||||
return HACKRF_ERROR_INVALID_PARAM;
|
return HACKRF_ERROR_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
*sep = 0;
|
*sep = 0;
|
||||||
|
|
||||||
result = parse_u32(s, value_min);
|
result = parse_u32(s, value_min);
|
||||||
if (result != HACKRF_SUCCESS)
|
if (result != HACKRF_SUCCESS) {
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
result = parse_u32(sep + 1, value_max);
|
result = parse_u32(sep + 1, value_max);
|
||||||
if (result != HACKRF_SUCCESS)
|
if (result != HACKRF_SUCCESS) {
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -527,11 +530,13 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lna_gain % 8)
|
if (lna_gain % 8) {
|
||||||
fprintf(stderr, "warning: lna_gain (-l) must be a multiple of 8\n");
|
fprintf(stderr, "warning: lna_gain (-l) must be a multiple of 8\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (vga_gain % 2)
|
if (vga_gain % 2) {
|
||||||
fprintf(stderr, "warning: vga_gain (-g) must be a multiple of 2\n");
|
fprintf(stderr, "warning: vga_gain (-g) must be a multiple of 2\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (amp) {
|
if (amp) {
|
||||||
if (amp_enable > 1) {
|
if (amp_enable > 1) {
|
||||||
@ -820,8 +825,9 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
gettimeofday(&time_now, NULL);
|
gettimeofday(&time_now, NULL);
|
||||||
time_diff = TimevalDiff(&time_now, &t_start);
|
time_diff = TimevalDiff(&time_now, &t_start);
|
||||||
if ((sweep_rate == 0) && (time_diff > 0))
|
if ((sweep_rate == 0) && (time_diff > 0)) {
|
||||||
sweep_rate = sweep_count / time_diff;
|
sweep_rate = sweep_count / time_diff;
|
||||||
|
}
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Total sweeps: %" PRIu64 " in %.5f seconds (%.2f sweeps/second)\n",
|
"Total sweeps: %" PRIu64 " in %.5f seconds (%.2f sweeps/second)\n",
|
||||||
sweep_count,
|
sweep_count,
|
||||||
|
Reference in New Issue
Block a user