Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MCP9803.h
00001 /******************************************************************************************** 00002 00003 Filename: MCP9803.h 00004 00005 Original Author: Steven Kay 00006 00007 Development Group: Autonomous Systems Group, RAL Space 00008 00009 Original Creation Date: April 2017 00010 00011 Description: <Desc> 00012 00013 Revision History: Version 1.0 - Initial Release 00014 00015 *********************************************************************************************/ 00016 00017 #ifndef MCP9803_H 00018 #define MCP9803_H 00019 00020 #include "mbed.h" 00021 00022 #define SUCCESS 0 00023 #define FAILURE 1 00024 00025 #define FAIL_EVEN_VALUE 0xFF 00026 #define FAIL_ODD_VALUE 0x00 00027 00028 #define TEMP_REG_POINT 0x00 00029 #define CONFIG_REG_POINT 0x01 00030 #define TEMP_HYST_POINT 0x02 00031 #define TEMP_LIM_SET_POINT 0x03 00032 00033 #define CONFIG_CMD_LENGTH 2 00034 #define TEMP_DATA_LENGTH 2 00035 00036 #define READ_TEMP_FAIL_VALUE 0x0FF0 00037 #define READ_TEMP_FAIL_ERROR -2000 00038 00039 #define CELCIUS 0x01 00040 #define FARENHEIT 0x02 00041 #define KELVIN 0x03 00042 #define FORMAT_FAIL -1000 00043 00044 #define RAW_TO_C 0.0625 00045 #define C_F_1 1.8 00046 #define C_F_2 32 00047 #define C_TO_F 273.15 00048 00049 00050 union CONFIG_REG 00051 { 00052 struct 00053 { 00054 unsigned int SHUTDOWN_BIT: 1; 00055 unsigned int COMP_INT_BIT: 1; 00056 unsigned int ALERT_POLARITY_BIT: 1; 00057 unsigned int FAULT_QUEUE: 2; 00058 unsigned int ADC_RES: 2; 00059 unsigned int ONE_SHOT: 1; 00060 } CONFIG_BITS; 00061 00062 uint8_t CONFIG_VALUE; 00063 }; 00064 00065 class MCP9803 00066 { 00067 00068 public: 00069 MCP9803(PinName sda, PinName scl, int Address, int frequency); 00070 int ConfigSensor( int shutdown, int comp_int, int alert_polarity, 00071 int fault_guide, int adc_res, int one_shot); 00072 00073 00074 int RawTempValue(); 00075 float FormattedTempValue(int format); 00076 00077 private: 00078 I2C *_I2C; 00079 int chipAddress; 00080 union CONFIG_REG CONFIG_REG_VALUE; 00081 00082 char *inBuffer; 00083 00084 int I2C_Write(char *dataOut,int dataLen); 00085 char *I2C_Read(int dataLen); 00086 void setBufferSize(int dataLen); 00087 00088 }; 00089 00090 #endif
Generated on Sun Jul 24 2022 05:14:36 by
1.7.2