Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
|
Regulator Interface . More...
Typedefs | |
typedef uint8_t | regulator_dvs_state_t |
Opaque type to store regulator DVS states. | |
typedef uint8_t | regulator_mode_t |
Opaque type to store regulator modes. | |
typedef uint8_t | regulator_error_flags_t |
Opaque bit map for regulator error flags (see REGULATOR_ERRORS) | |
Functions | |
int | regulator_enable (const struct device *dev) |
Enable a regulator. | |
bool | regulator_is_enabled (const struct device *dev) |
Check if a regulator is enabled. | |
int | regulator_disable (const struct device *dev) |
Disable a regulator. | |
static unsigned int | regulator_count_voltages (const struct device *dev) |
Obtain the number of supported voltage levels. | |
static int | regulator_list_voltage (const struct device *dev, unsigned int idx, int32_t *volt_uv) |
Obtain the value of a voltage given an index. | |
bool | regulator_is_supported_voltage (const struct device *dev, int32_t min_uv, int32_t max_uv) |
Check if a voltage within a window is supported. | |
int | regulator_set_voltage (const struct device *dev, int32_t min_uv, int32_t max_uv) |
Set the output voltage. | |
static int | regulator_get_voltage (const struct device *dev, int32_t *volt_uv) |
Obtain output voltage. | |
static unsigned int | regulator_count_current_limits (const struct device *dev) |
Obtain the number of supported current limit levels. | |
static int | regulator_list_current_limit (const struct device *dev, unsigned int idx, int32_t *current_ua) |
Obtain the value of a current limit given an index. | |
int | regulator_set_current_limit (const struct device *dev, int32_t min_ua, int32_t max_ua) |
Set output current limit. | |
static int | regulator_get_current_limit (const struct device *dev, int32_t *curr_ua) |
Get output current limit. | |
int | regulator_set_mode (const struct device *dev, regulator_mode_t mode) |
Set mode. | |
static int | regulator_get_mode (const struct device *dev, regulator_mode_t *mode) |
Get mode. | |
static int | regulator_set_active_discharge (const struct device *dev, bool active_discharge) |
Set active discharge setting. | |
static int | regulator_get_active_discharge (const struct device *dev, bool *active_discharge) |
Get active discharge setting. | |
static int | regulator_get_error_flags (const struct device *dev, regulator_error_flags_t *flags) |
Get active error flags. | |
Regulator error flags. | |
#define | REGULATOR_ERROR_OVER_VOLTAGE BIT(0) |
Voltage is too high. | |
#define | REGULATOR_ERROR_OVER_CURRENT BIT(1) |
Current is too high. | |
#define | REGULATOR_ERROR_OVER_TEMP BIT(2) |
Temperature is too high. | |
Regulator Interface .
#define REGULATOR_ERROR_OVER_CURRENT BIT(1) |
#include <zephyr/drivers/regulator.h>
Current is too high.
#define REGULATOR_ERROR_OVER_TEMP BIT(2) |
#include <zephyr/drivers/regulator.h>
Temperature is too high.
#define REGULATOR_ERROR_OVER_VOLTAGE BIT(0) |
#include <zephyr/drivers/regulator.h>
Voltage is too high.
typedef uint8_t regulator_dvs_state_t |
#include <zephyr/drivers/regulator.h>
Opaque type to store regulator DVS states.
typedef uint8_t regulator_error_flags_t |
#include <zephyr/drivers/regulator.h>
Opaque bit map for regulator error flags (see REGULATOR_ERRORS)
typedef uint8_t regulator_mode_t |
#include <zephyr/drivers/regulator.h>
Opaque type to store regulator modes.
#include <zephyr/drivers/regulator.h>
Obtain the number of supported current limit levels.
Each current limit level supported by a regulator gets an index, starting from zero. The total number of supported current limit levels can be used together with regulator_list_current_limit() to list all supported current limit levels.
dev | Regulator device instance. |
#include <zephyr/drivers/regulator.h>
Obtain the number of supported voltage levels.
Each voltage level supported by a regulator gets an index, starting from zero. The total number of supported voltage levels can be used together with regulator_list_voltage() to list all supported voltage levels.
dev | Regulator device instance. |
int regulator_disable | ( | const struct device * | dev | ) |
#include <zephyr/drivers/regulator.h>
Disable a regulator.
Release a regulator after a previous regulator_enable() completed successfully. Regulators that are always on, or configured in devicetree with regulator-always-on
will always stay enabled, and so this function will always succeed.
This must be invoked at most once for each successful regulator_enable().
dev | Regulator device instance. |
0 | If regulator has been successfully disabled. |
-errno | Negative errno in case of failure. |
-ENOTSUP | If regulator disablement can not be controlled. |
int regulator_enable | ( | const struct device * | dev | ) |
#include <zephyr/drivers/regulator.h>
Enable a regulator.
Reference-counted request that a regulator be turned on. A regulator is considered "on" when it has reached a stable/usable state. Regulators that are always on, or configured in devicetree with regulator-always-on
will always stay enabled, and so this function will always succeed.
dev | Regulator device instance |
0 | If regulator has been successfully enabled. |
-errno | Negative errno in case of failure. |
-ENOTSUP | If regulator enablement can not be controlled. |
|
inlinestatic |
#include <zephyr/drivers/regulator.h>
Get active discharge setting.
dev | Regulator device instance. | |
[out] | active_discharge | Where active discharge will be stored. |
0 | If successful. |
-ENOSYS | If function is not implemented. |
-errno | In case of any other error. |
|
inlinestatic |
#include <zephyr/drivers/regulator.h>
Get output current limit.
dev | Regulator device instance. | |
[out] | curr_ua | Where output current limit will be stored. |
0 | If successful. |
-ENOSYS | If function is not implemented. |
-errno | In case of any other error. |
|
inlinestatic |
#include <zephyr/drivers/regulator.h>
Get active error flags.
dev | Regulator device instance. | |
[out] | flags | Where error flags will be stored. |
0 | If successful. |
-ENOSYS | If function is not implemented. |
-errno | In case of any other error. |
|
inlinestatic |
#include <zephyr/drivers/regulator.h>
Get mode.
dev | Regulator device instance. | |
[out] | mode | Where mode will be stored. |
0 | If successful. |
-ENOSYS | If function is not implemented. |
-errno | In case of any other error. |
#include <zephyr/drivers/regulator.h>
Obtain output voltage.
dev | Regulator device instance. | |
[out] | volt_uv | Where configured output voltage will be stored. |
0 | If successful |
-ENOSYS | If function is not implemented. |
-errno | In case of any other error. |
#include <zephyr/drivers/regulator.h>
Check if a regulator is enabled.
dev | Regulator device instance. |
true | If regulator is enabled. |
false | If regulator is disabled. |
#include <zephyr/drivers/regulator.h>
Check if a voltage within a window is supported.
dev | Regulator device instance. |
min_uv | Minimum voltage in microvolts. |
max_uv | maximum voltage in microvolts. |
true | If voltage is supported. |
false | If voltage is not supported. |
|
inlinestatic |
#include <zephyr/drivers/regulator.h>
Obtain the value of a current limit given an index.
Each current limit level supported by a regulator gets an index, starting from zero. Together with regulator_count_current_limits(), this function can be used to iterate over all supported current limits.
dev | Regulator device instance. | |
idx | Current index. | |
[out] | current_ua | Where current for the given index will be stored, in microamps. |
0 | If index corresponds to a supported current limit. |
-EINVAL | If index does not correspond to a supported current limit. |
|
inlinestatic |
#include <zephyr/drivers/regulator.h>
Obtain the value of a voltage given an index.
Each voltage level supported by a regulator gets an index, starting from zero. Together with regulator_count_voltages(), this function can be used to iterate over all supported voltages.
dev | Regulator device instance. | |
idx | Voltage index. | |
[out] | volt_uv | Where voltage for the given index will be stored, in microvolts. |
0 | If index corresponds to a supported voltage. |
-EINVAL | If index does not correspond to a supported voltage. |
|
inlinestatic |
#include <zephyr/drivers/regulator.h>
Set active discharge setting.
dev | Regulator device instance. |
active_discharge | Active discharge enable or disable. |
0 | If successful. |
-ENOSYS | If function is not implemented. |
-errno | In case of any other error. |
#include <zephyr/drivers/regulator.h>
Set output current limit.
The output current limit will be configured to the closest supported output current limit. regulator_get_current_limit() can be used to obtain the actual configured current limit. Current may be limited using current-min-microamp
and/or current-max-microamp
in Devicetree.
dev | Regulator device instance. |
min_ua | Minimum acceptable current limit in microamps. |
max_ua | Maximum acceptable current limit in microamps. |
0 | If successful. |
-EINVAL | If the given current limit window is not valid. |
-ENOSYS | If function is not implemented. |
-errno | In case of any other error. |
int regulator_set_mode | ( | const struct device * | dev, |
regulator_mode_t | mode ) |
#include <zephyr/drivers/regulator.h>
Set mode.
Regulators can support multiple modes in order to permit different voltage configuration or better power savings. This API will apply a mode for the regulator. Allowed modes may be limited using regulator-allowed-modes
devicetree property.
dev | Regulator device instance. |
mode | Mode to select for this regulator. |
0 | If successful. |
-ENOTSUP | If mode is not supported. |
-ENOSYS | If function is not implemented. |
-errno | In case of any other error. |
#include <zephyr/drivers/regulator.h>
Set the output voltage.
The output voltage will be configured to the closest supported output voltage. regulator_get_voltage() can be used to obtain the actual configured voltage. The voltage will be applied to the active or selected mode. Output voltage may be limited using regulator-min-microvolt
and/or regulator-max-microvolt
in devicetree.
dev | Regulator device instance. |
min_uv | Minimum acceptable voltage in microvolts. |
max_uv | Maximum acceptable voltage in microvolts. |
0 | If successful. |
-EINVAL | If the given voltage window is not valid. |
-ENOSYS | If function is not implemented. |
-errno | In case of any other error. |