Fixed multiple bugs and errors.
- Added WARNING handler - put voltage calculations to dedicated module fixed last errors. Updated menu repair screen without ERROR from PID This is version 0.9.0.3, which is used for the first duration test Will also be tagged git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@272 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -11,7 +11,7 @@ ROOTDIR = ../
|
|||||||
|
|
||||||
LIBRARY_NAME = libHAL.a
|
LIBRARY_NAME = libHAL.a
|
||||||
|
|
||||||
CCFLAGS = -c -O2 -Wall -g -fno-common -mcpu=cortex-m3 -mthumb $(PLATFORM) $(RELEASE_DEFINES) $(ADDITIONAL_SWITCHES) \
|
CCFLAGS = -c -O2 -Wall -Werror -g -fno-common -mcpu=cortex-m3 -mthumb $(PLATFORM) $(RELEASE_DEFINES) $(ADDITIONAL_SWITCHES) \
|
||||||
-Iinc \
|
-Iinc \
|
||||||
-I$(ROOTDIR)/Platform/inc \
|
-I$(ROOTDIR)/Platform/inc \
|
||||||
-I$(ROOTDIR)/hsb-mrts/inc \
|
-I$(ROOTDIR)/hsb-mrts/inc \
|
||||||
|
|||||||
@@ -49,11 +49,13 @@
|
|||||||
struct DACDevice;
|
struct DACDevice;
|
||||||
|
|
||||||
typedef ErrorStatus (*DACWriteFunction)(const struct DACDevice* self, uint32_t voltage);
|
typedef ErrorStatus (*DACWriteFunction)(const struct DACDevice* self, uint32_t voltage);
|
||||||
|
typedef uint32_t (*DACReadbackFunction)(const struct DACDevice* self);
|
||||||
|
|
||||||
|
|
||||||
struct DACDevice
|
struct DACDevice
|
||||||
{
|
{
|
||||||
DACWriteFunction _write;
|
DACWriteFunction _write;
|
||||||
|
DACReadbackFunction _readback;
|
||||||
bool initialized;
|
bool initialized;
|
||||||
unsigned int resolutionInBits;
|
unsigned int resolutionInBits;
|
||||||
};
|
};
|
||||||
@@ -76,7 +78,7 @@ struct DACDevice
|
|||||||
* @todo
|
* @todo
|
||||||
* -----------------------------------------------------------------------------
|
* -----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
extern ErrorStatus DACDevice_construct(struct DACDevice* self, DACWriteFunction write, unsigned int resolutionInBits);
|
extern ErrorStatus DACDevice_construct(struct DACDevice* self, DACWriteFunction write, DACReadbackFunction readback, unsigned int resolutionInBits);
|
||||||
|
|
||||||
|
|
||||||
/** ----------------------------------------------------------------------------
|
/** ----------------------------------------------------------------------------
|
||||||
@@ -106,4 +108,7 @@ extern void DACDevice_destruct(struct DACDevice* self);
|
|||||||
*/
|
*/
|
||||||
extern ErrorStatus DACDevice_write(const struct DACDevice* self, uint32_t voltage);
|
extern ErrorStatus DACDevice_write(const struct DACDevice* self, uint32_t voltage);
|
||||||
|
|
||||||
|
|
||||||
|
extern uint32_t DACDevice_getCurrentValue(const struct DACDevice* self);
|
||||||
|
|
||||||
#endif /* INC_DACDEVICE_H_ */
|
#endif /* INC_DACDEVICE_H_ */
|
||||||
|
|||||||
@@ -238,6 +238,6 @@ extern ErrorStatus MAX5715Channel_construct(struct MAX5715_DAC* self, struct MAX
|
|||||||
* @todo
|
* @todo
|
||||||
* -----------------------------------------------------------------------------
|
* -----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
extern ErrorStatus MAX5715Channel_setValue(const struct MAX5715_DAC* self, uint16_t value);
|
extern ErrorStatus MAX5715Channel_setValue(struct MAX5715_DAC* self, uint16_t value);
|
||||||
|
|
||||||
#endif /* INC_MAX5715_H_ */
|
#endif /* INC_MAX5715_H_ */
|
||||||
|
|||||||
@@ -39,51 +39,6 @@
|
|||||||
// Constant and macro definitions
|
// Constant and macro definitions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
const static uint32_t crc32_tab[] = {
|
|
||||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
|
|
||||||
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
|
||||||
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
|
|
||||||
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
|
||||||
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
|
||||||
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
|
|
||||||
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
|
|
||||||
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
|
||||||
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
|
|
||||||
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
|
||||||
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
|
|
||||||
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
|
||||||
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
|
|
||||||
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
|
|
||||||
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
|
||||||
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
|
||||||
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
|
|
||||||
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
|
|
||||||
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
|
|
||||||
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
|
||||||
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
|
|
||||||
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
|
|
||||||
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
|
|
||||||
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
|
||||||
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
|
||||||
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
|
|
||||||
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
|
|
||||||
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
|
||||||
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
|
|
||||||
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
|
||||||
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
|
|
||||||
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
|
||||||
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
|
|
||||||
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
|
|
||||||
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
|
||||||
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
|
||||||
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
|
|
||||||
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
|
|
||||||
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
|
|
||||||
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
|
||||||
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
|
|
||||||
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
|
||||||
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
|
||||||
};
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Type definitions.
|
// Type definitions.
|
||||||
|
|||||||
@@ -25,13 +25,13 @@
|
|||||||
// Include files
|
// Include files
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "Logger.h"
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "CachedStorage.h"
|
#include "CachedStorage.h"
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
#include "InternalFlash.h"
|
#include "InternalFlash.h"
|
||||||
|
|
||||||
#include "stm32f10x_flash.h"
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Constant and macro definitions
|
// Constant and macro definitions
|
||||||
@@ -92,10 +92,6 @@ ErrorStatus CachedStorage_construct(struct CachedStorage* self, struct MemoryDev
|
|||||||
returnValue = ERROR;
|
returnValue = ERROR;
|
||||||
LOGGER_ERROR(mainLog, "Failed to malloc to tempbuffer");
|
LOGGER_ERROR(mainLog, "Failed to malloc to tempbuffer");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
LOGGER_INFO(mainLog, "Created tempBuffer memory with size %x at address %p", self->cacheSize, self->tempBuffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
@@ -106,10 +102,6 @@ ErrorStatus CachedStorage_construct(struct CachedStorage* self, struct MemoryDev
|
|||||||
returnValue = ERROR;
|
returnValue = ERROR;
|
||||||
LOGGER_ERROR(mainLog, "Failed to malloc to storage");
|
LOGGER_ERROR(mainLog, "Failed to malloc to storage");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
LOGGER_INFO(mainLog, "Created storage memory with size %x at address %p", self->cacheSize, self->storage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
@@ -118,7 +110,7 @@ ErrorStatus CachedStorage_construct(struct CachedStorage* self, struct MemoryDev
|
|||||||
self->initialized = true;
|
self->initialized = true;
|
||||||
self->dirty = false;
|
self->dirty = false;
|
||||||
|
|
||||||
LOGGER_DEBUG(mainLog, "Created Cached Storage at page: %d", self->pageNumber);
|
LOGGER_INFO(mainLog, "Created Cached Storage at page: %d", self->pageNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
@@ -130,7 +122,6 @@ void CachedStorage_destruct(struct CachedStorage* self)
|
|||||||
{
|
{
|
||||||
vPortFree(self->storage);
|
vPortFree(self->storage);
|
||||||
vPortFree(self->tempBuffer);
|
vPortFree(self->tempBuffer);
|
||||||
LOGGER_INFO(mainLog, "Free'd buffers");
|
|
||||||
self->initialized = false;
|
self->initialized = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,7 +150,7 @@ void CachedStorage_writeBlob(struct CachedStorage* self, int offset, const void*
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOGGER_ERROR(mainLog, "WriteBlob failed at offset %d, blobsize %d --- %p", offset, blobSize, self->storage[offset]);
|
LOGGER_ERROR(mainLog, "WriteBlob failed at offset %d, blobsize %d --- %p", offset, blobSize, &self->storage[offset]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,7 +186,7 @@ const void* CachedStorage_readBlob(struct CachedStorage* self, int offset)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOGGER_ERROR(mainLog, "ReadBlob failed at offset %d --- %p", offset, self->storage[offset]);
|
LOGGER_ERROR(mainLog, "ReadBlob failed at offset %d --- %p", offset, &self->storage[offset]);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,14 +215,14 @@ void CachedStorage_commit(struct CachedStorage* self)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOGGER_DEBUG(mainLog, "CachedStorage content unchanged, did not write");
|
LOGGER_INFO(mainLog, "No changes made to cache");
|
||||||
}
|
}
|
||||||
|
|
||||||
self->dirty = false;
|
self->dirty = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOGGER_DEBUG(mainLog, "CachedStorage content unchanged, did not write");
|
LOGGER_INFO(mainLog, "No changes made to cache");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,21 +57,15 @@
|
|||||||
// Function definitions
|
// Function definitions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
ErrorStatus DACDevice_construct(struct DACDevice* self, DACWriteFunction write, unsigned int resolutionInBits)
|
ErrorStatus DACDevice_construct(struct DACDevice* self, DACWriteFunction write, DACReadbackFunction readback, unsigned int resolutionInBits)
|
||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
if (!self->initialized)
|
if (!self->initialized)
|
||||||
{
|
{
|
||||||
if (write != NULL)
|
|
||||||
{
|
|
||||||
self->_write = write;
|
self->_write = write;
|
||||||
|
self->_readback = readback;
|
||||||
self->resolutionInBits = resolutionInBits;
|
self->resolutionInBits = resolutionInBits;
|
||||||
self->initialized = true;
|
self->initialized = true;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
returnValue = ERROR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -111,3 +105,26 @@ ErrorStatus DACDevice_write(const struct DACDevice* self, uint32_t voltage)
|
|||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t DACDevice_getCurrentValue(const struct DACDevice* self)
|
||||||
|
{
|
||||||
|
uint32_t returnValue = SUCCESS;
|
||||||
|
if (self->initialized)
|
||||||
|
{
|
||||||
|
if (self->_readback != NULL)
|
||||||
|
{
|
||||||
|
returnValue = self->_readback(self);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = 0;
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ static void loggerTask(void* parameters)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t seconds = RTC_GetCounter();
|
unsigned int seconds = (unsigned int)RTC_GetCounter();
|
||||||
|
|
||||||
#if defined(ENABLE_SERIAL_LOGGING)
|
#if defined(ENABLE_SERIAL_LOGGING)
|
||||||
// Formatted print
|
// Formatted print
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static ErrorStatus channelWrite(const struct DACDevice* self, uint32_t voltage);
|
static ErrorStatus channelWrite(const struct DACDevice* self, uint32_t voltage);
|
||||||
|
static uint32_t channelReadback (const struct DACDevice* self);
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function definitions
|
// Function definitions
|
||||||
@@ -166,7 +167,7 @@ ErrorStatus MAX5715Channel_construct(struct MAX5715_DAC* self, struct MAX5715* p
|
|||||||
|
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
returnValue = DACDevice_construct(&self->dacDevice, channelWrite, MAX5715_RESOLUTION_IN_BITS);
|
returnValue = DACDevice_construct(&self->dacDevice, channelWrite, channelReadback, MAX5715_RESOLUTION_IN_BITS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -187,7 +188,7 @@ ErrorStatus MAX5715Channel_construct(struct MAX5715_DAC* self, struct MAX5715* p
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ErrorStatus MAX5715Channel_setValue(const struct MAX5715_DAC* self, uint16_t value)
|
ErrorStatus MAX5715Channel_setValue(struct MAX5715_DAC* self, uint16_t value)
|
||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
@@ -195,8 +196,11 @@ ErrorStatus MAX5715Channel_setValue(const struct MAX5715_DAC* self, uint16_t val
|
|||||||
{
|
{
|
||||||
if ((self->initialized) && (self->parent->initialized))
|
if ((self->initialized) && (self->parent->initialized))
|
||||||
{
|
{
|
||||||
|
///TODO value must be verified with DAC device boarders (add limits to class)
|
||||||
|
|
||||||
|
self->value = value;
|
||||||
// Send data to CODEn register
|
// Send data to CODEn register
|
||||||
MAX5715_writeCODEn(self->parent, self->id, value);
|
MAX5715_writeCODEn(self->parent, self->id, self->value);
|
||||||
|
|
||||||
// Load CODEn register to DAC output
|
// Load CODEn register to DAC output
|
||||||
MAX5715_writeLOADn(self->parent, self->id);
|
MAX5715_writeLOADn(self->parent, self->id);
|
||||||
@@ -225,3 +229,11 @@ static ErrorStatus channelWrite(const struct DACDevice* self, uint32_t voltage)
|
|||||||
// MASK the uint32_t DAC value (voltage) with the resolution of the MAX5715 DAC
|
// MASK the uint32_t DAC value (voltage) with the resolution of the MAX5715 DAC
|
||||||
return MAX5715Channel_setValue((struct MAX5715_DAC*)self, (((1 << MAX5715_RESOLUTION_IN_BITS) - 1) & voltage));
|
return MAX5715Channel_setValue((struct MAX5715_DAC*)self, (((1 << MAX5715_RESOLUTION_IN_BITS) - 1) & voltage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint32_t channelReadback (const struct DACDevice* self)
|
||||||
|
{
|
||||||
|
struct MAX5715_DAC* tempDac = (struct MAX5715_DAC*)self;
|
||||||
|
|
||||||
|
return tempDac->value;
|
||||||
|
}
|
||||||
|
|||||||
@@ -38,10 +38,56 @@
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// File-scope variables
|
// File-scope variables
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const static uint32_t crc32_tab[] = {
|
||||||
|
0x00000001, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
|
||||||
|
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
||||||
|
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
|
||||||
|
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
||||||
|
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
||||||
|
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
|
||||||
|
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
|
||||||
|
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
||||||
|
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
|
||||||
|
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
||||||
|
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
|
||||||
|
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
||||||
|
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
|
||||||
|
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
|
||||||
|
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
||||||
|
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
||||||
|
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
|
||||||
|
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
|
||||||
|
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
|
||||||
|
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
||||||
|
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
|
||||||
|
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
|
||||||
|
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
|
||||||
|
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
||||||
|
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
||||||
|
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
|
||||||
|
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
|
||||||
|
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
||||||
|
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
|
||||||
|
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
||||||
|
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
|
||||||
|
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
||||||
|
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
|
||||||
|
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
|
||||||
|
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
||||||
|
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
||||||
|
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
|
||||||
|
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
|
||||||
|
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
|
||||||
|
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
||||||
|
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
|
||||||
|
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
||||||
|
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# Define release version for firmware here
|
# Define release version for firmware here
|
||||||
RELEASE_PRODUCT = \""S0\""
|
RELEASE_PRODUCT = \""S0\""
|
||||||
RELEASE_MAJOR = 0
|
RELEASE_MAJOR = 0
|
||||||
RELEASE_MINOR = 2
|
RELEASE_MINOR = 9
|
||||||
RELEASE_BRANCH = 0
|
RELEASE_BRANCH = 0
|
||||||
RELEASE_PATCH = 0
|
RELEASE_PATCH = 3
|
||||||
|
|
||||||
PLATFORM_OLIMEX_STM32_H107 = OLI_STM32_H107
|
PLATFORM_OLIMEX_STM32_H107 = OLI_STM32_H107
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ ROOTDIR = ../
|
|||||||
|
|
||||||
LIBRARY_NAME = libPlatform.a
|
LIBRARY_NAME = libPlatform.a
|
||||||
|
|
||||||
CCFLAGS = -c -O2 -Wall -g -fno-common -mcpu=cortex-m3 -mthumb $(PLATFORM) $(RELEASE_DEFINES) \
|
CCFLAGS = -c -O2 -Wall -Werror -g -fno-common -mcpu=cortex-m3 -mthumb $(PLATFORM) $(RELEASE_DEFINES) \
|
||||||
-Iinc \
|
-Iinc \
|
||||||
-I$(ROOTDIR)/HAL/inc \
|
-I$(ROOTDIR)/HAL/inc \
|
||||||
-I$(ROOTDIR)/hsb-mrts/inc \
|
-I$(ROOTDIR)/hsb-mrts/inc \
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ ErrorStatus Keypad_construct(struct Keypad* self, size_t numberOfRows, size_t nu
|
|||||||
LOGGER_INFO(mainLog, "Keypad task started");
|
LOGGER_INFO(mainLog, "Keypad task started");
|
||||||
self->initialized = true;
|
self->initialized = true;
|
||||||
|
|
||||||
|
// // TUBE REPAIR
|
||||||
// struct KeypadQueueItem rxQueueItem;
|
// struct KeypadQueueItem rxQueueItem;
|
||||||
// rxQueueItem.rowCoordinate = 0;
|
// rxQueueItem.rowCoordinate = 0;
|
||||||
// rxQueueItem.columnCoordinate = 0;
|
// rxQueueItem.columnCoordinate = 0;
|
||||||
@@ -137,7 +138,8 @@ ErrorStatus Keypad_construct(struct Keypad* self, size_t numberOfRows, size_t nu
|
|||||||
// rxQueueItem.keyEvent = RELEASED;
|
// rxQueueItem.keyEvent = RELEASED;
|
||||||
// // Put event in queue
|
// // Put event in queue
|
||||||
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
||||||
////
|
//
|
||||||
|
// // SELECT CATHODE
|
||||||
// rxQueueItem.rowCoordinate = 0;
|
// rxQueueItem.rowCoordinate = 0;
|
||||||
// rxQueueItem.columnCoordinate = 0;
|
// rxQueueItem.columnCoordinate = 0;
|
||||||
// rxQueueItem.keyEvent = PRESSED;
|
// rxQueueItem.keyEvent = PRESSED;
|
||||||
@@ -149,6 +151,7 @@ ErrorStatus Keypad_construct(struct Keypad* self, size_t numberOfRows, size_t nu
|
|||||||
// // Put event in queue
|
// // Put event in queue
|
||||||
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
||||||
//
|
//
|
||||||
|
// // SELECT PRESET
|
||||||
// rxQueueItem.rowCoordinate = 0;
|
// rxQueueItem.rowCoordinate = 0;
|
||||||
// rxQueueItem.columnCoordinate = 0;
|
// rxQueueItem.columnCoordinate = 0;
|
||||||
// rxQueueItem.keyEvent = PRESSED;
|
// rxQueueItem.keyEvent = PRESSED;
|
||||||
@@ -160,17 +163,19 @@ ErrorStatus Keypad_construct(struct Keypad* self, size_t numberOfRows, size_t nu
|
|||||||
// // Put event in queue
|
// // Put event in queue
|
||||||
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
||||||
//
|
//
|
||||||
// rxQueueItem.rowCoordinate = 1;
|
// // SELECT PRESET 7
|
||||||
// rxQueueItem.columnCoordinate = 2;
|
// rxQueueItem.rowCoordinate = 2;
|
||||||
|
// rxQueueItem.columnCoordinate = 0;
|
||||||
// rxQueueItem.keyEvent = PRESSED;
|
// rxQueueItem.keyEvent = PRESSED;
|
||||||
// // Put event in queue
|
// // Put event in queue
|
||||||
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
||||||
// rxQueueItem.rowCoordinate = 1;
|
// rxQueueItem.rowCoordinate = 2;
|
||||||
// rxQueueItem.columnCoordinate = 2;
|
// rxQueueItem.columnCoordinate = 0;
|
||||||
// rxQueueItem.keyEvent = RELEASED;
|
// rxQueueItem.keyEvent = RELEASED;
|
||||||
// // Put event in queue
|
// // Put event in queue
|
||||||
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
||||||
//
|
//
|
||||||
|
// // START
|
||||||
// rxQueueItem.rowCoordinate = 0;
|
// rxQueueItem.rowCoordinate = 0;
|
||||||
// rxQueueItem.columnCoordinate = 1;
|
// rxQueueItem.columnCoordinate = 1;
|
||||||
// rxQueueItem.keyEvent = PRESSED;
|
// rxQueueItem.keyEvent = PRESSED;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ ADConverter.o \
|
|||||||
ADConverters.o \
|
ADConverters.o \
|
||||||
DAConverter.o \
|
DAConverter.o \
|
||||||
DAConverters.o \
|
DAConverters.o \
|
||||||
|
DeviceParameters.o \
|
||||||
Display.o \
|
Display.o \
|
||||||
Displays.o \
|
Displays.o \
|
||||||
DisplayContent.o \
|
DisplayContent.o \
|
||||||
@@ -24,6 +25,8 @@ FreeRTOSFixes.o \
|
|||||||
hwValidationMenu.o \
|
hwValidationMenu.o \
|
||||||
MenuCore.o \
|
MenuCore.o \
|
||||||
MenuElements.o \
|
MenuElements.o \
|
||||||
|
PIDParameters.o \
|
||||||
|
PIN.o \
|
||||||
repairMenu.o \
|
repairMenu.o \
|
||||||
repairMenus.o \
|
repairMenus.o \
|
||||||
RepairPreset.o \
|
RepairPreset.o \
|
||||||
@@ -32,6 +35,8 @@ repairProcess.o \
|
|||||||
repairProcesses.o \
|
repairProcesses.o \
|
||||||
repairProcessRow.o \
|
repairProcessRow.o \
|
||||||
SignalProfileGenerator.o \
|
SignalProfileGenerator.o \
|
||||||
|
Voltage.o \
|
||||||
|
Warning.o \
|
||||||
\
|
\
|
||||||
heap_4.o\
|
heap_4.o\
|
||||||
list.o \
|
list.o \
|
||||||
@@ -71,7 +76,7 @@ OLI_STM32_H107: export OBJ_DIR := obj_release/
|
|||||||
OLI_STM32_H107: export OBJECTS := $(OBJECTS_GEN)
|
OLI_STM32_H107: export OBJECTS := $(OBJECTS_GEN)
|
||||||
OLI_STM32_H107: export OBJECTS_MAIN := $(OBJECTS_MAIN)
|
OLI_STM32_H107: export OBJECTS_MAIN := $(OBJECTS_MAIN)
|
||||||
OLI_STM32_H107: export CROSS_COMPILE := arm-none-eabi-
|
OLI_STM32_H107: export CROSS_COMPILE := arm-none-eabi-
|
||||||
OLI_STM32_H107: export CCFLAGS := -c -O2 -Wall -g -lc -lm -fno-common -mcpu=cortex-m3 -mthumb $(PLATFORM) $(RELEASE_DEFINES) $(INCLUDES)
|
OLI_STM32_H107: export CCFLAGS := -c -O2 -Wall -Werror -g -lc -lm -fno-common -mcpu=cortex-m3 -mthumb $(PLATFORM) $(RELEASE_DEFINES) $(INCLUDES)
|
||||||
OLI_STM32_H107: export ASFLAGS := -g -mapcs-32
|
OLI_STM32_H107: export ASFLAGS := -g -mapcs-32
|
||||||
OLI_STM32_H107: export LDFLAGS := -g -nostartfiles -mcpu=cortex-m3 -mthumb -T$(LINKER_SCRIPTS_DIR)/$(LINKER_SCRIPT) -Wl,-Map=hsb_mrts_OLI_STM32_H107.map
|
OLI_STM32_H107: export LDFLAGS := -g -nostartfiles -mcpu=cortex-m3 -mthumb -T$(LINKER_SCRIPTS_DIR)/$(LINKER_SCRIPT) -Wl,-Map=hsb_mrts_OLI_STM32_H107.map
|
||||||
OLI_STM32_H107: export LDARCHIVES := -L. -L$(STM32_STDPERIPH_ROOT) -L$(PLATFORM_DIR) -L$(HAL_DIR) -lhsb_mrts_OLI_STM32_H107 -lPlatform -lHAL -lSTM_StdPeriph
|
OLI_STM32_H107: export LDARCHIVES := -L. -L$(STM32_STDPERIPH_ROOT) -L$(PLATFORM_DIR) -L$(HAL_DIR) -lhsb_mrts_OLI_STM32_H107 -lPlatform -lHAL -lSTM_StdPeriph
|
||||||
|
|||||||
@@ -99,4 +99,7 @@ extern void ADConverter_destruct(struct ADConverter* self);
|
|||||||
*/
|
*/
|
||||||
extern int ADConverter_getInputVoltage(const struct ADConverter* self);
|
extern int ADConverter_getInputVoltage(const struct ADConverter* self);
|
||||||
|
|
||||||
|
|
||||||
|
extern unsigned int ADConverter_getInputConverterValue(const struct ADConverter* self);
|
||||||
|
|
||||||
#endif /* ADCONVERTER_H_ */
|
#endif /* ADCONVERTER_H_ */
|
||||||
|
|||||||
@@ -102,4 +102,18 @@ extern void DAConverter_destruct(struct DAConverter* self);
|
|||||||
extern ErrorStatus DAConverter_setOutputVoltage(const struct DAConverter* self, int voltage);
|
extern ErrorStatus DAConverter_setOutputVoltage(const struct DAConverter* self, int voltage);
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* DAConverter_getCurrentValue
|
||||||
|
* Description of function
|
||||||
|
*
|
||||||
|
* @param self
|
||||||
|
* @param
|
||||||
|
* @return uint32_t
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern uint32_t DAConverter_getCurrentValue(const struct DAConverter* self);
|
||||||
|
|
||||||
|
|
||||||
#endif /* DACONVERTER_H_ */
|
#endif /* DACONVERTER_H_ */
|
||||||
|
|||||||
@@ -108,4 +108,19 @@ extern struct PIDParameters* DeviceParameters_getPIDParameters(void);
|
|||||||
*/
|
*/
|
||||||
extern struct PIN* DeviceParameters_getPIN(void);
|
extern struct PIN* DeviceParameters_getPIN(void);
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* DeviceParameters_saveParameters
|
||||||
|
* Description of function
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern void DeviceParameters_saveParameters(void);
|
||||||
|
|
||||||
|
ErrorStatus DeviceParameters_writePIDParameters(struct PIDParameters* parameters);
|
||||||
|
ErrorStatus DeviceParameters_writePIN(struct PIN* pin);
|
||||||
|
|
||||||
#endif /* DEVICEPARAMETERS_H_ */
|
#endif /* DEVICEPARAMETERS_H_ */
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ typedef enum
|
|||||||
INTERLOCK_COMMON_FAIL,
|
INTERLOCK_COMMON_FAIL,
|
||||||
POWERENABLE_FAIL,
|
POWERENABLE_FAIL,
|
||||||
REPAIR_FAIL,
|
REPAIR_FAIL,
|
||||||
|
ERROR_CRC_PIN,
|
||||||
|
ERROR_CRC_PARAMETERS,
|
||||||
|
ERROR_CRC_PRESETS
|
||||||
} T_ErrorCode;
|
} T_ErrorCode;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ struct MenuCore
|
|||||||
struct MenuPage menuArray[RM_NUMBER_OF_MENUS];
|
struct MenuPage menuArray[RM_NUMBER_OF_MENUS];
|
||||||
struct Display* display;
|
struct Display* display;
|
||||||
struct KeyboardDevice* keyboardDevice;
|
struct KeyboardDevice* keyboardDevice;
|
||||||
char errorMessage[MENUCORE_DISPLAY_ROW_LENGTH];
|
char errorMessage[MENUCORE_DISPLAY_ROW_LENGTH + 1];
|
||||||
char warningMessage[MENUCORE_DISPLAY_ROW_LENGTH];
|
char warningMessage[MENUCORE_DISPLAY_ROW_LENGTH + 1];
|
||||||
TaskHandle_t taskHandle;
|
TaskHandle_t taskHandle;
|
||||||
int TaskPriority;
|
int TaskPriority;
|
||||||
bool runTask;
|
bool runTask;
|
||||||
@@ -109,6 +109,7 @@ struct MenuCore
|
|||||||
int cursorIndex;
|
int cursorIndex;
|
||||||
int selectionIndex;
|
int selectionIndex;
|
||||||
int scrollOffset;
|
int scrollOffset;
|
||||||
|
char insertString[MENUCORE_DISPLAY_ROW_LENGTH + 1];
|
||||||
int insertValue;
|
int insertValue;
|
||||||
uint32_t popUpCounter;
|
uint32_t popUpCounter;
|
||||||
MenuCoreFunctionCall _handleStateFunction;
|
MenuCoreFunctionCall _handleStateFunction;
|
||||||
|
|||||||
@@ -71,8 +71,10 @@ typedef enum
|
|||||||
// ADMINISTRATION MENUs
|
// ADMINISTRATION MENUs
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
RM_ADMIN_CATHODEMCP_SELECT,
|
RM_ADMIN_CATHODEMCP_SELECT,
|
||||||
|
RM_ADMINMENU_PIN_VERIFICATION,
|
||||||
RM_ADMINMENU,
|
RM_ADMINMENU,
|
||||||
RM_ADMIN_CHANGEPIN,
|
RM_ADMIN_CHANGEPIN_FIRST_INSERT,
|
||||||
|
RM_ADMIN_CHANGEPIN_SECOND_INSERT,
|
||||||
RM_ADMIN_IOCONTROL,
|
RM_ADMIN_IOCONTROL,
|
||||||
RM_ADMIN_PRESET_CONFIG_SELECT,
|
RM_ADMIN_PRESET_CONFIG_SELECT,
|
||||||
RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART,
|
RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART,
|
||||||
@@ -81,18 +83,25 @@ typedef enum
|
|||||||
RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART,
|
RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART,
|
||||||
RM_ADMIN_PRESET_CONFIG_SECOND_DURATION,
|
RM_ADMIN_PRESET_CONFIG_SECOND_DURATION,
|
||||||
RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE,
|
RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE,
|
||||||
|
RM_ADMIN_PID_CONFIG_KP,
|
||||||
|
RM_ADMIN_PID_CONFIG_KI,
|
||||||
|
RM_ADMIN_PID_CONFIG_KD,
|
||||||
RM_ADMIN_INFO,
|
RM_ADMIN_INFO,
|
||||||
|
|
||||||
RM_ADMIN_IO_INTERLOCK,
|
RM_ADMIN_IO_INTERLOCK,
|
||||||
RM_ADMIN_IO_SOLENOID,
|
RM_ADMIN_IO_SOLENOID,
|
||||||
RM_ADMIN_IO_VOLTAGE_IN,
|
RM_ADMIN_IO_VOLTAGE_IN,
|
||||||
RM_ADMIN_IO_VOLTAGE_OUT,
|
RM_ADMIN_IOCONTROL_VOLTAGE_OUT_CHANNEL1,
|
||||||
|
RM_ADMIN_IOCONTROL_VOLTAGE_OUT_CHANNEL2,
|
||||||
|
RM_ADMIN_IOCONTROL_VOLTAGE_OUT_CHANNEL3,
|
||||||
|
RM_ADMIN_IOCONTROL_VOLTAGE_OUT_CLEANUP,
|
||||||
RM_ADMIN_IO_TESLAGUN,
|
RM_ADMIN_IO_TESLAGUN,
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// CALIBRATION MENUs
|
// CALIBRATION MENUs
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
RM_CALIBRATIONMENU_PIN_VERIFICATION,
|
||||||
RM_CALIBRATIONMENU,
|
RM_CALIBRATIONMENU,
|
||||||
|
|
||||||
RM_ERROR_STATE,
|
RM_ERROR_STATE,
|
||||||
|
|||||||
@@ -126,7 +126,8 @@ static const char MenuText_ADMINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_
|
|||||||
" 1.Change Pin",
|
" 1.Change Pin",
|
||||||
" 2.I/O control",
|
" 2.I/O control",
|
||||||
" 3.Preset config",
|
" 3.Preset config",
|
||||||
" 4.Info & Version",
|
" 4.PID constants",
|
||||||
|
" 5.Info & Version",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
//FRENCH TBW
|
//FRENCH TBW
|
||||||
@@ -188,22 +189,6 @@ static const char MenuText_ADMINSOLENOIDMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUC
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Administration Get Voltage input screen
|
|
||||||
static const char MenuText_ADMINVOLTAGINMAINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] =
|
|
||||||
{
|
|
||||||
{
|
|
||||||
"Get voltage in",
|
|
||||||
" 1.Channel 1",
|
|
||||||
" 2.Channel 2",
|
|
||||||
" 3.Channel 3",
|
|
||||||
|
|
||||||
},
|
|
||||||
{
|
|
||||||
//FRENCH TBW
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Administration Get Voltage output screen
|
// Administration Get Voltage output screen
|
||||||
static const char MenuText_ADMINVOLTAGOUTMAINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] =
|
static const char MenuText_ADMINVOLTAGOUTMAINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] =
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,7 +38,11 @@
|
|||||||
|
|
||||||
struct PIDParameters
|
struct PIDParameters
|
||||||
{
|
{
|
||||||
|
int Kp; // proportional constant
|
||||||
|
int Ki; // integration constant
|
||||||
|
int Kd; // differential constant
|
||||||
|
int iMin;
|
||||||
|
int iMax;
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -51,5 +55,86 @@ struct PIDParameters
|
|||||||
// Function declarations
|
// Function declarations
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* PIDParameters_generateDefaultParameters
|
||||||
|
* Description of function
|
||||||
|
*
|
||||||
|
* @param self
|
||||||
|
* @param
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern void PIDParameters_generateDefaultParameters(struct PIDParameters* self);
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* PIDParameters_setKp
|
||||||
|
* Description of function
|
||||||
|
*
|
||||||
|
* @param self
|
||||||
|
* @param Kp
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern void PIDParameters_setKp(struct PIDParameters* self, int Kp);
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* PIDParameters_setKi
|
||||||
|
* Description of function
|
||||||
|
*
|
||||||
|
* @param self
|
||||||
|
* @param Ki
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern void PIDParameters_setKi(struct PIDParameters* self, int Ki);
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* PIDParameters_setKd
|
||||||
|
* Description of function
|
||||||
|
*
|
||||||
|
* @param self
|
||||||
|
* @param Kd
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern void PIDParameters_setKd(struct PIDParameters* self, int Kd);
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* PIDParameters_setiMin
|
||||||
|
* Description of function
|
||||||
|
*
|
||||||
|
* @param self
|
||||||
|
* @param Kp
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern void PIDParameters_setiMin(struct PIDParameters* self, int iMin);
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* PIDParameters_setiMax
|
||||||
|
* Description of function
|
||||||
|
*
|
||||||
|
* @param self
|
||||||
|
* @param Kp
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern void PIDParameters_setiMax(struct PIDParameters* self, int iMax);
|
||||||
#endif /* PIDPARAMETERS_H_ */
|
#endif /* PIDPARAMETERS_H_ */
|
||||||
|
|||||||
@@ -31,25 +31,93 @@
|
|||||||
// Include files
|
// Include files
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "stm32f10x.h"
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Constant and macro definitions
|
// Constant and macro definitions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define PIN_NUMBER_OF_DIGITS (4)
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Type definitions.
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
struct PIN
|
struct PIN
|
||||||
{
|
{
|
||||||
|
char firstDigit;
|
||||||
|
char secondDigit;
|
||||||
|
char thirdDigit;
|
||||||
|
char fourthDigit;
|
||||||
|
|
||||||
|
char pinchangeFirstInsert[5];
|
||||||
|
char pinchangeSecondInsert[5];
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Type definitions.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function declarations
|
// Function declarations
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* PIN_generateDefaultPIN
|
||||||
|
* Description of function
|
||||||
|
*
|
||||||
|
* @param self
|
||||||
|
* @param
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern void PIN_generateDefaultPIN(struct PIN* self);
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* PIN_isOK
|
||||||
|
* Description of function
|
||||||
|
*
|
||||||
|
* @param self
|
||||||
|
* @param PinToVerify
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern bool PIN_isOK(struct PIN* self, char* const pin);
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* PIN_changePinFirstInsert
|
||||||
|
* Transmits the first PIN insertion in order to change the current PIN
|
||||||
|
*
|
||||||
|
* @param self
|
||||||
|
* @param firstPinInsert
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern void PIN_changePinFirstInsert(struct PIN* self, char* const firstPinInsert);
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* PIN_changePinSecondInsert
|
||||||
|
* transmits the second PIN insertion in order to change the current PIN.
|
||||||
|
* Only accepts second insert after first insert has been called. Afterwards,
|
||||||
|
* both inserts a compared. If equal, the new PIN is registered. Otherwise an
|
||||||
|
* error message is generated
|
||||||
|
*
|
||||||
|
* @param self
|
||||||
|
* @param firstPinInsert
|
||||||
|
* @return ErrorStatus SUCCESS if both PIN inserts are equal
|
||||||
|
* ERROR otherwise
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern ErrorStatus PIN_changePinSecondInsert(struct PIN* self, char* const secondPinInsert);
|
||||||
|
|
||||||
#endif /* PIN_H_ */
|
#endif /* PIN_H_ */
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ struct SignalProfileGenerator
|
|||||||
uint32_t startTime;
|
uint32_t startTime;
|
||||||
uint32_t softStartTimer;
|
uint32_t softStartTimer;
|
||||||
uint32_t voltageHoldTimer;
|
uint32_t voltageHoldTimer;
|
||||||
|
uint32_t totalStartTime;
|
||||||
|
uint32_t totalRunTime;
|
||||||
|
|
||||||
int pauseStartVoltage;
|
int pauseStartVoltage;
|
||||||
uint32_t pauseStartTime;
|
uint32_t pauseStartTime;
|
||||||
@@ -103,8 +105,14 @@ extern void SignalProfileGenerator_pause(struct SignalProfileGenerator* self);
|
|||||||
extern bool SignalProfileGenerator_isPaused(struct SignalProfileGenerator* self);
|
extern bool SignalProfileGenerator_isPaused(struct SignalProfileGenerator* self);
|
||||||
|
|
||||||
|
|
||||||
|
extern bool SignalProfileGenerator_isFinished(struct SignalProfileGenerator* self);
|
||||||
|
|
||||||
|
|
||||||
extern void SignalProfileGenerator_continue(struct SignalProfileGenerator* self);
|
extern void SignalProfileGenerator_continue(struct SignalProfileGenerator* self);
|
||||||
|
|
||||||
|
|
||||||
extern uint32_t SignalProfileGenerator_getRemainingTime(const struct SignalProfileGenerator* self);
|
extern uint32_t SignalProfileGenerator_getRemainingTime(const struct SignalProfileGenerator* self);
|
||||||
|
|
||||||
|
|
||||||
|
extern uint32_t SignalProfileGenerator_getTotalRepairTime(const struct SignalProfileGenerator* self);
|
||||||
#endif /* INC_SIGNALPROFILEGENERATOR_H_ */
|
#endif /* INC_SIGNALPROFILEGENERATOR_H_ */
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
/// @file Voltage.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 Voltage.h
|
||||||
|
/// @ingroup {group_name}
|
||||||
|
|
||||||
|
#ifndef VOLTAGE_H_
|
||||||
|
#define VOLTAGE_H_
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Include files
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "stm32f10x.h"
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Constant and macro definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Type definitions.
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Function declarations
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
extern int Voltage_calculateVoltage(uint32_t value, uint32_t resolutionInBits, int minVoltage, int maxVoltage);
|
||||||
|
|
||||||
|
|
||||||
|
extern uint32_t Voltage_calculateDeviceValue(int value, uint32_t resolutionInBits, int minVoltage, int maxVoltage);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* VOLTAGE_H_ */
|
||||||
@@ -31,22 +31,81 @@
|
|||||||
// Include files
|
// Include files
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "stm32f10x.h"
|
||||||
|
|
||||||
|
#include "Observable.h"
|
||||||
|
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Constant and macro definitions
|
// Constant and macro definitions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Type definitions.
|
// Type definitions.
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
WARNING_INTERLOCK_COMMON_FAIL,
|
||||||
|
} T_WarningCode;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function declarations
|
// Function declarations
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* Warning_construct
|
||||||
|
* Constructs the Warning handler
|
||||||
|
*
|
||||||
|
* @return ErrorStatus SUCCESS if construction was successful
|
||||||
|
* ERROR otherwise
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern ErrorStatus Warning_construct(void);
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* Warning_getObservable
|
||||||
|
* Returns the observable of the Warning handler
|
||||||
|
*
|
||||||
|
* @return struct Observable* Observable of the Warning handler
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern struct Observable* Warning_getObservable(void);
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* Warning_postWarning
|
||||||
|
* Posts a new Warning
|
||||||
|
*
|
||||||
|
* @param warningCode Warning CODE
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern void Warning_postWarning(T_WarningCode warningCode);
|
||||||
|
|
||||||
|
|
||||||
|
/** ----------------------------------------------------------------------------
|
||||||
|
* Warning_postWarningFromISR
|
||||||
|
* Posts a new Warning from an ISR context
|
||||||
|
*
|
||||||
|
* @param warningCode Warning CODE
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
extern void Warning_postWarningFromISR(T_WarningCode warningCode);
|
||||||
|
|
||||||
#endif /* WARNING_H_ */
|
#endif /* WARNING_H_ */
|
||||||
|
|||||||
@@ -123,8 +123,10 @@ extern struct Display* const mainDisplay;
|
|||||||
*/
|
*/
|
||||||
extern ErrorStatus hsb_generateStartScreen(struct Display* Display);
|
extern ErrorStatus hsb_generateStartScreen(struct Display* Display);
|
||||||
|
|
||||||
|
extern ErrorStatus hsb_enableSafetyWithError(void);
|
||||||
|
|
||||||
|
extern ErrorStatus hsb_enableSafetyWithWarning(void);
|
||||||
|
|
||||||
extern ErrorStatus hsb_enableSafety(void);
|
|
||||||
extern ErrorStatus hsb_disableSafety(void);
|
extern ErrorStatus hsb_disableSafety(void);
|
||||||
|
extern bool hsb_safetyIsEnabled(void);
|
||||||
#endif /* HSB_MRTS_H_ */
|
#endif /* HSB_MRTS_H_ */
|
||||||
|
|||||||
@@ -38,6 +38,8 @@
|
|||||||
#include "semphr.h"
|
#include "semphr.h"
|
||||||
|
|
||||||
#include "stm32f10x.h"
|
#include "stm32f10x.h"
|
||||||
|
|
||||||
|
#include "Error.h"
|
||||||
#include "MenuCore.h"
|
#include "MenuCore.h"
|
||||||
#include "RepairPreset.h"
|
#include "RepairPreset.h"
|
||||||
#include "repairProcess.h"
|
#include "repairProcess.h"
|
||||||
@@ -142,6 +144,9 @@ extern void repairMenu_feedSecondsCounter(struct RepairMenu* self);
|
|||||||
extern void repairMenu_feedSecondsCounterFromISR(struct RepairMenu* self);
|
extern void repairMenu_feedSecondsCounterFromISR(struct RepairMenu* self);
|
||||||
|
|
||||||
|
|
||||||
|
extern void repairMenu_interlockWarning(struct RepairMenu* self, T_INTERLOCK_ID interlockID);
|
||||||
|
|
||||||
|
|
||||||
/** ----------------------------------------------------------------------------
|
/** ----------------------------------------------------------------------------
|
||||||
* repairMenu_interlockFailed
|
* repairMenu_interlockFailed
|
||||||
* Interlock verification failed
|
* Interlock verification failed
|
||||||
@@ -161,6 +166,9 @@ extern void repairMenu_interlockFailed(struct RepairMenu* self, T_INTERLOCK_ID i
|
|||||||
extern void repairMenu_processFailed(struct RepairMenu* self);
|
extern void repairMenu_processFailed(struct RepairMenu* self);
|
||||||
|
|
||||||
|
|
||||||
|
extern void repairMenu_printCRCFailure(struct RepairMenu* self, T_ErrorCode errorCode);
|
||||||
|
|
||||||
|
|
||||||
extern void repairMenu_menuStateHandle(struct MenuCore* menuCore);
|
extern void repairMenu_menuStateHandle(struct MenuCore* menuCore);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -175,6 +175,9 @@ extern bool repairProcess_isProcessRunning(struct RepairProcess* self);
|
|||||||
extern uint32_t repairProcess_getRemainingRepairTime(const struct RepairProcess* self);
|
extern uint32_t repairProcess_getRemainingRepairTime(const struct RepairProcess* self);
|
||||||
|
|
||||||
|
|
||||||
|
extern uint32_t repairProcess_getTotalRepairtime(const struct RepairProcess* self);
|
||||||
|
|
||||||
|
|
||||||
/** ----------------------------------------------------------------------------
|
/** ----------------------------------------------------------------------------
|
||||||
* repairProcess_getRowInformation
|
* repairProcess_getRowInformation
|
||||||
* Returns the current active repair time in seconds.
|
* Returns the current active repair time in seconds.
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "ADConverter.h"
|
#include "ADConverter.h"
|
||||||
|
#include "Voltage.h"
|
||||||
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@
|
|||||||
// Function declarations
|
// Function declarations
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int calculateVoltage(const struct ADConverter* self, uint32_t adcValue);
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function definitions
|
// Function definitions
|
||||||
@@ -90,53 +91,20 @@ int ADConverter_getInputVoltage(const struct ADConverter* self)
|
|||||||
uint32_t adcValue;
|
uint32_t adcValue;
|
||||||
adcValue = ADCDevice_read(self->adcDevice);
|
adcValue = ADCDevice_read(self->adcDevice);
|
||||||
|
|
||||||
returnValue = calculateVoltage(self, adcValue);
|
returnValue = Voltage_calculateVoltage(adcValue, self->adcDevice->resolutionInBits, self->minVoltage, self->maxVoltage);
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int calculateVoltage(const struct ADConverter* self, uint32_t adcValue)
|
unsigned int ADConverter_getInputConverterValue(const struct ADConverter* self)
|
||||||
{
|
{
|
||||||
int returnValue = 0;
|
unsigned int returnValue = 0;
|
||||||
|
|
||||||
if (self->initialized)
|
if (self->initialized)
|
||||||
{
|
{
|
||||||
int maxAdcValue = ((1 << self->adcDevice->resolutionInBits) - 1);
|
returnValue = ADCDevice_read(self->adcDevice);
|
||||||
|
|
||||||
returnValue = (int)adcValue * (self->maxVoltage - self->minVoltage);
|
|
||||||
returnValue = returnValue / maxAdcValue;
|
|
||||||
returnValue = returnValue + self->minVoltage;
|
|
||||||
|
|
||||||
// Differ between an positive and negative scale
|
|
||||||
if (self->maxVoltage > self->minVoltage)
|
|
||||||
{
|
|
||||||
// Common scale with a higher maximum value than the minimum value
|
|
||||||
if (returnValue < self->minVoltage)
|
|
||||||
{
|
|
||||||
returnValue = self->minVoltage;
|
|
||||||
}
|
|
||||||
else if (returnValue > self->maxVoltage)
|
|
||||||
{
|
|
||||||
returnValue = self->maxVoltage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Negative scale where the ADC value (positive) must be translated in a negative voltage
|
|
||||||
if (returnValue > self->minVoltage)
|
|
||||||
{
|
|
||||||
returnValue = self->minVoltage;
|
|
||||||
}
|
|
||||||
else if (returnValue < self->maxVoltage)
|
|
||||||
{
|
|
||||||
returnValue = self->maxVoltage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
returnValue = 0;
|
|
||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,8 @@
|
|||||||
// Include files
|
// Include files
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "DAConverter.h"
|
#include "DAConverter.h"
|
||||||
|
#include "Voltage.h"
|
||||||
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
|
||||||
@@ -52,8 +51,6 @@
|
|||||||
// Function declarations
|
// Function declarations
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static uint32_t calculateDACValue(const struct DAConverter* self, int voltage);
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function definitions
|
// Function definitions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -83,7 +80,7 @@ void DAConverter_destruct(struct DAConverter* self)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern ErrorStatus DAConverter_setOutputVoltage(const struct DAConverter* self, int voltage)
|
ErrorStatus DAConverter_setOutputVoltage(const struct DAConverter* self, int voltage)
|
||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
@@ -91,7 +88,7 @@ extern ErrorStatus DAConverter_setOutputVoltage(const struct DAConverter* self,
|
|||||||
if (self->initialized)
|
if (self->initialized)
|
||||||
{
|
{
|
||||||
uint32_t dacValue;
|
uint32_t dacValue;
|
||||||
dacValue = calculateDACValue(self, voltage);
|
dacValue = Voltage_calculateDeviceValue(voltage, self->dacDevice->resolutionInBits, self->minVoltage, self->maxVoltage);
|
||||||
DACDevice_write(self->dacDevice, dacValue);
|
DACDevice_write(self->dacDevice, dacValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,23 +100,15 @@ extern ErrorStatus DAConverter_setOutputVoltage(const struct DAConverter* self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uint32_t calculateDACValue(const struct DAConverter* self, int voltage)
|
uint32_t DAConverter_getCurrentValue(const struct DAConverter* self)
|
||||||
{
|
{
|
||||||
uint32_t dacValue;
|
uint32_t returnValue = 0;
|
||||||
if (self->initialized)
|
if (self->initialized)
|
||||||
{
|
{
|
||||||
int maxDacValue = ((1 << self->dacDevice->resolutionInBits) - 1);
|
returnValue = Voltage_calculateVoltage(DACDevice_getCurrentValue(self->dacDevice), self->dacDevice->resolutionInBits, self->minVoltage, self->maxVoltage);
|
||||||
int tempValue = (voltage - self->minVoltage) * maxDacValue;
|
|
||||||
tempValue /= (self->maxVoltage - self->minVoltage);
|
|
||||||
dacValue = abs(tempValue);
|
|
||||||
if (dacValue > maxDacValue)
|
|
||||||
{
|
|
||||||
dacValue = maxDacValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
return returnValue;
|
||||||
{
|
|
||||||
dacValue = 0;
|
|
||||||
}
|
|
||||||
return dacValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,17 @@
|
|||||||
|
|
||||||
#include "DeviceParameters.h"
|
#include "DeviceParameters.h"
|
||||||
|
|
||||||
|
#include "hsb-mrts.h"
|
||||||
|
#include "Error.h"
|
||||||
|
#include "PIDParameters.h"
|
||||||
|
#include "PIN.h"
|
||||||
|
|
||||||
|
#include "CachedStorage.h"
|
||||||
|
#include "crc32.h"
|
||||||
|
#include "Logger.h"
|
||||||
|
#include "MemoryDevice.h"
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Constant and macro definitions
|
// Constant and macro definitions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -42,6 +53,8 @@ struct DeviceParameters
|
|||||||
bool initialized;
|
bool initialized;
|
||||||
struct CachedStorage* parametersStorage;
|
struct CachedStorage* parametersStorage;
|
||||||
struct MemoryDevice* memoryDevice;
|
struct MemoryDevice* memoryDevice;
|
||||||
|
unsigned int PIDParametersOffset;
|
||||||
|
unsigned int PINOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PIDParametersStorageClass
|
struct PIDParametersStorageClass
|
||||||
@@ -60,14 +73,14 @@ struct PINStorageClass
|
|||||||
// File-scope variables
|
// File-scope variables
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static struct DeviceParameters _self = {.initialized = false};
|
static struct DeviceParameters _dParam = {.initialized = false};
|
||||||
struct DeviceParameters* const self = &_self;
|
struct DeviceParameters* const dParam = &_dParam;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function declarations
|
// Function declarations
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void DeviceParameters_verifyCRCs(void);
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function definitions
|
// Function definitions
|
||||||
@@ -76,13 +89,14 @@ struct DeviceParameters* const self = &_self;
|
|||||||
ErrorStatus DeviceParameters_construct(struct CachedStorage* parametersStorage, struct MemoryDevice* memoryDevice)
|
ErrorStatus DeviceParameters_construct(struct CachedStorage* parametersStorage, struct MemoryDevice* memoryDevice)
|
||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
if (!self->initialized)
|
|
||||||
|
if (!dParam->initialized)
|
||||||
{
|
{
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
if (parametersStorage != NULL)
|
if (parametersStorage != NULL)
|
||||||
{
|
{
|
||||||
self->parametersStorage = parametersStorage;
|
dParam->parametersStorage = parametersStorage;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -96,7 +110,7 @@ ErrorStatus DeviceParameters_construct(struct CachedStorage* parametersStorage,
|
|||||||
{
|
{
|
||||||
if (memoryDevice->initialized)
|
if (memoryDevice->initialized)
|
||||||
{
|
{
|
||||||
self->memoryDevice = memoryDevice;
|
dParam->memoryDevice = memoryDevice;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -108,7 +122,95 @@ ErrorStatus DeviceParameters_construct(struct CachedStorage* parametersStorage,
|
|||||||
returnValue = ERROR;
|
returnValue = ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self->initialized = true;
|
|
||||||
|
if (returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
// Create new cachedStorage with preset page number
|
||||||
|
returnValue = CachedStorage_construct(dParam->parametersStorage, dParam->memoryDevice, APP_FLASH_PARAMETERS_PAGE, (sizeof(struct PIDParametersStorageClass) + sizeof(struct PINStorageClass)) / 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
dParam->PIDParametersOffset = 0;
|
||||||
|
dParam->PINOffset = sizeof(struct PIDParametersStorageClass) / 4;
|
||||||
|
dParam->initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the CRC on the loaded parameters
|
||||||
|
// If a CRC fails, corrupted data will automatically be replaced with defaults
|
||||||
|
if (returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
DeviceParameters_verifyCRCs();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DeviceParameters_destruct(void)
|
||||||
|
{
|
||||||
|
if (dParam->initialized)
|
||||||
|
{
|
||||||
|
CachedStorage_destruct(dParam->parametersStorage);
|
||||||
|
dParam->parametersStorage = NULL;
|
||||||
|
dParam->memoryDevice = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct PIDParameters* DeviceParameters_getPIDParameters(void)
|
||||||
|
{
|
||||||
|
struct PIDParameters* returnValue = NULL;
|
||||||
|
if (dParam->initialized)
|
||||||
|
{
|
||||||
|
struct PIDParametersStorageClass* tempValue;
|
||||||
|
tempValue = (struct PIDParametersStorageClass*)CachedStorage_readBlob(dParam->parametersStorage, dParam->PIDParametersOffset);
|
||||||
|
returnValue = &tempValue->pidParameters;
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct PIN* DeviceParameters_getPIN(void)
|
||||||
|
{
|
||||||
|
struct PIN* returnValue = NULL;
|
||||||
|
if (dParam->initialized)
|
||||||
|
{
|
||||||
|
struct PINStorageClass* tempValue;
|
||||||
|
tempValue = (struct PINStorageClass*)CachedStorage_readBlob(dParam->parametersStorage, dParam->PINOffset);
|
||||||
|
returnValue = &tempValue->pin;
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DeviceParameters_saveParameters(void)
|
||||||
|
{
|
||||||
|
if (dParam->initialized)
|
||||||
|
{
|
||||||
|
// Commit cache to memory - will not write if no changes have been made
|
||||||
|
CachedStorage_commit(dParam->parametersStorage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ErrorStatus DeviceParameters_writePIDParameters(struct PIDParameters* parameters)
|
||||||
|
{
|
||||||
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
if (dParam->initialized)
|
||||||
|
{
|
||||||
|
struct PIDParametersStorageClass tempPIDStorage;
|
||||||
|
tempPIDStorage.pidParameters = *parameters;
|
||||||
|
// Calculate CRC over preset
|
||||||
|
tempPIDStorage.crc = crc32_calculate(0, &tempPIDStorage.pidParameters, sizeof(struct PIDParameters));
|
||||||
|
// Put default preset on Cache
|
||||||
|
CachedStorage_writeBlob(dParam->parametersStorage, dParam->PIDParametersOffset, &tempPIDStorage, sizeof(struct PIDParametersStorageClass) / 4);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -118,19 +220,70 @@ ErrorStatus DeviceParameters_construct(struct CachedStorage* parametersStorage,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DeviceParameters_destruct(void)
|
ErrorStatus DeviceParameters_writePIN(struct PIN* pin)
|
||||||
{
|
{
|
||||||
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
if (dParam->initialized)
|
||||||
|
{
|
||||||
|
struct PINStorageClass tempPINStorage;
|
||||||
|
tempPINStorage.pin = *pin;
|
||||||
|
// Calculate CRC over preset
|
||||||
|
tempPINStorage.crc = crc32_calculate(0, &tempPINStorage.pin, sizeof(struct PIN));
|
||||||
|
// Put default preset on Cache
|
||||||
|
CachedStorage_writeBlob(dParam->parametersStorage, dParam->PINOffset, &tempPINStorage, sizeof(struct PINStorageClass) / 4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = ERROR;
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct PIDParameters* DeviceParameters_getPIDParameters(void)
|
static void DeviceParameters_verifyCRCs(void)
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct PIN* DeviceParameters_getPIN(void)
|
|
||||||
{
|
{
|
||||||
|
uint32_t tempCRC;
|
||||||
|
if (dParam->initialized)
|
||||||
|
{
|
||||||
|
// PID PARAMETERS CHECK
|
||||||
|
struct PIDParametersStorageClass _tempPIDParameters;
|
||||||
|
struct PIDParametersStorageClass* tempPIDParameters = &_tempPIDParameters;
|
||||||
|
tempPIDParameters = (struct PIDParametersStorageClass*)CachedStorage_readBlob(dParam->parametersStorage, dParam->PIDParametersOffset);
|
||||||
|
|
||||||
|
// Calculate the CRC of the parameters
|
||||||
|
tempCRC = crc32_calculate(0, &tempPIDParameters->pidParameters, sizeof(struct PIDParameters));
|
||||||
|
// Compare CRC
|
||||||
|
if (tempCRC != tempPIDParameters->crc)
|
||||||
|
{
|
||||||
|
Error_postError(ERROR_CRC_PARAMETERS);
|
||||||
|
// CRC do not match
|
||||||
|
LOGGER_ERROR(mainLog, "CRC ERROR at Device Parameters (calculated %X but loaded %X)", (unsigned int)tempCRC, (unsigned int)tempPIDParameters->crc);
|
||||||
|
// Replace corrupt Device parameters with defaults
|
||||||
|
PIDParameters_generateDefaultParameters(&tempPIDParameters->pidParameters);
|
||||||
|
// Write parameters to cache including the CRC (calculated inside write function)
|
||||||
|
DeviceParameters_writePIDParameters(&tempPIDParameters->pidParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// PIN CHECK
|
||||||
|
struct PINStorageClass _tempPIN;
|
||||||
|
struct PINStorageClass* tempPIN = &_tempPIN;
|
||||||
|
tempPIN = (struct PINStorageClass*)CachedStorage_readBlob(dParam->parametersStorage, dParam->PINOffset);
|
||||||
|
|
||||||
|
// Calculate the CRC of the PIN
|
||||||
|
// Calculate the CRC of the parameters
|
||||||
|
tempCRC = crc32_calculate(0, &tempPIN->pin, sizeof(struct PIN));
|
||||||
|
// Compare CRC
|
||||||
|
if (tempCRC != tempPIN->crc)
|
||||||
|
{
|
||||||
|
Error_postError(ERROR_CRC_PIN);
|
||||||
|
// CRC do not match
|
||||||
|
LOGGER_ERROR(mainLog, "CRC ERROR at Device PIN (calculated %X but loaded %X)", (unsigned int)tempCRC, (unsigned int)tempPIN->crc);
|
||||||
|
// Replace corrupt Device parameters with defaults
|
||||||
|
PIN_generateDefaultPIN(&tempPIN->pin);
|
||||||
|
// Write parameters to cache including the CRC (calculated inside write function)
|
||||||
|
DeviceParameters_writePIN(&tempPIN->pin);
|
||||||
|
}
|
||||||
|
DeviceParameters_saveParameters();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,3 +117,5 @@ static ErrorStatus Displays_mainDisplayObserverFromISR(const void* const data)
|
|||||||
Display_feedRefreshCounterFromISR(mainDisplay);
|
Display_feedRefreshCounterFromISR(mainDisplay);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
// Include files
|
// Include files
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "MenuCore.h"
|
#include "MenuCore.h"
|
||||||
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
@@ -117,6 +119,7 @@ ErrorStatus MenuCore_construct(struct MenuCore* self, struct Display* display, s
|
|||||||
self->scrollOffset = 0;
|
self->scrollOffset = 0;
|
||||||
self->cursorIndex = 1;
|
self->cursorIndex = 1;
|
||||||
self->menuState = 0;
|
self->menuState = 0;
|
||||||
|
self->insertString[0] = '\0';
|
||||||
// Menu core is initialised - Menu core is good to go
|
// Menu core is initialised - Menu core is good to go
|
||||||
self->initialized = true;
|
self->initialized = true;
|
||||||
}
|
}
|
||||||
@@ -154,7 +157,10 @@ static void MenuCore_task(void* parameters)
|
|||||||
Keypad_KeyState keyState;
|
Keypad_KeyState keyState;
|
||||||
|
|
||||||
// Take care of potential actions that must be taken prior to reading the keyboard/input
|
// Take care of potential actions that must be taken prior to reading the keyboard/input
|
||||||
self->_handleStateFunction(self);
|
if (self->_handleStateFunction != NULL)
|
||||||
|
{
|
||||||
|
self->_handleStateFunction(self);
|
||||||
|
}
|
||||||
|
|
||||||
if (KeyboardDevice_read(self->keyboardDevice, &key, &keyState) == SUCCESS)
|
if (KeyboardDevice_read(self->keyboardDevice, &key, &keyState) == SUCCESS)
|
||||||
{
|
{
|
||||||
@@ -162,7 +168,7 @@ static void MenuCore_task(void* parameters)
|
|||||||
{
|
{
|
||||||
// The key had an action
|
// The key had an action
|
||||||
// Clear the screen for a new menu
|
// Clear the screen for a new menu
|
||||||
Display_clearScreen(self->display);
|
// Display_clearScreen(self->display);
|
||||||
// Print menu content to output device
|
// Print menu content to output device
|
||||||
MenuCore_printMenu(self);
|
MenuCore_printMenu(self);
|
||||||
// Add cursor if necessary
|
// Add cursor if necessary
|
||||||
@@ -200,6 +206,7 @@ static void MenuCore_printMenu(struct MenuCore* self)
|
|||||||
|
|
||||||
for (loopCounter = 1 ; loopCounter < self->display->displayDevice->parameters.numberOfRows; loopCounter++)
|
for (loopCounter = 1 ; loopCounter < self->display->displayDevice->parameters.numberOfRows; loopCounter++)
|
||||||
{
|
{
|
||||||
|
Display_clearLine(self->display, loopCounter + 1);
|
||||||
Display_write(self->display, self->menuArray[self->menuState].row[loopCounter + self->scrollOffset].text, loopCounter + 1, 1);
|
Display_write(self->display, self->menuArray[self->menuState].row[loopCounter + self->scrollOffset].text, loopCounter + 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,46 +291,26 @@ static ErrorStatus MenuCore_performAction(struct MenuCore* self, char key, Keypa
|
|||||||
}
|
}
|
||||||
case DIGIT_INSERT:
|
case DIGIT_INSERT:
|
||||||
{
|
{
|
||||||
LOGGER_INFO(mainLog, "Key is allowed as insert");
|
int numberOfDigits = strlen(self->insertString);
|
||||||
|
|
||||||
// Determine the number of digits currently used
|
|
||||||
int divider = self->insertValue;
|
|
||||||
int numberOfDigits = 0;
|
|
||||||
while (divider != 0)
|
|
||||||
{
|
|
||||||
divider /= 10;
|
|
||||||
numberOfDigits++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The Argument carries the max number of digits for the current insertion value
|
// The Argument carries the max number of digits for the current insertion value
|
||||||
if (numberOfDigits < keyAction.argument)
|
if (numberOfDigits < keyAction.argument)
|
||||||
{
|
{
|
||||||
// Verify that only digits 0-9 are taken into account
|
// Attach latest character to string
|
||||||
// Copare with decimal ASCII
|
strncat(self->insertString, &keyAction.key, 1);
|
||||||
if ((keyAction.key > 47) && (keyAction.key < 58))
|
|
||||||
{
|
|
||||||
// Shift the already inserted value to the left
|
|
||||||
self->insertValue = self->insertValue * 10;
|
|
||||||
// Add the latest value
|
|
||||||
self->insertValue = self->insertValue + (keyAction.key - 48);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
LOGGER_INFO(mainLog, "Inserted Value is: %d", self->insertValue);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case DIGIT_REMOVE:
|
case DIGIT_REMOVE:
|
||||||
{
|
{
|
||||||
LOGGER_INFO(mainLog, "Key is allowed as remove");
|
|
||||||
// Shift the already inserted value to the right
|
// Shift the already inserted value to the right
|
||||||
self->insertValue = self->insertValue / 10;
|
int numberOfDigits = strlen(self->insertString);
|
||||||
LOGGER_INFO(mainLog, "Inserted Value is: %d", self->insertValue);
|
self->insertString[numberOfDigits - 1] = '\0';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case DIGIT_INSERT_CONFIRM:
|
case DIGIT_INSERT_CONFIRM:
|
||||||
{
|
{
|
||||||
LOGGER_INFO(mainLog, "Digit insert confirmed");
|
|
||||||
if (keyAction.actionPointer != NULL)
|
if (keyAction.actionPointer != NULL)
|
||||||
{
|
{
|
||||||
keyAction.actionPointer(self);
|
keyAction.actionPointer(self);
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
/// @file PIDParameters.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 PIDParameters.c
|
||||||
|
/// @ingroup {group_name}
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Include files
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "PIDParameters.h"
|
||||||
|
|
||||||
|
#include "PCBA.h"
|
||||||
|
#include "PID.h"
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Constant and macro definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Type definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// File-scope variables
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Function declarations
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Function definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void PIDParameters_generateDefaultParameters(struct PIDParameters* self)
|
||||||
|
{
|
||||||
|
// Differ between positive and negative regulation
|
||||||
|
if (PCBA_getInstance()->pcba == PCBA_CathodeMCP)
|
||||||
|
{
|
||||||
|
// Negative regulation
|
||||||
|
self->iMin = -100000000;
|
||||||
|
self->iMax = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// positive regulation
|
||||||
|
self->iMin = 0;
|
||||||
|
self->iMax = 100000000;
|
||||||
|
}
|
||||||
|
self->Kp = 3 * PID_FIXED_POINT_FACTOR / 10;
|
||||||
|
self->Ki = 2 * PID_FIXED_POINT_FACTOR / 10;
|
||||||
|
self->Kd = 0 * PID_FIXED_POINT_FACTOR / 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIDParameters_setKp(struct PIDParameters* self, int Kp)
|
||||||
|
{
|
||||||
|
self->Kp = Kp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIDParameters_setKi(struct PIDParameters* self, int Ki)
|
||||||
|
{
|
||||||
|
self->Ki = Ki;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIDParameters_setKd(struct PIDParameters* self, int Kd)
|
||||||
|
{
|
||||||
|
self->Kd = Kd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIDParameters_setiMin(struct PIDParameters* self, int iMin)
|
||||||
|
{
|
||||||
|
self->iMin = iMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIDParameters_setiMax(struct PIDParameters* self, int iMax)
|
||||||
|
{
|
||||||
|
self->iMax = iMax;
|
||||||
|
}
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
/// @file PIN.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 PIN.c
|
||||||
|
/// @ingroup {group_name}
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Include files
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "PIN.h"
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Constant and macro definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Type definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// File-scope variables
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Function declarations
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static ErrorStatus PIN_verifyInsertedPins(struct PIN* self);
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Function definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
void PIN_generateDefaultPIN(struct PIN* self)
|
||||||
|
{
|
||||||
|
self->firstDigit = 0;
|
||||||
|
self->secondDigit = 1;
|
||||||
|
self->thirdDigit = 2;
|
||||||
|
self->fourthDigit = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PIN_isOK(struct PIN* self, char* const pin)
|
||||||
|
{
|
||||||
|
bool returnValue = false;
|
||||||
|
|
||||||
|
if (pin[0] == self->firstDigit)
|
||||||
|
{
|
||||||
|
if (pin[1] == self->secondDigit)
|
||||||
|
{
|
||||||
|
if (pin[2] == self->thirdDigit)
|
||||||
|
{
|
||||||
|
if (pin[3] == self->fourthDigit)
|
||||||
|
{
|
||||||
|
returnValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIN_changePinFirstInsert(struct PIN* self, char* const firstPinInsert)
|
||||||
|
{
|
||||||
|
int loopCounter;
|
||||||
|
if (firstPinInsert != NULL)
|
||||||
|
{
|
||||||
|
for (loopCounter = 0; loopCounter < PIN_NUMBER_OF_DIGITS; loopCounter++)
|
||||||
|
{
|
||||||
|
self->pinchangeFirstInsert[loopCounter] = firstPinInsert[loopCounter];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ErrorStatus PIN_changePinSecondInsert(struct PIN* self, char* const secondPinInsert)
|
||||||
|
{
|
||||||
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
|
int loopCounter;
|
||||||
|
if (secondPinInsert != NULL)
|
||||||
|
{
|
||||||
|
for (loopCounter = 0; loopCounter < PIN_NUMBER_OF_DIGITS; loopCounter++)
|
||||||
|
{
|
||||||
|
self->pinchangeSecondInsert[loopCounter] = secondPinInsert[loopCounter];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
returnValue = PIN_verifyInsertedPins(self);
|
||||||
|
// Verify both PINs
|
||||||
|
if (returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
self->firstDigit = self->pinchangeFirstInsert[0];
|
||||||
|
self->secondDigit = self->pinchangeFirstInsert[1];
|
||||||
|
self->thirdDigit = self->pinchangeFirstInsert[2];
|
||||||
|
self->fourthDigit = self->pinchangeFirstInsert[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ErrorStatus PIN_verifyInsertedPins(struct PIN* self)
|
||||||
|
{
|
||||||
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
|
if(memcmp(self->pinchangeFirstInsert, self->pinchangeSecondInsert, PIN_NUMBER_OF_DIGITS != 0))
|
||||||
|
{
|
||||||
|
// Inserted PINs are not equal
|
||||||
|
returnValue = ERROR;
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
@@ -61,7 +61,15 @@ ErrorStatus RepairPreset_generateDefaultPreset(struct RepairPreset* self, unsign
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
self->numberOfStages = 2;
|
// TELSA PCBA does not need multiple stages
|
||||||
|
if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||||
|
{
|
||||||
|
self->numberOfStages = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self->numberOfStages = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self->presetNumber = presetNumber;
|
self->presetNumber = presetNumber;
|
||||||
self->preset[0].softstartDuration = 1800;
|
self->preset[0].softstartDuration = 1800;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "hsb-mrts.h"
|
#include "hsb-mrts.h"
|
||||||
|
#include "Error.h"
|
||||||
#include "RepairPresets.h"
|
#include "RepairPresets.h"
|
||||||
|
|
||||||
#include "CachedStorage.h"
|
#include "CachedStorage.h"
|
||||||
@@ -72,7 +73,7 @@ struct RepairPresets* const self = &_self;
|
|||||||
// Function declarations
|
// Function declarations
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static ErrorStatus RepairPresets_verifyCRCs(void);
|
static void RepairPresets_verifyCRCs(void);
|
||||||
static ErrorStatus RepairPresets_verifyPresetCRC(struct RepairPresetStorageClass* repairPreset);
|
static ErrorStatus RepairPresets_verifyPresetCRC(struct RepairPresetStorageClass* repairPreset);
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -193,7 +194,7 @@ ErrorStatus RepairPresets_loadPresets(REPAIR_PRESETS_ID presetID)
|
|||||||
// Check the CRC on the loaded presets
|
// Check the CRC on the loaded presets
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
returnValue = RepairPresets_verifyCRCs();
|
RepairPresets_verifyCRCs();
|
||||||
}
|
}
|
||||||
|
|
||||||
// CRCs are verified
|
// CRCs are verified
|
||||||
@@ -225,7 +226,7 @@ struct RepairPreset* RepairPresets_getPreset(unsigned int index)
|
|||||||
if ((index > 0) || (index <= REPAIR_PRESETS_NUMBER_OF_PRESETS))
|
if ((index > 0) || (index <= REPAIR_PRESETS_NUMBER_OF_PRESETS))
|
||||||
{
|
{
|
||||||
struct RepairPresetStorageClass* tempPreset;
|
struct RepairPresetStorageClass* tempPreset;
|
||||||
tempPreset = CachedStorage_readBlob(self->presetStorage, (index - 1) * sizeof(struct RepairPresetStorageClass) / 4);
|
tempPreset = (struct RepairPresetStorageClass*)CachedStorage_readBlob(self->presetStorage, (index - 1) * sizeof(struct RepairPresetStorageClass) / 4);
|
||||||
returnValue = (struct RepairPreset*)&tempPreset->preset;
|
returnValue = (struct RepairPreset*)&tempPreset->preset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,7 +242,7 @@ void RepairPresets_savePresets(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ErrorStatus RepairPresets_verifyCRCs(void)
|
static void RepairPresets_verifyCRCs(void)
|
||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
if (self->initialized)
|
if (self->initialized)
|
||||||
@@ -249,15 +250,17 @@ static ErrorStatus RepairPresets_verifyCRCs(void)
|
|||||||
int loopCounter;
|
int loopCounter;
|
||||||
struct RepairPresetStorageClass _tempPresetStorage;
|
struct RepairPresetStorageClass _tempPresetStorage;
|
||||||
struct RepairPresetStorageClass* tempPresetStorage = &_tempPresetStorage;
|
struct RepairPresetStorageClass* tempPresetStorage = &_tempPresetStorage;
|
||||||
|
bool crcErrorFound = false;
|
||||||
for (loopCounter = 0; loopCounter < REPAIR_PRESETS_NUMBER_OF_PRESETS; loopCounter++)
|
for (loopCounter = 0; loopCounter < REPAIR_PRESETS_NUMBER_OF_PRESETS; loopCounter++)
|
||||||
{
|
{
|
||||||
// Load next preset from cache
|
// Load next preset from cache
|
||||||
tempPresetStorage = CachedStorage_readBlob(self->presetStorage, loopCounter * sizeof(struct RepairPresetStorageClass) / 4);
|
tempPresetStorage = (struct RepairPresetStorageClass*)CachedStorage_readBlob(self->presetStorage, loopCounter * sizeof(struct RepairPresetStorageClass) / 4);
|
||||||
// Verify CRC
|
// Verify CRC
|
||||||
returnValue = RepairPresets_verifyPresetCRC(tempPresetStorage);
|
returnValue = RepairPresets_verifyPresetCRC(tempPresetStorage);
|
||||||
// Check CRC verification
|
// Check CRC verification
|
||||||
if (returnValue != SUCCESS)
|
if (returnValue != SUCCESS)
|
||||||
{
|
{
|
||||||
|
crcErrorFound = true;
|
||||||
// CRC was not correct - replace corrupted preset with a DEFAULT preset
|
// CRC was not correct - replace corrupted preset with a DEFAULT preset
|
||||||
RepairPreset_generateDefaultPreset(&tempPresetStorage->preset, loopCounter + 1);
|
RepairPreset_generateDefaultPreset(&tempPresetStorage->preset, loopCounter + 1);
|
||||||
LOGGER_DEBUG(mainLog, "PRESET %d: Softstart: %d, Duration: %d, Voltage: %d", tempPresetStorage->preset.presetNumber, tempPresetStorage->preset.preset[0].softstartDuration, tempPresetStorage->preset.preset[0].duration, tempPresetStorage->preset.preset[0].voltage);
|
LOGGER_DEBUG(mainLog, "PRESET %d: Softstart: %d, Duration: %d, Voltage: %d", tempPresetStorage->preset.presetNumber, tempPresetStorage->preset.preset[0].softstartDuration, tempPresetStorage->preset.preset[0].duration, tempPresetStorage->preset.preset[0].voltage);
|
||||||
@@ -265,14 +268,13 @@ static ErrorStatus RepairPresets_verifyCRCs(void)
|
|||||||
RepairPresets_writePreset(&tempPresetStorage->preset);
|
RepairPresets_writePreset(&tempPresetStorage->preset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (crcErrorFound)
|
||||||
|
{
|
||||||
|
Error_postError(ERROR_CRC_PRESETS);
|
||||||
|
}
|
||||||
// Commit cache to memory - will not write if no changes have been made
|
// Commit cache to memory - will not write if no changes have been made
|
||||||
CachedStorage_commit(self->presetStorage);
|
CachedStorage_commit(self->presetStorage);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
returnValue = ERROR;
|
|
||||||
}
|
|
||||||
return returnValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -70,10 +70,28 @@ ErrorStatus SignalProfileGenerator_construct(struct SignalProfileGenerator* self
|
|||||||
|
|
||||||
if (!self->initialized)
|
if (!self->initialized)
|
||||||
{
|
{
|
||||||
self->secondsCounter = 0;
|
self->secondsCounter = 0;
|
||||||
self->currentState = SPG_PREPARE;
|
self->currentPresetIndex = 0;
|
||||||
self->initialized = true;
|
self->currentState = SPG_PREPARE;
|
||||||
self->repairPreset = preset;
|
self->initialized = true;
|
||||||
|
self->isProcessRunning = false;
|
||||||
|
self->repairPreset = preset;
|
||||||
|
self->signal = 0;
|
||||||
|
self->statePriorToPause = SPG_PREPARE;
|
||||||
|
self->totalRunTime = 0;
|
||||||
|
self->totalStartTime = 0;
|
||||||
|
|
||||||
|
self->pauseSoftStartTimer = 0;
|
||||||
|
self->pauseStartTime = 0;
|
||||||
|
self->pauseStartVoltage = 0;
|
||||||
|
|
||||||
|
self->softStartTimer = 0;
|
||||||
|
self->startTime = 0;
|
||||||
|
self->startVoltage = 0;
|
||||||
|
|
||||||
|
self->voltageHoldTimer = 0;
|
||||||
|
self->voltagePriorToPause = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -91,10 +109,10 @@ void SignalProfileGenerator_destruct(struct SignalProfileGenerator* self)
|
|||||||
|
|
||||||
void SignalProfileGenerator_calculate(struct SignalProfileGenerator* self)
|
void SignalProfileGenerator_calculate(struct SignalProfileGenerator* self)
|
||||||
{
|
{
|
||||||
self->signal = 0;
|
|
||||||
|
|
||||||
if (self->initialized)
|
if (self->initialized)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (self->currentState)
|
switch (self->currentState)
|
||||||
{
|
{
|
||||||
case SPG_PREPARE:
|
case SPG_PREPARE:
|
||||||
@@ -103,13 +121,30 @@ void SignalProfileGenerator_calculate(struct SignalProfileGenerator* self)
|
|||||||
//Load the timers
|
//Load the timers
|
||||||
self->startTime = self->secondsCounter;
|
self->startTime = self->secondsCounter;
|
||||||
self->softStartTimer = self->secondsCounter + self->repairPreset->preset[self->currentPresetIndex].softstartDuration;
|
self->softStartTimer = self->secondsCounter + self->repairPreset->preset[self->currentPresetIndex].softstartDuration;
|
||||||
self->voltageHoldTimer = self->secondsCounter + self->repairPreset->preset[self->currentPresetIndex].duration;
|
self->voltageHoldTimer = self->secondsCounter + self->repairPreset->preset[self->currentPresetIndex].duration + self->repairPreset->preset[self->currentPresetIndex].softstartDuration;
|
||||||
|
|
||||||
LOGGER_DEBUG(mainLog, "startTime %d - softStartTime %d - HoldTimer %d", (unsigned int)self->startTime, (unsigned int)self->softStartTimer, (unsigned int)self->voltageHoldTimer);
|
// Calculate the complete timer for ALL stages - but only when in first stage, so this
|
||||||
|
// calculation does not get re-done with every new stage
|
||||||
// If first preset, start voltage is 0
|
|
||||||
if (self->currentPresetIndex == 0)
|
if (self->currentPresetIndex == 0)
|
||||||
{
|
{
|
||||||
|
// RESET the total runtime prior to new calculation
|
||||||
|
// Take the current time (starttime) as offset
|
||||||
|
self->totalStartTime = self->startTime;
|
||||||
|
self->totalRunTime = self->startTime;
|
||||||
|
// The total run-time is the sum of all softstart times and hold times
|
||||||
|
int loopcounter;
|
||||||
|
for (loopcounter = 0; loopcounter < self->repairPreset->numberOfStages; loopcounter++)
|
||||||
|
{
|
||||||
|
self->totalRunTime += self->repairPreset->preset[loopcounter].softstartDuration;
|
||||||
|
self->totalRunTime += self->repairPreset->preset[loopcounter].duration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If first preset, start voltage is 0 (or the representative 0-offset values per PCBA)
|
||||||
|
if (self->currentPresetIndex == 0)
|
||||||
|
{
|
||||||
|
// RESET the signal to 0 at the very start of a new signalprofile
|
||||||
|
self->signal = 0;
|
||||||
if (PCBA_getInstance()->pcba == PCBA_Anode)
|
if (PCBA_getInstance()->pcba == PCBA_Anode)
|
||||||
{
|
{
|
||||||
self->startVoltage = SPG_0V_OFFSET_ANODE;
|
self->startVoltage = SPG_0V_OFFSET_ANODE;
|
||||||
@@ -172,10 +207,11 @@ void SignalProfileGenerator_calculate(struct SignalProfileGenerator* self)
|
|||||||
{
|
{
|
||||||
self->pauseStartTime = self->secondsCounter;
|
self->pauseStartTime = self->secondsCounter;
|
||||||
self->pauseSoftStartTimer = self->secondsCounter + SPG_PAUSE_SOFTSTART;
|
self->pauseSoftStartTimer = self->secondsCounter + SPG_PAUSE_SOFTSTART;
|
||||||
self->startTime = self->startTime + SPG_PAUSE_SOFTSTART;
|
|
||||||
self->softStartTimer = self->softStartTimer + SPG_PAUSE_SOFTSTART;
|
self->softStartTimer = self->softStartTimer + SPG_PAUSE_SOFTSTART;
|
||||||
self->voltageHoldTimer = self->voltageHoldTimer + SPG_PAUSE_SOFTSTART;
|
self->voltageHoldTimer = self->voltageHoldTimer + SPG_PAUSE_SOFTSTART;
|
||||||
self->currentState = SPG_PAUSE_RESTORE_SOFTSTART;
|
self->currentState = SPG_PAUSE_RESTORE_SOFTSTART;
|
||||||
|
// Add the pause time twice because the total time actually increases
|
||||||
|
self->totalRunTime = self->totalRunTime + SPG_PAUSE_SOFTSTART;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SPG_PAUSE_RESTORE_SOFTSTART:
|
case SPG_PAUSE_RESTORE_SOFTSTART:
|
||||||
@@ -226,6 +262,7 @@ void SignalProfileGenerator_calculate(struct SignalProfileGenerator* self)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SPG_FINISHED:
|
case SPG_FINISHED:
|
||||||
{
|
{
|
||||||
self->isProcessRunning = false;
|
self->isProcessRunning = false;
|
||||||
@@ -264,6 +301,21 @@ bool SignalProfileGenerator_isPaused(struct SignalProfileGenerator* self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SignalProfileGenerator_isFinished(struct SignalProfileGenerator* self)
|
||||||
|
{
|
||||||
|
bool returnValue;
|
||||||
|
if (self->currentState == SPG_FINISHED)
|
||||||
|
{
|
||||||
|
returnValue = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = false;
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SignalProfileGenerator_continue(struct SignalProfileGenerator* self)
|
void SignalProfileGenerator_continue(struct SignalProfileGenerator* self)
|
||||||
{
|
{
|
||||||
self->currentState = SPG_PAUSE_RESTORE;
|
self->currentState = SPG_PAUSE_RESTORE;
|
||||||
@@ -276,9 +328,10 @@ uint32_t SignalProfileGenerator_getRemainingTime(const struct SignalProfileGener
|
|||||||
|
|
||||||
if ((self->initialized) && (self->isProcessRunning))
|
if ((self->initialized) && (self->isProcessRunning))
|
||||||
{
|
{
|
||||||
if (self->voltageHoldTimer >= self->secondsCounter)
|
|
||||||
|
if (self->totalRunTime >= self->secondsCounter)
|
||||||
{
|
{
|
||||||
returnValue = (self->voltageHoldTimer - self->secondsCounter);
|
returnValue = (self->totalRunTime - self->secondsCounter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -294,6 +347,22 @@ uint32_t SignalProfileGenerator_getRemainingTime(const struct SignalProfileGener
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t SignalProfileGenerator_getTotalRepairTime(const struct SignalProfileGenerator* self)
|
||||||
|
{
|
||||||
|
uint32_t returnValue;
|
||||||
|
|
||||||
|
if ((self->initialized) && (self->isProcessRunning))
|
||||||
|
{
|
||||||
|
returnValue = (self->totalRunTime - self->totalStartTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = 0xFFFFFFFF;
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void incrementSecondsCounter(struct SignalProfileGenerator* self)
|
static inline void incrementSecondsCounter(struct SignalProfileGenerator* self)
|
||||||
{
|
{
|
||||||
self->secondsCounter++;
|
self->secondsCounter++;
|
||||||
|
|||||||
@@ -0,0 +1,114 @@
|
|||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
/// @file Voltage.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 Voltage.c
|
||||||
|
/// @ingroup {group_name}
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Include files
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "Voltage.h"
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Constant and macro definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Type definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// File-scope variables
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Function declarations
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Function definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
int Voltage_calculateVoltage(uint32_t value, uint32_t resolutionInBits, int minVoltage, int maxVoltage)
|
||||||
|
{
|
||||||
|
int returnValue = 0;
|
||||||
|
|
||||||
|
int maxAdcValue = ((1 << resolutionInBits) - 1);
|
||||||
|
|
||||||
|
returnValue = (int)value * (maxVoltage - minVoltage);
|
||||||
|
returnValue = returnValue / maxAdcValue;
|
||||||
|
returnValue = returnValue + minVoltage;
|
||||||
|
|
||||||
|
|
||||||
|
// Differ between an positive and negative scale
|
||||||
|
if (maxVoltage > minVoltage)
|
||||||
|
{
|
||||||
|
// Common scale with a higher maximum value than the minimum value
|
||||||
|
if (returnValue < minVoltage)
|
||||||
|
{
|
||||||
|
returnValue = minVoltage;
|
||||||
|
}
|
||||||
|
else if (returnValue > maxVoltage)
|
||||||
|
{
|
||||||
|
returnValue = maxVoltage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Negative scale where the ADC value (positive) must be translated in a negative voltage
|
||||||
|
if (returnValue > minVoltage)
|
||||||
|
{
|
||||||
|
returnValue = minVoltage;
|
||||||
|
}
|
||||||
|
else if (returnValue < maxVoltage)
|
||||||
|
{
|
||||||
|
returnValue = maxVoltage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t Voltage_calculateDeviceValue(int value, uint32_t resolutionInBits, int minVoltage, int maxVoltage)
|
||||||
|
{
|
||||||
|
uint32_t dacValue;
|
||||||
|
|
||||||
|
int maxDacValue = ((1 << resolutionInBits) - 1);
|
||||||
|
int tempValue = (value - minVoltage) * maxDacValue;
|
||||||
|
tempValue = tempValue / (maxVoltage - minVoltage) + 1;
|
||||||
|
dacValue = abs(tempValue);
|
||||||
|
if (dacValue > maxDacValue)
|
||||||
|
{
|
||||||
|
dacValue = maxDacValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dacValue;
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
/// @file Warning.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 Warning.c
|
||||||
|
/// @ingroup {group_name}
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Include files
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "Warning.h"
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Constant and macro definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define WARNING_QUEUE_SIZE (10)
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Type definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
struct WarningQueueItem
|
||||||
|
{
|
||||||
|
T_WarningCode warningCode;
|
||||||
|
};
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// File-scope variables
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static struct Observable observable;
|
||||||
|
static TaskHandle_t warningTaskHandle;
|
||||||
|
static QueueHandle_t warningQueue;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Function declarations
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void WarningTask (void* parameters);
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Function definitions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
ErrorStatus Warning_construct(void)
|
||||||
|
{
|
||||||
|
Observable_construct(&observable);
|
||||||
|
|
||||||
|
warningQueue = xQueueCreate(WARNING_QUEUE_SIZE, sizeof(struct WarningQueueItem));
|
||||||
|
xTaskCreate(WarningTask, "ErrorTask", 300, NULL, 1, &warningTaskHandle);
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct Observable* Warning_getObservable(void)
|
||||||
|
{
|
||||||
|
return &observable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Warning_postWarning(T_WarningCode warningCode)
|
||||||
|
{
|
||||||
|
LOGGER_WARNING(mainLog, "WARNING POSTED WITH CODE %d", warningCode);
|
||||||
|
struct WarningQueueItem queueItem;
|
||||||
|
queueItem.warningCode = warningCode;
|
||||||
|
xQueueSend(warningQueue, &queueItem, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Warning_postWarningFromISR(T_WarningCode warningCode)
|
||||||
|
{
|
||||||
|
portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||||
|
LOGGER_WARNING_ISR(mainLog, "WARNING POSTED FROM ISR");
|
||||||
|
|
||||||
|
struct WarningQueueItem queueItem;
|
||||||
|
queueItem.warningCode = warningCode;
|
||||||
|
xQueueSendFromISR(warningQueue, &queueItem, &higherPriorityTaskWoken);
|
||||||
|
|
||||||
|
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void WarningTask (void* parameters)
|
||||||
|
{
|
||||||
|
struct WarningQueueItem queueItem;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
xQueueReceive(warningQueue, &queueItem, portMAX_DELAY);
|
||||||
|
Observable_notifyObservers(&observable, (const void* const)queueItem.warningCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
#include "DAConverters.h"
|
#include "DAConverters.h"
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
#include "Error.h"
|
#include "Error.h"
|
||||||
|
#include "Warning.h"
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "CoverSolenoid.h"
|
#include "CoverSolenoid.h"
|
||||||
@@ -43,6 +44,7 @@
|
|||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "PCBA.h"
|
#include "PCBA.h"
|
||||||
#include "Power6V5Supply.h"
|
#include "Power6V5Supply.h"
|
||||||
|
#include "TeslaGunSafety.h"
|
||||||
#include "Version.h"
|
#include "Version.h"
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -60,7 +62,7 @@
|
|||||||
// File-scope variables
|
// File-scope variables
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static bool _hsb_safetyIsEnabled = false;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function declarations
|
// Function declarations
|
||||||
@@ -104,7 +106,7 @@ ErrorStatus hsb_generateStartScreen(struct Display* Display)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ErrorStatus hsb_enableSafety(void)
|
ErrorStatus hsb_enableSafetyWithError(void)
|
||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
@@ -117,8 +119,7 @@ ErrorStatus hsb_enableSafety(void)
|
|||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
// Check for INTERLOCK CLOSE
|
// Check for INTERLOCK CLOSE
|
||||||
// if (Interlock_isClosed(interlock))
|
if (Interlock_isClosed(interlock))
|
||||||
if (1)
|
|
||||||
{
|
{
|
||||||
// Enable Interrupt for interlock switch
|
// Enable Interrupt for interlock switch
|
||||||
Interlock_setEXTI(interlock, ENABLE);
|
Interlock_setEXTI(interlock, ENABLE);
|
||||||
@@ -130,11 +131,82 @@ ErrorStatus hsb_enableSafety(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
// In case of a TESLA repair, release the teslaGunSafety
|
||||||
|
if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||||
|
{
|
||||||
|
TeslaGunSafety_release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if Interlock(s) closed, continue procedure
|
// if Interlock(s) closed, continue procedure
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
// Power the circuit
|
// Power the circuit
|
||||||
Power6V5Supply_on();
|
returnValue = Power6V5Supply_on();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
_hsb_safetyIsEnabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_hsb_safetyIsEnabled = false;
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ErrorStatus hsb_enableSafetyWithWarning(void)
|
||||||
|
{
|
||||||
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
|
// First, Lock the cover
|
||||||
|
if (returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
CoverSolenoid_lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
// Check for INTERLOCK CLOSE
|
||||||
|
if (Interlock_isClosed(interlock))
|
||||||
|
{
|
||||||
|
// Enable Interrupt for interlock switch
|
||||||
|
Interlock_setEXTI(interlock, ENABLE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Warning_postWarning(WARNING_INTERLOCK_COMMON_FAIL);
|
||||||
|
returnValue = ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
// In case of a TESLA repair, release the teslaGunSafety
|
||||||
|
if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||||
|
{
|
||||||
|
TeslaGunSafety_release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if Interlock(s) closed, continue procedure
|
||||||
|
if (returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
// Power the circuit
|
||||||
|
returnValue = Power6V5Supply_on();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
_hsb_safetyIsEnabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_hsb_safetyIsEnabled = false;
|
||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
@@ -148,16 +220,19 @@ ErrorStatus hsb_disableSafety(void)
|
|||||||
int adcR2Value = HSB_SECURITY_VOLTAGE_THRESHOLD;
|
int adcR2Value = HSB_SECURITY_VOLTAGE_THRESHOLD;
|
||||||
int adcR3Value = HSB_SECURITY_VOLTAGE_THRESHOLD;
|
int adcR3Value = HSB_SECURITY_VOLTAGE_THRESHOLD;
|
||||||
|
|
||||||
Display_clearScreen(mainDisplay);
|
if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||||
|
{
|
||||||
|
TeslaGunSafety_block();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display_clearScreen(mainDisplay);
|
||||||
char buffer[mainDisplay->displayDevice->parameters.numberOfColumns];
|
char buffer[mainDisplay->displayDevice->parameters.numberOfColumns];
|
||||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "WAITING FOR");
|
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "WAITING FOR");
|
||||||
Display_write(mainDisplay, buffer, 2, 5);
|
Display_write(mainDisplay, buffer, 3, 5);
|
||||||
|
|
||||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "POWER");
|
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "POWER DOWN");
|
||||||
Display_write(mainDisplay, buffer, 3, 7);
|
Display_write(mainDisplay, buffer, 4, 6);
|
||||||
|
|
||||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "DOWN");
|
|
||||||
Display_write(mainDisplay, buffer, 4, 8);
|
|
||||||
|
|
||||||
// Power-down the DAC outputs
|
// Power-down the DAC outputs
|
||||||
DAConverter_setOutputVoltage(dacRow1, 0);
|
DAConverter_setOutputVoltage(dacRow1, 0);
|
||||||
@@ -167,18 +242,40 @@ ErrorStatus hsb_disableSafety(void)
|
|||||||
// Un-Power the circuit
|
// Un-Power the circuit
|
||||||
Power6V5Supply_off();
|
Power6V5Supply_off();
|
||||||
|
|
||||||
|
if (PCBA_getInstance()->pcba != PCBA_Tesla)
|
||||||
// Verify that all High Voltage Supplies are shut off and voltages are below security value
|
|
||||||
while ((abs(adcR1Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD) || (abs(adcR2Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD) || (abs(adcR3Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD))
|
|
||||||
{
|
{
|
||||||
adcR1Value = ADConverter_getInputVoltage(adcRow1);
|
// Verify that all High Voltage Supplies are shut off and voltages are below security value
|
||||||
adcR2Value = ADConverter_getInputVoltage(adcRow2);
|
while ((abs(adcR1Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD) || (abs(adcR2Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD) || (abs(adcR3Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD))
|
||||||
adcR3Value = ADConverter_getInputVoltage(adcRow3);
|
{
|
||||||
vTaskDelay(100);
|
adcR1Value = ADConverter_getInputVoltage(adcRow1);
|
||||||
|
adcR2Value = ADConverter_getInputVoltage(adcRow2);
|
||||||
|
adcR3Value = ADConverter_getInputVoltage(adcRow3);
|
||||||
|
vTaskDelay(100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Verify that all High Voltage Supplies are shut off and voltages are below security value
|
||||||
|
while (abs(adcR2Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD)
|
||||||
|
{
|
||||||
|
adcR2Value = ADConverter_getInputVoltage(adcRow2);
|
||||||
|
vTaskDelay(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Display_clearLine(mainDisplay, 3);
|
||||||
|
Display_clearLine(mainDisplay, 4);
|
||||||
|
|
||||||
|
|
||||||
Interlock_setEXTI(interlock, DISABLE);
|
Interlock_setEXTI(interlock, DISABLE);
|
||||||
|
|
||||||
|
_hsb_safetyIsEnabled = false;
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool hsb_safetyIsEnabled(void)
|
||||||
|
{
|
||||||
|
return _hsb_safetyIsEnabled;
|
||||||
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include "ADConverters.h"
|
#include "ADConverters.h"
|
||||||
#include "DAConverters.h"
|
#include "DAConverters.h"
|
||||||
|
#include "DeviceParameters.h"
|
||||||
#include "Displays.h"
|
#include "Displays.h"
|
||||||
#include "Error.h"
|
#include "Error.h"
|
||||||
#include "hsb-mrts.h"
|
#include "hsb-mrts.h"
|
||||||
@@ -43,6 +44,7 @@
|
|||||||
#include "repairMenus.h"
|
#include "repairMenus.h"
|
||||||
#include "repairProcess.h"
|
#include "repairProcess.h"
|
||||||
#include "repairProcesses.h"
|
#include "repairProcesses.h"
|
||||||
|
#include "Warning.h"
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "stm32f10x_rcc.h"
|
#include "stm32f10x_rcc.h"
|
||||||
@@ -100,12 +102,12 @@ static xTaskHandle initTaskHandle;
|
|||||||
static xTaskHandle ledTaskHandle;
|
static xTaskHandle ledTaskHandle;
|
||||||
static xTaskHandle sysTaskHandle;
|
static xTaskHandle sysTaskHandle;
|
||||||
|
|
||||||
static struct HwValidationMenu _hwValidation = {.initialized = false};
|
//static struct HwValidationMenu _hwValidation = {.initialized = false};
|
||||||
static struct HwValidationMenuItems hwTestItems;
|
//static struct HwValidationMenuItems hwTestItems;
|
||||||
|
//struct HwValidationMenu* hwValidation = &_hwValidation;
|
||||||
struct HwValidationMenu* hwValidation = &_hwValidation;
|
|
||||||
|
|
||||||
static struct CachedStorage cs = {.initialized = false};
|
static struct CachedStorage cs = {.initialized = false};
|
||||||
|
static struct CachedStorage deviceParameters = {.initialized = false};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function declarations
|
// Function declarations
|
||||||
@@ -151,7 +153,7 @@ void vApplicationTickHook ()
|
|||||||
|
|
||||||
static void printSystemInfoTask(void* parameters)
|
static void printSystemInfoTask(void* parameters)
|
||||||
{
|
{
|
||||||
while (1)
|
// while (1)
|
||||||
{
|
{
|
||||||
LOGGER_INFO(mainLog, "---------------------------------------");
|
LOGGER_INFO(mainLog, "---------------------------------------");
|
||||||
systeminfoCommandHandler();
|
systeminfoCommandHandler();
|
||||||
@@ -195,6 +197,9 @@ static void initTask(void* parameters)
|
|||||||
// Create the error handler
|
// Create the error handler
|
||||||
Error_construct();
|
Error_construct();
|
||||||
|
|
||||||
|
// Create the warning handler
|
||||||
|
Warning_construct();
|
||||||
|
|
||||||
// Initialize the platform first
|
// Initialize the platform first
|
||||||
// All IO is initialized here
|
// All IO is initialized here
|
||||||
// Also, all periphery and platform-specifics are initialized here
|
// Also, all periphery and platform-specifics are initialized here
|
||||||
@@ -213,13 +218,15 @@ static void initTask(void* parameters)
|
|||||||
// Construct the DA Converters
|
// Construct the DA Converters
|
||||||
DAConverters_construct();
|
DAConverters_construct();
|
||||||
|
|
||||||
// Construct the repair presets
|
|
||||||
RepairPresets_construct(&cs, &iFlash->memoryDevice);
|
|
||||||
|
|
||||||
hsb_generateStartScreen(mainDisplay);
|
hsb_generateStartScreen(mainDisplay);
|
||||||
// Let start screen stay for 5 seconds
|
// Let start screen stay for 5 seconds
|
||||||
// vTaskDelay(INIT_START_SCREEN_DELAY);
|
vTaskDelay(INIT_START_SCREEN_DELAY);
|
||||||
|
|
||||||
|
// Construct/Load the device parameters
|
||||||
|
DeviceParameters_construct(&deviceParameters, &iFlash->memoryDevice);
|
||||||
|
|
||||||
|
// Construct the repair presets
|
||||||
|
RepairPresets_construct(&cs, &iFlash->memoryDevice);
|
||||||
|
|
||||||
///TODO MUST BE UPDATED
|
///TODO MUST BE UPDATED
|
||||||
// hwTestItems.display = &nhd0420->displayDevice;
|
// hwTestItems.display = &nhd0420->displayDevice;
|
||||||
@@ -245,7 +252,7 @@ static void initTask(void* parameters)
|
|||||||
|
|
||||||
|
|
||||||
// Create task that repeats to print out TASK information on the logger
|
// Create task that repeats to print out TASK information on the logger
|
||||||
// xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 0, &sysTaskHandle);
|
xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 0, &sysTaskHandle);
|
||||||
|
|
||||||
// Delete this init task
|
// Delete this init task
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -33,6 +33,7 @@
|
|||||||
#include "MenuCore.h"
|
#include "MenuCore.h"
|
||||||
#include "repairMenus.h"
|
#include "repairMenus.h"
|
||||||
#include "repairMenu.h"
|
#include "repairMenu.h"
|
||||||
|
#include "Warning.h"
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
@@ -67,6 +68,7 @@ struct RepairMenu* const mainMenu = &_mainMenu;
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static ErrorStatus repairMenus_errorReceive(const void* const data);
|
static ErrorStatus repairMenus_errorReceive(const void* const data);
|
||||||
|
static ErrorStatus repairMenus_warningReceive(const void* const data);
|
||||||
static ErrorStatus repairMenus_freeMainMenuRepairScreenUpdateSemaphore(const void* const data);
|
static ErrorStatus repairMenus_freeMainMenuRepairScreenUpdateSemaphore(const void* const data);
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -91,6 +93,11 @@ ErrorStatus repairMenus_construct(void)
|
|||||||
returnValue = Observable_addObserver(Error_getObservable(), repairMenus_errorReceive);
|
returnValue = Observable_addObserver(Error_getObservable(), repairMenus_errorReceive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (returnValue == SUCCESS)
|
||||||
|
{
|
||||||
|
returnValue = Observable_addObserver(Warning_getObservable(), repairMenus_warningReceive);
|
||||||
|
}
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,20 +117,56 @@ struct RepairMenu* repairMenus_getMainRepairMenu(void)
|
|||||||
|
|
||||||
static ErrorStatus repairMenus_errorReceive(const void* const data)
|
static ErrorStatus repairMenus_errorReceive(const void* const data)
|
||||||
{
|
{
|
||||||
|
|
||||||
T_ErrorCode errorCode = (T_ErrorCode)data;
|
T_ErrorCode errorCode = (T_ErrorCode)data;
|
||||||
// Only respond to the errors necessary
|
|
||||||
if (errorCode == INTERLOCK_COMMON_FAIL)
|
|
||||||
{
|
|
||||||
repairMenu_interlockFailed(mainMenu, COMMON_INTERLOCK);
|
|
||||||
}
|
|
||||||
else if (errorCode == POWERENABLE_FAIL)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
switch (errorCode)
|
||||||
else if (errorCode == REPAIR_FAIL)
|
|
||||||
{
|
{
|
||||||
repairMenu_processFailed(mainMenu);
|
case INTERLOCK_COMMON_FAIL:
|
||||||
|
{
|
||||||
|
repairMenu_interlockFailed(mainMenu, COMMON_INTERLOCK);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case POWERENABLE_FAIL:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case REPAIR_FAIL:
|
||||||
|
{
|
||||||
|
repairMenu_processFailed(mainMenu);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ERROR_CRC_PIN:
|
||||||
|
case ERROR_CRC_PARAMETERS:
|
||||||
|
case ERROR_CRC_PRESETS:
|
||||||
|
{
|
||||||
|
repairMenu_printCRCFailure(mainMenu, errorCode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ErrorStatus repairMenus_warningReceive(const void* const data)
|
||||||
|
{
|
||||||
|
T_WarningCode warningCode = (T_WarningCode)data;
|
||||||
|
|
||||||
|
switch (warningCode)
|
||||||
|
{
|
||||||
|
case WARNING_INTERLOCK_COMMON_FAIL:
|
||||||
|
{
|
||||||
|
repairMenu_interlockWarning(mainMenu, COMMON_INTERLOCK);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,6 +185,12 @@ uint32_t repairProcess_getRemainingRepairTime(const struct RepairProcess* self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t repairProcess_getTotalRepairtime(const struct RepairProcess* self)
|
||||||
|
{
|
||||||
|
return SignalProfileGenerator_getTotalRepairTime(&self->signalProfileGenerator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const struct RepairProcessRow* repairProcess_getRowInformation(const struct RepairProcess* self, int rowIndex)
|
const struct RepairProcessRow* repairProcess_getRowInformation(const struct RepairProcess* self, int rowIndex)
|
||||||
{
|
{
|
||||||
return &self->row[rowIndex];
|
return &self->row[rowIndex];
|
||||||
@@ -223,12 +229,12 @@ static void repairProcess_task(void* parameters)
|
|||||||
|
|
||||||
while(self->runTask)
|
while(self->runTask)
|
||||||
{
|
{
|
||||||
LOGGER_DEBUG(mainLog, "----------------------------------------");
|
// LOGGER_DEBUG(mainLog, "----------------------------------------");
|
||||||
xSemaphoreTake(self->secondsSyncronisation, portMAX_DELAY);
|
xSemaphoreTake(self->secondsSyncronisation, portMAX_DELAY);
|
||||||
|
|
||||||
// The signal profile is identical for all rows in the regulation process
|
// The signal profile is identical for all rows in the regulation process
|
||||||
SignalProfileGenerator_calculate(&self->signalProfileGenerator);
|
SignalProfileGenerator_calculate(&self->signalProfileGenerator);
|
||||||
LOGGER_DEBUG(mainLog, "Signal: %d, TimeToRemain %d", self->signalProfileGenerator.signal, (unsigned int)SignalProfileGenerator_getRemainingTime(&self->signalProfileGenerator));
|
// LOGGER_DEBUG(mainLog, "Signal: %d, TimeToRemain %d", self->signalProfileGenerator.signal, (unsigned int)SignalProfileGenerator_getRemainingTime(&self->signalProfileGenerator));
|
||||||
|
|
||||||
// Check for correct signal
|
// Check for correct signal
|
||||||
if (!SignalProfileGenerator_isPaused(&self->signalProfileGenerator))
|
if (!SignalProfileGenerator_isPaused(&self->signalProfileGenerator))
|
||||||
@@ -272,7 +278,7 @@ static void repairProcess_task(void* parameters)
|
|||||||
// Send the PID value to the DAC
|
// Send the PID value to the DAC
|
||||||
DAConverter_setOutputVoltage(self->row[loopCounter].dacChannel, self->row[loopCounter].lastDACValue);
|
DAConverter_setOutputVoltage(self->row[loopCounter].dacChannel, self->row[loopCounter].lastDACValue);
|
||||||
|
|
||||||
LOGGER_DEBUG(mainLog, "Row %d --- ADC: %d Error: %d PID: %d", loopCounter, self->row[loopCounter].lastADCValue, self->row[loopCounter].pidError, self->row[loopCounter].lastDACValue);
|
// LOGGER_DEBUG(mainLog, "Row %d --- ADC: %d Error: %d PID: %d", loopCounter, self->row[loopCounter].lastADCValue, self->row[loopCounter].pidError, self->row[loopCounter].lastDACValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -79,10 +79,7 @@ ErrorStatus repairProcesses_startMainRepairProcess(const struct RepairPreset* re
|
|||||||
|
|
||||||
void repairProcesses_abortMainRepairProcess(void)
|
void repairProcesses_abortMainRepairProcess(void)
|
||||||
{
|
{
|
||||||
Interlock_setEXTI(interlock, DISABLE);
|
hsb_disableSafety();
|
||||||
|
|
||||||
// DISABLE external power
|
|
||||||
Power6V5Supply_off();
|
|
||||||
|
|
||||||
repairProcess_destruct(&mainRepairProcess);
|
repairProcess_destruct(&mainRepairProcess);
|
||||||
Observable_deleteObserver(RTC_getObservable(rtc), repairProcesses_feedMainRepairProcessSecondsCounter);
|
Observable_deleteObserver(RTC_getObservable(rtc), repairProcesses_feedMainRepairProcessSecondsCounter);
|
||||||
|
|||||||
Reference in New Issue
Block a user