Major updates:
- added DAConverter(s) - added ADConverter(s) - Fixed some display issues - Made repair process and signalProfileGenerator calculate with voltages (signed) instead of DAC/ADC values - Fixed several bugs in task handlings - Put display data mirror into dedicated file displaycontent git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@261 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -0,0 +1,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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -25,6 +25,8 @@
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user