8#ifndef ZEPHYR_INCLUDE_SYS_ONOFF_H_
9#define ZEPHYR_INCLUDE_SYS_ONOFF_H_
30#define ONOFF_FLAG_ERROR BIT(0)
33#define ONOFF_FLAG_ONOFF BIT(1)
35#define ONOFF_FLAG_TRANSITION BIT(2)
45#define ONOFF_STATE_MASK (ONOFF_FLAG_ERROR \
47 | ONOFF_FLAG_TRANSITION)
52#define ONOFF_STATE_OFF 0U
57#define ONOFF_STATE_ON ONOFF_FLAG_ONOFF
63#define ONOFF_STATE_ERROR ONOFF_FLAG_ERROR
69#define ONOFF_STATE_TO_ON (ONOFF_FLAG_TRANSITION | ONOFF_STATE_ON)
75#define ONOFF_STATE_TO_OFF (ONOFF_FLAG_TRANSITION | ONOFF_STATE_OFF)
81#define ONOFF_STATE_RESETTING (ONOFF_FLAG_TRANSITION | ONOFF_STATE_ERROR)
190#define ONOFF_TRANSITIONS_INITIALIZER(_start, _stop, _reset) { \
197#define ONOFF_MANAGER_INITIALIZER(_transitions) { \
198 .transitions = _transitions, \
298#define ONOFF_CLIENT_EXTENSION_POS SYS_NOTIFY_EXTENSION_POS
void
Definition: eswifi_shell.c:15
volatile int rv
Definition: main.c:45
int onoff_sync_lock(struct onoff_sync_service *srv, k_spinlock_key_t *keyp)
Lock a synchronous onoff service and provide its state.
int onoff_release(struct onoff_manager *mgr)
Release a reserved use of an on-off service.
int onoff_request(struct onoff_manager *mgr, struct onoff_client *cli)
Request a reservation to use an on-off service.
static bool onoff_has_error(const struct onoff_manager *mgr)
Test whether an on-off service has recorded an error.
Definition: onoff.h:313
void(* onoff_client_callback)(struct onoff_manager *mgr, struct onoff_client *cli, uint32_t state, int res)
Signature used to notify an on-off service client of the completion of an operation.
Definition: onoff.h:251
int onoff_monitor_unregister(struct onoff_manager *mgr, struct onoff_monitor *mon)
Remove a monitor of state changes from a manager.
void(* onoff_transition_fn)(struct onoff_manager *mgr, onoff_notify_fn notify)
Signature used by service implementations to effect a transition.
Definition: onoff.h:129
int onoff_manager_init(struct onoff_manager *mgr, const struct onoff_transitions *transitions)
Initialize an on-off service to off state.
static int onoff_cancel_or_release(struct onoff_manager *mgr, struct onoff_client *cli)
Helper function to safely cancel a request.
Definition: onoff.h:433
int onoff_monitor_register(struct onoff_manager *mgr, struct onoff_monitor *mon)
Add a monitor of state changes for a manager.
#define ONOFF_FLAG_ERROR
Flag indicating an error state.
Definition: onoff.h:30
void(* onoff_notify_fn)(struct onoff_manager *mgr, int res)
Signature used to notify an on-off manager that a transition has completed.
Definition: onoff.h:101
int onoff_cancel(struct onoff_manager *mgr, struct onoff_client *cli)
Attempt to cancel an in-progress client operation.
int onoff_sync_finalize(struct onoff_sync_service *srv, k_spinlock_key_t key, struct onoff_client *cli, int res, bool on)
Process the completion of a transition in a synchronous service and release lock.
void(* onoff_monitor_callback)(struct onoff_manager *mgr, struct onoff_monitor *mon, uint32_t state, int res)
Signature used to notify a monitor of an onoff service of errors or completion of a state transition.
Definition: onoff.h:510
int onoff_reset(struct onoff_manager *mgr, struct onoff_client *cli)
Clear errors on an on-off service and reset it to its off state.
#define EALREADY
Definition: errno.h:105
state
Definition: http_parser_state.h:30
struct _slist sys_slist_t
Definition: slist.h:40
struct _snode sys_snode_t
Definition: slist.h:33
struct z_spinlock_key k_spinlock_key_t
Spinlock key type.
Definition: spinlock.h:87
static k_spinlock_key_t key
Definition: spinlock_error_case.c:14
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__INT32_TYPE__ int32_t
Definition: stdint.h:44
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
Kernel Spin Lock.
Definition: spinlock.h:29
State associated with a client of an on-off service.
Definition: onoff.h:273
sys_snode_t node
Definition: onoff.h:280
struct sys_notify notify
Notification configuration.
Definition: onoff.h:283
State associated with an on-off manager.
Definition: onoff.h:154
sys_slist_t clients
Definition: onoff.h:158
uint16_t refs
Definition: onoff.h:178
sys_slist_t monitors
Definition: onoff.h:163
uint16_t flags
Definition: onoff.h:175
int last_res
Definition: onoff.h:172
const struct onoff_transitions * transitions
Definition: onoff.h:166
struct k_spinlock lock
Definition: onoff.h:169
Registration state for notifications of onoff service transitions.
Definition: onoff.h:522
sys_snode_t node
Definition: onoff.h:527
onoff_monitor_callback callback
Callback to be invoked on state change.
Definition: onoff.h:533
State used when a driver uses the on-off service API for synchronous operations.
Definition: onoff.h:574
struct k_spinlock lock
Definition: onoff.h:576
int32_t count
Definition: onoff.h:579
On-off service transition functions.
Definition: onoff.h:133
onoff_transition_fn reset
Definition: onoff.h:143
onoff_transition_fn start
Definition: onoff.h:135
onoff_transition_fn stop
Definition: onoff.h:138
State associated with notification for an asynchronous operation.
Definition: notify.h:138