summaryrefslogtreecommitdiffstats
path: root/api/Elonics_E4000.c
diff options
context:
space:
mode:
Diffstat (limited to 'api/Elonics_E4000.c')
-rw-r--r--api/Elonics_E4000.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/api/Elonics_E4000.c b/api/Elonics_E4000.c
new file mode 100644
index 0000000..949df21
--- /dev/null
+++ b/api/Elonics_E4000.c
@@ -0,0 +1,108 @@
+/**
+ * @(#)Afa_E4000.cpp
+ *
+ * ==========================================================
+ * Version: 2.0
+ * Date: 2008.07.02
+ * ==========================================================
+ *
+ * ==========================================================
+ * History:
+ *
+ * Date Author Description
+ * ----------------------------------------------------------
+ *
+ * 2008.07.02 Tom Lin added tuner version
+ * ==========================================================
+ *
+ * Copyright 2005 Afatech, Inc. All rights reserved.
+ *
+ */
+
+//#include <stdio.h> //for Linux
+#include "type.h"
+#include "error.h"
+#include "user.h"
+#include "register.h"
+#include "standard.h"
+#include "e4000.h"
+#include "Elonics_E4000.h"
+#include "Elonics_E4000_Script.h"
+
+
+Demodulator* E4000_demodulator;
+Byte E4000_chip;
+Word E4000_bandwidth;
+Dword E4000_frequency;
+Dword Ref_clk=26000; //Tuner reference clock frequency (kHz)
+
+Dword E4000_open (
+ IN Demodulator* demodulator,
+ IN Byte chip
+ ) {
+ E4000_demodulator = demodulator;
+ E4000_chip = chip;
+
+ E4000_tunerreset ();
+ E4000_Tunerclock();
+ // E4000_filtercal();
+ E4000_Qpeak();
+ E4000_DCoffloop();
+ //E4000_commonmode();
+ E4000_GainControlinit();
+ return (Error_NO_ERROR);
+}
+
+
+Dword E4000_close (
+ IN Demodulator* demodulator,
+ IN Byte chip
+ )
+{
+ E4000_demodulator = demodulator;
+ E4000_chip = chip;
+ Dword error = 0;
+ Byte buffer[1];
+ buffer[0] = 0x00;
+ error = Standard_writeTunerRegisters (E4000_demodulator, E4000_chip, 0x00, 1, buffer);
+ //Powers down tuner (will recover if tuner initialisation is subsequently run)
+ return (Error_NO_ERROR);
+}
+
+
+Dword E4000_set (
+ IN Demodulator* demodulator,
+ IN Byte chip,
+ IN Word bandwidth,
+ IN Dword frequency
+) {
+ E4000_demodulator = demodulator;
+ E4000_chip = chip;
+ E4000_bandwidth=bandwidth;
+ E4000_frequency=frequency;
+ E4000_Gainmanual();
+ E4000_PLL();
+ E4000_LNAfilter();
+ E4000_IFfilter();
+ E4000_freqband();
+ E4000_DCoffLUT();
+ E4000_Gainauto();
+ Dword error = 0;
+return (Error_NO_ERROR);
+}
+
+
+
+
+TunerDescription tuner_E4000 = {
+ E4000_open,
+ E4000_close,
+ E4000_set,
+ E4000_scripts,
+ E4000_scriptSets,
+ 0xC8, /** tuner i2c address */
+ 1, /** length of tuner register address */
+ 0, /** tuner if */
+ False, /** spectrum inverse */
+ 0xFF, /** tuner id */
+};