mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 01:50:53 +00:00
chip/stm32/usart: Add flags to usart_config
Allows setting TXINV/RXINV bits. BRANCH=none BUG=b:65697962 TEST=make BOARD=wand -j Change-Id: Ib1bb290cd9758c53b98c8fc1ca1a9369c8cff39e Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/694561 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
8434ed8f10
commit
7501654d20
@@ -65,6 +65,7 @@ static struct usart_config const loopback_usart =
|
||||
loopback_rx_dma.usart_rx,
|
||||
loopback_tx_dma.usart_tx,
|
||||
115200,
|
||||
0,
|
||||
loopback_queue,
|
||||
loopback_queue);
|
||||
|
||||
@@ -89,6 +90,7 @@ static struct usart_config const forward_usart =
|
||||
usart_rx_interrupt,
|
||||
forward_tx_dma.usart_tx,
|
||||
115200,
|
||||
0,
|
||||
usart_to_usb,
|
||||
usb_to_usart);
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ static struct usart_config const loopback_usart =
|
||||
loopback_rx_dma.usart_rx,
|
||||
loopback_tx_dma.usart_tx,
|
||||
115200,
|
||||
0,
|
||||
loopback_queue,
|
||||
loopback_queue);
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ static struct usart_config const usart2 =
|
||||
usart_rx_interrupt,
|
||||
usart_tx_interrupt,
|
||||
115200,
|
||||
0,
|
||||
usart2_to_usb,
|
||||
usb_to_usart2);
|
||||
|
||||
@@ -81,6 +82,7 @@ static struct usart_config const usart3 =
|
||||
usart_rx_interrupt,
|
||||
usart_tx_interrupt,
|
||||
115200,
|
||||
0,
|
||||
usart3_to_usb,
|
||||
usb_to_usart3);
|
||||
|
||||
@@ -112,6 +114,7 @@ static struct usart_config const usart4 =
|
||||
usart_rx_interrupt,
|
||||
usart_tx_interrupt,
|
||||
115200,
|
||||
0,
|
||||
usart4_to_usb,
|
||||
usb_to_usart4);
|
||||
|
||||
|
||||
@@ -162,6 +162,7 @@ static struct usart_config const usart3 =
|
||||
usart_rx_interrupt,
|
||||
usart_tx_interrupt,
|
||||
115200,
|
||||
0,
|
||||
usart3_to_usb,
|
||||
usb_to_usart3);
|
||||
|
||||
@@ -192,6 +193,7 @@ static struct usart_config const usart4 =
|
||||
usart_rx_interrupt,
|
||||
usart_tx_interrupt,
|
||||
9600,
|
||||
0,
|
||||
usart4_to_usb,
|
||||
usb_to_usart4);
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ static struct usart_config const usart1 =
|
||||
usart_rx_interrupt,
|
||||
usart_tx_interrupt,
|
||||
115200,
|
||||
0,
|
||||
usart1_to_usb,
|
||||
usb_to_usart1);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
void usart_init(struct usart_config const *config)
|
||||
{
|
||||
intptr_t base = config->hw->base;
|
||||
uint32_t cr2;
|
||||
|
||||
/*
|
||||
* Enable clock to USART, this must be done first, before attempting
|
||||
@@ -40,8 +41,18 @@ void usart_init(struct usart_config const *config)
|
||||
* 8N1, 16 samples per bit. error interrupts, and special modes
|
||||
* disabled.
|
||||
*/
|
||||
|
||||
cr2 = 0x0000;
|
||||
#if defined(CHIP_FAMILY_STM32F0) || defined(CHIP_FAMILY_STM32F3) || \
|
||||
defined(CHIP_FAMILY_STM32L4)
|
||||
if (config->flags & USART_CONFIG_FLAG_RX_INV)
|
||||
cr2 |= (1 << 16);
|
||||
if (config->flags & USART_CONFIG_FLAG_TX_INV)
|
||||
cr2 |= (1 << 17);
|
||||
#endif
|
||||
|
||||
STM32_USART_CR1(base) = 0x0000;
|
||||
STM32_USART_CR2(base) = 0x0000;
|
||||
STM32_USART_CR2(base) = cr2;
|
||||
STM32_USART_CR3(base) = 0x0000;
|
||||
|
||||
/*
|
||||
|
||||
@@ -133,6 +133,11 @@ struct usart_config {
|
||||
*/
|
||||
int baud;
|
||||
|
||||
/* Other flags. */
|
||||
#define USART_CONFIG_FLAG_RX_INV (1 << 0)
|
||||
#define USART_CONFIG_FLAG_TX_INV (1 << 1)
|
||||
unsigned int flags;
|
||||
|
||||
struct consumer consumer;
|
||||
struct producer producer;
|
||||
};
|
||||
@@ -154,21 +159,22 @@ struct usart_config {
|
||||
* BUILD_ASSERT(RX_QUEUE.unit_bytes == 1);
|
||||
* BUILD_ASSERT(TX_QUEUE.unit_bytes == 1);
|
||||
*/
|
||||
#define USART_CONFIG(HW, RX, TX, BAUD, RX_QUEUE, TX_QUEUE) \
|
||||
((struct usart_config const) { \
|
||||
.hw = &HW, \
|
||||
.rx = &RX, \
|
||||
.tx = &TX, \
|
||||
.state = &((struct usart_state){}), \
|
||||
.baud = BAUD, \
|
||||
.consumer = { \
|
||||
.queue = &TX_QUEUE, \
|
||||
.ops = &TX.consumer_ops, \
|
||||
}, \
|
||||
.producer = { \
|
||||
.queue = &RX_QUEUE, \
|
||||
.ops = &RX.producer_ops, \
|
||||
}, \
|
||||
#define USART_CONFIG(HW, RX, TX, BAUD, FLAGS, RX_QUEUE, TX_QUEUE) \
|
||||
((struct usart_config const) { \
|
||||
.hw = &HW, \
|
||||
.rx = &RX, \
|
||||
.tx = &TX, \
|
||||
.state = &((struct usart_state){}), \
|
||||
.baud = BAUD, \
|
||||
.flags = FLAGS, \
|
||||
.consumer = { \
|
||||
.queue = &TX_QUEUE, \
|
||||
.ops = &TX.consumer_ops, \
|
||||
}, \
|
||||
.producer = { \
|
||||
.queue = &RX_QUEUE, \
|
||||
.ops = &RX.producer_ops, \
|
||||
}, \
|
||||
})
|
||||
|
||||
/*
|
||||
|
||||
@@ -53,6 +53,7 @@ static struct usart_config const usart_mcdp = USART_CONFIG(CONFIG_MCDP28X0,
|
||||
usart_rx_interrupt,
|
||||
usart_tx_interrupt,
|
||||
115200,
|
||||
0,
|
||||
usart_mcdp_rx_queue,
|
||||
usart_mcdp_tx_queue);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user