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