diff --git a/software/Firmware/Src/VoltageSensorActualValue.c b/software/Firmware/Src/VoltageSensorActualValue.c index a14c4f5..1546486 100644 --- a/software/Firmware/Src/VoltageSensorActualValue.c +++ b/software/Firmware/Src/VoltageSensorActualValue.c @@ -9,7 +9,6 @@ #include "PinoutConfiguration.h" #include "UserInterface.h" #include "stm8s_i2c.h" -//#include "Logger.h" #define I2C_MASTER_ADDRESS 0x10 @@ -18,6 +17,15 @@ // is used to signalize communication direction (rx or tx) #define I2C_SLAVE_ADDRESS (0x68u << 1) +#define MCP3425_REG_BIT_READY (1 << 7) +#define MCP3425_REG_BIT_CONVERSION (1 << 4) +#define MCP3425_REG_BIT_SAMPLE_RATE_UPPER (1 << 3) +#define MCP3425_REG_BIT_SAMPLE_RATE_LOWER (1 << 2) +#define MCP3425_REG_BIT_GAIN_UPPER (1 << 1) +#define MCP3425_REG_BIT_GAIN_LOWER (1 << 0) + +#define MCP3425_CONFIGURATION (MCP3425_REG_BIT_READY | MCP3425_REG_BIT_SAMPLE_RATE_UPPER) + static void GPIO_setup(void); static void I2C_setup(void); static void write(uint8_t registerId); @@ -28,16 +36,13 @@ void VoltageSensorActualValue_Init() { GPIO_setup(); I2C_setup(); - - // select adc configuration and start measurement -// write(0x00); - write(0x4c); } bool VoltageSensorActualValue_MeasureValue(VoltageSensorActualValue_MeasurementData_t *measurementData) { - write(0x48); + // select adc configuration and start measurement + write(MCP3425_CONFIGURATION); write(0x10); *measurementData = read(0); @@ -125,7 +130,6 @@ static uint16_t read(uint8_t registerId) Logger_Print( registerLSB3); */ -// printf("data: %d %d %d %d %d\r\n", registerMSB, registerLSB, registerLSB1, registerLSB2, registerLSB3); uint16_t registerValue = (registerMSB << 8) + registerLSB; return registerValue;