Started working on issue to release tesla gun only when target voltage has been reached git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@430 05563f52-14a8-4384-a975-3d1654cca0fa
131 lines
3.1 KiB
C
131 lines
3.1 KiB
C
// -----------------------------------------------------------------------------
|
|
/// @file TeslaGunSafety.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 TeslaGunSafety.c
|
|
/// @ingroup {group_name}
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Include files
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#include "TeslaGunSafety.h"
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Constant and macro definitions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Type definitions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
struct TeslaGunSafety
|
|
{
|
|
bool initialized;
|
|
struct Gpio* gpio;
|
|
};
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// File-scope variables
|
|
// -----------------------------------------------------------------------------
|
|
|
|
static struct TeslaGunSafety self;
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Function declarations
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Function definitions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
ErrorStatus TeslaGunSafety_construct(struct Gpio* gpio)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (!self.initialized)
|
|
{
|
|
self.gpio = gpio;
|
|
self.initialized = true;
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
void TeslaGunSafety_destruct(void)
|
|
{
|
|
if (self.initialized)
|
|
{
|
|
self.initialized = false;
|
|
}
|
|
}
|
|
|
|
|
|
ErrorStatus TeslaGunSafety_release(void)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (self.initialized)
|
|
{
|
|
returnValue = GPIO_setValue(self.gpio, true);
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
bool TeslaGunSafety_isReleased(void)
|
|
{
|
|
bool returnValue;
|
|
|
|
GPIO_getValue(self.gpio, &returnValue);
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
ErrorStatus TeslaGunSafety_block(void)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (self.initialized)
|
|
{
|
|
returnValue = GPIO_setValue(self.gpio, false);
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
struct Gpio* TeslaGunSafety_getGpio(void)
|
|
{
|
|
return self.gpio;
|
|
}
|