From bb08cae83a0ccc99245fab2ecb352b3b76ce45c8 Mon Sep 17 00:00:00 2001 From: mmi Date: Tue, 24 Oct 2017 13:56:55 +0000 Subject: [PATCH] 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 --- .../3 - Implementation/0 - Code/HAL/Makefile | 2 + .../0 - Code/HAL/inc/ADCDevice.h | 57 ++++- .../0 - Code/HAL/inc/DACDevice.h | 57 +++++ .../0 - Code/HAL/inc/MAX5715.h | 5 + .../0 - Code/HAL/src/ADCDevice.c | 112 ++++++++++ .../0 - Code/HAL/src/DACDevice.c | 113 ++++++++++ .../0 - Code/HAL/src/MAX5715.c | 15 +- .../0 - Code/Platform/inc/internalADC.h | 5 +- .../0 - Code/Platform/src/internalADC.c | 83 ++++---- .../0 - Code/Platform/src/oli_stm32_h107.c | 2 + .../0 - Code/hsb-mrts/Makefile | 5 + .../0 - Code/hsb-mrts/inc/ADConverter.h | 52 ++++- .../0 - Code/hsb-mrts/inc/ADConverters.h | 80 +++++++ .../0 - Code/hsb-mrts/inc/DAConverter.h | 55 ++++- .../0 - Code/hsb-mrts/inc/DAConverters.h | 83 ++++++++ .../0 - Code/hsb-mrts/inc/Display.h | 14 +- .../0 - Code/hsb-mrts/inc/DisplayContent.h | 178 ++++++++++++++++ .../0 - Code/hsb-mrts/inc/FreeRTOSConfig.h | 3 +- .../0 - Code/hsb-mrts/inc/hsb-mrts.h | 20 +- .../0 - Code/hsb-mrts/inc/repairProcess.h | 14 +- .../0 - Code/hsb-mrts/inc/repairProcessRow.h | 10 +- .../0 - Code/hsb-mrts/src/ADConverter.c | 123 +++++++++++ .../0 - Code/hsb-mrts/src/ADConverters.c | 119 +++++++++++ .../0 - Code/hsb-mrts/src/DAConverter.c | 120 +++++++++++ .../0 - Code/hsb-mrts/src/DAConverters.c | 120 +++++++++++ .../0 - Code/hsb-mrts/src/Display.c | 199 +++--------------- .../0 - Code/hsb-mrts/src/DisplayContent.c | 192 +++++++++++++++++ .../0 - Code/hsb-mrts/src/Displays.c | 4 +- .../0 - Code/hsb-mrts/src/Error.c | 3 +- .../hsb-mrts/src/SignalProfileGenerator.c | 32 ++- .../0 - Code/hsb-mrts/src/main.c | 15 +- .../0 - Code/hsb-mrts/src/repairMenu.c | 31 +-- .../0 - Code/hsb-mrts/src/repairMenus.c | 1 + .../0 - Code/hsb-mrts/src/repairProcess.c | 51 +++-- .../0 - Code/hsb-mrts/src/repairProcessRow.c | 2 +- 35 files changed, 1689 insertions(+), 288 deletions(-) create mode 100644 S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/ADCDevice.c create mode 100644 S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/DACDevice.c create mode 100644 S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/ADConverters.h create mode 100644 S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/DAConverters.h create mode 100644 S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/DisplayContent.h create mode 100644 S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/ADConverter.c create mode 100644 S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/ADConverters.c create mode 100644 S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DAConverter.c create mode 100644 S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DAConverters.c create mode 100644 S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DisplayContent.c diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/Makefile b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/Makefile index c2d5702..0b65197 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/Makefile +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/Makefile @@ -23,6 +23,8 @@ CCFLAGS = -c -O2 -Wall -g -fno-common -mcpu=cortex-m3 -mthumb $(PLATFORM) $(RELE ARFLAGS = rs OBJECTS = \ +ADCDevice.o \ +DACDevice.o \ DisplayDevice.o \ hsb-mrts.o \ Interlock.o \ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/ADCDevice.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/ADCDevice.h index b16195c..e9319e7 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/ADCDevice.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/ADCDevice.h @@ -31,22 +31,71 @@ // Include files // ----------------------------------------------------------------------------- +#include +#include "stm32f10x.h" // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- +struct ADCDevice; +typedef uint32_t (*ADCReadFunction)(const struct ADCDevice* self); + + +struct ADCDevice +{ + ADCReadFunction _read; + bool initialized; + unsigned int resolutionInBits; +}; // ----------------------------------------------------------------------------- -// Type definitions. +// Function declarations // ----------------------------------------------------------------------------- +/** ---------------------------------------------------------------------------- + * ADCDevice_construct + * Constructor for ADC device + * + * @param self ADC object + * @param read Pointer to read function + * + * @return ErrorStatus SUCCESS if construction was successful + * ERROR otherwise + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus ADCDevice_construct(struct ADCDevice* self, ADCReadFunction read, unsigned int resolutionInBits); -// ----------------------------------------------------------------------------- -// Function declarations -// ----------------------------------------------------------------------------- +/** ---------------------------------------------------------------------------- + * ADCDevice_destruct + * Destructor for ADC device + * + * @param self ADC object + * + * @return void + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void ADCDevice_destruct(struct ADCDevice* self); + +/** ---------------------------------------------------------------------------- + * ADCDevice_read + * Reads a value from the ADC device input + * + * @param self ADC object + * @param voltage value in volt (signed) to write to output + * + * @return ErrorStatus + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern uint32_t ADCDevice_read(const struct ADCDevice* self); #endif /* INC_ADCDEVICE_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/DACDevice.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/DACDevice.h index c7518c9..801a89a 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/DACDevice.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/DACDevice.h @@ -31,6 +31,10 @@ // Include files // ----------------------------------------------------------------------------- +#include + +#include "stm32f10x.h" + // ----------------------------------------------------------------------------- // Constant and macro definitions @@ -42,11 +46,64 @@ // Type definitions. // ----------------------------------------------------------------------------- +struct DACDevice; +typedef ErrorStatus (*DACWriteFunction)(const struct DACDevice* self, uint32_t voltage); + + +struct DACDevice +{ + DACWriteFunction _write; + bool initialized; + unsigned int resolutionInBits; +}; // ----------------------------------------------------------------------------- // Function declarations // ----------------------------------------------------------------------------- +/** ---------------------------------------------------------------------------- + * DACDevice_construct + * Constructor for DAC device + * + * @param self DAC object + * @param write Pointer to write function + * + * @return ErrorStatus SUCCESS if construction was successful + * ERROR otherwise + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus DACDevice_construct(struct DACDevice* self, DACWriteFunction write, unsigned int resolutionInBits); + + +/** ---------------------------------------------------------------------------- + * DACDevice_destruct + * Destructor for DAC device + * + * @param self DAC object + * + * @return void + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void DACDevice_destruct(struct DACDevice* self); + +/** ---------------------------------------------------------------------------- + * DACDevice_construct + * Writes a value to the DAC device output + * + * @param self DAC object + * @param voltage value in volt (signed) to write to output + * + * @return ErrorStatus + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus DACDevice_write(const struct DACDevice* self, uint32_t voltage); + #endif /* INC_DACDEVICE_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/MAX5715.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/MAX5715.h index c352e54..5041615 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/MAX5715.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/MAX5715.h @@ -31,6 +31,9 @@ // Include files // ----------------------------------------------------------------------------- +#include + +#include "DACDevice.h" #include "IODevice.h" #include "spi.h" @@ -38,6 +41,7 @@ // Constant and macro definitions // ----------------------------------------------------------------------------- #define MAX5715_NUMBER_OF_DACS (4) +#define MAX5715_RESOLUTION_IN_BITS (12) #define MAX5715_SPI_MAX_CLK_HZ (50000000) // SPI settings @@ -120,6 +124,7 @@ struct MAX5715; struct MAX5715_DAC { + struct DACDevice dacDevice; struct MAX5715* parent; uint8_t id; uint16_t value; diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/ADCDevice.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/ADCDevice.c new file mode 100644 index 0000000..6a8a17e --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/ADCDevice.c @@ -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 + +#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; +} diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/DACDevice.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/DACDevice.c new file mode 100644 index 0000000..dae6d7d --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/DACDevice.c @@ -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 + +#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; +} diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/MAX5715.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/MAX5715.c index 8ab10b9..4fea1fd 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/MAX5715.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/MAX5715.c @@ -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)); +} diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/internalADC.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/internalADC.h index 3ea2960..9a1e398 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/internalADC.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/internalADC.h @@ -34,7 +34,7 @@ #include #include "platform.h" -#include "IODevice.h" +#include "ADCDevice.h" #include "stm32f10x.h" #include "stm32f10x_adc.h" @@ -43,6 +43,7 @@ // Constant and macro definitions // ----------------------------------------------------------------------------- +#define ADC_RESOLUTION_IN_BITS (12) #define ADC_AVERAGE_DEPTH (10) #define ADC_NUMBER_OF_CHANNELS (18) // 16 IOs + Temp + Vcc @@ -61,7 +62,7 @@ struct AdcChannelParameters struct AdcChannel { - struct IODevice device; + struct ADCDevice adcDevice; struct Adc* parent; uint8_t channel; uint8_t Rank; diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/internalADC.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/internalADC.c index e55446d..7d623f8 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/internalADC.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/internalADC.c @@ -26,7 +26,11 @@ // ----------------------------------------------------------------------------- #include "stm32f10x.h" + +#include "ADCDevice.h" + #include "internalADC.h" +#include "Logger.h" // ----------------------------------------------------------------------------- // Constant and macro definitions @@ -49,8 +53,8 @@ // Function declarations // ----------------------------------------------------------------------------- -// NO WRITE - ADCs cannot write -static ErrorStatus read(const struct IODevice* self, char* buffer, size_t length, size_t* actualLength); + +static uint32_t channelRead(const struct ADCDevice* self); // ----------------------------------------------------------------------------- // Function definitions @@ -160,25 +164,27 @@ ErrorStatus ADCChannel_construct(struct AdcChannel* self, struct Adc* parent, st { if (!self->initialized) { - IODevice_construct(&self->device, read, NULL); + returnValue = ADCDevice_construct(&self->adcDevice, channelRead, ADC_RESOLUTION_IN_BITS); - if ((parameters->Rank) > 0 && (parameters->Rank <= 16)) + if (returnValue == SUCCESS) { - self->Rank = parameters->Rank; + if ((parameters->Rank) > 0 && (parameters->Rank <= 16)) + { + self->Rank = parameters->Rank; + } + else + { + returnValue = ERROR; + } + if (parameters->channel < ADC_NUMBER_OF_CHANNELS) + { + self->channel = parameters->channel; + } + else + { + returnValue = ERROR; + } } - else - { - returnValue = ERROR; - } - if (parameters->channel < ADC_NUMBER_OF_CHANNELS) - { - self->channel = parameters->channel; - } - else - { - returnValue = ERROR; - } - if (returnValue == SUCCESS) { @@ -213,35 +219,34 @@ ErrorStatus ADCChannel_read(const struct AdcChannel* self, uint16_t* value) { ErrorStatus returnValue = SUCCESS; - // Reading ADC value is automatically combined with an floating averaging - uint32_t average = 0; - int loopCounter; - for (loopCounter = self->channel; loopCounter < self->parent->numberOfUsedChannels * ADC_AVERAGE_DEPTH; loopCounter = loopCounter + self->parent->numberOfUsedChannels) + if (self->initialized) { - average = average + self->parent->channelValue[loopCounter]; + // Reading ADC value is automatically combined with an floating averaging + uint32_t average = 0; + int loopCounter; + for (loopCounter = self->channel; loopCounter < self->parent->numberOfUsedChannels * ADC_AVERAGE_DEPTH; loopCounter = loopCounter + self->parent->numberOfUsedChannels) + { + average = average + self->parent->channelValue[loopCounter]; + } + *value = average / ADC_AVERAGE_DEPTH; + } + else + { + returnValue = ERROR; } - *value = average / ADC_AVERAGE_DEPTH; - - - return returnValue; } -static ErrorStatus read(const struct IODevice* self, char* buffer, size_t length, size_t* actualLength) +static uint32_t channelRead(const struct ADCDevice* self) { - ErrorStatus returnValue = SUCCESS; - (void)length; - - uint16_t adcValue = 0; - returnValue = ADCChannel_read((struct AdcChannel*)self, &adcValue); - - buffer[0] = adcValue >> 8; - buffer[1] = adcValue; - - *actualLength = 2; - + uint32_t returnValue = 0; + uint16_t value; + if (ADCChannel_read((struct AdcChannel*)self, &value) == SUCCESS) + { + returnValue = (((1 << ADC_RESOLUTION_IN_BITS) - 1) & value); + } return returnValue; } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/oli_stm32_h107.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/oli_stm32_h107.c index 10e75df..5db405f 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/oli_stm32_h107.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/oli_stm32_h107.c @@ -37,6 +37,7 @@ #include "Logger.h" #include "platform.h" +#include "CathodeMCP.h" #include "gpio.h" #include "Interlock.h" #include "internalADC.h" @@ -792,6 +793,7 @@ static ErrorStatus initPlatformDevices (void) /* NewHavenDispplay 04 20 */ /* --------------------------------------------------------------------*/ returnValue = NHD0420_construct(nhd0420, &spiDisplay->device); +// returnValue = NHD0420_construct(nhd0420, &uart1->device); } if (returnValue == SUCCESS) diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/Makefile b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/Makefile index 4f02570..627affd 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/Makefile +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/Makefile @@ -12,8 +12,13 @@ system_stm32f10x.o \ sysmem.o \ startup_stm32f10x_cl.o \ \ +ADConverter.o \ +ADConverters.o \ +DAConverter.o \ +DAConverters.o \ Display.o \ Displays.o \ +DisplayContent.o \ Error.o \ FreeRTOSFixes.o \ hwValidationMenu.o \ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/ADConverter.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/ADConverter.h index e535355..18f0f8e 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/ADConverter.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/ADConverter.h @@ -31,7 +31,11 @@ // Include files // ----------------------------------------------------------------------------- +#include +#include "stm32f10x.h" + +#include "ADCDevice.h" // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- @@ -42,11 +46,57 @@ // Type definitions. // ----------------------------------------------------------------------------- - +struct ADConverter +{ + bool initialized; + int minVoltage; + int maxVoltage; + struct ADCDevice* adcDevice; +}; // ----------------------------------------------------------------------------- // Function declarations // ----------------------------------------------------------------------------- +/** ---------------------------------------------------------------------------- + * ADConverter_construct + * Description of function + * + * @param self + * @param + * @return ErrorStatus + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus ADConverter_construct(struct ADConverter* self, int minVoltage, int maxVoltage, struct ADCDevice* adcDevice); + + +/** ---------------------------------------------------------------------------- + * ADConverter_destruct + * Description of function + * + * @param self + * + * @return void + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void ADConverter_destruct(struct ADConverter* self); + + +/** ---------------------------------------------------------------------------- + * ADConverter_setOutputVoltage + * Description of function + * + * @param self + * + * @return int + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern int ADConverter_getInputVoltage(const struct ADConverter* self); #endif /* ADCONVERTER_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/ADConverters.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/ADConverters.h new file mode 100644 index 0000000..0863bf2 --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/ADConverters.h @@ -0,0 +1,80 @@ +// ----------------------------------------------------------------------------- +/// @file ADConverters.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 ADConverters.h +/// @ingroup {group_name} + +#ifndef ADCONVERTERS_H_ +#define ADCONVERTERS_H_ + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + +#include "stm32f10x.h" + +#include "ADConverter.h" + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Type definitions. +// ----------------------------------------------------------------------------- + +extern struct ADConverter* adcRow1; +extern struct ADConverter* adcRow2; +extern struct ADConverter* adcRow3; + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + +/** ---------------------------------------------------------------------------- + * ADConverters_construct + * Constructor for ADConverters + * + * @return ErrorStatus SUCCESS if constructor was successful + * ERROR otherwise + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus ADConverters_construct(void); + + +/** ---------------------------------------------------------------------------- + * ADConverters_destruct + * Destructor for ADConverters + * + * @return void + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void ADConverters_destruct(void); + +#endif /* ADCONVERTERS_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/DAConverter.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/DAConverter.h index b1b7c37..e22ff52 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/DAConverter.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/DAConverter.h @@ -31,7 +31,11 @@ // Include files // ----------------------------------------------------------------------------- +#include +#include "stm32f10x.h" + +#include "DACDevice.h" // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- @@ -42,11 +46,60 @@ // Type definitions. // ----------------------------------------------------------------------------- - +struct DAConverter +{ + bool initialized; + int minVoltage; + int maxVoltage; + struct DACDevice* dacDevice; +}; // ----------------------------------------------------------------------------- // Function declarations // ----------------------------------------------------------------------------- +/** ---------------------------------------------------------------------------- + * DAConverter_construct + * Description of function + * + * @param self + * @param + * @return ErrorStatus + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus DAConverter_construct(struct DAConverter* self, int minVoltage, int maxVoltage, struct DACDevice* dacDevice); + + +/** ---------------------------------------------------------------------------- + * DAConverter_destruct + * Description of function + * + * @param self + * + * @return void + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void DAConverter_destruct(struct DAConverter* self); + + +/** ---------------------------------------------------------------------------- + * DAConverter_setOutputVoltage + * Description of function + * + * @param self + * @param voltage + * + * @return ErrorStatus + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus DAConverter_setOutputVoltage(const struct DAConverter* self, int voltage); + + #endif /* DACONVERTER_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/DAConverters.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/DAConverters.h new file mode 100644 index 0000000..eb1a3ef --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/DAConverters.h @@ -0,0 +1,83 @@ +// ----------------------------------------------------------------------------- +/// @file DAConverters.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 DAConverters.h +/// @ingroup {group_name} + +#ifndef DACONVERTERS_H_ +#define DACONVERTERS_H_ + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + +#include "stm32f10x.h" + +#include "DAConverter.h" + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Type definitions. +// ----------------------------------------------------------------------------- + +extern struct DAConverter* dacRow1; +extern struct DAConverter* dacRow2; +extern struct DAConverter* dacRow3; + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + + +/** ---------------------------------------------------------------------------- + * DAConverters_construct + * Constructor for DAConverters + * + * @return ErrorStatus SUCCESS if constructor was successful + * ERROR otherwise + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus DAConverters_construct(void); + + +/** ---------------------------------------------------------------------------- + * DAConverters_destruct + * Destructor for DAConverters + * + * @return void + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void DAConverters_destruct(void); + + + +#endif /* DACONVERTERS_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Display.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Display.h index aeb653c..feb9542 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Display.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Display.h @@ -39,24 +39,20 @@ #include "stm32f10x.h" +#include "DisplayContent.h" + #include "DisplayDevice.h" + // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- -#define DISPLAY_MAX_ROWS (6) -#define DISPLAY_MAX_COLUMNS (25) // ----------------------------------------------------------------------------- // Type definitions. // ----------------------------------------------------------------------------- -struct DisplayCharacter -{ - char character; - bool isUpdated; -}; struct Display { @@ -65,9 +61,8 @@ struct Display int TaskPriority; uint16_t stackSize; bool runTask; - SemaphoreHandle_t displayShadowAccessSemaphore; SemaphoreHandle_t displayWriteRequest; - struct DisplayCharacter displayShadow[DISPLAY_MAX_ROWS][DISPLAY_MAX_COLUMNS]; + struct DisplayContent displayContent; int maxCharactersPerTransmit; int refreshFeedCounter; int refreshFeedFrequency_ms; @@ -233,5 +228,6 @@ extern ErrorStatus Display_write(struct Display* self, const char* buffer, size_ * ----------------------------------------------------------------------------- */ extern void Display_feedRefreshCounter(struct Display* self); +extern void Display_feedRefreshCounterFromISR(struct Display* self); #endif /* DISPLAY_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/DisplayContent.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/DisplayContent.h new file mode 100644 index 0000000..2400481 --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/DisplayContent.h @@ -0,0 +1,178 @@ +// ----------------------------------------------------------------------------- +/// @file DisplayContent.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 DisplayContent.h +/// @ingroup {group_name} + +#ifndef DISPLAYCONTENT_H_ +#define DISPLAYCONTENT_H_ + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + +#include + +#include "FreeRTOS.h" +#include "semphr.h" + +#include "stm32f10x.h" + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + +#define DISPLAY_MAX_ROWS (6) +#define DISPLAY_MAX_COLUMNS (25) + +// ----------------------------------------------------------------------------- +// Type definitions. +// ----------------------------------------------------------------------------- + +struct DisplayCharacter +{ + char character; + bool isUpdated; +}; + +struct DisplayContent +{ + bool initialized; + SemaphoreHandle_t contentAccess; + size_t numberOfRows; + size_t numberOfColumns; + struct DisplayCharacter DisplayContent[DISPLAY_MAX_ROWS][DISPLAY_MAX_COLUMNS]; +}; + + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + + +/** ---------------------------------------------------------------------------- + * DisplayContent_construct + * Description of function + * + * @param self + * @param numberOfRows + * @param numberOfColumns + * @return ErrorStatus + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus DisplayContent_construct(struct DisplayContent* self, size_t numberOfRows, size_t numberOfColumns); + + +/** ---------------------------------------------------------------------------- + * DisplayContent_destruct + * Description of function + * + * @param self + * @param + * @return void + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void DisplayContent_destruct(struct DisplayContent* self); + + +/** ---------------------------------------------------------------------------- + * DisplayContent_updateCharacter + * Description of function + * + * @param self + * @param row + * @param column + * @param character + * + * @return void + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void DisplayContent_updateCharacter(struct DisplayContent* self, unsigned int row, unsigned int column, char character); + + +/** ---------------------------------------------------------------------------- + * DisplayContent_isCharacterUpdated + * Description of function + * + * @param self + * @param row + * @param column + * + * @return bool + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern bool DisplayContent_isCharacterUpdated(struct DisplayContent* self, unsigned int row, unsigned int column); + + +/** ---------------------------------------------------------------------------- + * DisplayContent_getCharacter + * Description of function + * + * @param self + * @param row + * @param column + * + * @return char + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern char DisplayContent_getCharacter(struct DisplayContent* self, unsigned int row, unsigned int column); + + +/** ---------------------------------------------------------------------------- + * DisplayContent_refresh + * Description of function + * + * @param self + * @param + * @return void + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void DisplayContent_refresh(struct DisplayContent* self); + + +/** ---------------------------------------------------------------------------- + * DisplayContent_clear + * Description of function + * + * @param self + * + * @return return_type + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void DisplayContent_clear(struct DisplayContent* self); + +#endif /* DISPLAYCONTENT_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/FreeRTOSConfig.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/FreeRTOSConfig.h index 306d82a..b902565 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/FreeRTOSConfig.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/FreeRTOSConfig.h @@ -44,7 +44,7 @@ #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) #define configMAX_PRIORITIES ( 5 ) #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 256 ) -#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 0x8000 ) ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 0xA000 ) ) #define configMAX_TASK_NAME_LEN ( 16 ) #define configUSE_TRACE_FACILITY 1 #define configUSE_16_BIT_TICKS 0 @@ -69,7 +69,6 @@ to exclude the API function. */ #define INCLUDE_vTaskPrioritySet 1 #define INCLUDE_uxTaskPriorityGet 1 #define INCLUDE_vTaskDelete 1 -#define INCLUDE_vTaskCleanUpResources 0 #define INCLUDE_vTaskSuspend 1 #define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelay 1 diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hsb-mrts.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hsb-mrts.h index 9146cdb..e7055c9 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hsb-mrts.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hsb-mrts.h @@ -39,7 +39,7 @@ // Constant and macro definitions // ----------------------------------------------------------------------------- -#define HSB_MAINMENU_TASK_PRIORITY (5) +#define HSB_MAINMENU_TASK_PRIORITY (2) #define HSB_MAINMENU_TASK_STACKSIZE (1024) #define HSB_MAINDISP_TASK_PRIORITY (2) @@ -47,8 +47,22 @@ #define HSB_MAINREPR_TASK_PRIORITY (2) #define HSB_MAINREPR_TASK_STACKSIZE (1024) -#define HSB_MAINREPR_OOL_DURATION (10) -#define HSB_MAINREPR_OOL_VALUE (100) +#define HSB_MAINREPR_OOL_DURATION (20) +#define HSB_MAINREPR_OOL_VALUE (200) + +#define HSB_ADC_ANODE_MIN_VOLTAGE (0) +#define HSB_ADC_ANODE_MAX_VOLTAGE (10042) +#define HSB_ADC_CMCP_MIN_VOLTAGE (0) +#define HSB_ADC_CMCP_MAX_VOLTAGE (-2018) +#define HSB_ADC_TESLA_MIN_VOLTAGE (0) +#define HSB_ADC_TESLA_MAX_VOLTAGE (6070) + +#define HSB_DAC_ANODE_MIN_VOLTAGE (0) +#define HSB_DAC_ANODE_MAX_VOLTAGE (10500) +#define HSB_DAC_CMCP_MIN_VOLTAGE (0) +#define HSB_DAC_CMCP_MAX_VOLTAGE (-2200) +#define HSB_DAC_TESLA_MIN_VOLTAGE (0) +#define HSB_DAC_TESLA_MAX_VOLTAGE (6200) // Exports of objects on application level diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/repairProcess.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/repairProcess.h index 91df222..ea548ba 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/repairProcess.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/repairProcess.h @@ -38,6 +38,8 @@ #include "stm32f10x.h" +#include "ADConverter.h" +#include "DAConverter.h" #include "repairPreset.h" #include "repairProcessRow.h" #include "SignalProfileGenerator.h" @@ -60,12 +62,12 @@ struct RepairProcessParameters { - const struct AdcChannel* adcRow1; - const struct AdcChannel* adcRow2; - const struct AdcChannel* adcRow3; - const struct MAX5715_DAC* dacRow1; - const struct MAX5715_DAC* dacRow2; - const struct MAX5715_DAC* dacRow3; + const struct ADConverter* adcR1; + const struct ADConverter* adcR2; + const struct ADConverter* adcR3; + const struct DAConverter* dacR1; + const struct DAConverter* dacR2; + const struct DAConverter* dacR3; }; diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/repairProcessRow.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/repairProcessRow.h index 7d3a33f..e08f653 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/repairProcessRow.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/repairProcessRow.h @@ -56,10 +56,10 @@ struct RepairProcessRowErrorData struct RepairProcessRow { bool initialized; - const struct AdcChannel* adcChannel; - uint16_t lastADCValue; - const struct MAX5715_DAC* dacChannel; - uint16_t lastDACValue; + const struct ADConverter* adcChannel; + int lastADCValue; + const struct DAConverter* dacChannel; + int lastDACValue; int pidError; struct Pid pid; struct RepairProcessRowErrorData errorData; @@ -88,7 +88,7 @@ struct RepairProcessRow * @todo * ----------------------------------------------------------------------------- */ -extern ErrorStatus repairProcessRow_construct(struct RepairProcessRow* self, const struct AdcChannel* adcChannel, const struct MAX5715_DAC* dacChannel, int outOfLimitsDuration, int outOfLimitsValue); +extern ErrorStatus repairProcessRow_construct(struct RepairProcessRow* self, const struct ADConverter* adcChannel, const struct DAConverter* dacChannel, int outOfLimitsDuration, int outOfLimitsValue); /** ---------------------------------------------------------------------------- diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/ADConverter.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/ADConverter.c new file mode 100644 index 0000000..deaa85f --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/ADConverter.c @@ -0,0 +1,123 @@ +// ----------------------------------------------------------------------------- +/// @file ADConverter.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 ADConverter.c +/// @ingroup {group_name} + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + +#include "ADConverter.h" + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Type definitions +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// File-scope variables +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + +static int calculateVoltage(const struct ADConverter* self, uint32_t adcValue); + +// ----------------------------------------------------------------------------- +// Function definitions +// ----------------------------------------------------------------------------- + + +ErrorStatus ADConverter_construct(struct ADConverter* self, int minVoltage, int maxVoltage, struct ADCDevice* adcDevice) +{ + ErrorStatus returnValue = SUCCESS; + if (!self->initialized) + { + self->minVoltage = minVoltage; + self->maxVoltage = maxVoltage; + self->adcDevice = adcDevice; + self->initialized = true; + } + else + { + returnValue = ERROR; + } + return returnValue; +} + + +void ADConverter_destruct(struct ADConverter* self) +{ + self->initialized = false; +} + + +int ADConverter_getInputVoltage(const struct ADConverter* self) +{ + int returnValue = 0; + + if (self->initialized) + { + uint32_t adcValue; + adcValue = ADCDevice_read(self->adcDevice); + + returnValue = calculateVoltage(self, adcValue); + } + + return returnValue; +} + + +static int calculateVoltage(const struct ADConverter* self, uint32_t adcValue) +{ + int returnValue = 0; + if (self->initialized) + { + uint32_t maxAdcValue = ((1 << self->adcDevice->resolutionInBits) - 1); + + returnValue = adcValue * (self->maxVoltage - self->minVoltage); + returnValue = returnValue / maxAdcValue; + returnValue = returnValue + self->minVoltage; + + if (returnValue < self->minVoltage) + { + returnValue = self->minVoltage; + } + else if (returnValue > self->maxVoltage) + { + returnValue = self->maxVoltage; + } + } + else + { + returnValue = 0; + } + return returnValue; +} diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/ADConverters.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/ADConverters.c new file mode 100644 index 0000000..4f97fb9 --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/ADConverters.c @@ -0,0 +1,119 @@ +// ----------------------------------------------------------------------------- +/// @file ADConverters.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 ADConverters.c +/// @ingroup {group_name} + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + +#include "ADConverters.h" +#include "hsb-mrts.h" + +#include "internalADC.h" +#include "PCBA.h" +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Type definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// File-scope variables +// ----------------------------------------------------------------------------- + +static struct ADConverter _adcRow1; +static struct ADConverter _adcRow2; +static struct ADConverter _adcRow3; + +struct ADConverter* adcRow1 = &_adcRow1; +struct ADConverter* adcRow2 = &_adcRow2; +struct ADConverter* adcRow3 = &_adcRow3; + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Function definitions +// ----------------------------------------------------------------------------- + +ErrorStatus ADConverters_construct(void) +{ + ErrorStatus returnValue = SUCCESS; + + int minVoltage; + int maxVoltage; + if (returnValue == SUCCESS) + { + if (PCBA_getInstance()->pcba == PCBA_Anode) + { + minVoltage = HSB_ADC_ANODE_MIN_VOLTAGE; + maxVoltage = HSB_ADC_ANODE_MAX_VOLTAGE; + } + else if (PCBA_getInstance()->pcba == PCBA_CathodeMCP) + { + minVoltage = HSB_ADC_CMCP_MIN_VOLTAGE; + maxVoltage = HSB_ADC_CMCP_MAX_VOLTAGE; + } + else if (PCBA_getInstance()->pcba == PCBA_Tesla) + { + minVoltage = HSB_ADC_TESLA_MIN_VOLTAGE; + maxVoltage = HSB_ADC_TESLA_MAX_VOLTAGE; + } + else + { + minVoltage = 0; + maxVoltage = 0; + returnValue = ERROR; + } + + if (returnValue == SUCCESS) + { + returnValue = ADConverter_construct(adcRow1, minVoltage, maxVoltage, &adc1->channel[0].adcDevice); + } + if (returnValue == SUCCESS) + { + returnValue = ADConverter_construct(adcRow2, minVoltage, maxVoltage, &adc1->channel[1].adcDevice); + } + if (returnValue == SUCCESS) + { + returnValue = ADConverter_construct(adcRow3, minVoltage, maxVoltage, &adc1->channel[2].adcDevice); + } + } + return returnValue; +} + + +void ADConverters_destruct(void) +{ + ADConverter_destruct(adcRow1); + ADConverter_destruct(adcRow2); + ADConverter_destruct(adcRow3); +} diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DAConverter.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DAConverter.c new file mode 100644 index 0000000..516dd8a --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DAConverter.c @@ -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; +} diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DAConverters.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DAConverters.c new file mode 100644 index 0000000..f673ee8 --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DAConverters.c @@ -0,0 +1,120 @@ +// ----------------------------------------------------------------------------- +/// @file DAConverters.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 DAConverters.c +/// @ingroup {group_name} + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + +#include "DAConverters.h" +#include "hsb-mrts.h" + +#include "MAX5715.h" +#include "PCBA.h" + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Type definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// File-scope variables +// ----------------------------------------------------------------------------- + +static struct DAConverter _dacRow1; +static struct DAConverter _dacRow2; +static struct DAConverter _dacRow3; + +struct DAConverter* dacRow1 = &_dacRow1; +struct DAConverter* dacRow2 = &_dacRow2; +struct DAConverter* dacRow3 = &_dacRow3; + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Function definitions +// ----------------------------------------------------------------------------- + +ErrorStatus DAConverters_construct(void) +{ + ErrorStatus returnValue = SUCCESS; + + int minVoltage; + int maxVoltage; + if (returnValue == SUCCESS) + { + if (PCBA_getInstance()->pcba == PCBA_Anode) + { + minVoltage = HSB_DAC_ANODE_MIN_VOLTAGE; + maxVoltage = HSB_DAC_ANODE_MAX_VOLTAGE; + } + else if (PCBA_getInstance()->pcba == PCBA_CathodeMCP) + { + minVoltage = HSB_DAC_CMCP_MIN_VOLTAGE; + maxVoltage = HSB_DAC_CMCP_MAX_VOLTAGE; + } + else if (PCBA_getInstance()->pcba == PCBA_Tesla) + { + minVoltage = HSB_DAC_TESLA_MIN_VOLTAGE; + maxVoltage = HSB_DAC_TESLA_MAX_VOLTAGE; + } + else + { + minVoltage = 0; + maxVoltage = 0; + returnValue = ERROR; + } + + if (returnValue == SUCCESS) + { + returnValue = DAConverter_construct(dacRow1, minVoltage, maxVoltage, &max5715->dac[0].dacDevice); + } + if (returnValue == SUCCESS) + { + returnValue = DAConverter_construct(dacRow2, minVoltage, maxVoltage, &max5715->dac[1].dacDevice); + } + if (returnValue == SUCCESS) + { + returnValue = DAConverter_construct(dacRow3, minVoltage, maxVoltage, &max5715->dac[2].dacDevice); + } + } + return returnValue; +} + + +void DAConverters_destruct(void) +{ + DAConverter_destruct(dacRow1); + DAConverter_destruct(dacRow2); + DAConverter_destruct(dacRow3); +} diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c index eb8f425..c02f4d9 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c @@ -25,6 +25,8 @@ // Include files // ----------------------------------------------------------------------------- +#include + #include "Display.h" #include "Logger.h" @@ -53,12 +55,6 @@ static void DisplayTask(void* parameters); -inline static void Display_characterUpdate (struct DisplayCharacter* displayCharacter, char character); -inline static bool Display_isCharacterUpdated (struct DisplayCharacter* displayCharacter); -inline static char Display_getUpdatedCharacter (struct DisplayCharacter* displayCharacter); -inline static void Display_characterUpdateAll(struct Display* self); -inline static void Display_clearShadow(struct Display* self); - // ----------------------------------------------------------------------------- // Function definitions // ----------------------------------------------------------------------------- @@ -81,13 +77,12 @@ ErrorStatus Display_construct(struct Display* self, struct DisplayDevice* displa if(returnValue == SUCCESS) { - // Create a semaphore to sync access to the display shadow - vSemaphoreCreateBinary(self->displayShadowAccessSemaphore); // Create a semaphore to sync writing requests to the display vSemaphoreCreateBinary(self->displayWriteRequest); - - - Display_clearShadow(self); + } + if (returnValue == SUCCESS) + { + returnValue = DisplayContent_construct(&self->displayContent, self->displayDevice->parameters.numberOfRows, self->displayDevice->parameters.numberOfColumns); } self->runTask = true; @@ -118,15 +113,14 @@ ErrorStatus Display_construct(struct Display* self, struct DisplayDevice* displa void Display_destruct(struct Display* self) { self->runTask = false; - vSemaphoreDelete(self->displayShadowAccessSemaphore); } ErrorStatus Display_clearScreen(struct Display* self) { ErrorStatus returnValue = SUCCESS; - returnValue = DisplayDevice_clear(self->displayDevice); - Display_clearShadow(self); + DisplayContent_clear(&self->displayContent); + xSemaphoreGive(self->displayWriteRequest); return returnValue; } @@ -203,16 +197,12 @@ ErrorStatus Display_write(struct Display* self, const char* buffer, size_t row, if (returnValue == SUCCESS) { - // Get the access semaphore to the display memory - wait for access - xSemaphoreTake(self->displayShadowAccessSemaphore, portMAX_DELAY); - int loopCounter; for (loopCounter = 0; loopCounter < length; loopCounter++) { - Display_characterUpdate(&self->displayShadow[row - 1][(column - 1) + loopCounter], buffer[loopCounter]); + DisplayContent_updateCharacter(&self->displayContent, (row - 1), (column - 1) + loopCounter, buffer[loopCounter]); } - xSemaphoreGive(self->displayShadowAccessSemaphore); xSemaphoreGive(self->displayWriteRequest); } @@ -230,74 +220,25 @@ void Display_feedRefreshCounter(struct Display* self) if (self->initialized) { self->refreshFeedCounter++; - } -} - - -inline static void Display_characterUpdate (struct DisplayCharacter* displayCharacter, char character) -{ - // Sending the same character should not lead to an updated character - if (displayCharacter->character != character) - { - displayCharacter->character = character; - displayCharacter->isUpdated = true; - } -} - - -inline static bool Display_isCharacterUpdated (struct DisplayCharacter* displayCharacter) -{ - return displayCharacter->isUpdated; -} - - -inline static char Display_getUpdatedCharacter (struct DisplayCharacter* displayCharacter) -{ - displayCharacter->isUpdated = false; - return displayCharacter->character; -} - - -inline static void Display_characterUpdateAll(struct Display* self) -{ - size_t rowCounter; - size_t colCounter; - - // Get the access semaphore to the shadow - wait until the other functions are finished with updating the shadow - xSemaphoreTake(self->displayShadowAccessSemaphore, portMAX_DELAY); - // Clear the display shadow - for (rowCounter = 0; rowCounter < self->displayDevice->parameters.numberOfRows; rowCounter++) - { - for (colCounter = 0; colCounter < self->displayDevice->parameters.numberOfColumns; colCounter++) + if (self->refreshFeedCounter * self->refreshFeedFrequency_ms > self->refreshPeriod_ms) { - self->displayShadow[rowCounter][colCounter].isUpdated = true; + xSemaphoreGive(self->displayWriteRequest); } } - // Give back display memory access semaphore to allow new updates - xSemaphoreGive(self->displayShadowAccessSemaphore); - xSemaphoreGive(self->displayWriteRequest); } - -inline static void Display_clearShadow(struct Display* self) +void Display_feedRefreshCounterFromISR(struct Display* self) { - // Clear the display shadow - size_t rowCounter; - size_t colCounter; - xSemaphoreTake(self->displayShadowAccessSemaphore, portMAX_DELAY); - for (rowCounter = 0; rowCounter < self->displayDevice->parameters.numberOfRows; rowCounter++) + portBASE_TYPE higherPriorityTaskWoken = pdFALSE; + if (self->initialized) { - for (colCounter = 0; colCounter < self->displayDevice->parameters.numberOfColumns; colCounter++) + self->refreshFeedCounter++; + if (self->refreshFeedCounter * self->refreshFeedFrequency_ms > self->refreshPeriod_ms) { - // All characters of the display shadow are set to BLANK, but the isUpdated flag is kept at FALSE - // this is, because the display itself has already received a command to clear its content. So - // blanking the shadow without setting isUpdated to TRUE is only an action to update the - // shadow to the actual situation on the screen - self->displayShadow[rowCounter][colCounter].character = 0x20; - self->displayShadow[rowCounter][colCounter].isUpdated = false; + xSemaphoreGiveFromISR(self->displayWriteRequest, &higherPriorityTaskWoken); } } - xSemaphoreGive(self->displayShadowAccessSemaphore); + portEND_SWITCHING_ISR(higherPriorityTaskWoken); } @@ -305,108 +246,32 @@ static void DisplayTask(void* parameters) { struct Display* self = (struct Display*)parameters; - bool leaveLoops = false; - char buffer[NHD0420_NUMBER_OF_COLUMNS]; - int bufferIndex = 0; + char buffer; int rowCounter = 0; int colCounter = 0; - size_t rowStart; - size_t columnStart; - while (self->runTask) { - // Wait until a write or refresh function has requested this task to write to the display -// xSemaphoreTake(self->displayWriteRequest, portMAX_DELAY); - -// for (rowCounter = 0; rowCounter < self->displayDevice->parameters.numberOfRows; rowCounter++) + xSemaphoreTake(self->displayWriteRequest, portMAX_DELAY); + // Check for display refresh timings + if (self->refreshFeedCounter * self->refreshFeedFrequency_ms > self->refreshPeriod_ms) { - // Get the access semaphore to the shadow - wait until the other functions are finished with updating the shadow - xSemaphoreTake(self->displayShadowAccessSemaphore, portMAX_DELAY); - leaveLoops = false; - bufferIndex = 0; + self->refreshFeedCounter = 0; + DisplayContent_refresh(&self->displayContent); + } - // Fragment display writing - writing will be done per line - for (; colCounter < self->displayDevice->parameters.numberOfColumns; colCounter++) + for (rowCounter = 0; rowCounter < self->displayDevice->parameters.numberOfRows; rowCounter++) + { + for (colCounter = 0; colCounter < self->displayDevice->parameters.numberOfColumns; colCounter++) { - if (Display_isCharacterUpdated(&self->displayShadow[rowCounter][colCounter])) + if (DisplayContent_isCharacterUpdated(&self->displayContent, rowCounter, colCounter)) { - // Found a character that has been updated - // Put the display cursor at the appropriate coordinates - rowStart = rowCounter + 1; - columnStart = colCounter + 1; - for (bufferIndex = 0; (colCounter < self->displayDevice->parameters.numberOfColumns); colCounter++, bufferIndex++) - { - // Respect the max number of bytes to transmit - if (bufferIndex < self->maxCharactersPerTransmit) - { - // Still within the boundaries - if (Display_isCharacterUpdated(&self->displayShadow[rowCounter][colCounter])) - { - // Current character has been updated and must be sent to display - // But data from display shadow to transmit buffer - buffer[bufferIndex] = Display_getUpdatedCharacter(&self->displayShadow[rowCounter][colCounter]); - } - else - { - // Current character is already on the display - // Stop scanning for more updated characters here and leave the loops in order - // to start transmission to the display - leaveLoops = true; - break; - } - } - else - { - // Max number of characters reached - // Stop scanning for more updated characters here and leave the loops in order - // to start transmission to the display - leaveLoops = true; - break; - } - } + buffer = DisplayContent_getCharacter(&self->displayContent, rowCounter, colCounter); + DisplayDevice_write(self->displayDevice, &buffer, 1, rowCounter + 1, colCounter + 1); } - - // Check if loop should be left - if (leaveLoops) - { - // An inner loop decided to leave, so leave - break; - } - } - - // Give back display memory access semaphore to allow new updates - xSemaphoreGive(self->displayShadowAccessSemaphore); - if (bufferIndex > 0) - { - // If there was an update found, send it to the display - DisplayDevice_write(self->displayDevice, buffer, bufferIndex, rowStart, columnStart); - } - - // Handle the counters for row and column - if (colCounter > (self->displayDevice->parameters.numberOfColumns - 1)) - { - // End of row reached - reset column and increment row - colCounter = 0; - - if (rowCounter < (self->displayDevice->parameters.numberOfRows - 1)) - { - // Increment row - rowCounter++; - } - else - { - // Last row reached - restart at row 0 - rowCounter = 0; - } - } - // Check for display refresh timings - if (self->refreshFeedCounter * self->refreshFeedFrequency_ms > self->refreshPeriod_ms) - { - self->refreshFeedCounter = 0; - Display_characterUpdateAll(self); } } + vTaskDelay(10); } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DisplayContent.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DisplayContent.c new file mode 100644 index 0000000..f2b7c32 --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DisplayContent.c @@ -0,0 +1,192 @@ +// ----------------------------------------------------------------------------- +/// @file DisplayContent.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 DisplayContent.c +/// @ingroup {group_name} + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + +#include "DisplayContent.h" + +#include "Logger.h" + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Type definitions +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// File-scope variables +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Function definitions +// ----------------------------------------------------------------------------- + + +ErrorStatus DisplayContent_construct(struct DisplayContent* self, size_t numberOfRows, size_t numberOfColumns) +{ + ErrorStatus returnValue = SUCCESS; + if (!self->initialized) + { + vSemaphoreCreateBinary(self->contentAccess); + self->numberOfRows = numberOfRows; + self->numberOfColumns = numberOfColumns; + self->initialized = true; + } + else + { + returnValue = ERROR; + } + return returnValue; +} + + + + void DisplayContent_destruct(struct DisplayContent* self) + { + vSemaphoreDelete(self->contentAccess); + self->initialized = false; + } + + + +void DisplayContent_updateCharacter(struct DisplayContent* self, unsigned int row, unsigned int column, char character) +{ + if (self->initialized) + { + if ((row < self->numberOfRows) && (column < self->numberOfColumns)) + { + if (self->DisplayContent[row][column].character != character) + { + xSemaphoreTake(self->contentAccess, portMAX_DELAY); + self->DisplayContent[row][column].character = character; + self->DisplayContent[row][column].isUpdated = true; + xSemaphoreGive(self->contentAccess); + } + } + } +} + + + +bool DisplayContent_isCharacterUpdated(struct DisplayContent* self, unsigned int row, unsigned int column) +{ + bool returnValue = false; + if (self->initialized) + { + if ((row < self->numberOfRows) && (column < self->numberOfColumns)) + { + returnValue = self->DisplayContent[row][column].isUpdated; + } + else + { + returnValue = false; + } + } + else + { + returnValue = false; + } + return returnValue; +} + + + +char DisplayContent_getCharacter(struct DisplayContent* self, unsigned int row, unsigned int column) +{ + char returnValue = 0; + if (self->initialized) + { + if ((row < self->numberOfRows) && (column < self->numberOfColumns)) + { + xSemaphoreTake(self->contentAccess, portMAX_DELAY); + returnValue = self->DisplayContent[row][column].character; + self->DisplayContent[row][column].isUpdated = false; + xSemaphoreGive(self->contentAccess); + } + else + { + returnValue = 0; + } + } + else + { + returnValue = 0; + } + return returnValue; +} + + + +void DisplayContent_refresh(struct DisplayContent* self) +{ + if (self->initialized) + { + int rowCounter; + int columnCounter; + xSemaphoreTake(self->contentAccess, portMAX_DELAY); + for (rowCounter = 0; rowCounter < self->numberOfRows; rowCounter++) + { + for (columnCounter = 0; columnCounter < self->numberOfColumns; columnCounter++) + { + self->DisplayContent[rowCounter][columnCounter].isUpdated = true; + } + } + xSemaphoreGive(self->contentAccess); + } +} + + + +void DisplayContent_clear(struct DisplayContent* self) +{ + if (self->initialized) + { + int rowCounter; + int columnCounter; + xSemaphoreTake(self->contentAccess, portMAX_DELAY); + for (rowCounter = 0; rowCounter < self->numberOfRows; rowCounter++) + { + for (columnCounter = 0; columnCounter < self->numberOfColumns; columnCounter++) + { + self->DisplayContent[rowCounter][columnCounter].character = ' '; + self->DisplayContent[rowCounter][columnCounter].isUpdated = true; + } + } + xSemaphoreGive(self->contentAccess); + } +} diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Displays.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Displays.c index ce3c1cb..ab88cf2 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Displays.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Displays.c @@ -108,6 +108,6 @@ extern void Displays_destruct(void) static ErrorStatus Displays_mainDisplayObserverFromISR(const void* const data) { - Display_feedRefreshCounter(mainDisplay); - return SUCCESS; + Display_feedRefreshCounterFromISR(mainDisplay); + return SUCCESS; } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Error.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Error.c index a0b7cea..feb1189 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Error.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Error.c @@ -70,7 +70,7 @@ ErrorStatus Error_construct(void) Observable_construct(&observable); errorQueue = xQueueCreate(ERROR_QUEUE_SIZE, sizeof(struct ErrorQueueItem)); - xTaskCreate(ErrorTask, "ErrorTask", 300, NULL, 1, &errorTaskHandle); + xTaskCreate(ErrorTask, "ErrorTask", 1024, NULL, 1, &errorTaskHandle); return SUCCESS; } @@ -111,6 +111,5 @@ static void ErrorTask (void* parameters) { xQueueReceive(errorQueue, &queueItem, portMAX_DELAY); Observable_notifyObservers(&observable, (const void* const)queueItem.errorCode); - vTaskDelay(1); } } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/SignalProfileGenerator.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/SignalProfileGenerator.c index c7eb2b2..8638123 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/SignalProfileGenerator.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/SignalProfileGenerator.c @@ -27,13 +27,17 @@ #include "SignalProfileGenerator.h" +#include "PCBA.h" + #include "Logger.h" // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- -#define SPG_0V_OFFSET (450) +#define SPG_0V_OFFSET_ANODE (1153) +#define SPG_0V_OFFSET_CMCP (-241) +#define SPG_0V_OFFSET_TESLA (681) #define SPG_PAUSE_SOFTSTART (300) // 5 minutes softstart after pause #define SPG_FIXPOINT_FACTOR (1000) @@ -106,7 +110,18 @@ void SignalProfileGenerator_calculate(struct SignalProfileGenerator* self) // If first preset, start voltage is 0 if (self->currentPresetIndex == 0) { - self->startVoltage = SPG_0V_OFFSET; + if (PCBA_getInstance()->pcba == PCBA_Anode) + { + self->startVoltage = SPG_0V_OFFSET_ANODE; + } + else if (PCBA_getInstance()->pcba == PCBA_CathodeMCP) + { + self->startVoltage = SPG_0V_OFFSET_CMCP; + } + else if (PCBA_getInstance()->pcba == PCBA_Tesla) + { + self->startVoltage = SPG_0V_OFFSET_TESLA; + } } else { @@ -165,7 +180,18 @@ void SignalProfileGenerator_calculate(struct SignalProfileGenerator* self) } case SPG_PAUSE_RESTORE_SOFTSTART: { - self->pauseStartVoltage = SPG_0V_OFFSET; + if (PCBA_getInstance()->pcba == PCBA_Anode) + { + self->pauseStartVoltage = SPG_0V_OFFSET_ANODE; + } + else if (PCBA_getInstance()->pcba == PCBA_CathodeMCP) + { + self->pauseStartVoltage = SPG_0V_OFFSET_CMCP; + } + else if (PCBA_getInstance()->pcba == PCBA_Tesla) + { + self->pauseStartVoltage = SPG_0V_OFFSET_TESLA; + } self->signal = ((self->voltagePriorToPause * SPG_FIXPOINT_FACTOR - self->pauseStartVoltage * SPG_FIXPOINT_FACTOR) / SPG_PAUSE_SOFTSTART) * (self->secondsCounter - self->pauseStartTime) + self->pauseStartVoltage * SPG_FIXPOINT_FACTOR; self->signal = self->signal / SPG_FIXPOINT_FACTOR; diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c index e58e82a..19f106e 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c @@ -33,7 +33,8 @@ #include "FreeRTOS.h" #include "task.h" -#include "CathodeMCP.h" +#include "ADConverters.h" +#include "DAConverters.h" #include "Displays.h" #include "Error.h" #include "hsb-mrts.h" @@ -52,6 +53,7 @@ #include "nhd0420.h" #include "platform.h" +#include "CathodeMCP.h" #include "Interlock.h" #include "internalADC.h" #include "gpio.h" @@ -196,7 +198,7 @@ static void initTask(void* parameters) initPlatform(); // Disable power - GPIO_setValue(power6v5Enable, true); + GPIO_setValue(power6v5Enable, false); // Create a small task that only blinks a LED and flashes the identification letter on the display xTaskCreate(ledBlinkTask, (const char* const)"ledTask", 100, &ledTaskArguments, 0, &ledTaskHandle); @@ -204,9 +206,15 @@ static void initTask(void* parameters) // Construct the displays Displays_construct(); + // Construct the AD Converters + ADConverters_construct(); + + // Construct the DA Converters + DAConverters_construct(); + hsb_generateStartScreen(mainDisplay); // Let start screen stay for 5 seconds -// vTaskDelay(INIT_START_SCREEN_DELAY); + vTaskDelay(INIT_START_SCREEN_DELAY); hwTestItems.display = &nhd0420->displayDevice; @@ -232,6 +240,7 @@ static void initTask(void* parameters) // Construct the repair menu repairMenus_construct(); + // xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 0, &sysTaskHandle); // Delete this init task diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c index ae0a2c8..42fcadc 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c @@ -31,7 +31,9 @@ #include "repairProcess.h" #include "repairProcesses.h" +#include "ADConverters.h" #include "CathodeMCP.h" +#include "DAConverters.h" #include "Display.h" #include "Error.h" #include "hsb-mrts.h" @@ -69,7 +71,7 @@ static const char cursorValue[2] = {0x7E, '\0'}; // TEMPORARY PRESET STORAGE -static const struct RepairPreset preset1 = {.numberOfStages = 1, .preset[0].softstartDuration = 100, .preset[0].duration = 200, .preset[0].voltage = 1000}; +static const struct RepairPreset preset1 = {.numberOfStages = 1, .preset[0].softstartDuration = 200, .preset[0].duration = 60, .preset[0].voltage = 1000}; static const struct RepairPreset preset2 = {.numberOfStages = 1, .preset[0].softstartDuration = 200, .preset[0].duration = 400, .preset[0].voltage = 3000}; static const struct RepairPreset preset3 = {.numberOfStages = 1, .preset[0].softstartDuration = 300, .preset[0].duration = 600, .preset[0].voltage = 300}; static const struct RepairPreset preset4 = {.numberOfStages = 1, .preset[0].softstartDuration = 400, .preset[0].duration = 800, .preset[0].voltage = 400}; @@ -77,7 +79,7 @@ static const struct RepairPreset preset5 = {.numberOfStages = 1, .preset[0].soft static const struct RepairPreset preset6 = {.numberOfStages = 1, .preset[0].softstartDuration = 600, .preset[0].duration = 1200, .preset[0].voltage = 600}; static const struct RepairPreset preset7 = {.numberOfStages = 1, .preset[0].softstartDuration = 700, .preset[0].duration = 1400, .preset[0].voltage = 700}; static const struct RepairPreset preset8 = {.numberOfStages = 1, .preset[0].softstartDuration = 800, .preset[0].duration = 1600, .preset[0].voltage = 800}; -static const struct RepairPreset preset9 = {.numberOfStages = 1, .preset[0].softstartDuration = 900, .preset[0].duration = 1800, .preset[0].voltage = 900}; +static const struct RepairPreset preset9 = {.numberOfStages = 2, .preset[0].softstartDuration = 900, .preset[0].duration = 1800, .preset[0].voltage = 6000, .preset[1].softstartDuration = 100, .preset[1].duration = 1800, .preset[1].voltage = 8000}; static const struct RepairPreset* presetArray[9] = {&preset1, &preset2, &preset3, &preset4, &preset5, &preset6, &preset7, &preset8, &preset9}; // ----------------------------------------------------------------------------- @@ -204,6 +206,7 @@ void repairMenu_destruct (struct RepairMenu* self) void repairMenu_interlockFailed(struct RepairMenu* self, T_INTERLOCK_ID interlockID) { repairMenu_changeState(self, ERROR_STATE); + if (interlockID == COMMON_INTERLOCK) { snprintf(self->errorMessage, sizeof(self->errorMessage) / sizeof(self->errorMessage[0]), "COVER OPEN"); @@ -275,13 +278,12 @@ static void repairMenu_task(void* parameters) else if (self->menuState == REPAIR_ASK_PAUSE) { uint32_t remainingTime = repairProcess_getRemainingRepairTime(repairProcesses_getMainRepairProcess()); + repairMenu_printAskPause(self); if (tempScreenCounter >= remainingTime) { // POPUP screen time is over, return to previous state repairMenu_changeState(self, tempMenuState); } - - repairMenu_printAskPause(self); } else if (self->menuState == REPAIR_PAUSE) { @@ -358,7 +360,6 @@ static void repairMenu_printRepair(struct RepairMenu* self) snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), " %02d:%02d:%02d remain ", remainingTime.hours, remainingTime.minutes, remainingTime.seconds); Display_write(self->display, buffer, 1, 1); - LOGGER_DEBUG(mainLog, "%s", buffer); // Regulation is unique for each row // For TESLA repair only row 1 (out of 0,1,2) is used @@ -369,14 +370,14 @@ static void repairMenu_printRepair(struct RepairMenu* self) row = repairProcess_getRowInformation(repairProcess, loopCounter); snprintf (buffer, sizeof(buffer) / sizeof(buffer[0]), "R%d", loopCounter + 1); - Display_write(self->display, buffer, 2, ((loopCounter * (self->display->displayDevice->parameters.numberOfColumns / REPAIRPROCESS_NUMBER_OF_ROWS)) + (self->display->displayDevice->parameters.numberOfColumns / REPAIRPROCESS_NUMBER_OF_ROWS) / strlen(buffer))); + Display_write(self->display, buffer, 2, ((loopCounter * (self->display->displayDevice->parameters.numberOfColumns / REPAIRPROCESS_NUMBER_OF_ROWS) + loopCounter) + (self->display->displayDevice->parameters.numberOfColumns / REPAIRPROCESS_NUMBER_OF_ROWS) / strlen(buffer))); if (!row->errorData.rowHasError) { - snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%05dV", row->lastADCValue); + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dV", row->lastADCValue); Display_write(self->display, buffer, 3, (loopCounter + (loopCounter * (self->display->displayDevice->parameters.numberOfColumns / REPAIRPROCESS_NUMBER_OF_ROWS)) + (self->display->displayDevice->parameters.numberOfColumns / REPAIRPROCESS_NUMBER_OF_ROWS) / strlen(buffer))); - snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%04dER", row->pidError); + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%4dER", row->pidError); Display_write(self->display, buffer, 4, (loopCounter + (loopCounter * (self->display->displayDevice->parameters.numberOfColumns / REPAIRPROCESS_NUMBER_OF_ROWS)) + (self->display->displayDevice->parameters.numberOfColumns / REPAIRPROCESS_NUMBER_OF_ROWS) / strlen(buffer))); } else @@ -631,12 +632,12 @@ static void repairMenu_solenoidUnlock(struct RepairMenu* self, int cursorIndex) static void repairMenu_startRepairProcess(struct RepairMenu* self, int cursorIndex) { ErrorStatus returnValue = SUCCESS; - self->rpParameters.adcRow1 = &adc1->channel[0]; - self->rpParameters.adcRow2 = &adc1->channel[1]; - self->rpParameters.adcRow3 = &adc1->channel[2]; - self->rpParameters.dacRow1 = &max5715->dac[0]; - self->rpParameters.dacRow2 = &max5715->dac[1]; - self->rpParameters.dacRow3 = &max5715->dac[2]; + self->rpParameters.adcR1 = adcRow1; + self->rpParameters.adcR2 = adcRow2; + self->rpParameters.adcR3 = adcRow3; + self->rpParameters.dacR1 = dacRow1; + self->rpParameters.dacR2 = dacRow2; + self->rpParameters.dacR3 = dacRow3; if (returnValue == SUCCESS) { @@ -700,11 +701,13 @@ static void repairMenu_pauseRepairProcess(struct RepairMenu* self, int cursorInd { repairMenu_changeState(self, REPAIR_PAUSE); repairProcess_pauseProcess(repairProcesses_getMainRepairProcess()); + hsb_disableSafety(); } static void repairMenu_continueRepairProcess(struct RepairMenu* self, int cursorIndex) { + hsb_enableSafety(); repairMenu_changeState(self, REPAIR_RUNNING); repairProcess_continueProcess(repairProcesses_getMainRepairProcess()); } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenus.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenus.c index f70edda..e1e7969 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenus.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenus.c @@ -103,6 +103,7 @@ struct RepairMenu* repairMenus_getMainRepairMenu(void) static ErrorStatus repairMenu_errorReceive(const void* const data) { + T_ErrorCode errorCode = (T_ErrorCode)data; // Only respond to the errors necessary if (errorCode == INTERLOCK_COMMON_FAIL) diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairProcess.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairProcess.c index f421dfa..be68362 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairProcess.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairProcess.c @@ -100,15 +100,15 @@ ErrorStatus repairProcess_construct(struct RepairProcess* self, struct RepairPro } if (returnValue == SUCCESS) { - returnValue = repairProcessRow_construct(&self->row[0], parameters->adcRow1, parameters->dacRow1, HSB_MAINREPR_OOL_DURATION, HSB_MAINREPR_OOL_VALUE); + returnValue = repairProcessRow_construct(&self->row[0], parameters->adcR1, parameters->dacR1, HSB_MAINREPR_OOL_DURATION, HSB_MAINREPR_OOL_VALUE); } if (returnValue == SUCCESS) { - returnValue = repairProcessRow_construct(&self->row[1], parameters->adcRow2, parameters->dacRow2, HSB_MAINREPR_OOL_DURATION, HSB_MAINREPR_OOL_VALUE); + returnValue = repairProcessRow_construct(&self->row[1], parameters->adcR2, parameters->dacR2, HSB_MAINREPR_OOL_DURATION, HSB_MAINREPR_OOL_VALUE); } if (returnValue == SUCCESS) { - returnValue = repairProcessRow_construct(&self->row[2], parameters->adcRow3, parameters->dacRow3, HSB_MAINREPR_OOL_DURATION, HSB_MAINREPR_OOL_VALUE); + returnValue = repairProcessRow_construct(&self->row[2], parameters->adcR3, parameters->dacR3, HSB_MAINREPR_OOL_DURATION, HSB_MAINREPR_OOL_VALUE); } if (returnValue == SUCCESS) { @@ -132,22 +132,27 @@ ErrorStatus repairProcess_construct(struct RepairProcess* self, struct RepairPro void repairProcess_destruct(struct RepairProcess* self) { - - MAX5715Channel_setValue(self->row[0].dacChannel, 0); - MAX5715Channel_setValue(self->row[1].dacChannel, 0); - MAX5715Channel_setValue(self->row[2].dacChannel, 0); - - self->runTask = false; - while (!self->taskIsRunning) + if (self->initialized) { - vTaskDelay(1); + // SET ALL DACs to 0 + DAConverter_setOutputVoltage(self->row[0].dacChannel, 0); + DAConverter_setOutputVoltage(self->row[1].dacChannel, 0); + DAConverter_setOutputVoltage(self->row[2].dacChannel, 0); + + self->runTask = false; + xSemaphoreGive(self->secondsSyncronisation); + while (!self->taskIsRunning) + { + vTaskDelay(1); + } + SignalProfileGenerator_destruct(&self->signalProfileGenerator); + Observable_destruct(&self->observable); + repairProcessRow_destruct(&self->row[0]); + repairProcessRow_destruct(&self->row[1]); + repairProcessRow_destruct(&self->row[2]); + vSemaphoreDelete(self->secondsSyncronisation); + self->initialized = false; } - Observable_destruct(&self->observable); - repairProcessRow_destruct(&self->row[0]); - repairProcessRow_destruct(&self->row[1]); - repairProcessRow_destruct(&self->row[2]); - vSemaphoreDelete(self->secondsSyncronisation); - self->initialized = false; } @@ -213,9 +218,9 @@ static void repairProcess_task(void* parameters) self->taskIsRunning = true; // Reset the seconds counter to 0 - MAX5715Channel_setValue(self->row[0].dacChannel, self->row[0].lastDACValue); - MAX5715Channel_setValue(self->row[1].dacChannel, self->row[1].lastDACValue); - MAX5715Channel_setValue(self->row[2].dacChannel, self->row[2].lastDACValue); + DAConverter_setOutputVoltage(self->row[0].dacChannel, self->row[0].lastDACValue); + DAConverter_setOutputVoltage(self->row[1].dacChannel, self->row[1].lastDACValue); + DAConverter_setOutputVoltage(self->row[2].dacChannel, self->row[2].lastDACValue); while(self->runTask) { @@ -237,7 +242,7 @@ static void repairProcess_task(void* parameters) if (!self->row[loopCounter].errorData.rowHasError) { // Read the last ADC channel value - ADCChannel_read(self->row[loopCounter].adcChannel, &self->row[loopCounter].lastADCValue); + self->row[loopCounter].lastADCValue = ADConverter_getInputVoltage(self->row[loopCounter].adcChannel); // Calculate the error self->row[loopCounter].pidError = self->signalProfileGenerator.signal - (int)self->row[loopCounter].lastADCValue; // Calculate the PID @@ -280,7 +285,7 @@ static void repairProcess_task(void* parameters) } } // Send the PID value to the DAC - MAX5715Channel_setValue(self->row[loopCounter].dacChannel, self->row[loopCounter].lastDACValue); + DAConverter_setOutputVoltage(self->row[loopCounter].dacChannel, self->row[loopCounter].lastDACValue); LOGGER_DEBUG(mainLog, "Row %d --- ADC: %d Error: %d PID: %d", loopCounter, self->row[loopCounter].lastADCValue, self->row[loopCounter].pidError, self->row[loopCounter].lastDACValue); } @@ -288,7 +293,7 @@ static void repairProcess_task(void* parameters) { // ROW is in error state self->row[loopCounter].lastDACValue = 0; - MAX5715Channel_setValue(self->row[loopCounter].dacChannel, self->row[loopCounter].lastDACValue); + DAConverter_setOutputVoltage(self->row[loopCounter].dacChannel, self->row[loopCounter].lastDACValue); LOGGER_ERROR(mainLog, "Row %d --- Row in ERROR state", loopCounter); } } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairProcessRow.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairProcessRow.c index 4fb61da..fefd73d 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairProcessRow.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairProcessRow.c @@ -54,7 +54,7 @@ // Function definitions // ----------------------------------------------------------------------------- -ErrorStatus repairProcessRow_construct(struct RepairProcessRow* self, const struct AdcChannel* adcChannel, const struct MAX5715_DAC* dacChannel, int outOfLimitsDuration, int outOfLimitsValue) +ErrorStatus repairProcessRow_construct(struct RepairProcessRow* self, const struct ADConverter* adcChannel, const struct DAConverter* dacChannel, int outOfLimitsDuration, int outOfLimitsValue) { ErrorStatus returnValue = SUCCESS;