Sound Byte Libs 1ee2ca6
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
timer_requirements.hpp
Go to the documentation of this file.
1/**
2 * @file timer_requirements.hpp
3 * @brief Timer driver requirements validator
4 * @ingroup validation
5 *
6 * Validates that Timer drivers provide required functionality using the
7 * method detection system.
8 *
9 * ## Timer Driver Contract
10 *
11 * Every Sound Byte Libs Timer driver MUST implement these methods:
12 * - `delay_ms(uint32_t)` - Blocking millisecond delay
13 * - `millis() -> uint32_t` - Milliseconds since boot
14 *
15 * ## Validation Usage
16 *
17 * Add validation at the bottom of driver timer.hpp:
18 * ```cpp
19 * #include <sbl/validation/timer_requirements.hpp>
20 * static_assert(sbl::validation::timer_driver_valid<sbl::driver::Timer>,
21 * "Timer driver missing required methods");
22 * ```
23 *
24 * @see method_detection.hpp
25 */
26
27#ifndef SBL_VALIDATION_TIMER_REQUIREMENTS_HPP_
28#define SBL_VALIDATION_TIMER_REQUIREMENTS_HPP_
29
30#include "method_detection.hpp"
31
32namespace sbl {
33namespace validation {
34
35/**
36 * @brief Timer driver requirements validator
37 *
38 * Validates that Timer drivers provide required methods.
39 */
40template<typename TimerDriver>
42public:
43 /**
44 * @brief Validate all required Timer methods
45 */
46 static constexpr bool validate() {
48 "SBL ERROR: Timer driver missing delay_ms() method.\n"
49 "Required: static void delay_ms(uint32_t)");
50
52 "SBL ERROR: Timer driver missing millis() method.\n"
53 "Required: static uint32_t millis()");
54
55 return true;
56 }
57};
58
59/**
60 * @brief Helper to validate a Timer driver implementation
61 *
62 * Usage:
63 * ```cpp
64 * static_assert(sbl::validation::timer_driver_valid<MyTimerDriver>,
65 * "Timer driver incomplete");
66 * ```
67 */
68template<typename TimerDriver>
70
71} // namespace validation
72} // namespace sbl
73
74#endif // SBL_VALIDATION_TIMER_REQUIREMENTS_HPP_
Timer driver requirements validator.
static constexpr bool validate()
Validate all required Timer methods.
Method and interface detection for driver validation.
constexpr bool timer_driver_valid
Helper to validate a Timer driver implementation.
Root namespace for all Sound Byte Libs functionality.
Definition aliases.hpp:24
Timer Driver Method Detection.