From 75792b3d6af243e043e66b1b2f7199229d430ef8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 21 Apr 2010 14:11:12 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1882 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/AVR/serial_lld.c | 56 ++++++++++++++++++++++----------------- os/hal/platforms/AVR/serial_lld.h | 27 +++++++++---------- 2 files changed, 44 insertions(+), 39 deletions(-) (limited to 'os/hal/platforms/AVR') diff --git a/os/hal/platforms/AVR/serial_lld.c b/os/hal/platforms/AVR/serial_lld.c index 48f688b64..8512fb873 100644 --- a/os/hal/platforms/AVR/serial_lld.c +++ b/os/hal/platforms/AVR/serial_lld.c @@ -18,8 +18,9 @@ */ /** - * @file AVR/serial_lld.c - * @brief AVR low level serial driver code. + * @file AVR/serial_lld.c + * @brief AVR low level serial driver code. + * * @addtogroup AVR_SERIAL * @{ */ @@ -34,18 +35,18 @@ /*===========================================================================*/ /** - * @brief USART0 serial driver identifier. - * @note The name does not follow the convention used in the other ports - * (COMn) because a name conflict with the AVR headers. + * @brief USART0 serial driver identifier. + * @note The name does not follow the convention used in the other ports + * (COMn) because a name conflict with the AVR headers. */ #if USE_AVR_USART0 || defined(__DOXYGEN__) SerialDriver SD1; #endif /** - * @brief USART1 serial driver identifier. - * @note The name does not follow the convention used in the other ports - * (COMn) because a name conflict with the AVR headers. + * @brief USART1 serial driver identifier. + * @note The name does not follow the convention used in the other ports + * (COMn) because a name conflict with the AVR headers. */ #if USE_AVR_USART1 || defined(__DOXYGEN__) SerialDriver SD2; @@ -56,7 +57,7 @@ SerialDriver SD2; /*===========================================================================*/ /** - * @brief Driver default configuration. + * @brief Driver default configuration. */ static const SerialConfig default_config = { UBRR(SERIAL_DEFAULT_BITRATE), @@ -88,8 +89,9 @@ static void notify1(void) { } /** - * @brief USART0 initialization. - * @param[in] config the architecture-dependent serial driver configuration + * @brief USART0 initialization. + * + * @param[in] config the architecture-dependent serial driver configuration */ static void usart0_init(const SerialConfig *config) { @@ -101,7 +103,7 @@ static void usart0_init(const SerialConfig *config) { } /** - * @brief USART0 de-initialization. + * @brief USART0 de-initialization. */ static void usart0_deinit(void) { @@ -118,8 +120,9 @@ static void notify2(void) { } /** - * @brief USART1 initialization. - * @param[in] config the architecture-dependent serial driver configuration + * @brief USART1 initialization. + * + * @param[in] config the architecture-dependent serial driver configuration */ static void usart1_init(const SerialConfig *config) { @@ -131,7 +134,7 @@ static void usart1_init(const SerialConfig *config) { } /** - * @brief USART1 de-initialization. + * @brief USART1 de-initialization. */ static void usart1_deinit(void) { @@ -216,7 +219,7 @@ CH_IRQ_HANDLER(USART1_UDRE_vect) { /*===========================================================================*/ /** - * Low level serial driver initialization. + * @brief Low level serial driver initialization. */ void sd_lld_init(void) { @@ -229,35 +232,38 @@ void sd_lld_init(void) { } /** - * @brief Low level serial driver configuration and (re)start. + * @brief Low level serial driver configuration and (re)start. * - * @param[in] sdp pointer to a @p SerialDriver object + * @param[in] sdp pointer to a @p SerialDriver object + * @param[in] config the architecture-dependent serial driver configuration. + * If this parameter is set to @p NULL then a default + * configuration is used. */ -void sd_lld_start(SerialDriver *sdp) { +void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) { - if (sdp->config == NULL) - sdp->config = &default_config; + if (config == NULL) + config = &default_config; #if USE_AVR_USART0 if (&SD1 == sdp) { - usart0_init(sdp->config); + usart0_init(config); return; } #endif #if USE_AVR_USART1 if (&SD2 == sdp) { - usart1_init(sdp->config); + usart1_init(config); return; } #endif } /** - * @brief Low level serial driver stop. + * @brief Low level serial driver stop. * @details De-initializes the USART, stops the associated clock, resets the * interrupt vector. * - * @param[in] sdp pointer to a @p SerialDriver object + * @param[in] sdp pointer to a @p SerialDriver object */ void sd_lld_stop(SerialDriver *sdp) { diff --git a/os/hal/platforms/AVR/serial_lld.h b/os/hal/platforms/AVR/serial_lld.h index b89bd3ef3..604a46c99 100644 --- a/os/hal/platforms/AVR/serial_lld.h +++ b/os/hal/platforms/AVR/serial_lld.h @@ -18,8 +18,9 @@ */ /** - * @file AVR/serial_lld.h - * @brief AVR low level serial driver header. + * @file AVR/serial_lld.h + * @brief AVR low level serial driver header. + * * @addtogroup AVR_SERIAL * @{ */ @@ -38,18 +39,18 @@ /*===========================================================================*/ /** - * @brief USART0 driver enable switch. + * @brief USART0 driver enable switch. * @details If set to @p TRUE the support for USART0 is included. - * @note The default is @p FALSE. + * @note The default is @p FALSE. */ #if !defined(USE_AVR_USART0) || defined(__DOXYGEN__) #define USE_AVR_USART0 TRUE #endif /** - * @brief USART1 driver enable switch. + * @brief USART1 driver enable switch. * @details If set to @p TRUE the support for USART1 is included. - * @note The default is @p TRUE. + * @note The default is @p TRUE. */ #if !defined(USE_AVR_USART1) || defined(__DOXYGEN__) #define USE_AVR_USART1 TRUE @@ -64,12 +65,12 @@ /*===========================================================================*/ /** - * @brief Serial Driver condition flags type. + * @brief Serial Driver condition flags type. */ typedef uint8_t sdflags_t; /** - * @brief AVR Serial Driver configuration structure. + * @brief AVR Serial Driver configuration structure. * @details An instance of this structure must be passed to @p sdStart() * in order to configure and start a serial driver operations. */ @@ -85,14 +86,12 @@ typedef struct { } SerialConfig; /** - * @brief @p SerialDriver specific data. + * @brief @p SerialDriver specific data. */ #define _serial_driver_data \ _base_asynchronous_channel_data \ /* Driver state.*/ \ sdstate_t state; \ - /* Current configuration data.*/ \ - const SerialConfig *config; \ /* Input queue.*/ \ InputQueue iqueue; \ /* Output queue.*/ \ @@ -112,8 +111,8 @@ typedef struct { /*===========================================================================*/ /** - * @brief Macro for baud rate computation. - * @note Make sure the final baud rate is within tolerance. + * @brief Macro for baud rate computation. + * @note Make sure the final baud rate is within tolerance. */ #define UBRR(b) ((F_CPU / (b << 4)) - 1) @@ -132,7 +131,7 @@ extern SerialDriver SD2; extern "C" { #endif void sd_lld_init(void); - void sd_lld_start(SerialDriver *sdp); + void sd_lld_start(SerialDriver *sdp, const SerialConfig *config); void sd_lld_stop(SerialDriver *sdp); #ifdef __cplusplus } -- cgit v1.2.3