Skip to content

Commit 476fcfc

Browse files
committed
merge: 同步 develop 分支的配置完善和 GNU 扩展检查
- 重命名 fc_config_template.h 为 fc_config.h - 完善配置文件的 Configuration Wizard 支持 - 添加 GNU 扩展编译检查 - 优化 PDSC 文件结构 - 删除 Common 组件,所有组件自动包含配置文件
2 parents 1f45ee8 + dd248b4 commit 476fcfc

File tree

4 files changed

+317
-27
lines changed

4 files changed

+317
-27
lines changed

core/fc_compiler.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,26 @@
2424

2525
// clang-format off
2626

27+
//+********************************* GNU Extension Check **********************************/
28+
/**
29+
* @brief Check if GNU extensions are enabled
30+
* @note fc_embed requires GNU extensions for __attribute__, typeof, etc.
31+
*
32+
* For ARM Compiler 5 (AC5):
33+
* Project Options -> C/C++ -> Check "Use MicroLIB" or enable GNU extensions
34+
*
35+
* For ARM Compiler 6 (AC6):
36+
* Project Options -> C/C++ -> Language C -> Select GNU dialect (e.g., gnu11, gnu99)
37+
*
38+
* For GCC/Clang:
39+
* GNU extensions are enabled by default
40+
*/
41+
#if defined(__ARMCC_VERSION)
42+
#if !defined(__GNUC__)
43+
#error "fc_embed requires GNU extensions! Please enable GNU dialect in Keil Project Options -> C/C++ settings."
44+
#endif
45+
#endif
46+
2747
#if defined(__ARMCC_VERSION) /* ARM Compiler */
2848
#define fc_section(x) __attribute__((section(x)))
2949
#define fc_used __attribute__((used))

core/fc_config.h

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
// <<< Use Configuration Wizard in Context Menu >>>
2+
3+
/**
4+
* @file fc_config.h
5+
* @author fool_cat (2696652257@qq.com)
6+
* @brief fc_embed配置头文件 - 所有可配置项的集中管理
7+
* @version 1.0
8+
* @date 2025-09-02
9+
*
10+
* @note 在 Keil MDK 中,点击此文件底部的 "Configuration Wizard" 标签
11+
* 可以通过图形界面配置所有选项
12+
*
13+
* @copyright Copyright (c) 2025
14+
*/
15+
16+
#ifndef _FC_CONFIG_H_
17+
#define _FC_CONFIG_H_
18+
19+
/**
20+
* =====================================================================
21+
* Custom Header Files Section
22+
* =====================================================================
23+
* Add your custom #include statements here if needed.
24+
*
25+
* Examples:
26+
* #include "stm32f4xx_hal.h"
27+
* #include "FreeRTOS.h"
28+
* #include "cmsis_os.h"
29+
*
30+
* Note: Configuration Wizard does not support dynamic header inclusion.
31+
* Please manually edit this section to add your headers.
32+
* =====================================================================
33+
*/
34+
35+
// Add your custom includes below:
36+
// #include "your_header.h"
37+
38+
39+
// <h> Auto Init Configuration
40+
// <i> Auto initialization framework configuration
41+
42+
// <q> USE_FC_AUTO_INIT - Enable Auto Initialization
43+
// <i> Enable auto-initialization before main() function
44+
// <i> Default: 1 (Enabled)
45+
#define USE_FC_AUTO_INIT 1
46+
47+
// </h>
48+
49+
// <h> Logger Configuration
50+
// <i> Logger component configuration
51+
52+
// <q> FC_LOG_ENABLE - Enable Logger
53+
// <i> Enable logging functionality
54+
// <i> Default: 1 (Enabled)
55+
#define FC_LOG_ENABLE 1
56+
57+
// <o> FC_LOG_LINE_SIZE - Log Line Buffer Size <32-512:8>
58+
// <i> Log line buffer size in bytes
59+
// <i> Default: 128
60+
#define FC_LOG_LINE_SIZE 128
61+
62+
// <o> FC_LOG_STACK_LINE_SIZE - Log Stack Line Size <32-512:8>
63+
// <i> Log buffer size on stack in bytes
64+
// <i> Default: FC_LOG_LINE_SIZE
65+
#define FC_LOG_STACK_LINE_SIZE (FC_LOG_LINE_SIZE)
66+
67+
// <q> FC_LOG_USING_COLOR - Enable Color Output
68+
// <i> Enable ANSI color codes for colored output
69+
// <i> Default: 1 (Enabled)
70+
#define FC_LOG_USING_COLOR 1
71+
72+
// <q> FC_LOG_NOPREFIX_API - Enable No-Prefix API
73+
// <i> Provide simplified log macros without fc_ prefix (log_debug, log_info, etc.)
74+
// <i> Default: 1 (Enabled)
75+
#define FC_LOG_NOPREFIX_API 1
76+
77+
// <o> FC_LOG_POOL_TOTAL_SIZE - Log Memory Pool Size <1024-16384:256>
78+
// <i> Total memory pool size for logger in bytes
79+
// <i> Default: 4096 (4KB)
80+
#define FC_LOG_POOL_TOTAL_SIZE (4 * 1024)
81+
82+
// <o> FC_LOG_ALLOC_BLOCK_SIZE - Log Allocation Block Size <64-512:64>
83+
// <i> Memory pool block size in bytes
84+
// <i> Default: 128
85+
#define FC_LOG_ALLOC_BLOCK_SIZE 128
86+
87+
// Note: The following string options are defined below but not configurable via Configuration Wizard
88+
// You can modify them directly in code if needed:
89+
// - FC_LOG_PREFIX_FMT: Log prefix format (default: "(%d)%s:")
90+
// - FC_LOG_END: Log end string (default: "" or "\r\n")
91+
// - FC_LOG_ERROR_HEAD/WARNING_HEAD/INFO_HEAD/DEBUG_HEAD/VERBOSE_HEAD: Log level prefixes
92+
93+
#define FC_LOG_PREFIX_FMT "(%d)%s:"
94+
#define FC_LOG_END ""
95+
#define FC_LOG_ERROR_HEAD "E"
96+
#define FC_LOG_WARNING_HEAD "W"
97+
#define FC_LOG_INFO_HEAD "I"
98+
#define FC_LOG_DEBUG_HEAD "D"
99+
#define FC_LOG_VERBOSE_HEAD "V"
100+
101+
// </h>
102+
103+
// <h> Memory Pool Configuration
104+
// <i> Memory pool configuration
105+
106+
// <q> FC_FOOL_ENABLE_DYNAMIC_POOL_ALLOC - Enable Dynamic Allocation
107+
// <i> Allow memory pool to use dynamic memory (malloc/free) when static memory is exhausted
108+
// <i> Default: 0 (Disabled)
109+
#define FC_FOOL_ENABLE_DYNAMIC_POOL_ALLOC 0
110+
111+
// </h>
112+
113+
// <h> Port Configuration
114+
// <i> Port and ring buffer configuration
115+
116+
// <o> PORT_RB_NUM - Number of Ring Buffers <1-16>
117+
// <i> Number of ring buffers per port (similar to SEGGER RTT)
118+
// <i> Default: 8
119+
#define PORT_RB_NUM 8
120+
121+
// <o> FIFO_TX_LOG2_SIZE - TX FIFO Size (log2) <8-16>
122+
// <i> Output ring buffer size as power of 2 (e.g., 12 = 4096 bytes)
123+
// <i> Default: 12 (4KB)
124+
#define FIFO_TX_LOG2_SIZE 12
125+
126+
// <o> STDOUT_TX_SINGLE_MAX_SHIFT - TX Single Max Shift <1-4>
127+
// <i> Single TX max bytes = buffer_size / (2^n), smaller value allows more data per transfer
128+
// <i> Default: 2
129+
#define STDOUT_TX_SINGLE_MAX_SHIFT 2
130+
131+
// <q> PHY_SERIAL_TX_ENABLE - Enable Serial TX
132+
// <i> Enable continuous serial transmission
133+
// <i> Default: 0 (Disabled)
134+
#define PHY_SERIAL_TX_ENABLE 0
135+
136+
// <o> FIFO_RX_LOG2_SIZE - RX FIFO Size (log2) <6-12>
137+
// <i> Input ring buffer size as power of 2 (e.g., 8 = 256 bytes)
138+
// <i> Default: 8 (256B)
139+
#define FIFO_RX_LOG2_SIZE 8
140+
141+
// <o> STDIN_RX_SINGLE_MAX_SHIFT - RX Single Max Shift <1-4>
142+
// <i> Single RX max bytes = buffer_size / (2^n), smaller value allows more data per transfer
143+
// <i> Default: 1
144+
#define STDIN_RX_SINGLE_MAX_SHIFT 1
145+
146+
// <q> PHY_SERIAL_RX_ENABLE - Enable Serial RX
147+
// <i> Enable continuous serial reception
148+
// <i> Default: 0 (Disabled)
149+
#define PHY_SERIAL_RX_ENABLE 0
150+
151+
// </h>
152+
153+
// <h> Transport Configuration
154+
// <i> Transport component configuration
155+
156+
// <o> FC_DIVISION_NUM_MAX_LEN - Port Number Max Length <1-8>
157+
// <i> Maximum length of port number in paging information
158+
// <i> Default: 4 (supports 0-9999)
159+
#define FC_DIVISION_NUM_MAX_LEN 4
160+
161+
// <o> FC_DIVISION_NUM_MAX - Port Number Max Value <99-99999999>
162+
// <i> Maximum value of port number, must match FC_DIVISION_NUM_MAX_LEN
163+
// <i> Default: 9999
164+
#define FC_DIVISION_NUM_MAX 9999
165+
166+
// </h>
167+
168+
// <h> StdIO Configuration
169+
// <i> Standard I/O configuration
170+
171+
// <q> XF_USE_LLI - Enable Long Long Integer Support
172+
// <i> Support %lld, %llu for 64-bit integer formatting
173+
// <i> Default: 1 (Enabled)
174+
#define XF_USE_LLI 1
175+
176+
// <q> XF_USE_FP - Enable Floating Point Support
177+
// <i> Support %f, %e, %E for floating point formatting (increases code size significantly)
178+
// <i> Default: 1 (Enabled)
179+
#define XF_USE_FP 1
180+
181+
// <o> SZB_OUTPUT - Output Buffer Size <16-128:8>
182+
// <i> Internal buffer size for printf/sprintf functions
183+
// <i> Default: 32
184+
#define SZB_OUTPUT 32
185+
186+
// <q> FC_FIFO_VPRINTF_LINEAR_WRITE - Enable Linear Write Mode
187+
// <i> Use linear write mode for better performance
188+
// <i> Default: 1 (Enabled)
189+
#define FC_FIFO_VPRINTF_LINEAR_WRITE 1
190+
191+
// Note: XF_DPC (Decimal Point Character) is defined below
192+
// Modify directly in code if you need a different decimal separator
193+
#define XF_DPC '.'
194+
195+
// </h>
196+
197+
// <h> FIFO Configuration
198+
// <i> FIFO (ring buffer) configuration
199+
200+
// <q> FC_USE_STD_MEMCPY - Use Standard memcpy
201+
// <i> Use standard library memcpy (0 = use byte-by-byte copy)
202+
// <i> Default: 1 (Enabled)
203+
#define FC_USE_STD_MEMCPY 1
204+
205+
// </h>
206+
207+
//+********************************* 高级配置 (通常不需要修改) **********************************/
208+
/**
209+
* Advanced Configuration - Normally no need to modify
210+
*
211+
* The following macros can be overridden in your project if needed:
212+
*
213+
* - fc_assert(x) - Runtime assertion
214+
* - FC_WAIT_MOMENT() - Wait/delay function
215+
* - FC_PORT_LOCK(port, rb, dir) - Port lock function
216+
* - FC_PORT_UNLOCK(port, rb, dir) - Port unlock function
217+
* - FC_PORT_LOSE_HOOK(...) - Data loss hook
218+
* - FC_LOG_OBJ - Log output object
219+
* - FC_LOG_LOSE_HOOK(...) - Log data loss hook
220+
* - FC_LOG_PREFIX_CONTENT - Log prefix content macro
221+
* - FC_STDOUT_OBJ - Standard output object
222+
* - FC_STDOUT_RB_INDEX - Standard output ring buffer index
223+
* - FC_STDIN_OBJ - Standard input object
224+
* - FC_STDIN_RB_INDEX - Standard input ring buffer index
225+
* - FC_POOL_ATOMIC_ENTER(obj) - Pool atomic section enter
226+
* - FC_POOL_ATOMIC_EXIT(obj) - Pool atomic section exit
227+
* - FC_POOL_MALLOC(size) - Pool malloc function
228+
* - FC_POOL_FREE(ptr) - Pool free function
229+
* - fc_fifo_assert(x) - FIFO assertion
230+
* - fc_fifo_memcpy(dst, src, size) - FIFO memory copy function
231+
*
232+
* Define these macros in your project before including fc_embed headers if you need
233+
* custom implementations.
234+
*/
235+
236+
//+********************************* 配置项说明 **********************************/
237+
/**
238+
* Configuration Wizard 使用说明:
239+
*
240+
* 1. 在 Keil MDK 中打开本文件
241+
* 2. 点击编辑器底部的 "Configuration Wizard" 标签
242+
* 3. 通过图形界面配置所有选项 (复选框、下拉框、数值输入框)
243+
* 4. 保存文件后配置立即生效
244+
*
245+
* 配置优先级:
246+
* 1. 工程中自定义的 fc_config.h (最高优先级)
247+
* 2. 本模板文件中的配置
248+
* 3. 源代码中的默认值 (最低优先级)
249+
*
250+
* 使用方法:
251+
* 1. 复制本文件并重命名为 fc_config.h
252+
* 2. 使用 Configuration Wizard 修改配置
253+
* 3. 将 fc_config.h 添加到工程的包含路径
254+
*/
255+
256+
#endif /* _FC_CONFIG_H_ */
257+
258+
// <<< end of configuration section >>>

core/fc_config_template.h

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)