From a1e2549ae189e5372aaccf489665ad0f402442a3 Mon Sep 17 00:00:00 2001 From: Michael Ossmann Date: Thu, 14 Jun 2012 10:36:38 -0600 Subject: [PATCH 1/4] troubleshooting RFFC5071 serial --- firmware/common/rffc5071.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/firmware/common/rffc5071.c b/firmware/common/rffc5071.c index f9492044..e6a468b9 100644 --- a/firmware/common/rffc5071.c +++ b/firmware/common/rffc5071.c @@ -41,6 +41,9 @@ void rffc5071_init(void) gpio_set(PORT_MIXER, PIN_MIXER_ENX); /* active low */ gpio_clear(PORT_MIXER, (PIN_MIXER_CLK | PIN_MIXER_DATA)); + //FIXME no writes until we get reads sorted: + return; + //FIXME hard coded setup, fields not broken out /* initial setup */ rffc5071_reg_write(RFFC5071_P2_FREQ1, 0x0000); From 007509996946c8779e4c7c8c1d8bd5507a3d6ad4 Mon Sep 17 00:00:00 2001 From: Michael Ossmann Date: Thu, 14 Jun 2012 10:40:37 -0600 Subject: [PATCH 2/4] mixertx: tests RFFC5071/Lollipop --- firmware/mixertx/Makefile | 11 +++++ firmware/mixertx/README | 26 +++++++++++ firmware/mixertx/mixertx.c | 89 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 firmware/mixertx/Makefile create mode 100644 firmware/mixertx/README create mode 100644 firmware/mixertx/mixertx.c diff --git a/firmware/mixertx/Makefile b/firmware/mixertx/Makefile new file mode 100644 index 00000000..0954b89b --- /dev/null +++ b/firmware/mixertx/Makefile @@ -0,0 +1,11 @@ +# Hey Emacs, this is a -*- makefile -*- + +BINARY = mixertx + +SRC = $(BINARY).c \ + ../common/hackrf_core.c \ + ../common/si5351c.c \ + ../common/max2837.c \ + ../common/rffc5071.c + +include ../common/Makefile_inc.mk diff --git a/firmware/mixertx/README b/firmware/mixertx/README new file mode 100644 index 00000000..eeb90270 --- /dev/null +++ b/firmware/mixertx/README @@ -0,0 +1,26 @@ +This program activates the MAX2837 transceiver to transmit an unmodulated +carrier. It also configures the RFFC5071 to downconvert the carrier to a lower +frequency. + +Required Lemondrop -> Jellybean connections: + +SCK: Lemondrop P3 pin 2 -> Jellybean P9 2 +MOSI: Lemondrop P3 pin 4 -> Jellybean P9 4 +MISO: Lemondrop P3 pin 6 -> Jellybean P9 6 +SSEL: Lemondrop P3 pin 3 -> Jellybean P9 3 +SCL: Lemondrop P7 pin 3 -> Jellybean P6 pin 3 +SDA: Lemondrop P7 pin 5 -> Jellybean P6 pin 5 +SDA: Lemondrop P7 pin 6 -> Jellybean P6 pin 6 +VCC: Lemondrop P4 pin 2, 4, or 6 -> Jellybean P17 pin 2, 4, or 6 +1V8: Lemondrop P11 pin 2, 4, or 6 -> Jellybean P16 pin 2, 4, or 6 +GND: Lemondrop P5 -> Jellybean P13 + +Required Lollipop -> Jellybean connections: +GND: Lollipop P8 pin 1, 3, or 5 -> Jellybean P17 pin 1, 3, or 5 +VCC: Lollipop P8 pin 2, 4, or 6 -> Jellybean P17 pin 2, 4, or 6 +ENX: Lollipop P4 pin 5 -> Jellybean P5 pin 1 +SCLK: Lollipop P4 pin 3 -> Jellybean P5 pin 3 +DATA: Lollipop P4 pin 1 -> Jellybean P5 pin 5 + +Also RF connectors, and you're on your own to get the RF switches configured +properly. diff --git a/firmware/mixertx/mixertx.c b/firmware/mixertx/mixertx.c new file mode 100644 index 00000000..25218303 --- /dev/null +++ b/firmware/mixertx/mixertx.c @@ -0,0 +1,89 @@ +/* + * Copyright 2012 Michael Ossmann + * + * 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 +#include +#include +#include + +#include "hackrf_core.h" +#include "max2837.h" +#include "rffc5071.h" + +void pin_setup(void) +{ + /* Configure SCU Pin Mux as GPIO */ + scu_pinmux(SCU_PINMUX_LED1, SCU_GPIO_FAST); + scu_pinmux(SCU_PINMUX_LED2, SCU_GPIO_FAST); + scu_pinmux(SCU_PINMUX_LED3, SCU_GPIO_FAST); + + scu_pinmux(SCU_PINMUX_EN1V8, SCU_GPIO_FAST); + + /* Configure all GPIO as Input (safe state) */ + GPIO0_DIR = 0; + GPIO1_DIR = 0; + GPIO2_DIR = 0; + GPIO3_DIR = 0; + GPIO4_DIR = 0; + GPIO5_DIR = 0; + GPIO6_DIR = 0; + GPIO7_DIR = 0; + + /* Configure GPIO2[1/2/8] (P4_1/2 P6_12) as output. */ + GPIO2_DIR |= (PIN_LED1|PIN_LED2|PIN_LED3); + + /* GPIO3[6] on P6_10 as output. */ + GPIO3_DIR |= PIN_EN1V8; +} + +int main(void) +{ + const uint32_t freq = 2441000000U; + + pin_setup(); + gpio_set(PORT_EN1V8, PIN_EN1V8); /* 1V8 on */ + cpu_clock_init(); + + gpio_set(PORT_LED1_3, (PIN_LED1)); /* LED1 on */ + + max2837_setup(); + rffc5071_init(); + gpio_set(PORT_LED1_3, (PIN_LED2)); /* LED2 on */ + + /* FIXME testing serial reads */ + while (1) { + //rffc5071_init(); + //rffc5071_reg_write(0x7a, 0xf0ca); + if (rffc5071_reg_read(0x00) == 0xbefb) + gpio_set(PORT_LED1_3, (PIN_LED3)); /* LED3 on */ + else + gpio_clear(PORT_LED1_3, (PIN_LED3)); /* LED3 off */ + } + + max2837_set_frequency(freq); + max2837_start(); + max2837_tx(); + gpio_set(PORT_LED1_3, (PIN_LED3)); /* LED3 on */ + while (1); + max2837_stop(); + + return 0; +} From 68f9a1c6e41c958e3f9b0324bfa0c14463e77663 Mon Sep 17 00:00:00 2001 From: Michael Ossmann Date: Thu, 14 Jun 2012 10:44:22 -0600 Subject: [PATCH 3/4] fixed inconsistent naming of mixer pins --- firmware/common/hackrf_core.h | 14 +++++------ firmware/common/rffc5071.c | 46 +++++++++++++++++------------------ firmware/mixertx/README | 2 +- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/firmware/common/hackrf_core.h b/firmware/common/hackrf_core.h index d300416a..7b4c7fde 100644 --- a/firmware/common/hackrf_core.h +++ b/firmware/common/hackrf_core.h @@ -94,8 +94,8 @@ extern "C" /* RFFC5071 GPIO serial interface PinMux */ #define SCU_MIXER_ENX (P7_0) /* GPIO3[8] on P7_0 */ -#define SCU_MIXER_CLK (P7_1) /* GPIO3[9] on P7_1 */ -#define SCU_MIXER_DATA (P7_2) /* GPIO3[10] on P7_2 */ +#define SCU_MIXER_SCLK (P7_1) /* GPIO3[9] on P7_1 */ +#define SCU_MIXER_SDATA (P7_2) /* GPIO3[10] on P7_2 */ /* TODO add other Pins */ @@ -120,10 +120,10 @@ extern "C" #define PIN_CS_AD (BIT7) /* GPIO2[7] on P5_7 */ #define PORT_CS_AD (GPIO2) /* PORT for CS_AD */ -#define PIN_MIXER_ENX (BIT8) /* GPIO3[8] on P7_0 */ -#define PIN_MIXER_CLK (BIT9) /* GPIO3[9] on P7_1 */ -#define PIN_MIXER_DATA (BIT10) /* GPIO3[10] on P7_2 */ -#define PORT_MIXER (GPIO3) /* PORT for mixer serial interface */ +#define PIN_MIXER_ENX (BIT8) /* GPIO3[8] on P7_0 */ +#define PIN_MIXER_SCLK (BIT9) /* GPIO3[9] on P7_1 */ +#define PIN_MIXER_SDATA (BIT10) /* GPIO3[10] on P7_2 */ +#define PORT_MIXER (GPIO3) /* PORT for mixer serial interface */ /* GPIO Input */ #define PIN_BOOT0 (BIT8) /* GPIO0[8] on P1_1 */ @@ -146,7 +146,7 @@ extern "C" #define BOOT1_STATE ((GPIO0_PIN & PIN_BOOT1)==PIN_BOOT1) #define BOOT2_STATE ((GPIO5_PIN & PIN_BOOT2)==PIN_BOOT2) #define BOOT3_STATE ((GPIO1_PIN & PIN_BOOT3)==PIN_BOOT3) -#define MIXER_DATA_STATE ((GPIO3_PIN & PIN_MIXER_DATA)==PIN_MIXER_DATA) +#define MIXER_SDATA_STATE ((GPIO3_PIN & PIN_MIXER_SDATA)==PIN_MIXER_SDATA) /* TODO add other Pins */ #endif diff --git a/firmware/common/rffc5071.c b/firmware/common/rffc5071.c index e6a468b9..c389e80a 100644 --- a/firmware/common/rffc5071.c +++ b/firmware/common/rffc5071.c @@ -31,15 +31,15 @@ void rffc5071_init(void) { /* Configure GPIO pins. */ scu_pinmux(SCU_MIXER_ENX, SCU_GPIO_FAST); - scu_pinmux(SCU_MIXER_CLK, SCU_GPIO_FAST); - scu_pinmux(SCU_MIXER_DATA, SCU_GPIO_FAST); + scu_pinmux(SCU_MIXER_SCLK, SCU_GPIO_FAST); + scu_pinmux(SCU_MIXER_SDATA, SCU_GPIO_FAST); /* Set GPIO pins as outputs. */ - GPIO3_DIR |= (PIN_MIXER_ENX | PIN_MIXER_CLK | PIN_MIXER_DATA); + GPIO3_DIR |= (PIN_MIXER_ENX | PIN_MIXER_SCLK | PIN_MIXER_SDATA); /* set to known state */ gpio_set(PORT_MIXER, PIN_MIXER_ENX); /* active low */ - gpio_clear(PORT_MIXER, (PIN_MIXER_CLK | PIN_MIXER_DATA)); + gpio_clear(PORT_MIXER, (PIN_MIXER_SCLK | PIN_MIXER_SDATA)); //FIXME no writes until we get reads sorted: return; @@ -103,7 +103,7 @@ void rffc5071_reg_write(uint8_t reg, uint16_t val) /* make sure everything is starting in the correct state */ gpio_set(PORT_MIXER, PIN_MIXER_ENX); - gpio_clear(PORT_MIXER, (PIN_MIXER_CLK | PIN_MIXER_DATA)); + gpio_clear(PORT_MIXER, (PIN_MIXER_SCLK | PIN_MIXER_SDATA)); serial_delay(); /* start transaction by bringing ENX low */ @@ -112,16 +112,16 @@ void rffc5071_reg_write(uint8_t reg, uint16_t val) while (bits--) { if (data & msb) - gpio_set(PORT_MIXER, PIN_MIXER_DATA); + gpio_set(PORT_MIXER, PIN_MIXER_SDATA); else - gpio_clear(PORT_MIXER, PIN_MIXER_DATA); + gpio_clear(PORT_MIXER, PIN_MIXER_SDATA); data <<= 1; serial_delay(); - gpio_set(PORT_MIXER, PIN_MIXER_CLK); + gpio_set(PORT_MIXER, PIN_MIXER_SCLK); serial_delay(); - gpio_clear(PORT_MIXER, PIN_MIXER_CLK); + gpio_clear(PORT_MIXER, PIN_MIXER_SCLK); } serial_delay(); @@ -143,7 +143,7 @@ uint16_t rffc5071_reg_read(uint8_t reg) /* make sure everything is starting in the correct state */ gpio_set(PORT_MIXER, PIN_MIXER_ENX); - gpio_clear(PORT_MIXER, (PIN_MIXER_CLK | PIN_MIXER_DATA)); + gpio_clear(PORT_MIXER, (PIN_MIXER_SCLK | PIN_MIXER_SDATA)); serial_delay(); /* start transaction by bringing ENX low */ @@ -152,42 +152,42 @@ uint16_t rffc5071_reg_read(uint8_t reg) while (bits--) { if (data & msb) - gpio_set(PORT_MIXER, PIN_MIXER_DATA); + gpio_set(PORT_MIXER, PIN_MIXER_SDATA); else - gpio_clear(PORT_MIXER, PIN_MIXER_DATA); + gpio_clear(PORT_MIXER, PIN_MIXER_SDATA); data <<= 1; serial_delay(); - gpio_set(PORT_MIXER, PIN_MIXER_CLK); + gpio_set(PORT_MIXER, PIN_MIXER_SCLK); serial_delay(); - gpio_clear(PORT_MIXER, PIN_MIXER_CLK); + gpio_clear(PORT_MIXER, PIN_MIXER_SCLK); } serial_delay(); - gpio_set(PORT_MIXER, PIN_MIXER_CLK); + gpio_set(PORT_MIXER, PIN_MIXER_SCLK); serial_delay(); - gpio_clear(PORT_MIXER, PIN_MIXER_CLK); + gpio_clear(PORT_MIXER, PIN_MIXER_SCLK); bits = 16; data = 0; - /* set DATA line as input */ - GPIO3_DIR &= ~PIN_MIXER_DATA; + /* set SDATA line as input */ + GPIO3_DIR &= ~PIN_MIXER_SDATA; while (bits--) { data <<= 1; serial_delay(); - gpio_set(PORT_MIXER, PIN_MIXER_CLK); + gpio_set(PORT_MIXER, PIN_MIXER_SCLK); serial_delay(); - gpio_clear(PORT_MIXER, PIN_MIXER_CLK); - if (MIXER_DATA_STATE) + gpio_clear(PORT_MIXER, PIN_MIXER_SCLK); + if (MIXER_SDATA_STATE) data |= 1; } - /* set DATA line as output */ - GPIO3_DIR |= PIN_MIXER_DATA; + /* set SDATA line as output */ + GPIO3_DIR |= PIN_MIXER_SDATA; serial_delay(); gpio_set(PORT_MIXER, PIN_MIXER_ENX); diff --git a/firmware/mixertx/README b/firmware/mixertx/README index eeb90270..5499e2c9 100644 --- a/firmware/mixertx/README +++ b/firmware/mixertx/README @@ -20,7 +20,7 @@ GND: Lollipop P8 pin 1, 3, or 5 -> Jellybean P17 pin 1, 3, or 5 VCC: Lollipop P8 pin 2, 4, or 6 -> Jellybean P17 pin 2, 4, or 6 ENX: Lollipop P4 pin 5 -> Jellybean P5 pin 1 SCLK: Lollipop P4 pin 3 -> Jellybean P5 pin 3 -DATA: Lollipop P4 pin 1 -> Jellybean P5 pin 5 +SDATA: Lollipop P4 pin 1 -> Jellybean P5 pin 5 Also RF connectors, and you're on your own to get the RF switches configured properly. From 2c76cc9bd2a2b8291b1d40df5475843d19873784 Mon Sep 17 00:00:00 2001 From: Michael Ossmann Date: Thu, 14 Jun 2012 10:46:55 -0600 Subject: [PATCH 4/4] fixed pinout in README --- firmware/mixertx/README | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/mixertx/README b/firmware/mixertx/README index 5499e2c9..bed2f6bf 100644 --- a/firmware/mixertx/README +++ b/firmware/mixertx/README @@ -18,9 +18,9 @@ GND: Lemondrop P5 -> Jellybean P13 Required Lollipop -> Jellybean connections: GND: Lollipop P8 pin 1, 3, or 5 -> Jellybean P17 pin 1, 3, or 5 VCC: Lollipop P8 pin 2, 4, or 6 -> Jellybean P17 pin 2, 4, or 6 -ENX: Lollipop P4 pin 5 -> Jellybean P5 pin 1 -SCLK: Lollipop P4 pin 3 -> Jellybean P5 pin 3 -SDATA: Lollipop P4 pin 1 -> Jellybean P5 pin 5 +ENX: Lollipop P4 pin 5 -> Jellybean P5 pin 2 +SCLK: Lollipop P4 pin 3 -> Jellybean P5 pin 4 +SDATA: Lollipop P4 pin 1 -> Jellybean P5 pin 6 Also RF connectors, and you're on your own to get the RF switches configured properly.