LoRa-BLE-Sensor
Loading...
Searching...
No Matches
sensor_power.h
Go to the documentation of this file.
1
13#ifndef SENSOR_POWER_H
14#define SENSOR_POWER_H
15
16#include "sensor_id.h"
17#include <zephyr/drivers/gpio.h>
18#include <zephyr/drivers/adc.h>
19
20#define OUTUT_READ_DIVIDER_HIGH 100
21#define OUTUT_READ_DIVIDER_LOW 13
22
26typedef struct {
27 /* Sensor power configurationid. */
28 enum sensor_power_id power_id;
29 /* GPIO spec for the boost enable pin. */
30 struct gpio_dt_spec boost_en;
31 /* GPIO spec for the boost control 1 pin. */
32 struct gpio_dt_spec boost_ctrl1;
33 /* GPIO spec for the boost control 2 pin. */
34 struct gpio_dt_spec boost_ctrl2;
35 /* LDO device for the sensor. */
36 const struct device *ldo_dev;
37 /* ADC spec for reading the output voltage. */
38 const struct adc_dt_spec output_read;
39 /* Delay in ms to wait after setting the voltage to allow the voltage to stabilize. */
40 uint32_t delay_ms;
42
51
59
69
77
86int validate_output(sensor_power_config_t *config, enum sensor_voltage voltage, uint8_t accepted_error);
87
88#endif
89
This is a library to keep track of sensor ids and sensor power ids. As well as the configuration for ...
sensor_power_id
Sensor power identifiers.
Definition sensor_id.h:45
sensor_voltage
Voltage levels for sensor power.
Definition sensor_id.h:54
int validate_output(sensor_power_config_t *config, enum sensor_voltage voltage, uint8_t accepted_error)
Definition sensor_power.c:228
enum sensor_voltage get_sensor_output(sensor_power_config_t *config)
Get the sensor voltage that is set for an output.
Definition sensor_power.c:185
int set_sensor_output(sensor_power_config_t *config, enum sensor_voltage voltage)
Set the sensor voltage for an output, enabling/disabling the correct regulators, and setting the corr...
Definition sensor_power.c:53
float read_sensor_output(sensor_power_config_t *config)
Read the voltage output of the selected sensor power configuration. Takes into account resistor divid...
Definition sensor_power.c:215
int sensor_power_init(sensor_power_config_t *config)
Initialize a sensor_power_setup. This sets the id of the output, the gpios beings used and the regula...
Definition sensor_power.c:170
Sensor power configuration.
Definition sensor_power.h:26