1 /* ----------------------------------------------------------------------------
\r
2 * SAM Software Package License
\r
3 * ----------------------------------------------------------------------------
\r
4 * Copyright (c) 2011, Atmel Corporation
\r
6 * All rights reserved.
\r
8 * Redistribution and use in source and binary forms, with or without
\r
9 * modification, are permitted provided that the following conditions are met:
\r
11 * - Redistributions of source code must retain the above copyright notice,
\r
12 * this list of conditions and the disclaimer below.
\r
14 * Atmel's name may not be used to endorse or promote products derived from
\r
15 * this software without specific prior written permission.
\r
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
\r
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
\r
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
27 * ----------------------------------------------------------------------------
\r
33 * Interface for configuration the Two Wire Interface (TWI) peripheral.
\r
40 /*------------------------------------------------------------------------------
\r
42 *------------------------------------------------------------------------------*/
\r
48 /*----------------------------------------------------------------------------
\r
50 *----------------------------------------------------------------------------*/
\r
51 /* Returns 1 if the TXRDY bit (ready to transmit data) is set in the given status register value.*/
\r
52 #define TWI_STATUS_TXRDY(status) ((status & TWIHS_SR_TXRDY) == TWIHS_SR_TXRDY)
\r
54 /* Returns 1 if the RXRDY bit (ready to receive data) is set in the given status register value.*/
\r
55 #define TWI_STATUS_RXRDY(status) ((status & TWIHS_SR_RXRDY) == TWIHS_SR_RXRDY)
\r
57 /* Returns 1 if the TXCOMP bit (transfer complete) is set in the given status register value.*/
\r
58 #define TWI_STATUS_TXCOMP(status) ((status & TWIHS_SR_TXCOMP) == TWIHS_SR_TXCOMP)
\r
64 /*----------------------------------------------------------------------------
\r
66 *----------------------------------------------------------------------------*/
\r
68 extern void TWI_ConfigureMaster(Twihs *pTwi, uint32_t twck, uint32_t mck);
\r
70 extern void TWI_ConfigureSlave(Twihs *pTwi, uint8_t slaveAddress);
\r
72 extern void TWI_Stop(Twihs *pTwi);
\r
74 extern void TWI_StartRead(
\r
80 extern uint8_t TWI_ReadByte(Twihs *pTwi);
\r
82 extern void TWI_WriteByte(Twihs *pTwi, uint8_t byte);
\r
84 extern void TWI_StartWrite(
\r
91 extern uint8_t TWI_ByteReceived(Twihs *pTwi);
\r
93 extern uint8_t TWI_ByteSent(Twihs *pTwi);
\r
95 extern uint8_t TWI_TransferComplete(Twihs *pTwi);
\r
97 extern void TWI_EnableIt(Twihs *pTwi, uint32_t sources);
\r
99 extern void TWI_DisableIt(Twihs *pTwi, uint32_t sources);
\r
101 extern uint32_t TWI_GetStatus(Twihs *pTwi);
\r
103 extern uint32_t TWI_GetMaskedStatus(Twihs *pTwi);
\r
105 extern void TWI_SendSTOPCondition(Twihs *pTwi);
\r
111 #endif /* #ifndef _TWI_ */
\r