Steven Kay
/
MCP9803_NUCLEO_Driver
Initial I2C Working
MCP9803/MCP9803.h@1:444546e8cd20, 2017-03-29 (annotated)
- Committer:
- sk398
- Date:
- Wed Mar 29 12:20:34 2017 +0000
- Revision:
- 1:444546e8cd20
- Parent:
- 0:fbf82bf637bb
- Child:
- 2:832cb4376d2a
working, useful for I2C Comms with NUCLEO Boards;
Who changed what in which revision?
User | Revision | Line number | New 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 | 1:444546e8cd20 | 50 | |
sk398 | 1:444546e8cd20 | 51 | char *inBuffer; |
sk398 | 1:444546e8cd20 | 52 | |
sk398 | 1:444546e8cd20 | 53 | void setBufferSize(int dataLen); |
sk398 | 1:444546e8cd20 | 54 | char *getBuffer(); |
sk398 | 1:444546e8cd20 | 55 | void setBuffer(); |
sk398 | 0:fbf82bf637bb | 56 | |
sk398 | 0:fbf82bf637bb | 57 | protected: |
sk398 | 0:fbf82bf637bb | 58 | |
sk398 | 0:fbf82bf637bb | 59 | |
sk398 | 0:fbf82bf637bb | 60 | }; |
sk398 | 0:fbf82bf637bb | 61 | |
sk398 | 0:fbf82bf637bb | 62 | #endif |