blmc/blmc.h

41 lines
801 B
C

#ifndef _BLMC_H_
#define _BLMC_H_
#define FLAG_RUN_MASK 0x00F
#define FLAG_PWM_SPINUP 0x001
#define FLAG_PWM_NORMAL 0x002
#define FLAG_COM_SPINUP 0x004
#define FLAG_COM_NORMAL 0x008
#define FLAG_SOFTERR_MASK 0x0F0
#define FLAG_CURRENT_LIMIT 0x010
#define FLAG_I2C_TIMEOUT 0x020
#define FLAG_HARDERR_MASK 0xF00
#define FLAG_UNDERVOLTAGE 0x100
#define FLAG_OVERCURRENT 0x200
#define FLAG_SELFTEST_FAILED 0x400
#define FLAG_INVALID_EEPROM 0x800
#define FLAG_I2C_ACTIVE 0x1000
struct blmc_ {
uint16_t flags;
uint8_t pwm; // pwm setpoint
uint8_t pwm_limit; // increased by current-limit
uint16_t rpm;
uint16_t rpm_tmp;
uint16_t rpm_tmp_old;
uint16_t current;
uint16_t voltage;
};
void trigger_adc(uint8_t channel);
void setpwm(uint8_t pwm);
void spinup(void);
#endif