Added buzzer

Added powerloss detector

Added buzzer behaviour to system.
Added powerloss behaviour to system 

Added french translation to menu texts

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@359 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-12-13 13:22:06 +00:00
parent 9a5bbf8a7a
commit a48164fe7a
24 changed files with 973 additions and 160 deletions

View File

@@ -0,0 +1,182 @@
// -----------------------------------------------------------------------------
/// @file Buzzer.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 Buzzer.c
/// @ingroup {group_name}
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include "Buzzer.h"
#include "gpio.h"
#include "IODevice.h"
#include "Logger.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// File-scope variables
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
static void BuzzerTask(void* parameters);
// -----------------------------------------------------------------------------
// Function definitions
// -----------------------------------------------------------------------------
ErrorStatus Buzzer_construct(struct Buzzer* self, struct Gpio* gpio, int taskPriority, uint16_t stackSize)
{
ErrorStatus returnValue = SUCCESS;
if (!self->initialized)
{
if (returnValue == SUCCESS)
{
if (gpio != NULL)
{
self->gpio = gpio;
}
else
{
returnValue = ERROR;
}
}
if (returnValue == SUCCESS)
{
self->taskPriority = taskPriority;
self->stackSize = stackSize;
}
if (returnValue == SUCCESS)
{
vSemaphoreCreateBinary(self->semaphore);
self->runPeriodically = false;
}
BaseType_t ctReturn = 0;
if (returnValue == SUCCESS)
{
self->runTask = true;
ctReturn = xTaskCreate(BuzzerTask, (const char*)"BuzzerTask", self->stackSize, self, self->taskPriority, &self->taskHandle);
}
if (ctReturn != pdPASS)
{
returnValue = ERROR;
LOGGER_ERROR(mainLog, "Buzzer task failed to create with error %d", (int)ctReturn);
}
else
{
self->initialized = true;
LOGGER_INFO(mainLog, "Buzzer task created successfully");
}
}
else
{
returnValue = ERROR;
}
return returnValue;
}
extern void Buzzer_destruct(struct Buzzer* self)
{
self->runTask = false;
self->initialized = false;
}
void Buzzer_start(struct Buzzer* self, unsigned int pulseWidth)
{
if (self->initialized)
{
if (pulseWidth >= BUZZER_MIN_PULSEWIDTH_MS)
{
self->pulseWidth = pulseWidth;
xSemaphoreGive(self->semaphore);
self->runPeriodically = true;
}
}
}
void Buzzer_stop(struct Buzzer* self)
{
if (self->initialized)
{
self->runPeriodically = false;
}
}
void Buzzer_singleTone(struct Buzzer* self, unsigned int pulseWidth)
{
if (self->initialized)
{
self->runPeriodically = false;
self->pulseWidth = pulseWidth;
xSemaphoreGive(self->semaphore);
}
}
static void BuzzerTask(void* parameters)
{
char cTrue = (char)true;
char cFalse = (char)false;
struct Buzzer* self = (struct Buzzer*)parameters;
while (self->runTask)
{
xSemaphoreTake(self->semaphore, portMAX_DELAY);
IODevice_write(&self->gpio->device, &cTrue, 1);
vTaskDelay(self->pulseWidth);
IODevice_write(&self->gpio->device, &cFalse, 1);
vTaskDelay(self->pulseWidth);
// For periodic use, give semaphore
if (self->runPeriodically)
{
xSemaphoreGive(self->semaphore);
}
}
LOGGER_INFO(mainLog, "Deleting task %s", pcTaskGetTaskName(self->taskHandle));
vTaskDelete(NULL);
}

View File

@@ -42,9 +42,9 @@
struct HighVoltageDetection
{
struct IODevice* hv0;
struct IODevice* hv1;
struct IODevice* hv2;
struct Gpio* hv0;
struct Gpio* hv1;
struct Gpio* hv2;
bool initialized;
};
@@ -71,9 +71,9 @@ ErrorStatus HighVoltageDetection_construct(struct Gpio* HV0_gpio, struct Gpio* H
if (!hvDetection->initialized)
{
hvDetection->hv0 = &HV0_gpio->device;
hvDetection->hv1 = &HV1_gpio->device;
hvDetection->hv2 = &HV2_gpio->device;
hvDetection->hv0 = HV0_gpio;
hvDetection->hv1 = HV1_gpio;
hvDetection->hv2 = HV2_gpio;
hvDetection->initialized = true;
}
else
@@ -102,10 +102,11 @@ bool HighVoltageDetection_isVoltagePresent(void)
char value0;
char value1;
char value2;
size_t al;
IODevice_read(hvDetection->hv0, &value0, 1, NULL);
IODevice_read(hvDetection->hv1, &value1, 1, NULL);
IODevice_read(hvDetection->hv2, &value2, 1, NULL);
IODevice_read((struct IODevice*)hvDetection->hv0, &value0, 1, &al);
IODevice_read((struct IODevice*)hvDetection->hv1, &value1, 1, &al);
IODevice_read((struct IODevice*)hvDetection->hv2, &value2, 1, &al);
if (PCBA_getInstance()->pcba == PCBA_Tesla)
{
@@ -127,5 +128,6 @@ bool HighVoltageDetection_isVoltagePresent(void)
}
}
return returnValue;
}

View File

@@ -157,8 +157,9 @@ extern bool Led_getStatus(Led led)
{
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);
size_t al;
IODevice_read(self.leds[LED_BICOLOR_RED].ioDevice, &valueRed, 1, &al);
IODevice_read(self.leds[LED_BICOLOR_GREEN].ioDevice, &valueGreen, 1, &al);
if ((valueRed != (char)false) && (valueGreen != (char)false))
{
returnValue = true;
@@ -167,7 +168,8 @@ extern bool Led_getStatus(Led led)
else
{
char value;
IODevice_read(self.leds[led].ioDevice, &value, 1, NULL);
size_t al;
IODevice_read(self.leds[led].ioDevice, &value, 1, &al);
if (value != (char)false)
{
returnValue = true;