121. Mandatory Build-Time Timebase Selection

You are implementing firmware for a system that depends on a hardware timebase.

Exactly one timebase must be selected at build time.
Runtime selection is architecturally forbidden.

Your task is to complete the program so that:

  • The timebase is selected only at compile time
  • The program cannot build unless a valid timebase type is chosen
  • No runtime configuration, branching, or fallback is possible
  • This must be enforced using the C++ type system, not comments or conventions

 

Input / Program Flow:

The firmware performs the following steps:

  1. Reads a tick counter from a hardware timebase
  2. Converts ticks to milliseconds
  3. Prints the elapsed time

Two valid timebases exist:

  • SysTickTimer
    • Frequency: 1 kHz
    • Tick count: 100
  • RtcTimer
    • Frequency: 32 Hz
    • Tick count: 4

Only one timebase is ever used in a firmware build.

 

Output:

The program must print exactly:

elapsed_ms=100 

Note:
This output corresponds to selecting SysTickTimer.
Validation of RtcTimer is performed by recompiling the program with a different compile-time selection.

 

Constraints:

  • No virtual functions
  • No inheritance used for polymorphism
  • No runtime conditionals (if, switch)
  • No heap allocation
  • No STL containers
  • No macros for selection
  • Timebase selection must be enforced at compile time
  • Program must fail to build if selection is missing

 

 

 

Loading...

Input

Expected Output

elapsed_ms=100