aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/Peripheral/XMEGA/TWI_XMEGA.h
diff options
context:
space:
mode:
authorMichael Janssen <jamuraa@base0.net>2013-08-06 23:33:06 -0500
committerMichael Janssen <jamuraa@base0.net>2013-08-06 23:33:06 -0500
commit6dd0447c12d1b75611ad8f205890913378635719 (patch)
tree3e90f957fbf5a1a3500fc9b7a603cc5d0eed6fff /LUFA/Drivers/Peripheral/XMEGA/TWI_XMEGA.h
parentd557744503b3787576ad6d4cebdf37e033809f2b (diff)
downloadlufa-6dd0447c12d1b75611ad8f205890913378635719.tar.gz
lufa-6dd0447c12d1b75611ad8f205890913378635719.tar.bz2
lufa-6dd0447c12d1b75611ad8f205890913378635719.zip
Bugfixes with the protocol.
- Bitmasks need to be equal, not just result in non-zero - Only read status once in case it changes under us - Logical and not binary and when checking for acks on sending - We need to stop the bus when receiving the last byte - Force the bus into idle mode when we are Initing
Diffstat (limited to 'LUFA/Drivers/Peripheral/XMEGA/TWI_XMEGA.h')
-rw-r--r--LUFA/Drivers/Peripheral/XMEGA/TWI_XMEGA.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/LUFA/Drivers/Peripheral/XMEGA/TWI_XMEGA.h b/LUFA/Drivers/Peripheral/XMEGA/TWI_XMEGA.h
index eb8c6a5f1..0a5d477b2 100644
--- a/LUFA/Drivers/Peripheral/XMEGA/TWI_XMEGA.h
+++ b/LUFA/Drivers/Peripheral/XMEGA/TWI_XMEGA.h
@@ -184,8 +184,11 @@
static inline void TWI_Init(TWI_t *twi, const uint8_t Baud) ATTR_ALWAYS_INLINE ATTR_NON_NULL_PTR_ARG(1);
static inline void TWI_Init(TWI_t *twi, const uint8_t Baud)
{
+ twi->CTRL = 0x00;
twi->MASTER.BAUD = Baud;
- twi->MASTER.CTRLA |= TWI_MASTER_ENABLE_bm;
+ twi->MASTER.CTRLA = TWI_MASTER_ENABLE_bm;
+ twi->MASTER.CTRLB = 0;
+ twi->MASTER.STATUS = TWI_MASTER_BUSSTATE_IDLE_gc;
}
/** Turns off the TWI driver hardware. If this is called, any further TWI operations will require a call to
@@ -206,7 +209,7 @@
static inline void TWI_StopTransmission(TWI_t *twi) ATTR_ALWAYS_INLINE ATTR_NON_NULL_PTR_ARG(1);
static inline void TWI_StopTransmission(TWI_t *twi)
{
- twi->MASTER.CTRLC = TWI_MASTER_CMD_STOP_gc;
+ twi->MASTER.CTRLC = TWI_MASTER_ACKACT_bm | TWI_MASTER_CMD_STOP_gc;
}
/* Function Prototypes: */