diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/.keep" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/e6cc63163ecb62e0f1fe6ac4b45dc54.jpg" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/e6cc63163ecb62e0f1fe6ac4b45dc54.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..5520325418ea474ccf21667690edc4c51fe34691 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/e6cc63163ecb62e0f1fe6ac4b45dc54.jpg" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\344\275\234\344\270\232/.keep" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\344\275\234\344\270\232/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\224\350\256\260/.keep" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\224\350\256\260/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\224\350\256\260/1ac677698b148c859a22a14daeb618d.jpg" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\224\350\256\260/1ac677698b148c859a22a14daeb618d.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..eb7436a8ae32912c2089f8b86018db5e9dbbf0f1 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\224\350\256\260/1ac677698b148c859a22a14daeb618d.jpg" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\224\350\256\260/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260.md" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\224\350\256\260/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..d6fe13001f64280d836c35455c54608e85bdaabe --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\224\350\256\260/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260.md" @@ -0,0 +1,7 @@ +# 笔记 + +## 大部分都是截图 + +## 信号量 + +![输入图片说明](1ac677698b148c859a22a14daeb618d.jpg) \ No newline at end of file diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/event.c" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/event.c" new file mode 100644 index 0000000000000000000000000000000000000000..4545e4baa6b0f61d1e0097a2e7fda730d6f4f419 --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/event.c" @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2006-2022, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-08-24 yangjie the first version + */ + + +#include + +#define THREAD_PRIORITY 9 +#define THREAD_TIMESLICE 5 + +#define EVENT_FLAG3 (1 << 3) +#define EVENT_FLAG5 (1 << 5) + +/* 事件控制块 */ +static struct rt_event event; + +static void event_recv_thread(void *param) +{ + rt_uint32_t recved; + + while(1) { + // 等待任一事件发生(逻辑或) + rt_event_recv(event, + (EVENT_FLAG1 | EVENT_FLAG2), // 等待的事件集合 + RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, // 逻辑或+清除事件 + RT_WAITING_FOREVER, + &recved); + + rt_kprintf("收到事件: %s\n", + recved & EVENT_FLAG1 ? "EVENT1" : + recved & EVENT_FLAG2 ? "EVENT2" : "UNKNOWN"); + } +} + +/* 事件发送线程 */ +static void event_send_thread(void *param) +{ + rt_uint8_t flag = 0; + + while(1) { + flag = !flag; + if (flag) { + rt_event_send(event, EVENT_FLAG1); + rt_kprintf("发送事件1\n"); + } else { + rt_event_send(event, EVENT_FLAG2); + rt_kprintf("发送事件2\n"); + } + rt_thread_mdelay(1000); + } +} + +int event_demo(void) +{ + // 创建事件集 + event = rt_event_create("evt", RT_IPC_FLAG_FIFO); + + rt_thread_t recv = rt_thread_create("recv", event_recv_thread, RT_NULL, + 512, 25, 10); + rt_thread_t send = rt_thread_create("send", event_send_thread, RT_NULL, + 512, 26, 10); + + rt_thread_startup(recv); + rt_thread_startup(send); + + return 0; +} + + +/* 导出到 msh 命令列表中 */ +MSH_CMD_EXPORT(event_demo, event sample); diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/mailbox.c" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/mailbox.c" new file mode 100644 index 0000000000000000000000000000000000000000..8f5e50b685447b111bb80635d7fccc8a02696ee7 --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/mailbox.c" @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2006-2022, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-08-24 yangjie the first version + */ + + +#include + +/* 自定义消息结构 */ +struct msg { + rt_uint8_t id; + rt_uint32_t value; + char text[16]; +}; + +static rt_mailbox_t mb; // 邮箱指针 + +/* 邮件发送线程 */ +static void send_thread_entry(void *parameter) +{ + struct msg *mail; + static rt_uint8_t count = 0; + + while (1) { + // 动态分配邮件内存 + mail = (struct msg *)rt_malloc(sizeof(struct msg)); + mail->id = count; + mail->value = count * 10; + rt_snprintf(mail->text, sizeof(mail->text), "Mail-%d", count); + + // 发送邮件(传递指针) + rt_mb_send(mb, (rt_ubase_t)mail); + rt_kprintf("发送邮件: id=%d, value=%d, text=%s\n", + mail->id, mail->value, mail->text); + + count++; + rt_thread_mdelay(800); + } +} + +/* 邮件接收线程 */ +static void recv_thread_entry(void *parameter) +{ + struct msg *mail; + + while (1) { + // 接收邮件(阻塞等待) + rt_mb_recv(mb, (rt_ubase_t *)&mail, RT_WAITING_FOREVER); + + rt_kprintf("接收邮件: id=%d, value=%d, text=%s\n", + mail->id, mail->value, mail->text); + + rt_free(mail); // 释放邮件内存 + } +} + +int mailbox_demo(void) +{ + // 创建邮箱(容量为4条消息) + mb = rt_mb_create("mbt", 4, RT_IPC_FLAG_FIFO); + + rt_thread_t send_thread = rt_thread_create("send", send_thread_entry, RT_NULL, + 512, 25, 10); + rt_thread_t recv_thread = rt_thread_create("recv", recv_thread_entry, RT_NULL, + 512, 26, 10); + + rt_thread_startup(send_thread); + rt_thread_startup(recv_thread); + + return 0; +} + +/* 导出到 msh 命令列表中 */ +MSH_CMD_EXPORT(mailbox_demo, mailbox sample); diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/message_queue.c" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/message_queue.c" new file mode 100644 index 0000000000000000000000000000000000000000..941b7d4541156b1bdcbe0c76fac19b510bea037b --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/message_queue.c" @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2006-2022, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-08-24 yangjie the first version + */ + + +#include + +#define THREAD_PRIORITY 25 +#define THREAD_TIMESLICE 5 + +#define RT_VERSION_CHECK(major, minor, revise) ((major * 10000) + (minor * 100) + revise) + +/* 消息队列控制块 */ +static rt_mq_t mq; + +/* 消息发送线程 */ +static void mq_send_thread(void *param) +{ + char buf[MQ_MSG_SIZE]; + rt_uint8_t count = 0; + + while(1) { + // 格式化消息内容 + rt_snprintf(buf, sizeof(buf), "Message-%d", count++); + + // 发送消息(非阻塞方式) + if (rt_mq_send(mq, buf, sizeof(buf)) == RT_EOK) { + rt_kprintf("发送消息: %s\n", buf); + } else { + rt_kprintf("消息队列已满!\n"); + } + + rt_thread_mdelay(500); + } +} + +/* 消息接收线程 */ +static void mq_recv_thread(void *param) +{ + char rbuf[MQ_MSG_SIZE]; + + while(1) { + // 接收消息(阻塞等待) + if (rt_mq_recv(mq, rbuf, sizeof(rbuf), RT_WAITING_FOREVER) > 0) { + rt_kprintf("接收消息: %s\n", rbuf); + } + } +} + +int message_queue_demo(void) +{ + // 创建消息队列 + mq = rt_mq_create("mq", MQ_MSG_SIZE, MQ_MAX_MSGS, RT_IPC_FLAG_FIFO); + + rt_thread_t send = rt_thread_create("send", mq_send_thread, RT_NULL, + 512, 25, 10); + rt_thread_t recv = rt_thread_create("recv", mq_recv_thread, RT_NULL, + 512, 26, 10); + + rt_thread_startup(send); + rt_thread_startup(recv); + + return 0; +} + + +/* 导出到 msh 命令列表中 */ +MSH_CMD_EXPORT(message_queue_demo, msgq sample); diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/mutex.c" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/mutex.c" new file mode 100644 index 0000000000000000000000000000000000000000..f88b04c30a95aec2b35d1e47c524c92ce6b97f3b --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/mutex.c" @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2006-2022, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-08-24 yangjie the first version + */ + + +#include + +#define THREAD_PRIORITY 8 +#define THREAD_TIMESLICE 5 + +/* 指向互斥量的指针 */ +static rt_mutex_t mutex; +static rt_uint8_t number = 0; // 共享资源 + +/* 低优先级线程 */ +static void low_priority_thread(void *param) +{ + while(1) { + rt_mutex_take(mutex, RT_WAITING_FOREVER); // 获取互斥锁 + number++; + rt_kprintf("低优先级线程: number=%d\n", number); + rt_thread_mdelay(500); // 模拟长时间操作 + rt_mutex_release(mutex); // 释放互斥锁 + rt_thread_mdelay(10); + } +} + +/* 高优先级线程 */ +static void high_priority_thread(void *param) +{ + while(1) { + rt_mutex_take(mutex, RT_WAITING_FOREVER); + number++; + rt_kprintf("高优先级线程: number=%d\n", number); + rt_mutex_release(mutex); + rt_thread_mdelay(300); + } +} + +int mutex_demo(void) +{ + // 创建互斥量 + mutex = rt_mutex_create("mtx", RT_IPC_FLAG_FIFO); + + // 创建线程(注意优先级设置) + rt_thread_t low = rt_thread_create("low", low_priority_thread, RT_NULL, + 1024, 20, 10); + rt_thread_t high = rt_thread_create("high", high_priority_thread, RT_NULL, + 1024, 19, 10); + + rt_thread_startup(low); + rt_thread_startup(high); + + return 0; +} +/* 导出到 msh 命令列表中 */ +MSH_CMD_EXPORT(mutex_demo, mutex sample); diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/sem.c" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/sem.c" new file mode 100644 index 0000000000000000000000000000000000000000..b46c47b1facf9e94f4f8b6d06b72f8669dd403fd --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/sem.c" @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2006-2022, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-08-24 yangjie the first version + */ + + +#include + +#define THREAD_PRIORITY 25 +#define THREAD_TIMESLICE 5 + +/* 指向信号量的指针 */ +static rt_sem_t dynamic_sem = RT_NULL; + + + + +static void producer_thread_entry(void *parameter) +{ + static rt_uint8_t count = 0; + + while (1) + { + rt_kprintf("count=%d\n", count++); + rt_sem_release(dynamic_sem); + rt_thread_mdelay(100); + } +} + + +static void consumer_thread_entry(void *parameter) +{ + while (1) + { + rt_sem_take(dynamic_sem, RT_WAITING_FOREVER); + rt_kprintf("+1\n"); + } +} + +/* 信号量示例的初始化 */ +int semaphore_demo(void) +{ + // 创建动态信号量,初始值为0(没有可用资源) + dynamic_sem = rt_sem_create("dsem", 0, RT_IPC_FLAG_FIFO); + + // 创建生产者线程(优先级较低) + rt_thread_t producer = rt_thread_create("producer", + producer_thread_entry, RT_NULL, + 512, THREAD_PRIORITY+1, THREAD_TIMESLICE); + + // 创建消费者线程(优先级较高) + rt_thread_t consumer = rt_thread_create("consumer", + consumer_thread_entry, RT_NULL, + 512, THREAD_PRIORITY, THREAD_TIMESLICE); + + // 启动线程 + rt_thread_startup(producer); + rt_thread_startup(consumer); + + return 0; +} + +/* 导出到 msh 命令列表中 */ +MSH_CMD_EXPORT(semaphore_demo, semaphore sample); + diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/signal.c" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/signal.c" new file mode 100644 index 0000000000000000000000000000000000000000..91d108aa2d6fb03d93bb2fd2beea29ea88f8d558 --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/signal.c" @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2006-2022, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-08-24 yangjie the first version + */ + + +#include + +static rt_thread_t tid = RT_NULL; + +/* 信号处理函数 */ +void signal_handler(int sig) +{ + rt_kprintf("!!! 信号处理函数执行: 收到信号 %d\n", sig); +} + +/* 信号接收线程 */ +static void signal_recv_thread(void *param) +{ + // 安装信号处理函数 + rt_signal_install(SIGUSR1, signal_handler); + rt_signal_install(SIGUSR2, signal_handler); + + rt_kprintf("信号接收线程启动\n"); + + while(1) { + rt_kprintf("接收线程正常运行...\n"); + rt_thread_mdelay(2000); + } +} + +/* 信号发送线程 */ +static void signal_send_thread(void *param) +{ + rt_thread_mdelay(3000); // 等待接收线程启动 + + while(1) { + rt_kprintf("\n发送信号 SIGUSR1\n"); + rt_signal_kill(tid, SIGUSR1); + + rt_thread_mdelay(4000); + + rt_kprintf("\n发送信号 SIGUSR2\n"); + rt_signal_kill(tid, SIGUSR2); + + rt_thread_mdelay(4000); + } +} + +int signal_demo(void) +{ + // 创建接收线程 + tid = rt_thread_create("recv", signal_recv_thread, RT_NULL, + 512, 25, 10); + + // 创建发送线程 + rt_thread_t send = rt_thread_create("send", signal_send_thread, RT_NULL, + 512, 26, 10); + + rt_thread_startup(tid); + rt_thread_startup(send); + + return 0; +} + +/* 导出到 msh 命令列表中 */ +MSH_CMD_EXPORT(signal_demo, signal sample); diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/\347\224\250\344\272\206\344\270\200\347\202\271\347\202\271ai\350\276\205\345\212\251.txt" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/\347\224\250\344\272\206\344\270\200\347\202\271\347\202\271ai\350\276\205\345\212\251.txt" new file mode 100644 index 0000000000000000000000000000000000000000..ad9cb8bace82ee040ce31580ed9c27615832f886 --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/\347\224\250\344\272\206\344\270\200\347\202\271\347\202\271ai\350\276\205\345\212\251.txt" @@ -0,0 +1 @@ +QAQ \ No newline at end of file diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/1ac677698b148c859a22a14daeb618d.jpg" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/1ac677698b148c859a22a14daeb618d.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..eb7436a8ae32912c2089f8b86018db5e9dbbf0f1 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/1ac677698b148c859a22a14daeb618d.jpg" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/22bd16cdef716095a6e92186e2ec40f.jpg" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/22bd16cdef716095a6e92186e2ec40f.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..e06813588a43e7642387411e8360e28c70f84237 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/22bd16cdef716095a6e92186e2ec40f.jpg" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/28b2d4fd7a1ca7d4e08e87943efe896.jpg" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/28b2d4fd7a1ca7d4e08e87943efe896.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..fd7fc8a5c6f1dba5723b3c59bf0d5cb46d2d3db0 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/28b2d4fd7a1ca7d4e08e87943efe896.jpg" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/355b72983b377c454f8b8e0fe58e5cf.jpg" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/355b72983b377c454f8b8e0fe58e5cf.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..a0baf253a2a8327efd23f7dc867b972bcbb5ad08 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/355b72983b377c454f8b8e0fe58e5cf.jpg" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/45bb5e2ceb786ce88e8c339da818692.jpg" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/45bb5e2ceb786ce88e8c339da818692.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..0c1884af80fc76aaf37a008ef2d2a5219d04d8c3 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/45bb5e2ceb786ce88e8c339da818692.jpg" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/5a2000ec7dd577283c2bb822af4fe87.jpg" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/5a2000ec7dd577283c2bb822af4fe87.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..baba80c41d009c1c784b6a3168356c693cc29f3c Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/5a2000ec7dd577283c2bb822af4fe87.jpg" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/ac17c9b26d2e06da401d67bbfa82ad6.jpg" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/ac17c9b26d2e06da401d67bbfa82ad6.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..9d1d441d67f01243a75615e56090601918373ffa Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/ac17c9b26d2e06da401d67bbfa82ad6.jpg" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/ae875a1294e6c20fa6232e0867d7248.jpg" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/ae875a1294e6c20fa6232e0867d7248.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..e0e300c3244ea1fb2313666f6e0343ef225d9af2 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/ae875a1294e6c20fa6232e0867d7248.jpg" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/c61d676ccf4bf3ed0bfe985672cd109.jpg" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/c61d676ccf4bf3ed0bfe985672cd109.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..1e42614a9b7cf24e68f0dbb1cf3e79227779e4b9 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/c61d676ccf4bf3ed0bfe985672cd109.jpg" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/image.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/image.png" new file mode 100644 index 0000000000000000000000000000000000000000..ab885702286d216ea48ca0873b8233e0cd0ecc50 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/image.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/image2.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/image2.png" new file mode 100644 index 0000000000000000000000000000000000000000..1850fd7e4632aa038b59a046be4aad46d9cbe83f Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/image2.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/image3.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/image3.png" new file mode 100644 index 0000000000000000000000000000000000000000..ee7b121ff61f140c0e38d736c32767da0ed602fe Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/image3.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260.md" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..822993749da9693daa753c79bc883220948a425d --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\350\242\201\346\265\251\345\215\216/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260/\347\254\254\344\270\211\345\244\251\347\254\224\350\256\260.md" @@ -0,0 +1,335 @@ +# 笔记 + +## 信息量 + +![输入图片说明](1ac677698b148c859a22a14daeb618d.jpg) + +![输入图片说明](../e6cc63163ecb62e0f1fe6ac4b45dc54.jpg) + +### 创建和删除信号量 + + +``` + rt_sem_t rt_sem_create(const char *name, + rt_uint32_t value, + rt_uint8_t flag); + +``` + +``` +rt_err_t rt_sem_delete(rt_sem_t sem); + +``` + +### 初始化和脱离信号量 + + +``` +rt_err_t rt_sem_init(rt_sem_t sem, + const char *name, + rt_uint32_t value, + rt_uint8_t flag) + +``` + + +``` +rt_err_t rt_sem_detach(rt_sem_t sem); + +``` + +### 获取信号量 + + +``` +rt_err_t rt_sem_take (rt_sem_t sem, rt_int32_t time); + +``` + +### 无等待获取信号量 + + +``` +rt_err_t rt_sem_trytake(rt_sem_t sem); + +``` + +### 释放信号量 + +``` +rt_err_t rt_sem_release(rt_sem_t sem); + +``` + +## 互斥量 + +![输入图片说明](28b2d4fd7a1ca7d4e08e87943efe896.jpg) + +![输入图片说明](22bd16cdef716095a6e92186e2ec40f.jpg) + +![输入图片说明](45bb5e2ceb786ce88e8c339da818692.jpg) + +![输入图片说明](355b72983b377c454f8b8e0fe58e5cf.jpg) + +![输入图片说明](c61d676ccf4bf3ed0bfe985672cd109.jpg) + +### 创建和删除互斥量 + + +``` +rt_mutex_t rt_mutex_create (const char* name, rt_uint8_t flag); + +``` + +### 初始化和脱离互斥量 + + +``` +rt_err_t rt_mutex_init (rt_mutex_t mutex, const char* name, rt_uint8_t flag); + +``` + +### 获取互斥量 + + +``` +rt_err_t rt_mutex_take (rt_mutex_t mutex, rt_int32_t time); + +``` + +### 释放互斥量 + + +``` +rt_err_t rt_mutex_release(rt_mutex_t mutex); + +``` + +## 事件集 + +![输入图片说明](ae875a1294e6c20fa6232e0867d7248.jpg) + +## 消息邮箱 + +![输入图片说明](ac17c9b26d2e06da401d67bbfa82ad6.jpg) + +![输入图片说明](5a2000ec7dd577283c2bb822af4fe87.jpg) + +### 创建和删除邮箱 + + +``` +rt_mailbox_t rt_mb_create (const char* name, rt_size_t size, rt_uint8_t flag); + +``` + +``` +rt_err_t rt_mb_delete (rt_mailbox_t mb); + +``` + +### 初始化和脱离邮箱 + + + +``` + rt_err_t rt_mb_init(rt_mailbox_t mb, + const char* name, + void* msgpool, + rt_size_t size, + rt_uint8_t flag) + +``` + + +``` +rt_err_t rt_mb_detach(rt_mailbox_t mb); + +``` + + +### 发送邮件 + + + + +``` +rt_err_t rt_mb_send (rt_mailbox_t mb, rt_uint32_t value); + +``` +### 等待方式发送邮件 + + +``` +rt_err_t rt_mb_send_wait (rt_mailbox_t mb, + rt_uint32_t value, + rt_int32_t timeout); + +``` + +### 发送紧急邮件 + + +``` +rt_err_t rt_mb_urgent (rt_mailbox_t mb, rt_ubase_t value); + +``` + +### 接收邮件 + + +``` +rt_err_t rt_mb_recv (rt_mailbox_t mb, rt_uint32_t* value, rt_int32_t timeout); + +``` + +## 消息队列 + +### 消息队列的工作机制 + +![输入图片说明](image.png) + +### 消息队列控制块 + + +``` +struct rt_messagequeue +{ + struct rt_ipc_object parent; + + void* msg_pool; /* 指向存放消息的缓冲区的指针 */ + + rt_uint16_t msg_size; /* 每个消息的长度 */ + rt_uint16_t max_msgs; /* 最大能够容纳的消息数 */ + + rt_uint16_t entry; /* 队列中已有的消息数 */ + + void* msg_queue_head; /* 消息链表头 */ + void* msg_queue_tail; /* 消息链表尾 */ + void* msg_queue_free; /* 空闲消息链表 */ + + rt_list_t suspend_sender_thread; /* 发送线程的挂起等待队列 */ +}; +typedef struct rt_messagequeue* rt_mq_t; + +``` + +### 创建和删除消息队列 + +``` +rt_mq_t rt_mq_create(const char* name, rt_size_t msg_size, + rt_size_t max_msgs, rt_uint8_t flag); + +``` + +### 初始化和脱离消息队列 + + +``` +rt_err_t rt_mq_init(rt_mq_t mq, const char* name, + void *msgpool, rt_size_t msg_size, + rt_size_t pool_size, rt_uint8_t flag); + +``` + + +``` +rt_err_t rt_mq_detach(rt_mq_t mq); + +``` + +### 发送消息 + + +``` +rt_err_t rt_mq_send (rt_mq_t mq, void* buffer, rt_size_t size); + +``` + +### 等待方式发送消息 + + +``` +rt_err_t rt_mq_send_wait(rt_mq_t mq, + const void *buffer, + rt_size_t size, + rt_int32_t timeout); + +``` + +### 发送紧急消息 + + +``` +rt_err_t rt_mq_urgent(rt_mq_t mq, void* buffer, rt_size_t size); + +``` + +### 接收消息 + + +``` +rt_ssize_t rt_mq_recv (rt_mq_t mq, void* buffer, + rt_size_t size, rt_int32_t timeout); + +``` + +## 信号 + +### 信号的工作机制 + + +![输入图片说明](image2.png) + +### 信号的管理方式 + +![输入图片说明](image3.png) + +### 安装信号 + + +``` +rt_sighandler_t rt_signal_install(int signo, rt_sighandler_t[] handler); + +``` + +### 阻塞信号 + + +``` +void rt_signal_mask(int signo); + +``` + +### 解除信号阻塞 + + + +``` +void rt_signal_unmask(int signo); + +``` + +### 发送信号 + + + +``` +int rt_thread_kill(rt_thread_t tid, int sig); + +``` + +### 等待信号 + + + +``` +int rt_signal_wait(const rt_sigset_t *set, + rt_siginfo_t[] *si, rt_int32_t timeout); + +``` + + + +### +