irrigation_system/software/include/lib/adc_sensor.h

47 lines
1.2 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.
*
* This function reads the value from the motor driver's sense pin via ADC
* and converts it to milliamps. This is used for end-stop detection.
*
* @return The motor current in milliamps (mA).
*/
uint16_t adc_sensor_get_current_ma(void);
#endif /* ADC_SENSOR_H */