drivers/serial/uart_nrfx_uarte2: Fix for simulation
Just like for the old driver, for simulation, we cannot get the UART regiter address for the pinctrl config structure from DT, as that cannot match the one allocated at build time. So let's override it at runtime with the correct address which is stored in the UART config structure. Also, do improve the condition for the busy wait during the poll_out, for simulation, so we only busy wait if we will loop/the Tx was busy. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
parent
a4ed3994b7
commit
6447b1c4fd
1 changed files with 11 additions and 4 deletions
|
@ -562,11 +562,13 @@ static void api_poll_out(const struct device *dev, unsigned char out_char)
|
|||
err = nrfx_uarte_tx(nrfx_dev, &out_char, 1, NRFX_UARTE_TX_EARLY_RETURN);
|
||||
__ASSERT(err != NRFX_ERROR_INVALID_ADDR, "Invalid address of the buffer");
|
||||
|
||||
if (err == NRFX_ERROR_BUSY &&
|
||||
IS_ENABLED(CONFIG_MULTITHREADING) && k_is_preempt_thread()) {
|
||||
k_msleep(1);
|
||||
if (err == NRFX_ERROR_BUSY) {
|
||||
if (IS_ENABLED(CONFIG_MULTITHREADING) && k_is_preempt_thread()) {
|
||||
k_msleep(1);
|
||||
} else {
|
||||
Z_SPIN_DELAY(3);
|
||||
}
|
||||
}
|
||||
Z_SPIN_DELAY(3);
|
||||
} while (err == NRFX_ERROR_BUSY);
|
||||
}
|
||||
|
||||
|
@ -789,6 +791,11 @@ static int uarte_nrfx_init(const struct device *dev)
|
|||
const struct uarte_nrfx_config *cfg = dev->config;
|
||||
struct uarte_nrfx_data *data = dev->data;
|
||||
|
||||
#ifdef CONFIG_ARCH_POSIX
|
||||
/* For simulation the DT provided peripheral address needs to be corrected */
|
||||
((struct pinctrl_dev_config *)cfg->pcfg)->reg = (uintptr_t)nrfx_dev->p_reg;
|
||||
#endif
|
||||
|
||||
err = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue