|
|
@ -13,6 +13,8 @@ class Device
|
|
|
|
|
|
|
|
|
|
|
|
void doSomething();
|
|
|
|
void doSomething();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void status();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -71,8 +73,39 @@ class Device
|
|
|
|
void operator = (uint8_t v) {raw = v;}
|
|
|
|
void operator = (uint8_t v) {raw = v;}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
union Reg_MotorStatus
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
struct POWER{
|
|
|
|
|
|
|
|
typedef BitField<uint8_t,0,1> Bits;
|
|
|
|
|
|
|
|
enum{OFF = 0, ON = 1};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct STATUS{
|
|
|
|
|
|
|
|
typedef BitField<uint8_t, 2,3>Bits;
|
|
|
|
|
|
|
|
enum{STANDSTILL = 0,
|
|
|
|
|
|
|
|
ACCELERATING_CW = 1,
|
|
|
|
|
|
|
|
DEACCELERATING_CW = 2,
|
|
|
|
|
|
|
|
ACCELERATING_CCW = 3,
|
|
|
|
|
|
|
|
DEACCELERATING_CCW = 4,
|
|
|
|
|
|
|
|
CONSTANT_SPEED = 5,
|
|
|
|
|
|
|
|
BLOCKED = 6};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
union Bits
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// is set const because it only used for status indication
|
|
|
|
|
|
|
|
const Reg_MotorStatus::POWER::Bits POWER;
|
|
|
|
|
|
|
|
const Reg_MotorStatus::STATUS::Bits STATUS;
|
|
|
|
|
|
|
|
}bits;
|
|
|
|
|
|
|
|
uint8_t raw;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Reg_MotorStatus(uint8_t v = 0x00) : raw(v) {}
|
|
|
|
|
|
|
|
operator uint8_t() {return raw;}
|
|
|
|
|
|
|
|
void operator = (uint8_t v) {raw = v;}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Reg_Control reg_control;
|
|
|
|
Reg_Control reg_control;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Reg_MotorStatus reg_motorStatus;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|