feat(lib): Introduce adc_sensor library

Adds a new `adc_sensor` library to abstract reading analog values from ADC channels. The output of this library is currently simulated.

This library is now used by the `modbus_server` to read the motor current and the main supply voltage, replacing the previous implementation. This change improves modularity by centralizing ADC-related code into a dedicated module.

The build system has been updated to include the new library.
This commit is contained in:
2025-07-08 15:19:44 +02:00
parent edf0fb2563
commit c9b0f38576
7 changed files with 117 additions and 2 deletions

View File

@@ -0,0 +1,27 @@
#ifndef ADC_SENSOR_H
#define ADC_SENSOR_H
#include <stdint.h>
/**
* @brief Initialize the ADC sensor system
*
* @return 0 on success, negative error code on failure
*/
int adc_sensor_init(void);
/**
* @brief Get supply voltage reading in millivolts
*
* @return Voltage in millivolts (currently simulated: 12000mV)
*/
uint16_t adc_sensor_get_voltage_mv(void);
/**
* @brief Get motor current reading in milliamps
*
* @return Current in milliamps (currently simulated: 45mA)
*/
uint16_t adc_sensor_get_current_ma(void);
#endif /* ADC_SENSOR_H */