Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf52832 Serial UART input example

Hello.

I use nrf52832 on Adafruit Feather board among with nrf5 SDK.
As a default I can log any info via NRF_LOG_DEBUG to my serial monitor.

But how can I use Serial input to send some data to app via same serial UART?
Are there any example in SDK to read from UART on app SDK level.
(I use ESB low-power TX/RX examples from Proprietary RF).

Kind regards.

Ivan.

Parents
  • I am using printf() without any issues. Assuming you enabled all of the UART related macros in sdk_config file: (UART instances, UART peripheral driver, EasyDMA, UART Config Log, UART RX/TX Pins, etc...).
    If you're having problem understanding, your best course of action is to open existing UART examples and play with them until you get it.
    Now to answer your question, you'll probably have to enable RETARGET_ENABLED. If you go this route and you are successful in sending data through, then you might want to add this too you Makefile file to enable printing floats:
    # Linker flags
    LDFLAGS += $(OPT)
    .
    .
    .
    LDFLAGS += -u _printf_float
    Hope this helps,
    Cheers
  • Output debug works no problem.

    I only mean some terminal input parse (i need to input some commands via serial and get responce to them in main application of my ESB example).
    like "app_uart_read" but to get access to it from ESB examples, cause app. can't find UART low level functions to read byte(couple of bytes).

    I think I need reimplement this handler in my app, right?

    uint8_t dataArray[MSG_LEN] = {0};
    
    void uart_event_handle(app_uart_evt_t * p_event)
    {
        static uint8_t index = 0;
    
        switch (p_event->evt_type)
        {
            case APP_UART_DATA_READY:
                app_uart_get(&dataArray[index]);
                index++;
                
                if (index == MSG_LEN) {
                    index = 0;
                    
                    //data ready
                }
                
                break;
    
            default:
                break;
        }
    }
    
    //do smth with @dataArray


    And what I need to include to get this work?

Reply
  • Output debug works no problem.

    I only mean some terminal input parse (i need to input some commands via serial and get responce to them in main application of my ESB example).
    like "app_uart_read" but to get access to it from ESB examples, cause app. can't find UART low level functions to read byte(couple of bytes).

    I think I need reimplement this handler in my app, right?

    uint8_t dataArray[MSG_LEN] = {0};
    
    void uart_event_handle(app_uart_evt_t * p_event)
    {
        static uint8_t index = 0;
    
        switch (p_event->evt_type)
        {
            case APP_UART_DATA_READY:
                app_uart_get(&dataArray[index]);
                index++;
                
                if (index == MSG_LEN) {
                    index = 0;
                    
                    //data ready
                }
                
                break;
    
            default:
                break;
        }
    }
    
    //do smth with @dataArray


    And what I need to include to get this work?

Children
Related