Advertisement
Guest User

main.c snippet

a guest
Jun 3rd, 2021
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.08 KB | None | 0 0
  1. //-------------------------------------------------- Zephyr Defintions ------------------------------------------
  2. # include <zephyr.h>
  3. # include <device.h>
  4. # include <devicetree.h>
  5. # include <drivers/pwm.h>   // Include the PWM Driver
  6. # include <drivers/gpio.h>  // Incldue the GPIO Driver
  7.  
  8. #define ON_OFF_MOTOR1 DT_ALIAS(bimotor1)
  9.  
  10. #if !DT_NODE_HAS_STATUS(ON_OFF_MOTOR1, okay)
  11. /* A build error here means your board isn't set up to blink an LED. */
  12. #error "Unsupported board: motor1 devicetree alias is not defined"
  13. #endif
  14.  
  15. static const struct gpio_dt_spec on_off_motor1 = GPIO_DT_SPEC_GET_OR(ON_OFF_MOTOR1, gpios, {0});
  16.  
  17. // Configure ON-OFF Motor Pin as Output
  18. if(on_off_motor1.port){
  19.     return_variable = gpio_pin_configure_dt(&on_off_motor1, GPIO_OUPUT);
  20.     if(return_variable != 0) {
  21.         printk("Error %d: failed to configure LED device %s pin %d\n",
  22.                 return_variable, on_off_motor1.port->name, on_off_motor1.pin);
  23.         led.port = NULL;}
  24.     else {
  25.         printk("Set up Motor PIN at %s pin %d\n", on_off_motor1.port->name, on_off_motor1.pin);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement