serial_configure not found

Created at 2022-04-25 11:07:49

First problem:
The extremely simple program below compiles fine with those commented lines:

#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
#include <vconsole.h>

#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>

#define LED_PIN GET_PIN(E, 3) // LED:PE3

/*
// uart3
rt_device_t serial;
serial_configure sconf = {
  BAUD_RATE_115200,
  DATA_BITS_8,
  STOP_BITS_1,
  PARITY_NONE,
  BIT_ORDER_LSB,
  NRZ_NORMAL,
  RT_SERIAL_RB_BUFSZ,
  0
};
*/

int main(void)
{
    int count = 1;

    /*
    // Configura a uart3
    serial = rt_device_find("uart3");
    rt_device_open(serial, RT_DEVICE_FLAG_INT_RX);
    rt_device_control(serial, RT_DEVICE_CTRL_CONFIG, &sconf);
    */

    rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT);

    rt_device_t dev = rt_device_find("vcom");
    vconsole_switch(dev);

    while (count++)
    {
      //rt_device_write(serial, 0, (void*) "Hello World!\r\n", 14);
      rt_kprintf("Hello World");
      rt_pin_write(LED_PIN, PIN_HIGH);
      rt_thread_mdelay(500);
      rt_pin_write(LED_PIN, PIN_LOW);
      rt_thread_mdelay(500);
    }

    return RT_EOK;
}

I got success when executing it with a 480 MHz system clock (STM32H750VB). Also all fine when redirecting the console (package vconsole ) from UART3 to USB (@ 48 MHz).
Anyway, as an UART needs to be defined initially for console, I have the following lines on board.h:

#define BSP_USING_UART3
#define BSP_UART3_TX_PIN       "PD8"
#define BSP_UART3_RX_PIN       "PD9"

After, the console is switched to USB in above code, but the problem is: The initial text with classic RT-Thread logo is send to UART3 and next transmisssions with "rt_kprintf("Hello World") are transmitted to USB. Is there a way to avoid this behavior?

Second problem:

I would like to use UART3 not as console, but for general serial communication, including ISR. So, I followed the instructions mentioned on

https://www.rt-thread.io/document/site/programming-manual/device/uart/uart/

But, uncommenting those lines and commenting "rt_kprintf("Hello World")", the result is

_../applications/main.c:24:1: error: unknown type name 'serial_configure'
 serial_configure sconf = {
 ^
In file included from C:\Temp\Test\rt-thread\components\drivers\include/rtdevice.h:60:0,
                 from ../applications/main.c:12:
C:\Temp\Test\rt-thread\components\drivers\include/drivers/serial.h:35:41: warning: excess elements in scalar initializer
 #define DATA_BITS_8                     8
                                         ^
../applications/main.c:26:3: note: in expansion of macro 'DATA_BITS_8'
   DATA_BITS_8,
   ^
C:\Temp\Test\rt-thread\components\drivers\include/drivers/serial.h:35:41: note: (near initialization for 'sconf')
 #define DATA_BITS_8                     8
                                         ^
../applications/main.c:26:3: note: in expansion of macro 'DATA_BITS_8'
   DATA_BITS_8,
   ^
C:\Temp\Test\rt-thread\components\drivers\include/drivers/serial.h:38:41: warning: excess elements in scalar initializer
 #define STOP_BITS_1                     0
                                         ^
../applications/main.c:27:3: note: in expansion of macro 'STOP_BITS_1'
   STOP_BITS_1,
   ^
C:\Temp\Test\rt-thread\components\drivers\include/drivers/serial.h:38:41: note: (near initialization for 'sconf')
 #define STOP_BITS_1                     0
                                         ^
../applications/main.c:27:3: note: in expansion of macro 'STOP_BITS_1'
   STOP_BITS_1,
   ^
C:\Temp\Test\rt-thread\components\drivers\include/drivers/serial.h:46:41: warning: excess elements in scalar initializer
 #define PARITY_NONE                     0
                                         ^
../applications/main.c:28:3: note: in expansion of macro 'PARITY_NONE'
   PARITY_NONE,
   ^
C:\Temp\Test\rt-thread\components\drivers\include/drivers/serial.h:46:41: note: (near initialization for 'sconf')
 #define PARITY_NONE                     0
                                         ^
../applications/main.c:28:3: note: in expansion of macro 'PARITY_NONE'
   PARITY_NONE,
   ^
C:\Temp\Test\rt-thread\components\drivers\include/drivers/serial.h:51:41: warning: excess elements in scalar initializer
 #define BIT_ORDER_LSB                   0
                                         ^
../applications/main.c:29:3: note: in expansion of macro 'BIT_ORDER_LSB'
   BIT_ORDER_LSB,
   ^
C:\Temp\Test\rt-thread\components\drivers\include/drivers/serial.h:51:41: note: (near initialization for 'sconf')
 #define BIT_ORDER_LSB                   0
                                         ^
../applications/main.c:29:3: note: in expansion of macro 'BIT_ORDER_LSB'
   BIT_ORDER_LSB,
   ^
C:\Temp\rt-thread\components\drivers\include/drivers/serial.h:54:41: warning: excess elements in scalar initializer
 #define NRZ_NORMAL                      0       /* Non Return to Zero : normal mode */
                                         ^
../applications/main.c:30:3: note: in expansion of macro 'NRZ_NORMAL'
   NRZ_NORMAL,
   ^
C:\Temp\Test\rt-thread\components\drivers\include/drivers/serial.h:54:41: note: (near initialization for 'sconf')
 #define NRZ_NORMAL                      0       /* Non Return to Zero : normal mode */
                                         ^
../applications/main.c:30:3: note: in expansion of macro 'NRZ_NORMAL'
   NRZ_NORMAL,
   ^
In file included from C:\Temp\Test\rt-thread\include/rtthread.h:22:0,
                 from ../applications/main.c:11:
C:\Temp\Test/rtconfig.h:91:28: warning: excess elements in scalar initializer
 #define RT_SERIAL_RB_BUFSZ 64
                            ^
../applications/main.c:31:3: note: in expansion of macro 'RT_SERIAL_RB_BUFSZ'
   RT_SERIAL_RB_BUFSZ,
   ^
C:\Temp\Test/rtconfig.h:91:28: note: (near initialization for 'sconf')
 #define RT_SERIAL_RB_BUFSZ 64
                            ^
../applications/main.c:31:3: note: in expansion of macro 'RT_SERIAL_RB_BUFSZ'
   RT_SERIAL_RB_BUFSZ,
   ^
../applications/main.c:32:3: warning: excess elements in scalar initializer
   0
   ^
../applications/main.c:32:3: note: (near initialization for 'sconf')
make: *** [applications/subdir.mk:18: applications/main.o] Error 1
"make -j8 all" terminated with exit code 2. Build might be incomplete._

More

Follower
0
Views
105
1 Answer
davidticker
davidticker 2022-04-27

Could you please share a log to quickly locate the issue? Thanks.

Write Your Answer

Log in to publish your answer.,Click here to log in.

Create
Post

Share