title: Using low level datatype from hardware abstraction layer in (high level) application
body: <p>I have a hardware abstraction layer for a peripheral of a MCU which is written in C. The application code is using the peripheral via a C++ wrapper. Now I have a low level enum <code>ll_enum</code> and a function, that requires a parameter with this datatype.</p>
  
  <p>My understanding of a good architecture would imply the following things:</p>
  
  <ul>
  <li>Low-level peripheral driver (C) 
  
  <ul>
  <li>should not know that there is a higher level</li>
  <li>has the definition of the enum</li>
  </ul></li>
  <li>C++ Wrapper
  
  <ul>
  <li>obviously knows the low-level layer and that there is an application</li>
  </ul></li>
  <li>Application Code that uses the C++ Wrapper 
  
  <ul>
  <li>Just knows the C++ Wrapper</li>
  </ul></li>
  </ul>
  
  <p>My solution right now:</p>
  
  <p>I have a enum in the C++ Wrapper that has the same entries as the low level enum. The enum gets casted to the low level type in the C++ Wrapper.</p>
  
  <pre><code>// ### C++ Wrapper ###
  enum hl_enum {
      foo = 1,
      bar = 2,
  }
  
  void Peripheral::hl_function(hl_enum param) {
      ll_function((ll_enum)param);
  }
  
  // ### Low level C-file ###
  typedef enum {
      foo = 1,
      bar = 2,
  } ll_enum;
  
  void ll_function(ll_enum param);
  </code></pre>
  
  <p>Obviously that is a bad solution, because you have to change code at two positions and get in trouble if you missed that. </p>
  
  <p>Is there a better solution?</p>