rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
board_overrides.h
Go to the documentation of this file.
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
31
32#if EFI_CAN_SUPPORT
33#include "can_msg_tx.h"
34using board_can_rx_type = void (*)(const size_t, const CANRxFrame &, efitick_t);
35extern std::optional<board_can_rx_type> custom_board_can_rx;
36
37using board_can_update_dash_type = void (*)(CanCycle cycle);
38extern std::optional<board_can_update_dash_type> custom_board_update_dash;
39#endif // EFI_CAN_SUPPORT
40
41/**
42 * @brief Pre-HAL initialization override point
43 * Allows boards to perform custom initialization before HAL is initialized
44 */
45extern std::optional<setup_custom_board_overrides_type> custom_board_preHalInit;
46
47extern std::optional<setup_custom_board_overrides_type> custom_board_boardSayHello;
48
49// Called before configuration is loaded
50extern std::optional<setup_custom_board_overrides_type> custom_board_InitHardwareEarly;
51extern std::optional<setup_custom_board_overrides_type> custom_board_InitHardware;
52extern std::optional<setup_custom_board_overrides_type> custom_board_InitHardwareExtra;
53
54// LTFT to VE table custom apply algo
55extern std::optional<setup_custom_board_overrides_type> custom_board_LtftTrimToVeApply;
56
57// specific firmware builds are meant for specific hardware. In order to provide best user experience on well-known boards sometimes we reduce user flexibility.
58extern std::optional<setup_custom_board_overrides_type> custom_board_DefaultConfiguration;
59extern std::optional<setup_custom_board_overrides_type> custom_board_ConfigOverrides;
60
61/**
62 * This function checks if an override is present and calls it if available.
63 * Return true if override is present and was called
64 */
65static inline bool call_board_override(std::optional<setup_custom_board_overrides_type> board_override){
66 if (board_override.has_value()) {
67 std::invoke(board_override.value());
68 return true;
69 }
70 return false;
71}
std::optional< board_can_rx_type > custom_board_can_rx
Definition can_rx.cpp:201
void(*)(const size_t, const CANRxFrame &, efitick_t) board_can_rx_type
std::optional< board_can_update_dash_type > custom_board_update_dash
Definition can_dash.cpp:612
std::optional< setup_custom_board_overrides_type > custom_board_InitHardware
Definition hardware.cpp:77
std::optional< setup_custom_board_overrides_type > custom_board_ConfigOverrides
void(*)() setup_custom_board_overrides_type
std::optional< setup_custom_board_overrides_type > custom_board_boardSayHello
void(*)(CanCycle cycle) board_can_update_dash_type
std::optional< setup_custom_board_overrides_type > custom_board_preHalInit
Pre-HAL initialization override point Allows boards to perform custom initialization before HAL is in...
Definition main.cpp:22
std::optional< setup_custom_board_overrides_type > custom_board_LtftTrimToVeApply
std::optional< setup_custom_board_overrides_type > custom_board_DefaultConfiguration
static bool call_board_override(std::optional< setup_custom_board_overrides_type > board_override)
std::optional< setup_custom_board_overrides_type > custom_board_InitHardwareExtra
Definition hardware.cpp:78
std::optional< setup_custom_board_overrides_type > custom_board_InitHardwareEarly
Definition hardware.cpp:76
Definition can.h:83