Updated HackRF firmware
This commit is contained in:
@ -0,0 +1,83 @@
|
||||
# Copyright 2012 Jared Boone <jared@sharebrained.com>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.1.3)
|
||||
set(CMAKE_TOOLCHAIN_FILE ../toolchain-arm-cortex-m.cmake)
|
||||
|
||||
project(hackrf_usb C)
|
||||
|
||||
include(../hackrf-common.cmake)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${PATH_HACKRF_CPLD_DATA_C}
|
||||
COMMAND ${PATH_CPLD_BITSTREAM_TOOL} --xsvf ${PATH_HACKRF_CPLD_XSVF} --hackrf-data ${PATH_HACKRF_CPLD_DATA_C}
|
||||
DEPENDS ${PATH_CPLD_BITSTREAM_TOOL} ${PATH_HACKRF_CPLD_XSVF}
|
||||
)
|
||||
|
||||
set(SRC_M4
|
||||
hackrf_usb.c
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/tuning.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/streaming.c"
|
||||
usb_bulk_buffer.c
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/usb.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/usb_request.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/usb_standard_request.c"
|
||||
usb_descriptor.c
|
||||
usb_device.c
|
||||
usb_endpoint.c
|
||||
usb_api_board_info.c
|
||||
usb_api_cpld.c
|
||||
usb_api_register.c
|
||||
usb_api_spiflash.c
|
||||
usb_api_transceiver.c
|
||||
usb_api_operacake.c
|
||||
usb_api_sweep.c
|
||||
usb_api_ui.c
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/usb_queue.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/fault_handler.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/cpld_jtag.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/cpld_xc2c.c"
|
||||
"${PATH_HACKRF_CPLD_DATA_C}"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/xapp058/lenval.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/xapp058/micro.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/xapp058/ports.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/crc.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/rom_iap.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/operacake.c"
|
||||
)
|
||||
|
||||
set(SRC_M0 sgpio_m0.s)
|
||||
|
||||
if(BOARD STREQUAL "HACKRF_ONE")
|
||||
SET(SRC_M4
|
||||
${SRC_M4}
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/portapack.c"
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/ui_portapack.c"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(BOARD STREQUAL "RAD1O")
|
||||
SET(SRC_M4
|
||||
${SRC_M4}
|
||||
"${PATH_HACKRF_FIRMWARE_COMMON}/ui_rad1o.c"
|
||||
)
|
||||
endif()
|
||||
|
||||
DeclareTargets()
|
||||
@ -0,0 +1,275 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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 <stddef.h>
|
||||
|
||||
#include <libopencm3/lpc43xx/ipc.h>
|
||||
#include <libopencm3/lpc43xx/m4/nvic.h>
|
||||
#include <libopencm3/lpc43xx/rgu.h>
|
||||
|
||||
#include <streaming.h>
|
||||
|
||||
#include "tuning.h"
|
||||
|
||||
#include "usb.h"
|
||||
#include "usb_standard_request.h"
|
||||
|
||||
#include <rom_iap.h>
|
||||
#include "usb_descriptor.h"
|
||||
|
||||
#include "usb_device.h"
|
||||
#include "usb_endpoint.h"
|
||||
#include "usb_api_board_info.h"
|
||||
#include "usb_api_cpld.h"
|
||||
#include "usb_api_register.h"
|
||||
#include "usb_api_spiflash.h"
|
||||
#include "usb_api_operacake.h"
|
||||
#include "operacake.h"
|
||||
#include "usb_api_sweep.h"
|
||||
#include "usb_api_transceiver.h"
|
||||
#include "usb_api_ui.h"
|
||||
#include "usb_bulk_buffer.h"
|
||||
#include "cpld_xc2c.h"
|
||||
#include "portapack.h"
|
||||
|
||||
#include "hackrf_ui.h"
|
||||
|
||||
extern uint32_t __m0_start__;
|
||||
extern uint32_t __m0_end__;
|
||||
extern uint32_t __ram_m0_start__;
|
||||
|
||||
static usb_request_handler_fn vendor_request_handler[] = {
|
||||
NULL,
|
||||
usb_vendor_request_set_transceiver_mode,
|
||||
usb_vendor_request_write_max2837,
|
||||
usb_vendor_request_read_max2837,
|
||||
usb_vendor_request_write_si5351c,
|
||||
usb_vendor_request_read_si5351c,
|
||||
usb_vendor_request_set_sample_rate_frac,
|
||||
usb_vendor_request_set_baseband_filter_bandwidth,
|
||||
#ifdef RAD1O
|
||||
NULL, // write_rffc5071 not used
|
||||
NULL, // read_rffc5071 not used
|
||||
#else
|
||||
usb_vendor_request_write_rffc5071,
|
||||
usb_vendor_request_read_rffc5071,
|
||||
#endif
|
||||
usb_vendor_request_erase_spiflash,
|
||||
usb_vendor_request_write_spiflash,
|
||||
usb_vendor_request_read_spiflash,
|
||||
NULL, // used to be write_cpld
|
||||
usb_vendor_request_read_board_id,
|
||||
usb_vendor_request_read_version_string,
|
||||
usb_vendor_request_set_freq,
|
||||
usb_vendor_request_set_amp_enable,
|
||||
usb_vendor_request_read_partid_serialno,
|
||||
usb_vendor_request_set_lna_gain,
|
||||
usb_vendor_request_set_vga_gain,
|
||||
usb_vendor_request_set_txvga_gain,
|
||||
NULL, // was set_if_freq
|
||||
#ifdef HACKRF_ONE
|
||||
usb_vendor_request_set_antenna_enable,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
usb_vendor_request_set_freq_explicit,
|
||||
usb_vendor_request_read_wcid, // USB_WCID_VENDOR_REQ
|
||||
usb_vendor_request_init_sweep,
|
||||
usb_vendor_request_operacake_get_boards,
|
||||
usb_vendor_request_operacake_set_ports,
|
||||
usb_vendor_request_set_hw_sync_mode,
|
||||
usb_vendor_request_reset,
|
||||
usb_vendor_request_operacake_set_ranges,
|
||||
usb_vendor_request_set_clkout_enable,
|
||||
usb_vendor_request_spiflash_status,
|
||||
usb_vendor_request_spiflash_clear_status,
|
||||
usb_vendor_request_operacake_gpio_test,
|
||||
#ifdef HACKRF_ONE
|
||||
usb_vendor_request_cpld_checksum,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
usb_vendor_request_set_ui_enable,
|
||||
};
|
||||
|
||||
static const uint32_t vendor_request_handler_count =
|
||||
sizeof(vendor_request_handler) / sizeof(vendor_request_handler[0]);
|
||||
|
||||
usb_request_status_t usb_vendor_request(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
) {
|
||||
usb_request_status_t status = USB_REQUEST_STATUS_STALL;
|
||||
|
||||
if( endpoint->setup.request < vendor_request_handler_count ) {
|
||||
usb_request_handler_fn handler = vendor_request_handler[endpoint->setup.request];
|
||||
if( handler ) {
|
||||
status = handler(endpoint, stage);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
const usb_request_handlers_t usb_request_handlers = {
|
||||
.standard = usb_standard_request,
|
||||
.class = 0,
|
||||
.vendor = usb_vendor_request,
|
||||
.reserved = 0,
|
||||
};
|
||||
|
||||
void usb_configuration_changed(
|
||||
usb_device_t* const device
|
||||
) {
|
||||
/* Reset transceiver to idle state until other commands are received */
|
||||
set_transceiver_mode(TRANSCEIVER_MODE_OFF);
|
||||
if( device->configuration->number == 1 ) {
|
||||
// transceiver configuration
|
||||
led_on(LED1);
|
||||
} else {
|
||||
/* Configuration number equal 0 means usb bus reset. */
|
||||
led_off(LED1);
|
||||
}
|
||||
usb_endpoint_init(&usb_endpoint_bulk_in);
|
||||
usb_endpoint_init(&usb_endpoint_bulk_out);
|
||||
}
|
||||
|
||||
void usb_set_descriptor_by_serial_number(void)
|
||||
{
|
||||
iap_cmd_res_t iap_cmd_res;
|
||||
|
||||
/* Read IAP Serial Number Identification */
|
||||
iap_cmd_res.cmd_param.command_code = IAP_CMD_READ_SERIAL_NO;
|
||||
iap_cmd_call(&iap_cmd_res);
|
||||
|
||||
if (iap_cmd_res.status_res.status_ret == CMD_SUCCESS) {
|
||||
usb_descriptor_string_serial_number[0] = USB_DESCRIPTOR_STRING_SERIAL_BUF_LEN;
|
||||
usb_descriptor_string_serial_number[1] = USB_DESCRIPTOR_TYPE_STRING;
|
||||
|
||||
/* 32 characters of serial number, convert to UTF-16LE */
|
||||
for (size_t i=0; i<USB_DESCRIPTOR_STRING_SERIAL_LEN; i++) {
|
||||
const uint_fast8_t nibble = (iap_cmd_res.status_res.iap_result[i >> 3] >> (28 - (i & 7) * 4)) & 0xf;
|
||||
const char c = (nibble > 9) ? ('a' + nibble - 10) : ('0' + nibble);
|
||||
usb_descriptor_string_serial_number[2 + i * 2] = c;
|
||||
usb_descriptor_string_serial_number[3 + i * 2] = 0x00;
|
||||
}
|
||||
} else {
|
||||
usb_descriptor_string_serial_number[0] = 2;
|
||||
usb_descriptor_string_serial_number[1] = USB_DESCRIPTOR_TYPE_STRING;
|
||||
}
|
||||
}
|
||||
|
||||
static bool cpld_jtag_sram_load(jtag_t* const jtag) {
|
||||
cpld_jtag_take(jtag);
|
||||
cpld_xc2c64a_jtag_sram_write(jtag, &cpld_hackrf_program_sram);
|
||||
const bool success = cpld_xc2c64a_jtag_sram_verify(jtag, &cpld_hackrf_program_sram, &cpld_hackrf_verify);
|
||||
cpld_jtag_release(jtag);
|
||||
return success;
|
||||
}
|
||||
|
||||
static void m0_rom_to_ram() {
|
||||
uint32_t *dest = &__ram_m0_start__;
|
||||
uint32_t *src = &__m0_start__;
|
||||
while (src < &__m0_end__) {
|
||||
*dest = *src;
|
||||
dest++;
|
||||
src++;
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
bool operacake_allow_gpio;
|
||||
pin_setup();
|
||||
enable_1v8_power();
|
||||
#if (defined HACKRF_ONE || defined RAD1O)
|
||||
enable_rf_power();
|
||||
|
||||
/* Let the voltage stabilize */
|
||||
delay(1000000);
|
||||
#endif
|
||||
cpu_clock_init();
|
||||
|
||||
/* Wake the M0 */
|
||||
m0_rom_to_ram();
|
||||
ipc_start_m0((uint32_t)&__ram_m0_start__);
|
||||
|
||||
if( !cpld_jtag_sram_load(&jtag_cpld) ) {
|
||||
halt_and_flash(6000000);
|
||||
}
|
||||
|
||||
#ifdef HACKRF_ONE
|
||||
portapack_init();
|
||||
#endif
|
||||
|
||||
#ifndef DFU_MODE
|
||||
usb_set_descriptor_by_serial_number();
|
||||
#endif
|
||||
|
||||
usb_set_configuration_changed_cb(usb_configuration_changed);
|
||||
usb_peripheral_reset();
|
||||
|
||||
usb_device_init(0, &usb_device);
|
||||
|
||||
usb_queue_init(&usb_endpoint_control_out_queue);
|
||||
usb_queue_init(&usb_endpoint_control_in_queue);
|
||||
usb_queue_init(&usb_endpoint_bulk_out_queue);
|
||||
usb_queue_init(&usb_endpoint_bulk_in_queue);
|
||||
|
||||
usb_endpoint_init(&usb_endpoint_control_out);
|
||||
usb_endpoint_init(&usb_endpoint_control_in);
|
||||
|
||||
nvic_set_priority(NVIC_USB0_IRQ, 255);
|
||||
|
||||
hackrf_ui()->init();
|
||||
|
||||
usb_run(&usb_device);
|
||||
|
||||
rf_path_init(&rf_path);
|
||||
|
||||
if( hackrf_ui()->operacake_gpio_compatible() ) {
|
||||
operacake_allow_gpio = true;
|
||||
} else {
|
||||
operacake_allow_gpio = false;
|
||||
}
|
||||
operacake_init(operacake_allow_gpio);
|
||||
|
||||
while(true) {
|
||||
switch (transceiver_mode()) {
|
||||
case TRANSCEIVER_MODE_RX:
|
||||
rx_mode();
|
||||
break;
|
||||
case TRANSCEIVER_MODE_TX:
|
||||
tx_mode();
|
||||
break;
|
||||
case TRANSCEIVER_MODE_RX_SWEEP:
|
||||
sweep_mode();
|
||||
break;
|
||||
case TRANSCEIVER_MODE_CPLD_UPDATE:
|
||||
cpld_update();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* This file is part of GreatFET
|
||||
*
|
||||
* Specialized SGPIO interrupt handler for Rhododendron.
|
||||
*/
|
||||
|
||||
|
||||
// Constants that point to registers we'll need to modify in the SGPIO block.
|
||||
.equ SGPIO_REGISTER_BLOCK_BASE, 0x40101000
|
||||
.equ SGPIO_SHADOW_REGISTERS_BASE, 0x40101100
|
||||
.equ SGPIO_EXCHANGE_INTERRUPT_CLEAR_REG, 0x40101F30
|
||||
.equ SGPIO_EXCHANGE_INTERRUPT_STATUS_REG, 0x40101F2C
|
||||
.equ SGPIO_GPIO_INPUT, 0x40101210
|
||||
|
||||
|
||||
// Buffer that we're funneling data to/from.
|
||||
.equ TARGET_DATA_BUFFER, 0x20008000
|
||||
.equ TARGET_BUFFER_POSITION, 0x20007000
|
||||
.equ TARGET_BUFFER_TX, 0x20007004
|
||||
.equ TARGET_BUFFER_MASK, 0x7fff
|
||||
|
||||
.global main
|
||||
.thumb_func
|
||||
main:
|
||||
|
||||
// Spin until we're ready to handle an SGPIO packet:
|
||||
// Grab the exchange interrupt staus...
|
||||
ldr r0, =SGPIO_EXCHANGE_INTERRUPT_STATUS_REG
|
||||
ldr r0, [r0]
|
||||
|
||||
// ... check to see if it has any interrupt bits set...
|
||||
lsr r0, #1
|
||||
|
||||
// ... and if not, jump back to the beginning.
|
||||
bcc main
|
||||
|
||||
// Clear the interrupt pending bits for the SGPIO slices we're working with.
|
||||
ldr r0, =SGPIO_EXCHANGE_INTERRUPT_CLEAR_REG
|
||||
ldr r1, =0xffff
|
||||
str r1, [r0]
|
||||
|
||||
// Grab the base address of the SGPIO shadow registers...
|
||||
ldr r7, =SGPIO_SHADOW_REGISTERS_BASE
|
||||
|
||||
// ... and grab the address of the buffer segment we want to write to / read from.
|
||||
ldr r0, =TARGET_DATA_BUFFER // r0 = &buffer
|
||||
ldr r3, =TARGET_BUFFER_POSITION // r3 = &position_in_buffer
|
||||
ldr r2, [r3] // r2 = position_in_buffer
|
||||
add r6, r0, r2 // r6 = buffer_target = &buffer + position_in_buffer
|
||||
|
||||
mov r8, r3 // Store &position_in_buffer.
|
||||
|
||||
// Our slice chain is set up as follows (ascending data age; arrows are reversed for flow):
|
||||
// L -> F -> K -> C -> J -> E -> I -> A
|
||||
// Which has equivalent shadow register offsets:
|
||||
// 44 -> 20 -> 40 -> 8 -> 36 -> 16 -> 32 -> 0
|
||||
|
||||
// Load direction (TX or RX)
|
||||
ldr r0, =TARGET_BUFFER_TX
|
||||
ldr r0, [r0]
|
||||
|
||||
// TX?
|
||||
lsr r0, #1
|
||||
bcc direction_rx
|
||||
|
||||
direction_tx:
|
||||
|
||||
ldm r6!, {r0-r5}
|
||||
str r0, [r7, #44]
|
||||
str r1, [r7, #20]
|
||||
str r2, [r7, #40]
|
||||
str r3, [r7, #8 ]
|
||||
str r4, [r7, #36]
|
||||
str r5, [r7, #16]
|
||||
|
||||
ldm r6!, {r0-r1}
|
||||
str r0, [r7, #32]
|
||||
str r1, [r7, #0]
|
||||
|
||||
b done
|
||||
|
||||
direction_rx:
|
||||
|
||||
// 8 cycles
|
||||
ldr r0, [r7, #44] // 2
|
||||
ldr r1, [r7, #20] // 2
|
||||
ldr r2, [r7, #40] // 2
|
||||
ldr r3, [r7, #8 ] // 2
|
||||
ldr r4, [r7, #36] // 2
|
||||
ldr r5, [r7, #16] // 2
|
||||
stm r6!, {r0-r5} // 7
|
||||
|
||||
// 6 cycles
|
||||
ldr r0, [r7, #32] // 2
|
||||
ldr r1, [r7, #0] // 2
|
||||
stm r6!, {r0-r1}
|
||||
|
||||
done:
|
||||
|
||||
// Finally, update the buffer location...
|
||||
ldr r0, =TARGET_BUFFER_MASK
|
||||
and r0, r6, r0 // r0 = (position_in_buffer + size_copied) % buffer_size
|
||||
|
||||
// ... restore &position_in_buffer, and store the new position there...
|
||||
mov r1, r8
|
||||
str r0, [r1] // position_in_buffer = (position_in_buffer + size_copied) % buffer_size
|
||||
|
||||
b main
|
||||
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_board_info.h"
|
||||
|
||||
#include <hackrf_core.h>
|
||||
#include <rom_iap.h>
|
||||
#include <usb_queue.h>
|
||||
#include <libopencm3/lpc43xx/wwdt.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
char version_string[] = VERSION_STRING;
|
||||
|
||||
usb_request_status_t usb_vendor_request_read_board_id(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
endpoint->buffer[0] = BOARD_ID;
|
||||
usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1, NULL, NULL);
|
||||
usb_transfer_schedule_ack(endpoint->out);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_read_version_string(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
uint8_t length;
|
||||
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
length = (uint8_t)strlen(version_string);
|
||||
usb_transfer_schedule_block(endpoint->in, version_string, length, NULL, NULL);
|
||||
usb_transfer_schedule_ack(endpoint->out);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_read_partid_serialno(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
uint8_t length;
|
||||
read_partid_serialno_t read_partid_serialno;
|
||||
iap_cmd_res_t iap_cmd_res;
|
||||
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP)
|
||||
{
|
||||
/* Read IAP Part Number Identification */
|
||||
iap_cmd_res.cmd_param.command_code = IAP_CMD_READ_PART_ID_NO;
|
||||
iap_cmd_call(&iap_cmd_res);
|
||||
if(iap_cmd_res.status_res.status_ret != CMD_SUCCESS)
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
|
||||
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 IAP Serial Number Identification */
|
||||
iap_cmd_res.cmd_param.command_code = IAP_CMD_READ_SERIAL_NO;
|
||||
iap_cmd_call(&iap_cmd_res);
|
||||
if(iap_cmd_res.status_res.status_ret != CMD_SUCCESS)
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
|
||||
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[2] = iap_cmd_res.status_res.iap_result[2];
|
||||
read_partid_serialno.serial_no[3] = iap_cmd_res.status_res.iap_result[3];
|
||||
|
||||
length = (uint8_t)sizeof(read_partid_serialno_t);
|
||||
usb_transfer_schedule_block(endpoint->in, &read_partid_serialno, length,
|
||||
NULL, NULL);
|
||||
usb_transfer_schedule_ack(endpoint->out);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_reset(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
wwdt_reset(100000);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_BOARD_INFO_H__
|
||||
#define __USB_API_BOARD_INFO_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <usb_type.h>
|
||||
#include <usb_request.h>
|
||||
|
||||
typedef struct {
|
||||
uint32_t part_id[2];
|
||||
uint32_t serial_no[4];
|
||||
} read_partid_serialno_t;
|
||||
|
||||
usb_request_status_t usb_vendor_request_read_board_id(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_read_version_string(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_read_partid_serialno(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_reset(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
|
||||
#endif /* end of include guard: __USB_API_BOARD_INFO_H__ */
|
||||
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_cpld.h"
|
||||
|
||||
#include <hackrf_core.h>
|
||||
#include <cpld_jtag.h>
|
||||
#include <cpld_xc2c.h>
|
||||
#include <usb_queue.h>
|
||||
|
||||
#include "usb_endpoint.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
uint8_t cpld_xsvf_buffer[512];
|
||||
volatile bool cpld_wait = false;
|
||||
|
||||
static void cpld_buffer_refilled(void* user_data, unsigned int length)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)length;
|
||||
cpld_wait = false;
|
||||
}
|
||||
|
||||
static void refill_cpld_buffer(void)
|
||||
{
|
||||
cpld_wait = true;
|
||||
usb_transfer_schedule(
|
||||
&usb_endpoint_bulk_out,
|
||||
cpld_xsvf_buffer,
|
||||
sizeof(cpld_xsvf_buffer),
|
||||
cpld_buffer_refilled,
|
||||
NULL
|
||||
);
|
||||
|
||||
// Wait until transfer finishes
|
||||
while (cpld_wait);
|
||||
}
|
||||
|
||||
void cpld_update(void)
|
||||
{
|
||||
int error;
|
||||
|
||||
usb_queue_flush_endpoint(&usb_endpoint_bulk_in);
|
||||
usb_queue_flush_endpoint(&usb_endpoint_bulk_out);
|
||||
|
||||
refill_cpld_buffer();
|
||||
|
||||
error = cpld_jtag_program(&jtag_cpld, sizeof(cpld_xsvf_buffer),
|
||||
cpld_xsvf_buffer,
|
||||
refill_cpld_buffer);
|
||||
if(error == 0)
|
||||
{
|
||||
halt_and_flash(6000000);
|
||||
}else
|
||||
{
|
||||
/* LED3 (Red) steady on error */
|
||||
led_on(LED3);
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_cpld_checksum(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
static uint32_t cpld_crc;
|
||||
uint8_t length;
|
||||
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP)
|
||||
{
|
||||
cpld_jtag_take(&jtag_cpld);
|
||||
const bool checksum_success = cpld_xc2c64a_jtag_checksum(&jtag_cpld, &cpld_hackrf_verify, &cpld_crc);
|
||||
cpld_jtag_release(&jtag_cpld);
|
||||
|
||||
if(!checksum_success) {
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
}
|
||||
|
||||
length = (uint8_t)sizeof(cpld_crc);
|
||||
usb_transfer_schedule_block(endpoint->in, &cpld_crc, length,
|
||||
NULL, NULL);
|
||||
usb_transfer_schedule_ack(endpoint->out);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_CPLD_H__
|
||||
#define __USB_API_CPLD_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <usb_type.h>
|
||||
#include <usb_request.h>
|
||||
|
||||
void cpld_update(void);
|
||||
|
||||
usb_request_status_t usb_vendor_request_cpld_checksum(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
|
||||
#endif /* end of include guard: __USB_API_CPLD_H__ */
|
||||
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright 2016 Dominic Spill <dominicgs@gmail.com>
|
||||
*
|
||||
* 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_operacake.h"
|
||||
#include "usb_queue.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <operacake.h>
|
||||
|
||||
usb_request_status_t usb_vendor_request_operacake_get_boards(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
usb_transfer_schedule_block(endpoint->in, operacake_boards, 8, NULL, NULL);
|
||||
usb_transfer_schedule_ack(endpoint->out);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_operacake_set_ports(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
uint8_t address, port_a, port_b;
|
||||
address = endpoint->setup.value & 0xFF;
|
||||
port_a = endpoint->setup.index & 0xFF;
|
||||
port_b = (endpoint->setup.index >> 8) & 0xFF;
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
operacake_set_ports(address, port_a, port_b);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
|
||||
static unsigned char data[MAX_OPERACAKE_RANGES * 5];
|
||||
usb_request_status_t usb_vendor_request_operacake_set_ranges(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
uint16_t i, freq_min, freq_max, num_ranges = 0;
|
||||
uint8_t port;
|
||||
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
num_ranges = endpoint->setup.length / 5;
|
||||
if((num_ranges == 0) || (num_ranges > MAX_OPERACAKE_RANGES)) {
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
}
|
||||
usb_transfer_schedule_block(endpoint->out, &data,
|
||||
endpoint->setup.length, NULL, NULL);
|
||||
} else if (stage == USB_TRANSFER_STAGE_DATA) {
|
||||
|
||||
for(i=0; i<endpoint->setup.length; i+=5) {
|
||||
freq_min = data[i] << 8 | data[i+1];
|
||||
freq_max = data[i+2] << 8 | data[i+3];
|
||||
port = data[i+4];
|
||||
operacake_add_range(freq_min, freq_max, port);
|
||||
}
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_operacake_gpio_test(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
uint16_t test_result;
|
||||
uint8_t address = endpoint->setup.value & 0xFF;
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
test_result = gpio_test(address);
|
||||
endpoint->buffer[0] = test_result & 0xff;
|
||||
endpoint->buffer[1] = test_result >> 8;
|
||||
usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 2, NULL, NULL);
|
||||
usb_transfer_schedule_ack(endpoint->out);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2016 Dominic Spill <dominicgs@gmail.com>
|
||||
*
|
||||
* 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_OPERACAKE_H__
|
||||
#define __USB_API_OPERACAKE_H__
|
||||
|
||||
#include <usb_type.h>
|
||||
#include <usb_request.h>
|
||||
|
||||
usb_request_status_t usb_vendor_request_operacake_get_boards(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
|
||||
usb_request_status_t usb_vendor_request_operacake_set_ports(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
|
||||
usb_request_status_t usb_vendor_request_operacake_set_ranges(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
|
||||
usb_request_status_t usb_vendor_request_operacake_gpio_test(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
|
||||
#endif /* end of include guard: __USB_API_OPERACAKE_H__ */
|
||||
@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_register.h"
|
||||
|
||||
#include <hackrf_core.h>
|
||||
#include <usb_queue.h>
|
||||
#include <max2837.h>
|
||||
#include <rffc5071.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <hackrf_core.h>
|
||||
|
||||
usb_request_status_t usb_vendor_request_write_max2837(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
) {
|
||||
if( stage == USB_TRANSFER_STAGE_SETUP ) {
|
||||
if( endpoint->setup.index < MAX2837_NUM_REGS ) {
|
||||
if( endpoint->setup.value < MAX2837_DATA_REGS_MAX_VALUE ) {
|
||||
max2837_reg_write(&max2837, endpoint->setup.index, endpoint->setup.value);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
} else {
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_read_max2837(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
) {
|
||||
if( stage == USB_TRANSFER_STAGE_SETUP ) {
|
||||
if( endpoint->setup.index < MAX2837_NUM_REGS ) {
|
||||
const uint16_t value = max2837_reg_read(&max2837, endpoint->setup.index);
|
||||
endpoint->buffer[0] = value & 0xff;
|
||||
endpoint->buffer[1] = value >> 8;
|
||||
usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 2,
|
||||
NULL, NULL);
|
||||
usb_transfer_schedule_ack(endpoint->out);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
} else {
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_write_si5351c(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
) {
|
||||
if( stage == USB_TRANSFER_STAGE_SETUP ) {
|
||||
if( endpoint->setup.index < 256 ) {
|
||||
if( endpoint->setup.value < 256 ) {
|
||||
si5351c_write_single(&clock_gen, endpoint->setup.index, endpoint->setup.value);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
} else {
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_read_si5351c(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
) {
|
||||
if( stage == USB_TRANSFER_STAGE_SETUP ) {
|
||||
if( endpoint->setup.index < 256 ) {
|
||||
const uint8_t value = si5351c_read_single(&clock_gen, endpoint->setup.index);
|
||||
endpoint->buffer[0] = value;
|
||||
usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1,
|
||||
NULL, NULL);
|
||||
usb_transfer_schedule_ack(endpoint->out);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
} else {
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef RAD1O
|
||||
usb_request_status_t usb_vendor_request_write_rffc5071(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
) {
|
||||
if( stage == USB_TRANSFER_STAGE_SETUP )
|
||||
{
|
||||
if( endpoint->setup.index < RFFC5071_NUM_REGS )
|
||||
{
|
||||
rffc5071_reg_write(&mixer, endpoint->setup.index, endpoint->setup.value);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
} else {
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_read_rffc5071(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
) {
|
||||
uint16_t value;
|
||||
if( stage == USB_TRANSFER_STAGE_SETUP )
|
||||
{
|
||||
if( endpoint->setup.index < RFFC5071_NUM_REGS )
|
||||
{
|
||||
value = rffc5071_reg_read(&mixer, endpoint->setup.index);
|
||||
endpoint->buffer[0] = value & 0xff;
|
||||
endpoint->buffer[1] = value >> 8;
|
||||
usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 2,
|
||||
NULL, NULL);
|
||||
usb_transfer_schedule_ack(endpoint->out);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
} else {
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
usb_request_status_t usb_vendor_request_set_clkout_enable(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
) {
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
si5351c_clkout_enable(&clock_gen, endpoint->setup.value);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_REGISTER_H__
|
||||
#define __USB_API_REGISTER_H__
|
||||
|
||||
#include <usb_type.h>
|
||||
#include <usb_request.h>
|
||||
|
||||
usb_request_status_t usb_vendor_request_write_max2837(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
);
|
||||
usb_request_status_t usb_vendor_request_read_max2837(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
);
|
||||
usb_request_status_t usb_vendor_request_write_si5351c(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
);
|
||||
usb_request_status_t usb_vendor_request_read_si5351c(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
);
|
||||
usb_request_status_t usb_vendor_request_write_rffc5071(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
);
|
||||
usb_request_status_t usb_vendor_request_read_rffc5071(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
);
|
||||
usb_request_status_t usb_vendor_request_set_clkout_enable(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
);
|
||||
|
||||
#endif /* end of include guard: __USB_API_REGISTER_H__ */
|
||||
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_spiflash.h"
|
||||
|
||||
#include "usb_queue.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <hackrf_core.h>
|
||||
|
||||
#include <w25q80bv.h>
|
||||
|
||||
/* Buffer size == spi_flash.page_len */
|
||||
uint8_t spiflash_buffer[256U];
|
||||
|
||||
usb_request_status_t usb_vendor_request_erase_spiflash(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
spi_bus_start(spi_flash.bus, &ssp_config_w25q80bv);
|
||||
w25q80bv_setup(&spi_flash);
|
||||
/* only chip erase is implemented */
|
||||
w25q80bv_chip_erase(&spi_flash);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_write_spiflash(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
uint32_t addr = 0;
|
||||
uint16_t len = 0;
|
||||
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
addr = (endpoint->setup.value << 16) | endpoint->setup.index;
|
||||
len = endpoint->setup.length;
|
||||
if ((len > spi_flash.page_len) || (addr > spi_flash.num_bytes)
|
||||
|| ((addr + len) > spi_flash.num_bytes)) {
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
} else {
|
||||
usb_transfer_schedule_block(endpoint->out, &spiflash_buffer[0], len,
|
||||
NULL, NULL);
|
||||
spi_bus_start(spi_flash.bus, &ssp_config_w25q80bv);
|
||||
w25q80bv_setup(&spi_flash);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
} else if (stage == USB_TRANSFER_STAGE_DATA) {
|
||||
addr = (endpoint->setup.value << 16) | endpoint->setup.index;
|
||||
len = endpoint->setup.length;
|
||||
/* This check is redundant but makes me feel better. */
|
||||
if ((len > spi_flash.page_len) || (addr > spi_flash.num_bytes)
|
||||
|| ((addr + len) > spi_flash.num_bytes)) {
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
} else {
|
||||
w25q80bv_program(&spi_flash, addr, len, &spiflash_buffer[0]);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
} else {
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_read_spiflash(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
uint32_t addr;
|
||||
uint16_t len;
|
||||
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP)
|
||||
{
|
||||
addr = (endpoint->setup.value << 16) | endpoint->setup.index;
|
||||
len = endpoint->setup.length;
|
||||
if ((len > spi_flash.page_len) || (addr > spi_flash.num_bytes)
|
||||
|| ((addr + len) > spi_flash.num_bytes)) {
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
} else {
|
||||
w25q80bv_read(&spi_flash, addr, len, &spiflash_buffer[0]);
|
||||
usb_transfer_schedule_block(endpoint->in, &spiflash_buffer[0], len,
|
||||
NULL, NULL);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
} else if (stage == USB_TRANSFER_STAGE_DATA)
|
||||
{
|
||||
addr = (endpoint->setup.value << 16) | endpoint->setup.index;
|
||||
len = endpoint->setup.length;
|
||||
/* This check is redundant but makes me feel better. */
|
||||
if ((len > spi_flash.page_len) || (addr > spi_flash.num_bytes)
|
||||
|| ((addr + len) > spi_flash.num_bytes))
|
||||
{
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
} else
|
||||
{
|
||||
usb_transfer_schedule_ack(endpoint->out);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
} else
|
||||
{
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_spiflash_status(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
uint8_t data[2];
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
w25q80bv_get_full_status(&spi_flash, data);
|
||||
usb_transfer_schedule_block(endpoint->in, &data, 2, NULL, NULL);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
} else if (stage == USB_TRANSFER_STAGE_DATA) {
|
||||
usb_transfer_schedule_ack(endpoint->out);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
} else {
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_spiflash_clear_status(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
w25q80bv_clear_status(&spi_flash);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_SPIFLASH_H__
|
||||
#define __USB_API_SPIFLASH_H__
|
||||
|
||||
#include <usb_type.h>
|
||||
#include <usb_request.h>
|
||||
|
||||
usb_request_status_t usb_vendor_request_erase_spiflash(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_write_spiflash(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_read_spiflash(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_spiflash_status(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_spiflash_clear_status(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
|
||||
#endif /* end of include guard: __USB_API_SPIFLASH_H__ */
|
||||
@ -0,0 +1,167 @@
|
||||
/*
|
||||
* 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_sweep.h"
|
||||
#include "usb_queue.h"
|
||||
#include <stddef.h>
|
||||
#include <hackrf_core.h>
|
||||
#include "usb_api_transceiver.h"
|
||||
#include "usb_bulk_buffer.h"
|
||||
#include "tuning.h"
|
||||
#include "usb_endpoint.h"
|
||||
#include "streaming.h"
|
||||
|
||||
#include <libopencm3/lpc43xx/m4/nvic.h>
|
||||
|
||||
#define MIN(x,y) ((x)<(y)?(x):(y))
|
||||
#define MAX(x,y) ((x)>(y)?(x):(y))
|
||||
#define FREQ_GRANULARITY 1000000
|
||||
#define MAX_RANGES 10
|
||||
#define THROWAWAY_BUFFERS 2
|
||||
|
||||
static uint64_t sweep_freq;
|
||||
static uint16_t frequencies[MAX_RANGES * 2];
|
||||
static unsigned char data[9 + MAX_RANGES * 2 * sizeof(frequencies[0])];
|
||||
static uint16_t num_ranges = 0;
|
||||
static uint32_t dwell_blocks = 0;
|
||||
static uint32_t step_width = 0;
|
||||
static uint32_t offset = 0;
|
||||
static enum sweep_style style = LINEAR;
|
||||
|
||||
/* Do this before starting sweep mode with set_transceiver_mode(). */
|
||||
usb_request_status_t usb_vendor_request_init_sweep(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
uint32_t num_bytes;
|
||||
int i;
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
num_bytes = (endpoint->setup.index << 16) | endpoint->setup.value;
|
||||
dwell_blocks = num_bytes / 0x4000;
|
||||
if(1 > dwell_blocks) {
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
}
|
||||
num_ranges = (endpoint->setup.length - 9) / (2 * sizeof(frequencies[0]));
|
||||
if((1 > num_ranges) || (MAX_RANGES < num_ranges)) {
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
}
|
||||
usb_transfer_schedule_block(endpoint->out, &data,
|
||||
endpoint->setup.length, NULL, NULL);
|
||||
} else if (stage == USB_TRANSFER_STAGE_DATA) {
|
||||
step_width = ((uint32_t)(data[3]) << 24) | ((uint32_t)(data[2]) << 16)
|
||||
| ((uint32_t)(data[1]) << 8) | data[0];
|
||||
if(1 > step_width) {
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
}
|
||||
offset = ((uint32_t)(data[7]) << 24) | ((uint32_t)(data[6]) << 16)
|
||||
| ((uint32_t)(data[5]) << 8) | data[4];
|
||||
style = data[8];
|
||||
if(INTERLEAVED < style) {
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
}
|
||||
for(i=0; i<(num_ranges*2); i++) {
|
||||
frequencies[i] = ((uint16_t)(data[10+i*2]) << 8) + data[9+i*2];
|
||||
}
|
||||
sweep_freq = (uint64_t)frequencies[0] * FREQ_GRANULARITY;
|
||||
set_freq(sweep_freq + offset);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
|
||||
void sweep_mode(void) {
|
||||
unsigned int blocks_queued = 0;
|
||||
unsigned int phase = 1;
|
||||
bool odd = true;
|
||||
uint16_t range = 0;
|
||||
|
||||
uint8_t *buffer;
|
||||
bool transfer = false;
|
||||
|
||||
baseband_streaming_enable(&sgpio_config);
|
||||
|
||||
while (TRANSCEIVER_MODE_RX_SWEEP == transceiver_mode()) {
|
||||
// Set up IN transfer of buffer 0.
|
||||
if ( usb_bulk_buffer_offset >= 16384 && phase == 1) {
|
||||
transfer = true;
|
||||
buffer = &usb_bulk_buffer[0x0000];
|
||||
phase = 0;
|
||||
blocks_queued++;
|
||||
}
|
||||
|
||||
// Set up IN transfer of buffer 1.
|
||||
if ( usb_bulk_buffer_offset < 16384 && phase == 0) {
|
||||
transfer = true;
|
||||
buffer = &usb_bulk_buffer[0x4000];
|
||||
phase = 1;
|
||||
blocks_queued++;
|
||||
}
|
||||
|
||||
if (transfer) {
|
||||
*buffer = 0x7f;
|
||||
*(buffer+1) = 0x7f;
|
||||
*(buffer+2) = sweep_freq & 0xff;
|
||||
*(buffer+3) = (sweep_freq >> 8) & 0xff;
|
||||
*(buffer+4) = (sweep_freq >> 16) & 0xff;
|
||||
*(buffer+5) = (sweep_freq >> 24) & 0xff;
|
||||
*(buffer+6) = (sweep_freq >> 32) & 0xff;
|
||||
*(buffer+7) = (sweep_freq >> 40) & 0xff;
|
||||
*(buffer+8) = (sweep_freq >> 48) & 0xff;
|
||||
*(buffer+9) = (sweep_freq >> 56) & 0xff;
|
||||
if (blocks_queued > THROWAWAY_BUFFERS) {
|
||||
usb_transfer_schedule_block(
|
||||
&usb_endpoint_bulk_in,
|
||||
buffer,
|
||||
0x4000,
|
||||
NULL, NULL
|
||||
);
|
||||
}
|
||||
transfer = false;
|
||||
}
|
||||
|
||||
if ((dwell_blocks + THROWAWAY_BUFFERS) <= blocks_queued) {
|
||||
if(INTERLEAVED == style) {
|
||||
if(!odd && ((sweep_freq + step_width) >= ((uint64_t)frequencies[1+range*2] * FREQ_GRANULARITY))) {
|
||||
range = (range + 1) % num_ranges;
|
||||
sweep_freq = (uint64_t)frequencies[range*2] * FREQ_GRANULARITY;
|
||||
} else {
|
||||
if(odd) {
|
||||
sweep_freq += step_width/4;
|
||||
} else {
|
||||
sweep_freq += 3*step_width/4;
|
||||
}
|
||||
}
|
||||
odd = !odd;
|
||||
} else {
|
||||
if((sweep_freq + step_width) >= ((uint64_t)frequencies[1+range*2] * FREQ_GRANULARITY)) {
|
||||
range = (range + 1) % num_ranges;
|
||||
sweep_freq = (uint64_t)frequencies[range*2] * FREQ_GRANULARITY;
|
||||
} else {
|
||||
sweep_freq += step_width;
|
||||
}
|
||||
}
|
||||
|
||||
nvic_disable_irq(NVIC_USB0_IRQ);
|
||||
set_freq(sweep_freq + offset);
|
||||
nvic_enable_irq(NVIC_USB0_IRQ);
|
||||
blocks_queued = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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_SWEEP_H__
|
||||
#define __USB_API_SWEEP_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <usb_type.h>
|
||||
#include <usb_request.h>
|
||||
|
||||
enum sweep_style {
|
||||
LINEAR = 0,
|
||||
INTERLEAVED = 1,
|
||||
};
|
||||
|
||||
usb_request_status_t usb_vendor_request_init_sweep(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
|
||||
void sweep_mode(void);
|
||||
|
||||
#endif /* __USB_API_SWEEP_H__ */
|
||||
@ -0,0 +1,388 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_transceiver.h"
|
||||
|
||||
#include "hackrf_ui.h"
|
||||
#include <libopencm3/cm3/vector.h>
|
||||
#include "usb_bulk_buffer.h"
|
||||
|
||||
#include "usb_api_cpld.h" // Remove when CPLD update is handled elsewhere
|
||||
|
||||
#include <max2837.h>
|
||||
#include <rf_path.h>
|
||||
#include <tuning.h>
|
||||
#include <streaming.h>
|
||||
#include <usb.h>
|
||||
#include <usb_queue.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "usb_endpoint.h"
|
||||
#include "usb_api_sweep.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t freq_mhz;
|
||||
uint32_t freq_hz;
|
||||
} set_freq_params_t;
|
||||
|
||||
set_freq_params_t set_freq_params;
|
||||
|
||||
struct set_freq_explicit_params {
|
||||
uint64_t if_freq_hz; /* intermediate frequency */
|
||||
uint64_t lo_freq_hz; /* front-end local oscillator frequency */
|
||||
uint8_t path; /* image rejection filter path */
|
||||
};
|
||||
|
||||
struct set_freq_explicit_params explicit_params;
|
||||
|
||||
typedef struct {
|
||||
uint32_t freq_hz;
|
||||
uint32_t divider;
|
||||
} set_sample_r_params_t;
|
||||
|
||||
set_sample_r_params_t set_sample_r_params;
|
||||
|
||||
usb_request_status_t usb_vendor_request_set_baseband_filter_bandwidth(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
) {
|
||||
if( stage == USB_TRANSFER_STAGE_SETUP ) {
|
||||
const uint32_t bandwidth = (endpoint->setup.index << 16) | endpoint->setup.value;
|
||||
if( baseband_filter_bandwidth_set(bandwidth) ) {
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
} else {
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_set_freq(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage)
|
||||
{
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP)
|
||||
{
|
||||
usb_transfer_schedule_block(endpoint->out, &set_freq_params, sizeof(set_freq_params_t),
|
||||
NULL, NULL);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
} else if (stage == USB_TRANSFER_STAGE_DATA)
|
||||
{
|
||||
const uint64_t freq = set_freq_params.freq_mhz * 1000000ULL + set_freq_params.freq_hz;
|
||||
if( set_freq(freq) )
|
||||
{
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
} else
|
||||
{
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_set_sample_rate_frac(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage)
|
||||
{
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP)
|
||||
{
|
||||
usb_transfer_schedule_block(endpoint->out, &set_sample_r_params, sizeof(set_sample_r_params_t),
|
||||
NULL, NULL);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
} else if (stage == USB_TRANSFER_STAGE_DATA)
|
||||
{
|
||||
if( sample_rate_frac_set(set_sample_r_params.freq_hz * 2, set_sample_r_params.divider ) )
|
||||
{
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
} else
|
||||
{
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_set_amp_enable(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
switch (endpoint->setup.value) {
|
||||
case 0:
|
||||
rf_path_set_lna(&rf_path, 0);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
case 1:
|
||||
rf_path_set_lna(&rf_path, 1);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
default:
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
}
|
||||
} else {
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_set_lna_gain(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage)
|
||||
{
|
||||
if( stage == USB_TRANSFER_STAGE_SETUP ) {
|
||||
const uint8_t value = max2837_set_lna_gain(&max2837, endpoint->setup.index);
|
||||
endpoint->buffer[0] = value;
|
||||
if(value) hackrf_ui()->set_bb_lna_gain(endpoint->setup.index);
|
||||
usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1,
|
||||
NULL, NULL);
|
||||
usb_transfer_schedule_ack(endpoint->out);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_set_vga_gain(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
if( stage == USB_TRANSFER_STAGE_SETUP ) {
|
||||
const uint8_t value = max2837_set_vga_gain(&max2837, endpoint->setup.index);
|
||||
endpoint->buffer[0] = value;
|
||||
if(value) hackrf_ui()->set_bb_vga_gain(endpoint->setup.index);
|
||||
usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1,
|
||||
NULL, NULL);
|
||||
usb_transfer_schedule_ack(endpoint->out);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_set_txvga_gain(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
if( stage == USB_TRANSFER_STAGE_SETUP ) {
|
||||
const uint8_t value = max2837_set_txvga_gain(&max2837, endpoint->setup.index);
|
||||
endpoint->buffer[0] = value;
|
||||
if(value) hackrf_ui()->set_bb_tx_vga_gain(endpoint->setup.index);
|
||||
usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1,
|
||||
NULL, NULL);
|
||||
usb_transfer_schedule_ack(endpoint->out);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_set_antenna_enable(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
switch (endpoint->setup.value) {
|
||||
case 0:
|
||||
rf_path_set_antenna(&rf_path, 0);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
case 1:
|
||||
rf_path_set_antenna(&rf_path, 1);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
default:
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
}
|
||||
} else {
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_set_freq_explicit(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage)
|
||||
{
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
usb_transfer_schedule_block(endpoint->out, &explicit_params,
|
||||
sizeof(struct set_freq_explicit_params), NULL, NULL);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
} else if (stage == USB_TRANSFER_STAGE_DATA) {
|
||||
if (set_freq_explicit(explicit_params.if_freq_hz,
|
||||
explicit_params.lo_freq_hz, explicit_params.path)) {
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
} else {
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
static volatile transceiver_mode_t _transceiver_mode = TRANSCEIVER_MODE_OFF;
|
||||
static volatile hw_sync_mode_t _hw_sync_mode = HW_SYNC_MODE_OFF;
|
||||
|
||||
void set_hw_sync_mode(const hw_sync_mode_t new_hw_sync_mode) {
|
||||
_hw_sync_mode = new_hw_sync_mode;
|
||||
}
|
||||
|
||||
transceiver_mode_t transceiver_mode(void) {
|
||||
return _transceiver_mode;
|
||||
}
|
||||
|
||||
void set_transceiver_mode(const transceiver_mode_t new_transceiver_mode) {
|
||||
baseband_streaming_disable(&sgpio_config);
|
||||
|
||||
usb_endpoint_flush(&usb_endpoint_bulk_in);
|
||||
usb_endpoint_flush(&usb_endpoint_bulk_out);
|
||||
|
||||
_transceiver_mode = new_transceiver_mode;
|
||||
|
||||
switch (_transceiver_mode) {
|
||||
case TRANSCEIVER_MODE_RX_SWEEP:
|
||||
case TRANSCEIVER_MODE_RX:
|
||||
led_off(LED3);
|
||||
led_on(LED2);
|
||||
rf_path_set_direction(&rf_path, RF_PATH_DIRECTION_RX);
|
||||
usb_bulk_buffer_tx = false;
|
||||
break;
|
||||
case TRANSCEIVER_MODE_TX:
|
||||
led_off(LED2);
|
||||
led_on(LED3);
|
||||
rf_path_set_direction(&rf_path, RF_PATH_DIRECTION_TX);
|
||||
usb_bulk_buffer_tx = true;
|
||||
break;
|
||||
case TRANSCEIVER_MODE_OFF:
|
||||
default:
|
||||
led_off(LED2);
|
||||
led_off(LED3);
|
||||
rf_path_set_direction(&rf_path, RF_PATH_DIRECTION_OFF);
|
||||
usb_bulk_buffer_tx = false;
|
||||
}
|
||||
|
||||
|
||||
if( _transceiver_mode != TRANSCEIVER_MODE_OFF ) {
|
||||
activate_best_clock_source();
|
||||
|
||||
hw_sync_enable(_hw_sync_mode);
|
||||
|
||||
usb_bulk_buffer_offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_set_transceiver_mode(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage)
|
||||
{
|
||||
if( stage == USB_TRANSFER_STAGE_SETUP ) {
|
||||
switch( endpoint->setup.value ) {
|
||||
case TRANSCEIVER_MODE_OFF:
|
||||
case TRANSCEIVER_MODE_RX:
|
||||
case TRANSCEIVER_MODE_TX:
|
||||
case TRANSCEIVER_MODE_RX_SWEEP:
|
||||
case TRANSCEIVER_MODE_CPLD_UPDATE:
|
||||
set_transceiver_mode(endpoint->setup.value);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
default:
|
||||
return USB_REQUEST_STATUS_STALL;
|
||||
}
|
||||
} else {
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_set_hw_sync_mode(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage)
|
||||
{
|
||||
if( stage == USB_TRANSFER_STAGE_SETUP ) {
|
||||
set_hw_sync_mode(endpoint->setup.value);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
} else {
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
void rx_mode(void) {
|
||||
unsigned int phase = 1;
|
||||
|
||||
baseband_streaming_enable(&sgpio_config);
|
||||
|
||||
while (TRANSCEIVER_MODE_RX == _transceiver_mode) {
|
||||
// Set up IN transfer of buffer 0.
|
||||
if (16384 <= usb_bulk_buffer_offset && 1 == phase) {
|
||||
usb_transfer_schedule_block(
|
||||
&usb_endpoint_bulk_in,
|
||||
&usb_bulk_buffer[0x0000],
|
||||
0x4000,
|
||||
NULL, NULL
|
||||
);
|
||||
phase = 0;
|
||||
}
|
||||
// Set up IN transfer of buffer 1.
|
||||
if (16384 > usb_bulk_buffer_offset && 0 == phase) {
|
||||
usb_transfer_schedule_block(
|
||||
&usb_endpoint_bulk_in,
|
||||
&usb_bulk_buffer[0x4000],
|
||||
0x4000,
|
||||
NULL, NULL
|
||||
);
|
||||
phase = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tx_mode(void) {
|
||||
unsigned int phase = 1;
|
||||
|
||||
memset(&usb_bulk_buffer[0x0000], 0, 0x8000);
|
||||
// Set up OUT transfer of buffer 1.
|
||||
usb_transfer_schedule_block(
|
||||
&usb_endpoint_bulk_out,
|
||||
&usb_bulk_buffer[0x4000],
|
||||
0x4000,
|
||||
NULL, NULL
|
||||
);
|
||||
// Start transmitting zeros while the host fills buffer 1.
|
||||
baseband_streaming_enable(&sgpio_config);
|
||||
|
||||
while (TRANSCEIVER_MODE_TX == _transceiver_mode) {
|
||||
// Set up OUT transfer of buffer 0.
|
||||
if (16384 <= usb_bulk_buffer_offset && 1 == phase) {
|
||||
usb_transfer_schedule_block(
|
||||
&usb_endpoint_bulk_out,
|
||||
&usb_bulk_buffer[0x0000],
|
||||
0x4000,
|
||||
NULL, NULL
|
||||
);
|
||||
phase = 0;
|
||||
}
|
||||
// Set up OUT transfer of buffer 1.
|
||||
if (16384 > usb_bulk_buffer_offset && 0 == phase) {
|
||||
usb_transfer_schedule_block(
|
||||
&usb_endpoint_bulk_out,
|
||||
&usb_bulk_buffer[0x4000],
|
||||
0x4000,
|
||||
NULL, NULL
|
||||
);
|
||||
phase = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_TRANSCEIVER_H__
|
||||
#define __USB_API_TRANSCEIVER_H__
|
||||
|
||||
#include <hackrf_core.h>
|
||||
#include <usb_type.h>
|
||||
#include <usb_request.h>
|
||||
|
||||
void set_hw_sync_mode(const hw_sync_mode_t new_hw_sync_mode);
|
||||
usb_request_status_t usb_vendor_request_set_transceiver_mode(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_set_baseband_filter_bandwidth(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_set_freq(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_set_sample_rate_frac(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_set_amp_enable(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_set_lna_gain(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_set_vga_gain(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_set_txvga_gain(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_set_antenna_enable(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_set_freq_explicit(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_set_hw_sync_mode(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage);
|
||||
|
||||
transceiver_mode_t transceiver_mode(void);
|
||||
void set_transceiver_mode(const transceiver_mode_t new_transceiver_mode);
|
||||
void start_streaming_on_hw_sync();
|
||||
void rx_mode(void);
|
||||
void tx_mode(void);
|
||||
|
||||
#endif/*__USB_API_TRANSCEIVER_H__*/
|
||||
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2020 Mike Walters
|
||||
*
|
||||
* 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_ui.h"
|
||||
|
||||
#include <hackrf_core.h>
|
||||
#include <hackrf_ui.h>
|
||||
#include <usb_queue.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
usb_request_status_t usb_vendor_request_set_ui_enable(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
) {
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
hackrf_ui_set_enable(endpoint->setup.value);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2020 Mike Walters
|
||||
*
|
||||
* 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_UI_H__
|
||||
#define __USB_API_UI_H__
|
||||
|
||||
#include <usb_type.h>
|
||||
#include <usb_request.h>
|
||||
|
||||
usb_request_status_t usb_vendor_request_set_ui_enable(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage
|
||||
);
|
||||
|
||||
#endif /* end of include guard: __USB_API_UI_H__ */
|
||||
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_bulk_buffer.h"
|
||||
|
||||
volatile uint32_t usb_bulk_buffer_offset = 0;
|
||||
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_BULK_BUFFER_H__
|
||||
#define __USB_BULK_BUFFER_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* Address of usb_bulk_buffer is set in ldscripts. If you change the name of this
|
||||
* variable, it won't be where it needs to be in the processor's address space,
|
||||
* unless you also adjust the ldscripts.
|
||||
*/
|
||||
extern uint8_t usb_bulk_buffer[32768];
|
||||
|
||||
extern volatile uint32_t usb_bulk_buffer_offset;
|
||||
|
||||
extern bool usb_bulk_buffer_tx;
|
||||
|
||||
#endif/*__USB_BULK_BUFFER_H__*/
|
||||
@ -0,0 +1,313 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
|
||||
#include "usb_type.h"
|
||||
#include "usb_descriptor.h"
|
||||
|
||||
#define USB_VENDOR_ID (0x1D50)
|
||||
|
||||
#ifdef HACKRF_ONE
|
||||
#define USB_PRODUCT_ID (0x6089)
|
||||
#elif JAWBREAKER
|
||||
#define USB_PRODUCT_ID (0x604B)
|
||||
#elif RAD1O
|
||||
#define USB_PRODUCT_ID (0xCC15)
|
||||
#else
|
||||
#define USB_PRODUCT_ID (0xFFFF)
|
||||
#endif
|
||||
|
||||
#define USB_API_VERSION (0x0104)
|
||||
|
||||
#define USB_WORD(x) (x & 0xFF), ((x >> 8) & 0xFF)
|
||||
|
||||
#define USB_MAX_PACKET0 (64)
|
||||
#define USB_MAX_PACKET_BULK_FS (64)
|
||||
#define USB_MAX_PACKET_BULK_HS (512)
|
||||
|
||||
#define USB_BULK_IN_EP_ADDR (0x81)
|
||||
#define USB_BULK_OUT_EP_ADDR (0x02)
|
||||
|
||||
#define USB_STRING_LANGID (0x0409)
|
||||
|
||||
uint8_t usb_descriptor_device[] = {
|
||||
18, // bLength
|
||||
USB_DESCRIPTOR_TYPE_DEVICE, // bDescriptorType
|
||||
USB_WORD(0x0200), // bcdUSB
|
||||
0x00, // bDeviceClass
|
||||
0x00, // bDeviceSubClass
|
||||
0x00, // bDeviceProtocol
|
||||
USB_MAX_PACKET0, // bMaxPacketSize0
|
||||
USB_WORD(USB_VENDOR_ID), // idVendor
|
||||
USB_WORD(USB_PRODUCT_ID), // idProduct
|
||||
USB_WORD(USB_API_VERSION), // bcdDevice
|
||||
0x01, // iManufacturer
|
||||
0x02, // iProduct
|
||||
0x04, // iSerialNumber
|
||||
0x01 // bNumConfigurations
|
||||
};
|
||||
|
||||
uint8_t usb_descriptor_device_qualifier[] = {
|
||||
10, // bLength
|
||||
USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER, // bDescriptorType
|
||||
USB_WORD(0x0200), // bcdUSB
|
||||
0x00, // bDeviceClass
|
||||
0x00, // bDeviceSubClass
|
||||
0x00, // bDeviceProtocol
|
||||
64, // bMaxPacketSize0
|
||||
0x01, // bNumOtherSpeedConfigurations
|
||||
0x00 // bReserved
|
||||
};
|
||||
|
||||
uint8_t usb_descriptor_configuration_full_speed[] = {
|
||||
9, // bLength
|
||||
USB_DESCRIPTOR_TYPE_CONFIGURATION, // bDescriptorType
|
||||
USB_WORD(32), // wTotalLength
|
||||
0x01, // bNumInterfaces
|
||||
0x01, // bConfigurationValue
|
||||
0x03, // iConfiguration
|
||||
0x80, // bmAttributes: USB-powered
|
||||
250, // bMaxPower: 500mA
|
||||
|
||||
9, // bLength
|
||||
USB_DESCRIPTOR_TYPE_INTERFACE, // bDescriptorType
|
||||
0x00, // bInterfaceNumber
|
||||
0x00, // bAlternateSetting
|
||||
0x02, // bNumEndpoints
|
||||
0xFF, // bInterfaceClass: vendor-specific
|
||||
0xFF, // bInterfaceSubClass
|
||||
0xFF, // bInterfaceProtocol: vendor-specific
|
||||
0x00, // iInterface
|
||||
|
||||
7, // bLength
|
||||
USB_DESCRIPTOR_TYPE_ENDPOINT, // bDescriptorType
|
||||
USB_BULK_IN_EP_ADDR, // bEndpointAddress
|
||||
0x02, // bmAttributes: BULK
|
||||
USB_WORD(USB_MAX_PACKET_BULK_FS), // wMaxPacketSize
|
||||
0x00, // bInterval: no NAK
|
||||
|
||||
7, // bLength
|
||||
USB_DESCRIPTOR_TYPE_ENDPOINT, // bDescriptorType
|
||||
USB_BULK_OUT_EP_ADDR, // bEndpointAddress
|
||||
0x02, // bmAttributes: BULK
|
||||
USB_WORD(USB_MAX_PACKET_BULK_FS), // wMaxPacketSize
|
||||
0x00, // bInterval: no NAK
|
||||
|
||||
0, // TERMINATOR
|
||||
};
|
||||
|
||||
uint8_t usb_descriptor_configuration_high_speed[] = {
|
||||
9, // bLength
|
||||
USB_DESCRIPTOR_TYPE_CONFIGURATION, // bDescriptorType
|
||||
USB_WORD(32), // wTotalLength
|
||||
0x01, // bNumInterfaces
|
||||
0x01, // bConfigurationValue
|
||||
0x03, // iConfiguration
|
||||
0x80, // bmAttributes: USB-powered
|
||||
250, // bMaxPower: 500mA
|
||||
|
||||
9, // bLength
|
||||
USB_DESCRIPTOR_TYPE_INTERFACE, // bDescriptorType
|
||||
0x00, // bInterfaceNumber
|
||||
0x00, // bAlternateSetting
|
||||
0x02, // bNumEndpoints
|
||||
0xFF, // bInterfaceClass: vendor-specific
|
||||
0xFF, // bInterfaceSubClass
|
||||
0xFF, // bInterfaceProtocol: vendor-specific
|
||||
0x00, // iInterface
|
||||
|
||||
7, // bLength
|
||||
USB_DESCRIPTOR_TYPE_ENDPOINT, // bDescriptorType
|
||||
USB_BULK_IN_EP_ADDR, // bEndpointAddress
|
||||
0x02, // bmAttributes: BULK
|
||||
USB_WORD(USB_MAX_PACKET_BULK_HS), // wMaxPacketSize
|
||||
0x00, // bInterval: no NAK
|
||||
|
||||
7, // bLength
|
||||
USB_DESCRIPTOR_TYPE_ENDPOINT, // bDescriptorType
|
||||
USB_BULK_OUT_EP_ADDR, // bEndpointAddress
|
||||
0x02, // bmAttributes: BULK
|
||||
USB_WORD(USB_MAX_PACKET_BULK_HS), // wMaxPacketSize
|
||||
0x00, // bInterval: no NAK
|
||||
|
||||
0, // TERMINATOR
|
||||
};
|
||||
|
||||
|
||||
uint8_t usb_descriptor_string_languages[] = {
|
||||
0x04, // bLength
|
||||
USB_DESCRIPTOR_TYPE_STRING, // bDescriptorType
|
||||
USB_WORD(USB_STRING_LANGID), // wLANGID
|
||||
};
|
||||
|
||||
uint8_t usb_descriptor_string_manufacturer[] = {
|
||||
40, // bLength
|
||||
USB_DESCRIPTOR_TYPE_STRING, // bDescriptorType
|
||||
'G', 0x00,
|
||||
'r', 0x00,
|
||||
'e', 0x00,
|
||||
'a', 0x00,
|
||||
't', 0x00,
|
||||
' ', 0x00,
|
||||
'S', 0x00,
|
||||
'c', 0x00,
|
||||
'o', 0x00,
|
||||
't', 0x00,
|
||||
't', 0x00,
|
||||
' ', 0x00,
|
||||
'G', 0x00,
|
||||
'a', 0x00,
|
||||
'd', 0x00,
|
||||
'g', 0x00,
|
||||
'e', 0x00,
|
||||
't', 0x00,
|
||||
's', 0x00,
|
||||
};
|
||||
|
||||
uint8_t usb_descriptor_string_product[] = {
|
||||
#ifdef HACKRF_ONE
|
||||
22, // bLength
|
||||
USB_DESCRIPTOR_TYPE_STRING, // bDescriptorType
|
||||
'H', 0x00,
|
||||
'a', 0x00,
|
||||
'c', 0x00,
|
||||
'k', 0x00,
|
||||
'R', 0x00,
|
||||
'F', 0x00,
|
||||
' ', 0x00,
|
||||
'O', 0x00,
|
||||
'n', 0x00,
|
||||
'e', 0x00,
|
||||
#elif JAWBREAKER
|
||||
36, // bLength
|
||||
USB_DESCRIPTOR_TYPE_STRING, // bDescriptorType
|
||||
'H', 0x00,
|
||||
'a', 0x00,
|
||||
'c', 0x00,
|
||||
'k', 0x00,
|
||||
'R', 0x00,
|
||||
'F', 0x00,
|
||||
' ', 0x00,
|
||||
'J', 0x00,
|
||||
'a', 0x00,
|
||||
'w', 0x00,
|
||||
'b', 0x00,
|
||||
'r', 0x00,
|
||||
'e', 0x00,
|
||||
'a', 0x00,
|
||||
'k', 0x00,
|
||||
'e', 0x00,
|
||||
'r', 0x00,
|
||||
#elif RAD1O
|
||||
12, // bLength
|
||||
USB_DESCRIPTOR_TYPE_STRING, // bDescriptorType
|
||||
'r', 0x00,
|
||||
'a', 0x00,
|
||||
'd', 0x00,
|
||||
'1', 0x00,
|
||||
'o', 0x00,
|
||||
#else
|
||||
14, // bLength
|
||||
USB_DESCRIPTOR_TYPE_STRING, // bDescriptorType
|
||||
'H', 0x00,
|
||||
'a', 0x00,
|
||||
'c', 0x00,
|
||||
'k', 0x00,
|
||||
'R', 0x00,
|
||||
'F', 0x00,
|
||||
#endif
|
||||
};
|
||||
|
||||
uint8_t usb_descriptor_string_config_description[] = {
|
||||
24, // bLength
|
||||
USB_DESCRIPTOR_TYPE_STRING, // bDescriptorType
|
||||
'T', 0x00,
|
||||
'r', 0x00,
|
||||
'a', 0x00,
|
||||
'n', 0x00,
|
||||
's', 0x00,
|
||||
'c', 0x00,
|
||||
'e', 0x00,
|
||||
'i', 0x00,
|
||||
'v', 0x00,
|
||||
'e', 0x00,
|
||||
'r', 0x00,
|
||||
};
|
||||
|
||||
#ifdef DFU_MODE
|
||||
uint8_t usb_descriptor_string_serial_number[] = {
|
||||
30, // bLength
|
||||
USB_DESCRIPTOR_TYPE_STRING, // bDescriptorType
|
||||
'R', 0x00,
|
||||
'u', 0x00,
|
||||
'n', 0x00,
|
||||
'n', 0x00,
|
||||
'i', 0x00,
|
||||
'n', 0x00,
|
||||
'g', 0x00,
|
||||
'F', 0x00,
|
||||
'r', 0x00,
|
||||
'o', 0x00,
|
||||
'm', 0x00,
|
||||
'R', 0x00,
|
||||
'A', 0x00,
|
||||
'M', 0x00,
|
||||
};
|
||||
#else
|
||||
uint8_t usb_descriptor_string_serial_number[USB_DESCRIPTOR_STRING_SERIAL_BUF_LEN];
|
||||
#endif
|
||||
|
||||
uint8_t* usb_descriptor_strings[] = {
|
||||
usb_descriptor_string_languages,
|
||||
usb_descriptor_string_manufacturer,
|
||||
usb_descriptor_string_product,
|
||||
usb_descriptor_string_config_description,
|
||||
usb_descriptor_string_serial_number,
|
||||
0, // TERMINATOR
|
||||
};
|
||||
|
||||
uint8_t wcid_string_descriptor[] = {
|
||||
18, // bLength
|
||||
USB_DESCRIPTOR_TYPE_STRING, // bDescriptorType
|
||||
'M', 0x00,
|
||||
'S', 0x00,
|
||||
'F', 0x00,
|
||||
'T', 0x00,
|
||||
'1', 0x00,
|
||||
'0', 0x00,
|
||||
'0', 0x00,
|
||||
USB_WCID_VENDOR_REQ, // vendor request code for further descriptor
|
||||
0x00
|
||||
};
|
||||
|
||||
uint8_t wcid_feature_descriptor[] = {
|
||||
0x28, 0x00, 0x00, 0x00, // bLength
|
||||
USB_WORD(0x0100), // WCID version
|
||||
USB_WORD(0x0004), // WICD descriptor index
|
||||
0x01, //bNumSections
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00, //Reserved
|
||||
0x00, //bInterfaceNumber
|
||||
0x01, //Reserved
|
||||
'W', 'I', 'N', 'U', 'S', 'B', 0x00,0x00, //Compatible ID, padded with zeros
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //Sub-compatible ID
|
||||
0x00,0x00,0x00,0x00,0x00,0x00 //Reserved
|
||||
};
|
||||
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
|
||||
extern uint8_t usb_descriptor_device[];
|
||||
extern uint8_t usb_descriptor_device_qualifier[];
|
||||
extern uint8_t usb_descriptor_configuration_full_speed[];
|
||||
extern uint8_t usb_descriptor_configuration_high_speed[];
|
||||
extern uint8_t usb_descriptor_string_languages[];
|
||||
extern uint8_t usb_descriptor_string_manufacturer[];
|
||||
extern uint8_t usb_descriptor_string_product[];
|
||||
|
||||
#define USB_DESCRIPTOR_STRING_SERIAL_LEN 32
|
||||
#define USB_DESCRIPTOR_STRING_SERIAL_BUF_LEN (USB_DESCRIPTOR_STRING_SERIAL_LEN*2 + 2) /* UTF-16LE */
|
||||
extern uint8_t usb_descriptor_string_serial_number[];
|
||||
|
||||
extern uint8_t* usb_descriptor_strings[];
|
||||
|
||||
#define USB_WCID_VENDOR_REQ 0x19
|
||||
extern uint8_t wcid_string_descriptor[];
|
||||
extern uint8_t wcid_feature_descriptor[];
|
||||
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_device.h"
|
||||
|
||||
#include <usb_type.h>
|
||||
|
||||
#include "usb_descriptor.h"
|
||||
|
||||
usb_configuration_t usb_configuration_high_speed = {
|
||||
.number = 1,
|
||||
.speed = USB_SPEED_HIGH,
|
||||
.descriptor = usb_descriptor_configuration_high_speed,
|
||||
};
|
||||
|
||||
usb_configuration_t usb_configuration_full_speed = {
|
||||
.number = 1,
|
||||
.speed = USB_SPEED_FULL,
|
||||
.descriptor = usb_descriptor_configuration_full_speed,
|
||||
};
|
||||
|
||||
|
||||
usb_configuration_t* usb_configurations[] = {
|
||||
&usb_configuration_high_speed,
|
||||
&usb_configuration_full_speed,
|
||||
0,
|
||||
};
|
||||
|
||||
usb_device_t usb_device = {
|
||||
.descriptor = usb_descriptor_device,
|
||||
.descriptor_strings = usb_descriptor_strings,
|
||||
.qualifier_descriptor = usb_descriptor_device_qualifier,
|
||||
.configurations = &usb_configurations,
|
||||
.configuration = 0,
|
||||
.wcid_string_descriptor = wcid_string_descriptor,
|
||||
.wcid_feature_descriptor = wcid_feature_descriptor,
|
||||
};
|
||||
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_DEVICE_H__
|
||||
#define __USB_DEVICE_H__
|
||||
|
||||
#include <usb_type.h>
|
||||
|
||||
extern usb_device_t usb_device;
|
||||
|
||||
#endif /* end of include guard: __USB_DEVICE_H__ */
|
||||
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_endpoint.h"
|
||||
|
||||
#include <usb_request.h>
|
||||
|
||||
#include "usb_device.h"
|
||||
|
||||
usb_endpoint_t usb_endpoint_control_out = {
|
||||
.address = 0x00,
|
||||
.device = &usb_device,
|
||||
.in = &usb_endpoint_control_in,
|
||||
.out = &usb_endpoint_control_out,
|
||||
.setup_complete = usb_setup_complete,
|
||||
.transfer_complete = usb_control_out_complete,
|
||||
};
|
||||
USB_DEFINE_QUEUE(usb_endpoint_control_out, 4);
|
||||
|
||||
usb_endpoint_t usb_endpoint_control_in = {
|
||||
.address = 0x80,
|
||||
.device = &usb_device,
|
||||
.in = &usb_endpoint_control_in,
|
||||
.out = &usb_endpoint_control_out,
|
||||
.setup_complete = 0,
|
||||
.transfer_complete = usb_control_in_complete,
|
||||
};
|
||||
static USB_DEFINE_QUEUE(usb_endpoint_control_in, 4);
|
||||
|
||||
// NOTE: Endpoint number for IN and OUT are different. I wish I had some
|
||||
// evidence that having BULK IN and OUT on separate endpoint numbers was
|
||||
// actually a good idea. Seems like everybody does it that way, but why?
|
||||
|
||||
usb_endpoint_t usb_endpoint_bulk_in = {
|
||||
.address = 0x81,
|
||||
.device = &usb_device,
|
||||
.in = &usb_endpoint_bulk_in,
|
||||
.out = 0,
|
||||
.setup_complete = 0,
|
||||
.transfer_complete = usb_queue_transfer_complete
|
||||
};
|
||||
static USB_DEFINE_QUEUE(usb_endpoint_bulk_in, 1);
|
||||
|
||||
usb_endpoint_t usb_endpoint_bulk_out = {
|
||||
.address = 0x02,
|
||||
.device = &usb_device,
|
||||
.in = 0,
|
||||
.out = &usb_endpoint_bulk_out,
|
||||
.setup_complete = 0,
|
||||
.transfer_complete = usb_queue_transfer_complete
|
||||
};
|
||||
static USB_DEFINE_QUEUE(usb_endpoint_bulk_out, 1);
|
||||
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
* 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_ENDPOINT_H__
|
||||
#define __USB_ENDPOINT_H__
|
||||
|
||||
#include <usb_type.h>
|
||||
#include <usb_queue.h>
|
||||
|
||||
extern usb_endpoint_t usb_endpoint_control_out;
|
||||
extern USB_DECLARE_QUEUE(usb_endpoint_control_out);
|
||||
|
||||
extern usb_endpoint_t usb_endpoint_control_in;
|
||||
extern USB_DECLARE_QUEUE(usb_endpoint_control_in);
|
||||
|
||||
extern usb_endpoint_t usb_endpoint_bulk_in;
|
||||
extern USB_DECLARE_QUEUE(usb_endpoint_bulk_in);
|
||||
|
||||
extern usb_endpoint_t usb_endpoint_bulk_out;
|
||||
extern USB_DECLARE_QUEUE(usb_endpoint_bulk_out);
|
||||
|
||||
#endif /* end of include guard: __USB_ENDPOINT_H__ */
|
||||
Reference in New Issue
Block a user