diff --git "a/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day1/\345\261\217\345\271\225\346\210\252\345\233\276 2025-08-06 153922.png" "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day1/\345\261\217\345\271\225\346\210\252\345\233\276 2025-08-06 153922.png" new file mode 100644 index 0000000000000000000000000000000000000000..93603cbb9c351bf0dbfb3e6b86406a0110f81cdd Binary files /dev/null and "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day1/\345\261\217\345\271\225\346\210\252\345\233\276 2025-08-06 153922.png" differ diff --git "a/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day1/\345\261\217\345\271\225\346\210\252\345\233\276 2025-08-06 160353.png" "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day1/\345\261\217\345\271\225\346\210\252\345\233\276 2025-08-06 160353.png" new file mode 100644 index 0000000000000000000000000000000000000000..5177bb20bdebc2061c78f4819fa7d31cbb44789b Binary files /dev/null and "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day1/\345\261\217\345\271\225\346\210\252\345\233\276 2025-08-06 160353.png" differ diff --git "a/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day1/\345\261\217\345\271\225\346\210\252\345\233\276 2025-08-06 160358.png" "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day1/\345\261\217\345\271\225\346\210\252\345\233\276 2025-08-06 160358.png" new file mode 100644 index 0000000000000000000000000000000000000000..01c9c5b4578cb86a4c6c3acf454b578c89a8aa2f Binary files /dev/null and "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day1/\345\261\217\345\271\225\346\210\252\345\233\276 2025-08-06 160358.png" differ diff --git "a/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day1/\345\261\217\345\271\225\346\210\252\345\233\276 2025-08-06 184325.png" "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day1/\345\261\217\345\271\225\346\210\252\345\233\276 2025-08-06 184325.png" new file mode 100644 index 0000000000000000000000000000000000000000..bfd24dcc10b661db0747a9d735b7e6940399ed5d Binary files /dev/null and "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day1/\345\261\217\345\271\225\346\210\252\345\233\276 2025-08-06 184325.png" differ diff --git "a/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day2/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232.c" "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day2/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232.c" new file mode 100644 index 0000000000000000000000000000000000000000..9fa45a170bde29258dadb55c3ed26aaf9c516feb --- /dev/null +++ "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day2/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232.c" @@ -0,0 +1,55 @@ +#include +#include +#include + + +rt_thread_t thread1; +rt_thread_t thread2; +rt_thread_t thread3; + +void thread1_task(void*parm) +{ + while(1) + { + rt_kprintf("run the thread1\r\n"); + rt_thread_delay(1000); + } +} +void thread2_task(void*parm) +{ + while(1) + { + rt_kprintf("run the thread2\r\n"); + rt_thread_delay(500); + } +} +void thread3_task(void*parm) +{ + while(1) + { + rt_kprintf("run the thread3\r\n"); + rt_thread_delay(500); + } +} + +int main(void) +{ + + thread1 = rt_thread_create("thread1", thread1_task, RT_NULL, 1024, 4, 10); + thread2 = rt_thread_create("thread2", thread2_task, RT_NULL, 1024, 5, 10); + thread3 = rt_thread_create("thread3", thread3_task, RT_NULL, 1024, 5 ,10); + + if(thread1 !=RT_NULL) + { + rt_thread_startup(thread1); + } + if(thread2 !=RT_NULL) + { + rt_thread_startup(thread2); + } + if(thread3 !=RT_NULL) + { + rt_thread_startup(thread3); + } + return RT_EOK; +} diff --git "a/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/event.c" "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/event.c" new file mode 100644 index 0000000000000000000000000000000000000000..f0d78d5bd62fbd488cd53914c328d198ccbddcc2 --- /dev/null +++ "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/event.c" @@ -0,0 +1,55 @@ +#include "board.h" +#include "rtthread.h" + +static rt_thread_t thread1 = RT_NULL; +static rt_thread_t thread2 = RT_NULL; +static rt_event_t test_event = RT_NULL; + +#define KEY1_EVENT (0x01 << 0) +#define KEY2_EVENT (0x01 << 1) + +static void thread1_entry(void* parm) { + rt_uint32_t recv; + while (1) { + rt_event_recv(test_event, + KEY1_EVENT | KEY2_EVENT, + RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, + RT_WAITING_FOREVER, + &recv); + + if (recv & KEY1_EVENT) LED1_TOGGLE; + if (recv & KEY2_EVENT) LED1_TOGGLE; + } +} + +static void thread2_entry(void* parm) { + while (1) { + if (Key_Scan(KEY1_GPIO_PORT, KEY1_GPIO_PIN) == KEY_ON) { + rt_kprintf("key1 pressed\n"); + rt_event_send(test_event, KEY1_EVENT); + } + if (Key_Scan(KEY2_GPIO_PORT, KEY2_GPIO_PIN) == KEY_ON) { + rt_kprintf("key2 pressed\n"); + rt_event_send(test_event, KEY2_EVENT); + } + rt_thread_delay(20); + } +} + +int main(void) { + test_event = rt_event_create("test_event", RT_IPC_FLAG_PRIO); + if (!test_event) { + rt_kprintf("Event creation failed\n"); + return -1; + } + + thread1 = rt_thread_create("thread1", thread1_entry, RT_NULL, + 1024, 3, 20); + thread2 = rt_thread_create("thread2", thread2_entry, RT_NULL, + 1024, 2, 20); + + if (thread1) rt_thread_startup(thread1); + if (thread2) rt_thread_startup(thread2); + + return 0; +} diff --git "a/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/mailbox.c" "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/mailbox.c" new file mode 100644 index 0000000000000000000000000000000000000000..0cce8c47c83c04422ffaf86269d268ee18788da0 --- /dev/null +++ "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/mailbox.c" @@ -0,0 +1,47 @@ +#include "board.h" +#include "rtthread.h" + +static rt_thread_t thread1 = RT_NULL; +static rt_thread_t thread2 = RT_NULL; +static rt_mailbox_t test_mb = RT_NULL; + +static const char test_str[] = "Mailbox test message\n"; + +static void thread1_entry(void* parm) { + char* r_str; + while (1) { + if (rt_mb_recv(test_mb, (rt_ubase_t*)&r_str, 1000) == RT_EOK) { + rt_kprintf("Received: %s", r_str); + } + rt_thread_delay(200); + } +} + +static void thread2_entry(void* parm) { + while (1) { + if (Key_Scan(KEY1_GPIO_PORT, KEY1_GPIO_PIN) == KEY_ON) { + if (rt_mb_send(test_mb, (rt_ubase_t)test_str) != RT_EOK) { + rt_kprintf("Mail send failed\n"); + } + rt_thread_delay(20); + } + } +} + +int main(void) { + test_mb = rt_mb_create("test_mb", 10, RT_IPC_FLAG_FIFO); + if (!test_mb) { + rt_kprintf("Mailbox creation failed\n"); + return -1; + } + + thread1 = rt_thread_create("thread1", thread1_entry, RT_NULL, + 1024, 5, 20); + thread2 = rt_thread_create("thread2", thread2_entry, RT_NULL, + 1024, 3, 20); + + if (thread1) rt_thread_startup(thread1); + if (thread2) rt_thread_startup(thread2); + + return 0; +} \ No newline at end of file diff --git "a/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/mutex.c" "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/mutex.c" new file mode 100644 index 0000000000000000000000000000000000000000..0a8e945a04668c57a7845f0498fbec1aaa0c1825 --- /dev/null +++ "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/mutex.c" @@ -0,0 +1,48 @@ +#include "board.h" +#include "rtthread.h" + +static rt_thread_t thread1 = RT_NULL; +static rt_thread_t thread2 = RT_NULL; +static rt_mutex_t test_mutex = RT_NULL; + +static int shared_data[2] = {0, 0}; + +static void thread1_entry(void* parm) { + while (1) { + rt_mutex_take(test_mutex, RT_WAITING_FOREVER); + if (shared_data[0] == shared_data[1]) { + rt_kprintf("Data consistent: %d\n", shared_data[0]); + } + rt_mutex_release(test_mutex); + rt_thread_delay(1000); + } +} + +static void thread2_entry(void* parm) { + while (1) { + rt_mutex_take(test_mutex, RT_WAITING_FOREVER); + shared_data[0]++; + rt_thread_delay(100); + shared_data[1]++; + rt_mutex_release(test_mutex); + rt_thread_yield(); + } +} + +int main(void) { + test_mutex = rt_mutex_create("test_mutex", RT_IPC_FLAG_FIFO); + if (!test_mutex) { + rt_kprintf("Mutex creation failed\n"); + return -1; + } + + thread1 = rt_thread_create("thread1", thread1_entry, RT_NULL, + 1024, 3, 20); + thread2 = rt_thread_create("thread2", thread2_entry, RT_NULL, + 1024, 5, 20); + + if (thread1) rt_thread_startup(thread1); + if (thread2) rt_thread_startup(thread2); + + return 0; +} \ No newline at end of file diff --git "a/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/queue.c" "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/queue.c" new file mode 100644 index 0000000000000000000000000000000000000000..5f84cd81e0cb1793fa60858c82fb80f86caf6ce6 --- /dev/null +++ "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/queue.c" @@ -0,0 +1,47 @@ +#include "board.h" +#include "rtthread.h" + +static rt_thread_t thread1 = RT_NULL; +static rt_thread_t thread2 = RT_NULL; +static rt_mq_t test_mq = RT_NULL; + +static void thread1_entry(void* parm) { + uint32_t rev_data; + while (1) { + if (rt_mq_recv(test_mq, &rev_data, sizeof(rev_data), 100) == RT_EOK) { + rt_kprintf("Received data: %d\n", rev_data); + } + rt_thread_delay(200); + } +} + +static void thread2_entry(void* parm) { + static uint32_t send_data = 1; + while (1) { + if (Key_Scan(KEY1_GPIO_PORT, KEY1_GPIO_PIN) == KEY_ON) { + if (rt_mq_send(test_mq, &send_data, sizeof(send_data)) != RT_EOK) { + rt_kprintf("Queue send failed\n"); + } + send_data++; + rt_thread_delay(20); + } + } +} + +int main(void) { + test_mq = rt_mq_create("test_mq", sizeof(uint32_t), 20, RT_IPC_FLAG_FIFO); + if (!test_mq) { + rt_kprintf("Message queue creation failed\n"); + return -1; + } + + thread1 = rt_thread_create("thread1", thread1_entry, RT_NULL, + 1024, 5, 20); + thread2 = rt_thread_create("thread2", thread2_entry, RT_NULL, + 1024, 3, 20); + + if (thread1) rt_thread_startup(thread1); + if (thread2) rt_thread_startup(thread2); + + return 0; +} \ No newline at end of file diff --git "a/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/sem.c" "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/sem.c" new file mode 100644 index 0000000000000000000000000000000000000000..eb87b04844a5f53ae3e380bd5851c6eb1a3ffffe --- /dev/null +++ "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/sem.c" @@ -0,0 +1,48 @@ +#include "board.h" +#include "rtthread.h" + +static rt_thread_t thread1 = RT_NULL; +static rt_thread_t thread2 = RT_NULL; +static rt_sem_t test_sem = RT_NULL; + +static int shared_data[2] = {0, 0}; + +static void thread1_entry(void* parm) { + while (1) { + rt_sem_take(test_sem, RT_WAITING_FOREVER); + if (shared_data[0] == shared_data[1]) { + rt_kprintf("Data consistent: %d\n", shared_data[0]); + } + rt_sem_release(test_sem); + rt_thread_delay(1000); + } +} + +static void thread2_entry(void* parm) { + while (1) { + rt_sem_take(test_sem, RT_WAITING_FOREVER); + shared_data[0]++; + rt_thread_delay(100); + shared_data[1]++; + rt_sem_release(test_sem); + rt_thread_yield(); + } +} + +int main(void) { + test_sem = rt_sem_create("test_sem", 1, RT_IPC_FLAG_FIFO); + if (!test_sem) { + rt_kprintf("Semaphore creation failed\n"); + return -1; + } + + thread1 = rt_thread_create("thread1", thread1_entry, RT_NULL, + 1024, 5, 20); + thread2 = rt_thread_create("thread2", thread2_entry, RT_NULL, + 1024, 3, 20); + + if (thread1) rt_thread_startup(thread1); + if (thread2) rt_thread_startup(thread2); + + return 0; +} \ No newline at end of file diff --git "a/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/signal.c" "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/signal.c" new file mode 100644 index 0000000000000000000000000000000000000000..47dff50df2a8e01722e71b493c06fbab141ffd58 --- /dev/null +++ "b/2025/\347\254\2541\347\273\204(STM32H750-ART-PI)/\347\250\213\345\207\257/Day3/signal.c" @@ -0,0 +1,46 @@ +#include "board.h" +#include "rtthread.h" + +#define SIG_USER 0x01 + +static rt_thread_t thread1 = RT_NULL; +static rt_thread_t thread2 = RT_NULL; + +static void signal_handler(int sig) { + rt_kprintf("Thread %s received signal %d\n", rt_thread_self()->name, sig); +} + +static void thread1_entry(void* parm) { + rt_signal_install(SIG_USER, signal_handler); + rt_signal_unmask(SIG_USER); + + while (1) { + rt_thread_delay(500); + } +} + +static void thread2_entry(void* parm) { + rt_signal_install(SIG_USER, SIG_IGN); + rt_signal_unmask(SIG_USER); + + while (1) { + rt_thread_delay(500); + } +} + +int main(void) { + thread1 = rt_thread_create("thread1", thread1_entry, RT_NULL, + 1024, 4, 20); + thread2 = rt_thread_create("thread2", thread2_entry, RT_NULL, + 1024, 6, 20); + + if (thread1) rt_thread_startup(thread1); + if (thread2) rt_thread_startup(thread2); + + rt_thread_delay(100); + + rt_thread_kill(thread1, SIG_USER); + rt_thread_kill(thread2, SIG_USER); + + return 0; +} \ No newline at end of file