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:
@@ -0,0 +1,112 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file ADCDevice.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 ADCDevice.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ADCDevice.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ErrorStatus ADCDevice_construct(struct ADCDevice* self, ADCReadFunction read, unsigned int resolutionInBits)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
{
|
||||
if (read != NULL)
|
||||
{
|
||||
self->_read = read;
|
||||
self->resolutionInBits = resolutionInBits;
|
||||
self->initialized = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void ADCDevice_destruct(struct ADCDevice* self)
|
||||
{
|
||||
if (self->initialized)
|
||||
{
|
||||
self->initialized = false;
|
||||
self->_read = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32_t ADCDevice_read(const struct ADCDevice* self)
|
||||
{
|
||||
uint32_t returnValue = 0;
|
||||
if (self->initialized)
|
||||
{
|
||||
if (self->_read != NULL)
|
||||
{
|
||||
returnValue = self->_read(self);
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = 0;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file DACDevice.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 DACDevice.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "DACDevice.h"
|
||||
#include "Logger.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ErrorStatus DACDevice_construct(struct DACDevice* self, DACWriteFunction write, unsigned int resolutionInBits)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
{
|
||||
if (write != NULL)
|
||||
{
|
||||
self->_write = write;
|
||||
self->resolutionInBits = resolutionInBits;
|
||||
self->initialized = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void DACDevice_destruct(struct DACDevice* self)
|
||||
{
|
||||
if (self->initialized)
|
||||
{
|
||||
self->initialized = false;
|
||||
self->_write = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus DACDevice_write(const struct DACDevice* self, uint32_t voltage)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (self->initialized)
|
||||
{
|
||||
if (self->_write != NULL)
|
||||
{
|
||||
returnValue = self->_write(self, voltage);
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
@@ -52,7 +52,7 @@
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
static ErrorStatus channelWrite(const struct DACDevice* self, uint32_t voltage);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
@@ -163,6 +163,11 @@ ErrorStatus MAX5715Channel_construct(struct MAX5715_DAC* self, struct MAX5715* p
|
||||
self->parent = parent;
|
||||
self->value = 0;
|
||||
self->initialized = true;
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = DACDevice_construct(&self->dacDevice, channelWrite, MAX5715_RESOLUTION_IN_BITS);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -208,3 +213,11 @@ ErrorStatus MAX5715Channel_setValue(const struct MAX5715_DAC* self, uint16_t val
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static ErrorStatus channelWrite(const struct DACDevice* self, uint32_t voltage)
|
||||
{
|
||||
// MASK the uint32_t DAC value (voltage) with the resolution of the MAX5715 DAC
|
||||
return MAX5715Channel_setValue((struct MAX5715_DAC*)self, (((1 << MAX5715_RESOLUTION_IN_BITS) - 1) & voltage));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user