]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M7_SAMV71_Xplained/libchip_samv7/include/twi.h
Update version number ready for V8.2.1 release.
[freertos] / FreeRTOS / Demo / CORTEX_M7_SAMV71_Xplained / libchip_samv7 / include / twi.h
1 /* ----------------------------------------------------------------------------\r
2  *         SAM Software Package License\r
3  * ----------------------------------------------------------------------------\r
4  * Copyright (c) 2011, Atmel Corporation\r
5  *\r
6  * All rights reserved.\r
7  *\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
10  *\r
11  * - Redistributions of source code must retain the above copyright notice,\r
12  * this list of conditions and the disclaimer below.\r
13  *\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
16  *\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
28  */\r
29 \r
30 /**\r
31  * \file\r
32  *\r
33  * Interface for configuration the Two Wire Interface (TWI) peripheral.\r
34  *\r
35  */\r
36 \r
37 #ifndef _TWI_\r
38 #define _TWI_\r
39 \r
40 /*------------------------------------------------------------------------------\r
41  *         Headers\r
42  *------------------------------------------------------------------------------*/\r
43 \r
44 #include "chip.h"\r
45 \r
46 #include <stdint.h>\r
47 \r
48 /*----------------------------------------------------------------------------\r
49  *        Macros\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
53 \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
56 \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
59 \r
60 #ifdef __cplusplus\r
61  extern "C" {\r
62 #endif\r
63 \r
64 /*----------------------------------------------------------------------------\r
65  *        External function\r
66  *----------------------------------------------------------------------------*/\r
67 \r
68 extern void TWI_ConfigureMaster(Twihs *pTwi, uint32_t twck, uint32_t mck);\r
69 \r
70 extern void TWI_ConfigureSlave(Twihs *pTwi, uint8_t slaveAddress);\r
71 \r
72 extern void TWI_Stop(Twihs *pTwi);\r
73 \r
74 extern void TWI_StartRead(\r
75     Twihs *pTwi,\r
76     uint8_t address,\r
77     uint32_t iaddress,\r
78     uint8_t isize);\r
79 \r
80 extern uint8_t TWI_ReadByte(Twihs *pTwi);\r
81 \r
82 extern void TWI_WriteByte(Twihs *pTwi, uint8_t byte);\r
83 \r
84 extern void TWI_StartWrite(\r
85     Twihs *pTwi,\r
86     uint8_t address,\r
87     uint32_t iaddress,\r
88     uint8_t isize,\r
89     uint8_t byte);\r
90 \r
91 extern uint8_t TWI_ByteReceived(Twihs *pTwi);\r
92 \r
93 extern uint8_t TWI_ByteSent(Twihs *pTwi);\r
94 \r
95 extern uint8_t TWI_TransferComplete(Twihs *pTwi);\r
96 \r
97 extern void TWI_EnableIt(Twihs *pTwi, uint32_t sources);\r
98 \r
99 extern void TWI_DisableIt(Twihs *pTwi, uint32_t sources);\r
100 \r
101 extern uint32_t TWI_GetStatus(Twihs *pTwi);\r
102 \r
103 extern uint32_t TWI_GetMaskedStatus(Twihs *pTwi);\r
104 \r
105 extern void TWI_SendSTOPCondition(Twihs *pTwi);\r
106 \r
107 #ifdef __cplusplus\r
108 }\r
109 #endif\r
110 \r
111 #endif /* #ifndef _TWI_ */\r