Lines Matching +full:conf +full:- +full:tx
4 * SPDX-License-Identifier: Apache-2.0
34 static int mbox_deinit(const struct icmsg_config_t *conf, in mbox_deinit() argument
39 err = mbox_set_enabled_dt(&conf->mbox_rx, 0); in mbox_deinit()
44 err = mbox_register_callback_dt(&conf->mbox_rx, NULL, NULL); in mbox_deinit()
50 (void)k_work_cancel(&dev_data->mbox_work); in mbox_deinit()
51 (void)k_work_cancel_delayable(&dev_data->notify_work); in mbox_deinit()
59 return atomic_get(&dev_data->state) == ICMSG_STATE_READY; in is_endpoint_ready()
69 (void)mbox_send_dt(&dev_data->cfg->mbox_tx, NULL); in notify_process()
71 atomic_t state = atomic_get(&dev_data->state); in notify_process()
84 (void)mbox_send_dt(&dev_data->cfg->mbox_tx, NULL); in notify_process()
93 if ((k_uptime_get() - start) > CONFIG_IPC_SERVICE_ICMSG_BOND_NOTIFY_REPEAT_TO_MS) { in notify_process()
95 (void)mbox_send_dt(&dev_data->cfg->mbox_tx, NULL); in notify_process()
107 int ret = k_mutex_lock(&dev_data->tx_lock, SHMEM_ACCESS_TO); in reserve_tx_buffer_if_unused()
118 return k_mutex_unlock(&dev_data->tx_lock); in release_tx_buffer()
124 return pbuf_read(dev_data->rx_pb, NULL, 0); in data_available()
130 if (k_work_submit_to_queue(workq, &dev_data->mbox_work) < 0) { in submit_mbox_work()
181 atomic_t state = atomic_get(&dev_data->state); in mbox_callback_process()
196 len = pbuf_read(dev_data->rx_pb, rx_buffer, sizeof(rx_buffer)); in mbox_callback_process()
199 if (dev_data->cb->received) { in mbox_callback_process()
200 dev_data->cb->received(rx_buffer, len, dev_data->ctx); in mbox_callback_process()
214 if (dev_data->cb->bound) { in mbox_callback_process()
215 dev_data->cb->bound(dev_data->ctx); in mbox_callback_process()
218 atomic_set(&dev_data->state, ICMSG_STATE_READY); in mbox_callback_process()
238 static int mbox_init(const struct icmsg_config_t *conf, in mbox_init() argument
244 k_work_init(&dev_data->mbox_work, mbox_callback_process); in mbox_init()
245 k_work_init_delayable(&dev_data->notify_work, notify_process); in mbox_init()
248 err = mbox_register_callback_dt(&conf->mbox_rx, mbox_callback, dev_data); in mbox_init()
253 return mbox_set_enabled_dt(&conf->mbox_rx, 1); in mbox_init()
256 int icmsg_open(const struct icmsg_config_t *conf, in icmsg_open() argument
260 if (!atomic_cas(&dev_data->state, ICMSG_STATE_OFF, ICMSG_STATE_BUSY)) { in icmsg_open()
262 return -EALREADY; in icmsg_open()
265 dev_data->cb = cb; in icmsg_open()
266 dev_data->ctx = ctx; in icmsg_open()
267 dev_data->cfg = conf; in icmsg_open()
270 k_mutex_init(&dev_data->tx_lock); in icmsg_open()
273 int ret = pbuf_tx_init(dev_data->tx_pb); in icmsg_open()
276 __ASSERT(false, "Incorrect Tx configuration"); in icmsg_open()
280 ret = pbuf_rx_init(dev_data->rx_pb); in icmsg_open()
287 ret = pbuf_write(dev_data->tx_pb, magic, sizeof(magic)); in icmsg_open()
299 ret = mbox_init(conf, dev_data); in icmsg_open()
304 ret = k_work_schedule_for_queue(workq, &dev_data->notify_work, K_NO_WAIT); in icmsg_open()
314 int icmsg_close(const struct icmsg_config_t *conf, in icmsg_close() argument
319 ret = mbox_deinit(conf, dev_data); in icmsg_close()
324 atomic_set(&dev_data->state, ICMSG_STATE_OFF); in icmsg_close()
329 int icmsg_send(const struct icmsg_config_t *conf, in icmsg_send() argument
341 return -EBUSY; in icmsg_send()
346 return -ENODATA; in icmsg_send()
352 return -ENOBUFS; in icmsg_send()
356 write_ret = pbuf_write(dev_data->tx_pb, msg, len); in icmsg_send()
366 return -EBADMSG; in icmsg_send()
370 __ASSERT_NO_MSG(conf->mbox_tx.dev != NULL); in icmsg_send()
372 ret = mbox_send_dt(&conf->mbox_tx, NULL); in icmsg_send()