aroarfw
caps.h
Go to the documentation of this file.
1 //caps.h:
2 
3 /*
4  * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2012-2013
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 #include <aroarfw/types.h>
31 
32 typedef union {
34  uint32_t u32;
36  struct {
38  uint8_t vendor;
40  uint8_t standardmsb;
42  uint8_t standardlsb;
44  uint8_t version;
45  } __RPACKED__ subm;
47  uint8_t u8array[4];
48 } rstandard_t;
49 
56 #define RSTANDARD_INIT(_vendor,_standard,_version) {.subm = { \
57  .vendor = (uint8_t)(rstdvendor_t)(_vendor), \
58  .standardmsb = (uint8_t)(uint16_t)(((_standard) & (uint16_t)0xFF00) >> (uint16_t)8), \
59  .standardlsb = (uint8_t)(uint16_t)(((_standard) & (uint16_t)0x00FF)), \
60  .version = (uint8_t)(_version) \
61  } \
62  }
63 
67 #define rstandard_getvendor(x) (((rstandard_t)(x)).subm.vendor)
68 
72 #define rstandard_getversion(x) (((rstandard_t)(x)).subm.version)
73 
77 #define rstandard_getstandard(x) (((uint16_t)(((rstandard_t)(x)).subm.standardmsb) << (uint16_t)8) | \
78  ((uint16_t)(((rstandard_t)(x)).subm.standardlsb)))
79 
83 #define rstandard_getu32hbo(x) RBO_NB2H32(&(x))
84 
85 #endif
86 
87 //ll
uint8_t standardlsb
Lower 8 bit of standard number.
Definition: caps.h:42
uint8_t version
Standard version.
Definition: caps.h:44
Type to store (in packed format) static information for the device info bank (bank 0)...
Definition: i2c.h:385
uint32_t u32
32 bit unsigned int representation in network byte order
Definition: caps.h:34
uint8_t vendor
Standard Vendor.
Definition: caps.h:38
uint8_t standardmsb
Upper 8 bits of standard number.
Definition: caps.h:40