]> rtime.felk.cvut.cz Git - arc.git/blob - include/Byteorder.h
Added an example of CAN communication for the TMS570LS31x HDK
[arc.git] / include / Byteorder.h
1 /* -------------------------------- Arctic Core ------------------------------\r
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
3  *\r
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
5  *\r
6  * This source code is free software; you can redistribute it and/or modify it\r
7  * under the terms of the GNU General Public License version 2 as published by the\r
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
9  *\r
10  * This program is distributed in the hope that it will be useful, but\r
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\r
13  * for more details.\r
14  * -------------------------------- Arctic Core ------------------------------*/\r
15 \r
16 \r
17 \r
18 \r
19 \r
20 \r
21 \r
22 \r
23 #ifndef BYTEORDER_H_\r
24 #define BYTEORDER_H_\r
25 \r
26 // NOTE!\r
27 // Implements only big endian stuff\r
28 \r
29 //#define BE_TO_CPU_32(x) ((uint8_t*)(x))[0] + (((uint8_t*)(x))[1]<<8) + (((uint8_t*)(x))[2]<<16) + (((uint8_t*)(x))[3]<<24)\r
30 //#define BIG_ENDIAN\r
31 \r
32 // a,b,c,d -> d,c,b,a\r
33 #define bswap32(x)              (((uint32)(x) >> 24) | (((uint32)(x) >> 8) & 0xff00) | (((uint32)(x) & 0xff00 ) << 8) | (((uint32)(x) & 0xff) << 24) )\r
34 #define bswap16(x)              (((uint16)(x) >> 8) | (((uint16)(x) & 0xff) << 8))\r
35 \r
36 #if 0 //defined(BIG_ENDIAN)\r
37 #define cpu_to_le32(_x) bswap32(_x)\r
38 #define cpu_to_be32(_x)\r
39 #define le32_to_cpu(_x)\r
40 #define be32_to_cpu(_x)\r
41 #endif\r
42 \r
43 \r
44 #endif /*BYTEORDER_H_*/\r