nRF5 SDK: UART

Understand UART, UARTE and getting it to work with PPI

UART — Universal asynchronous receiver/transmitter
UARTE — Universal asynchronous receiver/transmitter with EasyDMA
Peripheral drivers – UART
Peripheral drivers – UARTE
UART Driver
UART module
Serial port library

nrfx_err_t nrfx_uart_init(nrfx_uart_t const *        p_instance,
                          nrfx_uart_config_t const * p_config,
                          nrfx_uart_event_handler_t  event_handler)
{
    [...]
    apply_config(p_instance, p_config);
    [...]
}

static void apply_config(nrfx_uart_t        const * p_instance,
                         nrfx_uart_config_t const * p_config)
{
    [...]
    /* TXD */
    nrf_gpio_pin_set(p_config->pseltxd);
    nrf_gpio_cfg_output(p_config->pseltxd);
    
    /* RXD */
    nrf_gpio_cfg_input(p_config->pselrxd, NRF_GPIO_PIN_NOPULL);

    nrf_uart_baudrate_set(p_instance->p_reg, p_config->baudrate);
    nrf_uart_configure(p_instance->p_reg, p_config->parity, p_config->hwfc);
    nrf_uart_txrx_pins_set(p_instance->p_reg, p_config->pseltxd, p_config->pselrxd);
    [...]
}
void nrf_uart_txrx_pins_set(
    NRF_UART_Type  *p_reg,
    uint32_t        pseltxd,
    uint32_t        pselrxd
) {
    p_reg->PSELRXD = pselrxd;
    p_reg->PSELTXD = pseltxd;
}

Leave a Reply

Your email address will not be published. Required fields are marked *