implemented transceiver mode OFF
This commit is contained in:
@ -239,8 +239,9 @@ extern "C"
|
||||
/* TODO add other Pins */
|
||||
|
||||
typedef enum {
|
||||
TRANSCEIVER_MODE_RX,
|
||||
TRANSCEIVER_MODE_TX,
|
||||
TRANSCEIVER_MODE_OFF = 0,
|
||||
TRANSCEIVER_MODE_RX = 1,
|
||||
TRANSCEIVER_MODE_TX = 2
|
||||
} transceiver_mode_t;
|
||||
|
||||
void delay(uint32_t duration);
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "usb_descriptor.h"
|
||||
#include "usb_standard_request.h"
|
||||
|
||||
static volatile transceiver_mode_t transceiver_mode = TRANSCEIVER_MODE_RX;
|
||||
static volatile transceiver_mode_t transceiver_mode = TRANSCEIVER_MODE_OFF;
|
||||
|
||||
uint8_t* const usb_bulk_buffer = (uint8_t*)0x20004000;
|
||||
static volatile uint32_t usb_bulk_buffer_offset = 0;
|
||||
@ -53,6 +53,8 @@ const uint_fast8_t usb_td_bulk_count = sizeof(usb_td_bulk) / sizeof(usb_td_bulk[
|
||||
uint8_t spiflash_buffer[W25Q80BV_PAGE_LEN];
|
||||
char version_string[] = VERSION_STRING;
|
||||
|
||||
uint8_t switchctrl = 0;
|
||||
|
||||
static void usb_init_buffers_bulk() {
|
||||
usb_td_bulk[0].next_dtd_pointer = USB_TD_NEXT_DTD_POINTER_TERMINATE;
|
||||
usb_td_bulk[0].total_bytes
|
||||
@ -185,13 +187,20 @@ void set_transceiver_mode(const transceiver_mode_t new_transceiver_mode) {
|
||||
gpio_set(PORT_LED1_3, PIN_LED2);
|
||||
usb_endpoint_init(&usb_endpoint_bulk_in);
|
||||
|
||||
max2837_start();
|
||||
max2837_rx();
|
||||
} else {
|
||||
} else if (transceiver_mode == TRANSCEIVER_MODE_TX) {
|
||||
gpio_clear(PORT_LED1_3, PIN_LED2);
|
||||
gpio_set(PORT_LED1_3, PIN_LED3);
|
||||
usb_endpoint_init(&usb_endpoint_bulk_out);
|
||||
|
||||
max2837_start();
|
||||
max2837_tx();
|
||||
} else {
|
||||
gpio_clear(PORT_LED1_3, PIN_LED2);
|
||||
gpio_clear(PORT_LED1_3, PIN_LED3);
|
||||
max2837_stop();
|
||||
return;
|
||||
}
|
||||
|
||||
sgpio_configure(transceiver_mode, true);
|
||||
@ -209,16 +218,12 @@ usb_request_status_t usb_vendor_request_set_transceiver_mode(
|
||||
) {
|
||||
if( stage == USB_TRANSFER_STAGE_SETUP ) {
|
||||
switch( endpoint->setup.value ) {
|
||||
case 1:
|
||||
set_transceiver_mode(TRANSCEIVER_MODE_RX);
|
||||
case TRANSCEIVER_MODE_OFF:
|
||||
case TRANSCEIVER_MODE_RX:
|
||||
case TRANSCEIVER_MODE_TX:
|
||||
set_transceiver_mode(endpoint->setup.value);
|
||||
usb_endpoint_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
|
||||
case 2:
|
||||
set_transceiver_mode(TRANSCEIVER_MODE_TX);
|
||||
usb_endpoint_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
|
||||
default:
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
}
|
||||
@ -632,7 +637,6 @@ void sgpio_irqhandler() {
|
||||
|
||||
int main(void) {
|
||||
const uint32_t ifreq = 2600000000U;
|
||||
uint8_t switchctrl = 0;
|
||||
|
||||
pin_setup();
|
||||
enable_1v8_power();
|
||||
@ -655,19 +659,16 @@ int main(void) {
|
||||
|
||||
ssp1_set_mode_max2837();
|
||||
max2837_setup();
|
||||
max2837_set_frequency(ifreq);
|
||||
|
||||
rffc5071_setup();
|
||||
|
||||
|
||||
#ifdef JAWBREAKER
|
||||
switchctrl = SWITCHCTRL_AMP_BYPASS;
|
||||
#endif
|
||||
rffc5071_rx(switchctrl);
|
||||
rffc5071_set_frequency(1700, 0); // 2600 MHz IF - 1700 MHz LO = 900 MHz RF
|
||||
|
||||
max2837_set_frequency(ifreq);
|
||||
max2837_start();
|
||||
max2837_rx();
|
||||
|
||||
while(true) {
|
||||
// Wait until buffer 0 is transmitted/received.
|
||||
while( usb_bulk_buffer_offset < 16384 );
|
||||
|
@ -47,8 +47,9 @@
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
TRANSCEIVER_MODE_RX,
|
||||
TRANSCEIVER_MODE_TX,
|
||||
TRANSCEIVER_MODE_OFF = 0,
|
||||
TRANSCEIVER_MODE_RX = 1,
|
||||
TRANSCEIVER_MODE_TX = 2
|
||||
} transceiver_mode_t;
|
||||
static transceiver_mode_t transceiver_mode = TRANSCEIVER_MODE_RX;
|
||||
|
||||
|
@ -48,6 +48,7 @@ typedef enum {
|
||||
} hackrf_vendor_request;
|
||||
|
||||
typedef enum {
|
||||
HACKRF_TRANSCEIVER_MODE_OFF = 0,
|
||||
HACKRF_TRANSCEIVER_MODE_RECEIVE = 1,
|
||||
HACKRF_TRANSCEIVER_MODE_TRANSMIT = 2,
|
||||
} hackrf_transceiver_mode;
|
||||
@ -662,7 +663,12 @@ int hackrf_start_rx(hackrf_device* device, hackrf_sample_block_cb_fn callback) {
|
||||
}
|
||||
|
||||
int hackrf_stop_rx(hackrf_device* device) {
|
||||
return kill_transfer_thread(device);
|
||||
int result1, result2;
|
||||
result1 = kill_transfer_thread(device);
|
||||
result2 = hackrf_set_transceiver_mode(device, HACKRF_TRANSCEIVER_MODE_OFF);
|
||||
if (result2 != HACKRF_SUCCESS)
|
||||
return result2;
|
||||
return result1;
|
||||
}
|
||||
|
||||
int hackrf_start_tx(hackrf_device* device, hackrf_sample_block_cb_fn callback) {
|
||||
@ -675,7 +681,12 @@ int hackrf_start_tx(hackrf_device* device, hackrf_sample_block_cb_fn callback) {
|
||||
}
|
||||
|
||||
int hackrf_stop_tx(hackrf_device* device) {
|
||||
return kill_transfer_thread(device);
|
||||
int result1, result2;
|
||||
result1 = kill_transfer_thread(device);
|
||||
result2 = hackrf_set_transceiver_mode(device, HACKRF_TRANSCEIVER_MODE_OFF);
|
||||
if (result2 != HACKRF_SUCCESS)
|
||||
return result2;
|
||||
return result1;
|
||||
}
|
||||
|
||||
int hackrf_close(hackrf_device* device) {
|
||||
|
Reference in New Issue
Block a user