MNT Reform: Open Source Portable Computer https://mntre.com/reform
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.4KB

  1. /*
  2. NewSoftSerial.h
  3. Multi-instance software serial library for Arduino/Wiring
  4. -- Interrupt-driven receive and other improvements by ladyada
  5. (http://ladyada.net)
  6. -- Tuning, circular buffer, derivation from class Print/Stream,
  7. multi-instance support, porting to 8MHz processors,
  8. various optimizations, PROGMEM delay tables, inverse logic and
  9. direct port writing by Mikal Hart (http://www.arduiniana.org)
  10. -- Pin change interrupt macros by Paul Stoffregen (http://www.pjrc.com)
  11. -- 20MHz processor support by Garrett Mace (http://www.macetech.com)
  12. -- ATmega1280/2560 support by Brett Hagman (http://www.roguerobotics.com/)
  13. This library is free software; you can redistribute it and/or
  14. modify it under the terms of the GNU Lesser General Public
  15. License as published by the Free Software Foundation; either
  16. version 2.1 of the License, or (at your option) any later version.
  17. This library is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. Lesser General Public License for more details.
  21. You should have received a copy of the GNU Lesser General Public
  22. License along with this library; if not, write to the Free Software
  23. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  24. The latest version of this library can always be found at
  25. http://arduiniana.org.
  26. */
  27. #ifndef NewSoftSerial_h
  28. #define NewSoftSerial_h
  29. /******************************************************************************
  30. * Definitions
  31. ******************************************************************************/
  32. #define _SS_MAX_RX_BUFF 64 // RX buffer size
  33. #define _SS_VERSION 12 // software version of this library
  34. #ifndef GCC_VERSION
  35. #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
  36. #endif
  37. // private methods
  38. void ser_recv(void);
  39. uint8_t ser_rx_pin_read(void);
  40. void ser_tx_pin_write(uint8_t pin_state);
  41. void ser_set_tx(volatile uint8_t* port, uint8_t pin);
  42. void ser_set_rx(volatile uint8_t* port, uint8_t pin);
  43. // public methods
  44. void ser_init(volatile uint8_t* rx_port, uint8_t rx_pin, volatile uint8_t* tx_port, uint8_t tx_pin, bool inverse_logic);
  45. void ser_begin(long speed);
  46. bool ser_listen(void);
  47. void ser_end(void);
  48. bool ser_is_listening(void);
  49. bool ser_overflow(void);
  50. void ser_enable_timer0(bool enable);
  51. int ser_peek(void);
  52. void ser_write(uint8_t byte);
  53. int ser_read(void);
  54. int ser_available(void);
  55. void ser_flush(void);
  56. #endif