Skip to content

Commit 1092d84

Browse files
committed
[nrf fromlist] samples: boards: nordic: nrfx: Align to the new GPPI API
Align use of GPPI API. Upstream PR #: 98327 Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent f9d441d commit 1092d84

File tree

1 file changed

+10
-12
lines changed
  • samples/boards/nordic/nrfx/src

1 file changed

+10
-12
lines changed

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ int main(void)
3737
LOG_INF("nrfx_gpiote sample on %s", CONFIG_BOARD);
3838

3939
nrfx_err_t err;
40+
int rv;
4041
uint8_t in_channel, out_channel;
41-
uint8_t ppi_channel;
42+
nrfx_gppi_handle_t ppi_handle;
4243
const nrfx_gpiote_t gpiote = NRFX_GPIOTE_INSTANCE(GPIOTE_INST);
4344

4445
/* Connect GPIOTE instance IRQ to irq handler */
@@ -116,23 +117,20 @@ int main(void)
116117

117118
LOG_INF("nrfx_gpiote initialized");
118119

119-
/* Allocate a (D)PPI channel. */
120-
err = nrfx_gppi_channel_alloc(&ppi_channel);
121-
if (err != NRFX_SUCCESS) {
122-
LOG_ERR("nrfx_gppi_channel_alloc error: 0x%08X", err);
123-
return 0;
124-
}
125-
126120
/* Configure endpoints of the channel so that the input pin event is
127121
* connected with the output pin OUT task. This means that each time
128122
* the button is pressed, the LED pin will be toggled.
129123
*/
130-
nrfx_gppi_channel_endpoints_setup(ppi_channel,
131-
nrfx_gpiote_in_event_address_get(&gpiote, INPUT_PIN),
132-
nrfx_gpiote_out_task_address_get(&gpiote, OUTPUT_PIN));
124+
rv = nrfx_gppi_conn_alloc(nrfx_gpiote_in_event_address_get(&gpiote, INPUT_PIN),
125+
nrfx_gpiote_out_task_address_get(&gpiote, OUTPUT_PIN),
126+
&ppi_handle);
127+
if (rv < 0) {
128+
LOG_ERR("nrfx_gppi_conn_alloc error: 0x%08X", rv);
129+
return 0;
130+
}
133131

134132
/* Enable the channel. */
135-
nrfx_gppi_channels_enable(BIT(ppi_channel));
133+
nrfx_gppi_conn_enable(ppi_handle);
136134

137135
LOG_INF("(D)PPI configured, leaving main()");
138136
return 0;

0 commit comments

Comments
 (0)