Fixed some I2C items to work on STM Nucleo F446RE
Diff: MCP9600.h
- Revision:
- 1:4fbdf7768530
- Parent:
- 0:f33e95899738
diff -r f33e95899738 -r 4fbdf7768530 MCP9600.h --- a/MCP9600.h Tue Oct 02 23:00:22 2018 +0000 +++ b/MCP9600.h Thu Aug 08 15:36:58 2019 +0000 @@ -18,24 +18,27 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. + + * Modified by David Wahl to work with STM Nucleo boards (tested on Nucleo F446RE). Rewrote I2C related items. */ - + #ifndef MBED_MCP9600_H #define MBED_MCP9600_H #include "mbed.h" -class MCP9600 { +class MCP9600 +{ public: // Constructor with I2C instance and I2C Device Address of MCP9600 - MCP9600(I2C *i2c, char addr); - + MCP9600(I2C &i2c, int addr); + // Set I2C Device Address of MCP9600 - void setAddress(char addr); - + //void setAddress(char addr); + // Get I2C Device Address of this instance char getAddress(void); - + // Read Temperature from Temperature Register // tempRegister 0:TH / 1:Tdelta / 2: TC // Return value: temperature in float value (degree C) @@ -45,12 +48,12 @@ // Return value: 24 bit ADC register value // Refer MCP9600 datasheet for details. long readADCRegister(void); - + // Write to Status Register // statRegister: Status data to write // About register bit, refer MCP9600 datasheet. char writeStatusRegister( char statRegister ); - + // Read Status Register // About register bit, refer MCP9600 datasheet. char readStatusRegister( void ); @@ -59,20 +62,20 @@ // cnfgRegister: Sensor Config data to write // About register bit, refer MCP9600 datasheet. char writeSensorConfigRegister( char cnfgRegister ); - + // Read Sensor Configuration Register // About register bit, refer MCP9600 datasheet. char readSensorConfigRegister( void ); - + // Write to Device Configuration Register // cnfgRegister: Device Config data to write // About register bit, refer MCP9600 datasheet. char writeDeviceConfigRegister( char cnfgRegister ); - + // Read Device Configuration Register // About register bit, refer MCP9600 datasheet. char readDeviceConfigRegister( void ); - + // Write to Alert Configuration Register // alertCH: Alert CH (1 to 4) // alertConfig: Alert Configuration data to write to register @@ -96,7 +99,7 @@ // alertCH: Alert CH (1 to 4) // Return Value: Alert Histerisis Register value char readAlertHisterisisRegister(char alertCH); - + // Write to Alert Limit Value Register // alertCH: Alert CH (1 to 4) // alertLimit_val: Alert Limit value to write to register @@ -116,8 +119,8 @@ ~MCP9600(); private: - char Mcp9600Addr ; // I2C Slave Address of MCP9600 - I2C *i2cMcp9600; // I2C bus reference + I2C &i2c; + uint8_t mi2cAddress; }; #endif