aroarfw
|
00001 //caps.h: 00002 00003 /* 00004 * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 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_CAPS_H_ 00026 #define _AROARFW_CAPS_H_ 00027 00028 #include <stdint.h> 00029 #include <aroarfw/vendor.h> 00030 00031 #ifdef __GNUC__ 00032 #define __RPACKED__ __attribute__((packed)) 00033 #else 00034 #define __RPACKED__ 00035 #warn Don't know how to pack a struct with your compiler correctly 00036 #endif 00037 00039 typedef union { 00041 uint32_t u32; 00043 struct { 00045 uint8_t vendor; 00047 uint8_t standardmsb; 00049 uint8_t standardlsb; 00051 uint8_t version; 00052 } __RPACKED__ subm; 00054 uint8_t u8array[4]; 00055 } rstandard_t; 00056 00063 #define RSTANDARD_INIT(_vendor,_standard,_version) {.subm = { \ 00064 .vendor = (uint8_t)(rstdvendor_t)(_vendor), \ 00065 .standardmsb = (uint8_t)(uint16_t)(((_standard) & (uint16_t)0xFF00) >> (uint16_t)8), \ 00066 .standardlsb = (uint8_t)(uint16_t)(((_standard) & (uint16_t)0x00FF)), \ 00067 .version = (uint8_t)(_version) \ 00068 } \ 00069 } 00070 00074 #define rstandard_getvendor(x) (((rstandard_t)(x)).subm.vendor) 00075 00079 #define rstandard_getversion(x) (((rstandard_t)(x)).subm.version) 00080 00084 #define rstandard_getstandard(x) (((uint16_t)(((rstandard_t)(x)).subm.standardmsb) << (uint16_t)8) | \ 00085 ((uint16_t)(((rstandard_t)(x)).subm.standardlsb))) 00086 00090 #define rstandard_getu32hbo(x) RBO_NB2H32(&(x)) 00091 00092 #endif 00093 00094 //ll