git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@268 05563f52-14a8-4384-a975-3d1654cca0fa
184 lines
5.3 KiB
C
184 lines
5.3 KiB
C
// -----------------------------------------------------------------------------
|
|
/// @file hsb-mrts.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 hsb-mrts.c
|
|
/// @ingroup {group_name}
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Include files
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "hsb-mrts.h"
|
|
|
|
#include "ADConverter.h"
|
|
#include "ADConverters.h"
|
|
#include "DAConverter.h"
|
|
#include "DAConverters.h"
|
|
#include "Display.h"
|
|
#include "Error.h"
|
|
|
|
#include "platform.h"
|
|
#include "CoverSolenoid.h"
|
|
#include "Interlock.h"
|
|
#include "Logger.h"
|
|
#include "PCBA.h"
|
|
#include "Power6V5Supply.h"
|
|
#include "Version.h"
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Constant and macro definitions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Type definitions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// File-scope variables
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Function declarations
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Function definitions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
ErrorStatus hsb_generateStartScreen(struct Display* Display)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
|
|
if (returnValue == SUCCESS)
|
|
{
|
|
returnValue = Display_write(mainDisplay, PCBA_getInstance()->name, 1, 1);
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
|
|
if (returnValue == SUCCESS)
|
|
{
|
|
char buffer[20];
|
|
|
|
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "SW V. %d.%d.%d.%d", Version_getInstance()->major,
|
|
Version_getInstance()->minor,
|
|
Version_getInstance()->branch,
|
|
Version_getInstance()->patch);
|
|
Display_write(mainDisplay, buffer, 3, 4);
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
ErrorStatus hsb_enableSafety(void)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
|
|
// First, Lock the cover
|
|
if (returnValue == SUCCESS)
|
|
{
|
|
CoverSolenoid_lock();
|
|
}
|
|
|
|
if (returnValue == SUCCESS)
|
|
{
|
|
// Check for INTERLOCK CLOSE
|
|
// if (Interlock_isClosed(interlock))
|
|
if (1)
|
|
{
|
|
// Enable Interrupt for interlock switch
|
|
Interlock_setEXTI(interlock, ENABLE);
|
|
}
|
|
else
|
|
{
|
|
Error_postError(INTERLOCK_COMMON_FAIL);
|
|
returnValue = ERROR;
|
|
}
|
|
}
|
|
|
|
// if Interlock(s) closed, continue procedure
|
|
if (returnValue == SUCCESS)
|
|
{
|
|
// Power the circuit
|
|
Power6V5Supply_on();
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
ErrorStatus hsb_disableSafety(void)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
|
|
int adcR1Value = HSB_SECURITY_VOLTAGE_THRESHOLD;
|
|
int adcR2Value = HSB_SECURITY_VOLTAGE_THRESHOLD;
|
|
int adcR3Value = HSB_SECURITY_VOLTAGE_THRESHOLD;
|
|
|
|
Display_clearScreen(mainDisplay);
|
|
char buffer[mainDisplay->displayDevice->parameters.numberOfColumns];
|
|
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "WAITING FOR");
|
|
Display_write(mainDisplay, buffer, 2, 5);
|
|
|
|
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "POWER");
|
|
Display_write(mainDisplay, buffer, 3, 7);
|
|
|
|
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "DOWN");
|
|
Display_write(mainDisplay, buffer, 4, 8);
|
|
|
|
// Power-down the DAC outputs
|
|
DAConverter_setOutputVoltage(dacRow1, 0);
|
|
DAConverter_setOutputVoltage(dacRow2, 0);
|
|
DAConverter_setOutputVoltage(dacRow3, 0);
|
|
|
|
// Un-Power the circuit
|
|
Power6V5Supply_off();
|
|
|
|
|
|
// Verify that all High Voltage Supplies are shut off and voltages are below security value
|
|
while ((abs(adcR1Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD) || (abs(adcR2Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD) || (abs(adcR3Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD))
|
|
{
|
|
adcR1Value = ADConverter_getInputVoltage(adcRow1);
|
|
adcR2Value = ADConverter_getInputVoltage(adcRow2);
|
|
adcR3Value = ADConverter_getInputVoltage(adcRow3);
|
|
vTaskDelay(100);
|
|
}
|
|
|
|
Interlock_setEXTI(interlock, DISABLE);
|
|
|
|
return returnValue;
|
|
}
|