blmc/blmc.h

58 lines
1.2 KiB
C
Raw Normal View History

2007-09-20 22:54:11 +02:00
#ifndef _BLMC_H_
#define _BLMC_H_
#include <avr/io.h>
#define PHASE_A_H (1<<PORTB1)
#define PHASE_B_H (1<<PORTB2)
#define PHASE_C_H (1<<PORTB3)
#define PHASE_H_MASK (PHASE_A_H | PHASE_B_H | PHASE_C_H)
#define PHASE_A_L (1<<PORTD4)
#define PHASE_B_L (1<<PORTD3)
#define PHASE_C_L (1<<PORTD2)
#define PHASE_L_MASK (PHASE_A_L | PHASE_B_L | PHASE_C_L)
#define SENSE_A 0
#define SENSE_B 1
#define SENSE_C 2
#define SENSE_VOLTAGE 3
#define SENSE_CURRENT 6
2008-02-17 18:17:28 +01:00
#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
2007-09-20 22:54:11 +02:00
2008-02-17 18:17:28 +01:00
#define FLAG_SOFTERR_MASK 0x0F0
#define FLAG_CURRENTLIMIT 0x010
#define FLAG_I2CTIMEOUT 0x020
#define FLAG_HARDERR_MASK 0xF00
#define FLAG_UNDERVOLTAGE 0x100
#define FLAG_OVERCURRENT 0x200
#define FLAG_SELFTESTFAILED 0x400
2008-02-19 14:52:02 +01:00
#define FLAG_INVALIDEEPROM 0x800
2007-09-20 22:54:11 +02:00
struct blmc_ {
2008-02-17 18:17:28 +01:00
uint16_t flags;
2007-09-20 22:54:11 +02:00
uint8_t pwm; // pwm setpoint
uint8_t pwm_limit; // increased by current-limit
uint16_t rpm;
uint16_t rpm_tmp;
2008-02-17 18:17:28 +01:00
uint16_t rpm_tmp_old;
2007-09-20 22:54:11 +02:00
uint16_t current;
uint16_t voltage;
};
void trigger_adc(uint8_t channel);
void setpwm(uint8_t pwm);
void spinup(void);
#endif