Zephyr API Documentation  3.0.0
A Scalable Open Source RTOS
3.0.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
consumer.h File Reference

Regulator consumer API based on linux regulator API. More...

#include <zephyr/types.h>
#include <drivers/regulator.h>

Go to the source code of this file.

Functions

int regulator_count_voltages (const struct device *dev)
 Return the number of supported voltage levels Returns the number of selectors, or negative errno. Selectors are numbered starting at zero, and typically correspond to bitfields in hardware registers. More...
 
int regulator_list_voltages (const struct device *dev, unsigned int selector)
 Return supported voltage Returns a voltage that can be passed to regulator_set_voltage(), zero if the selector code can't be used, or a negative errno. More...
 
int regulator_is_supported_voltage (const struct device *dev, int min_uV, int max_uV)
 Check if a voltage range can be supported. More...
 
int regulator_set_voltage (const struct device *dev, int min_uV, int max_uV)
 Set regulator output voltage. Sets a regulator to the closest supported output voltage. More...
 
int regulator_get_voltage (const struct device *dev)
 Get regulator output voltage. Returns the current regulator voltage in microvolts. More...
 
int regulator_set_current_limit (const struct device *dev, int min_uA, int max_uA)
 Set regulator output current limit Sets current sink to desired output current. More...
 
int regulator_get_current_limit (const struct device *dev)
 Get regulator output current. Note the current limit must have been set for this call to succeed. More...
 

Detailed Description

Regulator consumer API based on linux regulator API.

Copyright (c) 2021 NXP

SPDX-License-Identifier: Apache-2.0

This API extends the Zephyr regulator API by implementing voltage and current level control for supported regulators. Currently, the only supported device is the NXP PCA9420 PMIC.

Function Documentation

◆ regulator_count_voltages()

int regulator_count_voltages ( const struct device dev)

Return the number of supported voltage levels Returns the number of selectors, or negative errno. Selectors are numbered starting at zero, and typically correspond to bitfields in hardware registers.

Parameters
devRegulator device to count voltage levels for.
Returns
number of selectors, or negative errno.

◆ regulator_get_current_limit()

int regulator_get_current_limit ( const struct device dev)

Get regulator output current. Note the current limit must have been set for this call to succeed.

Parameters
devRegulator to query
Returns
current limit in uA, or errno

◆ regulator_get_voltage()

int regulator_get_voltage ( const struct device dev)

Get regulator output voltage. Returns the current regulator voltage in microvolts.

Parameters
devRegulator to query
Returns
voltage level in uV

◆ regulator_is_supported_voltage()

int regulator_is_supported_voltage ( const struct device dev,
int  min_uV,
int  max_uV 
)

Check if a voltage range can be supported.

Parameters
devRegulator to check range against.
min_uVMinimum voltage in microvolts
max_uVmaximum voltage in microvolts
Returns
boolean or negative error code.

◆ regulator_list_voltages()

int regulator_list_voltages ( const struct device dev,
unsigned int  selector 
)

Return supported voltage Returns a voltage that can be passed to regulator_set_voltage(), zero if the selector code can't be used, or a negative errno.

Parameters
devRegulator device to get voltage for.
selectorvoltage selector code.
Returns
voltage level in uV, or zero if selector code can't be used.

◆ regulator_set_current_limit()

int regulator_set_current_limit ( const struct device dev,
int  min_uA,
int  max_uA 
)

Set regulator output current limit Sets current sink to desired output current.

Parameters
devRegulator to set output current level
min_uAminimum microamps
max_uAmaximum microamps
Returns
0 on success, or errno on error

◆ regulator_set_voltage()

int regulator_set_voltage ( const struct device dev,
int  min_uV,
int  max_uV 
)

Set regulator output voltage. Sets a regulator to the closest supported output voltage.

Parameters
devRegulator to set voltage
min_uVMinimum acceptable voltage in microvolts
max_uVMaximum acceptable voltage in microvolts