parent
c5b38d4c24
commit
12ab5b6cbe
@ -0,0 +1,14 @@
|
|||||||
|
#include "device.hpp"
|
||||||
|
|
||||||
|
Device::Device()
|
||||||
|
{
|
||||||
|
Reg_Control.POWER_DEV = Reg_Control::POWER_DEV::TURN_OFF;
|
||||||
|
Reg_Control.SPEED = Reg_Control::SPEED::STAND_STILL;
|
||||||
|
|
||||||
|
std::cout << Reg_Control.raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Device::doSomething()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
#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_
|
Loading…
Reference in new issue