Steven Kay
/
MCP9803_NUCLEO_Driver
Initial I2C Working
Diff: MCP9803/MCP9803.h
- Revision:
- 2:832cb4376d2a
- Parent:
- 1:444546e8cd20
--- a/MCP9803/MCP9803.h Wed Mar 29 12:20:34 2017 +0000 +++ b/MCP9803/MCP9803.h Wed Mar 29 17:55:38 2017 +0000 @@ -19,6 +19,34 @@ #include "mbed.h" +#define SUCCESS 0 +#define FAILURE 1 + +#define FAIL_EVEN_VALUE 0xFF +#define FAIL_ODD_VALUE 0x00 + +#define TEMP_REG_POINT 0x00 +#define CONFIG_REG_POINT 0x01 +#define TEMP_HYST_POINT 0x02 +#define TEMP_LIM_SET_POINT 0x03 + +#define CONFIG_CMD_LENGTH 2 +#define TEMP_DATA_LENGTH 2 + +#define READ_TEMP_FAIL_VALUE 0x0FF0 +#define READ_TEMP_FAIL_ERROR -2000 + +#define CELCIUS 0x01 +#define FARENHEIT 0x02 +#define KELVIN 0x03 +#define FORMAT_FAIL -1000 + +#define RAW_TO_C 0.0625 +#define C_F_1 1.8 +#define C_F_2 32 +#define C_TO_F 273.15 + + union CONFIG_REG { struct @@ -39,9 +67,12 @@ public: MCP9803(PinName sda, PinName scl, int Address, int frequency); - int ConfigSensor(); - int I2C_Write(char *dataOut,int dataLen); - char *I2C_Read(int dataLen); + int ConfigSensor( int shutdown, int comp_int, int alert_polarity, + int fault_guide, int adc_res, int one_shot); + + + int RawTempValue(); + float FormattedTempValue(int format); private: I2C *_I2C; @@ -50,13 +81,10 @@ char *inBuffer; - void setBufferSize(int dataLen); - char *getBuffer(); - void setBuffer(); + int I2C_Write(char *dataOut,int dataLen); + char *I2C_Read(int dataLen); + void setBufferSize(int dataLen); -protected: - - }; #endif \ No newline at end of file