![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Gets messages form the pc and translates it to I2C and back.
Dependencies: DevInterfaces I2Cinterfaces MCP4725 mbed
Diff: Utility.h
- Revision:
- 2:2330ad8b1baa
- Parent:
- 1:8ba039abd9b8
diff -r 8ba039abd9b8 -r 2330ad8b1baa Utility.h --- a/Utility.h Wed May 18 11:35:45 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -#pragma once - -#include "mbed.h" - -// Splits a number into a set number of bytes -inline void ByteShift(int num, int numBytes, int8_t** bytes, bool lowToHigh =false) { - *bytes = new int8_t[numBytes]; - for (int i = 0; i < numBytes; i++) { - (*bytes)[i] = (num >> 8*(lowToHigh ? i : numBytes-i-1)) & 0xFF; - } -} - -// Unsplits a number of bytes back to a number -inline int ByteUnshift(const int8_t* bytes, int numBytes, bool lowToHigh =false) { - int result = 0; - for (int i = 0; i < numBytes; i++) - result += (bytes[i] << 8*(lowToHigh ? i : numBytes-i-1)); - return result; -} - -// Copies an array deeply -inline void DeepCopy(const int8_t* source, int size, int8_t* dest) { - //*dest = new int8_t[size]; - for (int i = 0; i < size; i++) - dest[i] = source[i]; -} \ No newline at end of file