Cosmetic changes from review of last PR

This commit is contained in:
Gregory Nutt 2016-10-15 08:56:11 -06:00
parent 61b6fd0b1a
commit 30598c005f

View File

@ -1189,6 +1189,13 @@ static int up_dma_nextrx(struct up_dev_s *priv)
static void up_set_format(struct uart_dev_s *dev)
{
struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
uint32_t usartdiv8;
#else
uint32_t usartdiv32;
uint32_t mantissa;
uint32_t fraction;
#endif
uint32_t regval;
uint32_t brr;
@ -1201,11 +1208,8 @@ static void up_set_format(struct uart_dev_s *dev)
* by 8 in additional to the standard oversampling by 16.
* With baud rate of fCK / Divider for oversampling by 16.
* and baud rate of 2 * fCK / Divider for oversampling by 8
*/
uint32_t usartdiv8;
/* In case of oversampling by 8, the equation is:
*
* In case of oversampling by 8, the equation is:
*
* baud = 2 * fCK / usartdiv8
* usartdiv8 = 2 * fCK / baud
@ -1219,10 +1223,10 @@ static void up_set_format(struct uart_dev_s *dev)
* baud = fCK / usartdiv16
* usartdiv16 = fCK / baud
* = 2 * usartdiv8
*
* Use oversamply by 8 only if the divisor is small. But what is small?
*/
/* Use oversamply by 8 only if the divisor is small. But what is small? */
if (usartdiv8 > 100)
{
/* Use usartdiv16 */
@ -1247,16 +1251,10 @@ static void up_set_format(struct uart_dev_s *dev)
}
#else
/* This second implementation is for U[S]ARTs that support fractional
* dividers.
*/
uint32_t usartdiv32;
uint32_t mantissa;
uint32_t fraction;
/* Configure the USART Baud Rate. The baud rate for the receiver and
*
* Configure the USART Baud Rate. The baud rate for the receiver and
* transmitter (Rx and Tx) are both set to the same value as programmed
* in the Mantissa and Fraction values of USARTDIV.
*
@ -1283,9 +1281,9 @@ static void up_set_format(struct uart_dev_s *dev)
fraction = (usartdiv32 - (mantissa << 5) + 1) >> 1;
#if defined(CONFIG_STM32_STM32F40XX)
/* The F4 supports 8 X in oversampling additional to the
* standard oversampling by 16.
*
* With baud rate of fCK / (16 * Divider) for oversampling by 16.
* and baud rate of fCK / (8 * Divider) for oversampling by 8
*/
@ -1300,18 +1298,20 @@ static void up_set_format(struct uart_dev_s *dev)
mantissa = usartdiv32 >> 4;
/* The fractional remainder (with rounding) */
/* The fractional remainder (with rounding) */
fraction = (usartdiv32 - (mantissa << 4) + 1) >> 1;
fraction = (usartdiv32 - (mantissa << 4) + 1) >> 1;
}
else
{/* Use 16x Oversampling */
{
/* Use 16x Oversampling */
regval &= ~USART_CR1_OVER8;
}
#endif
brr = mantissa << USART_BRR_MANT_SHIFT;
brr |= fraction << USART_BRR_FRAC_SHIFT;
brr = mantissa << USART_BRR_MANT_SHIFT;
brr |= fraction << USART_BRR_FRAC_SHIFT;
#endif
up_serialout(priv, STM32_USART_CR1_OFFSET, regval);
@ -1364,7 +1364,8 @@ static void up_set_format(struct uart_dev_s *dev)
regval = up_serialin(priv, STM32_USART_CR3_OFFSET);
regval &= ~(USART_CR3_CTSE | USART_CR3_RTSE);
#if defined(CONFIG_SERIAL_IFLOWCONTROL) && !defined(CONFIG_STM32_FLOWCONTROL_BROKEN)
#if defined(CONFIG_SERIAL_IFLOWCONTROL) && \
!defined(CONFIG_STM32_FLOWCONTROL_BROKEN)
if (priv->iflow && (priv->rts_gpio != 0))
{
regval |= USART_CR3_RTSE;