Subversion Repositories idreammicro-avr

Rev

Rev 23 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12 jlesech 1
/**************************************************************************//**
2
 * \brief USART0 library
3
 * \author Copyright (C) 2011  Julien Le Sech - www.idreammicro.com
4
 * \version 1.0
5
 * \date 20090426
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 usart0.h
25
 ******************************************************************************/
26
 
27
#ifndef H__IDREAMMICRO__USART0__H
28
#define H__IDREAMMICRO__USART0__H
29
 
30
#ifdef _cplusplus
31
extern "C"{
32
#endif
33
 
34
/******************************************************************************
35
 * Header file inclusions.
36
 ******************************************************************************/
37
 
38
#include <usart/usart.h>
39
 
40
#include <useful/bool.h>
41
 
42
/******************************************************************************
43
 * Public function prototypes.
44
 ******************************************************************************/
45
 
46
/**************************************************************************//**
47
 * \fn void usart0__initialize(usart__configuration_t* p_configuration)
48
 *
49
 * \brief Initialize USART0.
50
 *
51
 * \param[in] p_configuration   USART configuration. If null, default settings
52
 *                              will be used.
53
 *
54
 * Default settings:
55
 * - baudrate = 9600 bps;
56
 * - 8 data bits;
57
 * - 1 stop bit;
58
 * - no parity.
59
 ******************************************************************************/
60
void
61
usart0__initialize
62
(
63
    usart__configuration_t* p_configuration
64
);
65
 
66
/**************************************************************************//**
67
 * \fn void usart0__set_baudrate(usart__baudrate_t baudrate)
68
 *
69
 * \brief Set USART0 baudrate.
70
 *
71
 * \param baudrate baudrate to set (in bauds per second)
72
 ******************************************************************************/
73
void
74
usart0__set_baudrate
75
(
76
    usart__baudrate_t baudrate
77
);
78
 
79
/**************************************************************************//**
80
 * \fn void usart0__set_mode(usart__mode_t usart_mode)
81
 *
82
 * \brief Set USART0 mode.
83
 *
84
 * \param usart_mode Mode to set.
85
 ******************************************************************************/
86
void
87
usart0__set_mode
88
(
89
    usart__mode_t usart_mode
90
);
91
 
92
/**************************************************************************//**
93
 * \fn void usart0__set_data_size(usart__data_size_t data_size)
94
 *
95
 * \brief Set USART0 data size.
96
 *
97
 * \param data_size data size (in bits)
98
 ******************************************************************************/
99
void
100
usart0__set_data_size
101
(
102
    usart__data_size_t data_size
103
);
104
 
105
/**************************************************************************//**
106
 * \fn void usart0__set_stop_size(usart__stop_size_t stop_size)
107
 *
108
 * \brief Set USART0 stop size.
109
 *
110
 * \param stop_size stop size (in bits)
111
 ******************************************************************************/
112
void
113
usart0__set_stop_size
114
(
115
    usart__stop_size_t stop_size
116
);
117
 
118
/**************************************************************************//**
119
 * \fn void usart0__set_parity(usart__parity_t parity)
120
 *
121
 * \brief Set USART0 parity.
122
 *
123
 * \param parity parity to set
124
 ******************************************************************************/
125
void
126
usart0__set_parity
127
(
128
    usart__parity_t parity
129
);
130
 
131
/**************************************************************************//**
132
 * \fn void usart0__set_double_speed(bool double_speed)
133
 *
134
 * \brief Set double speed.
135
 *
136
 * \param   double_speed    True to set double speed, false otherwise.
137
 ******************************************************************************/
138
void
139
usart0__set_double_speed
140
(
141
    bool double_speed
142
);
143
 
144
/**************************************************************************//**
145
 * \fn void usart0__enable_receiver(void)
146
 *
147
 * \brief Enable USART 0 receiver.
148
 ******************************************************************************/
149
void
150
usart0__enable_receiver
151
(
152
    void
153
);
154
 
155
/**************************************************************************//**
156
 * \fn void usart0__disable_receiver(void)
157
 *
158
 * \brief Disable USART 0 receiver.
159
 ******************************************************************************/
160
void
161
usart0__disable_receiver
162
(
163
    void
164
);
165
 
166
/**************************************************************************//**
167
 * \fn void usart0__enable_transmitter(void)
168
 *
169
 * \brief Enable USART 0 transmitter.
170
 ******************************************************************************/
171
void
172
usart0__enable_transmitter
173
(
174
    void
175
);
176
 
177
/**************************************************************************//**
178
 * \fn void usart0__disable_transmitter(void)
179
 *
180
 * \brief Disable USART 0 transmitter.
181
 ******************************************************************************/
182
void
183
usart0__disable_transmitter
184
(
185
    void
186
);
187
 
188
/**************************************************************************//**
189
 * \fn uint8_t usart0__receive_byte(void)
190
 *
191
 * \brief Receive a byte on USART0.
192
 *
193
 * \return received byte
194
 ******************************************************************************/
195
uint16_t
196
usart0__receive_byte
197
(
198
    void
199
);
200
 
201
/**************************************************************************//**
202
 * \fn usart0__transmit_byte(uint8_t byte_to_transmit)
203
 *
204
 * \brief Transmit a byte on USART0.
205
 *
206
 * \param byte_to_transmit byte to transmit
207
 ******************************************************************************/
208
void
209
usart0__transmit_byte
210
(
211
    uint16_t byte_to_transmit
212
);
213
 
214
/**************************************************************************//**
215
 * \fn void usart0__flush(void)
216
 *
217
 * \brief Flush USART0 receiver buffer.
218
 ******************************************************************************/
219
void
220
usart0__flush
221
(
222
    void
223
);
224
 
225
/**************************************************************************//**
226
 * \fn void usart0__enable_rx_complete_interrupt(void)
227
 *
228
 * \brief Enable USART 0 receive complete interrupt.
229
 ******************************************************************************/
230
void
231
usart0__enable_rx_complete_interrupt
232
(
233
    void
234
);
235
 
236
/**************************************************************************//**
237
 * \fn void usart0__disable_rx_complete_interrupt(void)
238
 *
239
 * \brief Disable USART 0 receive complete interrupt.
240
 ******************************************************************************/
241
void
242
usart0__disable_rx_complete_interrupt
243
(
244
    void
245
);
246
 
247
/**************************************************************************//**
248
 * \fn void usart0__set_rx_complete_callback(
249
 * const usart__rx_complete_callback_t* p_callback)
250
 *
251
 * \brief Set a callback to call when receive byte complete interrupt is
252
 * generated.
253
 *
254
 * \param[in]   p_callback  Callback to set.
255
 ******************************************************************************/
256
void
257
usart0__set_rx_complete_callback
258
(
259
    const usart__rx_complete_callback_t*  p_callback
260
);
261
 
262
/**************************************************************************//**
263
 * \fn void usart0__enable_tx_complete_interrupt(void)
264
 *
265
 * \brief Enable interrupt when TX complete.
266
 ******************************************************************************/
267
void
268
usart0__enable_tx_complete_interrupt
269
(
270
    void
271
);
272
 
273
/**************************************************************************//**
274
 * \fn void usart0__disable_tx_complete_interrupt(void)
275
 *
276
 * \brief Disable interrupt when TX complete.
277
 ******************************************************************************/
278
void
279
usart0__disable_tx_complete_interrupt
280
(
281
    void
282
);
283
 
284
/**************************************************************************//**
285
 * \fn void usart0__set_tx_complete_callback(
286
 * const usart__tx_complete_callback_t*  p_callback)
287
 *
288
 * \brief Set a callback to call when TX is complete.
289
 *
290
 * \param[in] p_callback        Function to call.
291
 ******************************************************************************/
292
void
293
usart0__set_tx_complete_callback
294
(
295
    const usart__tx_complete_callback_t*  p_callback
296
);
297
 
298
/**************************************************************************//**
299
 * \fn void usart0__enable_data_register_empty_interrupt()
300
 *
301
 * \brief Enable interrupt when data register is empty.
302
 ******************************************************************************/
303
void
304
usart0__enable_data_register_empty_interrupt
305
(
306
    void
307
);
308
 
309
/**************************************************************************//**
310
 * \fn void usart0__disable_data_register_empty_interrupt()
311
 *
312
 * \brief Disable interrupt when data register is empty.
313
 ******************************************************************************/
314
void
315
usart0__disable_data_register_empty_interrupt
316
(
317
    void
318
);
319
 
320
/**************************************************************************//**
321
 * \fn void usart0__set_data_register_empty_callback(
322
 * const usart__data_register_empty_callback_t*  p_callback)
323
 *
324
 * \brief Set a callback to call when data register is empty.
325
 *
326
 * \param[in] p_callback        Function to call.
327
 ******************************************************************************/
328
void
329
usart0__set_data_register_empty_callback
330
(
331
    const usart__data_register_empty_callback_t*  p_callback
332
);
333
 
334
#ifdef _cplusplus
335
}
336
#endif
337
 
338
#endif /* H__IDREAMMICRO__USART0__H */