aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms/STM32/USARTv2
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-12-05 11:19:22 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-12-05 11:19:22 +0000
commitd501fe85d1816bd8fc20cd8354f7b339df9ecc27 (patch)
treefdfc73d6bfec1a17ca0bf6e67b7cecbbeab0b2db /os/hal/platforms/STM32/USARTv2
parentf16865c2354bdfd78b712de2e4dac2882600bf35 (diff)
downloadChibiOS-d501fe85d1816bd8fc20cd8354f7b339df9ecc27.tar.gz
ChibiOS-d501fe85d1816bd8fc20cd8354f7b339df9ecc27.tar.bz2
ChibiOS-d501fe85d1816bd8fc20cd8354f7b339df9ecc27.zip
STM32F3xx DMA and SPI support.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4874 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms/STM32/USARTv2')
-rw-r--r--os/hal/platforms/STM32/USARTv2/serial_lld.c18
-rw-r--r--os/hal/platforms/STM32/USARTv2/serial_lld.h4
2 files changed, 11 insertions, 11 deletions
diff --git a/os/hal/platforms/STM32/USARTv2/serial_lld.c b/os/hal/platforms/STM32/USARTv2/serial_lld.c
index 40195319b..6d44d7d23 100644
--- a/os/hal/platforms/STM32/USARTv2/serial_lld.c
+++ b/os/hal/platforms/STM32/USARTv2/serial_lld.c
@@ -88,12 +88,14 @@ static const SerialConfig default_config =
*
* @param[in] sdp pointer to a @p SerialDriver object
* @param[in] config the architecture-dependent serial driver configuration
+ * @param[in] clock clock in Hz for the specified USART/UART
*/
-static void usart_init(SerialDriver *sdp, const SerialConfig *config) {
+static void usart_init(SerialDriver *sdp, const SerialConfig *config,
+ uint32_t clock) {
USART_TypeDef *u = sdp->usart;
/* Baud rate setting.*/
- u->BRR = sdp->clock / config->sc_speed;
+ u->BRR = clock / config->sc_speed;
/* Note that some bits are enforced.*/
u->CR2 = config->sc_cr2 | USART_CR2_LBDIE;
@@ -370,31 +372,26 @@ void sd_lld_init(void) {
#if STM32_SERIAL_USE_USART1
sdObjectInit(&SD1, NULL, notify1);
SD1.usart = USART1;
- SD1.clock = STM32_USART1CLK;
#endif
#if STM32_SERIAL_USE_USART2
sdObjectInit(&SD2, NULL, notify2);
SD2.usart = USART2;
- SD1.clock = STM32_USART2CLK;
#endif
#if STM32_SERIAL_USE_USART3
sdObjectInit(&SD3, NULL, notify3);
SD3.usart = USART3;
- SD1.clock = STM32_USART3CLK;
#endif
#if STM32_SERIAL_USE_UART4
sdObjectInit(&SD4, NULL, notify4);
SD4.usart = UART4;
- SD1.clock = STM32_UART4CLK;
#endif
#if STM32_SERIAL_USE_UART5
sdObjectInit(&SD5, NULL, notify5);
SD5.usart = UART5;
- SD1.clock = STM32_UART5CLK;
#endif
#if STM32_SERIAL_USE_USART6
@@ -424,6 +421,7 @@ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
rccEnableUSART1(FALSE);
nvicEnableVector(STM32_USART1_NUMBER,
CORTEX_PRIORITY_MASK(STM32_SERIAL_USART1_PRIORITY));
+ usart_init(sdp, config, STM32_USART1CLK);
}
#endif
#if STM32_SERIAL_USE_USART2
@@ -431,6 +429,7 @@ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
rccEnableUSART2(FALSE);
nvicEnableVector(STM32_USART2_NUMBER,
CORTEX_PRIORITY_MASK(STM32_SERIAL_USART2_PRIORITY));
+ usart_init(sdp, config, STM32_USART2CLK);
}
#endif
#if STM32_SERIAL_USE_USART3
@@ -438,6 +437,7 @@ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
rccEnableUSART3(FALSE);
nvicEnableVector(STM32_USART3_NUMBER,
CORTEX_PRIORITY_MASK(STM32_SERIAL_USART3_PRIORITY));
+ usart_init(sdp, config, STM32_USART3CLK);
}
#endif
#if STM32_SERIAL_USE_UART4
@@ -445,6 +445,7 @@ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
rccEnableUART4(FALSE);
nvicEnableVector(STM32_UART4_NUMBER,
CORTEX_PRIORITY_MASK(STM32_SERIAL_UART4_PRIORITY));
+ usart_init(sdp, config, STM32_UART4CLK);
}
#endif
#if STM32_SERIAL_USE_UART5
@@ -452,6 +453,7 @@ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
rccEnableUART5(FALSE);
nvicEnableVector(STM32_UART5_NUMBER,
CORTEX_PRIORITY_MASK(STM32_SERIAL_UART5_PRIORITY));
+ usart_init(sdp, config, STM32_UART5CLK);
}
#endif
#if STM32_SERIAL_USE_USART6
@@ -459,10 +461,10 @@ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
rccEnableUSART6(FALSE);
nvicEnableVector(STM32_USART6_NUMBER,
CORTEX_PRIORITY_MASK(STM32_SERIAL_USART6_PRIORITY));
+ usart_init(sdp, config, STM32_USART6CLK);
}
#endif
}
- usart_init(sdp, config);
}
/**
diff --git a/os/hal/platforms/STM32/USARTv2/serial_lld.h b/os/hal/platforms/STM32/USARTv2/serial_lld.h
index 639884fdb..d3b3a9352 100644
--- a/os/hal/platforms/STM32/USARTv2/serial_lld.h
+++ b/os/hal/platforms/STM32/USARTv2/serial_lld.h
@@ -252,9 +252,7 @@ typedef struct {
uint8_t ob[SERIAL_BUFFERS_SIZE]; \
/* End of the mandatory fields.*/ \
/* Pointer to the USART registers block.*/ \
- USART_TypeDef *usart; \
- /* Clock frequency for this USART.*/ \
- uint32_t clock;
+ USART_TypeDef *usart;
/*===========================================================================*/
/* Driver macros. */