Lines Matching +full:context +full:- +full:buffer +full:- +full:size

11  * SPDX-License-Identifier: Apache-2.0
31 * @brief Finds receiver context which manages provided device.
33 * @param dev: device used by the receiver context.
35 * @retval Receiver context or NULL.
42 if (contexts[i] && contexts[i]->uart_dev == dev) { in context_from_dev()
51 * @brief Persists receiver context if there is a free place.
56 * @param ctx: receiver context to persist.
71 return -ENOMEM; in mdm_receiver_get()
79 * @param ctx: receiver context.
88 __ASSERT(ctx->uart_dev, "invalid ctx device"); in mdm_receiver_flush()
90 while (uart_fifo_read(ctx->uart_dev, &c, 1) > 0) { in mdm_receiver_flush()
98 * @note Fills contexts ring buffer with received data.
99 * When ring buffer is full the data is discarded.
120 while (uart_irq_update(ctx->uart_dev) && in mdm_receiver_isr()
121 uart_irq_rx_ready(ctx->uart_dev)) { in mdm_receiver_isr()
122 rx = uart_fifo_read(ctx->uart_dev, read_buf, sizeof(read_buf)); in mdm_receiver_isr()
124 ret = ring_buf_put(&ctx->rx_rb, read_buf, rx); in mdm_receiver_isr()
126 LOG_ERR("Rx buffer doesn't have enough space. " in mdm_receiver_isr()
130 k_sem_give(&ctx->rx_sem); in mdm_receiver_isr()
133 k_sem_give(&ctx->rx_sem); in mdm_receiver_isr()
139 * @brief Configures receiver context and assigned device.
141 * @param ctx: receiver context.
149 uart_irq_rx_disable(ctx->uart_dev); in mdm_receiver_setup()
150 uart_irq_tx_disable(ctx->uart_dev); in mdm_receiver_setup()
152 uart_irq_callback_set(ctx->uart_dev, mdm_receiver_isr); in mdm_receiver_setup()
153 uart_irq_rx_enable(ctx->uart_dev); in mdm_receiver_setup()
166 uint8_t *buf, size_t size, size_t *bytes_read) in mdm_receiver_recv() argument
169 return -EINVAL; in mdm_receiver_recv()
172 if (size == 0) { in mdm_receiver_recv()
177 *bytes_read = ring_buf_get(&ctx->rx_rb, buf, size); in mdm_receiver_recv()
182 const uint8_t *buf, size_t size) in mdm_receiver_send() argument
185 return -EINVAL; in mdm_receiver_send()
188 if (size == 0) { in mdm_receiver_send()
193 uart_poll_out(ctx->uart_dev, *buf++); in mdm_receiver_send()
194 } while (--size); in mdm_receiver_send()
201 uart_irq_rx_disable(ctx->uart_dev); in mdm_receiver_sleep()
203 pm_device_action_run(ctx->uart_dev, PM_DEVICE_ACTION_SUSPEND); in mdm_receiver_sleep()
211 pm_device_action_run(ctx->uart_dev, PM_DEVICE_ACTION_RESUME); in mdm_receiver_wake()
213 uart_irq_rx_enable(ctx->uart_dev); in mdm_receiver_wake()
220 uint8_t *buf, size_t size) in mdm_receiver_register() argument
224 if ((!ctx) || (size == 0)) { in mdm_receiver_register()
225 return -EINVAL; in mdm_receiver_register()
230 uart_dev ? uart_dev->name : "<null>"); in mdm_receiver_register()
231 return -ENODEV; in mdm_receiver_register()
234 ctx->uart_dev = uart_dev; in mdm_receiver_register()
235 ring_buf_init(&ctx->rx_rb, size, buf); in mdm_receiver_register()
236 k_sem_init(&ctx->rx_sem, 0, 1); in mdm_receiver_register()