Tutorial: Building a Mainloop Application (Step 3)

Define the Hardware Platform

The hardware for our application needs to provide two digital outputs (that drive the LEDs) and a communication interface (typically a UART interface on the real hardware for logging and entering the LED switching commands). The communication interface is already prepared in the project template (because we chose the project type MainloopProject during creation). Thus we only need to introduce two digital outputs in our redBlocks Hardware Abstraction Layer definition. See the Hello World example tutorial for details on this task.

This is what needs to be added to project/sim/LowLevelPlatform.h (the code snippets can be generated from within the redBlocks Simulator):

template< unsigned int T = 0 >
class TLowLevelPlatform
{
  public:

    //...
    typedef redBlocks::HAL::Drivers::TDigitalOutputDriverStub<0> Led;
    typedef redBlocks::HAL::Drivers::TDigitalOutputDriverStub<1> AwakeLed;

    static void initLowLevelDrivers()
    {
      // ...

      SimulationStubs::DigitalOutput::add<Led>(false);
      SimulationStubs::DigitalOutput::add<AwakeLed>(false);
    }
};

There is no need to add any high level driver functionality to Platform.h