Bitstream Interpretation Library (BIL)  0.1
V5CMDRegister.cpp
Go to the documentation of this file.
1 
10 
11 using namespace bil;
12 
13 
15  Register(V5RegisterAddress::CMD, V5RegisterAddress::CMD_STRING, true, true),
16  m_command(V5CommandCode::NULLCMD),
17  m_crcReg(crcReg)
18 {
19 
20 }
21 
22 
23 void V5CMDRegister::write(const boost::uint32_t* words, size_t wordCount)
24 {
25  Register::write(words, wordCount);
26 
27  // word count has to be 1
28  if (1 != wordCount) throw Exception();
29  // set command and execute
30  commandCode(*words);
31  execute();
32 }
33 
34 
35 void V5CMDRegister::read(boost::uint32_t* words, size_t wordCount) const
36 {
37  Register::read(words, wordCount);
38 
39  // word count has to be 1
40  if (1 != wordCount) throw Exception();
41  // return current command code
42  *words = m_command;
43 }
44 
45 
47 {
48  // ensure that only valid command codes are loaded into register
49  switch (code) {
52  case V5CommandCode::MFW:
66  case V5CommandCode::LTIMER: m_command = code; break;
67  default: throw Exception();
68  }
69 }
70 
71 
73 {
74  return m_command;
75 }
76 
77 
79 {
80  // only implemented command code at the moment is RCRC
81  if (V5CommandCode::RCRC == m_command) m_crcReg.reset();
82 }
83 
84 
86 {
87  return m_crcReg;
88 }