Skip to content

Commit f83526c

Browse files
Merge pull request #11 from EmbeddedKitOrg/develop/nn
Develop/nn
2 parents 6353a53 + 55e7474 commit f83526c

6 files changed

Lines changed: 21 additions & 18 deletions

File tree

‎L2_Core/port/gd32f470zgt6/gd_gpio_port.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static const ek_gpio_ops_t gd_gpio_ops = {
5959
// 注册到hal
6060
void gd_gpio_drv_init(void)
6161
{
62-
for (uint8_t i = 0; i < sizeof(gd_drv_gpio_table) / sizeof(gd_drv_gpio_table[0]); i++)
62+
for (uint8_t i = 0; i < EK_ARRAY_LEN(gd_drv_gpio_table); i++)
6363
{
6464
ek_hal_gpio_register(gd_drv_gpio_table[i].dev,
6565
gd_drv_gpio_table[i].name,

‎L2_Core/port/stm32f429zi/st_gpio_port.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static const ek_gpio_ops_t st_gpio_ops = {
4949
// 注册到hal
5050
void st_gpio_drv_init(void)
5151
{
52-
for (uint8_t i = 0; i < sizeof(st_drv_gpio_table) / sizeof(st_drv_gpio_table[0]); i++)
52+
for (uint8_t i = 0; i < EK_ARRAY_LEN(st_drv_gpio_table); i++)
5353
{
5454
ek_hal_gpio_register(st_drv_gpio_table[i].dev,
5555
st_drv_gpio_table[i].name,

‎L2_Core/utils/inc/ek_def.h‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define EK_DEF_H
1717

1818
#include <inttypes.h>
19+
#include <stdarg.h>
1920
#include <string.h>
2021
#include <stddef.h>
2122
#include <stdint.h>
@@ -77,8 +78,13 @@
7778
# define __STATIC_INLINE static __inline
7879
# define __ALWAYS_INLINE __forceinline
7980
# define __ASM __asm
80-
/* ========== 不支持的编译器(空定义) ========== */
81+
/* ========== 不支持的编译器(需手动适配,默认编译报错) ========== */
8182
#else
83+
84+
# if 1
85+
# error "Unsupported compiler detected. Please review and update the macro definitions in ek_def.h for this toolchain."
86+
# endif
87+
8288
# define __WEAK
8389
# define __PACKED
8490
# define __PACKED_STRUCT struct
@@ -93,4 +99,11 @@
9399
# define __ASM asm
94100
#endif
95101

102+
/* ========== 功能宏 ========== */
103+
#define EK_ARRAY_LEN(x) (sizeof(x) / (sizeof((x)[0])))
104+
#define EK_CLAMP(val, min, max) (((val) < (min)) ? (min) : (((val) > (max)) ? (max) : (val)))
105+
#define EK_GET_FILE_NAME(file_path) \
106+
(strrchr((file_path), '/') ? strrchr((file_path), '/') + 1 \
107+
: (strrchr((file_path), '\\') ? strrchr((file_path), '\\') + 1 : (file_path)))
108+
96109
#endif /* EK_DEF_H */

‎L2_Core/utils/src/ek_assert.c‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,12 @@
66

77
#include "../inc/ek_assert.h"
88
#include "../inc/ek_log.h"
9-
#include <string.h>
10-
11-
#define GET_FILE_NAME(file_path) \
12-
(strrchr(file_path, '/') ? strrchr(file_path, '/') + 1 \
13-
: (strrchr(file_path, '\\') ? strrchr(file_path, '\\') + 1 : file_path))
149

1510
void ek_assert_fault(const char *file, uint32_t line, const char *expr)
1611
{
1712
#if EK_ASSERT_WITH_LOG == 1
1813
EK_LOG_FILE_TAG("ek_assert.c");
19-
EK_LOG_ERROR("file:%s,line:%" PRIu32 ",expr: %s", GET_FILE_NAME(file), line, expr);
14+
EK_LOG_ERROR("file:%s,line:%" PRIu32 ",expr: %s", EK_GET_FILE_NAME(file), line, expr);
2015
#else
2116
__UNUSED(file);
2217
__UNUSED(line);

‎L2_Core/utils/src/ek_log.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,15 @@ void _ek_log_printf(const char *tag, uint32_t line, ek_log_type_t type, uint32_t
4646
EK_LOG_LOCK();
4747

4848
# if (EK_LOG_COLOR_ENABLE == 1)
49-
50-
ek_printf("%s[%s/%s L:%" PRIu32 ",T:%" PRIu32 "]:",
51-
ek_log_color_table[type],
52-
ek_log_type_table[type],
53-
tag,
54-
line,
55-
_ek_log_get_tick());
49+
ek_printf(
50+
"%s[%s/%s L:%" PRIu32 ",T:%" PRIu32 "]:", ek_log_color_table[type], ek_log_type_table[type], tag, line, tick);
5651
# else /* EK_LOG_COLOR_ENABLE == 1 */
5752
ek_printf("[%s/%s L:%" PRIu32 ",T:%" PRIu32 "]:", ek_log_type_table[type], tag, line, tick);
5853
# endif /* EK_LOG_COLOR_ENABLE == 1 */
5954

6055
va_list args;
6156
va_start(args, fmt);
62-
lwvsnprintf(ek_log_buffer, EK_LOG_BUFFER_SIZE - 1, fmt, args);
57+
ek_vsnprintf(ek_log_buffer, EK_LOG_BUFFER_SIZE - 1, fmt, args);
6358
va_end(args);
6459

6560
ek_printf("%s", ek_log_buffer);

‎ek_conf.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#define EK_VEC_ENABLE (1)
4747
#define EK_RINGBUF_ENABLE (1)
4848
#define EK_STACK_ENABLE (1)
49-
#define EK_SHELL_ENABLE (1)
49+
#define EK_SHELL_ENABLE (0)
5050

5151
/* ========================================================================
5252
* 日志模块配置

0 commit comments

Comments
 (0)