Naze32 clone with Frysky receiver
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

BusIn.h 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* mbed Microcontroller Library
  2. * Copyright (c) 2006-2013 ARM Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MBED_BUSIN_H
  17. #define MBED_BUSIN_H
  18. #include "platform.h"
  19. #include "DigitalIn.h"
  20. namespace mbed {
  21. /** A digital input bus, used for reading the state of a collection of pins
  22. */
  23. class BusIn {
  24. public:
  25. /* Group: Configuration Methods */
  26. /** Create an BusIn, connected to the specified pins
  27. *
  28. * @param <n> DigitalIn pin to connect to bus bit <n> (p5-p30, NC)
  29. *
  30. * @note
  31. * It is only required to specify as many pin variables as is required
  32. * for the bus; the rest will default to NC (not connected)
  33. */
  34. BusIn(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
  35. PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
  36. PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
  37. PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC);
  38. BusIn(PinName pins[16]);
  39. virtual ~BusIn();
  40. /** Read the value of the input bus
  41. *
  42. * @returns
  43. * An integer with each bit corresponding to the value read from the associated DigitalIn pin
  44. */
  45. int read();
  46. /** Set the input pin mode
  47. *
  48. * @param mode PullUp, PullDown, PullNone
  49. */
  50. void mode(PinMode pull);
  51. /** Binary mask of bus pins connected to actual pins (not NC pins)
  52. * If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1
  53. *
  54. * @returns
  55. * Binary mask of connected pins
  56. */
  57. int mask() {
  58. return _nc_mask;
  59. }
  60. #ifdef MBED_OPERATORS
  61. /** A shorthand for read()
  62. */
  63. operator int();
  64. /** Access to particular bit in random-iterator fashion
  65. */
  66. DigitalIn & operator[] (int index);
  67. #endif
  68. protected:
  69. DigitalIn* _pin[16];
  70. /** Mask of bus's NC pins
  71. * If bit[n] is set to 1 - pin is connected
  72. * if bit[n] is cleared - pin is not connected (NC)
  73. */
  74. int _nc_mask;
  75. /* disallow copy constructor and assignment operators */
  76. private:
  77. BusIn(const BusIn&);
  78. BusIn & operator = (const BusIn&);
  79. };
  80. } // namespace mbed
  81. #endif