diff --git "a/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\345\210\230\344\277\212\351\272\237/\344\273\243\347\240\201/day2.c" "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\345\210\230\344\277\212\351\272\237/\344\273\243\347\240\201/day2.c" new file mode 100644 index 0000000000000000000000000000000000000000..8380f221318f076c0275987b37a33cb65e417a3b --- /dev/null +++ "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\345\210\230\344\277\212\351\272\237/\344\273\243\347\240\201/day2.c" @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-11-06 SummerGift first version + * 2018-11-19 flybreak add stm32f407-atk-explorer bsp + */ + +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-11-06 SummerGift first version + * 2018-11-19 flybreak add stm32f407-atk-explorer bsp + */ + +#include +#include +#include + +/* defined the LED0 pin: PF9 */ +#define LED0_PIN GET_PIN(F, 9) +void usr_thread(void){ + + while(1){ + rt_kprintf("1111\n"); + } +} +void usr_thread2(void){ + + while(1){ + rt_kprintf("2222\n"); + } +} +void usr_thread3(void){ + int i=0; + int j = 0; + while(1){ + rt_kprintf("33333333333\n"); + + i++; + if(i==1000){ + j++; + i=0; + } + else if(j==10) { + return 0; + } + } +} + + +rt_thread_t tid =RT_NULL; +rt_thread_t tid2 =RT_NULL; +rt_thread_t tid3 =RT_NULL; +int main(void) +{ + tid = rt_thread_create("usr1",usr_thread, RT_NULL, 1024, 11, 5); + + if(tid!=RT_NULL){ + rt_thread_startup(tid); + rt_thread_delay(rt_tick_from_millisecond(500)); + } + tid2 = rt_thread_create("usr2",usr_thread2, RT_NULL, 1024,11, 5); + if(tid2!=RT_NULL){ + rt_thread_startup(tid2); + rt_thread_delay(rt_tick_from_millisecond(500)); + } + tid3 = rt_thread_create("usr3",usr_thread3, RT_NULL, 1024,4, 5); + if(tid3!=RT_NULL){ + rt_thread_startup(tid3); + } + rt_kprintf("run in mainthread\n"); + + return RT_EOK; +} diff --git "a/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\345\210\230\344\277\212\351\272\237/\344\273\243\347\240\201/day3_rt_mutex_create.c" "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\345\210\230\344\277\212\351\272\237/\344\273\243\347\240\201/day3_rt_mutex_create.c" new file mode 100644 index 0000000000000000000000000000000000000000..25f7bf651d2f796f323ca0717a13e389e3e8868b --- /dev/null +++ "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\345\210\230\344\277\212\351\272\237/\344\273\243\347\240\201/day3_rt_mutex_create.c" @@ -0,0 +1,49 @@ +#include + +rt_mutex_t mutex; // 定义一个互斥量 + +// 线程1入口函数 +void thread1_entry(void *parameter) +{ + while (1) + { + rt_mutex_take(mutex, RT_WAITING_FOREVER); // 获取互斥量 + rt_kprintf("1111111111\n"); + rt_thread_mdelay(1000); // 模拟临界区操作 + rt_mutex_release(mutex); // 释放互斥量 + + } +} + +// 线程2入口函数 +void thread2_entry(void *parameter) +{ + while (1) + { + rt_mutex_take(mutex, RT_WAITING_FOREVER); // 获取互斥量 + rt_kprintf("222222222222\n"); + rt_mutex_release(mutex); // 释放互斥量 + + } +} + +// 主函数 +int main(void) +{ + // 初始化互斥量 + mutex = rt_mutex_create("simple_mutex", RT_IPC_FLAG_FIFO); + if (mutex == RT_NULL) + { + rt_kprintf("Mutex create failed\n"); + return -1; + } + + // 创建线程1和线程2 + rt_thread_t tid1 = rt_thread_create("thread1", thread1_entry, RT_NULL, 512, 10, 10); + rt_thread_t tid2 = rt_thread_create("thread2", thread2_entry, RT_NULL, 512, 10, 10); + + if (tid1 != RT_NULL) rt_thread_startup(tid1); + if (tid2 != RT_NULL) rt_thread_startup(tid2); + + return 0; +} diff --git "a/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\345\210\230\344\277\212\351\272\237/\344\273\243\347\240\201/day3_rt_sem_create.c" "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\345\210\230\344\277\212\351\272\237/\344\273\243\347\240\201/day3_rt_sem_create.c" new file mode 100644 index 0000000000000000000000000000000000000000..3b14b11a6bac5480ec5671187140d2164da52790 --- /dev/null +++ "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\345\210\230\344\277\212\351\272\237/\344\273\243\347\240\201/day3_rt_sem_create.c" @@ -0,0 +1,77 @@ +#include + +/* 定义信号量 */ +static rt_sem_t test_sem = RT_NULL; + +/* 任务1:释放信号量 */ +static void thread1_send(void *parameter) +{ + rt_uint32_t count = 0; + + while (1) + { + count++; + rt_kprintf("Thread1: send signal %d\n", count); + + /* 释放信号量 */ + rt_sem_release(test_sem); + + /* 延时2秒 */ + rt_thread_mdelay(2000); + } +} + +/* 任务2:等待信号量 */ +static void thread2_recv(void *parameter) +{ + rt_err_t result; + + while (1) + { + /* 等待信号量,最多等待5秒 */ + result = rt_sem_take(test_sem, 5000); + + if (result == RT_EOK) + { + rt_kprintf("Thread2: received signal\n"); + } + else + { + rt_kprintf("Thread2: wait timeout\n"); + } + } +} + +/* 主函数 */ +int main(void) +{ + rt_thread_t tid1, tid2; + + /* 创建信号量,初始值为0 */ + test_sem = rt_sem_create("test_sem", 0, RT_IPC_FLAG_FIFO); + if (test_sem == RT_NULL) + { + rt_kprintf("Create semaphore failed!\n"); + return -1; + } + + /* 创建线程1 */ + tid1 = rt_thread_create("thread1", + thread1_send, + RT_NULL, + 1024, + 20, 10); + if (tid1 != RT_NULL) + rt_thread_startup(tid1); + + /* 创建线程2 */ + tid2 = rt_thread_create("thread2", + thread2_recv, + RT_NULL, + 1024, + 21, 10); + if (tid2 != RT_NULL) + rt_thread_startup(tid2); + + return 0; +} \ No newline at end of file diff --git "a/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\345\210\230\344\277\212\351\272\237/\347\254\224\350\256\260/day1.md" "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\345\210\230\344\277\212\351\272\237/\347\254\224\350\256\260/day1.md" new file mode 100644 index 0000000000000000000000000000000000000000..e030990f3f4ecbe24f6f0753bd967c4f91f97620 --- /dev/null +++ "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\345\210\230\344\277\212\351\272\237/\347\254\224\350\256\260/day1.md" @@ -0,0 +1,31 @@ +# 初始化仓库(在项目文件夹内执行) +git init + +# 查看仓库状态 +git status + +# 添加文件到暂存区 +git add <文件名> # 添加单个文件 + +git add . # 添加所有修改 + +# 提交到本地仓库 +git commit -m "提交说明" + +# 查看提交历史 +git log + +# 查看所有分支 +git branch -a + +# 创建并切换到新分支 +git switch -c <分支名> # 推荐新写法 + +# 切换分支 +git switch <分支名> + +# 删除分支 +git branch -d <分支名> + +# 远端推送 +git push origin ljl \ No newline at end of file