Clock Control¶
Overview¶
The clock control API provides access to clocks in the system, including the ability to turn them on and off.
API Reference¶
-
group
clock_control_interface
Clock Control Interface.
Defines
-
CLOCK_CONTROL_SUBSYS_ALL
¶
-
CLOCK_CONTROL_ASYNC_DATA_DEFINE
(name, cb, user_data)¶ Define and initialize clock_control async data.
- Parameters
name
: Name of the data.cb
: Callback.user_data
: User data
Typedefs
-
typedef void *
clock_control_subsys_t
¶ clock_control_subsys_t is a type to identify a clock controller sub-system. Such data pointed is opaque and relevant only to the clock controller driver instance being used.
-
typedef void (*
clock_control_cb_t
)(const struct device *dev, clock_control_subsys_t subsys, void *user_data)¶ Callback called on clock started.
- Parameters
dev
: Device structure whose driver controls the clock.subsys
: Opaque data representing the clock.user_data
: User data.
-
typedef int (*
clock_control
)(const struct device *dev, clock_control_subsys_t sys)¶
-
typedef int (*
clock_control_get
)(const struct device *dev, clock_control_subsys_t sys, uint32_t *rate)¶
-
typedef int (*
clock_control_async_on_fn
)(const struct device *dev, clock_control_subsys_t sys, struct clock_control_async_data *data)¶
-
typedef enum clock_control_status (*
clock_control_get_status_fn
)(const struct device *dev, clock_control_subsys_t sys)¶
Enums
Functions
-
int
clock_control_on
(const struct device *dev, clock_control_subsys_t sys)¶ Enable a clock controlled by the device.
On success, the clock is enabled and ready when this function returns. This function may sleep, and thus can only be called from thread context.
Use clock_control_async_on() for non-blocking operation.
- Return
0 on success, negative errno on failure.
- Parameters
dev
: Device structure whose driver controls the clock.sys
: Opaque data representing the clock.
-
int
clock_control_off
(const struct device *dev, clock_control_subsys_t sys)¶ Disable a clock controlled by the device.
This function is non-blocking and can be called from any context. On success, the clock is disabled when this function returns.
- Return
0 on success, negative errno on failure.
- Parameters
dev
: Device structure whose driver controls the clocksys
: Opaque data representing the clock
-
int
clock_control_async_on
(const struct device *dev, clock_control_subsys_t sys, struct clock_control_async_data *data)¶ Request clock to start with notification when clock has been started.
Function is non-blocking and can be called from any context. When clock is already running user callback will be called from the context of the function call else it is called from other context (e.g. clock interrupt).
- Parameters
dev
: Device.sys
: A pointer to an opaque data representing the sub-system.data
: Data structure containing a callback that is called when action is performed. Structure content must be valid until clock is started and user callback is called. Can be NULL.
- Return Value
0
: if clock is started or already running.-EBUSY
: if same request already scheduled and not yet completed.-ENOTSUP
: if not supported.
-
enum clock_control_status
clock_control_get_status
(const struct device *dev, clock_control_subsys_t sys)¶ Get clock status.
- Return
Status.
- Parameters
dev
: Device.sys
: A pointer to an opaque data representing the sub-system.
-
int
clock_control_get_rate
(const struct device *dev, clock_control_subsys_t sys, uint32_t *rate)¶ Obtain the clock rate of given sub-system.
- Parameters
dev
: Pointer to the device structure for the clock controller driver instancesys
: A pointer to an opaque data representing the sub-system[out] rate
: Subsystem clock rate
-
struct
clock_control_async_data
¶ - #include <clock_control.h>
Clock control data used for asynchronous clock enabling.
- Parameters
node
: Used internally for linking asynchronous requests.cb
: Callback called when clock is started.user_data
: User data passed as an argument in the callback.
-
struct
clock_control_driver_api
¶ - #include <clock_control.h>
-