Example of using the DS271 battery monitor on the ESP motor driver board using PC_12 as the OneWire interface (Any other GPIO can be used)
ds2781.h@0:de50f9a71c22, 2019-03-04 (annotated)
- Committer:
- EmbeddedSam
- Date:
- Mon Mar 04 14:48:45 2019 +0000
- Revision:
- 0:de50f9a71c22
Initial Commit;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| EmbeddedSam | 0:de50f9a71c22 | 1 | #include "stdint.h" |
| EmbeddedSam | 0:de50f9a71c22 | 2 | |
| EmbeddedSam | 0:de50f9a71c22 | 3 | /* ***** net address commands ***** */ |
| EmbeddedSam | 0:de50f9a71c22 | 4 | #define READ_NETADDRESS 0x33 |
| EmbeddedSam | 0:de50f9a71c22 | 5 | #define SKIP_NETADDRESS 0xCC |
| EmbeddedSam | 0:de50f9a71c22 | 6 | |
| EmbeddedSam | 0:de50f9a71c22 | 7 | |
| EmbeddedSam | 0:de50f9a71c22 | 8 | /* ***** function commands ***** */ |
| EmbeddedSam | 0:de50f9a71c22 | 9 | #define READ_DATA 0x69 |
| EmbeddedSam | 0:de50f9a71c22 | 10 | #define WRITE_DATA 0x6C |
| EmbeddedSam | 0:de50f9a71c22 | 11 | #define COPY_DATA 0x48 |
| EmbeddedSam | 0:de50f9a71c22 | 12 | #define RECALL_DATA 0xB8 |
| EmbeddedSam | 0:de50f9a71c22 | 13 | #define LOCK_EEPROM 0x6A //DO NOT USE |
| EmbeddedSam | 0:de50f9a71c22 | 14 | |
| EmbeddedSam | 0:de50f9a71c22 | 15 | |
| EmbeddedSam | 0:de50f9a71c22 | 16 | /* ***** function prototypes ***** */ |
| EmbeddedSam | 0:de50f9a71c22 | 17 | /* Function details can be found in the .c file */ |
| EmbeddedSam | 0:de50f9a71c22 | 18 | int ReadVoltage (void); |
| EmbeddedSam | 0:de50f9a71c22 | 19 | uint16_t ReadCurrent (void); |
| EmbeddedSam | 0:de50f9a71c22 | 20 | uint32_t ReadAccumulatedCurrent (void); |
| EmbeddedSam | 0:de50f9a71c22 | 21 | void ResetAccumulatedCurrent (void); |
| EmbeddedSam | 0:de50f9a71c22 | 22 | uint32_t ReadNetAddress (void); |
| EmbeddedSam | 0:de50f9a71c22 | 23 | uint16_t ReadTemperature (void); |
| EmbeddedSam | 0:de50f9a71c22 | 24 | uint8_t ReadCurrentOffset (void); |
| EmbeddedSam | 0:de50f9a71c22 | 25 | void WriteCurrentOffset (uint8_t offset); |
| EmbeddedSam | 0:de50f9a71c22 | 26 | void AdjustCurrentOffset (void); |
| EmbeddedSam | 0:de50f9a71c22 | 27 | void UpdateControlRegister (uint8_t control); |
| EmbeddedSam | 0:de50f9a71c22 | 28 | uint8_t ReadRAM (uint8_t addr); |
| EmbeddedSam | 0:de50f9a71c22 | 29 | void WriteRAM (uint8_t byte, uint8_t addr); |
| EmbeddedSam | 0:de50f9a71c22 | 30 | void CopyEEPROM (uint8_t addr); |
| EmbeddedSam | 0:de50f9a71c22 | 31 | void RecallEEPROM (uint8_t addr); |
| EmbeddedSam | 0:de50f9a71c22 | 32 |