Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
voltage_divider.h File Reference

Go to the source code of this file.

Data Structures

struct  voltage_divider_dt_spec
 

Macros

#define VOLTAGE_DIVIDER_DT_SPEC_GET(node_id)
 Get voltage divider information from devicetree.
 

Functions

static int voltage_divider_scale_dt (const struct voltage_divider_dt_spec *spec, int32_t *v_to_v)
 Calculates the actual voltage from the measured voltage.
 

Macro Definition Documentation

◆ VOLTAGE_DIVIDER_DT_SPEC_GET

#define VOLTAGE_DIVIDER_DT_SPEC_GET ( node_id)
Value:
{ \
.port = ADC_DT_SPEC_GET(node_id), \
.full_ohms = DT_PROP_OR(node_id, full_ohms, 0), \
.output_ohms = DT_PROP(node_id, output_ohms), \
}
#define ADC_DT_SPEC_GET(node_id)
Equivalent to ADC_DT_SPEC_GET_BY_IDX(node_id, 0).
Definition adc.h:516
#define DT_PROP_OR(node_id, prop, default_value)
Like DT_PROP(), but with a fallback to default_value.
Definition devicetree.h:914
#define DT_PROP(node_id, prop)
Get a devicetree property value.
Definition devicetree.h:752

Get voltage divider information from devicetree.

This returns a static initializer for a voltage_divider_dt_spec structure given a devicetree node.

Parameters
node_idDevicetree node identifier.
Returns
Static initializer for an voltage_divider_dt_spec structure.

Function Documentation

◆ voltage_divider_scale_dt()

static int voltage_divider_scale_dt ( const struct voltage_divider_dt_spec * spec,
int32_t * v_to_v )
inlinestatic

Calculates the actual voltage from the measured voltage.

Parameters
[in]specvoltage divider specification from Devicetree.
[in,out]v_to_vPointer to the measured voltage on input, and the corresponding scaled voltage value on output.
Return values
0on success
-ENOTSUPif "full_ohms" is not specified