irrigation_system/software/include/lib/adc_sensor.h

68 lines
1.9 KiB
C

#ifndef ADC_SENSOR_H
#define ADC_SENSOR_H
#include <stdint.h>
/**
* @file adc_sensor.h
* @brief API for the ADC sensor library.
*
* This library provides functions to initialize and read from the ADC sensors,
* specifically for measuring supply voltage and motor current.
* It can operate in a real or simulated mode.
*/
/**
* @brief Initializes the ADC sensor system.
*
* This function sets up the necessary ADC channels and configurations.
* It should be called once before any other function in this library.
* In simulated mode, it logs the simulated values.
*
* @return 0 on success, or a negative error code on failure.
*/
int adc_sensor_init(void);
/**
* @brief Gets the current supply voltage reading.
*
* This function reads the value from the corresponding ADC channel and converts
* it to millivolts.
*
* @return The supply voltage in millivolts (mV).
*/
uint16_t adc_sensor_get_voltage_mv(void);
/**
* @brief Gets the current motor current reading (legacy function).
*
* This function reads the current from the opening channel (IN0).
* For backward compatibility only. Use adc_sensor_get_current_open_ma()
* instead.
*
* @return The motor current in milliamps (mA).
*/
uint16_t adc_sensor_get_current_ma(void);
/**
* @brief Gets the motor opening current reading (IN0 current sense).
*
* This function reads the current from the VND7050AJ IN0 current sense channel.
* Used for monitoring valve opening current.
*
* @return The motor opening current in milliamps (mA).
*/
uint16_t adc_sensor_get_current_open_ma(void);
/**
* @brief Gets the motor closing current reading (IN1 current sense).
*
* This function reads the current from the VND7050AJ IN1 current sense channel.
* Used for monitoring valve closing current.
*
* @return The motor closing current in milliamps (mA).
*/
uint16_t adc_sensor_get_current_close_ma(void);
#endif /* ADC_SENSOR_H */