summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Daniel <cd@maintech.de>2012-06-01 00:15:55 +0200
committerChristian Daniel <cd@maintech.de>2012-06-01 00:15:55 +0200
commit399d41474f184e4fb6e554036239004ec48afa04 (patch)
treeb388f7511f77a93df246dc7ff1ff147758a2d0ab
parent83340d0b371fa5693270871f077d31a910d4af72 (diff)
added accessor functions for specific FPGA registers
-rw-r--r--firmware/include/osdr_fpga.h8
-rw-r--r--firmware/src/osdr_fpga.c20
2 files changed, 28 insertions, 0 deletions
diff --git a/firmware/include/osdr_fpga.h b/firmware/include/osdr_fpga.h
index e1c5a64..2e07f49 100644
--- a/firmware/include/osdr_fpga.h
+++ b/firmware/include/osdr_fpga.h
@@ -8,11 +8,19 @@ enum osdr_fpga_reg {
OSDR_FPGA_REG_ADC_TIMING = 3,
OSDR_FPGA_REG_DUMMY = 4,
OSDR_FPGA_REG_ADC_VAL = 5,
+ OSDR_FPGA_REG_DECIMATION = 6,
+ OSDR_FPGA_REG_IQ_OFS = 7,
+ OSDR_FPGA_REG_IQ_GAIN = 8,
+ OSDR_FPGA_REG_IQ_SWAP = 9,
};
void osdr_fpga_power(int on);
void osdr_fpga_init(uint32_t masterClock);
uint32_t osdr_fpga_reg_read(uint8_t reg);
void osdr_fpga_reg_write(uint8_t reg, uint32_t val);
+void osdr_fpga_set_decimation(uint8_t val);
+void osdr_fpga_set_iq_swap(uint8_t val);
+void osdr_fpga_set_iq_gain(uint16_t igain, uint16_t qgain);
+void osdr_fpga_set_iq_ofs(int16_t iofs, int16_t qofs);
#endif
diff --git a/firmware/src/osdr_fpga.c b/firmware/src/osdr_fpga.c
index 03e3cfb..5b7adf4 100644
--- a/firmware/src/osdr_fpga.c
+++ b/firmware/src/osdr_fpga.c
@@ -106,6 +106,26 @@ void osdr_fpga_power(int on)
PIO_Clear(&fon_pin);
}
+void osdr_fpga_set_decimation(uint8_t val)
+{
+ osdr_fpga_reg_write(OSDR_FPGA_REG_DECIMATION, val);
+}
+
+void osdr_fpga_set_iq_swap(uint8_t val)
+{
+ osdr_fpga_reg_write(OSDR_FPGA_REG_IQ_SWAP, (val & 1) ^ 1);
+}
+
+void osdr_fpga_set_iq_gain(uint16_t igain, uint16_t qgain)
+{
+ osdr_fpga_reg_write(OSDR_FPGA_REG_IQ_GAIN, ((uint32_t)igain) | (((uint32_t)qgain) << 16));
+}
+
+void osdr_fpga_set_iq_ofs(int16_t iofs, int16_t qofs)
+{
+ osdr_fpga_reg_write(OSDR_FPGA_REG_IQ_OFS, (((uint32_t)iofs) & 0xffff) | ((((uint32_t)qofs) << 16) & 0xffff0000));
+}
+
/***********************************************************************
* command integration