aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms/AVR
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-04-21 14:11:12 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-04-21 14:11:12 +0000
commit75792b3d6af243e043e66b1b2f7199229d430ef8 (patch)
tree8c0740a9254d7b4b8d635c6734e3fbd30dc6d30e /os/hal/platforms/AVR
parent3621ac37b0cbab7737d215db0335017561856a10 (diff)
downloadChibiOS-75792b3d6af243e043e66b1b2f7199229d430ef8.tar.gz
ChibiOS-75792b3d6af243e043e66b1b2f7199229d430ef8.tar.bz2
ChibiOS-75792b3d6af243e043e66b1b2f7199229d430ef8.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1882 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms/AVR')
-rw-r--r--os/hal/platforms/AVR/serial_lld.c56
-rw-r--r--os/hal/platforms/AVR/serial_lld.h27
2 files changed, 44 insertions, 39 deletions
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
}