From c2ba7ebf4611f2beec0ebdf537934f6f28513579 Mon Sep 17 00:00:00 2001 From: liamstask Date: Mon, 19 Apr 2010 15:29:44 +0000 Subject: * remove the SerialConfig pointer from the SerialDriver structure. This is now simply passed through from sdStart() to sd_lld_start() * implementation for AT91SAM7 port provided - others will need to be updated git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1875 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/AT91SAM7/serial_lld.c | 18 +++++++++--------- os/hal/platforms/AT91SAM7/serial_lld.h | 6 +++--- os/hal/src/serial.c | 3 +-- os/hal/templates/serial_lld.c | 6 +++--- os/hal/templates/serial_lld.h | 4 +--- 5 files changed, 17 insertions(+), 20 deletions(-) (limited to 'os') diff --git a/os/hal/platforms/AT91SAM7/serial_lld.c b/os/hal/platforms/AT91SAM7/serial_lld.c index c5197544d..c166a697d 100644 --- a/os/hal/platforms/AT91SAM7/serial_lld.c +++ b/os/hal/platforms/AT91SAM7/serial_lld.c @@ -81,7 +81,7 @@ static const SerialConfig default_config = { * * @param[in] sdp communication channel associated to the USART */ -static void usart_init(SerialDriver *sdp) { +static void usart_init(SerialDriver *sdp, const SerialConfig *config) { AT91PS_USART u = sdp->usart; /* Disables IRQ sources and stop operations.*/ @@ -89,11 +89,11 @@ static void usart_init(SerialDriver *sdp) { u->US_CR = AT91C_US_RSTRX | AT91C_US_RSTTX | AT91C_US_RSTSTA; /* New parameters setup.*/ - if (sdp->config->sc_mr & AT91C_US_OVER) - u->US_BRGR = MCK / (sdp->config->sc_speed * 8); + if (config->sc_mr & AT91C_US_OVER) + u->US_BRGR = MCK / (config->sc_speed * 8); else - u->US_BRGR = MCK / (sdp->config->sc_speed * 16); - u->US_MR = sdp->config->sc_mr; + u->US_BRGR = MCK / (config->sc_speed * 16); + u->US_MR = config->sc_mr; u->US_RTOR = 0; u->US_TTGR = 0; @@ -254,10 +254,10 @@ void sd_lld_init(void) { * * @param[in] sdp pointer to a @p SerialDriver object */ -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 (sdp->state == SD_STOP) { #if USE_SAM7_USART0 @@ -277,7 +277,7 @@ void sd_lld_start(SerialDriver *sdp) { } #endif } - usart_init(sdp); + usart_init(sdp, config); } /** diff --git a/os/hal/platforms/AT91SAM7/serial_lld.h b/os/hal/platforms/AT91SAM7/serial_lld.h index e3bb23259..33355ab3d 100644 --- a/os/hal/platforms/AT91SAM7/serial_lld.h +++ b/os/hal/platforms/AT91SAM7/serial_lld.h @@ -90,10 +90,12 @@ typedef uint32_t sdflags_t; typedef struct { /** * @brief Bit rate. + * @details This is written to the US_BRGR register of the appropriate AT91S_USART */ uint32_t sc_speed; /** * @brief Initialization value for the MR register. + * @details This is written to the US_MR register of the appropriate AT91S_USART */ uint32_t sc_mr; } SerialConfig; @@ -105,8 +107,6 @@ typedef struct { _base_asynchronous_channel_data \ /* Driver state.*/ \ sdstate_t state; \ - /* Current configuration data.*/ \ - const SerialConfig *config; \ /* Input queue.*/ \ InputQueue iqueue; \ /* Output queue.*/ \ @@ -142,7 +142,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 } diff --git a/os/hal/src/serial.c b/os/hal/src/serial.c index 52a1772c8..94418e46c 100644 --- a/os/hal/src/serial.c +++ b/os/hal/src/serial.c @@ -146,8 +146,7 @@ void sdStart(SerialDriver *sdp, const SerialConfig *config) { chDbgAssert((sdp->state == SD_STOP) || (sdp->state == SD_READY), "sdStart(), #1", "invalid state"); - sdp->config = config; - sd_lld_start(sdp); + sd_lld_start(sdp, config); sdp->state = SD_READY; chSysUnlock(); } diff --git a/os/hal/templates/serial_lld.c b/os/hal/templates/serial_lld.c index 52e1881e7..0293f28e7 100644 --- a/os/hal/templates/serial_lld.c +++ b/os/hal/templates/serial_lld.c @@ -68,10 +68,10 @@ void sd_lld_init(void) { * * @param[in] sdp pointer to a @p SerialDriver object */ -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; } diff --git a/os/hal/templates/serial_lld.h b/os/hal/templates/serial_lld.h index 72a0063be..2a2abb582 100644 --- a/os/hal/templates/serial_lld.h +++ b/os/hal/templates/serial_lld.h @@ -70,8 +70,6 @@ typedef struct { _base_asynchronous_channel_data \ /* Driver state.*/ \ sdstate_t state; \ - /* Current configuration data.*/ \ - const SerialConfig *config; \ /* Input queue.*/ \ InputQueue iqueue; \ /* Output queue.*/ \ @@ -98,7 +96,7 @@ typedef struct { 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