1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

drivers/at: removed async URC handling.

This commit is contained in:
Mihai Renea 2024-01-12 16:52:06 +01:00
parent 17ec57ee6d
commit b40c9a0366

View File

@ -58,26 +58,10 @@
#define AT_PRINT_INCOMING (0) #define AT_PRINT_INCOMING (0)
#endif #endif
#if defined(MODULE_AT_URC_ISR_LOWEST)
#define AT_EVENT_PRIO EVENT_PRIO_LOWEST
#elif defined(MODULE_AT_URC_ISR_MEDIUM)
#define AT_EVENT_PRIO EVENT_PRIO_MEDIUM
#elif defined(MODULE_AT_URC_ISR_HIGHEST)
#define AT_EVENT_PRIO EVENT_PRIO_HIGHEST
#endif
#if defined(MODULE_AT_URC) #if defined(MODULE_AT_URC)
static int _check_urc(clist_node_t *node, void *arg); static int _check_urc(clist_node_t *node, void *arg);
#endif #endif
#if defined(MODULE_AT_URC_ISR)
static void _event_process_urc(event_t *_event)
{
at_dev_t *dev = (at_dev_t *)container_of(_event, at_dev_t, event);
at_process_urc(dev, 1000);
}
#endif
static ssize_t at_readline_skip_empty_stop_at_str(at_dev_t *dev, char *resp_buf, static ssize_t at_readline_skip_empty_stop_at_str(at_dev_t *dev, char *resp_buf,
size_t len, bool keep_eol, size_t len, bool keep_eol,
char const *substr, uint32_t timeout); char const *substr, uint32_t timeout);
@ -94,11 +78,6 @@ static void _isrpipe_write_one_wrapper(void *_dev, uint8_t data)
{ {
at_dev_t *dev = (at_dev_t *) _dev; at_dev_t *dev = (at_dev_t *) _dev;
isrpipe_write_one(&dev->isrpipe, data); isrpipe_write_one(&dev->isrpipe, data);
#if defined(MODULE_AT_URC_ISR)
if (data == AT_RECV_EOL_2[0] && !dev->awaiting_response) {
event_post(AT_EVENT_PRIO, &dev->event);
}
#endif
} }
int at_dev_init(at_dev_t *dev, at_dev_init_t const *init) int at_dev_init(at_dev_t *dev, at_dev_init_t const *init)
@ -108,11 +87,6 @@ int at_dev_init(at_dev_t *dev, at_dev_init_t const *init)
dev->rp_buf = init->rp_buf; dev->rp_buf = init->rp_buf;
dev->rp_buf_size = init->rp_buf_size; dev->rp_buf_size = init->rp_buf_size;
#if IS_USED(MODULE_AT_URC_ISR)
dev->awaiting_response = false;
dev->event.handler = _event_process_urc;
#endif
isrpipe_init(&dev->isrpipe, (uint8_t *)init->rx_buf, init->rx_buf_size); isrpipe_init(&dev->isrpipe, (uint8_t *)init->rx_buf, init->rx_buf_size);
return uart_init(init->uart, init->baudrate, _isrpipe_write_one_wrapper, dev); return uart_init(init->uart, init->baudrate, _isrpipe_write_one_wrapper, dev);
@ -150,11 +124,6 @@ int at_parse_resp(at_dev_t *dev, char const *resp)
int at_expect_bytes(at_dev_t *dev, const char *bytes, uint32_t timeout) int at_expect_bytes(at_dev_t *dev, const char *bytes, uint32_t timeout)
{ {
int res = 0; int res = 0;
#if IS_USED(MODULE_AT_URC_ISR)
dev->awaiting_response = true;
#endif
while (*bytes) { while (*bytes) {
char c; char c;
if ((res = isrpipe_read_timeout(&dev->isrpipe, (uint8_t *)&c, 1, timeout)) == 1) { if ((res = isrpipe_read_timeout(&dev->isrpipe, (uint8_t *)&c, 1, timeout)) == 1) {
@ -171,12 +140,7 @@ int at_expect_bytes(at_dev_t *dev, const char *bytes, uint32_t timeout)
} }
} }
res = 0; res = 0;
out: out:
#if IS_USED(MODULE_AT_URC_ISR)
dev->awaiting_response = false;
#endif
return res; return res;
} }
@ -197,11 +161,6 @@ void at_send_bytes(at_dev_t *dev, const char *bytes, size_t len)
ssize_t at_recv_bytes(at_dev_t *dev, char *bytes, size_t len, uint32_t timeout) ssize_t at_recv_bytes(at_dev_t *dev, char *bytes, size_t len, uint32_t timeout)
{ {
char *resp_pos = bytes; char *resp_pos = bytes;
#if IS_USED(MODULE_AT_URC_ISR)
dev->awaiting_response = true;
#endif
while (len) { while (len) {
int read_res; int read_res;
if ((read_res = isrpipe_read_timeout(&dev->isrpipe, (uint8_t *)resp_pos, if ((read_res = isrpipe_read_timeout(&dev->isrpipe, (uint8_t *)resp_pos,
@ -213,11 +172,6 @@ ssize_t at_recv_bytes(at_dev_t *dev, char *bytes, size_t len, uint32_t timeout)
break; break;
} }
} }
#if IS_USED(MODULE_AT_URC_ISR)
dev->awaiting_response = false;
#endif
return (resp_pos - bytes); return (resp_pos - bytes);
} }
@ -228,10 +182,6 @@ int at_recv_bytes_until_string(at_dev_t *dev, const char *string,
char *_string = (char *)string; char *_string = (char *)string;
int res = 0; int res = 0;
#if IS_USED(MODULE_AT_URC_ISR)
dev->awaiting_response = true;
#endif
while (*_string && len < *bytes_len) { while (*_string && len < *bytes_len) {
char c; char c;
if ((res = isrpipe_read_timeout(&dev->isrpipe, (uint8_t *)&c, 1, timeout)) == 1) { if ((res = isrpipe_read_timeout(&dev->isrpipe, (uint8_t *)&c, 1, timeout)) == 1) {
@ -249,11 +199,6 @@ int at_recv_bytes_until_string(at_dev_t *dev, const char *string,
} }
} }
*bytes_len = len; *bytes_len = len;
#if IS_USED(MODULE_AT_URC_ISR)
dev->awaiting_response = false;
#endif
return res; return res;
} }
@ -282,18 +227,10 @@ void at_drain(at_dev_t *dev)
uint8_t _tmp[16]; uint8_t _tmp[16];
int res; int res;
#if IS_USED(MODULE_AT_URC_ISR)
dev->awaiting_response = true;
#endif
do { do {
/* consider no character within 10ms "drained" */ /* consider no character within 10ms "drained" */
res = isrpipe_read_timeout(&dev->isrpipe, _tmp, sizeof(_tmp), 10000U); res = isrpipe_read_timeout(&dev->isrpipe, _tmp, sizeof(_tmp), 10000U);
} while (res > 0); } while (res > 0);
#if IS_USED(MODULE_AT_URC_ISR)
dev->awaiting_response = false;
#endif
} }
ssize_t at_send_cmd_get_resp(at_dev_t *dev, const char *command, ssize_t at_send_cmd_get_resp(at_dev_t *dev, const char *command,
@ -498,10 +435,6 @@ static size_t at_readline_stop_at_str(at_dev_t *dev, char *resp_buf, size_t len,
ssize_t res = 0; ssize_t res = 0;
char *resp_pos = resp_buf; char *resp_pos = resp_buf;
#if IS_USED(MODULE_AT_URC_ISR)
dev->awaiting_response = true;
#endif
memset(resp_buf, 0, len); memset(resp_buf, 0, len);
size_t substr_len = 0; size_t substr_len = 0;
if (substr) { if (substr) {
@ -544,11 +477,6 @@ static size_t at_readline_stop_at_str(at_dev_t *dev, char *resp_buf, size_t len,
break; break;
} }
} }
#if IS_USED(MODULE_AT_URC_ISR)
dev->awaiting_response = false;
#endif
if (res < 0) { if (res < 0) {
*resp_buf = '\0'; *resp_buf = '\0';
} else { } else {