Set write permission for 'write without response' characteristics.

Fork of nRF51822 by Nordic Semiconductor

Committer:
marcuschang
Date:
Fri Dec 12 17:12:35 2014 +0000
Revision:
85:17fe69405098
Parent:
0:eff01767de02
Write permission was not set for 'write without response' characteristics.

Who changed what in which revision?

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