|
| 1 | +/* |
| 2 | + Access_Tests.ino |
| 3 | +
|
| 4 | + Test access for different field sizes |
| 5 | +
|
| 6 | + License: MIT. Please see LICENSE.md for more details |
| 7 | +*/ |
| 8 | + |
| 9 | +#include <SparkFun_Extensible_Message_Parser.h> //http://librarymanager/All#SparkFun_Extensible_Message_Parser |
| 10 | + |
| 11 | +extern uint8_t bufferArea[]; |
| 12 | + |
| 13 | +//---------------------------------------- |
| 14 | +// Return the 8-bit value at the beginning of the buffer |
| 15 | +//---------------------------------------- |
| 16 | +uint8_t access_8_bits(uint8_t * buffer) |
| 17 | +{ |
| 18 | + sempPrintStringLn(output, "access_8_bits"); |
| 19 | + return *buffer; |
| 20 | +} |
| 21 | + |
| 22 | +//---------------------------------------- |
| 23 | +// Return the 16-bit value at the beginning of the buffer |
| 24 | +//---------------------------------------- |
| 25 | +uint16_t access_16_bits(uint8_t * buffer) |
| 26 | +{ |
| 27 | + sempPrintStringLn(output, "access_16_bits"); |
| 28 | + return *(uint16_t *)buffer; |
| 29 | +} |
| 30 | + |
| 31 | +//---------------------------------------- |
| 32 | +// Return the 32-bit value at the beginning of the buffer |
| 33 | +//---------------------------------------- |
| 34 | +uint32_t access_32_bits(uint8_t * buffer) |
| 35 | +{ |
| 36 | + sempPrintStringLn(output, "access_32_bits"); |
| 37 | + return *(uint32_t *)buffer; |
| 38 | +} |
| 39 | + |
| 40 | +//---------------------------------------- |
| 41 | +// Return the 64-bit value at the beginning of the buffer |
| 42 | +//---------------------------------------- |
| 43 | +uint64_t access_64_bits(uint8_t * buffer) |
| 44 | +{ |
| 45 | + sempPrintStringLn(output, "access_64_bits"); |
| 46 | + return *(uint64_t *)buffer; |
| 47 | +} |
| 48 | + |
| 49 | +//---------------------------------------- |
| 50 | +// Test the justification routines |
| 51 | +//---------------------------------------- |
| 52 | +void accessTests(uint8_t * buffer) |
| 53 | +{ |
| 54 | + access_8_bits(buffer); |
| 55 | + access_16_bits(buffer); |
| 56 | + access_32_bits(buffer); |
| 57 | + access_64_bits(buffer); |
| 58 | +} |
0 commit comments