GCC Code Coverage Report


Directory: ./
File: firmware/hw_layer/board_overrides.h
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 60.0% 3 0 5
Functions: 100.0% 1 0 1
Branches: 50.0% 1 0 2
Decisions: 50.0% 1 - 2

Line Branch Decision Exec Source
1 /*
2 * @file board_overrides.h
3 * @brief Board-specific override mechanism
4 *
5 * This header provides a centralized way to define and manage board-specific overrides.
6 * Custom boards can implement their own specialized behavior by overriding these function pointers.
7 *
8 * Usage Example:
9 *
10 * 1. Define your custom function:
11 * void myBoardCustomHello() {
12 * // Your custom implementation
13 * }
14 *
15 * 2. Set up the override in your board_configuration.cpp:
16 * void setup_custom_board_overrides() {
17 * custom_board_boardSayHello = myBoardCustomHello;
18 * }
19 *
20 *
21 * @date: jul 09, 2025
22 * @author FDSoftware
23 */
24
25 #pragma once
26 #include <functional>
27 #include <optional>
28
29 // function with no parameters and returning void
30 using setup_custom_board_overrides_type = void (*)();
31
32 using setup_custom_board_ts_command_override_type = void (*)(uint16_t /*subsystem*/, uint16_t /*index*/);
33 extern std::optional<setup_custom_board_ts_command_override_type> custom_board_ts_command;
34
35 #if EFI_CAN_SUPPORT
36 #include "can_msg_tx.h"
37 using board_can_rx_type = void (*)(const size_t, const CANRxFrame &, efitick_t);
38 extern std::optional<board_can_rx_type> custom_board_can_rx;
39
40 using board_can_update_dash_type = void (*)(CanCycle cycle);
41 extern std::optional<board_can_update_dash_type> custom_board_update_dash;
42 #endif // EFI_CAN_SUPPORT
43
44 /**
45 * @brief Pre-HAL initialization override point
46 * Allows boards to perform custom initialization before HAL is initialized
47 */
48 extern std::optional<setup_custom_board_overrides_type> custom_board_preHalInit;
49
50 extern std::optional<setup_custom_board_overrides_type> custom_board_boardSayHello;
51
52 // Called before configuration is loaded
53 extern std::optional<setup_custom_board_overrides_type> custom_board_InitHardwareEarly;
54 extern std::optional<setup_custom_board_overrides_type> custom_board_InitHardware;
55 extern std::optional<setup_custom_board_overrides_type> custom_board_InitHardwareExtra;
56
57 // LTFT to VE table custom apply algo
58 extern std::optional<setup_custom_board_overrides_type> custom_board_LtftTrimToVeApply;
59
60 // specific firmware builds are meant for specific hardware. In order to provide best user experience on well-known boards sometimes we reduce user flexibility.
61 extern std::optional<setup_custom_board_overrides_type> custom_board_DefaultConfiguration;
62 extern std::optional<setup_custom_board_overrides_type> custom_board_ConfigOverrides;
63
64 /**
65 * This function checks if an override is present and calls it if available.
66 * Return true if override is present and was called
67 */
68 1167 static inline bool call_board_override(std::optional<setup_custom_board_overrides_type> board_override){
69
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1167 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 1167 times.
1167 if (board_override.has_value()) {
70 std::invoke(board_override.value());
71 return true;
72 }
73 1167 return false;
74 }
75