CSSE4011_BLE_IMU IMU Seeed Tiny Ble

Dependencies:   BLE_API_Tiny_BLE MPU6050-DMP-Seeed-Tiny-BLE mbed

Committer:
flywind
Date:
Wed Jun 10 12:56:48 2015 +0000
Revision:
2:44bc61abdf33
Parent:
0:f90c3452d779
milestone working one , yaw pitch roll update in BLE sucessfull

Who changed what in which revision?

UserRevisionLine numberNew contents of line
flywind 0:f90c3452d779 1 /**************************************************************************/
flywind 0:f90c3452d779 2 /*!
flywind 0:f90c3452d779 3 @file binary.h
flywind 0:f90c3452d779 4 @author hathach (tinyusb.org)
flywind 0:f90c3452d779 5
flywind 0:f90c3452d779 6 @section LICENSE
flywind 0:f90c3452d779 7
flywind 0:f90c3452d779 8 Software License Agreement (BSD License)
flywind 0:f90c3452d779 9
flywind 0:f90c3452d779 10 Copyright (c) 2013, K. Townsend (microBuilder.eu)
flywind 0:f90c3452d779 11 All rights reserved.
flywind 0:f90c3452d779 12
flywind 0:f90c3452d779 13 Redistribution and use in source and binary forms, with or without
flywind 0:f90c3452d779 14 modification, are permitted provided that the following conditions are met:
flywind 0:f90c3452d779 15 1. Redistributions of source code must retain the above copyright
flywind 0:f90c3452d779 16 notice, this list of conditions and the following disclaimer.
flywind 0:f90c3452d779 17 2. Redistributions in binary form must reproduce the above copyright
flywind 0:f90c3452d779 18 notice, this list of conditions and the following disclaimer in the
flywind 0:f90c3452d779 19 documentation and/or other materials provided with the distribution.
flywind 0:f90c3452d779 20 3. Neither the name of the copyright holders nor the
flywind 0:f90c3452d779 21 names of its contributors may be used to endorse or promote products
flywind 0:f90c3452d779 22 derived from this software without specific prior written permission.
flywind 0:f90c3452d779 23
flywind 0:f90c3452d779 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
flywind 0:f90c3452d779 25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
flywind 0:f90c3452d779 26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
flywind 0:f90c3452d779 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
flywind 0:f90c3452d779 28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
flywind 0:f90c3452d779 29 INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
flywind 0:f90c3452d779 30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
flywind 0:f90c3452d779 31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
flywind 0:f90c3452d779 32 INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
flywind 0:f90c3452d779 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
flywind 0:f90c3452d779 34 */
flywind 0:f90c3452d779 35 /**************************************************************************/
flywind 0:f90c3452d779 36
flywind 0:f90c3452d779 37 /** \ingroup TBD
flywind 0:f90c3452d779 38 * \defgroup TBD
flywind 0:f90c3452d779 39 * \brief TBD
flywind 0:f90c3452d779 40 *
flywind 0:f90c3452d779 41 * @{
flywind 0:f90c3452d779 42 */
flywind 0:f90c3452d779 43
flywind 0:f90c3452d779 44 #ifndef _BINARY_H_
flywind 0:f90c3452d779 45 #define _BINARY_H_
flywind 0:f90c3452d779 46
flywind 0:f90c3452d779 47 #ifdef __cplusplus
flywind 0:f90c3452d779 48 extern "C" {
flywind 0:f90c3452d779 49 #endif
flywind 0:f90c3452d779 50
flywind 0:f90c3452d779 51 /// n-th Bit
flywind 0:f90c3452d779 52 #define BIT(n) (1 << (n))
flywind 0:f90c3452d779 53
flywind 0:f90c3452d779 54 /// set n-th bit of x to 1
flywind 0:f90c3452d779 55 #define BIT_SET(x, n) ( (x) | BIT(n) )
flywind 0:f90c3452d779 56
flywind 0:f90c3452d779 57 /// clear n-th bit of x
flywind 0:f90c3452d779 58 #define BIT_CLR(x, n) ( (x) & (~BIT(n)) )
flywind 0:f90c3452d779 59
flywind 0:f90c3452d779 60 /// test n-th bit of x
flywind 0:f90c3452d779 61 #define BIT_TEST(x, n) ( (x) & BIT(n) )
flywind 0:f90c3452d779 62
flywind 0:f90c3452d779 63 #if defined(__GNUC__) && !defined(__CC_ARM) // keil does not support binary format
flywind 0:f90c3452d779 64
flywind 0:f90c3452d779 65 #define BIN8(x) ((uint8_t) (0b##x))
flywind 0:f90c3452d779 66 #define BIN16(b1, b2) ((uint16_t) (0b##b1##b2))
flywind 0:f90c3452d779 67 #define BIN32(b1, b2, b3, b4) ((uint32_t) (0b##b1##b2##b3##b4))
flywind 0:f90c3452d779 68
flywind 0:f90c3452d779 69 #else
flywind 0:f90c3452d779 70
flywind 0:f90c3452d779 71 // internal macro of B8, B16, B32
flywind 0:f90c3452d779 72 #define _B8__(x) (((x&0x0000000FUL)?1:0) \
flywind 0:f90c3452d779 73 +((x&0x000000F0UL)?2:0) \
flywind 0:f90c3452d779 74 +((x&0x00000F00UL)?4:0) \
flywind 0:f90c3452d779 75 +((x&0x0000F000UL)?8:0) \
flywind 0:f90c3452d779 76 +((x&0x000F0000UL)?16:0) \
flywind 0:f90c3452d779 77 +((x&0x00F00000UL)?32:0) \
flywind 0:f90c3452d779 78 +((x&0x0F000000UL)?64:0) \
flywind 0:f90c3452d779 79 +((x&0xF0000000UL)?128:0))
flywind 0:f90c3452d779 80
flywind 0:f90c3452d779 81 #define BIN8(d) ((uint8_t) _B8__(0x##d##UL))
flywind 0:f90c3452d779 82 #define BIN16(dmsb,dlsb) (((uint16_t)BIN8(dmsb)<<8) + BIN8(dlsb))
flywind 0:f90c3452d779 83 #define BIN32(dmsb,db2,db3,dlsb) \
flywind 0:f90c3452d779 84 (((uint32_t)BIN8(dmsb)<<24) \
flywind 0:f90c3452d779 85 + ((uint32_t)BIN8(db2)<<16) \
flywind 0:f90c3452d779 86 + ((uint32_t)BIN8(db3)<<8) \
flywind 0:f90c3452d779 87 + BIN8(dlsb))
flywind 0:f90c3452d779 88 #endif
flywind 0:f90c3452d779 89
flywind 0:f90c3452d779 90 #ifdef __cplusplus
flywind 0:f90c3452d779 91 }
flywind 0:f90c3452d779 92 #endif
flywind 0:f90c3452d779 93
flywind 0:f90c3452d779 94 #endif /* _BINARY_H_ */
flywind 0:f90c3452d779 95
flywind 0:f90c3452d779 96 /** @} */