-
Notifications
You must be signed in to change notification settings - Fork 5.3k
添加了NXP MCXA346的UART demo #11120
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
tm456-43
wants to merge
1
commit into
RT-Thread:master
Choose a base branch
from
tm456-43:NXP_FRDM-MCXA346_UART_demo
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.
+972
−239
Open
添加了NXP MCXA346的UART demo #11120
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
122 changes: 122 additions & 0 deletions
122
bsp/nxp/mcx/mcxa/frdm-mcxa346/applications/at_sample_client.c
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 |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| /* | ||
| * Copyright (c) 2006-2023, RT-Thread Development Team | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * Change Logs: | ||
| * Date Author Notes | ||
| * 2018-07-06 chenyong first version | ||
| */ | ||
|
|
||
| #include <stdlib.h> | ||
| #include <string.h> | ||
|
|
||
| #include <rtthread.h> | ||
| #include <at.h> | ||
|
|
||
| #define LOG_TAG "at.sample" | ||
| #include <at_log.h> | ||
|
|
||
| #define AT_CMD_MAX_LEN 512 | ||
|
|
||
| /* AT+CIFSR Query local IP address and MAC */ | ||
| int at_client_test(int argc, char **argv) | ||
| { | ||
| at_response_t resp = RT_NULL; | ||
| int result = 0; | ||
|
|
||
| if (argc != 1) | ||
| { | ||
| LOG_E("at_client_test - AT client send commands to AT server."); | ||
| return -1; | ||
| } | ||
|
|
||
| resp = at_create_resp(256, 0, rt_tick_from_millisecond(5000)); | ||
| if (resp == RT_NULL) | ||
| { | ||
| LOG_E("No memory for response structure!"); | ||
| return -2; | ||
| } | ||
|
|
||
| /* close echo */ | ||
| at_exec_cmd(resp, "ATE0"); | ||
|
|
||
| result = at_exec_cmd(resp, "AT+CIFSR"); | ||
| if (result != RT_EOK) | ||
| { | ||
| LOG_E("AT client send commands failed or return response error!"); | ||
| goto __exit; | ||
| } | ||
|
|
||
| /* Print response line buffer */ | ||
| { | ||
| const char *line_buffer = RT_NULL; | ||
|
|
||
| LOG_D("Response buffer"); | ||
|
|
||
| for(rt_size_t line_num = 1; line_num <= resp->line_counts; line_num++) | ||
| { | ||
| if((line_buffer = at_resp_get_line(resp, line_num)) != RT_NULL) | ||
| { | ||
| LOG_D("line %d buffer : %s", line_num, line_buffer); | ||
| } | ||
| else | ||
| { | ||
| LOG_E("Parse line buffer error!"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| { | ||
| char resp_arg[AT_CMD_MAX_LEN] = { 0 }; | ||
| const char * resp_expr = "%*[^\"]\"%[^\"]\""; | ||
|
|
||
| LOG_D(" Parse arguments"); | ||
| if (at_resp_parse_line_args(resp, 1, resp_expr, resp_arg) == 1) | ||
| { | ||
| LOG_D("Station IP : %s", resp_arg); | ||
| rt_memset(resp_arg, 0x00, AT_CMD_MAX_LEN); | ||
| } | ||
| else | ||
| { | ||
| LOG_E("Parse error, current line buff : %s", at_resp_get_line(resp, 4)); | ||
| } | ||
|
|
||
| if (at_resp_parse_line_args(resp, 2, resp_expr, resp_arg) == 1) | ||
| { | ||
| LOG_D("Station MAC : %s", resp_arg); | ||
| } | ||
| else | ||
| { | ||
| LOG_E("Parse error, current line buff : %s", at_resp_get_line(resp, 5)); | ||
| goto __exit; | ||
| } | ||
| } | ||
| __exit: | ||
| if(resp) | ||
| { | ||
| at_delete_resp(resp); | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| int at_client_test_init(int argc, char **argv) | ||
| { | ||
| #define AT_CLIENT_RECV_BUFF_LEN 1024 | ||
| #define AT_CLIENT_SEND_BUFF_LEN 512 | ||
| if (argc != 2) | ||
| { | ||
| rt_kprintf("at_client_init <dev_name> -- AT client initialize.\n"); | ||
| return -RT_ERROR; | ||
| } | ||
|
|
||
| at_client_init(argv[1], AT_CLIENT_RECV_BUFF_LEN, AT_CLIENT_SEND_BUFF_LEN); | ||
|
|
||
| return RT_EOK; | ||
| } | ||
| #ifdef FINSH_USING_MSH | ||
| #include <finsh.h> | ||
| MSH_CMD_EXPORT(at_client_test, AT client send cmd and get response); | ||
| MSH_CMD_EXPORT_ALIAS(at_client_test_init, at_client_init, initialize AT client); | ||
| #endif |
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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #include <rtthread.h> | ||
|
|
||
| #define TX_UART_NAME "uart3" | ||
|
|
||
| static rt_device_t tx_serial = RT_NULL; | ||
|
|
||
| /* ����������ں��� */ | ||
| static void serial_tx_thread(void *parameter) | ||
| { | ||
| char msg[] = "hello RT-Thread!\r\n"; | ||
|
|
||
| while (1) | ||
| { | ||
| rt_device_write(tx_serial, 0, msg, sizeof(msg) - 1); | ||
| rt_thread_mdelay(500); /* ÿ 500ms ��һ�� */ | ||
| } | ||
| } | ||
|
|
||
| /* ��ʼ����������ϵͳ������ɺ��Զ����� */ | ||
| int uart3_tx_init(void) | ||
| { | ||
| /* ���� uart3 �豸 */ | ||
| tx_serial = rt_device_find(TX_UART_NAME); | ||
| if (tx_serial == RT_NULL) | ||
| { | ||
| rt_kprintf("Cannot find %s device!\n", TX_UART_NAME); | ||
| return -1; | ||
| } | ||
|
|
||
| /* ���豸�������ͣ�����Ҫ���գ� */ | ||
| rt_device_open(tx_serial, RT_DEVICE_FLAG_WRONLY); | ||
|
|
||
| /* �����߳� */ | ||
| rt_thread_t tid = rt_thread_create( | ||
| "uart3_tx", /* �߳��� */ | ||
| serial_tx_thread, /* ��ں��� */ | ||
| RT_NULL, /* ���� */ | ||
| 1024, /* ջ��С */ | ||
| 20, /* ���ȼ� */ | ||
| 10 /* ʱ��Ƭ */ | ||
| ); | ||
|
|
||
| if (tid != RT_NULL) | ||
| rt_thread_startup(tid); | ||
| else | ||
| rt_kprintf("Create uart3_tx thread failed!\n"); | ||
|
|
||
| return 0; | ||
| } | ||
| //INIT_APP_EXPORT(uart3_tx_init); | ||
| /* ������ msh ������� */ | ||
| MSH_CMD_EXPORT(uart3_tx_init, uart3 device test); | ||
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.
注释部分编码不对