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

how to use Simple UART driver?

From the SDK8 s110 device, I want to send the string("hello") to the other device via the uart, and in the meantime I want the battery voltage to come through uart.

I defined ;

void uart_event_handle(app_uart_evt_t * p_event)
{
    static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
    static uint8_t index = 0;

    switch (p_event->evt_type)
    {
        case APP_UART_DATA_READY:
            UNUSED_VARIABLE(app_uart_get(&data_array[index]));
            index++;

           
		if((data_array[index - 2] == 'm') && (data_array[index - 1] == 'V'))
		{
			for(int i=0 ; i<6; i++)
			{
				m_battery_level[i] = data_array[i];
			}
		}
            break;

        case APP_UART_COMMUNICATION_ERROR:
            APP_ERROR_HANDLER(p_event->data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:
            APP_ERROR_HANDLER(p_event->data.error_code);
            break;

        default:
            break;
    }
}

static void uart_init(void)
{
    uint32_t                     err_code;
    const app_uart_comm_params_t comm_params =
    {
        RX_PIN_NUMBER,
        TX_PIN_NUMBER,
        RTS_PIN_NUMBER,
        CTS_PIN_NUMBER,
        APP_UART_FLOW_CONTROL_DISABLED,
        false,
        UART_BAUDRATE_BAUDRATE_Baud9600
    };

    APP_UART_FIFO_INIT( &comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_event_handle,
                       APP_IRQ_PRIORITY_LOW,
                       err_code);
    APP_ERROR_CHECK(err_code);
}

I found the app_uart_put (uint8_t byte) function in app_uart_fifo.c, but I want to send a string. How can I send "Hello" string data over uart connection?

Related