Major updates:

- added DAConverter(s)
- added ADConverter(s)
- Fixed some display issues
- Made repair process and signalProfileGenerator calculate with voltages (signed) instead of DAC/ADC values
- Fixed several bugs in task handlings
- Put display data mirror into dedicated file displaycontent

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@261 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-10-24 13:56:55 +00:00
parent e3ca058c96
commit bb08cae83a
35 changed files with 1689 additions and 288 deletions

View File

@@ -0,0 +1,120 @@
// -----------------------------------------------------------------------------
/// @file DAConverter.c
/// @brief Description
// -----------------------------------------------------------------------------
// Micro-Key bv
// Industrieweg 28, 9804 TG Noordhorn
// Postbus 92, 9800 AB Zuidhorn
// The Netherlands
// Tel: +31 594 503020
// Fax: +31 594 505825
// Email: support@microkey.nl
// Web: www.microkey.nl
// -----------------------------------------------------------------------------
/// $Revision$
/// $Author$
/// $Date$
// (c) 2017 Micro-Key bv
// -----------------------------------------------------------------------------
/// @file DAConverter.c
/// @ingroup {group_name}
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include "DAConverter.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// File-scope variables
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
static uint32_t calculateDACValue(const struct DAConverter* self, int voltage);
// -----------------------------------------------------------------------------
// Function definitions
// -----------------------------------------------------------------------------
ErrorStatus DAConverter_construct(struct DAConverter* self, int minVoltage, int maxVoltage, struct DACDevice* dacDevice)
{
ErrorStatus returnValue = SUCCESS;
if (!self->initialized)
{
self->minVoltage = minVoltage;
self->maxVoltage = maxVoltage;
self->dacDevice = dacDevice;
self->initialized = true;
}
else
{
returnValue = ERROR;
}
return returnValue;
}
void DAConverter_destruct(struct DAConverter* self)
{
self->initialized = false;
}
extern ErrorStatus DAConverter_setOutputVoltage(const struct DAConverter* self, int voltage)
{
ErrorStatus returnValue = SUCCESS;
if (returnValue == SUCCESS)
{
if (self->initialized)
{
uint32_t dacValue;
dacValue = calculateDACValue(self, voltage);
DACDevice_write(self->dacDevice, dacValue);
}
}
else
{
returnValue = ERROR;
}
return returnValue;
}
static uint32_t calculateDACValue(const struct DAConverter* self, int voltage)
{
uint32_t dacValue;
if (self->initialized)
{
uint32_t maxDacValue = ((1 << self->dacDevice->resolutionInBits) - 1);
dacValue = (voltage - self->minVoltage) * maxDacValue;
dacValue/= (self->maxVoltage - self->minVoltage);
if (dacValue > maxDacValue)
{
dacValue = maxDacValue;
}
}
else
{
dacValue = 0;
}
return dacValue;
}