LoRa-BLE-Sensor
Loading...
Searching...
No Matches
Classes | Macros | Functions
sensor_power.h File Reference

This is a library for sensor power configurations and control. This is manages the power configuration, pin configuration, and control of sensor power. More...

#include "sensor_id.h"
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/adc.h>
Include dependency graph for sensor_power.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  sensor_power_config_t
 Sensor power configuration. More...
 

Macros

#define OUTUT_READ_DIVIDER_HIGH   100
 
#define OUTUT_READ_DIVIDER_LOW   13
 

Functions

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 regulator device being used. After configurations are set, the sensors output is set OFF.
 
enum sensor_voltage get_sensor_output (sensor_power_config_t *config)
 Get the sensor voltage that is set for an output.
 
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 correct gpios. When setting the voltage to OFF the voltage may take 1-2 seconds to fully turn off, due to capacitors on the output.
 
float read_sensor_output (sensor_power_config_t *config)
 Read the voltage output of the selected sensor power configuration. Takes into account resistor divider on output.
 
int validate_output (sensor_power_config_t *config, enum sensor_voltage voltage, uint8_t accepted_error)
 

Detailed Description

This is a library for sensor power configurations and control. This is manages the power configuration, pin configuration, and control of sensor power.

Author
Tyler Garcia
Version
0.1
Date
2025-05-09

Function Documentation

◆ get_sensor_output()

enum sensor_voltage get_sensor_output ( sensor_power_config_t config)

Get the sensor voltage that is set for an output.

Parameters
configsensor_power_config_t sensor power configuration for the current sensor
Returns
enum sensor_voltage for selected sensor configuration

◆ read_sensor_output()

float read_sensor_output ( sensor_power_config_t config)

Read the voltage output of the selected sensor power configuration. Takes into account resistor divider on output.

Parameters
configsensor_power_config_t sensor power configuration for the current sensor
Returns
float output of the sensor power system

◆ sensor_power_init()

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 regulator device being used. After configurations are set, the sensors output is set OFF.

Parameters
configsensor_power_config_t sensor power configuration for the current sensor
Returns
int -1 if error setting up power system or adc

◆ set_sensor_output()

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 correct gpios. When setting the voltage to OFF the voltage may take 1-2 seconds to fully turn off, due to capacitors on the output.

Parameters
configsensor_power_config_t sensor power configuration for the current sensor
voltageenum sensor_voltage setting selected
Returns
int 0 if successful, sets voltage to OFF if invalid voltage input

◆ validate_output()

int validate_output ( sensor_power_config_t config,
enum sensor_voltage  voltage,
uint8_t  accepted_error 
)
Parameters
configsensor_power_config_t sensor power configuration for the current sensor
voltageenum sensor_voltage setting selected
accepted_errorerror in percent that the device is allowed to be off by
Returns
int 0 if successful, -1 if not