diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232.md" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232.md" new file mode 100644 index 0000000000000000000000000000000000000000..d0dad5236f84b9c75a954bff0e645c5b4a332165 --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232.md" @@ -0,0 +1,4 @@ +1. 完成对git fork的配置 +2. 更新git和发布博客 + +[RT-Thread-【RSOC25】Day1课程笔记:环境配置RT-Thread问答社区 - RT-Thread](https://club.rt-thread.org/ask/article/0cad960cf550a11d.html) \ No newline at end of file diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\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)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/event.c" new file mode 100644 index 0000000000000000000000000000000000000000..52a8f9223688d4117f2c05bcc29d540fa70bfc2d --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/event.c" @@ -0,0 +1,78 @@ +/*信号量、互斥量、事件集、邮箱、消息队列、信号*/ + +#include "board.h" +#include "rtthread.h" + + +ALIGN(RT_ALIGN_SIZE) + +static rt_thread_t thread1 = RT_NULL; +static rt_thread_t thread2 = RT_NULL; + +static void thread1_entry(void*parm); +static void thread2_entry(void*parm); + +/* 事件TCB */ +static rt_event_t test_event; + +#define Key1_event (0x01<<0) +#define Key2_event (0x01<<1) + +int main(void) +{ + /* 创建信号量 */ + test_event = rt_event_create("test_event",RT_IPC_FLAG_PRIO); + + if(test_event !=RT_NULL) + { + rt_kprintf("create test_event\r\n"); + } + + thread1 = rt_thread_create("thread1",thread1_entry, RT_NULL, 1024, 3, 20); + + if(thread1 != RT_NULL) + { + rt_thread_startup(thread1); + } + thread2 = rt_thread_create("thread2",thread2_entry, RT_NULL, 1024, 2, 20); + + if(thread2 != RT_NULL) + { + rt_thread_startup(thread2); + } + +} + +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) ||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\r\n"); + rt_event_send(test_event, Key1_event); + } + if(Key_Scan(KEY2_GPIO_PORT, KEY2_GPIO_PIN) == KEY_ON) + { + rt_kprintf("key2\r\n"); + rt_event_send(test_event, Key2_event); + } + rt_thread_delay(20); + } +} + diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\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)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/mailbox.c" new file mode 100644 index 0000000000000000000000000000000000000000..14086fd885e0a150f6eab4eaaf9d336ec3bf53a8 --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/mailbox.c" @@ -0,0 +1,77 @@ +/*信号量、互斥量、事件集、邮箱、消息队列、信号*/ + +#include "board.h" +#include "rtthread.h" + + +ALIGN(RT_ALIGN_SIZE) + +static rt_thread_t thread1 = RT_NULL; +static rt_thread_t thread2 = RT_NULL; + +static void thread1_entry(void*parm); +static void thread2_entry(void*parm); + +/* 邮箱TCB */ +static rt_mailbox_t test_mb =RT_NULL; + +char test_str1[] = "this is mailbox test\r\n"; + +int main(void) +{ + /* 创建邮箱 */ + test_mb = rt_mb_create("test_mb", 10, RT_IPC_FLAG_FIFO); + + if(test_mb !=RT_NULL) + { + rt_kprintf("create mb\r\n"); + } + + thread1 = rt_thread_create("thread1",thread1_entry, RT_NULL, 1024, 5, 20); + + if(thread1 != RT_NULL) + { + rt_thread_startup(thread1); + } + thread2 = rt_thread_create("thread2",thread2_entry, RT_NULL, 1024, 3, 20); + + if(thread2 != RT_NULL) + { + rt_thread_startup(thread2); + } + +} + +static void thread1_entry(void*parm) +{ + rt_err_t uwRet = RT_EOK; + char* r_str ; + + while(1) + { + uwRet = rt_mb_recv(test_mb,(rt_ubase_t*)&r_str,1000); + if(uwRet == RT_EOK) + { + rt_kprintf("revice mail = %s\r\n",r_str); + } + rt_thread_delay(200); + } +} +static void thread2_entry(void*parm) +{ + rt_err_t uwRet = RT_EOK; + + while(1) + { + if(Key_Scan(KEY1_GPIO_PORT, KEY1_GPIO_PIN) == KEY_ON) + { + uwRet = rt_mb_send(test_mb, (uint32_t)&test_str1); + if(uwRet !=RT_EOK) + { + rt_kprintf("Send error %lx\r\n",uwRet); + } + rt_thread_delay(20); + } + } +} + diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\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)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/mutex.c" new file mode 100644 index 0000000000000000000000000000000000000000..71a1cac1372593edd534fa6466983e8369ed8647 --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/mutex.c" @@ -0,0 +1,72 @@ +/*信号量、互斥量、事件集、邮箱、消息队列、信号*/ + +#include "board.h" +#include "rtthread.h" + + +ALIGN(RT_ALIGN_SIZE) + +static rt_thread_t thread1 = RT_NULL; +static rt_thread_t thread2 = RT_NULL; + +static void thread1_entry(void*parm); +static void thread2_entry(void*parm); + +/* 互斥量TCB */ +static rt_mutex_t test_mutex =RT_NULL; + +char uwdata[2] = {0,0}; + +int main(void) +{ + /* 创建信号量 */ + test_mutex = rt_mutex_create("test_mutex",RT_IPC_FLAG_FIFO); + + if(test_mutex !=RT_NULL) + { + rt_kprintf("create mutex\r\n"); + } + + thread1 = rt_thread_create("thread1",thread1_entry, RT_NULL, 1024, 3, 20); + + if(thread1 != RT_NULL) + { + rt_thread_startup(thread1); + } + thread2 = rt_thread_create("thread2",thread2_entry, RT_NULL, 1024, 5, 20); + + if(thread2 != RT_NULL) + { + rt_thread_startup(thread2); + } + +} + +static void thread1_entry(void*parm) +{ + + while(1) + { + rt_mutex_take(test_mutex, RT_WAITING_FOREVER); + if(uwdata[0] == uwdata[1]) + { + rt_kprintf("successful \r\n"); + } + 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); + uwdata[0]++; + rt_thread_delay(100); + uwdata[1]++; + rt_mutex_release(test_mutex); + rt_thread_yield(); + } +} + diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/queue.c" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/queue.c" new file mode 100644 index 0000000000000000000000000000000000000000..cefae1a41bd246f8efbe63dddc3bd2a866665764 --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/queue.c" @@ -0,0 +1,76 @@ + +#include "board.h" +#include "rtthread.h" + + +ALIGN(RT_ALIGN_SIZE) + +static rt_thread_t thread1 = RT_NULL; +static rt_thread_t thread2 = RT_NULL; + +static void thread1_entry(void*parm); +static void thread2_entry(void*parm); + +/* 消息队列TCB */ +static rt_mq_t test_mq =RT_NULL; + + +int main(void) +{ + /* 创建消息队列 */ + test_mq = rt_mq_create("test_mq",40,20,RT_IPC_FLAG_FIFO); + + if(test_mq !=RT_NULL) + { + rt_kprintf("create mq\r\n"); + } + + thread1 = rt_thread_create("thread1",thread1_entry, RT_NULL, 1024, 5, 20); + + if(thread1 != RT_NULL) + { + rt_thread_startup(thread1); + } + thread2 = rt_thread_create("thread2",thread2_entry, RT_NULL, 1024, 3, 20); + + if(thread2 != RT_NULL) + { + rt_thread_startup(thread2); + } + +} + +static void thread1_entry(void*parm) +{ + rt_err_t uwRet = RT_EOK; + uint32_t rev_data = 0; + + while(1) + { + uwRet = rt_mq_recv(test_mq, &rev_data, sizeof(rev_data), 100); + if(uwRet == RT_EOK) + { + rt_kprintf("revice data = %d\r\n",rev_data); + } + rt_thread_delay(200); + } +} +static void thread2_entry(void*parm) +{ + rt_err_t uwRet = RT_EOK; + uint32_t send_data = 1; + + while(1) + { + if(Key_Scan(KEY1_GPIO_PORT, KEY1_GPIO_PIN) == KEY_ON) + { + uwRet = rt_mq_send(test_mq, &send_data, sizeof(send_data)); + if(uwRet !=RT_EOK) + { + rt_kprintf("Send error %lx\r\n",uwRet); + } + rt_thread_delay(20); + } + } +} + diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\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)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/sem.c" new file mode 100644 index 0000000000000000000000000000000000000000..f7f4d29d008251c50331644644c24a168b35572f --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/sem.c" @@ -0,0 +1,72 @@ +/*信号量、互斥量、事件集、邮箱、消息队列、信号*/ + +#include "board.h" +#include "rtthread.h" + + +ALIGN(RT_ALIGN_SIZE) + +static rt_thread_t thread1 = RT_NULL; +static rt_thread_t thread2 = RT_NULL; + +static void thread1_entry(void*parm); +static void thread2_entry(void*parm); + +/* 信号量TCB */ +static rt_sem_t test_sem =RT_NULL; + +char uwdata[2] = {0,0}; + +int main(void) +{ + /* 创建信号量 */ + test_sem = rt_sem_create("test_sem", 1, RT_IPC_FLAG_FIFO); + + if(test_sem !=RT_NULL) + { + rt_kprintf("create sem\r\n"); + } + + thread1 = rt_thread_create("thread1",thread1_entry, RT_NULL, 1024, 5, 20); + + if(thread1 != RT_NULL) + { + rt_thread_startup(thread1); + } + thread2 = rt_thread_create("thread2",thread2_entry, RT_NULL, 1024, 3, 20); + + if(thread2 != RT_NULL) + { + rt_thread_startup(thread2); + } + +} + +static void thread1_entry(void*parm) +{ + + while(1) + { + rt_sem_take(test_sem, RT_WAITING_FOREVER); + if(uwdata[0] == uwdata[1]) + { + rt_kprintf("successful \r\n"); + } + 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); + uwdata[0]++; + rt_thread_delay(100); + uwdata[1]++; + rt_sem_release(test_sem); + rt_thread_yield(); + } +} + diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\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)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/signal.c" new file mode 100644 index 0000000000000000000000000000000000000000..1a74dafc5adc4c79f260b1d7d71b7917970f9763 --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/signal.c" @@ -0,0 +1,118 @@ + + +#include +#include +#include + + + +static struct rt_thread *thread1; +static struct rt_thread *thread2; + + +void thread1_signal_handler(int sig) +{ + rt_kprintf("Thread1 received signal %d\n", sig); +} + +static void thread1_entry(void *parameter) +{ + const char *thread_name = parameter; + + rt_kprintf(thread_name); + + rt_signal_install(SIGUSR1, thread1_signal_handler); + + rt_signal_unmask(SIGUSR1); + + while(1) + { + rt_thread_mdelay(500); + } +} + + +static void thread2_entry(void *parameter) +{ + const char *thread_name = parameter; + + + rt_kprintf(thread_name); + + + rt_signal_install(SIGUSR1, SIG_IGN); + + + rt_signal_unmask(SIGUSR1); + + while(1) + { + rt_thread_mdelay(500); + } +} + +static const char *thread1_name = "Thread1 run\r\n"; +static const char *thread2_name = "Thread2 run\r\n"; + +int main(void) +{ + + thread1 = rt_thread_create("thread1", + thread1_entry, + (void *)thread1_name, + 1024, + 4, + 20); + + + if (thread1 != RT_NULL) + rt_thread_startup(thread1); + + + thread2 = rt_thread_create("thread2", + thread2_entry, + (void *)thread2_name, + 1024, + 6, + 20); + + + if (thread2 != RT_NULL) + rt_thread_startup(thread2); + + rt_thread_mdelay(100); + + rt_thread_kill(thread1, SIGUSR1); + rt_thread_kill(thread2, SIGUSR1); + + + return 0; +} + + + +#include "app_esp8266.h" +#include +#include +#include + + +int Set_esp8266(void) +{ + rt_pin_mode(GET_PIN(B,8), PIN_MODE_OUTPUT); + rt_pin_write(GET_PIN(B,8), 1); + + return 0; +} +INIT_BOARD_EXPORT(Set_esp8266); + +int Reset_esp8266(void) +{ + rt_pin_mode(GET_PIN(B,9), PIN_MODE_OUTPUT); + rt_pin_write(GET_PIN(B,9), 0); + rt_thread_mdelay(200); + rt_pin_write(GET_PIN(B,9), 1); + return 0; +} +INIT_BOARD_EXPORT(Reset_esp8266); + diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232.c" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232.c" new file mode 100644 index 0000000000000000000000000000000000000000..32f65c768acea3bb550dea738e716421863a7cdd --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232.c" @@ -0,0 +1,66 @@ +/* + * 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 + + +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\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/drv_hello.c" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/drv_hello.c" new file mode 100644 index 0000000000000000000000000000000000000000..0fe7ebf41aa0eb5f5312a195f6343aa49946608b --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/drv_hello.c" @@ -0,0 +1,132 @@ + +#include +#include +#include + +#include +#include "drv_config.h" + +//#define DRV_DEBUG +#define LOG_TAG "drv.hello" +#include + + +#include "drv_hello.h" + + +static struct hello_dev* hello_devs[100]; +static int hello_dev_cnt; + + +int register_hello_devs(struct hello_dev*dev) +{ + if(hello_dev_cnt<100) + { + hello_devs[hello_dev_cnt++] = dev; + return 0; + } + else + return -1; +} + +struct hello_dev* get_hello_devs(char* name) +{ + int i; + for(i=0;i<100;i++) + { + if(strcmp(name,hello_devs[i]->name) == 0) + return hello_devs[i]; + } + + return NULL; +} +static rt_size_t hello_write (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size) +{ + char name[10]; + char word[10]; + int len; + struct hello_dev* hello_dev; + char*str = strstr(buffer,","); + /* 解析buffer,格式为hello,word */ + if(!str) + { + rt_set_errno(-RT_ERROR); + rt_kprintf("string format err\n"); + return 0; + } + len = str - (char*)buffer; + + if(len > 10) + len = 10; + + strncpy(name,buffer,len); + name[len] = '\0'; + + str++; + len = 0; + while(*str && (len<10)) + { + word[len++] = *str; + str++; + } + if(len == 10) + len--; + word[len] = '\0'; + +/* 根据设备name 找到设备 */ + hello_dev = get_hello_devs(name); + if(!hello_dev) + { + rt_kprintf("get hello_dev(%s)error\n",name); + rt_set_errno(-RT_ERROR); + return 0; + } + hello_dev->say(word); + + return size; +} + + +static struct rt_device hello_drv; + + +/* operations */ +#ifdef RT_USING_DEVICE_OPS +const static struct rt_device_ops hello_ops = +{ + RT_NULL, + RT_NULL, + RT_NULL, + RT_NULL, + hello_write, + RT_NULL, +}; +#endif + +static int drv_hello_init(void) +{ + int ret; + + hello_drv.type = RT_Device_Class_Miscellaneous; + hello_drv.rx_indicate = RT_NULL; + hello_drv.tx_complete = RT_NULL; + +#ifdef RT_USING_DEVICE_OPS + hello_drv.ops = &hello_ops; +#else + hello_drv.init = RT_NULL; + hello_drv.open = RT_NULL; + hello_drv.close = RT_NULL; + hello_drv.read = RT_NULL; + hello_drv.write = hello_write; + hello_drv.control = RT_NULL; +#endif + + ret = rt_device_register(&hello_drv, "hello", RT_DEVICE_FLAG_RDWR); + + return ret; + +} + +INIT_BOARD_EXPORT(drv_hello_init); + diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250721210740643.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250721210740643.png" new file mode 100644 index 0000000000000000000000000000000000000000..769408bf916649a07bcad0508e7493d52afb91a4 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250721210740643.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250721210756229.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250721210756229.png" new file mode 100644 index 0000000000000000000000000000000000000000..9960d68065f5ef77f2f0262fa49608563ed47da1 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250721210756229.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250721210932327.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250721210932327.png" new file mode 100644 index 0000000000000000000000000000000000000000..c29717cc3cec96504935e5cfa0e0c9f7f30a8929 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250721210932327.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250721211009294.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250721211009294.png" new file mode 100644 index 0000000000000000000000000000000000000000..662375639d85e17fae9dab77b7674fd52b35a9dc Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250721211009294.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250722195430124.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250722195430124.png" new file mode 100644 index 0000000000000000000000000000000000000000..350354ff69b699cfe75f1b6e48c4e5f93ef0d995 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250722195430124.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250722195441203.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250722195441203.png" new file mode 100644 index 0000000000000000000000000000000000000000..e4fa46c62921ea62cbc35de2322e52f6d30715f6 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250722195441203.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250722195844159.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250722195844159.png" new file mode 100644 index 0000000000000000000000000000000000000000..8569ba3931c618bb69a9855d80ec2c6a34353ee3 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250722195844159.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725064318917.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725064318917.png" new file mode 100644 index 0000000000000000000000000000000000000000..9d6b95ecceffc0bd52d2260b014a51fc65462e38 Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725064318917.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725065922301.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725065922301.png" new file mode 100644 index 0000000000000000000000000000000000000000..371304a8287c8a6ccd6f2657437e645a00d47bda Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725065922301.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725070225595.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725070225595.png" new file mode 100644 index 0000000000000000000000000000000000000000..cbe87cccab67f8248716b5d7ff9648b4d132179b Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725070225595.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725070325412.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725070325412.png" new file mode 100644 index 0000000000000000000000000000000000000000..c61d23c775e1a30f15c5b55797f54bc42902ee6e Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725070325412.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725070504692.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725070504692.png" new file mode 100644 index 0000000000000000000000000000000000000000..75fee45f7c100a4732f6200d305f6c9bec3c073c Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725070504692.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725071114460.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725071114460.png" new file mode 100644 index 0000000000000000000000000000000000000000..d3e1b9cc86cc51b729aa7b204e749a6c29eb497f Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725071114460.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725071146852.png" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725071146852.png" new file mode 100644 index 0000000000000000000000000000000000000000..b5ec0664da84383dc681c4bef7ac18b361461ffe Binary files /dev/null and "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/pic.assets/image-20250725071146852.png" differ diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/\347\254\254\344\270\200\345\244\251\347\254\224\350\256\260.md" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/\347\254\254\344\270\200\345\244\251\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..875ee0aab6f1a6f7ce6c72aa1bd7e8126ab97288 --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/\347\254\254\344\270\200\345\244\251\347\254\224\350\256\260.md" @@ -0,0 +1,61 @@ + + +## env工具 + +### 环境配置 + +![image-20250721210756229](pic.assets/image-20250721210756229.png) + +放在c盘进行register,右键选择comemu here进入env + +![image-20250721210740643](pic.assets/image-20250721210740643.png) + +### 功能介绍 + +#### 内核的裁剪 + +#### env进入在rtconfig,h文件目录下 + +![image-20250721211009294](pic.assets/image-20250721211009294.png) + +![image-20250721210932327](pic.assets/image-20250721210932327.png) + +```c +menuconfig 进入配置界面 +``` + +#### 对项目进行编译和生成工程 + +```c +scons --target = xxx (xxx=mak4\mdk5\iar) +``` + +## git 工具 + +### 常用指令 + +```c +git init //创建仓库地址 +``` + +```c +git commit -m "xxx" //名称 +``` + +```c +git log // 查看历史版本 +``` + +```c +git branch -a //查看所有分支 +``` + +```c +git swtich xxx //切换分支 +``` + +### 图形化插件 + +在vscode中下载插件Git Graph + +使用参考文章[快速搞懂 Git Graph-CSDN博客](https://blog.csdn.net/weixin_43242506/article/details/123230514) \ No newline at end of file diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\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)/\345\206\257\344\275\263\345\271\263/\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..cabe5878c20cee5f307540e22fb0b7b76354bd76 --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\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,83 @@ +#### IPC_FLAG声明 + +RT_IPC_FLAG_PRIO:表示唤醒优先级最高的等待线程 + RT_IPC_FLAG_FIFO:表示唤醒等待时间最长的等待线程 + +#### 消息队列 + +API: + +```c + 1/队列控制块 static rt_mq_t test_mq =RT_NULL; + 2/创建队列 rt_mq_create(); + 3/发送消息 rt_mq_send(); + 4/获取消息 rt_mq_recv(); + 5/删除队列 rt_mq_delete(); +``` + +使用: + +1. 先创建消息队列,通过句柄进行操作 +2. 采样FIFO,或者使用紧急函数将发送消息放入队列头部 +3. 获取消息时,必须定义储存地址,并传入recv,且接收消息为复制信息,需要保证存放大小 + + + +#### 邮箱 + +API + +```c +1/ 邮箱控制块 rt_mailbox_t test_mb =RT_NULL; +2/ 创建邮箱 test_mb = rt_mb_create() +3/ 发送信件 rt_mb_send(); +4/ 获取信件 rt_mb_recv(); +5/ 删除邮箱 rt_mb_delete(); +``` + +使用: + +1. 每封邮件为4字节大小,通常用于传地址,效率高,可以传递大数据时指向缓冲区的指针作为邮件 +2. 设定发送区和接收区 + + + +#### 信号量 + +API: + +```c +1/ 信号量控制块 rt_sem_t test_sem =RT_NULL; +2/ 创建信号量 test_sem = rt_sem_create +3/ 获取信号量 rt_sem_take(); +4/ 释放信号量 rt_sem_release(); +5/ 删除信号量 rt_sem_delete(); +``` + +使用: + +1. 线程和中断同步的重要手段 +2. 在同步时不会消耗太多资源,且响应快 + + + + + +#### 互斥量 + +API + +```c +1/ 互斥量控制块 rt_mutex_t test_mutex =RT_NULL; +2/ 创建互斥量 test_mutex = rt_sem_create +3/ 获取互斥量 rt_mutex_take(); +4/ 释放互斥量 rt_mutex_release(); +5/ 删除互斥量 rt_mutex_delete(); +``` + + + +使用: + +1. 优先级继承,且不能在中断程序中使用, +2. 可使用其对资源保护,例如串口资源,进行单一访问 \ No newline at end of file diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/\347\254\254\344\272\214\345\244\251\347\254\224\350\256\260.md" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/\347\254\254\344\272\214\345\244\251\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..35f7dac3977090b59827ebd80290ca7559caecae --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/\347\254\254\344\272\214\345\244\251\347\254\224\350\256\260.md" @@ -0,0 +1,71 @@ +# 详细分析RT-Thread的启动流程 + +![image-20250722195430124](pic.assets/image-20250722195430124.png) + +![image-20211203093350029](file://E:/BaiduNetdiskDownload/90%E5%A4%A9learn/0--RTOS%E5%9F%B9%E8%AE%AD%E8%B5%84%E6%96%99/07_%E9%A1%B9%E7%9B%AE6_RT-Thread%E7%A7%BB%E6%A4%8D%E4%B8%8E%E5%86%85%E9%83%A8%E5%AE%9E%E7%8E%B0/07_%E9%A1%B9%E7%9B%AE6_RT-Thread%E7%A7%BB%E6%A4%8D%E4%B8%8E%E5%86%85%E9%83%A8%E5%AE%9E%E7%8E%B0/01_RT-Thread%E5%86%85%E9%83%A8%E5%AE%9E%E7%8E%B0/2_%E5%AD%A6%E4%B9%A0%E6%96%87%E6%A1%A3/pic/23_rtt_startup_code.png?lastModify=1750853466) + +##### startup.s + +![image-20250722195441203](pic.assets/image-20250722195441203.png) + +1. 初始化时钟和配置中断向量表 +2. 初始化堆栈 +3. 进行Flash上的变量初始化 ==》重定位“+RW”/清零“+ZI” +4. __main跳转到!![image-20250722195844159](pic.assets/image-20250722195844159.png) + +##### components.c(以mdk为例) + +###### Sub$main + +```c +int $Sub$$main(void) +{ + rtthread_startup(); + return 0; +} +``` + +###### rtthread_startup + +- 关中断 + +- 初始化系统相关硬件(硬件初始化gpio,uart,系统时钟等) + +- 初始化系统内核对象(定时器、调度器、信号等) + + tick设定:msh + +- 创建用户进程:rt_application_init (各模块初始化) + +- 启动调度器 + +###### rt_application_init + +```c +tid = rt_thread_create("main", main_thread_entry, RT_NULL, + RT_MAIN_THREAD_STACK_SIZE, RT_MAIN_THREAD_PRIORITY, 20); +``` + +###### main_thread_entry + +- 调用rt_components_init函数:这会初始化一系列的组件,比如创建shell线程 +- 调用$Super$$main函数:就是调用main函数 + +```c +void main_thread_entry(void *parameter) +{ + extern int main(void); + extern int $Super$$main(void); + +#ifdef RT_USING_COMPONENTS_INIT + /* RT-Thread components initialization */ + rt_components_init(); +#endif + /* invoke system main function */ +#if defined(__CC_ARM) || defined(__CLANG_ARM) + $Super$$main(); /* for ARMCC. */ +#elif defined(__ICCARM__) || defined(__GNUC__) + main(); +#endif +} +``` \ No newline at end of file diff --git "a/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/\347\254\254\345\233\233\345\244\251\347\254\224\350\256\260.md" "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/\347\254\254\345\233\233\345\244\251\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..3575e04755cc1f78faff3fb78a88be818124a544 --- /dev/null +++ "b/2025/\347\254\2543\347\273\204(PSoC62 evaluation Kit)/\345\206\257\344\275\263\345\271\263/\347\254\224\350\256\260/\347\254\254\345\233\233\345\244\251\347\254\224\350\256\260.md" @@ -0,0 +1,54 @@ +## rtthread的驱动分析 + +### 驱动模型 + +![I/O 设备模型框架](file://E:/BaiduNetdiskDownload/90%E5%A4%A9learn/0--RTOS%E5%9F%B9%E8%AE%AD%E8%B5%84%E6%96%99/06_%E9%A1%B9%E7%9B%AE5_%E5%9F%BA%E4%BA%8ERT-Thread_nano%E5%AE%9E%E7%8E%B0%E6%99%BA%E8%83%BD%E5%AE%B6%E5%B1%85/06_%E9%A1%B9%E7%9B%AE5/03_RT-Thread%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F/2_%E5%AD%A6%E4%B9%A0%E6%96%87%E6%A1%A3/02_%E8%A7%86%E9%A2%91%E9%85%8D%E5%A5%97%E6%96%87%E4%BB%B6/pic/02_io_drv_module.png?lastModify=1753397044) + +### 分析pin驱动 + +![image-20250725065922301](pic.assets/image-20250725065922301.png) + +#### 向上申请父类结构体 rt_device + +```c + struct rt_object parent; /**< inherit from rt_object */ + + enum rt_device_class_type type; /**< device type */ + rt_uint16_t flag; /**< device flag */ + rt_uint16_t open_flag; /**< device open flag */ + + rt_uint8_t ref_count; /**< reference count */ + rt_uint8_t device_id; /**< 0 - 255 */ + +/* 向上提供信息 */ +``` + +#### 定义PIN驱动框架 + +![image-20250725070225595](pic.assets/image-20250725070225595.png) + +#### 提供框架函数并注册设备 + +![image-20250725070325412](pic.assets/image-20250725070325412.png) + +![image-20250725070504692](pic.assets/image-20250725070504692.png) + +```c +/* 实现继承,并向上提供设备信息*/ +&_hw_pin.parent ---> rt_device_t dev +``` + +#### 底层硬件实现 + +![image-20250725071146852](pic.assets/image-20250725071146852.png) + +![image-20250725071114460](pic.assets/image-20250725071114460.png) + +```文本 +1,向上申请ops结构体,得到PIN的驱动框架 + +2.通过pin_register实现框架与硬件的链接,实现信息的转发 + +3.之后可通过调用PIN设备即可操作stm32的gpio +``` +