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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
48 changes: 22 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,12 @@ jobs:
- name: "Default (All OFF)"
freertos: "OFF"
lvgl: "OFF"
thorvg: "OFF"
- name: "FreeRTOS ON"
freertos: "ON"
lvgl: "OFF"
thorvg: "OFF"
- name: "LVGL ON"
freertos: "OFF"
lvgl: "ON"
thorvg: "OFF"
- name: "LVGL + ThorVG ON"
freertos: "OFF"
lvgl: "ON"
thorvg: "ON"

steps:
- name: Checkout repository
Expand Down Expand Up @@ -60,8 +53,7 @@ jobs:
-DMCU_MODEL="STM32F429ZIT6_GCC" \
-DUSE_FREERTOS=${{ matrix.config.freertos }} \
-DUSE_FATFS=OFF \
-DUSE_LVGL=${{ matrix.config.lvgl }} \
-DUSE_LVGL_THORVG=${{ matrix.config.thorvg }}
-DUSE_LVGL=${{ matrix.config.lvgl }}
ninja -C build

build-gcc-windows:
Expand All @@ -73,19 +65,12 @@ jobs:
- name: "Default (All OFF)"
freertos: "OFF"
lvgl: "OFF"
thorvg: "OFF"
- name: "FreeRTOS ON"
freertos: "ON"
lvgl: "OFF"
thorvg: "OFF"
- name: "LVGL ON"
freertos: "OFF"
lvgl: "ON"
thorvg: "OFF"
- name: "LVGL + ThorVG ON"
freertos: "OFF"
lvgl: "ON"
thorvg: "ON"

steps:
- name: Checkout repository
Expand Down Expand Up @@ -168,25 +153,36 @@ jobs:
with:
lfs: true

- name: Setup MSYS2 with GCC
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: >-
mingw-w64-x86_64-gcc
mingw-w64-x86_64-cmake
mingw-w64-x86_64-ninja

- name: Verify tools installation
shell: pwsh
shell: msys2 {0}
run: |
ninja --version
gcc --version
cmake --version
ninja --version

- name: Run tests
shell: pwsh
shell: msys2 {0}
run: |
cd Test
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
cmake --build build --config Debug

# 运行测试可执行文件
if (Test-Path "build/test.exe") {
Write-Host "Running test executable..."
& .\build\test.exe
} else {
Write-Error "Test executable not found at build/test.exe"
Get-ChildItem build | Select-Object Name, Length
if [ -f "build/test.exe" ]; then
echo "Running test executable..."
./build/test.exe
else
echo "Error: Test executable not found at build/test.exe"
ls -la build/
exit 1
}
fi
38 changes: 38 additions & 0 deletions L2_Core/hal/inc/ek_hal_i2c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef EK_HAL_I2C_H
#define EK_HAL_I2C_H

#include "../../utils/inc/ek_def.h"
#include "../../utils/inc/ek_list.h"

typedef struct ek_hal_i2c_t ek_hal_i2c_t;

typedef enum
{
EK_HAL_I2C_MEM_8B,
EK_HAL_I2C_MEM_16B,
} ek_hal_i2c_mem_size_t;

struct ek_hal_i2c_t
{
uint8_t idx;
ek_list_node_t node;
uint32_t speed_hz;

bool lock;

void (*init)(void);
bool (*write)(uint16_t dev_addr, uint8_t *txdata, size_t size);
bool (*read)(uint16_t dev_addr, uint8_t *txdata, size_t size);
bool (*mem_write)(
uint16_t dev_addr, uint16_t mem_addr, ek_hal_i2c_mem_size_t mem_size, uint8_t *txdata, size_t size);
bool (*mem_read)(
uint16_t dev_addr, uint16_t mem_addr, ek_hal_i2c_mem_size_t mem_size, uint8_t *rxdata, size_t size);
};

extern ek_list_node_t ek_hal_i2c_head;

extern ek_hal_i2c_t hal_drv_i2c1;

void ek_hal_i2c_init(void);

#endif
119 changes: 119 additions & 0 deletions L2_Core/hal/src/ek_hal_i2c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#include "../inc/ek_hal_i2c.h"
#include "../../utils/inc/ek_assert.h"
#include "../../utils/inc/ek_export.h"

#define EK_HAL_LOCK_ON(x) ((x)->lock = true)
#define EK_HAL_LOCK_OFF(x) ((x)->lock = false)
#define EK_HAL_LOCK_TEST(x) ((x)->lock == true)

static void i2c1_init(void);
static bool i2c1_send(uint16_t dev_addr, uint8_t *txdata, size_t size);
static bool i2c1_recieve(uint16_t dev_addr, uint8_t *rxdata, size_t size);
static bool
i2c1_mem_write(uint16_t dev_addr, uint16_t mem_addr, ek_hal_i2c_mem_size_t mem_size, uint8_t *txdata, size_t size);
static bool
i2c1_mem_read(uint16_t dev_addr, uint16_t mem_addr, ek_hal_i2c_mem_size_t mem_size, uint8_t *rxdata, size_t size);

ek_list_node_t ek_hal_i2c_head;

ek_hal_i2c_t hal_drv_i2c1 = {
.idx = 1,
.speed_hz = 400000,

.lock = false,

.init = i2c1_init,
.read = i2c1_recieve,
.write = i2c1_send,

.mem_read = i2c1_mem_read,
.mem_write = i2c1_mem_write,
};

static void i2c1_init(void)
{
hal_drv_i2c1.lock = false;
}

static bool i2c1_send(uint16_t dev_addr, uint8_t *txdata, size_t size)
{
if (EK_HAL_LOCK_TEST(&hal_drv_i2c1) == true) return false;

EK_HAL_LOCK_ON(&hal_drv_i2c1);

__UNUSED(dev_addr);
__UNUSED(txdata);
__UNUSED(size);
// 具体的i2c底层

EK_HAL_LOCK_OFF(&hal_drv_i2c1);

return true;
}

static bool i2c1_recieve(uint16_t dev_addr, uint8_t *rxdata, size_t size)
{
if (EK_HAL_LOCK_TEST(&hal_drv_i2c1) == true) return false;

EK_HAL_LOCK_ON(&hal_drv_i2c1);

__UNUSED(dev_addr);
__UNUSED(rxdata);
__UNUSED(size);
// 具体的i2c底层

EK_HAL_LOCK_OFF(&hal_drv_i2c1);

return true;
}

static bool
i2c1_mem_write(uint16_t dev_addr, uint16_t mem_addr, ek_hal_i2c_mem_size_t mem_size, uint8_t *txdata, size_t size)
{
if (EK_HAL_LOCK_TEST(&hal_drv_i2c1) == true) return false;

// uint16_t msize = (mem_size == EK_HAL_I2C_MEM_8B) ? I2C_MEMADD_SIZE_8BIT : I2C_MEMADD_SIZE_16BIT;
// msize 来判断从机设备长度

EK_HAL_LOCK_ON(&hal_drv_i2c1);

__UNUSED(dev_addr);
__UNUSED(mem_addr);
__UNUSED(txdata);
__UNUSED(size);
// 具体的i2c底层

EK_HAL_LOCK_OFF(&hal_drv_i2c1);

return true;
}

static bool
i2c1_mem_read(uint16_t dev_addr, uint16_t mem_addr, ek_hal_i2c_mem_size_t mem_size, uint8_t *rxdata, size_t size)
{
if (EK_HAL_LOCK_TEST(&hal_drv_i2c1) == true) return false;

// uint16_t msize = (mem_size == EK_HAL_I2C_MEM_8B) ? I2C_MEMADD_SIZE_8BIT : I2C_MEMADD_SIZE_16BIT;
// msize 来判断从机设备长度

EK_HAL_LOCK_ON(&hal_drv_i2c1);

__UNUSED(dev_addr);
__UNUSED(mem_addr);
__UNUSED(rxdata);
__UNUSED(size);
// 具体的i2c底层

EK_HAL_LOCK_OFF(&hal_drv_i2c1);

return true;
}

void ek_hal_i2c_init(void)
{
ek_list_init(&ek_hal_i2c_head);

ek_list_add_tail(&ek_hal_i2c_head, &hal_drv_i2c1.node);
}

EK_EXPORT(ek_hal_i2c_init, 0);
4 changes: 2 additions & 2 deletions L2_Core/hal/src/ek_hal_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#define EK_HAL_LOCK_OFF(x) ((x)->lock = false)
#define EK_HAL_LOCK_TEST(x) ((x)->lock == true)

#define STM32F429XX_TIMEOUT (100)

ek_list_node_t ek_hal_spi_head;

static void spi1_init(void);
Expand Down Expand Up @@ -54,6 +52,7 @@ static bool spi1_recieve(uint8_t *rxdata, size_t size)

__UNUSED(rxdata);
__UNUSED(size);
// 具体的spi底层

EK_HAL_LOCK_OFF(&hal_drv_spi1);

Expand All @@ -69,6 +68,7 @@ static bool spi1_write_recieve(uint8_t *txdata, uint8_t *rxdata, size_t size)
__UNUSED(txdata);
__UNUSED(rxdata);
__UNUSED(size);
// 具体的spi底层

EK_HAL_LOCK_OFF(&hal_drv_spi1);

Expand Down
Loading