Initial I2C Working

Dependencies:   mbed

Committer:
sk398
Date:
Wed Mar 29 08:33:10 2017 +0000
Revision:
0:fbf82bf637bb
Child:
1:444546e8cd20
Initial version - I2C working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sk398 0:fbf82bf637bb 1 /********************************************************************************************
sk398 0:fbf82bf637bb 2
sk398 0:fbf82bf637bb 3 Filename: MCP9803.h
sk398 0:fbf82bf637bb 4
sk398 0:fbf82bf637bb 5 Original Author: Steven Kay
sk398 0:fbf82bf637bb 6
sk398 0:fbf82bf637bb 7 Development Group: Autonomous Systems Group, RAL Space
sk398 0:fbf82bf637bb 8
sk398 0:fbf82bf637bb 9 Original Creation Date: April 2017
sk398 0:fbf82bf637bb 10
sk398 0:fbf82bf637bb 11 Description: <Desc>
sk398 0:fbf82bf637bb 12
sk398 0:fbf82bf637bb 13 Revision History: Version 1.0 - Initial Release
sk398 0:fbf82bf637bb 14
sk398 0:fbf82bf637bb 15 *********************************************************************************************/
sk398 0:fbf82bf637bb 16
sk398 0:fbf82bf637bb 17 #ifndef MCP9803_H
sk398 0:fbf82bf637bb 18 #define MCP9803_H
sk398 0:fbf82bf637bb 19
sk398 0:fbf82bf637bb 20 #include "mbed.h"
sk398 0:fbf82bf637bb 21
sk398 0:fbf82bf637bb 22 union CONFIG_REG
sk398 0:fbf82bf637bb 23 {
sk398 0:fbf82bf637bb 24 struct
sk398 0:fbf82bf637bb 25 {
sk398 0:fbf82bf637bb 26 unsigned int SHUTDOWN_BIT: 1;
sk398 0:fbf82bf637bb 27 unsigned int COMP_INT_BIT: 1;
sk398 0:fbf82bf637bb 28 unsigned int ALERT_POLARITY_BIT: 1;
sk398 0:fbf82bf637bb 29 unsigned int FAULT_QUEUE: 2;
sk398 0:fbf82bf637bb 30 unsigned int ADC_RES: 2;
sk398 0:fbf82bf637bb 31 unsigned int ONE_SHOT: 1;
sk398 0:fbf82bf637bb 32 } CONFIG_BITS;
sk398 0:fbf82bf637bb 33
sk398 0:fbf82bf637bb 34 uint8_t CONFIG_VALUE;
sk398 0:fbf82bf637bb 35 };
sk398 0:fbf82bf637bb 36
sk398 0:fbf82bf637bb 37 class MCP9803
sk398 0:fbf82bf637bb 38 {
sk398 0:fbf82bf637bb 39
sk398 0:fbf82bf637bb 40 public:
sk398 0:fbf82bf637bb 41 MCP9803(PinName sda, PinName scl, int Address, int frequency);
sk398 0:fbf82bf637bb 42 int ConfigSensor();
sk398 0:fbf82bf637bb 43 int I2C_Write(char *dataOut,int dataLen);
sk398 0:fbf82bf637bb 44 char *I2C_Read(int dataLen);
sk398 0:fbf82bf637bb 45
sk398 0:fbf82bf637bb 46 private:
sk398 0:fbf82bf637bb 47 I2C *_I2C;
sk398 0:fbf82bf637bb 48 int chipAddress;
sk398 0:fbf82bf637bb 49 union CONFIG_REG CONFIG_REG_VALUE;
sk398 0:fbf82bf637bb 50
sk398 0:fbf82bf637bb 51
sk398 0:fbf82bf637bb 52 protected:
sk398 0:fbf82bf637bb 53
sk398 0:fbf82bf637bb 54
sk398 0:fbf82bf637bb 55 };
sk398 0:fbf82bf637bb 56
sk398 0:fbf82bf637bb 57 #endif