Files
hsb/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/repairProcess.h
mmi 088ce81dc7 Most parts of the menu structure are functional.
Error handler added
Screens for warning, pause, FINISH etc yet to be added

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@255 05563f52-14a8-4384-a975-3d1654cca0fa
2017-10-17 15:23:56 +00:00

186 lines
5.7 KiB
C

// -----------------------------------------------------------------------------
/// @file repairProcess.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 repairProcess.h
/// @ingroup {group_name}
#ifndef REPAIRPROCESS_H_
#define REPAIRPROCESS_H_
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include <stdbool.h>
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "stm32f10x.h"
#include "repairPreset.h"
#include "PID.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
#define REPAIRPROCESS_NUMBER_OF_ROWS (3)
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
typedef enum
{
PREPARE = 0,
SOFTSTART,
VOLTAGE_HOLD,
PAUSE,
PAUSE_RESTORE,
FINISH_VERIFY,
FINISHED
} RepairState;
struct RepairProcessParameters
{
const struct AdcChannel* adcRow1;
const struct AdcChannel* adcRow2;
const struct AdcChannel* adcRow3;
const struct MAX5715_DAC* dacRow1;
const struct MAX5715_DAC* dacRow2;
const struct MAX5715_DAC* dacRow3;
};
struct RepairProcess
{
TaskHandle_t taskHandle;
int TaskPriority;
uint16_t stackSize;
bool runTask;
SemaphoreHandle_t secondsSyncronisation;
uint32_t startTime;
uint32_t secondsCounter;
uint32_t softStartTimer;
uint32_t voltageHoldTimer;
RepairState currentState;
bool initialized;
size_t currentPresetIndex;
struct RepairPreset* repairPreset;
const struct AdcChannel* adc[REPAIRPROCESS_NUMBER_OF_ROWS];
const struct MAX5715_DAC* dac[REPAIRPROCESS_NUMBER_OF_ROWS];
struct Pid pid[REPAIRPROCESS_NUMBER_OF_ROWS];
};
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
/** ----------------------------------------------------------------------------
* repairProcess_construct
* Description of function
*
* @param self The process object
* @param parameters
* @param preset
* @param taskPriority Task priority for the repair process
* @param stackSize Stacksize of the task
*
* @return ErrorStatus SUCCESS if construction was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus repairProcess_construct(struct RepairProcess* self, struct RepairProcessParameters* parameters, const struct RepairPreset* preset, int taskPriority, uint16_t stackSize);
/** ----------------------------------------------------------------------------
* repairProcess_construct
* Destructor for repair process
*
* @param self The process object
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void repairProcess_destruct(struct RepairProcess* self);
/** ----------------------------------------------------------------------------
* repairProcess_feedSecondsCounter
* Feeds the seconds counter of the repair process.
* The process is designed to be run every second, so this feed function should
* be called every second.
*
* @param self The repair process
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void repairProcess_feedSecondsCounter(struct RepairProcess* self);
/** ----------------------------------------------------------------------------
* repairProcess_feedSecondsCounterFromISR
* Feeds the seconds counter of the repair process.
* This function should be called in an ISR context
* The process is designed to be run every second, so this feed function should
* be called every second.
*
* @param self The repair process
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void repairProcess_feedSecondsCounterFromISR(struct RepairProcess* self);
/** ----------------------------------------------------------------------------
* repairProcess_getRepairTime
* Returns the current active repair time in seconds.
*
* @param self
* @param repairTime
* @param hours
* @param minutes
* @param seconds
*
* @return ErrorStatus
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus repairProcess_getRepairTime(const struct RepairProcess* self, uint32_t* repairTime, int* hours, int* minutes, int* seconds);
#endif /* REPAIRPROCESS_H_ */