Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
17 | jlesech | 1 | /**************************************************************************//** |
2 | * \brief TWI library |
||
3 | * \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com |
||
4 | * \version 1.0 |
||
5 | * \date 20090501 |
||
6 | * |
||
7 | * This file is part of the iDreamMicro library. |
||
8 | * |
||
9 | * This library is free software: you can redistribute it and/or modify it under |
||
10 | * the terms of the GNU Lesser General Public License as published by the Free |
||
11 | * Software Foundation, either version 3 of the License, or (at your option) any |
||
12 | * later version. |
||
13 | * |
||
14 | * This library is distributed in the hope that it will be useful, but WITHOUT |
||
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
||
16 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
||
17 | * details. |
||
18 | * |
||
19 | * You should have received a copy of the GNU Lesser General Public License |
||
20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
||
21 | ******************************************************************************/ |
||
22 | |||
23 | /**************************************************************************//** |
||
24 | * \headerfile twi.h |
||
25 | ******************************************************************************/ |
||
26 | |||
27 | #ifndef H__IDREAMMICRO__TWI__H |
||
28 | #define H__IDREAMMICRO__TWI__H |
||
29 | |||
30 | #ifdef _cplusplus |
||
31 | extern "C"{ |
||
32 | #endif |
||
33 | |||
34 | /****************************************************************************** |
||
35 | * Header file inclusions. |
||
36 | ******************************************************************************/ |
||
37 | |||
38 | #include <stdint.h> |
||
39 | |||
40 | /****************************************************************************** |
||
41 | * Public type definitions. |
||
42 | ******************************************************************************/ |
||
43 | |||
44 | /**************************************************************************//** |
||
45 | * \typedef twi__error_t |
||
46 | * |
||
47 | * \brief TWI errors. |
||
48 | ******************************************************************************/ |
||
49 | // TODO: more errors. |
||
50 | typedef enum twi__errors |
||
51 | { |
||
52 | TWI__ERROR__NONE, |
||
53 | TWI__ERROR__ERROR, |
||
54 | TWI__ERROR__INVALID |
||
55 | } twi__error_t; |
||
56 | |||
57 | /****************************************************************************** |
||
58 | * Public function prototypes. |
||
59 | ******************************************************************************/ |
||
60 | |||
61 | /**************************************************************************//** |
||
62 | * \fn void twi__initialize(uint32_t frequency) |
||
63 | * |
||
64 | * \brief Initialize TWI. |
||
65 | * |
||
66 | * \param frequency TWI frequency (up to 400 kHz). |
||
67 | ******************************************************************************/ |
||
68 | void |
||
69 | twi__initialize |
||
70 | ( |
||
71 | uint32_t frequency |
||
72 | ); |
||
73 | |||
74 | /**************************************************************************//** |
||
75 | * \fn twi__error_t twi__start(void) |
||
76 | * |
||
77 | * \brief |
||
78 | ******************************************************************************/ |
||
79 | twi__error_t |
||
80 | twi__start |
||
81 | ( |
||
82 | void |
||
83 | ); |
||
84 | |||
85 | /**************************************************************************//** |
||
86 | * \fn twi__error_t twi__repeat_start(void) |
||
87 | * |
||
88 | * \brief |
||
89 | ******************************************************************************/ |
||
90 | twi__error_t |
||
91 | twi__repeat_start |
||
92 | ( |
||
93 | void |
||
94 | ); |
||
95 | |||
96 | /**************************************************************************//** |
||
97 | * \fn twi__error_t twi__send_slar(uint8_t sla) |
||
98 | * |
||
99 | * \brief |
||
100 | * |
||
101 | * \param sla |
||
102 | ******************************************************************************/ |
||
103 | twi__error_t |
||
104 | twi__send_slar |
||
105 | ( |
||
106 | uint8_t sla |
||
107 | ); |
||
108 | |||
109 | /**************************************************************************//** |
||
110 | * \fn twi__error_t twi__send_slaw(uint8_t sla) |
||
111 | * |
||
112 | * \brief |
||
113 | * |
||
114 | * \param sla |
||
115 | ******************************************************************************/ |
||
116 | twi__error_t |
||
117 | twi__send_slaw |
||
118 | ( |
||
119 | uint8_t sla |
||
120 | ); |
||
121 | |||
122 | /**************************************************************************//** |
||
123 | * \fn twi__error_t twi__send_data(uint8_t data) |
||
124 | * |
||
125 | * \brief |
||
126 | * |
||
127 | * \param data Data to send. |
||
128 | ******************************************************************************/ |
||
129 | twi__error_t |
||
130 | twi__send_data |
||
131 | ( |
||
132 | uint8_t data |
||
133 | ); |
||
134 | |||
135 | /**************************************************************************//** |
||
136 | * \fn twi__error_t twi__receive_data_ack(uint8_t* p_data) |
||
137 | * |
||
138 | * \brief |
||
139 | * |
||
140 | * \param p_data |
||
141 | ******************************************************************************/ |
||
142 | twi__error_t |
||
143 | twi__receive_data_ack |
||
144 | ( |
||
145 | uint8_t* p_data |
||
146 | ); |
||
147 | |||
148 | /**************************************************************************//** |
||
149 | * \fn twi__error_t twi__receive_data_nack(uint8_t* p_data) |
||
150 | * |
||
151 | * \brief |
||
152 | * |
||
153 | * \param p_data |
||
154 | ******************************************************************************/ |
||
155 | twi__error_t |
||
156 | twi__receive_data_nack |
||
157 | ( |
||
158 | uint8_t* p_data |
||
159 | ); |
||
160 | |||
161 | /**************************************************************************//** |
||
162 | * \fn void twi__stop(void) |
||
163 | * |
||
164 | * \brief |
||
165 | ******************************************************************************/ |
||
166 | void |
||
167 | twi__stop |
||
168 | ( |
||
169 | void |
||
170 | ); |
||
171 | |||
172 | #ifdef _cplusplus |
||
173 | } |
||
174 | #endif |
||
175 | |||
176 | #endif /* H__IDREAMMICRO__TWI__H */ |