diff --git a/README.md b/README.md index ca30a25a..17498cb1 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,12 @@ This repository contains all the source code required to program and interact wi The source is organized as follows: -| Directory | Description | -| --------------- |:--------------------------------------------------------------------------------------------------| -| [common] | Source and header files common between the following components | -| [fx3_firmware] | Firmware for the Cypress FX3 USB controller | -| [hdl] | All HDL code associated with the Cyclone IV FPGA | -| [host] | Host-side libraries, drivers, utilities and samples | +| Directory | Description | +| ----------------- |:--------------------------------------------------------------------------------------------------| +| [firmware_common] | Source and header files common between firmware and host software | +| [fx3_firmware] | Firmware for the Cypress FX3 USB controller | +| [hdl] | All HDL code associated with the Cyclone IV FPGA | +| [host] | Host-side libraries, drivers, utilities and samples | ## Quick Start ## diff --git a/common/bladeRF.h b/firmware_common/bladeRF.h similarity index 100% rename from common/bladeRF.h rename to firmware_common/bladeRF.h diff --git a/fx3_firmware/bladeRF.h b/fx3_firmware/bladeRF.h index c8938df2..2a8a985f 100644 --- a/fx3_firmware/bladeRF.h +++ b/fx3_firmware/bladeRF.h @@ -4,7 +4,7 @@ #include "cyu3externcstart.h" #include "cyu3types.h" #include "cyu3usbconst.h" -#include "../common/bladeRF.h" +#include "../firmware_common/bladeRF.h" #define BLADE_GPIF_16_32BIT_CONF_SELECT (0) @@ -18,7 +18,7 @@ #define BLADE_FPGA_EP_PRODUCER 0x02 #define BLADE_FPGA_CONFIG_SOCKET CY_U3P_UIB_SOCKET_PROD_2 -// interface #1 +// interface #1 #define BLADE_RF_SAMPLE_EP_PRODUCER 0x01 #define BLADE_RF_SAMPLE_EP_PRODUCER_USB_SOCKET CY_U3P_UIB_SOCKET_PROD_1 #define BLADE_UART_EP_PRODUCER 0x02 diff --git a/fx3_firmware/make/toolchain.mk.sample b/fx3_firmware/make/toolchain.mk.sample index 07130a16..e9be3d7c 100644 --- a/fx3_firmware/make/toolchain.mk.sample +++ b/fx3_firmware/make/toolchain.mk.sample @@ -20,12 +20,12 @@ endif # are needed for make, but this doesn't fly when executing external programs # (e.g., gcc, ld) # -# This is a little hack to replace a paths with escaped spaces +# This is a little hack to replace a paths with escaped spaces # with a quoted, space-containing path. # -# If anyone has any suggestions or advice on cleaning this up, -# please feel free to make some noise over at: -# www.github.com/jynik/bladeRF +# If anyone has any suggestions or advice on cleaning this up, +# please feel free to make some noise over at: +# www.github.com/jynik/bladeRF pathfixup = $(if $(HOST_IS_WINDOWS),"$(subst /,\,$(subst \ , ,$(1)))",$(1)) # These are the items that will likely vary system to system @@ -41,7 +41,7 @@ ifdef HOST_IS_WINDOWS FX3_FW_DIR := $(FX3_ROOT)/firmware ELF2IMG_DIR := $(FX3_ROOT)/util/elf2img else - FX3_ROOT ?= /opt/cypress/fx3_sdk + FX3_ROOT ?= /home/jon/software/fx3_sdk ARMGCC_INSTALL_PATH ?= $(FX3_ROOT)/arm-2011.03 FX3_FW_DIR := $(FX3_ROOT)/cyfx3sdk/firmware ELF2IMG_DIR := $(FX3_ROOT)/cyfx3sdk/util/elf2img diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index a48dc067..4878faab 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -22,7 +22,8 @@ endif() set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Build type") list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/modules) -set(BLADERF_COMMON_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../common) +# Firmware <--> Host common files +set(BLADERF_FW_COMMON_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../firmware_common) ################################################################################ # Compiler configuration @@ -70,7 +71,7 @@ endif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR ################################################################################ -# Process subdirectories +# Process subdirectories ################################################################################ add_subdirectory(libraries) @@ -86,6 +87,6 @@ configure_file( IMMEDIATE @ONLY) add_custom_target(uninstall - COMMAND + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake ) diff --git a/host/libraries/libbladeRF/CMakeLists.txt b/host/libraries/libbladeRF/CMakeLists.txt index 6332a997..1fb47b82 100644 --- a/host/libraries/libbladeRF/CMakeLists.txt +++ b/host/libraries/libbladeRF/CMakeLists.txt @@ -15,7 +15,7 @@ project(libbladeRF C) # Version information ################################################################################ -set(VERSION_INFO_MAJOR 0) +set(VERSION_INFO_MAJOR 0) set(VERSION_INFO_MINOR 3) set(VERSION_INFO_PATCH 0) set(VERSION_INFO_EXTRA "git") @@ -39,12 +39,12 @@ configure_file( ############################## option(ENABLE_BACKEND_LIBUSB - "Enable libusb backend support" + "Enable libusb backend support" ON ) -option(LIBUSB_DETACH_KERNEL_DRIVER - "Enable calls to libusb_detach_kernel_driver(). Not supported in Windows." +option(LIBUSB_DETACH_KERNEL_DRIVER + "Enable calls to libusb_detach_kernel_driver(). Not supported in Windows." ON ) @@ -55,9 +55,9 @@ option(ENABLE_BACKEND_LINUX_DRIVER # Ensure we've got at least one backend enabled if(NOT ENABLE_BACKEND_LIBUSB AND NOT ENABLE_BACKEND_LINUX_DRIVER) - message(FATAL_ERROR + message(FATAL_ERROR "No libbladeRF backends are enabled. " - "Please enable one or more backends." ) + "Please enable one or more backends." ) endif() @@ -85,7 +85,7 @@ endif() ################################################################################ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src - ${BLADERF_COMMON_INCLUDE_DIR} + ${BLADERF_FW_COMMON_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/src ${LIBUSB_INCLUDE_DIRS} ) @@ -111,7 +111,7 @@ endif() ################################################################################ # Configure source files ################################################################################ -set(LIBBLADERF_SOURCE +set(LIBBLADERF_SOURCE src/backend.c src/bladerf.c src/bladerf_priv.c @@ -128,7 +128,7 @@ if(ENABLE_BACKEND_LIBUSB) endif() if(ENABLE_BACKEND_LINUX_DRIVER) - set(LIBBLADERF_SOURCE ${LIBBLADERF_SOURCE} src/linux.c) + set(LIBBLADERF_SOURCE ${LIBBLADERF_SOURCE} src/backend/linux.c) endif() add_library(libbladerf_shared SHARED ${LIBBLADERF_SOURCE}) @@ -149,7 +149,7 @@ set_target_properties(libbladerf_shared PROPERTIES SOVERSION ${VERSION_INFO_MAJO ################################################################################ -# Misc. installation config +# Misc. installation config ################################################################################ if(NOT DEFINED LIB_INSTALL_DIR) @@ -208,7 +208,7 @@ install( # Library installation information ################################################################################ install(TARGETS libbladerf_shared - LIBRARY DESTINATION ${LIB_INSTALL_DIR} # .so/.dylib + LIBRARY DESTINATION ${LIB_INSTALL_DIR} # .so/.dylib ARCHIVE DESTINATION ${LIB_INSTALL_DIR} # .a/.lib RUNTIME DESTINATION bin # .dll ) diff --git a/host/libraries/libbladeRF/src/backend/linux.c b/host/libraries/libbladeRF/src/backend/linux.c index 62a48abb..9c3f09d9 100644 --- a/host/libraries/libbladeRF/src/backend/linux.c +++ b/host/libraries/libbladeRF/src/backend/linux.c @@ -31,6 +31,8 @@ struct bladerf_linux { int fd; /* File descriptor to associated driver device node */ }; +const struct bladerf_fn bladerf_linux_fn; + static bool time_past(struct timeval ref, struct timeval now) { if (now.tv_sec > ref.tv_sec) return true; @@ -314,7 +316,7 @@ static int linux_dac_write(struct bladerf *dev, uint16_t val) * Data transfer *----------------------------------------------------------------------------*/ /* TODO Fail out if n > ssize_t max, as we can't return that. */ -static ssize_t linux_tx(struct bladerf *dev, bladerf_format_t format, +static ssize_t linux_tx(struct bladerf *dev, bladerf_format format, void *samples, size_t n, struct bladerf_metadata *metadata) //static ssize_t linux_write_samples(struct bladerf *dev, int16_t *samples, size_t n) { @@ -351,7 +353,7 @@ static ssize_t linux_tx(struct bladerf *dev, bladerf_format_t format, } /* TODO Fail out if n > ssize_t max, as we can't return that */ -static ssize_t linux_rx(struct bladerf *dev, bladerf_format_t format, +static ssize_t linux_rx(struct bladerf *dev, bladerf_format format, void *samples, size_t n, struct bladerf_metadata *metadata) //static ssize_t linux_read_samples(struct bladerf *dev, int16_t *samples, size_t n) { @@ -503,7 +505,8 @@ static int linux_open( struct bladerf **device, struct bladerf_devinfo *info) * so no need to allocate backend and ret until we know we * have said fd */ - assert(info->backend == BACKEND_LINUX || info->backend == BACKEND_ANY); + assert(info->backend == BLADERF_BACKEND_LINUX || + info->backend == BLADERF_BACKEND_ANY); /* If an instance is specified, we start with that */ if (info->instance != DEVINFO_INST_ANY) { @@ -642,7 +645,7 @@ static int linux_probe(struct bladerf_devinfo_list *info_list) for (i = 0; i < num_matches; i++) { status = 0; bladerf_init_devinfo(&devinfo); - devinfo.backend = BACKEND_LINUX; + devinfo.backend = BLADERF_BACKEND_LINUX; devinfo.instance = str2instance(matches[i]->d_name); status = linux_open(&dev, &devinfo); backend = dev->backend; @@ -694,15 +697,14 @@ static int linux_probe(struct bladerf_devinfo_list *info_list) return (!status && num_matches > 0) ? status : BLADERF_ERR_NODEV; } -static int linux_stream(struct bladerf *dev, bladerf_module_t module, - bladerf_format_t format, struct bladerf_stream *stream) +static int linux_stream(struct bladerf *dev, bladerf_module module, + bladerf_format format, struct bladerf_stream *stream) { return BLADERF_ERR_UNSUPPORTED; } -void lusb_deinit_stream(struct bladerf_stream *stream) +void linux_deinit_stream(struct bladerf_stream *stream) { - return BLADERF_ERR_UNSUPPORTED; } /*------------------------------------------------------------------------------ @@ -738,7 +740,7 @@ const struct bladerf_fn bladerf_linux_fn = { .dac_write = linux_dac_write, .rx = linux_rx, - .tx = linux_tx + .tx = linux_tx, .stream = linux_stream, .deinit_stream = linux_deinit_stream diff --git a/host/libraries/libbladeRF/src/backend_config.h.in b/host/libraries/libbladeRF/src/backend_config.h.in index aefc0e9c..9397523c 100644 --- a/host/libraries/libbladeRF/src/backend_config.h.in +++ b/host/libraries/libbladeRF/src/backend_config.h.in @@ -7,7 +7,7 @@ #ifdef ENABLE_BACKEND_LIBUSB # include "backend/libusb.h" # define BACKEND_LIBUSB_FN_TBL_ENTRY \ - {BLADERF_BACKEND_LIBUSB, &bladerf_lusb_fn}, + { BLADERF_BACKEND_LIBUSB, &bladerf_lusb_fn }, #else # define BACKEND_LIBUSB_FN_TBL_ENTRY #endif @@ -15,7 +15,7 @@ #ifdef ENABLE_BACKEND_LINUX_DRIVER # include "backend/linux.h" # define BACKEND_LINUX_DRIVER_FN_TBL_ENTRY \ - { BLADERF_BACKEND_LINUX_DRIVER, &bladerf_linux_fn}, + { BLADERF_BACKEND_LINUX, &bladerf_linux_fn }, #else # define BACKEND_LINUX_DRIVER_FN_TBL_ENTRY #endif