RT-Thread / RT-Thread/rt-thread

nxp1052 串口bsp驱动,如果应用程序对某个串口重新配置波特率等参数,该串口无法接收数据,需将中断重新使能

Open
#6,112 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
12.2k
Forks
5.4k
Avg merge
4d 12h
Merged PRs (30d)
40

Description

应用程序如果重新配置串口参数会调用
`static rt_err_t imxrt_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
{
struct imxrt_uart *uart;
lpuart_config_t config;

RT_ASSERT(serial != RT_NULL);
RT_ASSERT(cfg != RT_NULL);

uart = rt_container_of(serial, struct imxrt_uart, serial);

LPUART_GetDefaultConfig(&config);
config.baudRate_Bps = cfg->baud_rate;

switch (cfg->data_bits)
{
case DATA_BITS_7:
    config.dataBitsCount = kLPUART_SevenDataBits;
    break;

default:
    config.dataBitsCount = kLPUART_EightDataBits;
    break;
}

switch (cfg->stop_bits)
{
case STOP_BITS_2:
    config.stopBitCount = kLPUART_TwoStopBit;
    break;
default:
    config.stopBitCount = kLPUART_OneStopBit;
    break;
}

switch (cfg->parity)
{
case PARITY_ODD:
    config.parityMode = kLPUART_ParityOdd;
    break;
case PARITY_EVEN:
    config.parityMode = kLPUART_ParityEven;
    break;
default:
    config.parityMode = kLPUART_ParityDisabled;
    break;
}

config.enableTx = true;
config.enableRx = true;

LPUART_Init(uart->uart_base, &config, GetUartSrcFreq(uart->uart_base));

return RT_EOK;

}`

但是调用后串口无法收到数据,需再次中断使能
LPUART_EnableInterrupts(uart->uart_base, kLPUART_RxDataRegFullInterruptEnable); NVIC_SetPriority(uart->irqn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 4, 0)); EnableIRQ(uart->irqn);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the imxrt_configure implementation and trace how LPUART_Init affects the receive interrupt state. Reproduce changing baud rate or other serial parameters, then verify that RX data reception resumes after reconfiguration and that the required interrupt setup remains enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.