diff --git a/modules/hal_nordic/nrfx/Kconfig b/modules/hal_nordic/nrfx/Kconfig index 0b1882ba7a653..19bb90a593f02 100644 --- a/modules/hal_nordic/nrfx/Kconfig +++ b/modules/hal_nordic/nrfx/Kconfig @@ -1106,106 +1106,6 @@ config NRFX_UART0 config NRFX_UARTE bool -config NRFX_UARTE0 - bool "UARTE0 driver instance" - depends on $(dt_nodelabel_exists,uart0) - select NRFX_UARTE - -config NRFX_UARTE1 - bool "UARTE1 driver instance" - depends on $(dt_nodelabel_exists,uart1) - select NRFX_UARTE - -config NRFX_UARTE2 - bool "UARTE2 driver instance" - depends on $(dt_nodelabel_exists,uart2) - select NRFX_UARTE - -config NRFX_UARTE3 - bool "UARTE3 driver instance" - depends on $(dt_nodelabel_exists,uart3) - select NRFX_UARTE - -config NRFX_UARTE00 - bool "UARTE00 driver instance" - depends on $(dt_nodelabel_exists,uart00) - select NRFX_UARTE - -config NRFX_UARTE20 - bool "UARTE20 driver instance" - depends on $(dt_nodelabel_exists,uart20) - select NRFX_UARTE - -config NRFX_UARTE21 - bool "UARTE21 driver instance" - depends on $(dt_nodelabel_exists,uart21) - select NRFX_UARTE - -config NRFX_UARTE22 - bool "UARTE22 driver instance" - depends on $(dt_nodelabel_exists,uart22) - select NRFX_UARTE - -config NRFX_UARTE23 - bool "UARTE23 driver instance" - depends on $(dt_nodelabel_exists,uart23) - select NRFX_UARTE - -config NRFX_UARTE24 - bool "UARTE24 driver instance" - depends on $(dt_nodelabel_exists,uart24) - select NRFX_UARTE - -config NRFX_UARTE30 - bool "UARTE30 driver instance" - depends on $(dt_nodelabel_exists,uart30) - select NRFX_UARTE - -config NRFX_UARTE120 - bool "UARTE120 driver instance" - depends on $(dt_nodelabel_exists,uart120) - select NRFX_UARTE - -config NRFX_UARTE130 - bool "UARTE130 driver instance" - depends on $(dt_nodelabel_exists,uart130) - select NRFX_UARTE - -config NRFX_UARTE131 - bool "UARTE131 driver instance" - depends on $(dt_nodelabel_exists,uart131) - select NRFX_UARTE - -config NRFX_UARTE132 - bool "UARTE132 driver instance" - depends on $(dt_nodelabel_exists,uart132) - select NRFX_UARTE - -config NRFX_UARTE133 - bool "UARTE133 driver instance" - depends on $(dt_nodelabel_exists,uart133) - select NRFX_UARTE - -config NRFX_UARTE134 - bool "UARTE134 driver instance" - depends on $(dt_nodelabel_exists,uart134) - select NRFX_UARTE - -config NRFX_UARTE135 - bool "UARTE135 driver instance" - depends on $(dt_nodelabel_exists,uart135) - select NRFX_UARTE - -config NRFX_UARTE136 - bool "UARTE136 driver instance" - depends on $(dt_nodelabel_exists,uart136) - select NRFX_UARTE - -config NRFX_UARTE137 - bool "UARTE137 driver instance" - depends on $(dt_nodelabel_exists,uart137) - select NRFX_UARTE - config NRFX_UARTE_CONFIG_SKIP_GPIO_CONFIG bool "UARTE GPIO configuration support" depends on NRFX_UARTE diff --git a/modules/hal_nordic/nrfx/nrfx_glue.c b/modules/hal_nordic/nrfx/nrfx_glue.c index 4e7fc94e11de0..dd972ee039d82 100644 --- a/modules/hal_nordic/nrfx/nrfx_glue.c +++ b/modules/hal_nordic/nrfx/nrfx_glue.c @@ -45,3 +45,25 @@ char const *nrfx_error_string_get(nrfx_err_t code) default: return "unknown"; } } + +char const *nrfx_new_error_string_get(int code) +{ + #define NRFX_NEW_ERROR_STRING_CASE(code) case code: return #code + switch (-code) + { + NRFX_NEW_ERROR_STRING_CASE(0); + NRFX_NEW_ERROR_STRING_CASE(ECANCELED); + NRFX_NEW_ERROR_STRING_CASE(ENOMEM); + NRFX_NEW_ERROR_STRING_CASE(ENOTSUP); + NRFX_NEW_ERROR_STRING_CASE(EINVAL); + NRFX_NEW_ERROR_STRING_CASE(EINPROGRESS); + NRFX_NEW_ERROR_STRING_CASE(E2BIG); + NRFX_NEW_ERROR_STRING_CASE(ETIMEDOUT); + NRFX_NEW_ERROR_STRING_CASE(EPERM); + NRFX_NEW_ERROR_STRING_CASE(EFAULT); + NRFX_NEW_ERROR_STRING_CASE(EACCES); + NRFX_NEW_ERROR_STRING_CASE(EBUSY); + NRFX_NEW_ERROR_STRING_CASE(EALREADY); + default: return "unknown"; + } +} diff --git a/modules/hal_nordic/nrfx/nrfx_kconfig.h b/modules/hal_nordic/nrfx/nrfx_kconfig.h index 4f0d594a21236..b5a2a2168be30 100644 --- a/modules/hal_nordic/nrfx/nrfx_kconfig.h +++ b/modules/hal_nordic/nrfx/nrfx_kconfig.h @@ -898,66 +898,6 @@ #ifdef CONFIG_NRFX_UARTE_LOG #define NRFX_UARTE_CONFIG_LOG_ENABLED 1 #endif -#ifdef CONFIG_NRFX_UARTE0 -#define NRFX_UARTE0_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE1 -#define NRFX_UARTE1_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE2 -#define NRFX_UARTE2_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE3 -#define NRFX_UARTE3_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE00 -#define NRFX_UARTE00_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE20 -#define NRFX_UARTE20_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE21 -#define NRFX_UARTE21_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE22 -#define NRFX_UARTE22_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE23 -#define NRFX_UARTE23_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE24 -#define NRFX_UARTE24_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE30 -#define NRFX_UARTE30_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE120 -#define NRFX_UARTE120_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE130 -#define NRFX_UARTE130_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE131 -#define NRFX_UARTE131_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE132 -#define NRFX_UARTE132_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE133 -#define NRFX_UARTE133_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE134 -#define NRFX_UARTE134_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE135 -#define NRFX_UARTE135_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE136 -#define NRFX_UARTE136_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_UARTE137 -#define NRFX_UARTE137_ENABLED 1 -#endif #ifdef CONFIG_NRFX_UARTE_CONFIG_SKIP_GPIO_CONFIG #define NRFX_UARTE_CONFIG_SKIP_GPIO_CONFIG 1 #endif diff --git a/modules/hal_nordic/nrfx/nrfx_log.h b/modules/hal_nordic/nrfx/nrfx_log.h index 682388d7dd16d..973ca672b5384 100644 --- a/modules/hal_nordic/nrfx/nrfx_log.h +++ b/modules/hal_nordic/nrfx/nrfx_log.h @@ -128,6 +128,16 @@ LOG_MODULE_REGISTER(NRFX_MODULE_PREFIX, NRFX_MODULE_LOG_LEVEL); #define NRFX_LOG_ERROR_STRING_GET(error_code) nrfx_error_string_get(error_code) extern char const *nrfx_error_string_get(nrfx_err_t code); +/** + * @brief Macro for getting the textual representation of a given errno error code. + * + * @param[in] error_code Errno error code. + * + * @return String containing the textual representation of the errno error code. + */ +#define NRFX_NEW_LOG_ERROR_STRING_GET(error_code) nrfx_new_error_string_get(error_code) +extern char const *nrfx_new_error_string_get(int code); + /** @} */ #ifdef __cplusplus diff --git a/samples/boards/nordic/nrfx_prs/prj.conf b/samples/boards/nordic/nrfx_prs/prj.conf index 3c8ea985f56c9..8e7a06d1ff4e3 100644 --- a/samples/boards/nordic/nrfx_prs/prj.conf +++ b/samples/boards/nordic/nrfx_prs/prj.conf @@ -2,7 +2,7 @@ # between those peripherals, as they share the same ID and hence cannot be used # simultaneously. CONFIG_NRFX_SPIM2=y -CONFIG_NRFX_UARTE2=y +CONFIG_NRFX_UARTE=y CONFIG_NRFX_PRS_BOX_2=y # This is needed for using another SPIM instance via the Zephyr SPI driver. diff --git a/samples/boards/nordic/nrfx_prs/src/main.c b/samples/boards/nordic/nrfx_prs/src/main.c index 1b9411d2da43a..3ac7346a0b622 100644 --- a/samples/boards/nordic/nrfx_prs/src/main.c +++ b/samples/boards/nordic/nrfx_prs/src/main.c @@ -29,7 +29,7 @@ #define SPI_DEV_NODE DT_NODELABEL(spi1) static nrfx_spim_t spim = NRFX_SPIM_INSTANCE(2); -static nrfx_uarte_t uarte = NRFX_UARTE_INSTANCE(2); +static nrfx_uarte_t uarte = NRFX_UARTE_INSTANCE(NRF_UARTE2); static bool spim_initialized; static bool uarte_initialized; static volatile size_t received; @@ -213,7 +213,6 @@ static void uarte_handler(const nrfx_uarte_event_t *p_event, void *p_context) static bool switch_to_uarte(void) { int ret; - nrfx_err_t err; PINCTRL_DT_DEFINE(UARTE_NODE); @@ -244,9 +243,9 @@ static bool switch_to_uarte(void) return ret; } - err = nrfx_uarte_init(&uarte, &uarte_config, uarte_handler); - if (err != NRFX_SUCCESS) { - printk("nrfx_uarte_init() failed: 0x%08x\n", err); + ret = nrfx_uarte_init(&uarte, &uarte_config, uarte_handler); + if (err != 0) { + printk("nrfx_uarte_init() failed: %d\n", ret); return false; } @@ -258,17 +257,23 @@ static bool switch_to_uarte(void) static bool uarte_transfer(const uint8_t *tx_data, size_t tx_data_len, uint8_t *rx_buf, size_t rx_buf_size) { - nrfx_err_t err; + int err; - err = nrfx_uarte_rx(&uarte, rx_buf, rx_buf_size); - if (err != NRFX_SUCCESS) { - printk("nrfx_uarte_rx() failed: 0x%08x\n", err); + err = nrfx_uarte_rx_buffer_set(&uarte, rx_buf, rx_buf_size); + if (err != 0) { + printk("nrfx_uarte_rx_buffer_set() failed: %d\n", err); + return false; + } + + err = nrfx_uarte_rx_enable(&uarte, NRFX_UARTE_RX_ENABLE_STOP_ON_END); + if (err != 0) { + printk("nrfx_uarte_rx_enable() failed: %d\n", err); return false; } err = nrfx_uarte_tx(&uarte, tx_data, tx_data_len, 0); - if (err != NRFX_SUCCESS) { - printk("nrfx_uarte_tx() failed: 0x%08x\n", err); + if (err != 0) { + printk("nrfx_uarte_tx() failed: %d\n", err); return false; }