ライントレースとうおーるぼっとチャレンジのコードです。 SW1で操作モードとライントレースモードを切り替えます。 操作モードの時にRCBControllerのSTARTボタンを押すとチャレンジが開始します。 チャレンジの時はiPhoneを傾けてハンドリングする操作しか効かなくなっています。
Dependencies: mbed
nRF51822/common/binary.h@1:a86c84ead24a, 2014-11-18 (annotated)
- Committer:
- sibu2
- Date:
- Tue Nov 18 04:28:02 2014 +0000
- Revision:
- 1:a86c84ead24a
- Parent:
- 0:76dfa9657d9d
adjust wheel rotate direction, wheel encoder signals
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 0:76dfa9657d9d | 1 | /**************************************************************************/ |
jksoft | 0:76dfa9657d9d | 2 | /*! |
jksoft | 0:76dfa9657d9d | 3 | @file binary.h |
jksoft | 0:76dfa9657d9d | 4 | @author hathach (tinyusb.org) |
jksoft | 0:76dfa9657d9d | 5 | |
jksoft | 0:76dfa9657d9d | 6 | @section LICENSE |
jksoft | 0:76dfa9657d9d | 7 | |
jksoft | 0:76dfa9657d9d | 8 | Software License Agreement (BSD License) |
jksoft | 0:76dfa9657d9d | 9 | |
jksoft | 0:76dfa9657d9d | 10 | Copyright (c) 2013, K. Townsend (microBuilder.eu) |
jksoft | 0:76dfa9657d9d | 11 | All rights reserved. |
jksoft | 0:76dfa9657d9d | 12 | |
jksoft | 0:76dfa9657d9d | 13 | Redistribution and use in source and binary forms, with or without |
jksoft | 0:76dfa9657d9d | 14 | modification, are permitted provided that the following conditions are met: |
jksoft | 0:76dfa9657d9d | 15 | 1. Redistributions of source code must retain the above copyright |
jksoft | 0:76dfa9657d9d | 16 | notice, this list of conditions and the following disclaimer. |
jksoft | 0:76dfa9657d9d | 17 | 2. Redistributions in binary form must reproduce the above copyright |
jksoft | 0:76dfa9657d9d | 18 | notice, this list of conditions and the following disclaimer in the |
jksoft | 0:76dfa9657d9d | 19 | documentation and/or other materials provided with the distribution. |
jksoft | 0:76dfa9657d9d | 20 | 3. Neither the name of the copyright holders nor the |
jksoft | 0:76dfa9657d9d | 21 | names of its contributors may be used to endorse or promote products |
jksoft | 0:76dfa9657d9d | 22 | derived from this software without specific prior written permission. |
jksoft | 0:76dfa9657d9d | 23 | |
jksoft | 0:76dfa9657d9d | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY |
jksoft | 0:76dfa9657d9d | 25 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
jksoft | 0:76dfa9657d9d | 26 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
jksoft | 0:76dfa9657d9d | 27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY |
jksoft | 0:76dfa9657d9d | 28 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
jksoft | 0:76dfa9657d9d | 29 | INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
jksoft | 0:76dfa9657d9d | 30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND |
jksoft | 0:76dfa9657d9d | 31 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
jksoft | 0:76dfa9657d9d | 32 | INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS |
jksoft | 0:76dfa9657d9d | 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
jksoft | 0:76dfa9657d9d | 34 | */ |
jksoft | 0:76dfa9657d9d | 35 | /**************************************************************************/ |
jksoft | 0:76dfa9657d9d | 36 | |
jksoft | 0:76dfa9657d9d | 37 | /** \ingroup TBD |
jksoft | 0:76dfa9657d9d | 38 | * \defgroup TBD |
jksoft | 0:76dfa9657d9d | 39 | * \brief TBD |
jksoft | 0:76dfa9657d9d | 40 | * |
jksoft | 0:76dfa9657d9d | 41 | * @{ |
jksoft | 0:76dfa9657d9d | 42 | */ |
jksoft | 0:76dfa9657d9d | 43 | |
jksoft | 0:76dfa9657d9d | 44 | #ifndef _BINARY_H_ |
jksoft | 0:76dfa9657d9d | 45 | #define _BINARY_H_ |
jksoft | 0:76dfa9657d9d | 46 | |
jksoft | 0:76dfa9657d9d | 47 | #ifdef __cplusplus |
jksoft | 0:76dfa9657d9d | 48 | extern "C" { |
jksoft | 0:76dfa9657d9d | 49 | #endif |
jksoft | 0:76dfa9657d9d | 50 | |
jksoft | 0:76dfa9657d9d | 51 | /// n-th Bit |
jksoft | 0:76dfa9657d9d | 52 | #define BIT(n) (1 << (n)) |
jksoft | 0:76dfa9657d9d | 53 | |
jksoft | 0:76dfa9657d9d | 54 | /// set n-th bit of x to 1 |
jksoft | 0:76dfa9657d9d | 55 | #define BIT_SET(x, n) ( (x) | BIT(n) ) |
jksoft | 0:76dfa9657d9d | 56 | |
jksoft | 0:76dfa9657d9d | 57 | /// clear n-th bit of x |
jksoft | 0:76dfa9657d9d | 58 | #define BIT_CLR(x, n) ( (x) & (~BIT(n)) ) |
jksoft | 0:76dfa9657d9d | 59 | |
jksoft | 0:76dfa9657d9d | 60 | /// test n-th bit of x |
jksoft | 0:76dfa9657d9d | 61 | #define BIT_TEST(x, n) ( (x) & BIT(n) ) |
jksoft | 0:76dfa9657d9d | 62 | |
jksoft | 0:76dfa9657d9d | 63 | #if defined(__GNUC__) && !defined(__CC_ARM) // keil does not support binary format |
jksoft | 0:76dfa9657d9d | 64 | |
jksoft | 0:76dfa9657d9d | 65 | #define BIN8(x) ((uint8_t) (0b##x)) |
jksoft | 0:76dfa9657d9d | 66 | #define BIN16(b1, b2) ((uint16_t) (0b##b1##b2)) |
jksoft | 0:76dfa9657d9d | 67 | #define BIN32(b1, b2, b3, b4) ((uint32_t) (0b##b1##b2##b3##b4)) |
jksoft | 0:76dfa9657d9d | 68 | |
jksoft | 0:76dfa9657d9d | 69 | #else |
jksoft | 0:76dfa9657d9d | 70 | |
jksoft | 0:76dfa9657d9d | 71 | // internal macro of B8, B16, B32 |
jksoft | 0:76dfa9657d9d | 72 | #define _B8__(x) (((x&0x0000000FUL)?1:0) \ |
jksoft | 0:76dfa9657d9d | 73 | +((x&0x000000F0UL)?2:0) \ |
jksoft | 0:76dfa9657d9d | 74 | +((x&0x00000F00UL)?4:0) \ |
jksoft | 0:76dfa9657d9d | 75 | +((x&0x0000F000UL)?8:0) \ |
jksoft | 0:76dfa9657d9d | 76 | +((x&0x000F0000UL)?16:0) \ |
jksoft | 0:76dfa9657d9d | 77 | +((x&0x00F00000UL)?32:0) \ |
jksoft | 0:76dfa9657d9d | 78 | +((x&0x0F000000UL)?64:0) \ |
jksoft | 0:76dfa9657d9d | 79 | +((x&0xF0000000UL)?128:0)) |
jksoft | 0:76dfa9657d9d | 80 | |
jksoft | 0:76dfa9657d9d | 81 | #define BIN8(d) ((uint8_t) _B8__(0x##d##UL)) |
jksoft | 0:76dfa9657d9d | 82 | #define BIN16(dmsb,dlsb) (((uint16_t)BIN8(dmsb)<<8) + BIN8(dlsb)) |
jksoft | 0:76dfa9657d9d | 83 | #define BIN32(dmsb,db2,db3,dlsb) \ |
jksoft | 0:76dfa9657d9d | 84 | (((uint32_t)BIN8(dmsb)<<24) \ |
jksoft | 0:76dfa9657d9d | 85 | + ((uint32_t)BIN8(db2)<<16) \ |
jksoft | 0:76dfa9657d9d | 86 | + ((uint32_t)BIN8(db3)<<8) \ |
jksoft | 0:76dfa9657d9d | 87 | + BIN8(dlsb)) |
jksoft | 0:76dfa9657d9d | 88 | #endif |
jksoft | 0:76dfa9657d9d | 89 | |
jksoft | 0:76dfa9657d9d | 90 | #ifdef __cplusplus |
jksoft | 0:76dfa9657d9d | 91 | } |
jksoft | 0:76dfa9657d9d | 92 | #endif |
jksoft | 0:76dfa9657d9d | 93 | |
jksoft | 0:76dfa9657d9d | 94 | #endif /* _BINARY_H_ */ |
jksoft | 0:76dfa9657d9d | 95 | |
jksoft | 0:76dfa9657d9d | 96 | /** @} */ |