Skip to content

Commit dccd866

Browse files
samples: nordic: nrfx_prs: align to nrfx_uarte rework
Changed error codes, driver instantiation and removed unnecessary symbols. Signed-off-by: Michał Stasiak <[email protected]>
1 parent 622e0b1 commit dccd866

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

samples/boards/nordic/nrfx_prs/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# between those peripherals, as they share the same ID and hence cannot be used
33
# simultaneously.
44
CONFIG_NRFX_SPIM2=y
5-
CONFIG_NRFX_UARTE2=y
5+
CONFIG_NRFX_UARTE=y
66
CONFIG_NRFX_PRS_BOX_2=y
77

88
# This is needed for using another SPIM instance via the Zephyr SPI driver.

samples/boards/nordic/nrfx_prs/src/main.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#define SPI_DEV_NODE DT_NODELABEL(spi1)
3030

3131
static nrfx_spim_t spim = NRFX_SPIM_INSTANCE(2);
32-
static nrfx_uarte_t uarte = NRFX_UARTE_INSTANCE(2);
32+
static nrfx_uarte_t uarte = NRFX_UARTE_INSTANCE(NRF_UARTE2);
3333
static bool spim_initialized;
3434
static bool uarte_initialized;
3535
static volatile size_t received;
@@ -213,7 +213,6 @@ static void uarte_handler(const nrfx_uarte_event_t *p_event, void *p_context)
213213
static bool switch_to_uarte(void)
214214
{
215215
int ret;
216-
nrfx_err_t err;
217216

218217
PINCTRL_DT_DEFINE(UARTE_NODE);
219218

@@ -244,9 +243,9 @@ static bool switch_to_uarte(void)
244243
return ret;
245244
}
246245

247-
err = nrfx_uarte_init(&uarte, &uarte_config, uarte_handler);
248-
if (err != NRFX_SUCCESS) {
249-
printk("nrfx_uarte_init() failed: 0x%08x\n", err);
246+
ret = nrfx_uarte_init(&uarte, &uarte_config, uarte_handler);
247+
if (err != 0) {
248+
printk("nrfx_uarte_init() failed: %d\n", ret);
250249
return false;
251250
}
252251

@@ -258,23 +257,23 @@ static bool switch_to_uarte(void)
258257
static bool uarte_transfer(const uint8_t *tx_data, size_t tx_data_len,
259258
uint8_t *rx_buf, size_t rx_buf_size)
260259
{
261-
nrfx_err_t err;
260+
int err;
262261

263262
err = nrfx_uarte_rx_buffer_set(&uarte, rx_buf, rx_buf_size);
264-
if (err != NRFX_SUCCESS) {
265-
printk("nrfx_uarte_rx_buffer_set() failed: 0x%08x\n", err);
263+
if (err != 0) {
264+
printk("nrfx_uarte_rx_buffer_set() failed: %d\n", err);
266265
return false;
267266
}
268267

269268
err = nrfx_uarte_rx_enable(&uarte, NRFX_UARTE_RX_ENABLE_STOP_ON_END);
270-
if (err != NRFX_SUCCESS) {
271-
printk("nrfx_uarte_rx_enable() failed: 0x%08x\n", err);
269+
if (err != 0) {
270+
printk("nrfx_uarte_rx_enable() failed: %d\n", err);
272271
return false;
273272
}
274273

275274
err = nrfx_uarte_tx(&uarte, tx_data, tx_data_len, 0);
276-
if (err != NRFX_SUCCESS) {
277-
printk("nrfx_uarte_tx() failed: 0x%08x\n", err);
275+
if (err != 0) {
276+
printk("nrfx_uarte_tx() failed: %d\n", err);
278277
return false;
279278
}
280279

0 commit comments

Comments
 (0)