Skip to content

Commit

Permalink
Unified AirSpy firmware, support multiple AirSpy boards with same fir…
Browse files Browse the repository at this point in the history
…mware (AirSpy NOS and upcoming AirSpy MINI)

Unified multiple configurations files to one configuration per board with multiple expansion points
Board configuration use now a special dedicated shared memory(ram_ahb1_spare)
Update copyright headers replaced bvernoux@gmail.com by bvernoux@airspy.com
  • Loading branch information
bvernoux committed Feb 9, 2016
1 parent b973886 commit 4a268e2
Show file tree
Hide file tree
Showing 50 changed files with 1,222 additions and 636 deletions.
6 changes: 0 additions & 6 deletions Makefile
Expand Up @@ -20,12 +20,6 @@
# Boston, MA 02110-1301, USA.
#

#export BOARD ?= AIRSPY_DEMO
#export VERSION_STRING ?= -D'VERSION_STRING="AirSpy DEMO"'

export BOARD ?= AIRSPY_NOS
export VERSION_STRING ?= -D'VERSION_STRING="AirSpy NOS"'

TARGETS = airspy_m0 \
airspy_m0s \
airspy_rom_to_ram
Expand Down
6 changes: 2 additions & 4 deletions airspy_m0/Makefile
@@ -1,7 +1,7 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright 2012 Jared Boone <jared@sharebrained.com>
# Copyright 2013/2014 Benjamin Vernoux <bvernoux@gmail.com>
# Copyright 2013-2016 Benjamin Vernoux <bvernoux@airspy.com>
#
# This file is part of AirSpy (based on HackRF project).
#
Expand All @@ -28,8 +28,7 @@ SRC = $(BINARY).c\
airspy_usb_req.c \
usb_descriptor.c \
usb_device.c \
usb_endpoint.c \
airspy_m0_conf.c
usb_endpoint.c

# Source from ../common dir
VPATH += ../common
Expand All @@ -38,7 +37,6 @@ SRC += \
fault_handler.c \
si5351c.c \
r820t.c \
r820t_conf.c \
w25q80bv.c \
rom_iap.c \
signal_mcu.c \
Expand Down
22 changes: 9 additions & 13 deletions airspy_m0/airspy_m0.c
Expand Up @@ -49,7 +49,6 @@
#include "airspy_commands.h"
#include "airspy_rx.h"
#include "r820t.h"
#include "r820t_conf.h"
#include "airspy_m0.hdr"

extern uint32_t cm4_data_share; /* defined in linker script */
Expand All @@ -73,9 +72,7 @@ volatile airspy_mcore_t *set_packing = (airspy_mcore_t *)((&cm0_data_share)+2);

uint8_t* const usb_bulk_buffer = (uint8_t*)0x20004000;

uint8_t spiflash_buffer[W25Q80BV_PAGE_LEN];
char version_string[] = VERSION_STRING " " AIRSPY_FW_GIT_TAG " " AIRSPY_FW_CHECKIN_DATE;
uint8_t version_string_strlen = sizeof(version_string);
const char version_string[] = " " AIRSPY_FW_GIT_TAG " " AIRSPY_FW_CHECKIN_DATE;

typedef struct {
uint32_t freq_hz;
Expand Down Expand Up @@ -152,27 +149,26 @@ void ADCHS_start(uint8_t conf_num)
{
start_stop_adchs_m4(conf_num, START_ADCHS_CMD);

enable_r820t_power();
//enable_r820t_power();

/* Re-Init I2C0 & I2C1 after PLL1 frequency is modified (for I2C1 also because PowerOn on R820T) */
i2c0_init(AIRSPY_I2C0_PLL1_LS_HS_CONF_VAL); /* Si5351C I2C peripheral */
i2c1_init(AIRSPY_I2C1_PLL1_HS_CONF_VAL); /* R820T I2C peripheral */
i2c0_init(airspy_conf->i2c_conf.i2c0_pll1_ls_hs_conf_val); /* Si5351C I2C peripheral */
i2c1_init(airspy_conf->i2c_conf.i2c1_pll1_hs_conf_val); /* R820T I2C peripheral */

r820t_init(&r820t_conf_rw, airspy_m0_conf[conf_num].r820t_if_freq);
r820t_set_if_bandwidth(&r820t_conf_rw, airspy_m0_conf[conf_num].r820t_if_bw);
r820t_init(&airspy_conf->r820t_conf_rw, airspy_conf->airspy_m0_m4_conf[conf_num].airspy_m0_conf.r820t_if_freq);
r820t_set_if_bandwidth(&airspy_conf->r820t_conf_rw, airspy_conf->airspy_m0_m4_conf[conf_num].airspy_m0_conf.r820t_if_bw);

phase = 1;
}

void ADCHS_stop(uint8_t conf_num)
{
r820t_standby();
start_stop_adchs_m4(conf_num, STOP_ADCHS_CMD);

/* Re-Init I2C0 & I2C1 after PLL1 frequency is modified */
i2c0_init(AIRSPY_I2C0_PLL1_LS_HS_CONF_VAL); /* Si5351C I2C peripheral */
i2c1_init(AIRSPY_I2C1_PLL1_LS_CONF_VAL); /* R820T I2C peripheral */

disable_r820t_power();
i2c0_init(airspy_conf->i2c_conf.i2c0_pll1_ls_hs_conf_val); /* Si5351C I2C peripheral */
i2c1_init(airspy_conf->i2c_conf.i2c1_pll1_ls_conf_val); /* R820T I2C peripheral */
}

/***************************/
Expand Down
2 changes: 1 addition & 1 deletion airspy_m0/airspy_m0.h
@@ -1,5 +1,5 @@
/*
* Copyright 2014 Benjamin Vernoux <bvernoux@gmail.com>
* Copyright 2014 Benjamin Vernoux <bvernoux@airspy.com>
*
* This file is part of AirSpy.
*
Expand Down
36 changes: 0 additions & 36 deletions airspy_m0/airspy_m0_conf.c

This file was deleted.

6 changes: 3 additions & 3 deletions airspy_m0/airspy_rx.c
@@ -1,6 +1,6 @@
/*
* Copyright 2012 Jared Boone
* Copyright 2013/2014 Benjamin Vernoux <bvernoux@gmail.com>
* Copyright 2013-2016 Benjamin Vernoux <bvernoux@airspy.com>
*
* This file is part of AirSpy (based on HackRF project).
*
Expand Down Expand Up @@ -47,12 +47,12 @@ void set_receiver_mode(const receiver_mode_t new_receiver_mode)
{
ADCHS_stop(sample_rate_conf_no);
}
receiver_mode = new_receiver_mode;
receiver_mode = new_receiver_mode;
}

receiver_mode_t get_receiver_mode(void)
{
return receiver_mode;
return receiver_mode;
}


2 changes: 1 addition & 1 deletion airspy_m0/airspy_rx.h
@@ -1,5 +1,5 @@
/*
* Copyright 2014 Benjamin Vernoux <bvernoux@gmail.com>
* Copyright 2014-2016 Benjamin Vernoux <bvernoux@airspy.com>
*
* This file is part of AirSpy.
*
Expand Down
70 changes: 47 additions & 23 deletions airspy_m0/airspy_usb_req.c
@@ -1,6 +1,6 @@
/*
* Copyright 2012 Jared Boone
* Copyright 2013-2015 Benjamin Vernoux <bvernoux@airspy.com>
* Copyright 2013-2016 Benjamin Vernoux <bvernoux@airspy.com>
*
* This file is part of AirSpy (based on HackRF project).
*
Expand Down Expand Up @@ -46,18 +46,20 @@
#include "airspy_commands.h"
#include "airspy_rx.h"
#include "r820t.h"
#include "r820t_conf.h"

#include "airspy_conf.h"

#define ADDR_ALIGN_32BITS (3)

extern char version_string[];
extern uint8_t version_string_strlen;
extern const char version_string[];

/* Allocate aligned buffer on 4bytes for 32bits store */
/* Allocate aligned buffer on 4bytes for 32bits store (this buffer shall be not less than 256bytes) */
uint8_t spiflash_buffer[W25Q80BV_PAGE_LEN] __attribute__ ((aligned(4)));
uint32_t samplerates_buffer[AIRSPY_CONF_NB];
/* spiflash_buffer used for:
* spiflash read/write.
* samplerates_buffer shall not exceed AIRSPY_CONF_NB_MAX.
* version_string.
*/

typedef struct {
uint32_t freq_hz;
Expand Down Expand Up @@ -181,7 +183,7 @@ const usb_transfer_stage_t stage)
{
if( endpoint->setup.value < 256 )
{
airspy_r820t_write_single(&r820t_conf_rw, endpoint->setup.index, endpoint->setup.value);
airspy_r820t_write_single(&airspy_conf->r820t_conf_rw, endpoint->setup.index, endpoint->setup.value);
usb_transfer_schedule_ack(endpoint->in);
return USB_REQUEST_STATUS_OK;
}
Expand All @@ -200,7 +202,7 @@ const usb_transfer_stage_t stage)
{
if( endpoint->setup.index < 256 )
{
const uint8_t value = airspy_r820t_read_single(&r820t_conf_rw, endpoint->setup.index);
const uint8_t value = airspy_r820t_read_single(&airspy_conf->r820t_conf_rw, endpoint->setup.index);
endpoint->buffer[0] = value;
usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1);
usb_transfer_schedule_ack(endpoint->out);
Expand Down Expand Up @@ -344,8 +346,20 @@ 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)
{
unsigned int i;
int version_string_len;

if (stage == USB_TRANSFER_STAGE_SETUP) {
usb_transfer_schedule_block(endpoint->in, version_string, version_string_strlen);
for(i = 0; i < sizeof(spiflash_buffer); i++)
spiflash_buffer[i] = 0;

strcpy((char *)spiflash_buffer, (char *)airspy_conf->conf_hw.version);
version_string_len = strlen((char *)spiflash_buffer);
strcpy((char *)&spiflash_buffer[version_string_len], version_string);
version_string_len = strlen((char *)spiflash_buffer);
version_string_len = (version_string_len + 3) & ~0x03; /* Round to a multiple of 4 */

usb_transfer_schedule_block(endpoint->in, spiflash_buffer, version_string_len);
usb_transfer_schedule_ack(endpoint->out);
}
return USB_REQUEST_STATUS_OK;
Expand Down Expand Up @@ -401,9 +415,9 @@ const usb_transfer_stage_t stage)

if( stage == USB_TRANSFER_STAGE_SETUP )
{
if(endpoint->setup.index > (AIRSPY_CONF_NB-1))
if(endpoint->setup.index > 1)
{
return USB_REQUEST_STATUS_STALL;
return USB_REQUEST_STATUS_STALL;
}else
{
state = endpoint->setup.index;
Expand All @@ -430,16 +444,18 @@ const usb_transfer_stage_t stage)
return USB_REQUEST_STATUS_OK;
}


usb_request_status_t usb_vendor_request_set_samplerate(
usb_endpoint_t* const endpoint,
const usb_transfer_stage_t stage)
{
uint16_t airspy_conf_nb;
receiver_mode_t rx_mode;

if( stage == USB_TRANSFER_STAGE_SETUP )
{
if(endpoint->setup.index > (AIRSPY_CONF_NB-1))
airspy_conf_nb = airspy_conf->nb_airspy_m0_m4_conf_t;
if( (endpoint->setup.index > (airspy_conf_nb-1)) ||
(endpoint->setup.index > AIRSPY_CONF_NB_MAX) )
{
return USB_REQUEST_STATUS_STALL;
}else
Expand Down Expand Up @@ -478,7 +494,7 @@ const usb_transfer_stage_t stage)
return USB_REQUEST_STATUS_OK;
} else if (stage == USB_TRANSFER_STAGE_DATA)
{
r820t_set_freq(&r820t_conf_rw, set_freq_params.freq_hz);
r820t_set_freq(&airspy_conf->r820t_conf_rw, set_freq_params.freq_hz);
usb_transfer_schedule_ack(endpoint->in);
return USB_REQUEST_STATUS_OK;
/*
Expand All @@ -497,7 +513,7 @@ usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)

if( stage == USB_TRANSFER_STAGE_SETUP )
{
value = r820t_set_lna_gain(&r820t_conf_rw, endpoint->setup.index);
value = r820t_set_lna_gain(&airspy_conf->r820t_conf_rw, endpoint->setup.index);
endpoint->buffer[0] = value;

usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1);
Expand All @@ -514,7 +530,7 @@ usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)

if( stage == USB_TRANSFER_STAGE_SETUP )
{
value = r820t_set_mixer_gain(&r820t_conf_rw, endpoint->setup.index);
value = r820t_set_mixer_gain(&airspy_conf->r820t_conf_rw, endpoint->setup.index);
endpoint->buffer[0] = value;

usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1);
Expand All @@ -531,7 +547,7 @@ usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)

if( stage == USB_TRANSFER_STAGE_SETUP )
{
value = r820t_set_vga_gain(&r820t_conf_rw, endpoint->setup.index);
value = r820t_set_vga_gain(&airspy_conf->r820t_conf_rw, endpoint->setup.index);
endpoint->buffer[0] = value;

usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1);
Expand All @@ -548,7 +564,7 @@ usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)

if( stage == USB_TRANSFER_STAGE_SETUP )
{
value = r820t_set_lna_agc(&r820t_conf_rw, endpoint->setup.index);
value = r820t_set_lna_agc(&airspy_conf->r820t_conf_rw, endpoint->setup.index);
endpoint->buffer[0] = value;

usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1);
Expand All @@ -565,7 +581,7 @@ usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)

if( stage == USB_TRANSFER_STAGE_SETUP )
{
value = r820t_set_mixer_agc(&r820t_conf_rw, endpoint->setup.index);
value = r820t_set_mixer_agc(&airspy_conf->r820t_conf_rw, endpoint->setup.index);
endpoint->buffer[0] = value;

usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1);
Expand Down Expand Up @@ -774,27 +790,35 @@ usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
int i;
uint16_t nb_samplerate;
uint32_t schedule_block_len;
uint16_t airspy_conf_nb;
uint32_t* samplerates_buffer;

if (stage == USB_TRANSFER_STAGE_SETUP)
{
nb_samplerate = endpoint->setup.index;
airspy_conf_nb = airspy_conf->nb_airspy_m0_m4_conf_t;

if(nb_samplerate > AIRSPY_CONF_NB)
if(nb_samplerate > airspy_conf_nb)
{
nb_samplerate = airspy_conf_nb;
}
if(nb_samplerate > AIRSPY_CONF_NB_MAX)
{
nb_samplerate = AIRSPY_CONF_NB;
nb_samplerate = AIRSPY_CONF_NB_MAX;
}

samplerates_buffer = (uint32_t*)&spiflash_buffer[0];
if(nb_samplerate == 0)
{
/* Return the number of samplerates available */
samplerates_buffer[0] = AIRSPY_CONF_NB;
samplerates_buffer[0] = airspy_conf_nb;
usb_transfer_schedule_block(endpoint->in, &samplerates_buffer[0], 4);
} else
{
/* Return each samplerate available */
for(i = 0; i < nb_samplerate; i++)
{
samplerates_buffer[i] = airspy_m0_conf[i].r820t_if_freq * 2; /* samplerate = IF_freq * 2 */
samplerates_buffer[i] = airspy_conf->airspy_m0_m4_conf[i].airspy_m0_conf.r820t_if_freq * 2; /* samplerate = IF_freq * 2 */
}
schedule_block_len = nb_samplerate * sizeof(uint32_t);
usb_transfer_schedule_block(endpoint->in, &samplerates_buffer[0], schedule_block_len);
Expand Down
2 changes: 1 addition & 1 deletion airspy_m0/airspy_usb_req.h
@@ -1,5 +1,5 @@
/*
* Copyright 2014 Benjamin Vernoux <bvernoux@gmail.com>
* Copyright 2014 Benjamin Vernoux <bvernoux@airspy.com>
*
* This file is part of AirSpy.
*
Expand Down
2 changes: 1 addition & 1 deletion airspy_m0/usb_descriptor.c
@@ -1,6 +1,6 @@
/*
* Copyright 2012 Jared Boone
* Copyright 2013/2014 Benjamin Vernoux <bvernoux@gmail.com>
* Copyright 2013-2016 Benjamin Vernoux <bvernoux@airspy.com>
*
* This file is part of AirSpy (based on HackRF project).
*
Expand Down
2 changes: 1 addition & 1 deletion airspy_m0/usb_device.h
@@ -1,6 +1,6 @@
/*
* Copyright 2012 Jared Boone
* Copyright 2013 Benjamin Vernoux <bvernoux@gmail.com>
* Copyright 2013-2016 Benjamin Vernoux <bvernoux@airspy.com>
*
* This file is part of AirSpy (based on HackRF project).
*
Expand Down

0 comments on commit 4a268e2

Please sign in to comment.