Skip to content

Commit 40e9993

Browse files
Merge pull request #3 from EmbeddedKitOrg/develop/nn
Develop/nn
2 parents e5c8447 + c772b4b commit 40e9993

963 files changed

Lines changed: 75801 additions & 219877 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,12 @@ jobs:
1616
- name: "Default (All OFF)"
1717
freertos: "OFF"
1818
lvgl: "OFF"
19-
thorvg: "OFF"
2019
- name: "FreeRTOS ON"
2120
freertos: "ON"
2221
lvgl: "OFF"
23-
thorvg: "OFF"
2422
- name: "LVGL ON"
2523
freertos: "OFF"
2624
lvgl: "ON"
27-
thorvg: "OFF"
28-
- name: "LVGL + ThorVG ON"
29-
freertos: "OFF"
30-
lvgl: "ON"
31-
thorvg: "ON"
3225

3326
steps:
3427
- name: Checkout repository
@@ -60,8 +53,7 @@ jobs:
6053
-DMCU_MODEL="STM32F429ZIT6_GCC" \
6154
-DUSE_FREERTOS=${{ matrix.config.freertos }} \
6255
-DUSE_FATFS=OFF \
63-
-DUSE_LVGL=${{ matrix.config.lvgl }} \
64-
-DUSE_LVGL_THORVG=${{ matrix.config.thorvg }}
56+
-DUSE_LVGL=${{ matrix.config.lvgl }}
6557
ninja -C build
6658
6759
build-gcc-windows:
@@ -73,19 +65,12 @@ jobs:
7365
- name: "Default (All OFF)"
7466
freertos: "OFF"
7567
lvgl: "OFF"
76-
thorvg: "OFF"
7768
- name: "FreeRTOS ON"
7869
freertos: "ON"
7970
lvgl: "OFF"
80-
thorvg: "OFF"
8171
- name: "LVGL ON"
8272
freertos: "OFF"
8373
lvgl: "ON"
84-
thorvg: "OFF"
85-
- name: "LVGL + ThorVG ON"
86-
freertos: "OFF"
87-
lvgl: "ON"
88-
thorvg: "ON"
8974

9075
steps:
9176
- name: Checkout repository
@@ -168,25 +153,36 @@ jobs:
168153
with:
169154
lfs: true
170155

156+
- name: Setup MSYS2 with GCC
157+
uses: msys2/setup-msys2@v2
158+
with:
159+
msystem: MINGW64
160+
update: true
161+
install: >-
162+
mingw-w64-x86_64-gcc
163+
mingw-w64-x86_64-cmake
164+
mingw-w64-x86_64-ninja
165+
171166
- name: Verify tools installation
172-
shell: pwsh
167+
shell: msys2 {0}
173168
run: |
174-
ninja --version
169+
gcc --version
175170
cmake --version
171+
ninja --version
176172
177173
- name: Run tests
178-
shell: pwsh
174+
shell: msys2 {0}
179175
run: |
180176
cd Test
181177
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
182178
cmake --build build --config Debug
183179
184180
# 运行测试可执行文件
185-
if (Test-Path "build/test.exe") {
186-
Write-Host "Running test executable..."
187-
& .\build\test.exe
188-
} else {
189-
Write-Error "Test executable not found at build/test.exe"
190-
Get-ChildItem build | Select-Object Name, Length
181+
if [ -f "build/test.exe" ]; then
182+
echo "Running test executable..."
183+
./build/test.exe
184+
else
185+
echo "Error: Test executable not found at build/test.exe"
186+
ls -la build/
191187
exit 1
192-
}
188+
fi

L2_Core/hal/inc/ek_hal_i2c.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#ifndef EK_HAL_I2C_H
2+
#define EK_HAL_I2C_H
3+
4+
#include "../../utils/inc/ek_def.h"
5+
#include "../../utils/inc/ek_list.h"
6+
7+
typedef struct ek_hal_i2c_t ek_hal_i2c_t;
8+
9+
typedef enum
10+
{
11+
EK_HAL_I2C_MEM_8B,
12+
EK_HAL_I2C_MEM_16B,
13+
} ek_hal_i2c_mem_size_t;
14+
15+
struct ek_hal_i2c_t
16+
{
17+
uint8_t idx;
18+
ek_list_node_t node;
19+
uint32_t speed_hz;
20+
21+
bool lock;
22+
23+
void (*init)(void);
24+
bool (*write)(uint16_t dev_addr, uint8_t *txdata, size_t size);
25+
bool (*read)(uint16_t dev_addr, uint8_t *txdata, size_t size);
26+
bool (*mem_write)(
27+
uint16_t dev_addr, uint16_t mem_addr, ek_hal_i2c_mem_size_t mem_size, uint8_t *txdata, size_t size);
28+
bool (*mem_read)(
29+
uint16_t dev_addr, uint16_t mem_addr, ek_hal_i2c_mem_size_t mem_size, uint8_t *rxdata, size_t size);
30+
};
31+
32+
extern ek_list_node_t ek_hal_i2c_head;
33+
34+
extern ek_hal_i2c_t hal_drv_i2c1;
35+
36+
void ek_hal_i2c_init(void);
37+
38+
#endif

L2_Core/hal/src/ek_hal_i2c.c

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#include "../inc/ek_hal_i2c.h"
2+
#include "../../utils/inc/ek_assert.h"
3+
#include "../../utils/inc/ek_export.h"
4+
5+
#define EK_HAL_LOCK_ON(x) ((x)->lock = true)
6+
#define EK_HAL_LOCK_OFF(x) ((x)->lock = false)
7+
#define EK_HAL_LOCK_TEST(x) ((x)->lock == true)
8+
9+
static void i2c1_init(void);
10+
static bool i2c1_send(uint16_t dev_addr, uint8_t *txdata, size_t size);
11+
static bool i2c1_recieve(uint16_t dev_addr, uint8_t *rxdata, size_t size);
12+
static bool
13+
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);
14+
static bool
15+
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);
16+
17+
ek_list_node_t ek_hal_i2c_head;
18+
19+
ek_hal_i2c_t hal_drv_i2c1 = {
20+
.idx = 1,
21+
.speed_hz = 400000,
22+
23+
.lock = false,
24+
25+
.init = i2c1_init,
26+
.read = i2c1_recieve,
27+
.write = i2c1_send,
28+
29+
.mem_read = i2c1_mem_read,
30+
.mem_write = i2c1_mem_write,
31+
};
32+
33+
static void i2c1_init(void)
34+
{
35+
hal_drv_i2c1.lock = false;
36+
}
37+
38+
static bool i2c1_send(uint16_t dev_addr, uint8_t *txdata, size_t size)
39+
{
40+
if (EK_HAL_LOCK_TEST(&hal_drv_i2c1) == true) return false;
41+
42+
EK_HAL_LOCK_ON(&hal_drv_i2c1);
43+
44+
__UNUSED(dev_addr);
45+
__UNUSED(txdata);
46+
__UNUSED(size);
47+
// 具体的i2c底层
48+
49+
EK_HAL_LOCK_OFF(&hal_drv_i2c1);
50+
51+
return true;
52+
}
53+
54+
static bool i2c1_recieve(uint16_t dev_addr, uint8_t *rxdata, size_t size)
55+
{
56+
if (EK_HAL_LOCK_TEST(&hal_drv_i2c1) == true) return false;
57+
58+
EK_HAL_LOCK_ON(&hal_drv_i2c1);
59+
60+
__UNUSED(dev_addr);
61+
__UNUSED(rxdata);
62+
__UNUSED(size);
63+
// 具体的i2c底层
64+
65+
EK_HAL_LOCK_OFF(&hal_drv_i2c1);
66+
67+
return true;
68+
}
69+
70+
static bool
71+
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)
72+
{
73+
if (EK_HAL_LOCK_TEST(&hal_drv_i2c1) == true) return false;
74+
75+
// uint16_t msize = (mem_size == EK_HAL_I2C_MEM_8B) ? I2C_MEMADD_SIZE_8BIT : I2C_MEMADD_SIZE_16BIT;
76+
// msize 来判断从机设备长度
77+
78+
EK_HAL_LOCK_ON(&hal_drv_i2c1);
79+
80+
__UNUSED(dev_addr);
81+
__UNUSED(mem_addr);
82+
__UNUSED(txdata);
83+
__UNUSED(size);
84+
// 具体的i2c底层
85+
86+
EK_HAL_LOCK_OFF(&hal_drv_i2c1);
87+
88+
return true;
89+
}
90+
91+
static bool
92+
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)
93+
{
94+
if (EK_HAL_LOCK_TEST(&hal_drv_i2c1) == true) return false;
95+
96+
// uint16_t msize = (mem_size == EK_HAL_I2C_MEM_8B) ? I2C_MEMADD_SIZE_8BIT : I2C_MEMADD_SIZE_16BIT;
97+
// msize 来判断从机设备长度
98+
99+
EK_HAL_LOCK_ON(&hal_drv_i2c1);
100+
101+
__UNUSED(dev_addr);
102+
__UNUSED(mem_addr);
103+
__UNUSED(rxdata);
104+
__UNUSED(size);
105+
// 具体的i2c底层
106+
107+
EK_HAL_LOCK_OFF(&hal_drv_i2c1);
108+
109+
return true;
110+
}
111+
112+
void ek_hal_i2c_init(void)
113+
{
114+
ek_list_init(&ek_hal_i2c_head);
115+
116+
ek_list_add_tail(&ek_hal_i2c_head, &hal_drv_i2c1.node);
117+
}
118+
119+
EK_EXPORT(ek_hal_i2c_init, 0);

L2_Core/hal/src/ek_hal_spi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#define EK_HAL_LOCK_OFF(x) ((x)->lock = false)
77
#define EK_HAL_LOCK_TEST(x) ((x)->lock == true)
88

9-
#define STM32F429XX_TIMEOUT (100)
10-
119
ek_list_node_t ek_hal_spi_head;
1210

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

5553
__UNUSED(rxdata);
5654
__UNUSED(size);
55+
// 具体的spi底层
5756

5857
EK_HAL_LOCK_OFF(&hal_drv_spi1);
5958

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

7373
EK_HAL_LOCK_OFF(&hal_drv_spi1);
7474

0 commit comments

Comments
 (0)