Naze32 clone with Frysky receiver
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_PORTIN_H
  17. #define MBED_PORTIN_H
  18. #include "platform.h"
  19. #if DEVICE_PORTIN
  20. #include "port_api.h"
  21. namespace mbed {
  22. /** A multiple pin digital input
  23. *
  24. * Example:
  25. * @code
  26. * // Switch on an LED if any of mbed pins 21-26 is high
  27. *
  28. * #include "mbed.h"
  29. *
  30. * PortIn p(Port2, 0x0000003F); // p21-p26
  31. * DigitalOut ind(LED4);
  32. *
  33. * int main() {
  34. * while(1) {
  35. * int pins = p.read();
  36. * if(pins) {
  37. * ind = 1;
  38. * } else {
  39. * ind = 0;
  40. * }
  41. * }
  42. * }
  43. * @endcode
  44. */
  45. class PortIn {
  46. public:
  47. /** Create an PortIn, connected to the specified port
  48. *
  49. * @param port Port to connect to (Port0-Port5)
  50. * @param mask A bitmask to identify which bits in the port should be included (0 - ignore)
  51. */
  52. PortIn(PortName port, int mask = 0xFFFFFFFF) {
  53. port_init(&_port, port, mask, PIN_INPUT);
  54. }
  55. /** Read the value currently output on the port
  56. *
  57. * @returns
  58. * An integer with each bit corresponding to associated port pin setting
  59. */
  60. int read() {
  61. return port_read(&_port);
  62. }
  63. /** Set the input pin mode
  64. *
  65. * @param mode PullUp, PullDown, PullNone, OpenDrain
  66. */
  67. void mode(PinMode mode) {
  68. port_mode(&_port, mode);
  69. }
  70. /** A shorthand for read()
  71. */
  72. operator int() {
  73. return read();
  74. }
  75. private:
  76. port_t _port;
  77. };
  78. } // namespace mbed
  79. #endif
  80. #endif