From 06621969059f61dceaa6d14701f6bec8e3844199 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Tue, 26 Apr 2016 13:06:46 -0700 Subject: [PATCH] Fix audio codec I2C reliability for some HackRF units. --- firmware/application/portapack.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/firmware/application/portapack.cpp b/firmware/application/portapack.cpp index 12bae2243..0aabc219b 100644 --- a/firmware/application/portapack.cpp +++ b/firmware/application/portapack.cpp @@ -106,9 +106,23 @@ void init() { } /* Configure other pins */ + /* Glitch filter operates at 3ns instead of 50ns due to the WM8731 + * returning an ACK very fast (170ns) and confusing the I2C state + * machine into thinking there was a bus error. It looks like the + * MCU sees SDA fall before SCL falls, indicating a START at the + * point an ACK is expected. With the glitch filter off or set to + * 3ns, it's probably still a bit tight timing-wise, but improves + * reliability on some problem units. + */ LPC_SCU->SFSI2C0 = - (1U << 3) - | (1U << 11) + (1U << 0) // SCL: 3ns glitch + | (0U << 2) // SCL: Standard/Fast mode + | (1U << 3) // SCL: Input enabled + | (0U << 7) // SCL: Enable input glitch filter + | (1U << 8) // SDA: 3ns glitch + | (0U << 10) // SDA: Standard/Fast mode + | (1U << 11) // SDA: Input enabled + | (0U << 15) // SDA: Enable input glitch filter ; power.init();