Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion L2_Core/port/gd32f470zgt6/gd_gpio_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static const ek_gpio_ops_t gd_gpio_ops = {
// 注册到hal
void gd_gpio_drv_init(void)
{
for (uint8_t i = 0; i < sizeof(gd_drv_gpio_table) / sizeof(gd_drv_gpio_table[0]); i++)
for (uint8_t i = 0; i < EK_ARRAY_LEN(gd_drv_gpio_table); i++)
{
ek_hal_gpio_register(gd_drv_gpio_table[i].dev,
gd_drv_gpio_table[i].name,
Expand Down
2 changes: 1 addition & 1 deletion L2_Core/port/stm32f429zi/st_gpio_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static const ek_gpio_ops_t st_gpio_ops = {
// 注册到hal
void st_gpio_drv_init(void)
{
for (uint8_t i = 0; i < sizeof(st_drv_gpio_table) / sizeof(st_drv_gpio_table[0]); i++)
for (uint8_t i = 0; i < EK_ARRAY_LEN(st_drv_gpio_table); i++)
{
ek_hal_gpio_register(st_drv_gpio_table[i].dev,
st_drv_gpio_table[i].name,
Expand Down
15 changes: 14 additions & 1 deletion L2_Core/utils/inc/ek_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define EK_DEF_H

#include <inttypes.h>
#include <stdarg.h>
#include <string.h>
#include <stddef.h>
#include <stdint.h>
Expand Down Expand Up @@ -77,8 +78,13 @@
# define __STATIC_INLINE static __inline
# define __ALWAYS_INLINE __forceinline
# define __ASM __asm
/* ========== 不支持的编译器(空定义) ========== */
/* ========== 不支持的编译器(需手动适配,默认编译报错) ========== */
#else

# if 1
# error "Unsupported compiler detected. Please review and update the macro definitions in ek_def.h for this toolchain."
# endif

# define __WEAK
# define __PACKED
# define __PACKED_STRUCT struct
Expand All @@ -93,4 +99,11 @@
# define __ASM asm
#endif

/* ========== 功能宏 ========== */
#define EK_ARRAY_LEN(x) (sizeof(x) / (sizeof((x)[0])))
#define EK_CLAMP(val, min, max) (((val) < (min)) ? (min) : (((val) > (max)) ? (max) : (val)))
#define EK_GET_FILE_NAME(file_path) \
(strrchr((file_path), '/') ? strrchr((file_path), '/') + 1 \
: (strrchr((file_path), '\\') ? strrchr((file_path), '\\') + 1 : (file_path)))

#endif /* EK_DEF_H */
7 changes: 1 addition & 6 deletions L2_Core/utils/src/ek_assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@

#include "../inc/ek_assert.h"
#include "../inc/ek_log.h"
#include <string.h>

#define GET_FILE_NAME(file_path) \
(strrchr(file_path, '/') ? strrchr(file_path, '/') + 1 \
: (strrchr(file_path, '\\') ? strrchr(file_path, '\\') + 1 : file_path))

void ek_assert_fault(const char *file, uint32_t line, const char *expr)
{
#if EK_ASSERT_WITH_LOG == 1
EK_LOG_FILE_TAG("ek_assert.c");
EK_LOG_ERROR("file:%s,line:%" PRIu32 ",expr: %s", GET_FILE_NAME(file), line, expr);
EK_LOG_ERROR("file:%s,line:%" PRIu32 ",expr: %s", EK_GET_FILE_NAME(file), line, expr);
#else
__UNUSED(file);
__UNUSED(line);
Expand Down
11 changes: 3 additions & 8 deletions L2_Core/utils/src/ek_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,15 @@ void _ek_log_printf(const char *tag, uint32_t line, ek_log_type_t type, uint32_t
EK_LOG_LOCK();

# if (EK_LOG_COLOR_ENABLE == 1)

ek_printf("%s[%s/%s L:%" PRIu32 ",T:%" PRIu32 "]:",
ek_log_color_table[type],
ek_log_type_table[type],
tag,
line,
_ek_log_get_tick());
ek_printf(
"%s[%s/%s L:%" PRIu32 ",T:%" PRIu32 "]:", ek_log_color_table[type], ek_log_type_table[type], tag, line, tick);
# else /* EK_LOG_COLOR_ENABLE == 1 */
ek_printf("[%s/%s L:%" PRIu32 ",T:%" PRIu32 "]:", ek_log_type_table[type], tag, line, tick);
# endif /* EK_LOG_COLOR_ENABLE == 1 */

va_list args;
va_start(args, fmt);
lwvsnprintf(ek_log_buffer, EK_LOG_BUFFER_SIZE - 1, fmt, args);
ek_vsnprintf(ek_log_buffer, EK_LOG_BUFFER_SIZE - 1, fmt, args);
va_end(args);

ek_printf("%s", ek_log_buffer);
Expand Down
2 changes: 1 addition & 1 deletion ek_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#define EK_VEC_ENABLE (1)
#define EK_RINGBUF_ENABLE (1)
#define EK_STACK_ENABLE (1)
#define EK_SHELL_ENABLE (1)
#define EK_SHELL_ENABLE (0)

/* ========================================================================
* 日志模块配置
Expand Down