test firmware for BLE Micro V1.3 1. test io, vcc and ble 2. act as a UART to BLE bridge

Dependencies:   BLE_API Buffer mbed

Fork of BLE_LEDBlinker by Bluetooth Low Energy

Committer:
arch
Date:
Tue Dec 08 06:02:25 2015 +0000
Revision:
11:c8cbc4bc2c17
test firmware for BLE Micro V1.3

Who changed what in which revision?

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