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

@@ -29,6 +29,7 @@ CoverSolenoid.o \
crc32.o \
DACDevice.o \
DisplayDevice.o \
HighVoltageDetection.o \
hsb-mrts.o \
Interlock.o \
IODevice.o \

View File

@@ -0,0 +1,99 @@
// -----------------------------------------------------------------------------
/// @file HighVoltageDetection.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 HighVoltageDetection.h
/// @ingroup {group_name}
#ifndef INC_HIGHVOLTAGEDETECTION_H_
#define INC_HIGHVOLTAGEDETECTION_H_
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include <stdbool.h>
#include "stm32f10x.h"
#include "gpio.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
/** ----------------------------------------------------------------------------
* HighVoltageDetection_construct
* Constructs a HighVoltage detection
*
* @param HV0_gpio
* @param HV1_gpio
* @param HV2_gpio
*
* @return ErrorStatus SUCCESS if construction was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus HighVoltageDetection_construct(struct Gpio* HV0_gpio, struct Gpio* HV1_gpio, struct Gpio* HV2_gpio);
/** ----------------------------------------------------------------------------
* HighVoltageDetection_destruct
* Destructor for High Voltage detection
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void HighVoltageDetection_destruct(void);
/** ----------------------------------------------------------------------------
* HighVoltageDetection_isVoltagePresent
* Determines whether or not a High Voltage is present on the given inputs
*
* @return bool TRUE if at least one of the given inputs
* has HIGH voltage present
* FALSE otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern bool HighVoltageDetection_isVoltagePresent(void);
#endif /* INC_HIGHVOLTAGEDETECTION_H_ */

View File

@@ -33,6 +33,10 @@
#include <stdbool.h>
#include "stm32f10x.h"
#include "gpio.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
@@ -61,12 +65,17 @@ typedef enum
* Led_construct
* Constructor for LEDs
*
* @param onboardGreen
* @param onboardOrange
* @param bicolourGreen
* @param bicolourRed
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void Led_construct(void);
extern ErrorStatus Led_construct(struct Gpio* onboardGreen, struct Gpio* onboardOrange, struct Gpio* bicolourGreen, struct Gpio* bicolourRed);
/** ----------------------------------------------------------------------------

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;
}
}
}
}