modules: hal_nordic: nrfs: callback when connected
User can assign callback functions to nrfs ipc backend to be notified when connection is actually established. Callbacks register needs to be done before nrfs is initialized. Signed-off-by: Łukasz Stępnicki <lukasz.stepnicki@nordicsemi.no>
This commit is contained in:
parent
fc831ead04
commit
c02db33789
2 changed files with 32 additions and 0 deletions
|
@ -54,6 +54,8 @@ static struct ipc_channel_config ipc_cpusys_channel_config = {
|
|||
.enabled = true
|
||||
};
|
||||
|
||||
static sys_slist_t nrfs_backend_info_cb_slist = SYS_SLIST_STATIC_INIT(&nrfs_backend_info_cb_slist);
|
||||
|
||||
/**
|
||||
* @brief nrfs backend error handler
|
||||
*
|
||||
|
@ -99,6 +101,12 @@ static void ipc_sysctrl_ept_bound(void *priv)
|
|||
if (k_msgq_num_used_get(&ipc_transmit_msgq) > 0) {
|
||||
k_work_submit(&backend_send_work);
|
||||
}
|
||||
|
||||
struct nrfs_backend_bound_info_subs *subs;
|
||||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&nrfs_backend_info_cb_slist, subs, node) {
|
||||
subs->cb();
|
||||
}
|
||||
}
|
||||
|
||||
static void ipc_sysctrl_ept_recv(const void *data, size_t size, void *priv)
|
||||
|
@ -222,6 +230,15 @@ int nrfs_backend_wait_for_connection(k_timeout_t timeout)
|
|||
return (events == IPC_INIT_DONE_EVENT ? 0 : (-EAGAIN));
|
||||
}
|
||||
|
||||
void nrfs_backend_register_bound_subscribe(struct nrfs_backend_bound_info_subs *subs,
|
||||
nrfs_backend_bound_info_cb_t cb)
|
||||
{
|
||||
if (cb) {
|
||||
subs->cb = cb;
|
||||
sys_slist_append(&nrfs_backend_info_cb_slist, &subs->node);
|
||||
}
|
||||
}
|
||||
|
||||
__weak void nrfs_backend_fatal_error_handler(enum nrfs_backend_error error_id)
|
||||
{
|
||||
LOG_ERR("Fatal error: %d rebooting...", error_id);
|
||||
|
|
|
@ -86,6 +86,21 @@ nrfs_err_t nrfs_backend_send_ex(void *message, size_t size, k_timeout_t timeout,
|
|||
*/
|
||||
void nrfs_backend_fatal_error_handler(enum nrfs_backend_error error_id);
|
||||
|
||||
typedef void (*nrfs_backend_bound_info_cb_t)(void);
|
||||
struct nrfs_backend_bound_info_subs {
|
||||
sys_snode_t node;
|
||||
nrfs_backend_bound_info_cb_t cb;
|
||||
};
|
||||
/**
|
||||
* @brief Register callback function to notify when nrfs is connected.
|
||||
* There can be multiple callbacks registered.
|
||||
*
|
||||
* @param subs Subcription instance.
|
||||
* @param cb Callback
|
||||
*/
|
||||
void nrfs_backend_register_bound_subscribe(struct nrfs_backend_bound_info_subs *subs,
|
||||
nrfs_backend_bound_info_cb_t cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue