aroarfw
caps.h
Go to the documentation of this file.
1 //caps.h:
2 
3 /*
4  * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2012
5  *
6  * This file is part of aroarfw, a RoarAudio framework for
7  * embedded systems (µControlers).
8  *
9  * This file is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 3
11  * or (at your option) any later version as published by
12  * the Free Software Foundation.
13  *
14  * aroarfw is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this software; see the file COPYING. If not, write to
21  * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  */
24 
25 #ifndef _AROARFW_CAPS_H_
26 #define _AROARFW_CAPS_H_
27 
28 #include <stdint.h>
29 #include <aroarfw/vendor.h>
30 
31 #ifdef __GNUC__
32 #define __RPACKED__ __attribute__((packed))
33 #else
34 #define __RPACKED__
35 #warn Don't know how to pack a struct with your compiler correctly
36 #endif
37 
39 typedef union {
41  uint32_t u32;
43  struct {
45  uint8_t vendor;
47  uint8_t standardmsb;
49  uint8_t standardlsb;
51  uint8_t version;
52  } __RPACKED__ subm;
54  uint8_t u8array[4];
55 } rstandard_t;
56 
63 #define RSTANDARD_INIT(_vendor,_standard,_version) {.subm = { \
64  .vendor = (uint8_t)(rstdvendor_t)(_vendor), \
65  .standardmsb = (uint8_t)(uint16_t)(((_standard) & (uint16_t)0xFF00) >> (uint16_t)8), \
66  .standardlsb = (uint8_t)(uint16_t)(((_standard) & (uint16_t)0x00FF)), \
67  .version = (uint8_t)(_version) \
68  } \
69  }
70 
74 #define rstandard_getvendor(x) (((rstandard_t)(x)).subm.vendor)
75 
79 #define rstandard_getversion(x) (((rstandard_t)(x)).subm.version)
80 
84 #define rstandard_getstandard(x) (((uint16_t)(((rstandard_t)(x)).subm.standardmsb) << (uint16_t)8) | \
85  ((uint16_t)(((rstandard_t)(x)).subm.standardlsb)))
86 
90 #define rstandard_getu32hbo(x) RBO_NB2H32(&(x))
91 
92 #endif
93 
94 //ll