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

Go to the source code of this file.

Data Structures

struct  current_sense_amplifier_dt_spec
 

Macros

#define CURRENT_SENSE_AMPLIFIER_DT_SPEC_GET(node_id)
 Get current sensor information from devicetree.
 

Functions

static void current_sense_amplifier_scale_dt (const struct current_sense_amplifier_dt_spec *spec, int32_t *v_to_i)
 Calculates the actual amperage from the measured voltage.
 

Macro Definition Documentation

◆ CURRENT_SENSE_AMPLIFIER_DT_SPEC_GET

#define CURRENT_SENSE_AMPLIFIER_DT_SPEC_GET ( node_id)
Value:
{ \
.port = ADC_DT_SPEC_GET(node_id), \
.sense_milli_ohms = DT_PROP(node_id, sense_resistor_milli_ohms), \
.sense_gain_mult = DT_PROP(node_id, sense_gain_mult), \
.sense_gain_div = DT_PROP(node_id, sense_gain_div), \
.power_gpio = GPIO_DT_SPEC_GET_OR(node_id, power_gpios, {0}), \
}
#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(node_id, prop)
Get a devicetree property value.
Definition devicetree.h:752
#define GPIO_DT_SPEC_GET_OR(node_id, prop, default_value)
Equivalent to GPIO_DT_SPEC_GET_BY_IDX_OR(node_id, prop, 0, default_value).
Definition gpio.h:382

Get current sensor information from devicetree.

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

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

Function Documentation

◆ current_sense_amplifier_scale_dt()

static void current_sense_amplifier_scale_dt ( const struct current_sense_amplifier_dt_spec * spec,
int32_t * v_to_i )
inlinestatic

Calculates the actual amperage from the measured voltage.

Parameters
[in]speccurrent sensor specification from Devicetree.
[in,out]v_to_iPointer to the measured voltage in millivolts on input, and the corresponding scaled current value in milliamps on output.