Replaced verification of voltageFree rows with HighVoltageDetection module

Added LED module

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@338 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-12-04 15:18:32 +00:00
parent 7577593dd1
commit 056572f24e
14 changed files with 400 additions and 73 deletions

View File

@@ -0,0 +1,131 @@
// -----------------------------------------------------------------------------
/// @file HighVoltageDetection.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 HighVoltageDetection.c
/// @ingroup {group_name}
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include "HighVoltageDetection.h"
#include "IODevice.h"
#include "PCBA.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions
// -----------------------------------------------------------------------------
struct HighVoltageDetection
{
struct IODevice* hv0;
struct IODevice* hv1;
struct IODevice* hv2;
bool initialized;
};
// -----------------------------------------------------------------------------
// File-scope variables
// -----------------------------------------------------------------------------
static struct HighVoltageDetection _hvDetection = {.initialized = false};
struct HighVoltageDetection* const hvDetection = &_hvDetection;
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Function definitions
// -----------------------------------------------------------------------------
ErrorStatus HighVoltageDetection_construct(struct Gpio* HV0_gpio, struct Gpio* HV1_gpio, struct Gpio* HV2_gpio)
{
ErrorStatus returnValue = SUCCESS;
if (!hvDetection->initialized)
{
hvDetection->hv0 = &HV0_gpio->device;
hvDetection->hv1 = &HV1_gpio->device;
hvDetection->hv2 = &HV2_gpio->device;
hvDetection->initialized = true;
}
else
{
returnValue = ERROR;
}
return returnValue;
}
extern void HighVoltageDetection_destruct(void)
{
hvDetection->initialized = false;
}
bool HighVoltageDetection_isVoltagePresent(void)
{
bool returnValue = false;
if (hvDetection->initialized)
{
char value0;
char value1;
char value2;
IODevice_read(hvDetection->hv0, &value0, 1, NULL);
IODevice_read(hvDetection->hv1, &value1, 1, NULL);
IODevice_read(hvDetection->hv2, &value2, 1, NULL);
if (PCBA_getInstance()->pcba == PCBA_Tesla)
{
// For TESLA repair, only ROW2 (HV1) is used
if (value1 != (char)false)
{
// At least on voltage is present, so returnValue must be TRUE
returnValue = true;
}
}
else
{
// For CathodeMCP or Anode, all three rows are used
if ((value0 != (char)false) || (value1 != (char)false) || (value2 != (char)false))
{
// At least on voltage is present, so returnValue must be TRUE
returnValue = true;
}
}
}
return returnValue;
}

View File

@@ -71,24 +71,30 @@ static struct Leds self = { .initialized = false };
// Function definitions
// -----------------------------------------------------------------------------
void Led_construct(void)
ErrorStatus Led_construct(struct Gpio* onboardGreen, struct Gpio* onboardOrange, struct Gpio* bicolourGreen, struct Gpio* bicolourRed)
{
ErrorStatus returnValue = SUCCESS;
if (!self.initialized)
{
self.initialized = true;
self.leds[LED_ONBOARD_GREEN].ioDevice = &ledInternGreen->device;
self.leds[LED_ONBOARD_GREEN].ioDevice = &onboardGreen->device;
self.leds[LED_ONBOARD_GREEN].initialized = true;
self.leds[LED_ONBOARD_ORANGE].ioDevice = &ledInternOrange->device;
self.leds[LED_ONBOARD_ORANGE].ioDevice = &onboardOrange->device;
self.leds[LED_ONBOARD_ORANGE].initialized = true;
self.leds[LED_BICOLOR_GREEN].ioDevice = &ledBicolourGreen->device;
self.leds[LED_BICOLOR_GREEN].ioDevice = &bicolourGreen->device;
self.leds[LED_BICOLOR_GREEN].initialized = true;
self.leds[LED_BICOLOR_RED].ioDevice = &ledBicolourRed->device;
self.leds[LED_BICOLOR_RED].ioDevice = &bicolourRed->device;
self.leds[LED_BICOLOR_RED].initialized = true;
}
else
{
returnValue = ERROR;
}
return returnValue;
}
@@ -146,11 +152,26 @@ extern bool Led_getStatus(Led led)
{
if (self.leds[led].initialized)
{
char value;
IODevice_read(self.leds[led].ioDevice, &value, 1, NULL);
if (value != (char)false)
// IN case of the BICOLOUR ORANGE LED, actually the GREEN and RED LEDs must be read
if (led == LED_BICOLOR_ORANGE)
{
returnValue = true;
char valueRed;
char valueGreen;
IODevice_read(self.leds[LED_BICOLOR_RED].ioDevice, &valueRed, 1, NULL);
IODevice_read(self.leds[LED_BICOLOR_GREEN].ioDevice, &valueGreen, 1, NULL);
if ((valueRed != (char)false) && (valueGreen != (char)false))
{
returnValue = true;
}
}
else
{
char value;
IODevice_read(self.leds[led].ioDevice, &value, 1, NULL);
if (value != (char)false)
{
returnValue = true;
}
}
}
}