Added Interlock
Fixed PID regulation functionality git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@250 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file Interlock.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 Interlock.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "Interlock.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ErrorStatus Interlock_construct(struct Interlock* self, struct Gpio* NO, EXTI_InitTypeDef NOEXTI, struct Gpio* NC, EXTI_InitTypeDef NCEXTI)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
{
|
||||
self->NO.io = NO;
|
||||
self->NO.ioEXTI = NOEXTI;
|
||||
self->NC.io = NC;
|
||||
self->NC.ioEXTI = NCEXTI;
|
||||
self->initialized = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void Interlock_getStatus(struct Interlock* self, FunctionalState* command, int* NO, int* NC)
|
||||
{
|
||||
*command = self->NO.ioEXTI.EXTI_LineCmd;
|
||||
|
||||
IODevice_read((struct IODevice*)self->NO.io, (char*)NO, 1, NULL);
|
||||
IODevice_read((struct IODevice*)self->NC.io, (char*)NC, 1, NULL);
|
||||
}
|
||||
|
||||
|
||||
bool Interlock_isClosed(struct Interlock* self)
|
||||
{
|
||||
bool returnValue;
|
||||
|
||||
char no;
|
||||
char nc;
|
||||
|
||||
IODevice_read((struct IODevice*)self->NO.io, &no, 1, NULL);
|
||||
IODevice_read((struct IODevice*)self->NC.io, &nc, 1, NULL);
|
||||
|
||||
if ((no != 0) && (nc == 0))
|
||||
{
|
||||
returnValue = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = false;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void Interlock_setEXTI(struct Interlock* self, FunctionalState command)
|
||||
{
|
||||
self->NO.ioEXTI.EXTI_LineCmd = command;
|
||||
EXTI_Init(&self->NO.ioEXTI);
|
||||
|
||||
self->NC.ioEXTI.EXTI_LineCmd = command;
|
||||
EXTI_Init(&self->NC.ioEXTI);
|
||||
}
|
||||
Reference in New Issue
Block a user