Fixed issue with external DAC handlign from repair process

repair process implemented. Simple regulation without feedback (must be addeed, yet)

HW validation menu functional but buggy (IOs not OK)

Added ClearLine functionality to displayDevice

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@244 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-10-09 15:29:23 +00:00
parent 0e69a81570
commit a73154a5e6
25 changed files with 1054 additions and 229 deletions

View File

@@ -24,6 +24,7 @@ ARFLAGS = rs
OBJECTS = \
DisplayDevice.o \
IODevice.o \
Logger.o \
MAX5715.o \
nhd0420.o

View File

@@ -0,0 +1,52 @@
// -----------------------------------------------------------------------------
/// @file ADCDevice.h
/// @brief File 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) 2015 Micro-Key bv
// -----------------------------------------------------------------------------
/// @defgroup {group_name} {group_description}
/// Description
/// @file ADCDevice.h
/// @ingroup {group_name}
#ifndef INC_ADCDEVICE_H_
#define INC_ADCDEVICE_H_
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
#endif /* INC_ADCDEVICE_H_ */

View File

@@ -0,0 +1,52 @@
// -----------------------------------------------------------------------------
/// @file DACDevice.h
/// @brief File 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) 2015 Micro-Key bv
// -----------------------------------------------------------------------------
/// @defgroup {group_name} {group_description}
/// Description
/// @file DACDevice.h
/// @ingroup {group_name}
#ifndef INC_DACDEVICE_H_
#define INC_DACDEVICE_H_
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
#endif /* INC_DACDEVICE_H_ */

View File

@@ -58,6 +58,7 @@ typedef ErrorStatus (*DisplayResetFunction)(const struct DisplayDevice* self);
typedef ErrorStatus (*DisplaySetStateFunction)(const struct DisplayDevice* self, DisplayDevice_functionalState state);
typedef ErrorStatus (*DisplayWriteFunction)(const struct DisplayDevice* self, const char* buffer, size_t length, size_t row, size_t column);
typedef ErrorStatus (*DisplayClearFunction)(const struct DisplayDevice* self);
typedef ErrorStatus (*DisplayClearLineFunction)(const struct DisplayDevice* self, size_t row);
typedef ErrorStatus (*DisplaySetBrightnessFunction)(const struct DisplayDevice* self, size_t brightness);
typedef ErrorStatus (*DisplaySetContrastFunction)(const struct DisplayDevice* self, size_t contrast);
typedef ErrorStatus (*DisplayInvertFunction)(const struct DisplayDevice* self);
@@ -78,6 +79,7 @@ struct DisplayDevice
DisplaySetStateFunction _setState;
DisplayWriteFunction _write;
DisplayClearFunction _clear;
DisplayClearLineFunction _clearLine;
DisplaySetBrightnessFunction _setBrightness;
DisplaySetContrastFunction _setContrast;
DisplayInvertFunction _invert;
@@ -94,6 +96,7 @@ extern ErrorStatus DisplayDevice_construct (struct DisplayDevice* self, struct D
DisplaySetStateFunction setState,
DisplayWriteFunction write,
DisplayClearFunction clear,
DisplayClearLineFunction clearLine,
DisplaySetBrightnessFunction setBrightness,
DisplaySetContrastFunction setContrast,
DisplayInvertFunction invert);
@@ -102,6 +105,7 @@ extern ErrorStatus DisplayDevice_reset(const struct DisplayDevice* self);
extern ErrorStatus DisplayDevice_setState(const struct DisplayDevice* self, DisplayDevice_functionalState state);
extern ErrorStatus DisplayDevice_write(const struct DisplayDevice* self, const char* buffer, size_t length, size_t row, size_t column);
extern ErrorStatus DisplayDevice_clear(const struct DisplayDevice* self);
extern ErrorStatus DisplayDevice_clearLine(const struct DisplayDevice* self, size_t row);
extern ErrorStatus DisplayDevice_setBrightness(const struct DisplayDevice* self, size_t brightness);
extern ErrorStatus DisplayDevice_setContrast(const struct DisplayDevice* self, size_t contrast);
extern ErrorStatus DisplayDevice_invert(const struct DisplayDevice* self);

View File

@@ -0,0 +1,70 @@
// -----------------------------------------------------------------------------
/// @file IODevice.h
/// @brief File 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
// -----------------------------------------------------------------------------
/// @defgroup {group_name} {group_description}
/// Description
/// @file IODevice.h
/// @ingroup {group_name}
#ifndef MISC_INC_IODEVICE_H_
#define MISC_INC_IODEVICE_H_
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include <stdio.h>
#include "stm32f10x.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
struct IODevice;
typedef ErrorStatus (*ReadFunction)(const struct IODevice* self, char* buffer, size_t length, size_t* actualLength);
typedef ErrorStatus (*WriteFunction)(const struct IODevice* self, const char* buffer, size_t length);
struct IODevice
{
ReadFunction _read;
WriteFunction _write;
};
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
extern ErrorStatus IODevice_construct (struct IODevice* self, ReadFunction read, WriteFunction write);
extern ErrorStatus IODevice_write(const struct IODevice* self, const char* buffer, size_t length);
extern ErrorStatus IODevice_read(const struct IODevice* self, char* buffer, size_t length, size_t* actualLength);
#endif /* MISC_INC_IODEVICE_H_ */

View File

@@ -0,0 +1,52 @@
// -----------------------------------------------------------------------------
/// @file KeyboardDevice.h
/// @brief File 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) 2015 Micro-Key bv
// -----------------------------------------------------------------------------
/// @defgroup {group_name} {group_description}
/// Description
/// @file KeyboardDevice.h
/// @ingroup {group_name}
#ifndef INC_KEYBOARDDEVICE_H_
#define INC_KEYBOARDDEVICE_H_
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
#endif /* INC_KEYBOARDDEVICE_H_ */

View File

@@ -233,6 +233,6 @@ extern ErrorStatus MAX5715Channel_construct(struct MAX5715_DAC* self, struct MAX
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus MAX5715Channel_setValue(struct MAX5715_DAC* self, uint16_t value);
extern ErrorStatus MAX5715Channel_setValue(const struct MAX5715_DAC* self, uint16_t value);
#endif /* INC_MAX5715_H_ */

View File

@@ -60,6 +60,7 @@ ErrorStatus DisplayDevice_construct (struct DisplayDevice* self, struct DisplayD
DisplaySetStateFunction setState,
DisplayWriteFunction write,
DisplayClearFunction clear,
DisplayClearLineFunction clearLine,
DisplaySetBrightnessFunction setBrightness,
DisplaySetContrastFunction setContrast,
DisplayInvertFunction invert)
@@ -68,13 +69,14 @@ ErrorStatus DisplayDevice_construct (struct DisplayDevice* self, struct DisplayD
if (!self->initialized)
{
self->_reset = reset;
self->_setState = setState;
self->_write = write;
self->_clear = clear;
self->_reset = reset;
self->_setState = setState;
self->_write = write;
self->_clear = clear;
self->_clearLine = clearLine,
self->_setBrightness = setBrightness;
self->_setContrast = setContrast;
self->_invert = invert;
self->_setContrast = setContrast;
self->_invert = invert;
self->parameters = *parameters;
}
@@ -158,6 +160,24 @@ ErrorStatus DisplayDevice_clear(const struct DisplayDevice* self)
}
ErrorStatus DisplayDevice_clearLine(const struct DisplayDevice* self, size_t row)
{
ErrorStatus returnValue = SUCCESS;
if (!self->initialized)
{
if (self->_clearLine != NULL)
{
returnValue = self->_clearLine(self, row);
}
}
else
{
returnValue = ERROR;
}
return returnValue;
}
ErrorStatus DisplayDevice_setBrightness(const struct DisplayDevice* self, size_t brightness)
{
ErrorStatus returnValue = SUCCESS;

View File

@@ -0,0 +1,91 @@
// -----------------------------------------------------------------------------
/// @file IODevice.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 IODevice.c
/// @ingroup {group_name}
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include "IODevice.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// File-scope variables
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Function definitions
// -----------------------------------------------------------------------------
ErrorStatus IODevice_construct (struct IODevice* self, ReadFunction read, WriteFunction write)
{
ErrorStatus returnValue = SUCCESS;
self->_write = write;
self->_read = read;
return returnValue;
}
ErrorStatus IODevice_write(const struct IODevice* self, const char* buffer, size_t length)
{
ErrorStatus returnValue = SUCCESS;
if (self->_write != NULL)
{
returnValue = self->_write(self, buffer, length);
}
return returnValue;
}
ErrorStatus IODevice_read(const struct IODevice* self, char* buffer, size_t length, size_t* actualLength)
{
ErrorStatus returnValue = SUCCESS;
if (self->_read != NULL)
{
returnValue = self->_read(self, buffer, length, actualLength);
}
return returnValue;
}

View File

@@ -182,15 +182,29 @@ ErrorStatus MAX5715Channel_construct(struct MAX5715_DAC* self, struct MAX5715* p
}
ErrorStatus MAX5715Channel_setValue(struct MAX5715_DAC* self, uint16_t value)
ErrorStatus MAX5715Channel_setValue(const struct MAX5715_DAC* self, uint16_t value)
{
ErrorStatus returnValue = SUCCESS;
// Send data to CODEn register
MAX5715_writeCODEn(self->parent, self->id, value);
if (self != NULL)
{
if ((self->initialized) && (self->parent->initialized))
{
// Send data to CODEn register
MAX5715_writeCODEn(self->parent, self->id, value);
// Load CODEn register to DAC output
MAX5715_writeLOADn(self->parent, self->id);
// Load CODEn register to DAC output
MAX5715_writeLOADn(self->parent, self->id);
}
else
{
returnValue = ERROR;
}
}
else
{
returnValue = ERROR;
}
return returnValue;
}

View File

@@ -67,6 +67,7 @@ static int nhd0420_cursorRowOffset[NHD0420_NUMBER_OF_ROWS] =
static ErrorStatus setState(const struct DisplayDevice* self, DisplayDevice_functionalState state);
static ErrorStatus write(const struct DisplayDevice* self, const char* buffer, size_t length, size_t row, size_t column);
static ErrorStatus clear(const struct DisplayDevice* self);
static ErrorStatus clearLine(const struct DisplayDevice* self);
static ErrorStatus setBrightness(const struct DisplayDevice* self, size_t brightness);
static ErrorStatus setContrast(const struct DisplayDevice* self, size_t contrast);
@@ -92,7 +93,7 @@ ErrorStatus NHD0420_construct(struct NHD0420* self, const struct IODevice* devic
ddParameters.brightnessMax = NHD0420_BRIGHTNESS_MAX;
ddParameters.contrastMin = NHD0420_CONTRAST_MIN;
ddParameters.contrastMax = NHD0420_CONTRAST_MAX;
DisplayDevice_construct(&self->displayDevice, &ddParameters, NULL, setState, write, clear, setBrightness, setContrast, NULL);
DisplayDevice_construct(&self->displayDevice, &ddParameters, NULL, setState, write, clear, clearLine, setBrightness, setContrast, NULL);
}
else
{
@@ -416,6 +417,31 @@ static ErrorStatus clear(const struct DisplayDevice* self)
}
static ErrorStatus clearLine(const struct DisplayDevice* self, size_t row)
{
ErrorStatus returnValue = SUCCESS;
if (!self->initialized)
{
// Set cursor on display
returnValue = NHD0420_setCursorToPosition((const struct NHD0420*)self, row, 1);
char buffer[self->parameters.numberOfColumns] = {0x20,};
if (returnValue == SUCCESS)
{
returnValue = NHD0420_sendData((const struct NHD0420*)self, buffer, self->parameters.numberOfColumns);
}
}
else
{
returnValue = ERROR;
}
return returnValue;
}
static ErrorStatus setBrightness(const struct DisplayDevice* self, size_t brightness)
{
if (!self->initialized)