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.
70 lines
1.6 KiB
70 lines
1.6 KiB
#ifndef _DEVICE_HPP_
|
|
#define _DEVICE_HPP_
|
|
|
|
#include"../BitField.hpp"
|
|
|
|
#include <iostream>
|
|
#include <stdint.h>
|
|
|
|
class Device
|
|
{
|
|
public:
|
|
Device();
|
|
|
|
void doSomething();
|
|
|
|
private:
|
|
|
|
//
|
|
// Register declarations
|
|
//
|
|
#ifdef EXAMPLE_CODE_FOR_REFERENCE
|
|
union Control {
|
|
struct OPM{
|
|
typedef Bits<uint16_t, 10, 2> bits;
|
|
enum { NO_CHANGE = 0, AS_STANDBY = 1};
|
|
};
|
|
struct CTRL_BR{
|
|
enum { NO_CHANGE = 0, BRANCH_NORMAL = 1};
|
|
};
|
|
struct CTRL_BR1 : CTRL_BR{
|
|
typedef Bits<uint16_t, 8, 2> bits;
|
|
};
|
|
struct CTRL_BR2 : CTRL_BR{
|
|
typedef Bits<uint16_t, 6, 2> bits;
|
|
};
|
|
|
|
union Bits {
|
|
Control::OPM::bits OPM;
|
|
Control::CTRL_BR1::bits CTRL_BR1;
|
|
Control::CTRL_BR2::bits CTRL_BR2;
|
|
} bits;
|
|
uint16_t raw;
|
|
};
|
|
#endif
|
|
union Reg_Control
|
|
{
|
|
// bit 7
|
|
struct POWER_DEV{
|
|
typedef Bits<uint8_t, 7, 1> bits;
|
|
enum{TURN_OFF = 0, TURN_ON = 1};
|
|
};
|
|
// bits 2-3
|
|
struct SPEED{
|
|
typedef Bits<uint8_t, 2, 2> bits;
|
|
enum{STAND_STILL = 0,
|
|
SLOW = 1,
|
|
NORMAL = 2,
|
|
FAST = 3};
|
|
};
|
|
union Bits{
|
|
Reg_Control::POWER_DEV::bits POWER_DEV;
|
|
Reg_Control::SPEED::bits SPEED;
|
|
} bits;
|
|
uint8_t raw;
|
|
};
|
|
|
|
};
|
|
|
|
#endif // _DEVICE_HPP_
|