Skip to content

[AT] AT_Device 适配 SERIAL_V2 #9860

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

Merged
merged 4 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion components/net/at/include/at.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
* Copyright (c) 2006-2025, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
Expand All @@ -14,6 +14,7 @@

#include <stddef.h>
#include <rtthread.h>
#include <rtdevice.h>

#ifdef __cplusplus
extern "C" {
Expand Down
8 changes: 7 additions & 1 deletion components/net/at/src/at_client.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
* Copyright (c) 2006-2025, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
Expand All @@ -10,6 +10,7 @@
* 2018-08-17 chenyong multiple client support
* 2021-03-17 Meco Man fix a buf of leaking memory
* 2021-07-14 Sszl fix a buf of leaking memory
* 2025-01-02 dongly support SERIAL_V2
*/

#include <at.h>
Expand Down Expand Up @@ -960,13 +961,18 @@ int at_client_init(const char *dev_name, rt_size_t recv_bufsz, rt_size_t send_bu
RT_ASSERT(client->device->type == RT_Device_Class_Char);

rt_device_set_rx_indicate(client->device, at_client_rx_ind);

#ifdef RT_USING_SERIAL_V2
open_result = rt_device_open(client->device, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_RX_NON_BLOCKING);
#else
/* using DMA mode first */
open_result = rt_device_open(client->device, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_DMA_RX);
/* using interrupt mode when DMA mode not supported */
if (open_result == -RT_EIO)
{
open_result = rt_device_open(client->device, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
}
#endif // RT_USING_SERIAL_V2
RT_ASSERT(open_result == RT_EOK);
}
else
Expand Down
8 changes: 7 additions & 1 deletion components/net/at/src/at_server.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
* Copyright (c) 2006-2025, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-03-30 chenyong first version
* 2018-04-14 chenyong modify parse arguments
* 2025-01-02 dongly support SERIAL_V2
*/

#include <at.h>
Expand Down Expand Up @@ -565,13 +566,18 @@ int at_server_init(void)
RT_ASSERT(at_server_local->device->type == RT_Device_Class_Char);

rt_device_set_rx_indicate(at_server_local->device, at_rx_ind);

#ifdef RT_USING_SERIAL_V2
open_result = rt_device_open(client->device, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_RX_NON_BLOCKING);
#else
/* using DMA mode first */
open_result = rt_device_open(at_server_local->device, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_DMA_RX);
/* using interrupt mode when DMA mode not supported */
if (open_result == -RT_EIO)
{
open_result = rt_device_open(at_server_local->device, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
}
#endif /* RT_USING_SERIAL_V2 */
RT_ASSERT(open_result == RT_EOK);
}
else
Expand Down
Loading