I want to interface 3 custom made heater boards to nrf5340dk. Where the simple task is to toggle gpio's to Turn ON & OFF the heater board.
Now, we are using P 0.01, 0.02 & 0.03 pins to control the heater board.
But, as I see these pins are mapped to P0.00, 0.01 - XL1 & XL2 and P0.02, 0.03 - NFC1 and NFC2 respectively. May I know how can I configure them to work as simple GPIOS so that I can toggle them.
Went through some of the references and did the below steps but not working.
In prj.conf
CONFIG_GPIO=y
CONFIG_CLOCK_CONTROL=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=n
CONFIG_SOC_ENABLE_LFXO=n
CONFIG_NFCT_PINS_AS_GPIOS=y
Testing node created.
Accessing the nodes in main.c
Testing node created.
/{
keys {
compatible = "gpio-keys";
key_0: key0 {
gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>;
};
key_1: key1 {
gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
};
key_2: key2 {
gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>;
};
};
};
Accessing the nodes in main.c
static const struct gpio_dt_spec key0 = GPIO_DT_SPEC_GET(DT_NODELABEL(key_0), gpios);
static const struct gpio_dt_spec key1 = GPIO_DT_SPEC_GET(DT_NODELABEL(key_1), gpios);
static const struct gpio_dt_spec key2 = GPIO_DT_SPEC_GET(DT_NODELABEL(key_2), gpios);
int main(void)
{
// spec_interface.Init();
int err;
if(!gpio_is_ready_dt(&key0))
{
LOG_ERR("Key0 GPIO is not ready");
return -ENODEV;
}
if(!gpio_is_ready_dt(&key1))
{
LOG_ERR("Key1 GPIO is not ready");
return -ENODEV;
}
if(!gpio_is_ready_dt(&key2))
{
LOG_ERR("Key2 GPIO is not ready");
return -ENODEV;
}
err = gpio_pin_configure_dt(&key0, GPIO_OUTPUT_ACTIVE);
err = gpio_pin_configure_dt(&key1, GPIO_OUTPUT_ACTIVE);
err = gpio_pin_configure_dt(&key2, GPIO_OUTPUT_ACTIVE);
while(1)
{
gpio_pin_toggle_dt(&key0);
k_msleep(SLEEP_TIME_MS);
gpio_pin_toggle_dt(&key1);
k_msleep(SLEEP_TIME_MS);
gpio_pin_toggle_dt(&key2);
}
return 0;
}