aroarfw
|
00001 //byteorder.h: 00002 00003 /* 00004 * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2012 00005 * 00006 * This file is part of aroarfw, a RoarAudio framework for 00007 * embedded systems (µControlers). 00008 * 00009 * This file is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License version 3 00011 * or (at your option) any later version as published by 00012 * the Free Software Foundation. 00013 * 00014 * aroarfw is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this software; see the file COPYING. If not, write to 00021 * the Free Software Foundation, 51 Franklin Street, Fifth Floor, 00022 * Boston, MA 02110-1301, USA. 00023 */ 00024 00025 #ifndef _AROARFW_BYTEORDER_H_ 00026 #define _AROARFW_BYTEORDER_H_ 00027 00037 #define RBO_H2NB16(buf, v) ( \ 00038 ((uint16_t)(((unsigned char*)(buf))[0] = ((uint16_t)(v) >> 8) & 0xFF) << 8) + \ 00039 (uint16_t)(((unsigned char*)(buf))[1] = (uint16_t)(v) & 0xFF) \ 00040 ) 00041 00050 #define RBO_NB2H16(buf) ( \ 00051 ((uint16_t)(((unsigned char*)(buf))[0]) << 8) + \ 00052 (uint16_t)(((unsigned char*)(buf))[1]) \ 00053 ) 00054 00064 #define RBO_H2NB32(buf, v) ( \ 00065 ((uint32_t)(((unsigned char*)(buf))[0] = ((uint32_t)(v) >> 24) & 0xFF) << 24) + \ 00066 ((uint32_t)(((unsigned char*)(buf))[1] = ((uint32_t)(v) >> 16) & 0xFF) << 16) + \ 00067 ((uint32_t)(((unsigned char*)(buf))[2] = ((uint32_t)(v) >> 8) & 0xFF) << 8) + \ 00068 (uint32_t)(((unsigned char*)(buf))[3] = (uint32_t)(v) & 0xFF) \ 00069 ) 00070 00079 #define RBO_NB2H32(buf) ( \ 00080 ((uint32_t)(((unsigned char*)(buf))[0]) << 24) + \ 00081 ((uint32_t)(((unsigned char*)(buf))[1]) << 16) + \ 00082 ((uint32_t)(((unsigned char*)(buf))[2]) << 8) + \ 00083 (uint32_t)(((unsigned char*)(buf))[3]) \ 00084 ) 00085 00086 #endif 00087 00088 //ll