Fixed multiple bugs and errors.
- Added WARNING handler - put voltage calculations to dedicated module fixed last errors. Updated menu repair screen without ERROR from PID This is version 0.9.0.3, which is used for the first duration test Will also be tagged git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@272 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -25,9 +25,8 @@
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "DAConverter.h"
|
||||
#include "Voltage.h"
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
@@ -52,8 +51,6 @@
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static uint32_t calculateDACValue(const struct DAConverter* self, int voltage);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -83,7 +80,7 @@ void DAConverter_destruct(struct DAConverter* self)
|
||||
|
||||
|
||||
|
||||
extern ErrorStatus DAConverter_setOutputVoltage(const struct DAConverter* self, int voltage)
|
||||
ErrorStatus DAConverter_setOutputVoltage(const struct DAConverter* self, int voltage)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (returnValue == SUCCESS)
|
||||
@@ -91,7 +88,7 @@ extern ErrorStatus DAConverter_setOutputVoltage(const struct DAConverter* self,
|
||||
if (self->initialized)
|
||||
{
|
||||
uint32_t dacValue;
|
||||
dacValue = calculateDACValue(self, voltage);
|
||||
dacValue = Voltage_calculateDeviceValue(voltage, self->dacDevice->resolutionInBits, self->minVoltage, self->maxVoltage);
|
||||
DACDevice_write(self->dacDevice, dacValue);
|
||||
}
|
||||
}
|
||||
@@ -103,23 +100,15 @@ extern ErrorStatus DAConverter_setOutputVoltage(const struct DAConverter* self,
|
||||
}
|
||||
|
||||
|
||||
static uint32_t calculateDACValue(const struct DAConverter* self, int voltage)
|
||||
uint32_t DAConverter_getCurrentValue(const struct DAConverter* self)
|
||||
{
|
||||
uint32_t dacValue;
|
||||
uint32_t returnValue = 0;
|
||||
if (self->initialized)
|
||||
{
|
||||
int maxDacValue = ((1 << self->dacDevice->resolutionInBits) - 1);
|
||||
int tempValue = (voltage - self->minVoltage) * maxDacValue;
|
||||
tempValue /= (self->maxVoltage - self->minVoltage);
|
||||
dacValue = abs(tempValue);
|
||||
if (dacValue > maxDacValue)
|
||||
{
|
||||
dacValue = maxDacValue;
|
||||
}
|
||||
returnValue = Voltage_calculateVoltage(DACDevice_getCurrentValue(self->dacDevice), self->dacDevice->resolutionInBits, self->minVoltage, self->maxVoltage);
|
||||
}
|
||||
else
|
||||
{
|
||||
dacValue = 0;
|
||||
}
|
||||
return dacValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user