Hi everyone,
I am trying to use P0.0 but it keeps getting uninitialized when calling nrfx_spim_uninit.
nrfx_spim.c line 659 keeps uninitializing P0.0
#if NRFY_SPIM_HAS_DCX
spim_pin_uninit(ext_pins.dcx_pin);
#endif
It is because in nrf_spim.h line 1431 does not change the value of PSELDCX:
#else
p_reg->PSELDCX = dcx_pin;
#endif
Is there a way to change NRFY_SPIM_HAS_DCX without modifying the library?
I do not need DCX in my application.
This code on the nRF52840DK will reproduce the bug:
#include <zephyr/kernel.h>
#include <nrfx_spim.h>
#include <hal/nrf_gpio.h>
static nrfx_spim_t spim_inst = NRFX_SPIM_INSTANCE(NRF_SPIM0);
static nrfx_spim_config_t config = NRFX_SPIM_DEFAULT_CONFIG(28, 29, 30, 31);
static uint32_t pin_num = 0;
static void spim_example()
{
nrf_gpio_cfg_output(pin_num);
printk("pin dir before: %x\n", nrf_gpio_pin_dir_get(pin_num));
nrfx_spim_init(&spim_inst, &config, NULL, NULL);
nrfx_spim_uninit(&spim_inst);
printk("pin dir after: %x\n", nrf_gpio_pin_dir_get(pin_num));
}
static void register_example()
{
printk("PSELDCX before: %x\n", spim_inst.p_reg->PSELDCX);
spim_inst.p_reg->PSELDCX = 0xAAAAAAAA;
printk("PSELDCX after: %x\n", spim_inst.p_reg->PSELDCX);
}
int main(void)
{
spim_example();
register_example();
return 0;
}
output:
*** Booting nRF Connect SDK v3.3.0-ba167d9f3db4 *** *** Using Zephyr OS v4.3.99-fd9204a02d52 *** config.dcx_pin: ffffffff pin dir before: 1 pin dir after: 0 PSELDCX before: 0 PSELDCX after: 0
