From 1a130eed6c990701642afc1a1e9738dfd86b0d4b Mon Sep 17 00:00:00 2001
From: Dean Camera <dean@fourwalledcubicle.com>
Date: Tue, 15 Mar 2011 04:02:15 +0000
Subject: [PATCH] Updated the software USART code in the XPLAIN Bridge
 application so that the incomming bits are sampled at their mid-point instead
 of starting point, to give maximum reliability (thanks to Anton).

---
 LUFA/ManPages/ChangeLog.txt           | 2 ++
 LUFA/ManPages/LUFAPoweredProjects.txt | 4 +++-
 Projects/XPLAINBridge/Lib/SoftUART.c  | 6 ++++--
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt
index fbd3bdccb..231920e8f 100644
--- a/LUFA/ManPages/ChangeLog.txt
+++ b/LUFA/ManPages/ChangeLog.txt
@@ -68,6 +68,8 @@
   *   - Changed TempDataLogger project's DS1307 driver to simplify the function interface and prevent a possible race condition
   *   - Changed AVRISP-MKII project to use the Watchdog interrupt for command timeouts, to reduce CPU usage and free timer 0
   *     for other uses
+  *   - Updated the software USART code in the XPLAIN Bridge application so that the incomming bits are sampled at their mid-point
+  *     instead of starting point, to give maximum reliability (thanks to Anton)
   *
   *  <b>Fixed:</b>
   *  - Core:
diff --git a/LUFA/ManPages/LUFAPoweredProjects.txt b/LUFA/ManPages/LUFAPoweredProjects.txt
index fd2a76819..34d4944b6 100644
--- a/LUFA/ManPages/LUFAPoweredProjects.txt
+++ b/LUFA/ManPages/LUFAPoweredProjects.txt
@@ -46,14 +46,16 @@
  *  - DIY PS3 controller emulator: https://code.google.com/p/diyps3controller/
  *  - EMUCOMBOX, a USB-RS422 adapter for E-Mu Emax samplers: http://users.skynet.be/emxp/EMUCOMBOX.htm
  *  - Estick JTAG, an ARM JTAG debugger: http://code.google.com/p/estick-jtag/
- *  - "Fingerlicking Wingdinger" (WARNING: Bad Language if no Javascript), a MIDI controller: http://noisybox.net/electronics/wingdinger/
+ *  - "Fingerlicking Wingdinger" (WARNING: Bad language if no Javascript), a MIDI controller: http://noisybox.net/electronics/wingdinger/
  *  - Flyatar, a real-time fly tracking system: https://github.com/peterpolidoro/Flyatar
  *  - Garmin GPS USB to NMEA standard serial sentence translator: http://github.com/nall/garmin-transmogrifier/tree/master
  *  - Generic HID Device Creator: http://generichid.sourceforge.net/
  *  - Ghetto Drum, a MIDI drum controller: http://noisybox.net/art/gdrum/
  *  - IR Remote to Keyboard decoder: http://netzhansa.blogspot.com/2010/04/our-living-room-hi-fi-setup-needs-mp3.html
  *  - LED Panel controller: http://projects.peterpolidoro.net/caltech/panelscontroller/panelscontroller.htm
+ *  - LUFA powered DDR dance mat (French): http://logicien-parfait.fr/dokuwiki/doku.php?id=projet:ddr_repair
  *  - Motherboard BIOS flasher: http://www.coreboot.org/InSystemFlasher
+ *  - Multi-button Joystick (French): http://logicien-parfait.fr/dokuwiki/doku.php?id=projet:joystick
  *  - Nikon wireless camera remote control (Norwegian): http://hekta.org/~hpe1119/
  *  - PSGroove, a Playstation 3 Homebrew dongle: http://github.com/psgroove
  *  - Single LED Matrix Display: http://guysoft.wordpress.com/2009/10/08/bumble-b/
diff --git a/Projects/XPLAINBridge/Lib/SoftUART.c b/Projects/XPLAINBridge/Lib/SoftUART.c
index ddd983a91..370e806ac 100644
--- a/Projects/XPLAINBridge/Lib/SoftUART.c
+++ b/Projects/XPLAINBridge/Lib/SoftUART.c
@@ -81,8 +81,10 @@ ISR(INT0_vect, ISR_BLOCK)
 	/* Reset the number of reception bits remaining counter */
 	RX_BitsRemaining = 8;
 
-	/* Reset the bit reception timer */
-	TCNT1 = 0;
+	/* Reset the bit reception timer to -(1/2) of the total bit time, so that the first data bit is
+	 * sampled mid way through the total bit time, making reception more robust.
+	 */
+	TCNT1 = -(OCR1A >> 1);
 
 	/* Check to see that the pin is still low (prevents glitches from starting a frame reception) */
 	if (!(SRXPIN & (1 << SRX)))
-- 
GitLab