h1r9: use single SSP configuration for MAX283x
During r9 hardware development it was thought that the MAX2839 would use a different GPIO pin for chip select, but it ended up being the same pin as is used for MAX2837 on other hardware revisions. This takes the MAX283x abstraction a bit further and fixes a bug with hackrf_debug -m.
This commit is contained in:
@ -60,8 +60,8 @@ static struct gpio_t gpio_led[] = {
|
||||
// clang-format off
|
||||
static struct gpio_t gpio_1v8_enable = GPIO(3, 6);
|
||||
|
||||
/* MAX2837 GPIO (XCVR_CTL) PinMux */
|
||||
static struct gpio_t gpio_max2837_select = GPIO(0, 15);
|
||||
/* MAX283x GPIO (XCVR_CTL) PinMux */
|
||||
static struct gpio_t gpio_max283x_select = GPIO(0, 15);
|
||||
|
||||
/* MAX5864 SPI chip select (AD_CS) GPIO PinMux */
|
||||
static struct gpio_t gpio_max5864_select = GPIO(2, 7);
|
||||
@ -172,7 +172,7 @@ si5351c_driver_t clock_gen = {
|
||||
.i2c_address = 0x60,
|
||||
};
|
||||
|
||||
const ssp_config_t ssp_config_max2837 = {
|
||||
const ssp_config_t ssp_config_max283x = {
|
||||
/* FIXME speed up once everything is working reliably */
|
||||
/*
|
||||
// Freq About 0.0498MHz / 49.8KHz => Freq = PCLK / (CPSDVSR * [SCR+1]) with PCLK=PLL1=204MHz
|
||||
@ -183,21 +183,7 @@ const ssp_config_t ssp_config_max2837 = {
|
||||
.data_bits = SSP_DATA_16BITS,
|
||||
.serial_clock_rate = 21,
|
||||
.clock_prescale_rate = 2,
|
||||
.gpio_select = &gpio_max2837_select,
|
||||
};
|
||||
|
||||
const ssp_config_t ssp_config_max2839 = {
|
||||
/* FIXME speed up once everything is working reliably */
|
||||
/*
|
||||
// Freq About 0.0498MHz / 49.8KHz => Freq = PCLK / (CPSDVSR * [SCR+1]) with PCLK=PLL1=204MHz
|
||||
const uint8_t serial_clock_rate = 32;
|
||||
const uint8_t clock_prescale_rate = 128;
|
||||
*/
|
||||
// Freq About 4.857MHz => Freq = PCLK / (CPSDVSR * [SCR+1]) with PCLK=PLL1=204MHz
|
||||
.data_bits = SSP_DATA_16BITS,
|
||||
.serial_clock_rate = 21,
|
||||
.clock_prescale_rate = 2,
|
||||
.gpio_select = &gpio_max2837_select,
|
||||
.gpio_select = &gpio_max283x_select,
|
||||
};
|
||||
|
||||
const ssp_config_t ssp_config_max5864 = {
|
||||
@ -868,14 +854,9 @@ clock_source_t activate_best_clock_source(void)
|
||||
return source;
|
||||
}
|
||||
|
||||
void ssp1_set_mode_max2837(void)
|
||||
void ssp1_set_mode_max283x(void)
|
||||
{
|
||||
spi_bus_start(max2837.bus, &ssp_config_max2837);
|
||||
}
|
||||
|
||||
void ssp1_set_mode_max2839(void)
|
||||
{
|
||||
spi_bus_start(max2839.bus, &ssp_config_max2839);
|
||||
spi_bus_start(&spi_bus_ssp1, &ssp_config_max283x);
|
||||
}
|
||||
|
||||
void ssp1_set_mode_max5864(void)
|
||||
@ -974,11 +955,7 @@ void pin_setup(void)
|
||||
/* enable input on SCL and SDA pins */
|
||||
SCU_SFSI2C0 = SCU_I2C0_NOMINAL;
|
||||
|
||||
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
|
||||
spi_bus_start(&spi_bus_ssp1, &ssp_config_max2839);
|
||||
} else {
|
||||
spi_bus_start(&spi_bus_ssp1, &ssp_config_max2837);
|
||||
}
|
||||
spi_bus_start(&spi_bus_ssp1, &ssp_config_max283x);
|
||||
|
||||
mixer_bus_setup(&mixer);
|
||||
|
||||
|
@ -35,8 +35,6 @@ extern "C" {
|
||||
#include "spi_ssp.h"
|
||||
|
||||
#include "max283x.h"
|
||||
#include "max2837.h"
|
||||
#include "max2839.h"
|
||||
#include "max5864.h"
|
||||
#include "mixer.h"
|
||||
#include "w25q80bv.h"
|
||||
@ -270,13 +268,10 @@ void delay_us_at_mhz(uint32_t us, uint32_t mhz);
|
||||
/* TODO: Hide these configurations */
|
||||
extern si5351c_driver_t clock_gen;
|
||||
extern const ssp_config_t ssp_config_w25q80bv;
|
||||
extern const ssp_config_t ssp_config_max2837;
|
||||
extern const ssp_config_t ssp_config_max2839;
|
||||
extern const ssp_config_t ssp_config_max283x;
|
||||
extern const ssp_config_t ssp_config_max5864;
|
||||
|
||||
extern max283x_driver_t max283x;
|
||||
extern max2837_driver_t max2837;
|
||||
extern max2839_driver_t max2839; //FIXME xcvr hal
|
||||
extern max5864_driver_t max5864;
|
||||
extern mixer_driver_t mixer;
|
||||
extern w25q80bv_driver_t spi_flash;
|
||||
@ -286,8 +281,7 @@ extern jtag_t jtag_cpld;
|
||||
extern i2c_bus_t i2c0;
|
||||
|
||||
void cpu_clock_init(void);
|
||||
void ssp1_set_mode_max2837(void);
|
||||
void ssp1_set_mode_max2839(void);
|
||||
void ssp1_set_mode_max283x(void);
|
||||
void ssp1_set_mode_max5864(void);
|
||||
|
||||
void pin_setup(void);
|
||||
|
@ -76,9 +76,6 @@ void max283x_reg_write(max283x_driver_t* const drv, uint8_t r, uint16_t v);
|
||||
* provided routines for those operations. */
|
||||
void max283x_regs_commit(max283x_driver_t* const drv);
|
||||
|
||||
//max283x_mode_t max283x_mode(max283x_driver_t* const drv);
|
||||
//void max283x_set_mode(max283x_driver_t* const drv, const max283x_mode_t new_mode);
|
||||
|
||||
max283x_mode_t max283x_mode(max283x_driver_t* const drv);
|
||||
void max283x_set_mode(max283x_driver_t* const drv, const max283x_mode_t new_mode);
|
||||
|
||||
|
@ -32,8 +32,6 @@
|
||||
#include "platform_detect.h"
|
||||
#include "mixer.h"
|
||||
#include "max283x.h"
|
||||
#include "max2837.h"
|
||||
#include "max2839.h"
|
||||
#include "max5864.h"
|
||||
#include "sgpio.h"
|
||||
|
||||
@ -369,11 +367,10 @@ void rf_path_init(rf_path_t* const rf_path)
|
||||
max5864_setup(&max5864);
|
||||
max5864_shutdown(&max5864);
|
||||
|
||||
ssp1_set_mode_max283x();
|
||||
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
|
||||
ssp1_set_mode_max2839();
|
||||
max283x_setup(&max283x, MAX2839_VARIANT);
|
||||
} else {
|
||||
ssp1_set_mode_max2837();
|
||||
max283x_setup(&max283x, MAX2837_VARIANT);
|
||||
}
|
||||
max283x_start(&max283x);
|
||||
@ -404,11 +401,7 @@ void rf_path_set_direction(rf_path_t* const rf_path, const rf_path_direction_t d
|
||||
}
|
||||
ssp1_set_mode_max5864();
|
||||
max5864_tx(&max5864);
|
||||
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
|
||||
ssp1_set_mode_max2839();
|
||||
} else {
|
||||
ssp1_set_mode_max2837();
|
||||
}
|
||||
ssp1_set_mode_max283x();
|
||||
max283x_tx(&max283x);
|
||||
sgpio_configure(&sgpio_config, SGPIO_DIRECTION_TX);
|
||||
break;
|
||||
@ -427,11 +420,7 @@ void rf_path_set_direction(rf_path_t* const rf_path, const rf_path_direction_t d
|
||||
}
|
||||
ssp1_set_mode_max5864();
|
||||
max5864_rx(&max5864);
|
||||
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
|
||||
ssp1_set_mode_max2839();
|
||||
} else {
|
||||
ssp1_set_mode_max2837();
|
||||
}
|
||||
ssp1_set_mode_max283x();
|
||||
max283x_rx(&max283x);
|
||||
sgpio_configure(&sgpio_config, SGPIO_DIRECTION_RX);
|
||||
break;
|
||||
@ -447,11 +436,7 @@ void rf_path_set_direction(rf_path_t* const rf_path, const rf_path_direction_t d
|
||||
mixer_disable(&mixer);
|
||||
ssp1_set_mode_max5864();
|
||||
max5864_standby(&max5864);
|
||||
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
|
||||
ssp1_set_mode_max2839();
|
||||
} else {
|
||||
ssp1_set_mode_max2837();
|
||||
}
|
||||
ssp1_set_mode_max283x();
|
||||
max283x_set_mode(&max283x, MAX283x_MODE_STANDBY);
|
||||
sgpio_configure(&sgpio_config, SGPIO_DIRECTION_RX);
|
||||
break;
|
||||
|
@ -202,7 +202,7 @@ static void ui_update(void)
|
||||
rad1o_lcdDisplay();
|
||||
|
||||
// Don't ask...
|
||||
ssp1_set_mode_max2837();
|
||||
ssp1_set_mode_max283x();
|
||||
}
|
||||
|
||||
static void rad1o_ui_init(void)
|
||||
@ -217,7 +217,7 @@ static void rad1o_ui_deinit(void)
|
||||
rad1o_lcdDeInit();
|
||||
enabled = false;
|
||||
// Don't ask...
|
||||
ssp1_set_mode_max2837();
|
||||
ssp1_set_mode_max283x();
|
||||
}
|
||||
|
||||
static void rad1o_ui_set_frequency(uint64_t frequency)
|
||||
|
@ -66,8 +66,8 @@ extern uint32_t _etext_ram, _text_ram, _etext_rom;
|
||||
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_max283x,
|
||||
usb_vendor_request_read_max283x,
|
||||
usb_vendor_request_write_si5351c,
|
||||
usb_vendor_request_read_si5351c,
|
||||
usb_vendor_request_set_sample_rate_frac,
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <hackrf_core.h>
|
||||
#include <usb_queue.h>
|
||||
#include <max2837.h>
|
||||
#include <max283x.h>
|
||||
#include <rffc5071.h>
|
||||
|
||||
#include <stddef.h>
|
||||
@ -33,15 +33,15 @@
|
||||
|
||||
#include <hackrf_core.h>
|
||||
|
||||
usb_request_status_t usb_vendor_request_write_max2837(
|
||||
usb_request_status_t usb_vendor_request_write_max283x(
|
||||
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,
|
||||
max283x_reg_write(
|
||||
&max283x,
|
||||
endpoint->setup.index,
|
||||
endpoint->setup.value);
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
@ -54,14 +54,14 @@ usb_request_status_t usb_vendor_request_write_max2837(
|
||||
}
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_read_max2837(
|
||||
usb_request_status_t usb_vendor_request_read_max283x(
|
||||
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);
|
||||
max283x_reg_read(&max283x, endpoint->setup.index);
|
||||
endpoint->buffer[0] = value & 0xff;
|
||||
endpoint->buffer[1] = value >> 8;
|
||||
usb_transfer_schedule_block(
|
||||
|
@ -27,10 +27,10 @@
|
||||
#include <usb_type.h>
|
||||
#include <usb_request.h>
|
||||
|
||||
usb_request_status_t usb_vendor_request_write_max2837(
|
||||
usb_request_status_t usb_vendor_request_write_max283x(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_read_max2837(
|
||||
usb_request_status_t usb_vendor_request_read_max283x(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage);
|
||||
usb_request_status_t usb_vendor_request_write_si5351c(
|
||||
|
Reference in New Issue
Block a user