Keyboard firmwares for Atmel AVR and Cortex-M
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.

SoftUART.h 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. LUFA Library
  3. Copyright (C) Dean Camera, 2014.
  4. dean [at] fourwalledcubicle [dot] com
  5. www.lufa-lib.org
  6. */
  7. /*
  8. Copyright 2010 David Prentice (david.prentice [at] farming [dot] uk)
  9. Copyright 2010 Peter Danneger
  10. Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  11. Permission to use, copy, modify, distribute, and sell this
  12. software and its documentation for any purpose is hereby granted
  13. without fee, provided that the above copyright notice appear in
  14. all copies and that both that the copyright notice and this
  15. permission notice and warranty disclaimer appear in supporting
  16. documentation, and that the name of the author not be used in
  17. advertising or publicity pertaining to distribution of the
  18. software without specific, written prior permission.
  19. The author disclaims all warranties with regard to this
  20. software, including all implied warranties of merchantability
  21. and fitness. In no event shall the author be liable for any
  22. special, indirect or consequential damages or any damages
  23. whatsoever resulting from loss of use, data or profits, whether
  24. in an action of contract, negligence or other tortious action,
  25. arising out of or in connection with the use or performance of
  26. this software.
  27. */
  28. /** \file
  29. *
  30. * Header file for SoftUART.c.
  31. */
  32. #ifndef _SOFT_UART_
  33. #define _SOFT_UART_
  34. /* Includes: */
  35. #include <avr/io.h>
  36. #include <avr/interrupt.h>
  37. #include <stdbool.h>
  38. #include "../XPLAINBridge.h"
  39. #include "Config/AppConfig.h"
  40. /* Macros: */
  41. #define SRX PD0
  42. #define SRXPIN PIND
  43. #define SRXPORT PORTD
  44. #define STX PD1
  45. #define STXPORT PORTD
  46. #define STXDDR DDRD
  47. /* Inline Functions: */
  48. static inline void SoftUART_SetBaud(const uint32_t Baud)
  49. {
  50. uint16_t BitTime = ((F_CPU / Baud) - 1);
  51. OCR1A = BitTime;
  52. OCR3A = BitTime;
  53. }
  54. /* Function Prototypes: */
  55. void SoftUART_Init(void);
  56. #endif