Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
12 | jlesech | 1 | /**************************************************************************//** |
2 | * \brief USART 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 usart.h |
||
25 | ******************************************************************************/ |
||
26 | |||
27 | #ifndef H__IDREAMMICRO__USART__H |
||
28 | #define H__IDREAMMICRO__USART__H |
||
29 | |||
30 | #ifdef _cplusplus |
||
31 | extern "C"{ |
||
32 | #endif |
||
33 | |||
34 | /****************************************************************************** |
||
35 | * Public types. |
||
36 | ******************************************************************************/ |
||
37 | |||
38 | /**************************************************************************//** |
||
39 | * \enum usart__baudrates |
||
40 | * \brief USART baudrates (in baud per second). |
||
41 | * |
||
42 | * \typedef usart__baudrate_t |
||
43 | * \brief USART baudrate (in baud per second). |
||
44 | ******************************************************************************/ |
||
45 | typedef enum usart__baudrates |
||
46 | { |
||
47 | USART__BAUDRATE__2400 = 2400, /*!< 2400 bps. */ |
||
48 | USART__BAUDRATE__4800 = 4800, /*!< 4800 bps. */ |
||
49 | USART__BAUDRATE__9600 = 9600, /*!< 9600 bps. */ |
||
50 | USART__BAUDRATE__14400 = 14400, /*!< 14400 bps. */ |
||
51 | USART__BAUDRATE__19200 = 19200, /*!< 19200 bps. */ |
||
52 | USART__BAUDRATE__28800 = 28800, /*!< 28800 bps. */ |
||
53 | USART__BAUDRATE__38400 = 38400, /*!< 38400 bps. */ |
||
54 | USART__BAUDRATE__57600 = 57600, /*!< 57600 bps. */ |
||
55 | USART__BAUDRATE__76800 = 76800, /*!< 76800 bps. */ |
||
56 | USART__BAUDRATE__115200 = 115200, /*!< 115200 bps. */ |
||
57 | USART__BAUDRATE__230400 = 230400, /*!< 230400 bps. */ |
||
58 | USART__BAUDRATE__250000 = 250000, /*!< 250000 bps. */ |
||
59 | USART__BAUDRATE__500000 = 500000, /*!< 500000 bps. */ |
||
60 | USART__BAUDRATE__1000000 = 1000000 /*!< 1000000 bps. */ |
||
61 | } usart__baudrate_t; |
||
62 | |||
63 | /**************************************************************************//** |
||
64 | * \enum usart__modes |
||
65 | * \brief USART modes. |
||
66 | * |
||
67 | * \typedef usart__mode_t |
||
68 | * \brief USART mode. |
||
69 | ******************************************************************************/ |
||
70 | typedef enum usart__modes |
||
71 | { |
||
72 | USART__MODE__ASYNCHRONOUS, |
||
73 | USART__MODE__SYNCHRONOUS, |
||
74 | USART__MODE__MASTER_SPI, |
||
75 | USART__MODE__INVALID |
||
76 | } usart__mode_t; |
||
77 | |||
78 | /**************************************************************************//** |
||
79 | * \enum usart__data_sizes |
||
80 | * \brief USART data sizes. |
||
81 | * |
||
82 | * \typedef usart__data_size_t |
||
83 | * \brief USART data size. |
||
84 | ******************************************************************************/ |
||
85 | typedef enum usart__data_sizes |
||
86 | { |
||
87 | USART__DATA_SIZE__5_BITS, /*!< 5 data bits. */ |
||
88 | USART__DATA_SIZE__6_BITS, /*!< 6 data bits. */ |
||
89 | USART__DATA_SIZE__7_BITS, /*!< 7 data bits. */ |
||
90 | USART__DATA_SIZE__8_BITS, /*!< 8 data bits. */ |
||
91 | USART__DATA_SIZE__9_BITS /*!< 9 data bits. */ |
||
92 | } usart__data_size_t; |
||
93 | |||
94 | /**************************************************************************//** |
||
95 | * \enum usart__stop_sizes |
||
96 | * \brief USART stop bits. |
||
97 | * |
||
98 | * \typedef usart__stop_size_t |
||
99 | * \brief USART stop bits. |
||
100 | ******************************************************************************/ |
||
101 | typedef enum usart__stop_sizes |
||
102 | { |
||
103 | USART__STOP_SIZE__1_BIT, /*!< 1 stop bit. */ |
||
104 | USART__STOP_SIZE__2_BITS /*!< 2 stop bits. */ |
||
105 | } usart__stop_size_t; |
||
106 | |||
107 | /**************************************************************************//** |
||
108 | * \enum usart__parities |
||
109 | * \brief USART parities. |
||
110 | * |
||
111 | * \typedef usart__parity_t |
||
112 | * \brief USART parity. |
||
113 | ******************************************************************************/ |
||
114 | typedef enum usart__parities |
||
115 | { |
||
116 | USART__PARITY__DISABLED, /*!< Parity disabled. */ |
||
117 | USART__PARITY__EVEN, /*!< Even parity. */ |
||
118 | USART__PARITY__ODD /*!< Odd parity. */ |
||
119 | } usart__parity_t; |
||
120 | |||
121 | /**************************************************************************//** |
||
122 | * \struct usart__configuration |
||
123 | * \brief USART configuration. |
||
124 | * |
||
125 | * \typedef usart__configuration_t |
||
126 | * \brief USART configuration. |
||
127 | ******************************************************************************/ |
||
128 | typedef struct usart__configuration |
||
129 | { |
||
130 | usart__mode_t mode; |
||
131 | usart__baudrate_t baudrate; |
||
132 | usart__data_size_t data_size; |
||
133 | usart__stop_size_t stop_size; |
||
134 | usart__parity_t parity; |
||
135 | } usart__configuration_t; |
||
136 | |||
137 | /**************************************************************************//** |
||
138 | * \typedef usart__rx_complete_callback_t |
||
139 | * \brief RX complete callback. |
||
140 | ******************************************************************************/ |
||
141 | typedef |
||
142 | void |
||
143 | usart__rx_complete_callback_t |
||
144 | ( |
||
145 | void |
||
146 | ); |
||
147 | |||
148 | /**************************************************************************//** |
||
149 | * \typedef usart__tx_complete_callback_t |
||
150 | * \brief TX complete callback. |
||
151 | ******************************************************************************/ |
||
152 | typedef |
||
153 | void |
||
154 | usart__tx_complete_callback_t |
||
155 | ( |
||
156 | void |
||
157 | ); |
||
158 | |||
159 | /**************************************************************************//** |
||
160 | * \typedef usart__data_register_empty_callback_t |
||
161 | * \brief Data register empty callback. |
||
162 | ******************************************************************************/ |
||
163 | typedef |
||
164 | void |
||
165 | usart__data_register_empty_callback_t |
||
166 | ( |
||
167 | void |
||
168 | ); |
||
169 | |||
170 | #ifdef _cplusplus |
||
171 | } |
||
172 | #endif |
||
173 | |||
174 | #endif /* H__IDREAMMICRO__USART__H */ |