Hi!
I was controling a little vibration motor with a mosfet which is activated by a nrf52840Dongle pin. I was using pin 0.17 and it worked pretty well, but now I am trying to use another pin because of development reasons and I am not able to make it work with the same configuration. I am using the pins the dongle uses for the leds activation in order to simplify the work in the devicetree document. When I was using pin 0.17 I had the next configuration:
In the devicetree:
As you can see I have 0.17 enable as the led_0. In the code
/*GPIO vibration declarations*/ const struct device *gpio_dev;
In the main:
/*GPIO Vibration code*/ gpio_dev = device_get_binding(DT_LABEL(DT_NODELABEL(gpio0))); gpio_pin_configure(gpio_dev, 17, GPIO_OUTPUT | GPIO_OUTPUT_INIT_LOW | GPIO_PULL_UP);
And the function that uses the pin
void gpio_set_on(struct k_timer *timer) { gpio_pin_set_raw(gpio_dev, 17, 1); k_timer_start(timer, K_SECONDS(1), K_NO_WAIT); }
Up to this point it works well. Now I try to change the pin to 1.15 (port 1 pin 15) and I jus modified a couple of parameters
In the devicetree
In the code
/*GPIO vibration declarations*/ const struct device *gpio_dev;
In the main
/*GPIO Vibration code*/ gpio_dev = device_get_binding(DT_LABEL(DT_NODELABEL(gpio1))); gpio_pin_configure(gpio_dev, 15, GPIO_OUTPUT | GPIO_OUTPUT_INIT_LOW | GPIO_PULL_UP);
And the function which uses the pin with a timer
void gpio_set_on(struct k_timer *timer) { gpio_pin_set_raw(gpio_dev, 15, 1); k_timer_start(timer, K_SECONDS(1), K_NO_WAIT); }