[net][at] Using DMA mode first when device is supported.
This commit is contained in:
parent
7323916c6c
commit
ccfde36b4d
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include <rtthread.h>
|
||||
|
||||
#define AT_SW_VERSION "0.2.1"
|
||||
#define AT_SW_VERSION "0.2.2"
|
||||
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME "AT"
|
||||
|
|
|
@ -354,11 +354,12 @@ rt_size_t at_client_send(const char *buf, rt_size_t size)
|
|||
static char at_client_getchar(void)
|
||||
{
|
||||
char ch;
|
||||
at_client_t client = at_client_local;
|
||||
|
||||
rt_sem_take(client->rx_notice, RT_WAITING_FOREVER);
|
||||
|
||||
rt_device_read(client->device, 0, &ch, 1);
|
||||
if (rt_device_read(at_client_local->device, 0, &ch, 1) == 0)
|
||||
{
|
||||
rt_sem_take(at_client_local->rx_notice, RT_WAITING_FOREVER);
|
||||
rt_device_read(at_client_local->device, 0, &ch, 1);
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
@ -604,6 +605,7 @@ void at_set_urc_table(const struct at_urc *table, rt_size_t size)
|
|||
int at_client_init(void)
|
||||
{
|
||||
int result = RT_EOK;
|
||||
rt_err_t open_result = RT_EOK;
|
||||
|
||||
if (at_client_local)
|
||||
{
|
||||
|
@ -651,7 +653,14 @@ int at_client_init(void)
|
|||
{
|
||||
RT_ASSERT(at_client_local->device->type == RT_Device_Class_Char);
|
||||
|
||||
rt_device_open(at_client_local->device, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
|
||||
/* using DMA mode first */
|
||||
open_result = rt_device_open(at_client_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_client_local->device, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
|
||||
}
|
||||
RT_ASSERT(open_result == RT_EOK);
|
||||
|
||||
rt_device_set_rx_indicate(at_client_local->device, at_client_rx_ind);
|
||||
}
|
||||
|
|
|
@ -352,9 +352,11 @@ static char at_server_gerchar(void)
|
|||
{
|
||||
char ch;
|
||||
|
||||
if (rt_device_read(at_server_local->device, 0, &ch, 1) == 0)
|
||||
{
|
||||
rt_sem_take(at_server_local->rx_notice, RT_WAITING_FOREVER);
|
||||
|
||||
rt_device_read(at_server_local->device, 0, &ch, 1);
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
@ -443,6 +445,7 @@ static rt_err_t at_rx_ind(rt_device_t dev, rt_size_t size)
|
|||
int at_server_init(void)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
rt_err_t open_result = RT_EOK;
|
||||
|
||||
if (at_server_local)
|
||||
{
|
||||
|
@ -493,7 +496,14 @@ int at_server_init(void)
|
|||
{
|
||||
RT_ASSERT(at_server_local->device->type == RT_Device_Class_Char);
|
||||
|
||||
rt_device_open(at_server_local->device, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
|
||||
/* 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);
|
||||
}
|
||||
RT_ASSERT(open_result == RT_EOK);
|
||||
|
||||
rt_device_set_rx_indicate(at_server_local->device, at_rx_ind);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue