MinimumSerial.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * Copyright (c) 2011-2022 Bill Greiman
  3. * This file is part of the SdFat library for SD memory cards.
  4. *
  5. * MIT License
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included
  15. * in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. */
  25. /**
  26. * \file
  27. * \brief Minimal AVR Serial driver.
  28. */
  29. #ifndef MinimumSerial_h
  30. #define MinimumSerial_h
  31. #include "common/SysCall.h"
  32. //==============================================================================
  33. /**
  34. * \class MinimumSerial
  35. * \brief mini serial class for the %SdFat library.
  36. */
  37. class MinimumSerial : public print_t {
  38. public:
  39. /** \return true for hardware serial */
  40. operator bool() {return true;}
  41. /**
  42. * \return one if data is available.
  43. */
  44. int available();
  45. /**
  46. * Set baud rate for serial port zero and enable in non interrupt mode.
  47. * Do not call this function if you use another serial library.
  48. * \param[in] baud rate
  49. */
  50. void begin(uint32_t baud);
  51. /** Wait for write done. */
  52. void flush();
  53. /**
  54. * Unbuffered read
  55. * \return -1 if no character is available or an available character.
  56. */
  57. int read();
  58. /**
  59. * Unbuffered write
  60. *
  61. * \param[in] b byte to write.
  62. * \return 1
  63. */
  64. size_t write(uint8_t b);
  65. using print_t::write;
  66. };
  67. #endif // MinimumSerial_h