Skip to content

Commit

Permalink
Merge remote-tracking branch 'mossmann/master' into opera-merge
Browse files Browse the repository at this point in the history
Conflicts:
	firmware/common/hackrf_core.c
	firmware/common/rf_path.c
	firmware/hackrf-common.cmake
	firmware/hackrf_usb/hackrf_usb.c
	firmware/hackrf_usb/usb_api_transceiver.c
	host/hackrf-tools/src/hackrf_transfer.c
  • Loading branch information
schneider42 committed Jan 28, 2017
2 parents f96ea4b + 4363144 commit 642feac
Show file tree
Hide file tree
Showing 42 changed files with 1,917 additions and 478 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.hex
*.srec
host/build/
host/**/build

# Operating system spew
.DS_Store
Expand Down
43 changes: 30 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,56 @@ language: c
cache: apt

sudo: false
dist: trusty

os:
- linux
- osx

compiler:
- gcc
# - clang
- clang

matrix:
exclude:
- os: osx
compiler: gcc
- os: linux
compiler: clang

before_script:
# - wget https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q1-update/+download/gcc-arm-none-eabi-5_3-2016q1-20160330-linux.tar.bz2 -O /tmp/gcc-arm.tar.bz2
# - tar -xvf /tmp/gcc-arm.tar.bz2
# - export PATH=$PWD/gcc-arm-none-eabi-5_3-2016q1/bin:$PATH
- export CFLAGS="-Wall -Wextra -Werror"

before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install libusb; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew tap PX4/homebrew-px4; brew update; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install libusb fftw gcc-arm-none-eabi dfu-util; fi
# For virtualenv(?) reasons we can't apt-get install python-yaml
- pip install PyYAML

script:
- mkdir host/build
- cd host/build
- cmake ..
- make
# - cd ../../firmware/hackrf_usb
# - mkdir build
# - cd build
# - export CC="arm-none-eabi-gcc"
# - export CXX="arm-none-eabi-g++"
# - cmake ..
# - make
- cd ../..
- mkdir firmware/build-hackrf-one
- mkdir firmware/build-jawbreaker
- cd firmware/libopencm3
- make
- cd ../build-hackrf-one
- cmake ..
- make
- cd ../build-jawbreaker
- cmake -DBOARD=JAWBREAKER ..
- make

addons:
apt:
sources:
- debian-sid
packages:
- libusb-1.0-0-dev
- libfftw3-dev
- gcc-arm-none-eabi
- libnewlib-arm-none-eabi
- dfu-util
27 changes: 27 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
os: Visual Studio 2015
clone_depth: 1

configuration:
- Release
- Debug

install:
- appveyor DownloadFile "https://downloads.sourceforge.net/project/libusb/libusb-1.0/libusb-1.0.21/libusb-1.0.21.7z?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Flibusb%2Ffiles%2Flibusb-1.0%2Flibusb-1.0.21%2F&ts=1485478643&use_mirror=cytranet" -FileName "C:\libusb.7z"
- 7z x -y "C:\libusb.7z" -o"C:\libusb"
- appveyor DownloadFile "http://mirrors.kernel.org/sourceware/pthreads-win32/pthreads-w32-2-9-1-release.zip" -FileName "C:\pthreads-w32-release.zip"
- 7z x -y "C:\pthreads-w32-release.zip" -o"C:\pthreads"
- appveyor DownloadFile "http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.26-1_win32.zip" -FileName "C:\pkg-config_win32.zip"
- 7z x -y "C:\pkg-config_win32.zip" -o"C:\pkg-config"


build_script:
- mkdir c:\projects\hackrf\host\build
- cd c:\projects\hackrf\host\build
- cmake -G "Visual Studio 14 2015 Win64" \
-DLIBUSB_LIBRARIES="C:\libusb\MS64\dll\libusb-1.0.lib" \
-DLIBUSB_INCLUDE_DIR="C:\libusb\include\libusb-1.0" \
-DTHREADS_PTHREADS_INCLUDE_DIR=c:\pthreads\Pre-built.2\include \
-DTHREADS_PTHREADS_WIN32_LIBRARY=c:\pthreads\Pre-built.2\lib\x64\pthreadVC2.lib \
-DPKG_CONFIG_EXECUTABLE="C:\pkg-config\bin\pkg-config.exe" \
..
- msbuild .\ALL_BUILD.vcxproj /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
2 changes: 1 addition & 1 deletion firmware/README
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ projects. The cpld directory contains HDL source for the CPLD.

The firmware is set up for compilation with the GCC toolchain available here:

https://launchpad.net/gcc-arm-embedded
https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads

Required dependency:

Expand Down
7 changes: 2 additions & 5 deletions firmware/blinky/blinky.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

int main(void)
{
int i;
pin_setup();

/* enable all power supplies */
Expand All @@ -36,15 +35,13 @@ int main(void)
led_on(LED2);
led_on(LED3);

for (i = 0; i < 2000000; i++) /* Wait a bit. */
__asm__("nop");
delay(2000000);

led_off(LED1);
led_off(LED2);
led_off(LED3);

for (i = 0; i < 2000000; i++) /* Wait a bit. */
__asm__("nop");
delay(2000000);
}

return 0;
Expand Down
67 changes: 64 additions & 3 deletions firmware/common/hackrf_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,24 @@ static struct gpio_t gpio_max2837_b7 = GPIO(2, 15);
/* MAX5864 SPI chip select (AD_CS) GPIO PinMux */
static struct gpio_t gpio_max5864_select = GPIO(2, 7);

/* RF LDO control */
#ifdef JAWBREAKER
static struct gpio_t gpio_rf_ldo_enable = GPIO(2, 9);
#if (defined JAWBREAKER || defined HACKRF_ONE || defined RAD1O)
/*
static struct gpio_t gpio_sync_in_a = GPIO(3, 8);
static struct gpio_t gpio_sync_in_b = GPIO(3, 9);
static struct gpio_t gpio_sync_out_a = GPIO(3, 10);
static struct gpio_t gpio_sync_out_b = GPIO(3, 11);
*/
static struct gpio_t gpio_sync_in_a = GPIO(3, 10);
static struct gpio_t gpio_sync_in_b = GPIO(3, 11);
static struct gpio_t gpio_sync_out_a = GPIO(3, 8);
static struct gpio_t gpio_sync_out_b = GPIO(3, 9);
#endif

/* RF LDO control */
// #ifdef JAWBREAKER
// static struct gpio_t gpio_rf_ldo_enable = GPIO(2, 9);
// #endif

/* RF supply (VAA) control */
#ifdef HACKRF_ONE
static struct gpio_t gpio_vaa_disable = GPIO(2, 9);
Expand Down Expand Up @@ -886,6 +899,15 @@ void pin_setup(void) {

/* Safe state: start with VAA turned off: */
disable_rf_power();

scu_pinmux(SCU_PINMUX_GPIO3_10, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
scu_pinmux(SCU_PINMUX_GPIO3_11, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);

gpio_input(&gpio_sync_in_a);
gpio_input(&gpio_sync_in_b);

gpio_output(&gpio_sync_out_a);
gpio_output(&gpio_sync_out_b);
#endif

#ifdef RAD1O
Expand All @@ -894,6 +916,15 @@ void pin_setup(void) {

/* Safe state: start with VAA turned off: */
disable_rf_power();

scu_pinmux(SCU_PINMUX_GPIO3_10, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
scu_pinmux(SCU_PINMUX_GPIO3_11, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);

gpio_input(&gpio_sync_in_a);
gpio_input(&gpio_sync_in_b);

gpio_output(&gpio_sync_out_a);
gpio_output(&gpio_sync_out_b);
#endif

/* enable input on SCL and SDA pins */
Expand Down Expand Up @@ -950,3 +981,33 @@ void led_off(const led_t led) {
void led_toggle(const led_t led) {
gpio_toggle(&gpio_led[led]);
}

void hw_sync_syn() {
gpio_set(&gpio_sync_out_a);
}

void hw_sync_stop() {
gpio_clear(&gpio_sync_out_a);
gpio_clear(&gpio_sync_out_b);
}

void hw_sync_ack() {
gpio_set(&gpio_sync_out_b);
}

void hw_sync_copy_state() {
if(gpio_read(&gpio_sync_in_a)) {
gpio_set(&gpio_sync_out_a);
} else {
gpio_clear(&gpio_sync_out_a);
}
if(gpio_read(&gpio_sync_in_b)) {
gpio_set(&gpio_sync_out_b);
} else {
gpio_clear(&gpio_sync_out_b);
}
}

bool hw_sync_ready() {
return (gpio_read(&gpio_sync_in_a) && gpio_read(&gpio_sync_in_b));
}
13 changes: 13 additions & 0 deletions firmware/common/hackrf_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@ typedef enum {
TRANSCEIVER_MODE_CPLD_UPDATE = 4
} transceiver_mode_t;

typedef enum {
HW_SYNC_MODE_OFF = 0,
HW_SYNC_MODE_ON = 1,
} hw_sync_mode_t;

void delay(uint32_t duration);

/* TODO: Hide these configurations */
Expand All @@ -279,6 +284,7 @@ extern w25q80bv_driver_t spi_flash;
extern sgpio_config_t sgpio_config;
extern rf_path_t rf_path;
extern jtag_t jtag_cpld;
extern i2c_bus_t i2c0;

void cpu_clock_init(void);
void cpu_clock_pll1_low_speed(void);
Expand Down Expand Up @@ -311,6 +317,13 @@ void led_on(const led_t led);
void led_off(const led_t led);
void led_toggle(const led_t led);

void hw_sync_syn();
void hw_sync_stop();
void hw_sync_ack();
bool hw_sync_ready();
void hw_sync_copy_state();


#ifdef __cplusplus
}
#endif
Expand Down
20 changes: 13 additions & 7 deletions firmware/common/i2c_lpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,23 @@ void i2c_lpc_transfer(i2c_bus_t* const bus,
uint8_t* const data_rx, const size_t count_rx
) {
const uint32_t port = (uint32_t)bus->obj;
i2c_tx_start(port);
i2c_tx_byte(port, (slave_address << 1) | I2C_WRITE);
for(size_t i=0; i<count_tx; i++) {
i2c_tx_byte(port, data_tx[i]);
size_t i;
bool ack = false;
if (data_tx && (count_tx > 0)) {
i2c_tx_start(port);
i2c_tx_byte(port, (slave_address << 1) | I2C_WRITE);
for(i=0; i<count_tx; i++) {
i2c_tx_byte(port, data_tx[i]);
}
}

if( data_rx ) {
if (data_rx && (count_rx > 0)) {
i2c_tx_start(port);
i2c_tx_byte(port, (slave_address << 1) | I2C_READ);
for(size_t i=0; i<count_rx; i++) {
data_rx[i] = i2c_rx_byte(port);
for(i=0; i<count_rx; i++) {
/* ACK each byte except the last */
ack = (i!=count_rx-1);
data_rx[i] = i2c_rx_byte(port, ack);
}
}

Expand Down

0 comments on commit 642feac

Please sign in to comment.