added formatting

This commit is contained in:
2025-07-08 16:06:11 +02:00
parent bc327acc41
commit 9b7159d5a4
33 changed files with 685 additions and 615 deletions

View File

@@ -2,14 +2,14 @@
* @file adc_sensor.c
* @brief Implementation of the ADC sensor library.
*
* This file contains the implementation for initializing and reading from ADC sensors.
* It currently provides simulated values for voltage and current, with placeholders
* for real hardware ADC implementation.
* This file contains the implementation for initializing and reading from ADC
* sensors. It currently provides simulated values for voltage and current, with
* placeholders for real hardware ADC implementation.
*/
#include <lib/adc_sensor.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <lib/adc_sensor.h>
LOG_MODULE_REGISTER(adc_sensor, LOG_LEVEL_INF);
@@ -17,54 +17,53 @@ LOG_MODULE_REGISTER(adc_sensor, LOG_LEVEL_INF);
#define SIMULATED_VOLTAGE_MV 12000
#define SIMULATED_CURRENT_MA 45
static bool initialized = false; // Flag to indicate if the ADC sensor is initialized
static bool initialized =
false; // Flag to indicate if the ADC sensor is initialized
int adc_sensor_init(void)
{
if (initialized) {
return 0;
}
#ifdef CONFIG_ADC_SENSOR_SIMULATED
LOG_INF("ADC sensor initialized (simulated mode)");
LOG_INF("Simulated values: %dmV, %dmA", SIMULATED_VOLTAGE_MV, SIMULATED_CURRENT_MA);
#else
// TODO: Initialize real ADC hardware
LOG_INF("ADC sensor initialized (real ADC mode - not yet implemented)");
#endif
initialized = true;
int adc_sensor_init(void) {
if (initialized) {
return 0;
}
uint16_t adc_sensor_get_voltage_mv(void)
{
if (!initialized) {
LOG_WRN("ADC sensor not initialized, calling adc_sensor_init()");
adc_sensor_init();
}
}
#ifdef CONFIG_ADC_SENSOR_SIMULATED
return SIMULATED_VOLTAGE_MV;
LOG_INF("ADC sensor initialized (simulated mode)");
LOG_INF("Simulated values: %dmV, %dmA", SIMULATED_VOLTAGE_MV,
SIMULATED_CURRENT_MA);
#else
// TODO: Read real ADC value for voltage
// For now return simulated value
return SIMULATED_VOLTAGE_MV;
// TODO: Initialize real ADC hardware
LOG_INF("ADC sensor initialized (real ADC mode - not yet implemented)");
#endif
initialized = true;
return 0;
}
uint16_t adc_sensor_get_voltage_mv(void) {
if (!initialized) {
LOG_WRN("ADC sensor not initialized, calling adc_sensor_init()");
adc_sensor_init();
}
#ifdef CONFIG_ADC_SENSOR_SIMULATED
return SIMULATED_VOLTAGE_MV;
#else
// TODO: Read real ADC value for voltage
// For now return simulated value
return SIMULATED_VOLTAGE_MV;
#endif
}
uint16_t adc_sensor_get_current_ma(void)
{
if (!initialized) {
LOG_WRN("ADC sensor not initialized, calling adc_sensor_init()");
adc_sensor_init();
}
uint16_t adc_sensor_get_current_ma(void) {
if (!initialized) {
LOG_WRN("ADC sensor not initialized, calling adc_sensor_init()");
adc_sensor_init();
}
#ifdef CONFIG_ADC_SENSOR_SIMULATED
return SIMULATED_CURRENT_MA;
return SIMULATED_CURRENT_MA;
#else
// TODO: Read real ADC value for current
// For now return simulated value
return SIMULATED_CURRENT_MA;
// TODO: Read real ADC value for current
// For now return simulated value
return SIMULATED_CURRENT_MA;
#endif
}