checked in missing file

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@240 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-10-06 09:04:50 +00:00
parent 5105d55089
commit 71ae4c6832
8 changed files with 382 additions and 24 deletions

View File

@@ -0,0 +1,130 @@
// -----------------------------------------------------------------------------
/// @file repairProcess.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 repairProcess.c
/// @ingroup {group_name}
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include "FreeRTOS.h"
#include "queue.h"
#include "semphr.h"
#include "task.h"
#include "repairProcess.h"
#include "repairPreset.h"
#include "Logger.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// File-scope variables
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
static void repairProcess_task(void* parameters);
// -----------------------------------------------------------------------------
// Function definitions
// -----------------------------------------------------------------------------
ErrorStatus repairProcess_construct(struct RepairProcess* self, int taskPriority, uint16_t stackSize)
{
ErrorStatus returnValue = SUCCESS;
if (!self->initialized)
{
// Create a semaphore to sync access to the display shadow
vSemaphoreCreateBinary(self->secondsSyncronisation);
xSemaphoreGive(self->secondsSyncronisation);
if (xTaskCreate(repairProcess_task, "RepairProcess", stackSize, self, taskPriority, &self->taskHandle) != pdTRUE)
{
returnValue = ERROR;
}
if (returnValue == SUCCESS)
{
self->runTask = true;
}
}
else
{
returnValue = ERROR;
}
return returnValue;
}
void repairProcess_feedSecondsCounter(struct RepairProcess* self)
{
xSemaphoreGive(self->secondsSyncronisation);
}
void repairProcess_feedSecondsCounterFromISR(struct RepairProcess* self)
{
portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
xSemaphoreGiveFromISR(self->secondsSyncronisation, &higherPriorityTaskWoken);
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
}
static void repairProcess_task(void* parameters)
{
struct RepairProcess* self = (struct RepairProcess*)parameters;
while(self->runTask)
{
xSemaphoreTake(self->secondsSyncronisation, portMAX_DELAY);
int hours = (self->secondsCounter / (60 * 60));
int minutes = (self->secondsCounter - (hours * 60 * 60)) / 60;
int seconds = (self->secondsCounter - (hours * 60 * 60) - (minutes * 60));
LOGGER_WARNING(mainLog, "--- Repair clock %02i %02d %02d", hours, minutes, seconds);
self->secondsCounter++;
}
vTaskDelete(self->taskHandle);
}