From 61ea4db04063c71d2088fa4409aa17c74b715be4 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 11 Jan 2012 15:42:41 +0000 Subject: starting i2c version --- ESS1995i2c/electic.h | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 ESS1995i2c/electic.h (limited to 'ESS1995i2c/electic.h') 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 //main Arduino header file +#include "adapticsBT.h" +#include + +#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(); -- cgit v1.2.3