From 742f59ac987294c2597cb42add725312c486681c Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 9 Jan 2012 18:53:46 +0100 Subject: [PATCH] Disable PDC controller during TWI init. --- hardware/sam/libraries/Wire/Wire.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hardware/sam/libraries/Wire/Wire.cpp b/hardware/sam/libraries/Wire/Wire.cpp index 146bda79d..67383ac3f 100644 --- a/hardware/sam/libraries/Wire/Wire.cpp +++ b/hardware/sam/libraries/Wire/Wire.cpp @@ -89,6 +89,10 @@ TwoWire::TwoWire(Twi *_twi, void(*_beginCb)(void)) : void TwoWire::begin(void) { if (onBeginCallback) onBeginCallback(); + + // Disable PDC channel + twi->TWI_PTCR = UART_PTCR_RXTDIS | UART_PTCR_TXTDIS; + TWI_ConfigureMaster(twi, TWI_CLOCK, VARIANT_MCK); status = MASTER_IDLE; } @@ -96,6 +100,10 @@ void TwoWire::begin(void) { void TwoWire::begin(uint8_t address) { if (onBeginCallback) onBeginCallback(); + + // Disable PDC channel + twi->TWI_PTCR = UART_PTCR_RXTDIS | UART_PTCR_TXTDIS; + TWI_ConfigureSlave(twi, address); status = SLAVE_IDLE; TWI_EnableIt(twi, TWI_IER_SVACC);