Merge branch 'master' of https://github.com/mossmann/hackrf
This commit is contained in:
@ -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 */
|
||||
|
||||
@ -121,8 +121,8 @@ extern "C"
|
||||
#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 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 */
|
||||
@ -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
|
||||
|
@ -31,15 +31,18 @@ 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;
|
||||
|
||||
//FIXME hard coded setup, fields not broken out
|
||||
/* initial setup */
|
||||
@ -100,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 */
|
||||
@ -109,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();
|
||||
@ -140,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 */
|
||||
@ -149,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);
|
||||
|
11
firmware/mixertx/Makefile
Normal file
11
firmware/mixertx/Makefile
Normal file
@ -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
|
26
firmware/mixertx/README
Normal file
26
firmware/mixertx/README
Normal file
@ -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 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.
|
89
firmware/mixertx/mixertx.c
Normal file
89
firmware/mixertx/mixertx.c
Normal file
@ -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 <libopencm3/lpc43xx/gpio.h>
|
||||
#include <libopencm3/lpc43xx/scu.h>
|
||||
#include <libopencm3/lpc43xx/i2c.h>
|
||||
#include <libopencm3/lpc43xx/ssp.h>
|
||||
|
||||
#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;
|
||||
}
|
Reference in New Issue
Block a user