-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[bsp][gd32]:gd32vw553h-eval add wifi support #11175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
CYFS3
wants to merge
1
commit into
RT-Thread:master
Choose a base branch
from
CYFS3:gd32_wifi
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+911
−129
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,15 +13,57 @@ | |
| #include <rtthread.h> | ||
| #include <rtdevice.h> | ||
| #include <board.h> | ||
|
|
||
| #ifdef BSP_USING_WLAN | ||
| #include "gd32vw55x_platform.h" | ||
| #include "wrapper_os.h" | ||
| #include "wifi_management.h" | ||
| #include "wifi_init.h" | ||
| #include "user_setting.h" | ||
| #include "util.h" | ||
| #endif /* BSP_USING_WLAN */ | ||
| /* LED1 ~ LED3 pin: PA4 PA5 PA6 */ | ||
| #define LED1_PIN GET_PIN(A, 4) | ||
|
|
||
| int main(void) | ||
|
|
||
| #ifdef RT_USING_WIFI | ||
| #define START_TASK_STACK_SIZE 512 | ||
| #define START_TASK_PRIO 4 | ||
|
|
||
| static void application_init(void) | ||
| { | ||
| rt_kprintf("Hello GD32VW553H\n"); | ||
| /* set LED1 pin mode to output */ | ||
| rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT); | ||
| util_init(); | ||
|
|
||
| user_setting_init(); | ||
|
|
||
| if (wifi_init()) { | ||
| rt_kprintf("wifi init failed\r\n"); | ||
| } else { | ||
| // rt_kprintf("wifi init success\r\n"); | ||
| } | ||
| } | ||
|
|
||
| static rt_sem_t init_done_sem = RT_NULL; | ||
|
|
||
| static void start_task(void *param) | ||
| { | ||
| (void)param; | ||
|
|
||
| application_init(); | ||
| // rt_kprintf("Start task completed, exiting.\n"); | ||
|
|
||
| /* Note: In RT-Thread, task should exit by returning, not by calling sys_task_delete(NULL). | ||
| * When the task function returns, RT-Thread will automatically clean up the task. | ||
| */ | ||
|
|
||
| rt_sem_release(init_done_sem); | ||
| } | ||
|
|
||
| #endif /* RT_USING_WIFI */ | ||
|
Comment on lines
+28
to
+61
|
||
|
|
||
| /* LED blink thread */ | ||
| static void led_thread_entry(void *param) | ||
| { | ||
| (void)param; | ||
|
|
||
| while (1) | ||
| { | ||
|
|
@@ -30,6 +72,63 @@ int main(void) | |
| rt_pin_write(LED1_PIN, PIN_LOW); | ||
| rt_thread_mdelay(500); | ||
| } | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| rt_thread_t led_thread; | ||
|
|
||
| rt_kprintf("Hello GD32VW553H\n"); | ||
| /* set LED1 pin mode to output */ | ||
| rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT); | ||
|
|
||
| #ifdef RT_USING_WIFI | ||
| /* Create semaphore for synchronization */ | ||
| init_done_sem = rt_sem_create("init_done", 0, RT_IPC_FLAG_PRIO); | ||
| if (init_done_sem == RT_NULL) { | ||
| rt_kprintf("Failed to create semaphore\n"); | ||
| return -RT_ERROR; | ||
| } | ||
|
|
||
| if (sys_task_create_dynamic((const uint8_t *)"start_task", | ||
| START_TASK_STACK_SIZE, OS_TASK_PRIORITY(START_TASK_PRIO), start_task, NULL) == NULL) { | ||
| rt_kprintf("Create start task failed\r\n"); | ||
| return -RT_ERROR; | ||
| } | ||
|
|
||
| // rt_kprintf("Waiting for initialization to complete...\n"); | ||
| /* Wait for initialization task to complete */ | ||
| rt_sem_take(init_done_sem, RT_WAITING_FOREVER); | ||
| // rt_kprintf("Initialization completed, continuing...\n"); | ||
|
|
||
| /* Clean up semaphore */ | ||
| rt_sem_delete(init_done_sem); | ||
| init_done_sem = RT_NULL; | ||
|
|
||
| /* set wifi work mode */ | ||
| rt_wlan_set_mode(RT_WLAN_DEVICE_STA_NAME, RT_WLAN_STATION); | ||
| rt_wlan_set_mode(RT_WLAN_DEVICE_AP_NAME, RT_WLAN_AP); | ||
| #ifdef RT_USING_NETDEV | ||
| rt_thread_mdelay(1000); | ||
| extern int wifi_netdev_register(void); | ||
| wifi_netdev_register(); | ||
| #endif /* RT_USING_NETDEV */ | ||
| #endif /* RT_USING_WIFI */ | ||
|
|
||
| /* Create LED blink thread */ | ||
| led_thread = rt_thread_create("led", | ||
| led_thread_entry, | ||
| RT_NULL, | ||
| 1024, | ||
| 25, /* Lower priority to not block shell */ | ||
| 10); | ||
| if (led_thread != RT_NULL) { | ||
| rt_thread_startup(led_thread); | ||
| rt_kprintf("LED thread started\n"); | ||
| } else { | ||
| rt_kprintf("Failed to create LED thread\n"); | ||
| } | ||
|
|
||
| /* Return from main to allow shell to work properly */ | ||
| return RT_EOK; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
将main.c中wifi相关内容移至board文件夹或board.c文件中,还原main.c