To get started with Seeed Tiny BLE, include detecting motion, button and battery level.

Dependencies:   BLE_API eMPL_MPU6050 mbed nRF51822

Committer:
yihui
Date:
Wed Apr 22 07:47:17 2015 +0000
Revision:
1:fc2f9d636751
update libraries; ; delete nRF51822/nordic-sdk/components/gpiote/app_gpiote.c to solve GPIOTE_IRQHandler multiply defined issue. temperarily change nRF51822 library to folder

Who changed what in which revision?

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