AVR based brushless motor controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
801 B

  1. #ifndef _BLMC_H_
  2. #define _BLMC_H_
  3. #define FLAG_RUN_MASK 0x00F
  4. #define FLAG_PWM_SPINUP 0x001
  5. #define FLAG_PWM_NORMAL 0x002
  6. #define FLAG_COM_SPINUP 0x004
  7. #define FLAG_COM_NORMAL 0x008
  8. #define FLAG_SOFTERR_MASK 0x0F0
  9. #define FLAG_CURRENT_LIMIT 0x010
  10. #define FLAG_I2C_TIMEOUT 0x020
  11. #define FLAG_HARDERR_MASK 0xF00
  12. #define FLAG_UNDERVOLTAGE 0x100
  13. #define FLAG_OVERCURRENT 0x200
  14. #define FLAG_SELFTEST_FAILED 0x400
  15. #define FLAG_INVALID_EEPROM 0x800
  16. #define FLAG_I2C_ACTIVE 0x1000
  17. struct blmc_ {
  18. uint16_t flags;
  19. uint8_t pwm; // pwm setpoint
  20. uint8_t pwm_limit; // increased by current-limit
  21. uint16_t rpm;
  22. uint16_t rpm_tmp;
  23. uint16_t rpm_tmp_old;
  24. uint16_t current;
  25. uint16_t voltage;
  26. };
  27. void trigger_adc(uint8_t channel);
  28. void setpwm(uint8_t pwm);
  29. void spinup(void);
  30. #endif