This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

initialization function uart inside a c++ function

Hello all, I try to initialize the uart module inside a c++ code as follow:

#include "uart.hpp"

void Uart::uart_init()
{
  uint32_t err_code;
  app_uart_comm_params_t comm_params;

  comm_params.rx_pin_no=RX_PIN_NUMBER;
  comm_params.tx_pin_no=TX_PIN_NUMBER;
  comm_params.rts_pin_no=RTS_PIN_NUMBER;
  comm_params.cts_pin_no=CTS_PIN_NUMBER;
  comm_params.flow_control=APP_UART_FLOW_CONTROL_DISABLED;
  comm_params.use_parity=false;
  comm_params.baud_rate=UART_BAUDRATE_BAUDRATE_Baud115200;

  err_code = app_uart_init(&comm_params, NULL, this->uart_event_handle, APP_IRQ_PRIORITY_MID);
  APP_ERROR_CHECK(err_code);
}

but I got the following error :

src/uart.cpp: In member function 'void Uart::uart_init()':
src/uart.cpp:43:93: error: invalid use of non-static member function
   err_code = app_uart_init(&comm_params, NULL, this->uart_event_handle, APP_IRQ_PRIORITY_MID);
                                                                                         ^
Makefile.common:44: recipe for target '_build/nrf52832_xxaa_uart.cpp.o' failed
make: *** [_build/nrf52832_xxaa_uart.cpp.o] Error 1

can someone help me, plz

Related