|
| 1 | +// File: sfeToolkit.cpp |
| 2 | +// |
| 3 | +// General impl file for the SparkFun Toolkit |
| 4 | +/* |
| 5 | +
|
| 6 | +The MIT License (MIT) |
| 7 | +
|
| 8 | +Copyright (c) 2024 SparkFun Electronics |
| 9 | +
|
| 10 | +Permission is hereby granted, free of charge, to any person obtaining a |
| 11 | +copy of this software and associated documentation files (the "Software"), |
| 12 | +to deal in the Software without restriction, including without limitation |
| 13 | +the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 14 | +and/or sell copies of the Software, and to permit persons to whom the |
| 15 | +Software is furnished to do so, subject to the following conditions: The |
| 16 | +above copyright notice and this permission notice shall be included in all |
| 17 | +copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED |
| 18 | +"AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT |
| 19 | +NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
| 20 | +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 21 | +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 22 | +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 23 | +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 24 | +*/ |
| 25 | +#include "sfeToolkit.h" |
| 26 | +#include <stdint.h> |
| 27 | + |
| 28 | +/** |
| 29 | + * @brief C function - Runtime check for system byte order |
| 30 | + */ |
| 31 | +sfeTKByteOrder_t systemByteOrder(void) |
| 32 | +{ |
| 33 | + uint16_t i = 1; |
| 34 | + return *((uint8_t *)&i) == 0 ? SFETK_BIG_ENDIAN : SFETK_LITTLE_ENDIAN; |
| 35 | +} |
0 commit comments