mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #12341 from fkjagodzinski/fix-stm-hal_fpga
STM32L4: Fix the UART RX & TX data reg bitmaskspull/12405/head
commit
7fd5119b89
|
@ -263,8 +263,15 @@ int serial_getc(serial_t *obj)
|
||||||
struct serial_s *obj_s = SERIAL_S(obj);
|
struct serial_s *obj_s = SERIAL_S(obj);
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
|
/* Computation of UART mask to apply to RDR register */
|
||||||
|
UART_MASK_COMPUTATION(huart);
|
||||||
|
uint16_t uhMask = huart->Mask;
|
||||||
|
|
||||||
while (!serial_readable(obj));
|
while (!serial_readable(obj));
|
||||||
return (int)(huart->Instance->RDR & (uint16_t)0xFF);
|
/* When receiving with the parity enabled, the value read in the MSB bit
|
||||||
|
* is the received parity bit.
|
||||||
|
*/
|
||||||
|
return (int)(huart->Instance->RDR & uhMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_putc(serial_t *obj, int c)
|
void serial_putc(serial_t *obj, int c)
|
||||||
|
@ -273,7 +280,12 @@ void serial_putc(serial_t *obj, int c)
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
while (!serial_writable(obj));
|
while (!serial_writable(obj));
|
||||||
huart->Instance->TDR = (uint32_t)(c & (uint16_t)0xFF);
|
/* When transmitting with the parity enabled (PCE bit set to 1 in the
|
||||||
|
* USART_CR1 register), the value written in the MSB (bit 7 or bit 8
|
||||||
|
* depending on the data length) has no effect because it is replaced
|
||||||
|
* by the parity.
|
||||||
|
*/
|
||||||
|
huart->Instance->TDR = (uint16_t)(c & 0x1FFU);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_clear(serial_t *obj)
|
void serial_clear(serial_t *obj)
|
||||||
|
|
|
@ -202,12 +202,15 @@ int serial_getc(serial_t *obj)
|
||||||
struct serial_s *obj_s = SERIAL_S(obj);
|
struct serial_s *obj_s = SERIAL_S(obj);
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
|
/* Computation of UART mask to apply to RDR register */
|
||||||
|
UART_MASK_COMPUTATION(huart);
|
||||||
|
uint16_t uhMask = huart->Mask;
|
||||||
|
|
||||||
while (!serial_readable(obj));
|
while (!serial_readable(obj));
|
||||||
if (obj_s->databits == UART_WORDLENGTH_8B) {
|
/* When receiving with the parity enabled, the value read in the MSB bit
|
||||||
return (int)(huart->Instance->RDR & (uint8_t)0xFF);
|
* is the received parity bit.
|
||||||
} else {
|
*/
|
||||||
return (int)(huart->Instance->RDR & (uint16_t)0x1FF);
|
return (int)(huart->Instance->RDR & uhMask);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_putc(serial_t *obj, int c)
|
void serial_putc(serial_t *obj, int c)
|
||||||
|
@ -216,11 +219,12 @@ void serial_putc(serial_t *obj, int c)
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
while (!serial_writable(obj));
|
while (!serial_writable(obj));
|
||||||
if (obj_s->databits == UART_WORDLENGTH_8B) {
|
/* When transmitting with the parity enabled (PCE bit set to 1 in the
|
||||||
huart->Instance->TDR = (uint8_t)(c & (uint8_t)0xFF);
|
* USART_CR1 register), the value written in the MSB (bit 7 or bit 8
|
||||||
} else {
|
* depending on the data length) has no effect because it is replaced
|
||||||
huart->Instance->TDR = (uint16_t)(c & (uint16_t)0x1FF);
|
* by the parity.
|
||||||
}
|
*/
|
||||||
|
huart->Instance->TDR = (uint16_t)(c & 0x1FFU);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_clear(serial_t *obj)
|
void serial_clear(serial_t *obj)
|
||||||
|
|
|
@ -234,8 +234,15 @@ int serial_getc(serial_t *obj)
|
||||||
struct serial_s *obj_s = SERIAL_S(obj);
|
struct serial_s *obj_s = SERIAL_S(obj);
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
|
/* Computation of UART mask to apply to RDR register */
|
||||||
|
UART_MASK_COMPUTATION(huart);
|
||||||
|
uint16_t uhMask = huart->Mask;
|
||||||
|
|
||||||
while (!serial_readable(obj));
|
while (!serial_readable(obj));
|
||||||
return (int)(huart->Instance->RDR & 0x1FF);
|
/* When receiving with the parity enabled, the value read in the MSB bit
|
||||||
|
* is the received parity bit.
|
||||||
|
*/
|
||||||
|
return (int)(huart->Instance->RDR & uhMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_putc(serial_t *obj, int c)
|
void serial_putc(serial_t *obj, int c)
|
||||||
|
@ -244,7 +251,12 @@ void serial_putc(serial_t *obj, int c)
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
while (!serial_writable(obj));
|
while (!serial_writable(obj));
|
||||||
huart->Instance->TDR = (uint32_t)(c & 0x1FF);
|
/* When transmitting with the parity enabled (PCE bit set to 1 in the
|
||||||
|
* USART_CR1 register), the value written in the MSB (bit 7 or bit 8
|
||||||
|
* depending on the data length) has no effect because it is replaced
|
||||||
|
* by the parity.
|
||||||
|
*/
|
||||||
|
huart->Instance->TDR = (uint16_t)(c & 0x1FFU);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_clear(serial_t *obj)
|
void serial_clear(serial_t *obj)
|
||||||
|
|
|
@ -190,8 +190,15 @@ int serial_getc(serial_t *obj)
|
||||||
struct serial_s *obj_s = SERIAL_S(obj);
|
struct serial_s *obj_s = SERIAL_S(obj);
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
|
/* Computation of UART mask to apply to RDR register */
|
||||||
|
UART_MASK_COMPUTATION(huart);
|
||||||
|
uint16_t uhMask = huart->Mask;
|
||||||
|
|
||||||
while (!serial_readable(obj));
|
while (!serial_readable(obj));
|
||||||
return (int)(huart->Instance->RDR & (uint16_t)0xFF);
|
/* When receiving with the parity enabled, the value read in the MSB bit
|
||||||
|
* is the received parity bit.
|
||||||
|
*/
|
||||||
|
return (int)(huart->Instance->RDR & uhMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_putc(serial_t *obj, int c)
|
void serial_putc(serial_t *obj, int c)
|
||||||
|
@ -200,7 +207,12 @@ void serial_putc(serial_t *obj, int c)
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
while (!serial_writable(obj));
|
while (!serial_writable(obj));
|
||||||
huart->Instance->TDR = (uint32_t)(c & (uint16_t)0xFF);
|
/* When transmitting with the parity enabled (PCE bit set to 1 in the
|
||||||
|
* USART_CR1 register), the value written in the MSB (bit 7 or bit 8
|
||||||
|
* depending on the data length) has no effect because it is replaced
|
||||||
|
* by the parity.
|
||||||
|
*/
|
||||||
|
huart->Instance->TDR = (uint16_t)(c & 0x1FFU);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_clear(serial_t *obj)
|
void serial_clear(serial_t *obj)
|
||||||
|
|
|
@ -247,8 +247,15 @@ int serial_getc(serial_t *obj)
|
||||||
struct serial_s *obj_s = SERIAL_S(obj);
|
struct serial_s *obj_s = SERIAL_S(obj);
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
|
/* Computation of UART mask to apply to RDR register */
|
||||||
|
UART_MASK_COMPUTATION(huart);
|
||||||
|
uint16_t uhMask = huart->Mask;
|
||||||
|
|
||||||
while (!serial_readable(obj));
|
while (!serial_readable(obj));
|
||||||
return (int)(huart->Instance->RDR & 0x1FF);
|
/* When receiving with the parity enabled, the value read in the MSB bit
|
||||||
|
* is the received parity bit.
|
||||||
|
*/
|
||||||
|
return (int)(huart->Instance->RDR & uhMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_putc(serial_t *obj, int c)
|
void serial_putc(serial_t *obj, int c)
|
||||||
|
@ -257,7 +264,12 @@ void serial_putc(serial_t *obj, int c)
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
while (!serial_writable(obj));
|
while (!serial_writable(obj));
|
||||||
huart->Instance->TDR = (uint32_t)(c & 0x1FF);
|
/* When transmitting with the parity enabled (PCE bit set to 1 in the
|
||||||
|
* USART_CR1 register), the value written in the MSB (bit 7 or bit 8
|
||||||
|
* depending on the data length) has no effect because it is replaced
|
||||||
|
* by the parity.
|
||||||
|
*/
|
||||||
|
huart->Instance->TDR = (uint16_t)(c & 0x1FFU);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_clear(serial_t *obj)
|
void serial_clear(serial_t *obj)
|
||||||
|
|
|
@ -204,8 +204,15 @@ int serial_getc(serial_t *obj)
|
||||||
struct serial_s *obj_s = SERIAL_S(obj);
|
struct serial_s *obj_s = SERIAL_S(obj);
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
|
/* Computation of UART mask to apply to RDR register */
|
||||||
|
UART_MASK_COMPUTATION(huart);
|
||||||
|
uint16_t uhMask = huart->Mask;
|
||||||
|
|
||||||
while (!serial_readable(obj));
|
while (!serial_readable(obj));
|
||||||
return (int)(huart->Instance->RDR & (uint16_t)0xFF);
|
/* When receiving with the parity enabled, the value read in the MSB bit
|
||||||
|
* is the received parity bit.
|
||||||
|
*/
|
||||||
|
return (int)(huart->Instance->RDR & uhMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_putc(serial_t *obj, int c)
|
void serial_putc(serial_t *obj, int c)
|
||||||
|
@ -214,7 +221,12 @@ void serial_putc(serial_t *obj, int c)
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
while (!serial_writable(obj));
|
while (!serial_writable(obj));
|
||||||
huart->Instance->TDR = (uint32_t)(c & (uint16_t)0xFF);
|
/* When transmitting with the parity enabled (PCE bit set to 1 in the
|
||||||
|
* USART_CR1 register), the value written in the MSB (bit 7 or bit 8
|
||||||
|
* depending on the data length) has no effect because it is replaced
|
||||||
|
* by the parity.
|
||||||
|
*/
|
||||||
|
huart->Instance->TDR = (uint16_t)(c & 0x1FFU);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_clear(serial_t *obj)
|
void serial_clear(serial_t *obj)
|
||||||
|
|
|
@ -215,12 +215,15 @@ int serial_getc(serial_t *obj)
|
||||||
struct serial_s *obj_s = SERIAL_S(obj);
|
struct serial_s *obj_s = SERIAL_S(obj);
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
|
/* Computation of UART mask to apply to RDR register */
|
||||||
|
UART_MASK_COMPUTATION(huart);
|
||||||
|
uint16_t uhMask = huart->Mask;
|
||||||
|
|
||||||
while (!serial_readable(obj));
|
while (!serial_readable(obj));
|
||||||
if (obj_s->databits == UART_WORDLENGTH_8B) {
|
/* When receiving with the parity enabled, the value read in the MSB bit
|
||||||
return (int)(huart->Instance->RDR & (uint8_t)0xFF);
|
* is the received parity bit.
|
||||||
} else {
|
*/
|
||||||
return (int)(huart->Instance->RDR & (uint16_t)0x1FF);
|
return (int)(huart->Instance->RDR & uhMask);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_putc(serial_t *obj, int c)
|
void serial_putc(serial_t *obj, int c)
|
||||||
|
@ -229,11 +232,12 @@ void serial_putc(serial_t *obj, int c)
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
while (!serial_writable(obj));
|
while (!serial_writable(obj));
|
||||||
if (obj_s->databits == UART_WORDLENGTH_8B) {
|
/* When transmitting with the parity enabled (PCE bit set to 1 in the
|
||||||
huart->Instance->TDR = (uint8_t)(c & (uint8_t)0xFF);
|
* USART_CR1 register), the value written in the MSB (bit 7 or bit 8
|
||||||
} else {
|
* depending on the data length) has no effect because it is replaced
|
||||||
huart->Instance->TDR = (uint16_t)(c & (uint16_t)0x1FF);
|
* by the parity.
|
||||||
}
|
*/
|
||||||
|
huart->Instance->TDR = (uint16_t)(c & 0x1FFU);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_clear(serial_t *obj)
|
void serial_clear(serial_t *obj)
|
||||||
|
|
|
@ -146,12 +146,15 @@ int serial_getc(serial_t *obj)
|
||||||
struct serial_s *obj_s = SERIAL_S(obj);
|
struct serial_s *obj_s = SERIAL_S(obj);
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
|
/* Computation of UART mask to apply to RDR register */
|
||||||
|
UART_MASK_COMPUTATION(huart);
|
||||||
|
uint16_t uhMask = huart->Mask;
|
||||||
|
|
||||||
while (!serial_readable(obj));
|
while (!serial_readable(obj));
|
||||||
if (obj_s->databits == UART_WORDLENGTH_8B) {
|
/* When receiving with the parity enabled, the value read in the MSB bit
|
||||||
return (int)(huart->Instance->RDR & (uint8_t)0xFF);
|
* is the received parity bit.
|
||||||
} else {
|
*/
|
||||||
return (int)(huart->Instance->RDR & (uint16_t)0x1FF);
|
return (int)(huart->Instance->RDR & uhMask);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_putc(serial_t *obj, int c)
|
void serial_putc(serial_t *obj, int c)
|
||||||
|
@ -160,11 +163,12 @@ void serial_putc(serial_t *obj, int c)
|
||||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||||
|
|
||||||
while (!serial_writable(obj));
|
while (!serial_writable(obj));
|
||||||
if (obj_s->databits == UART_WORDLENGTH_8B) {
|
/* When transmitting with the parity enabled (PCE bit set to 1 in the
|
||||||
huart->Instance->TDR = (uint8_t)(c & (uint8_t)0xFF);
|
* USART_CR1 register), the value written in the MSB (bit 7 or bit 8
|
||||||
} else {
|
* depending on the data length) has no effect because it is replaced
|
||||||
huart->Instance->TDR = (uint16_t)(c & (uint16_t)0x1FF);
|
* by the parity.
|
||||||
}
|
*/
|
||||||
|
huart->Instance->TDR = (uint16_t)(c & 0x1FFU);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_clear(serial_t *obj)
|
void serial_clear(serial_t *obj)
|
||||||
|
|
Loading…
Reference in New Issue