Naze32 clone with Frysky receiver
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

RawSerial.h 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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_RAW_SERIAL_H
  17. #define MBED_RAW_SERIAL_H
  18. #include "platform.h"
  19. #if DEVICE_SERIAL
  20. #include "SerialBase.h"
  21. #include "serial_api.h"
  22. namespace mbed {
  23. /** A serial port (UART) for communication with other serial devices
  24. * This is a variation of the Serial class that doesn't use streams,
  25. * thus making it safe to use in interrupt handlers with the RTOS.
  26. *
  27. * Can be used for Full Duplex communication, or Simplex by specifying
  28. * one pin as NC (Not Connected)
  29. *
  30. * Example:
  31. * @code
  32. * // Send a char to the PC
  33. *
  34. * #include "mbed.h"
  35. *
  36. * RawSerial pc(USBTX, USBRX);
  37. *
  38. * int main() {
  39. * pc.putc('A');
  40. * }
  41. * @endcode
  42. */
  43. class RawSerial: public SerialBase {
  44. public:
  45. /** Create a RawSerial port, connected to the specified transmit and receive pins
  46. *
  47. * @param tx Transmit pin
  48. * @param rx Receive pin
  49. *
  50. * @note
  51. * Either tx or rx may be specified as NC if unused
  52. */
  53. RawSerial(PinName tx, PinName rx);
  54. /** Write a char to the serial port
  55. *
  56. * @param c The char to write
  57. *
  58. * @returns The written char or -1 if an error occured
  59. */
  60. int putc(int c);
  61. /** Read a char from the serial port
  62. *
  63. * @returns The char read from the serial port
  64. */
  65. int getc();
  66. /** Write a string to the serial port
  67. *
  68. * @param str The string to write
  69. *
  70. * @returns 0 if the write succeeds, EOF for error
  71. */
  72. int puts(const char *str);
  73. int printf(const char *format, ...);
  74. };
  75. } // namespace mbed
  76. #endif
  77. #endif