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
12 changes: 11 additions & 1 deletion L2_Core/hal/inc/ek_hal_adc.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
#include "../../utils/inc/ek_def.h"
#include "../../utils/inc/ek_list.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct ek_hal_adc_t ek_hal_adc_t;
typedef struct ek_adc_ops_t ek_adc_ops_t;

/** @brief ADC 分辨率枚举 */
typedef enum {
typedef enum
{
EK_HAL_ADC_RES_8B,
EK_HAL_ADC_RES_10B,
EK_HAL_ADC_RES_12B,
Expand Down Expand Up @@ -47,4 +53,8 @@ bool ek_hal_adc_read_dma(ek_hal_adc_t *const dev, uint32_t *buffer, size_t size)
void ek_hal_adc_start(ek_hal_adc_t *const dev);
void ek_hal_adc_stop(ek_hal_adc_t *const dev);

#ifdef __cplusplus
}
#endif

#endif // EK_HAL_ADC_H
9 changes: 9 additions & 0 deletions L2_Core/hal/inc/ek_hal_dac.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include "../../utils/inc/ek_def.h"
#include "../../utils/inc/ek_list.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct ek_hal_dac_t ek_hal_dac_t;
typedef struct ek_dac_ops_t ek_dac_ops_t;

Expand Down Expand Up @@ -38,4 +43,8 @@ bool ek_hal_dac_write_dma(ek_hal_dac_t *const dev, uint32_t *buffer, size_t size
void ek_hal_dac_start(ek_hal_dac_t *const dev);
void ek_hal_dac_stop(ek_hal_dac_t *const dev);

#ifdef __cplusplus
}
#endif

#endif // EK_HAL_DAC_H
9 changes: 9 additions & 0 deletions L2_Core/hal/inc/ek_hal_dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include "../../utils/inc/ek_def.h"
#include "../../utils/inc/ek_list.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct ek_hal_dma_t ek_hal_dma_t;
typedef struct ek_dma_ops_t ek_dma_ops_t;

Expand Down Expand Up @@ -42,4 +47,8 @@ bool ek_hal_dma_transfer(ek_hal_dma_t *const dev, void *src, void *dst, size_t s
bool ek_hal_dma_transfer_it(ek_hal_dma_t *const dev, void *src, void *dst, size_t size, ek_dma_direction_t dir);
void ek_hal_dma_abort(ek_hal_dma_t *const dev);

#ifdef __cplusplus
}
#endif

#endif // EK_HAL_DMA_H
9 changes: 9 additions & 0 deletions L2_Core/hal/inc/ek_hal_dma2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include "../../utils/inc/ek_def.h"
#include "../../utils/inc/ek_list.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct ek_hal_dma2d_t ek_hal_dma2d_t;
typedef struct ek_dma2d_ops_t ek_dma2d_ops_t;

Expand Down Expand Up @@ -71,4 +76,8 @@ bool ek_hal_dma2d_convert_it(ek_hal_dma2d_t *const dev,
uint32_t offset,
ek_dma2d_color_mode_t input_mode);

#ifdef __cplusplus
}
#endif

#endif // EK_HAL_DMA2D_H
9 changes: 9 additions & 0 deletions L2_Core/hal/inc/ek_hal_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include "../../utils/inc/ek_def.h"
#include "../../utils/inc/ek_list.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct ek_hal_gpio_t ek_hal_gpio_t;
typedef struct ek_gpio_ops_t ek_gpio_ops_t;

Expand Down Expand Up @@ -56,4 +61,8 @@ void ek_hal_gpio_set(ek_hal_gpio_t *const dev, ek_gpio_status_t status);
void ek_hal_gpio_toggle(ek_hal_gpio_t *const dev);
ek_gpio_status_t ek_hal_gpio_read(ek_hal_gpio_t *const dev);

#ifdef __cplusplus
}
#endif

#endif // EK_HAL_GPIO_H
9 changes: 9 additions & 0 deletions L2_Core/hal/inc/ek_hal_i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include "../../utils/inc/ek_def.h"
#include "../../utils/inc/ek_list.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct ek_hal_i2c_t ek_hal_i2c_t;
typedef struct ek_i2c_ops_t ek_i2c_ops_t;

Expand Down Expand Up @@ -65,4 +70,8 @@ bool ek_hal_i2c_mem_read(ek_hal_i2c_t *const dev,
uint8_t *rxdata,
size_t size);

#ifdef __cplusplus
}
#endif

#endif // EK_HAL_I2C_H
9 changes: 9 additions & 0 deletions L2_Core/hal/inc/ek_hal_ltdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include "../../utils/inc/ek_def.h"
#include "../../utils/inc/ek_list.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct ek_hal_ltdc_t ek_hal_ltdc_t;
typedef struct ek_ltdc_ops_t ek_ltdc_ops_t;

Expand Down Expand Up @@ -41,4 +46,8 @@ bool ek_hal_ltdc_reload_config(ek_hal_ltdc_t *const dev);
void ek_hal_ltdc_display_on(ek_hal_ltdc_t *const dev);
void ek_hal_ltdc_display_off(ek_hal_ltdc_t *const dev);

#ifdef __cplusplus
}
#endif

#endif // EK_HAL_LTDC_H
9 changes: 9 additions & 0 deletions L2_Core/hal/inc/ek_hal_pwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include "../../utils/inc/ek_def.h"
#include "../../utils/inc/ek_list.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct ek_hal_pwm_t ek_hal_pwm_t;
typedef struct ek_pwm_ops_t ek_pwm_ops_t;

Expand Down Expand Up @@ -43,4 +48,8 @@ void ek_hal_pwm_set_freq(ek_hal_pwm_t *const dev, uint32_t freq);
uint32_t ek_hal_pwm_get_duty(ek_hal_pwm_t *const dev);
uint32_t ek_hal_pwm_get_freq(ek_hal_pwm_t *const dev);

#ifdef __cplusplus
}
#endif

#endif // EK_HAL_PWM_H
9 changes: 9 additions & 0 deletions L2_Core/hal/inc/ek_hal_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include "../../utils/inc/ek_def.h"
#include "../../utils/inc/ek_list.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct ek_hal_spi_t ek_hal_spi_t;
typedef struct ek_spi_ops_t ek_spi_ops_t;

Expand Down Expand Up @@ -35,4 +40,8 @@ bool ek_hal_spi_write(ek_hal_spi_t *const dev, uint8_t *txdata, size_t size);
bool ek_hal_spi_read(ek_hal_spi_t *const dev, uint8_t *rxdata, size_t size);
bool ek_hal_spi_write_read(ek_hal_spi_t *const dev, uint8_t *txdata, uint8_t *rxdata, size_t size);

#ifdef __cplusplus
}
#endif

#endif // EK_HAL_SPI_H
9 changes: 9 additions & 0 deletions L2_Core/hal/inc/ek_hal_tick.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include "../../utils/inc/ek_def.h"
#include "../../utils/inc/ek_list.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct ek_hal_tick_t ek_hal_tick_t;
typedef struct ek_tick_ops_t ek_tick_ops_t;

Expand Down Expand Up @@ -33,4 +38,8 @@ ek_hal_tick_t *ek_hal_tick_find(const char *name);
uint32_t ek_hal_tick_get(ek_hal_tick_t *const dev);
void ek_hal_tick_delay(ek_hal_tick_t *const dev, uint32_t xtick);

#ifdef __cplusplus
}
#endif

#endif // EK_HAL_TICK_H
9 changes: 9 additions & 0 deletions L2_Core/hal/inc/ek_hal_tim.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include "../../utils/inc/ek_def.h"
#include "../../utils/inc/ek_list.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct ek_hal_tim_base_t ek_hal_tim_base_t;
typedef struct ek_tim_ops_t ek_tim_ops_t;

Expand Down Expand Up @@ -53,4 +58,8 @@ void ek_hal_tim_stop(ek_hal_tim_base_t *const dev);
uint32_t ek_hal_tim_get(ek_hal_tim_base_t *const dev);
void ek_hal_tim_set(ek_hal_tim_base_t *const dev, uint32_t value);

#ifdef __cplusplus
}
#endif

#endif // EK_HAL_TIMER_H
9 changes: 9 additions & 0 deletions L2_Core/hal/inc/ek_hal_uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include "../../utils/inc/ek_def.h"
#include "../../utils/inc/ek_list.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct ek_hal_uart_t ek_hal_uart_t;
typedef struct ek_uart_ops_t ek_uart_ops_t;

Expand Down Expand Up @@ -38,4 +43,8 @@ bool ek_hal_uart_write(ek_hal_uart_t *const dev, uint8_t *txdata, size_t size);
bool ek_hal_uart_write_dma(ek_hal_uart_t *const dev, uint8_t *txdata, size_t size);
void ek_hal_uart_read(ek_hal_uart_t *const dev);

#ifdef __cplusplus
}
#endif

#endif // EK_HAL_UART_H
9 changes: 9 additions & 0 deletions L2_Core/port/inc/gd_hal_port.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#ifndef GD_HAL_PORT_H
#define GD_HAL_PORT_H

#ifdef __cplusplus
extern "C"
{
#endif

void gd_gpio_drv_init(void);
void gd_uart_drv_init(void);
void gd_spi_drv_init(void);
Expand All @@ -12,4 +17,8 @@ void gd_adc_drv_init(void);
void gd_dac_drv_init(void);
void gd_pwm_drv_init(void);

#ifdef __cplusplus
}
#endif

#endif // GD_HAL_PORT_H
9 changes: 9 additions & 0 deletions L2_Core/port/inc/st_hal_port.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#ifndef ST_HAL_PORT_H
#define ST_HAL_PORT_H

#ifdef __cplusplus
extern "C"
{
#endif

void st_gpio_drv_init(void);
void st_spi_drv_init(void);
void st_uart_drv_init(void);
Expand All @@ -10,4 +15,8 @@ void st_dma2d_drv_init(void);
void st_ltdc_drv_init(void);
void st_tick_drv_init(void);

#ifdef __cplusplus
}
#endif

#endif // ST_HAL_PORT_H
9 changes: 9 additions & 0 deletions L2_Core/utils/inc/ek_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
# define ek_assert_param(expr) ek_assert_full(expr)
#endif /* EK_ASSERT_USE_TINY */

#ifdef __cplusplus
extern "C"
{
#endif

/**
* @brief 断言失败处理函数
* @param file 源文件名
Expand All @@ -68,4 +73,8 @@
*/
void ek_assert_fault(const char *file, uint32_t line, const char *expr);

#ifdef __cplusplus
}
#endif

#endif /* EK_ASSERT_H */
11 changes: 7 additions & 4 deletions L2_Core/utils/inc/ek_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
# define __WEAK __weak
# define __PACKED __packed
# define __PACKED_STRUCT __packed struct
# define __ALIGNED(x) __align(x)
# define __ALIGNED(x) __align((x))
# define __USED __attribute__((used))
# define __SECTION(x) __attribute__((section(x)))
# define __NO_RETURN __declspec(noreturn)
Expand All @@ -82,7 +82,8 @@
#else

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

# define __WEAK
Expand All @@ -100,10 +101,12 @@
#endif

/* ========== 功能宏 ========== */
#define EK_FREQ_K(x) ((x) * 1000UL)
#define EK_FREQ_M(x) ((x) * 1000UL * 1000UL)
#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 \
#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 */
22 changes: 16 additions & 6 deletions L2_Core/utils/inc/ek_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ typedef void (*_ek_export_init_fn_t)(void);
* }
* EK_EXPORT(my_init, 10); // 优先级 10
*/
# define EK_EXPORT(fn, prio) \
const _ek_export_init_fn_t __init_##fn##prio __attribute__((used, section(".ek_export_fn." _EK_STR(prio)))) = fn
# define EK_EXPORT(fn, prio) \
const _ek_export_init_fn_t __init_##fn##prio __attribute__((used, section(".ek_export_fn." _EK_STR(prio)))) = \
(fn)

# define EK_EXPORT_HARDWARE(fn) EK_EXPORT(fn, 0)
# define EK_EXPORT_COMPONENTS(fn) EK_EXPORT(fn, 1)
# define EK_EXPORT_APP(fn) EK_EXPORT(fn, 2)
# define EK_EXPORT_USER(fn) EK_EXPORT(fn, 3)
# define EK_EXPORT_HARDWARE(fn) EK_EXPORT((fn), 0)
# define EK_EXPORT_COMPONENTS(fn) EK_EXPORT((fn), 1)
# define EK_EXPORT_APP(fn) EK_EXPORT((fn), 2)
# define EK_EXPORT_USER(fn) EK_EXPORT((fn), 3)
Comment on lines +61 to +64

#else

Expand All @@ -72,10 +73,19 @@ typedef void (*_ek_export_init_fn_t)(void);

#endif /* EK_EXPORT_ENABLE */

#ifdef __cplusplus
extern "C"
{
#endif

/**
* @brief 执行所有导出的初始化函数
* @note 按优先级顺序调用所有通过 EK_EXPORT 导出的函数
*/
void ek_export_init(void);

#ifdef __cplusplus
}
#endif

#endif /* EK_EXPORT_H */
Loading
Loading