Skip to content

Commit c8bff1d

Browse files
[nrf fromlist] samples: nordic: nrfx_prs: align to spi_nrfx_spim rework
Changed error codes, driver instantiation and removed unnecessary symbols. Upstream PR #: 96792 Signed-off-by: Michał Stasiak <[email protected]>
1 parent 090e92f commit c8bff1d

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

samples/boards/nordic/nrfx_prs/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This is needed for using SPIM2 and UARTE2 via nrfx drivers and for switching
22
# between those peripherals, as they share the same ID and hence cannot be used
33
# simultaneously.
4-
CONFIG_NRFX_SPIM2=y
4+
CONFIG_NRFX_SPIM=y
55
CONFIG_NRFX_UARTE2=y
66
CONFIG_NRFX_PRS_BOX_2=y
77

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
#define SPI_DEV_NODE DT_NODELABEL(spi1)
3030

31-
static nrfx_spim_t spim = NRFX_SPIM_INSTANCE(2);
31+
static nrfx_spim_t spim = NRFX_SPIM_INSTANCE(NRF_SPIM2);
3232
static nrfx_uarte_t uarte = NRFX_UARTE_INSTANCE(2);
3333
static bool spim_initialized;
3434
static bool uarte_initialized;
@@ -121,7 +121,6 @@ static void spim_handler(const nrfx_spim_evt_t *p_event, void *p_context)
121121
static bool switch_to_spim(void)
122122
{
123123
int ret;
124-
nrfx_err_t err;
125124
uint32_t sck_pin;
126125

127126
PINCTRL_DT_DEFINE(SPIM_NODE);
@@ -162,9 +161,9 @@ static bool switch_to_spim(void)
162161
nrfy_gpio_pin_write(sck_pin, (spim_config.mode <= NRF_SPIM_MODE_1) ? 0 : 1);
163162
}
164163

165-
err = nrfx_spim_init(&spim, &spim_config, spim_handler, NULL);
166-
if (err != NRFX_SUCCESS) {
167-
printk("nrfx_spim_init() failed: 0x%08x\n", err);
164+
ret = nrfx_spim_init(&spim, &spim_config, spim_handler, NULL);
165+
if (ret != 0) {
166+
printk("nrfx_spim_init() failed: %d", ret);
168167
return false;
169168
}
170169

@@ -176,7 +175,7 @@ static bool switch_to_spim(void)
176175
static bool spim_transfer(const uint8_t *tx_data, size_t tx_data_len,
177176
uint8_t *rx_buf, size_t rx_buf_size)
178177
{
179-
nrfx_err_t err;
178+
int err;
180179
nrfx_spim_xfer_desc_t xfer_desc = {
181180
.p_tx_buffer = tx_data,
182181
.tx_length = tx_data_len,
@@ -185,8 +184,8 @@ static bool spim_transfer(const uint8_t *tx_data, size_t tx_data_len,
185184
};
186185

187186
err = nrfx_spim_xfer(&spim, &xfer_desc, 0);
188-
if (err != NRFX_SUCCESS) {
189-
printk("nrfx_spim_xfer() failed: 0x%08x\n", err);
187+
if (err != 0) {
188+
printk("nrfx_spim_xfer() failed: %d\n", err);
190189
return false;
191190
}
192191

0 commit comments

Comments
 (0)