Lines Matching full:ctx

56  * @param  ctx: receiver context to persist.
60 static int mdm_receiver_get(struct mdm_receiver_context *ctx) in mdm_receiver_get() argument
66 contexts[i] = ctx; in mdm_receiver_get()
79 * @param ctx: receiver context.
83 static void mdm_receiver_flush(struct mdm_receiver_context *ctx) in mdm_receiver_flush() argument
87 __ASSERT(ctx, "invalid ctx"); in mdm_receiver_flush()
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()
107 struct mdm_receiver_context *ctx; in mdm_receiver_isr() local
114 ctx = context_from_dev(uart_dev); in mdm_receiver_isr()
115 if (!ctx) { in mdm_receiver_isr()
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()
129 mdm_receiver_flush(ctx); 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()
141 * @param ctx: receiver context.
145 static void mdm_receiver_setup(struct mdm_receiver_context *ctx) in mdm_receiver_setup() argument
147 __ASSERT(ctx, "invalid ctx"); in mdm_receiver_setup()
149 uart_irq_rx_disable(ctx->uart_dev); in mdm_receiver_setup()
150 uart_irq_tx_disable(ctx->uart_dev); in mdm_receiver_setup()
151 mdm_receiver_flush(ctx); 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()
165 int mdm_receiver_recv(struct mdm_receiver_context *ctx, in mdm_receiver_recv() argument
168 if (!ctx) { in mdm_receiver_recv()
177 *bytes_read = ring_buf_get(&ctx->rx_rb, buf, size); in mdm_receiver_recv()
181 int mdm_receiver_send(struct mdm_receiver_context *ctx, in mdm_receiver_send() argument
184 if (!ctx) { in mdm_receiver_send()
193 uart_poll_out(ctx->uart_dev, *buf++); in mdm_receiver_send()
199 int mdm_receiver_sleep(struct mdm_receiver_context *ctx) in mdm_receiver_sleep() argument
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()
208 int mdm_receiver_wake(struct mdm_receiver_context *ctx) in mdm_receiver_wake() argument
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()
218 int mdm_receiver_register(struct mdm_receiver_context *ctx, in mdm_receiver_register() argument
224 if ((!ctx) || (size == 0)) { 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()
238 ret = mdm_receiver_get(ctx); in mdm_receiver_register()
243 mdm_receiver_setup(ctx); in mdm_receiver_register()