AndroidのBLEラジコンプロポアプリ「BLEPropo」と接続し、RCサーボとDCモータを制御するプログラムです。 BLE Nanoで動作を確認しています。 BLEPropo → https://github.com/lipoyang/BLEPropo
BLEを使ったAndroid用ラジコンプロポアプリ「BLEPropo」に対応するBLE Nano用ファームウェアです。
BLEPropoは、GitHubにて公開中。
https://github.com/lipoyang/BLEPropo
ラジコンは、mbed HRM1017とRCサーボやDCモータを組み合わせて作ります。
回路図
/media/uploads/lipoyang/ministeer3.pdf
nRF51822/common/binary.h@5:7f89fca19a9e, 2015-03-14 (annotated)
- Committer:
- lipoyang
- Date:
- Sat Mar 14 12:02:48 2015 +0000
- Revision:
- 5:7f89fca19a9e
-convert nRF51822 library to a folder
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lipoyang | 5:7f89fca19a9e | 1 | /**************************************************************************/ |
lipoyang | 5:7f89fca19a9e | 2 | /*! |
lipoyang | 5:7f89fca19a9e | 3 | @file binary.h |
lipoyang | 5:7f89fca19a9e | 4 | @author hathach (tinyusb.org) |
lipoyang | 5:7f89fca19a9e | 5 | |
lipoyang | 5:7f89fca19a9e | 6 | @section LICENSE |
lipoyang | 5:7f89fca19a9e | 7 | |
lipoyang | 5:7f89fca19a9e | 8 | Software License Agreement (BSD License) |
lipoyang | 5:7f89fca19a9e | 9 | |
lipoyang | 5:7f89fca19a9e | 10 | Copyright (c) 2013, K. Townsend (microBuilder.eu) |
lipoyang | 5:7f89fca19a9e | 11 | All rights reserved. |
lipoyang | 5:7f89fca19a9e | 12 | |
lipoyang | 5:7f89fca19a9e | 13 | Redistribution and use in source and binary forms, with or without |
lipoyang | 5:7f89fca19a9e | 14 | modification, are permitted provided that the following conditions are met: |
lipoyang | 5:7f89fca19a9e | 15 | 1. Redistributions of source code must retain the above copyright |
lipoyang | 5:7f89fca19a9e | 16 | notice, this list of conditions and the following disclaimer. |
lipoyang | 5:7f89fca19a9e | 17 | 2. Redistributions in binary form must reproduce the above copyright |
lipoyang | 5:7f89fca19a9e | 18 | notice, this list of conditions and the following disclaimer in the |
lipoyang | 5:7f89fca19a9e | 19 | documentation and/or other materials provided with the distribution. |
lipoyang | 5:7f89fca19a9e | 20 | 3. Neither the name of the copyright holders nor the |
lipoyang | 5:7f89fca19a9e | 21 | names of its contributors may be used to endorse or promote products |
lipoyang | 5:7f89fca19a9e | 22 | derived from this software without specific prior written permission. |
lipoyang | 5:7f89fca19a9e | 23 | |
lipoyang | 5:7f89fca19a9e | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY |
lipoyang | 5:7f89fca19a9e | 25 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
lipoyang | 5:7f89fca19a9e | 26 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
lipoyang | 5:7f89fca19a9e | 27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY |
lipoyang | 5:7f89fca19a9e | 28 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
lipoyang | 5:7f89fca19a9e | 29 | INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
lipoyang | 5:7f89fca19a9e | 30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND |
lipoyang | 5:7f89fca19a9e | 31 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
lipoyang | 5:7f89fca19a9e | 32 | INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS |
lipoyang | 5:7f89fca19a9e | 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
lipoyang | 5:7f89fca19a9e | 34 | */ |
lipoyang | 5:7f89fca19a9e | 35 | /**************************************************************************/ |
lipoyang | 5:7f89fca19a9e | 36 | |
lipoyang | 5:7f89fca19a9e | 37 | /** \ingroup TBD |
lipoyang | 5:7f89fca19a9e | 38 | * \defgroup TBD |
lipoyang | 5:7f89fca19a9e | 39 | * \brief TBD |
lipoyang | 5:7f89fca19a9e | 40 | * |
lipoyang | 5:7f89fca19a9e | 41 | * @{ |
lipoyang | 5:7f89fca19a9e | 42 | */ |
lipoyang | 5:7f89fca19a9e | 43 | |
lipoyang | 5:7f89fca19a9e | 44 | #ifndef _BINARY_H_ |
lipoyang | 5:7f89fca19a9e | 45 | #define _BINARY_H_ |
lipoyang | 5:7f89fca19a9e | 46 | |
lipoyang | 5:7f89fca19a9e | 47 | #ifdef __cplusplus |
lipoyang | 5:7f89fca19a9e | 48 | extern "C" { |
lipoyang | 5:7f89fca19a9e | 49 | #endif |
lipoyang | 5:7f89fca19a9e | 50 | |
lipoyang | 5:7f89fca19a9e | 51 | /// n-th Bit |
lipoyang | 5:7f89fca19a9e | 52 | #define BIT(n) (1 << (n)) |
lipoyang | 5:7f89fca19a9e | 53 | |
lipoyang | 5:7f89fca19a9e | 54 | /// set n-th bit of x to 1 |
lipoyang | 5:7f89fca19a9e | 55 | #define BIT_SET(x, n) ( (x) | BIT(n) ) |
lipoyang | 5:7f89fca19a9e | 56 | |
lipoyang | 5:7f89fca19a9e | 57 | /// clear n-th bit of x |
lipoyang | 5:7f89fca19a9e | 58 | #define BIT_CLR(x, n) ( (x) & (~BIT(n)) ) |
lipoyang | 5:7f89fca19a9e | 59 | |
lipoyang | 5:7f89fca19a9e | 60 | /// test n-th bit of x |
lipoyang | 5:7f89fca19a9e | 61 | #define BIT_TEST(x, n) ( (x) & BIT(n) ) |
lipoyang | 5:7f89fca19a9e | 62 | |
lipoyang | 5:7f89fca19a9e | 63 | #if defined(__GNUC__) && !defined(__CC_ARM) // keil does not support binary format |
lipoyang | 5:7f89fca19a9e | 64 | |
lipoyang | 5:7f89fca19a9e | 65 | #define BIN8(x) ((uint8_t) (0b##x)) |
lipoyang | 5:7f89fca19a9e | 66 | #define BIN16(b1, b2) ((uint16_t) (0b##b1##b2)) |
lipoyang | 5:7f89fca19a9e | 67 | #define BIN32(b1, b2, b3, b4) ((uint32_t) (0b##b1##b2##b3##b4)) |
lipoyang | 5:7f89fca19a9e | 68 | |
lipoyang | 5:7f89fca19a9e | 69 | #else |
lipoyang | 5:7f89fca19a9e | 70 | |
lipoyang | 5:7f89fca19a9e | 71 | // internal macro of B8, B16, B32 |
lipoyang | 5:7f89fca19a9e | 72 | #define _B8__(x) (((x&0x0000000FUL)?1:0) \ |
lipoyang | 5:7f89fca19a9e | 73 | +((x&0x000000F0UL)?2:0) \ |
lipoyang | 5:7f89fca19a9e | 74 | +((x&0x00000F00UL)?4:0) \ |
lipoyang | 5:7f89fca19a9e | 75 | +((x&0x0000F000UL)?8:0) \ |
lipoyang | 5:7f89fca19a9e | 76 | +((x&0x000F0000UL)?16:0) \ |
lipoyang | 5:7f89fca19a9e | 77 | +((x&0x00F00000UL)?32:0) \ |
lipoyang | 5:7f89fca19a9e | 78 | +((x&0x0F000000UL)?64:0) \ |
lipoyang | 5:7f89fca19a9e | 79 | +((x&0xF0000000UL)?128:0)) |
lipoyang | 5:7f89fca19a9e | 80 | |
lipoyang | 5:7f89fca19a9e | 81 | #define BIN8(d) ((uint8_t) _B8__(0x##d##UL)) |
lipoyang | 5:7f89fca19a9e | 82 | #define BIN16(dmsb,dlsb) (((uint16_t)BIN8(dmsb)<<8) + BIN8(dlsb)) |
lipoyang | 5:7f89fca19a9e | 83 | #define BIN32(dmsb,db2,db3,dlsb) \ |
lipoyang | 5:7f89fca19a9e | 84 | (((uint32_t)BIN8(dmsb)<<24) \ |
lipoyang | 5:7f89fca19a9e | 85 | + ((uint32_t)BIN8(db2)<<16) \ |
lipoyang | 5:7f89fca19a9e | 86 | + ((uint32_t)BIN8(db3)<<8) \ |
lipoyang | 5:7f89fca19a9e | 87 | + BIN8(dlsb)) |
lipoyang | 5:7f89fca19a9e | 88 | #endif |
lipoyang | 5:7f89fca19a9e | 89 | |
lipoyang | 5:7f89fca19a9e | 90 | #ifdef __cplusplus |
lipoyang | 5:7f89fca19a9e | 91 | } |
lipoyang | 5:7f89fca19a9e | 92 | #endif |
lipoyang | 5:7f89fca19a9e | 93 | |
lipoyang | 5:7f89fca19a9e | 94 | #endif /* _BINARY_H_ */ |
lipoyang | 5:7f89fca19a9e | 95 | |
lipoyang | 5:7f89fca19a9e | 96 | /** @} */ |