summaryrefslogtreecommitdiff
path: root/ESS1995i2c/electic.h
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-01-11 15:42:41 +0000
committerTim Redfern <tim@eclectronics.org>2012-01-11 15:42:41 +0000
commit61ea4db04063c71d2088fa4409aa17c74b715be4 (patch)
tree70e5b7ddd241c0792d6985a5b5df04ed37bc0f8d /ESS1995i2c/electic.h
parente9a73bbb3c14af340999f70146747787785f4fee (diff)
starting i2c version
Diffstat (limited to 'ESS1995i2c/electic.h')
-rw-r--r--ESS1995i2c/electic.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/ESS1995i2c/electic.h b/ESS1995i2c/electic.h
new file mode 100644
index 0000000..a04220f
--- /dev/null
+++ b/ESS1995i2c/electic.h
@@ -0,0 +1,75 @@
+/*
+ ESS1995 communications test
+
+ should the bitfields be parsed in the MCU or the app?
+
+ the device needs to be able to do the ranging itself.
+
+ data format-
+
+ ACK is necessary
+
+ write per read? or is it a delay thing
+
+
+*/
+
+#include <WProgram.h> //main Arduino header file
+#include "adapticsBT.h"
+#include <Wire.h>
+
+#define DATA_NEW 2
+#define SCLK 3
+#define SDATA 4
+#define CS 5
+
+//feedback leds
+#define OUTPUT1 12
+#define OUTPUT2 13
+
+#define WRITE_ID 0b11001000
+#define READ_ID 0b11001001
+
+#define ESS1995_ADDR 0b1100100
+
+//clock delays are doubled for 8MHZ chip - CPUSPD isnt working
+//6 and 3 = 83kHz, doesn't work with ISP plugged in
+//500Hz works with ISP (sometimes)
+
+#define CLOCK_DELAY 20
+#define START_DELAY 10
+
+const uint16_t ELECTIC_ID = 0xF0;
+uint8_t packetSize = 7;
+bool connected=false;
+
+uint8_t data[10];
+
+//default write values
+uint8_t CB_SHBP = 0b0;
+uint8_t CB_function = 0b0000; //0b0000 voltage mode
+uint8_t CB_VARCrange = 0b000; //0b001 6v
+uint8_t CB_FREQrange = 0b000;
+uint8_t CB_BUZfreq = 0b000;
+uint8_t CB_ADCrate = 0b00; //0b11 fastest 50hz
+uint8_t CB_ACmode = 0b0;
+uint8_t CB_PEAKmode = 0b0;
+uint8_t CB_PCALmode = 0b0;
+uint8_t CB_LPFbw = 0b000;
+uint8_t CB_EXTdiode = 0b0;
+uint8_t CB_OPconf = 0b00;
+uint8_t CB_FREQinprest = 0b0;
+uint8_t CB_ADPext = 0b0;
+uint8_t CB_DCfs = 0b0;
+
+
+void SCLKcycle_W();
+void SCLKcycle_R();
+void startRead();
+void startWrite();
+void writeByte(uint8_t data);
+void writeStartBit();
+void writeStopBit();
+uint8_t readByte();
+void writeDMM();
+int main();