mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-03-27 13:49:56 +00:00
arm/stm32f4: extend USART DR field to 9 bits
The STM32F4 USART data register supports up to 9-bit data when CR1.M is set. The current DR macros mask only bits [7:0], which truncates the MSB in 9-bit mode. Extend the field width to [8:0] to match the hardware definition while remaining compatible with 8-bit mode.
This commit is contained in:
committed by
Kinsey Moore
parent
0e86a5de8e
commit
1097e00b5f
@@ -60,7 +60,8 @@ static void stm32f4_usart_interrupt(void *arg)
|
|||||||
|
|
||||||
while ((usart->sr & STM32F4_USART_SR_RXNE) == STM32F4_USART_SR_RXNE)
|
while ((usart->sr & STM32F4_USART_SR_RXNE) == STM32F4_USART_SR_RXNE)
|
||||||
{
|
{
|
||||||
char data = STM32F4_USART_DR_GET(usart->dr);
|
/* Mask to 8 bits to preserve existing behavior */
|
||||||
|
char data = STM32F4_USART_DR_GET(usart->dr) & 0xFF;
|
||||||
rtems_termios_enqueue_raw_characters(tty, &data, sizeof(data));
|
rtems_termios_enqueue_raw_characters(tty, &data, sizeof(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,7 +225,7 @@ static int usart_read_polled(int minor)
|
|||||||
volatile stm32f4_usart *usart = usart_get_regs(ct);
|
volatile stm32f4_usart *usart = usart_get_regs(ct);
|
||||||
|
|
||||||
if ((usart->sr & STM32F4_USART_SR_RXNE) != 0) {
|
if ((usart->sr & STM32F4_USART_SR_RXNE) != 0) {
|
||||||
return STM32F4_USART_DR_GET(usart->dr);
|
return STM32F4_USART_DR_GET(usart->dr) & 0xFF;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,9 +56,9 @@ typedef struct {
|
|||||||
#define STM32F4_USART_SR_FE BSP_BIT32(1)
|
#define STM32F4_USART_SR_FE BSP_BIT32(1)
|
||||||
#define STM32F4_USART_SR_PE BSP_BIT32(0)
|
#define STM32F4_USART_SR_PE BSP_BIT32(0)
|
||||||
uint32_t dr;
|
uint32_t dr;
|
||||||
#define STM32F4_USART_DR(val) BSP_FLD32(val, 0, 7)
|
#define STM32F4_USART_DR(val) BSP_FLD32(val, 0, 8)
|
||||||
#define STM32F4_USART_DR_GET(reg) BSP_FLD32GET(reg, 0, 7)
|
#define STM32F4_USART_DR_GET(reg) BSP_FLD32GET(reg, 0, 8)
|
||||||
#define STM32F4_USART_DR_SET(reg, val) BSP_FLD32SET(reg, val, 0, 7)
|
#define STM32F4_USART_DR_SET(reg, val) BSP_FLD32SET(reg, val, 0, 8)
|
||||||
uint32_t bbr;
|
uint32_t bbr;
|
||||||
#define STM32F4_USART_BBR_DIV_MANTISSA(val) BSP_FLD32(val, 4, 15)
|
#define STM32F4_USART_BBR_DIV_MANTISSA(val) BSP_FLD32(val, 4, 15)
|
||||||
#define STM32F4_USART_BBR_DIV_MANTISSA_GET(reg) BSP_FLD32GET(reg, 4, 15)
|
#define STM32F4_USART_BBR_DIV_MANTISSA_GET(reg) BSP_FLD32GET(reg, 4, 15)
|
||||||
|
|||||||
Reference in New Issue
Block a user