rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
chconf_common.h
Go to the documentation of this file.
1/*
2 * @file chconf_common.h
3 *
4 * @date Apr 20, 2019
5 * @author Andrey Belomutskiy, (c) 2012-2020
6 */
7
8/*
9 * __process_stack_size__ and __process_stack_size__ defaults are each hard-coded as 0x400 in ChibiOS rules.mk files
10 * rusEFI does not override these defaults.
11 *
12 * http://www.chibios.com/forum/viewtopic.php?t=309
13 * "__main_stack_size__ is the size of INTERRUPTS stack"
14 * "__process_stack_size__ is the stack of the C-runtime, in ChibiOS the "main" thread uses the C-runtime stack."
15 *
16 */
17
18#pragma once
19
20#define _CHIBIOS_RT_CONF_
21#define _CHIBIOS_RT_CONF_VER_7_0_
22
23#define PORT_IDLE_THREAD_STACK_SIZE 32
24
25// See global_shared.h notes about stack requirements
26// see also http://www.chibios.org/dokuwiki/doku.php?id=chibios:kb:stacks
27#define PORT_INT_REQUIRED_STACK 128
28
29#define CHPRINTF_USE_FLOAT TRUE
30
31#ifdef __cplusplus
32extern "C"
33{
34#endif /* __cplusplus */
35 #ifndef __ASSEMBLER__
36 void irqEnterHook(void);
37 void irqExitHook(void);
38 void contextSwitchHook(void);
39 void threadInitHook(void* tp);
40 void onLockHook(void);
41 void onUnlockHook(void);
42 #endif /* __ASSEMBLER__ */
43#ifdef __cplusplus
44}
45#endif /* __cplusplus */
46
47#define ON_LOCK_HOOK onLockHook()
48#define ON_UNLOCK_HOOK onUnlockHook()
49
50#if !defined(_FROM_ASM_)
51#ifdef __cplusplus
52extern "C" {
53#endif
54 void boardInit(void);
56 void setAdcChannelOverrides(void);
57#ifdef __cplusplus
58}
59#endif
60#endif /* _FROM_ASM_ */
61
62/*===========================================================================*/
63/**
64 * @name Kernel hooks
65 * @{
66 */
67/*===========================================================================*/
68
69/**
70 * @brief System structure extension.
71 * @details User fields added to the end of the @p ch_system_t structure.
72 */
73#define CH_CFG_SYSTEM_EXTRA_FIELDS \
74 /* Add threads custom fields here.*/
75
76/**
77 * @brief System initialization hook.
78 * @details User initialization code added to the @p chSysInit() function
79 * just before interrupts are enabled globally.
80 */
81#define CH_CFG_SYSTEM_INIT_HOOK() { \
82 /* Add system initialization code here.*/ \
83}
84
85/**
86 * @brief OS instance structure extension.
87 * @details User fields added to the end of the @p os_instance_t structure.
88 */
89#define CH_CFG_OS_INSTANCE_EXTRA_FIELDS \
90 /* Add OS instance custom fields here.*/
91
92/**
93 * @brief OS instance initialization hook.
94 *
95 * @param[in] oip pointer to the @p os_instance_t structure
96 */
97#define CH_CFG_OS_INSTANCE_INIT_HOOK(oip) { \
98 /* Add OS instance initialization code here.*/ \
99}
100
101/**
102 * @brief Threads descriptor structure extension.
103 * @details User fields added to the end of the @p thread_t structure.
104 */
105#define CH_CFG_THREAD_EXTRA_FIELDS \
106 void *activeStack; \
107 int remainingStack; \
108 unsigned char threadId; \
109 /* Add threads custom fields here.*/
110
111/**
112 * @brief Threads initialization hook.
113 * @details User initialization code added to the @p chThdInit() API.
114 *
115 * @note It is invoked from within @p chThdInit() and implicitly from all
116 * the threads creation APIs.
117 */
118#define CH_CFG_THREAD_INIT_HOOK(tp) { \
119 threadInitHook(tp); \
120}
121
122/**
123 * @brief Threads finalization hook.
124 * @details User finalization code added to the @p chThdExit() API.
125 *
126 * @param[in] tp pointer to the @p thread_t structure
127 */
128#define CH_CFG_THREAD_EXIT_HOOK(tp) { \
129 /* Add threads finalization code here.*/ \
130}
131
132/**
133 * @brief Context switch hook.
134 * @details This hook is invoked just before switching between threads.
135 *
136 * @param[in] ntp thread being switched in
137 * @param[in] otp thread being switched out
138 */
139#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
140 contextSwitchHook(); \
141}
142
143/**
144 * @brief ISR enter hook.
145 */
146#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
147 /* IRQ prologue code here.*/ \
148 irqEnterHook(); \
149}
150
151/**
152 * @brief ISR exit hook.
153 */
154#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
155 /* IRQ epilogue code here.*/ \
156 irqExitHook(); \
157}
158
159/**
160 * @brief Idle thread enter hook.
161 * @note This hook is invoked within a critical zone, no OS functions
162 * should be invoked from here.
163 * @note This macro can be used to activate a power saving mode.
164 */
165#define CH_CFG_IDLE_ENTER_HOOK() { \
166 /* Idle-enter code here.*/ \
167}
168
169/**
170 * @brief Idle thread leave hook.
171 * @note This hook is invoked within a critical zone, no OS functions
172 * should be invoked from here.
173 * @note This macro can be used to deactivate a power saving mode.
174 */
175#define CH_CFG_IDLE_LEAVE_HOOK() { \
176 /* Idle-leave code here.*/ \
177}
178
179/**
180 * @brief Idle Loop hook.
181 * @details This hook is continuously invoked by the idle thread loop.
182 */
183#define CH_CFG_IDLE_LOOP_HOOK() { \
184 /* Idle loop code here.*/ \
185}
186
187/**
188 * @brief System tick event hook.
189 * @details This hook is invoked in the system tick handler immediately
190 * after processing the virtual timers queue.
191 */
192#define CH_CFG_SYSTEM_TICK_HOOK() { \
193 /* System tick event code here.*/ \
194}
195
196/**
197 * @brief System halt hook.
198 * @details This hook is invoked in case to a system halting error before
199 * the system is halted.
200 */
201#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
202 /* System halt code here.*/ \
203 chDbgPanic3(reason, __FILE__, __LINE__); \
204}
205
206/**
207 * @brief Trace hook.
208 * @details This hook is invoked each time a new record is written in the
209 * trace buffer.
210 */
211#define CH_CFG_TRACE_HOOK(tep) { \
212 /* Trace code here.*/ \
213}
214
215/**
216 * @brief Runtime Faults Collection Unit hook.
217 * @details This hook is invoked each time new faults are collected and stored.
218 */
219#define CH_CFG_RUNTIME_FAULTS_HOOK(mask) { \
220 /* Faults handling code here.*/ \
221}
222
223/** @} */
224
225/**
226 * declared as a macro so that this code does not use stack
227 * so that it would not crash the error handler in case of stack issues
228 */
229#if CH_DBG_SYSTEM_STATE_CHECK
230#define hasOsPanicError() (ch.dbg.panic_msg != NULL)
231#else
232#define hasOsPanicError() (FALSE)
233#endif
234
235#ifndef __ASSEMBLER__
236 #ifdef __cplusplus
237 extern "C"
238 #endif // __cplusplus
239 void chDbgPanic3(const char *msg, const char * file, int line);
240#endif // __ASSEMBLER__
void onUnlockHook(void)
void irqEnterHook(void)
void threadInitHook(void *tp)
void boardInit(void)
Board-specific initialization code.
Definition board.c:31
void contextSwitchHook(void)
void onLockHook(void)
void irqExitHook(void)
C void chDbgPanic3(const char *msg, const char *file, int line)
void setPinConfigurationOverrides(void)
void setAdcChannelOverrides(void)