* STM32 SerialDriver to remove SerialConfig pointer

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1878 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
liamstask 2010-04-19 15:48:30 +00:00
parent 6e8ee65859
commit a222ba2dde
2 changed files with 11 additions and 13 deletions

View File

@ -83,25 +83,25 @@ static const SerialConfig default_config =
* *
* @param[in] sdp pointer to a @p SerialDriver object * @param[in] sdp pointer to a @p SerialDriver object
*/ */
static void usart_init(SerialDriver *sdp) { static void usart_init(SerialDriver *sdp, const SerialConfig *config) {
USART_TypeDef *u = sdp->usart; USART_TypeDef *u = sdp->usart;
/* /*
* Baud rate setting. * Baud rate setting.
*/ */
if (sdp->usart == USART1) if (sdp->usart == USART1)
u->BRR = APB2CLK / sdp->config->sc_speed; u->BRR = APB2CLK / config->sc_speed;
else else
u->BRR = APB1CLK / sdp->config->sc_speed; u->BRR = APB1CLK / config->sc_speed;
/* /*
* Note that some bits are enforced. * Note that some bits are enforced.
*/ */
u->CR1 = sdp->config->sc_cr1 | USART_CR1_UE | USART_CR1_PEIE | u->CR1 = config->sc_cr1 | USART_CR1_UE | USART_CR1_PEIE |
USART_CR1_RXNEIE | USART_CR1_TE | USART_CR1_RXNEIE | USART_CR1_TE |
USART_CR1_RE; USART_CR1_RE;
u->CR2 = sdp->config->sc_cr2 | USART_CR2_LBDIE; u->CR2 = config->sc_cr2 | USART_CR2_LBDIE;
u->CR3 = sdp->config->sc_cr3 | USART_CR3_EIE; u->CR3 = config->sc_cr3 | USART_CR3_EIE;
(void)u->SR; /* SR reset step 1.*/ (void)u->SR; /* SR reset step 1.*/
(void)u->DR; /* SR reset step 2.*/ (void)u->DR; /* SR reset step 2.*/
} }
@ -318,10 +318,10 @@ void sd_lld_init(void) {
* *
* @param[in] sdp pointer to a @p SerialDriver object * @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) if (config == NULL)
sdp->config = &default_config; config = &default_config;
if (sdp->state == SD_STOP) { if (sdp->state == SD_STOP) {
#if USE_STM32_USART1 #if USE_STM32_USART1
@ -362,7 +362,7 @@ void sd_lld_start(SerialDriver *sdp) {
#endif #endif
#endif #endif
} }
usart_init(sdp); usart_init(sdp, config);
} }
/** /**

View File

@ -170,8 +170,6 @@ typedef struct {
_base_asynchronous_channel_data \ _base_asynchronous_channel_data \
/* Driver state.*/ \ /* Driver state.*/ \
sdstate_t state; \ sdstate_t state; \
/* Current configuration data.*/ \
const SerialConfig *config; \
/* Input queue.*/ \ /* Input queue.*/ \
InputQueue iqueue; \ InputQueue iqueue; \
/* Output queue.*/ \ /* Output queue.*/ \
@ -226,7 +224,7 @@ extern SerialDriver SD5;
extern "C" { extern "C" {
#endif #endif
void sd_lld_init(void); 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); void sd_lld_stop(SerialDriver *sdp);
#ifdef __cplusplus #ifdef __cplusplus
} }