![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Fork to see if I can get working
Dependencies: BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated
Fork of xDotBridge_update_test20180823 by
xDotBridge/src/EepromLog.cpp@73:dc5adf462660, 2017-04-10 (annotated)
- Committer:
- Matt Briggs
- Date:
- Mon Apr 10 16:06:31 2017 -0600
- Revision:
- 73:dc5adf462660
Forgot to add some files.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Matt Briggs | 73:dc5adf462660 | 1 | /* |
Matt Briggs | 73:dc5adf462660 | 2 | * EepromLog.cpp |
Matt Briggs | 73:dc5adf462660 | 3 | * |
Matt Briggs | 73:dc5adf462660 | 4 | * Created on: Mar 23, 2017 |
Matt Briggs | 73:dc5adf462660 | 5 | * Author: mbriggs |
Matt Briggs | 73:dc5adf462660 | 6 | */ |
Matt Briggs | 73:dc5adf462660 | 7 | |
Matt Briggs | 73:dc5adf462660 | 8 | #include "EepromLog.h" |
Matt Briggs | 73:dc5adf462660 | 9 | #include "dot_util.h" |
Matt Briggs | 73:dc5adf462660 | 10 | #include <cstring> |
Matt Briggs | 73:dc5adf462660 | 11 | |
Matt Briggs | 73:dc5adf462660 | 12 | EepromLog::EepromLog(uint16_t baseAddr, uint8_t size) |
Matt Briggs | 73:dc5adf462660 | 13 | { |
Matt Briggs | 73:dc5adf462660 | 14 | mBaseAddr = baseAddr; |
Matt Briggs | 73:dc5adf462660 | 15 | mLogSize = size; |
Matt Briggs | 73:dc5adf462660 | 16 | mData = new uint8_t[size]; |
Matt Briggs | 73:dc5adf462660 | 17 | } |
Matt Briggs | 73:dc5adf462660 | 18 | EepromLog::~EepromLog() |
Matt Briggs | 73:dc5adf462660 | 19 | { |
Matt Briggs | 73:dc5adf462660 | 20 | mLogSize=0; |
Matt Briggs | 73:dc5adf462660 | 21 | delete mData; |
Matt Briggs | 73:dc5adf462660 | 22 | } |
Matt Briggs | 73:dc5adf462660 | 23 | void EepromLog::clear() |
Matt Briggs | 73:dc5adf462660 | 24 | { |
Matt Briggs | 73:dc5adf462660 | 25 | if (mLogSize == 0 || mData == NULL) |
Matt Briggs | 73:dc5adf462660 | 26 | return; |
Matt Briggs | 73:dc5adf462660 | 27 | std::memset(mData, 0x00, mLogSize); |
Matt Briggs | 73:dc5adf462660 | 28 | } |
Matt Briggs | 73:dc5adf462660 | 29 | bool EepromLog::read() |
Matt Briggs | 73:dc5adf462660 | 30 | { |
Matt Briggs | 73:dc5adf462660 | 31 | if (mLogSize == 0 || mData == NULL) |
Matt Briggs | 73:dc5adf462660 | 32 | return false; |
Matt Briggs | 73:dc5adf462660 | 33 | return dot->nvmRead(mBaseAddr, mData, mLogSize); |
Matt Briggs | 73:dc5adf462660 | 34 | } |
Matt Briggs | 73:dc5adf462660 | 35 | bool EepromLog::save() |
Matt Briggs | 73:dc5adf462660 | 36 | { |
Matt Briggs | 73:dc5adf462660 | 37 | if (mLogSize == 0 || mData == NULL) |
Matt Briggs | 73:dc5adf462660 | 38 | return false; |
Matt Briggs | 73:dc5adf462660 | 39 | return dot->nvmWrite(mBaseAddr, mData, mLogSize); |
Matt Briggs | 73:dc5adf462660 | 40 | } |