https://github.com/lathoub/arduino_endian
Determine endianess at compile time
https://github.com/lathoub/arduino_endian
arduino arduino-library endian endianness
Last synced: 3 months ago
JSON representation
Determine endianess at compile time
- Host: GitHub
- URL: https://github.com/lathoub/arduino_endian
- Owner: lathoub
- Created: 2019-10-20T07:06:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-10-20T13:23:26.000Z (over 5 years ago)
- Last Synced: 2025-01-20T00:57:04.529Z (5 months ago)
- Topics: arduino, arduino-library, endian, endianness
- Language: C
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Determine endianess at compile time
Add to your project and the endianess will be available in macro BYTE_ORDER. It will either be BIG_ENDIAN or LITTLE_ENDIAN```c
#include
#includevoid setup()
{
Serial.begin(115200);
Serial.println("booting..");#ifndef BYTE_ORDER
Serial.println("BYTE_ORDER not defined");
#else
#if (BYTE_ORDER == LITTLE_ENDIAN)
Serial.println("Little Endian");
#endif
#if (BYTE_ORDER == BIG_ENDIAN)
Serial.println("Big Endian");
#endif
#endif// from https://en.wikipedia.org/wiki/Endianness
uint32_t word = 0x0A0B0C0D; // An unsigned 32-bit integer.
char *pointer = (char *) &word; // A pointer to the first octet of the word.for (int i = 0; i < 4; i++)
{
Serial.print("byte[");
Serial.print(i);
Serial.print("] = 0x");
Serial.println((unsigned int) * (pointer + i), HEX);
}
}void loop()
{
}
```## Endianess
Chipset | Platform | Endianess
--- | --- | ---
ATMega4809 | Nano Every | Little
ESP32 | Adafruit ESP32 Feather | Little