From ef3fd926a81ccd99109a0d95a1d79d6ceff3a84c Mon Sep 17 00:00:00 2001 From: Paul Selkirk Date: Tue, 10 Nov 2015 17:31:14 -0500 Subject: Do the proper endianness dance for htonl. --- hal_io_fmc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'hal_io_fmc.c') diff --git a/hal_io_fmc.c b/hal_io_fmc.c index 386e4c8..afbfc6e 100644 --- a/hal_io_fmc.c +++ b/hal_io_fmc.c @@ -47,7 +47,8 @@ static int inited = 0; #endif /* not available in arm-none-eabi libc */ -static uint32_t htonl(uint32_t w) +#ifndef __ARMEB__ // Little endian +static inline uint32_t htonl(uint32_t w) { return ((w & 0x000000ff) << 24) + @@ -55,6 +56,9 @@ static uint32_t htonl(uint32_t w) ((w & 0x00ff0000) >> 8) + ((w & 0xff000000) >> 24); } +#else // Big endian +#define htonl(x) (x) +#endif #define ntohl htonl static hal_error_t init(void) -- cgit v1.2.3