Added buzzer

Added powerloss detector

Added buzzer behaviour to system.
Added powerloss behaviour to system 

Added french translation to menu texts

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

View File

@@ -27,6 +27,7 @@ MenuCore.o \
MenuElements.o \
PIDParameters.o \
PIN.o \
PowerLossDetector.o \
repairMenu.o \
repairMenus.o \
RepairPreset.o \

View File

@@ -48,6 +48,7 @@
typedef enum
{
ERROR_POWER_LOSS,
GPIO_FAIL,
INTERLOCK_COMMON_FAIL,
POWERENABLE_FAIL,

View File

@@ -35,6 +35,7 @@
#include "stm32f10x.h"
#include "Buzzer.h"
#include "Display.h"
#include "KeyboardDevice.h"
#include "MenuStates.h"
@@ -44,7 +45,7 @@
#define MENUCORE_MAX_NUMBER_OF_ROWS (11)
#define MENUCORE_MAX_NUMBER_OF_KEYS (16)
#define MENUCORE_DISPLAY_ROW_LENGTH (20)
#define MENUCORE_DISPLAY_ROW_LENGTH (21)
// -----------------------------------------------------------------------------
// Type definitions.
@@ -100,6 +101,7 @@ struct MenuCore
struct MenuPage menuArray[RM_NUMBER_OF_MENUS];
struct Display* display;
struct KeyboardDevice* keyboardDevice;
struct Buzzer* buzzer;
char errorMessage[MENUCORE_DISPLAY_ROW_LENGTH + 1];
char warningMessage[MENUCORE_DISPLAY_ROW_LENGTH + 1];
TaskHandle_t taskHandle;
@@ -130,6 +132,8 @@ struct MenuCore
* @param self Menu core object to construct
* @param display Display device to use for output
* @param keyboardDevice KeyboardDevice for menu input
* @param buzzer A buzzer that gives audible feedback
* when a VALID key is pressed
* @param taskPriority Priority for the menu task
* @param stacksize Task stacksize
* @param createMenu Functionpointer to a function that
@@ -149,7 +153,7 @@ struct MenuCore
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus MenuCore_construct(struct MenuCore* self, struct Display* display, struct KeyboardDevice* keyboardDevice, int taskPriority, uint16_t stackSize, MenuCoreFunctionCall createMenu, MenuCoreFunctionCall stateHandle);
extern ErrorStatus MenuCore_construct(struct MenuCore* self, struct Display* display, struct KeyboardDevice* keyboardDevice, struct Buzzer* buzzer, int taskPriority, uint16_t stackSize, MenuCoreFunctionCall createMenu, MenuCoreFunctionCall stateHandle);
/** ----------------------------------------------------------------------------

View File

@@ -61,7 +61,7 @@ static const char MenuText_WARNING[MENUTEXT_NUMBER_OF_LANGUAGES][MENUTEXT_ROW1_P
"!!WARNING!!"
},
{
//FRENCH TBW
"!!ATTENTION!!"
}
};
@@ -72,7 +72,7 @@ static const char MenuText_WARNING_COVER_OPEN[MENUTEXT_NUMBER_OF_LANGUAGES][MENU
"COVER OPEN"
},
{
//FRENCH TBW
"CAPOT OUVERT"
}
};
@@ -87,7 +87,7 @@ static const char MenuText_ERROR[MENUTEXT_NUMBER_OF_LANGUAGES][MENUTEXT_ROW1_POP
"!!ERROR!!"
},
{
//FRENCH TBW
"ERREUR!!"
}
};
@@ -98,10 +98,20 @@ static const char MenuText_ERROR_COVER_OPEN[MENUTEXT_NUMBER_OF_LANGUAGES][MENUTE
"COVER OPEN"
},
{
//FRENCH TBW
"CAPOT OUVERT"
}
};
static const char MenuText_ERROR_POWER_LOSS[MENUTEXT_NUMBER_OF_LANGUAGES][MENUTEXT_POPUP_MESSAGE_LENGTH] =
{
// MAX 20 CHARACTERS
{
"POWERLOSS DETECTED"
},
{
//FRENCH TBW
}
};
static const char MenuText_ERROR_PROCESS_FAILED[MENUTEXT_NUMBER_OF_LANGUAGES][MENUTEXT_POPUP_MESSAGE_LENGTH] =
{
@@ -110,7 +120,7 @@ static const char MenuText_ERROR_PROCESS_FAILED[MENUTEXT_NUMBER_OF_LANGUAGES][ME
"PROCESS FAILED"
},
{
//FRENCH TBW
"PROCESS ECHOUE"
}
};
@@ -121,7 +131,7 @@ static const char MenuText_ERROR_CRC_PIN[MENUTEXT_NUMBER_OF_LANGUAGES][MENUTEXT_
"PIN CRC ERROR"
},
{
//FRENCH TBW
"ERREUR PIN CRC"
}
};
@@ -132,7 +142,7 @@ static const char MenuText_ERROR_CRC_PARAMETERS[MENUTEXT_NUMBER_OF_LANGUAGES][ME
"PARAMETERS CRC ERROR"
},
{
//FRENCH TBW
"ERREUR PARAMETRE CRC"
}
};
@@ -143,7 +153,7 @@ static const char MenuText_ERROR_CRC_PRESETS[MENUTEXT_NUMBER_OF_LANGUAGES][MENUT
"PRESETS CRC ERROR"
},
{
//FRENCH TBW
"ERREUR PREREGL. CRC"
}
};
@@ -158,7 +168,7 @@ static const char MenuText_X_CONTINUE[MENUTEXT_NUMBER_OF_LANGUAGES][MENUTEXT_POP
"Hit X to continue"
},
{
//FRENCH TBW
"Continuer : touche X"
}
};
@@ -172,7 +182,10 @@ static const char MenuText_REPAIR_SCREEN[MENUTEXT_NUMBER_OF_LANGUAGES][4][MENUTE
"ERROR" // Error identifier in case a ROW is in error-state. Will be written instead of the current voltage
},
{
//FRENCH TBW
"total",
"reste",
"R",
"ERREUR"
}
};
@@ -183,7 +196,7 @@ static const char MenuText_REPAIR_SCREEN_INIT[MENUTEXT_NUMBER_OF_LANGUAGES][MENU
"Initialising" // Indicates start of a repair
},
{
//FRENCH TBW
"Initialisation"
}
};
@@ -198,7 +211,11 @@ static const char MenuText_PAUSE[MENUTEXT_NUMBER_OF_LANGUAGES][5][MENUTEXT_POPUP
"Hit X to RESET"
},
{
//FRENCH TBW
"TRAITEMENT EN COURS",
"Pause : touche x",
"!!PAUSE!!",
"Continuer: ENTREE",
"R<EFBFBD>init : touche X"
}
};
@@ -210,7 +227,8 @@ static const char MenuText_FINISH[MENUTEXT_NUMBER_OF_LANGUAGES][2][MENUTEXT_POPU
"Hit ENT to continue",
},
{
//FRENCH TBW
"TRAITEMENT TERMINE",
"Continuer : ENTREE"
}
};
@@ -225,7 +243,11 @@ static const char MenuText_PRINT_PRESET[MENUTEXT_NUMBER_OF_LANGUAGES][5][MENUTEX
"Volt:"
},
{
//FRENCH TBW
"Preset",
"info",
"Start:",
"Temps:",
"Volt:"
}
};
@@ -237,7 +259,8 @@ static const char MenuText_CHANGE_PIN[MENUTEXT_NUMBER_OF_LANGUAGES][2][MENUTEXT_
" Repeat PIN:"
},
{
//FRENCH TBW
" Nouveau PIN:",
"Confirmer PIN:"
}
};
@@ -250,7 +273,9 @@ static const char MenuText_INTERLOCK_STATUS[MENUTEXT_NUMBER_OF_LANGUAGES][3][MEN
"open"
},
{
//FRENCH TBW
"Le capot est :",
"ferme",
"ouvert"
}
};
@@ -262,7 +287,8 @@ static const char MenuText_CONFIRM_PIN[MENUTEXT_NUMBER_OF_LANGUAGES][2][MENUTEXT
"PIN DENIED"
},
{
//FRENCH TBW
"PIN OK",
"PIN REFUSE"
}
};
@@ -274,7 +300,8 @@ static const char MenuText_CONFIRM_NEW_PIN[MENUTEXT_NUMBER_OF_LANGUAGES][2][MENU
"New PIN denied"
},
{
//FRENCH TBW
"Nouveau PIN accept<70>",
"Nouveau PIN refus<75>"
}
};
@@ -285,7 +312,7 @@ static const char MenuText_SAFE_PRESET[MENUTEXT_NUMBER_OF_LANGUAGES][MENUTEXT_PO
"Preset saved"
},
{
//FRENCH TBW
"Pr<EFBFBD>r<EFBFBD>gl. sauvegard<72>"
}
};
@@ -296,7 +323,7 @@ static const char MenuText_SELECT_PRESET[MENUTEXT_NUMBER_OF_LANGUAGES][MENUTEXT_
"Selected preset:"
},
{
//FRENCH TBW
"Pr<EFBFBD>r<EFBFBD>glage n<> :"
}
};
@@ -308,7 +335,7 @@ static const char MenuText_SAFE_CONSTANTS[MENUTEXT_NUMBER_OF_LANGUAGES][MENUTEXT
"Constants saved"
},
{
//FRENCH TBW
"Valeurs sauvegard<72>es"
}
};
@@ -319,7 +346,7 @@ static const char MenuText_INSERT_PIN[MENUTEXT_NUMBER_OF_LANGUAGES][MENUTEXT_POP
"Insert PIN"
},
{
//FRENCH TBW
"Ecrire PIN"
}
};
@@ -330,7 +357,7 @@ static const char MenuText_VOLTAGE_IN_HEADER[MENUTEXT_NUMBER_OF_LANGUAGES][MENUT
"Get voltage in"
},
{
//FRENCH TBW
"Lecture tension"
}
};
@@ -341,7 +368,7 @@ static const char MenuText_VOLTAGE_OUT_HEADER[MENUTEXT_NUMBER_OF_LANGUAGES][MENU
"Set voltage out"
},
{
//FRENCH TBW
"R<EFBFBD>glage tension"
}
};
@@ -352,7 +379,7 @@ static const char MenuText_VOLTAGE_ROW[MENUTEXT_NUMBER_OF_LANGUAGES][5] =
"Row"
},
{
//FRENCH TBW
"Ligne"
}
};
@@ -363,7 +390,7 @@ static const char MenuText_CONSTANTS_HEADER[MENUTEXT_NUMBER_OF_LANGUAGES][MENUTE
"PID constants"
},
{
//FRENCH TBW
"Valeurs du PID"
}
};
@@ -375,7 +402,8 @@ static const char MenuText_VOLTAGE_OUT_CLEANUP[MENUTEXT_NUMBER_OF_LANGUAGES][2][
"Press X to continue"
},
{
//FRENCH TBW
"Ttes les lignes <20> 0V",
"Continuer : touche X"
}
};
@@ -392,7 +420,10 @@ static const char MenuText_MAINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_N
" 3.Calibration"
},
{
//FRENCH TBW
"",
" 1.Traitement tubes",
" 2.Mode Admin",
" 3.Mode Calibration"
}
};
@@ -405,7 +436,9 @@ static const char MenuText_CATHODEMCP_SELECT[MENUTEXT_NUMBER_OF_LANGUAGES][MENUC
" 2.MCP repair",
},
{
//FRENCH TBW
"Traitement tubes",
" 1.Traitement Pk",
" 2.Traitement GMC"
}
};
@@ -418,7 +451,9 @@ static const char MenuText_ADMIN_CATHODEMCP_SELECT[MENUTEXT_NUMBER_OF_LANGUAGES]
" 2.MCP",
},
{
//FRENCH TBW
"Mode Administrateur",
" 1.Photocathode",
" 2.GMC"
}
};
@@ -432,7 +467,9 @@ static const char MenuText_REPAIRMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX
" 2.Start",
},
{
//FRENCH TBW
"Traitement tubes",
" 1.S<>lection pr<70>r<EFBFBD>g",
" 2.D<>marrer"
}
};
@@ -453,7 +490,17 @@ static const char MenuText_PRESETMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX
" 9.Preset 9",
},
{
//FRENCH TBW
"S<EFBFBD>lection pr<70>r<EFBFBD>glage",
" 1.Pr<50>r<EFBFBD>glage n<>1",
" 2.Pr<50>r<EFBFBD>glage n<>2",
" 3.Pr<50>r<EFBFBD>glage n<>3",
" 4.Pr<50>r<EFBFBD>glage n<>4",
" 5.Pr<50>r<EFBFBD>glage n<>5",
" 6.Pr<50>r<EFBFBD>glage n<>6",
" 7.Pr<50>r<EFBFBD>glage n<>7",
" 8.Pr<50>r<EFBFBD>glage n<>8",
" 9.Pr<50>r<EFBFBD>glage n<>9",
}
};
@@ -475,7 +522,12 @@ static const char MenuText_ADMINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_
" 5.Info & Version",
},
{
//FRENCH TBW
"Mode Administrateur",
" 1.Modifier PIN",
" 2.Contr<74>le des E/S",
" 3.Config. Pr<50>r<EFBFBD>gl.",
" 4.Valeurs du PID",
" 5.Info & Version"
}
};
@@ -487,7 +539,7 @@ static const char MenuText_ADMINCHANGEPINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENU
"Change PIN",
},
{
//FRENCH TBW
"Modifier PIN"
}
};
@@ -504,7 +556,12 @@ static const char MenuText_ADMINIOMAINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCOR
" 5.Teslagun relais",
},
{
//FRENCH TBW
"Contr<EFBFBD>le des E/S",
" 1.Interlock",
" 2.Sol<6F>no<6E>des",
" 3.Lecture tension",
" 4.R<>glage tension",
" 5.Relai TeslaGun"
}
};
@@ -517,7 +574,7 @@ static const char MenuText_ADMINIOINTERLOCKMENU[MENUTEXT_NUMBER_OF_LANGUAGES][ME
"Read interlock",
},
{
//FRENCH TBW
"Lecture interlock"
}
};
@@ -533,24 +590,8 @@ static const char MenuText_ADMINSOLENOIDMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUC
},
{
//FRENCH TBW
}
};
// Administration Get Voltage output screen
static const char MenuText_ADMINVOLTAGOUTMAINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] =
{
// MAX 20 CHARACTERS - MIND THE TWO BLANKS AT STRING START - THIS IS WHERE THE CURSOR IS PUT
{
"Set voltage out",
" 1.Channel 1",
" 2.Channel 2",
" 3.Channel 3",
},
{
//FRENCH TBW
"Sol<EFBFBD>no<EFBFBD>des",
"Basculer : touche 0"
}
};
@@ -566,7 +607,8 @@ static const char MenuText_ADMINTESLAGUNMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUC
},
{
//FRENCH TBW
"Relai du TeslaGun",
"Basculer : touche 0"
}
};
@@ -588,7 +630,16 @@ static const char MenuText_ADMINPRESETCONFIGSELECTMENU[MENUTEXT_NUMBER_OF_LANGUA
" 9.Preset 9 config",
},
{
//FRENCH TBW
"Config. Pr<50>r<EFBFBD>gl.",
" 1 Pr<50>r<EFBFBD>gl 1 config",
" 2 Pr<50>r<EFBFBD>gl 2 config",
" 3 Pr<50>r<EFBFBD>gl 3 config",
" 4 Pr<50>r<EFBFBD>gl 4 config",
" 5 Pr<50>r<EFBFBD>gl 5 config",
" 6 Pr<50>r<EFBFBD>gl 6 config",
" 7 Pr<50>r<EFBFBD>gl 7 config",
" 8 Pr<50>r<EFBFBD>gl 8 config",
" 9 Pr<50>r<EFBFBD>gl 9 config",
}
};
@@ -601,7 +652,7 @@ static const char MenuText_ADMININFOMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_
"Info & Version",
},
{
//FRENCH TBW
"Info & Version",
}
};
@@ -614,11 +665,12 @@ static const char MenuText_CALIBRATIONMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCOR
// MAX 20 CHARACTERS - MIND THE TWO BLANKS AT STRING START - THIS IS WHERE THE CURSOR IS PUT
{
"Calibration",
" 1.NOTHING YET",
" 1.To be written",
},
{
//FRENCH TBW
"Calibration",
" 1.En construction"
}
};

View File

@@ -0,0 +1,118 @@
// -----------------------------------------------------------------------------
/// @file PowerLossDetector.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 PowerLossDetector.h
/// @ingroup {group_name}
#ifndef POWERLOSSDETECTOR_H_
#define POWERLOSSDETECTOR_H_
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include "stm32f10x.h"
#include "CachedStorage.h"
#include "MemoryDevice.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
/** ----------------------------------------------------------------------------
* PowerLossDetector_construct
* Description of function
*
* @param memoryDevice
*
* @return ErrorStatus
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus PowerLossDetector_construct(struct MemoryDevice* memoryDevice, unsigned int pageNumber, unsigned int startAddress, unsigned int length);
/** ----------------------------------------------------------------------------
* PowerLossDetector_destruct
* Description of function
*
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void PowerLossDetector_destruct(void);
/** ----------------------------------------------------------------------------
* PowerLossDetector_setBusyFlag
* Description of function
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void PowerLossDetector_setBusyFlag(void);
/** ----------------------------------------------------------------------------
* PowerLossDetector_clearBusyFlag
* Description of function
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void PowerLossDetector_clearBusyFlag(void);
/** ----------------------------------------------------------------------------
* PowerLossDetection_isFlagSet
* Description of function
*
* @return bool
*
* @todo
* -----------------------------------------------------------------------------
*/
extern bool PowerLossDetection_isFlagSet(void);
#endif /* POWERLOSSDETECTOR_H_ */

View File

@@ -54,8 +54,6 @@
#define HSB_MAINREPR_OOL_DURATION (20)
#define HSB_MAINREPR_OOL_VALUE (300)
#define HSB_SECURITY_VOLTAGE_THRESHOLD (100)
#define HSB_ADC_ANODE_MIN_VOLTAGE (0)
#define HSB_ADC_ANODE_MAX_VOLTAGE (10042)
#define HSB_ADC_CMCP_MIN_VOLTAGE (0)
@@ -72,7 +70,6 @@
// FLASH ADDRESSES FOR DATA STORAGE
// Define storage for presets, which is the biggest storage part
// Each set of presets is written/saved on a dedicated page. This reduces
// cache size when erasing page prior to write
@@ -91,8 +88,9 @@
#define APP_FLASH_STORAGE_PARAMETERS (INTERNAL_FLASH_BASE_ADDRESS + INTERNAL_FLASH_PAGE_SIZE * APP_FLASH_PARAMETERS_PAGE)
// Define storage for power-down detection flag
#define APP_FLASH_POWERDOWN_PAGE (127)
#define APP_FLASH_STORAGE_POWERDOWN (INTERNAL_FLASH_BASE_ADDRESS + INTERNAL_FLASH_PAGE_SIZE * APP_FLASH_POWERDOWN_PAGE)
#define APP_FLASH_POWERLOSS_PAGE (127)
#define APP_FLASH_STORAGE_POWERLOSS (INTERNAL_FLASH_BASE_ADDRESS + INTERNAL_FLASH_PAGE_SIZE * APP_FLASH_POWERLOSS_PAGE)
#define APP_FLASH_POWERLOSS_PAGESIZE (INTERNAL_FLASH_PAGE_SIZE)

View File

@@ -163,6 +163,9 @@ extern void repairMenu_interlockWarning(struct RepairMenu* self, T_INTERLOCK_ID
extern void repairMenu_interlockFailed(struct RepairMenu* self, T_INTERLOCK_ID interlockID);
extern void repairMenu_powerLossDetected(struct RepairMenu* self);
extern void repairMenu_processFailed(struct RepairMenu* self);

View File

@@ -46,7 +46,7 @@
// Type definitions.
// -----------------------------------------------------------------------------
extern struct RepairProcess* const rp;
// -----------------------------------------------------------------------------
// Function declarations

View File

@@ -68,7 +68,7 @@ static void MenuCore_scrollDownIndexHandler(struct MenuCore* self);
// -----------------------------------------------------------------------------
ErrorStatus MenuCore_construct(struct MenuCore* self, struct Display* display, struct KeyboardDevice* keyboardDevice, int taskPriority, uint16_t stackSize, MenuCoreFunctionCall createMenu, MenuCoreFunctionCall stateHandle)
ErrorStatus MenuCore_construct(struct MenuCore* self, struct Display* display, struct KeyboardDevice* keyboardDevice, struct Buzzer* buzzer, int taskPriority, uint16_t stackSize, MenuCoreFunctionCall createMenu, MenuCoreFunctionCall stateHandle)
{
ErrorStatus returnValue = SUCCESS;
@@ -98,6 +98,18 @@ ErrorStatus MenuCore_construct(struct MenuCore* self, struct Display* display, s
}
}
if (returnValue == SUCCESS)
{
if (buzzer->initialized)
{
self->buzzer = buzzer;
}
else
{
returnValue = ERROR;
}
}
if (returnValue == SUCCESS)
{
// Let Task run as soon as it has been created
@@ -225,6 +237,12 @@ static ErrorStatus MenuCore_performAction(struct MenuCore* self, char key, Keypa
struct KeyActionBinding keyAction = MenuCore_findKeyAction(self, key, keyState);
if (keyAction.action != NO_ACTION)
{
// Give audible feedback of valid key
BUZZER_KEYPAD_ACKNOWLEDGE(self->buzzer);
}
switch (keyAction.action)
{
case NO_ACTION:

View File

@@ -0,0 +1,199 @@
// -----------------------------------------------------------------------------
/// @file PowerLossDetector.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 PowerLossDetector.c
/// @ingroup {group_name}
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include "FreeRTOS.h"
#include "task.h"
#include "PowerLossDetector.h"
#include "Logger.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
#define PLD_MASK_FREE (0xFFFFFFFF)
#define PLD_MASK_BUSY (0xDEADC01A)
#define PLD_MASK_USED (0x00000000)
// -----------------------------------------------------------------------------
// Type definitions
// -----------------------------------------------------------------------------
struct PowerLossDetector
{
bool initialized;
bool loaded;
unsigned int pageNumber;
unsigned int startAddress;
unsigned int length;
struct MemoryDevice* memoryDevice;
};
// -----------------------------------------------------------------------------
// File-scope variables
// -----------------------------------------------------------------------------
static struct PowerLossDetector _plDetector = {.initialized = false, .loaded = false};
struct PowerLossDetector* const plDetector = &_plDetector;
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Function definitions
// -----------------------------------------------------------------------------
ErrorStatus PowerLossDetector_construct(struct MemoryDevice* memoryDevice, unsigned int pageNumber, unsigned int startAddress, unsigned int length)
{
ErrorStatus returnValue = SUCCESS;
if (!plDetector->initialized)
{
if (returnValue == SUCCESS)
{
plDetector->pageNumber = pageNumber;
plDetector->startAddress = startAddress;
plDetector->length = length;
}
if (returnValue == SUCCESS)
{
if (memoryDevice != NULL)
{
if (memoryDevice->initialized)
{
plDetector->memoryDevice = memoryDevice;
plDetector->initialized = true;
LOGGER_DEBUG(mainLog, "PowerLossDetector constructed");
}
else
{
returnValue = ERROR;
}
}
else
{
returnValue = ERROR;
}
}
}
else
{
returnValue = ERROR;
}
return returnValue;
}
extern void PowerLossDetector_destruct(void)
{
plDetector->initialized = false;
}
void PowerLossDetector_setBusyFlag(void)
{
bool freeAddressFound = false;
uint32_t buffer;
unsigned int flagAddress;
unsigned int loopcounter;
// Find the first available free address
for (loopcounter = plDetector->startAddress; loopcounter < (plDetector->startAddress + plDetector->length); loopcounter += 4)
{
MemoryDevice_read(plDetector->memoryDevice, &buffer, loopcounter, 1);
if (buffer == PLD_MASK_FREE)
{
// Found free space
flagAddress = loopcounter;
freeAddressFound = true;
LOGGER_DEBUG(mainLog, "Found free address at: %X", loopcounter);
break;
}
}
// In case no free address has been found, the complete page must be cleared
// After clearing, the address to write the busy flag to is equal to the start address
if (!freeAddressFound)
{
MemoryDevice_erasePage(plDetector->memoryDevice, plDetector->pageNumber);
flagAddress = plDetector->startAddress;
}
buffer = PLD_MASK_BUSY;
MemoryDevice_write(plDetector->memoryDevice, &buffer, flagAddress, 1);
}
extern void PowerLossDetector_clearBusyFlag(void)
{
uint32_t buffer;
unsigned int loopcounter;
// Find the first available free address
for (loopcounter = plDetector->startAddress; loopcounter < (plDetector->startAddress + plDetector->length); loopcounter += 4)
{
MemoryDevice_read(plDetector->memoryDevice, &buffer, loopcounter, 1);
if (buffer == PLD_MASK_BUSY)
{
// Found the busy flag
buffer = PLD_MASK_USED;
LOGGER_DEBUG(mainLog, "Found busyFlag at address %X", loopcounter);
MemoryDevice_write(plDetector->memoryDevice, &buffer, loopcounter, 1);
break;
}
}
}
bool PowerLossDetection_isFlagSet(void)
{
bool returnValue = false;
uint32_t buffer;
unsigned int loopcounter;
// Find the first available free address
for (loopcounter = plDetector->startAddress; loopcounter < (plDetector->startAddress + plDetector->length); loopcounter += 4)
{
MemoryDevice_read(plDetector->memoryDevice, &buffer, loopcounter, 1);
if (buffer == PLD_MASK_BUSY)
{
// Found the busy flag
returnValue = true;
LOGGER_DEBUG(mainLog, "Found busyFlag at address %X", loopcounter);
break;
}
}
return returnValue;
}

View File

@@ -81,6 +81,8 @@ ErrorStatus hsb_generateStartScreen(struct Display* Display)
if (returnValue == SUCCESS)
{
Display_setCursorToPosition(mainDisplay, 1, 1);
vTaskDelay(10);
returnValue = Display_write(mainDisplay, PCBA_getInstance()->name, 1, 1);
}
else
@@ -116,29 +118,29 @@ ErrorStatus hsb_enableSafetyWithError(void)
CoverSolenoid_lock();
}
if (returnValue == SUCCESS)
{
// Check for INTERLOCK CLOSE
if (Interlock_isClosed(interlock))
{
// Enable Interrupt for interlock switch
Interlock_setEXTI(interlock, ENABLE);
}
else
{
Error_postError(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 (returnValue == SUCCESS)
// {
// // Check for INTERLOCK CLOSE
// if (Interlock_isClosed(interlock))
// {
// // Enable Interrupt for interlock switch
// Interlock_setEXTI(interlock, ENABLE);
// }
// else
// {
// Error_postError(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 (returnValue == SUCCESS)
{
@@ -162,29 +164,29 @@ ErrorStatus hsb_enableSafetyWithWarning(void)
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 (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 (returnValue == SUCCESS)
{
@@ -202,29 +204,22 @@ ErrorStatus hsb_disableSafety(void)
{
ErrorStatus returnValue = SUCCESS;
int adcR1Value = HSB_SECURITY_VOLTAGE_THRESHOLD;
int adcR2Value = HSB_SECURITY_VOLTAGE_THRESHOLD;
int adcR3Value = HSB_SECURITY_VOLTAGE_THRESHOLD;
if (PCBA_getInstance()->pcba == PCBA_Tesla)
{
TeslaGunSafety_block();
}
// Display_clearScreen(mainDisplay);
char buffer[mainDisplay->displayDevice->parameters.numberOfColumns];
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "WAITING FOR");
Display_write(mainDisplay, buffer, 3, 5);
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "POWER DOWN");
Display_write(mainDisplay, buffer, 4, 6);
// Power-down the DAC outputs
DAConverter_setOutputVoltage(dacRow1, 0);
DAConverter_setOutputVoltage(dacRow2, 0);
DAConverter_setOutputVoltage(dacRow3, 0);
char buffer[mainDisplay->displayDevice->parameters.numberOfColumns];
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "WAITING FOR");
Display_write(mainDisplay, buffer, 3, 5);
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "POWER DOWN");
Display_write(mainDisplay, buffer, 4, 6);
while (HighVoltageDetection_isVoltagePresent())
{

View File

@@ -44,8 +44,10 @@
#include "Error.h"
#include "hsb-mrts.h"
#include "hwValidationMenu.h"
#include "PowerLossDetector.h"
#include "repairMenu.h"
#include "repairMenus.h"
#include "repairProcesses.h"
#include "Warning.h"
#include "CathodeMCP.h"
@@ -150,7 +152,7 @@ static void printSystemInfoTask(void* parameters)
{
LOGGER_INFO(mainLog, "---------------------------------------");
systeminfoCommandHandler();
vTaskDelay(20000);
vTaskDelay(10000);
}
}
@@ -173,9 +175,14 @@ static ErrorStatus systeminfoCommandHandler(void)
vTaskDelay(10);
OS_logTaskInfo(mainMenu->menuCore->taskHandle);
vTaskDelay(10);
OS_logTaskInfo(rp->taskHandle);
vTaskDelay(10);
OS_logTaskInfo(mainDisplay->taskHandle);
vTaskDelay(10);
OS_logTaskInfo(errorTaskHandle);
vTaskDelay(10);
OS_logTaskInfo(mainBuzzer->taskHandle);
@@ -189,13 +196,13 @@ static void initTask(void* parameters)
if (returnValue == SUCCESS)
{
// Create the error handler
Error_construct();
returnValue = Error_construct();
}
if (returnValue == SUCCESS)
{
// Create the warning handler
Warning_construct();
returnValue = Warning_construct();
}
if (returnValue == SUCCESS)
@@ -204,30 +211,36 @@ static void initTask(void* parameters)
// All IO is initialized here
// Also, all periphery and platform-specifics are initialized here
// IRQs are defined here
initPlatform();
returnValue = initPlatform();
}
if (returnValue == SUCCESS)
{
// Construct the displays
Displays_construct();
returnValue = Displays_construct();
}
if (returnValue == SUCCESS)
{
// Construct the powerloss detector
returnValue = PowerLossDetector_construct(&iFlash->memoryDevice, APP_FLASH_POWERLOSS_PAGE, APP_FLASH_STORAGE_POWERLOSS, APP_FLASH_POWERLOSS_PAGESIZE);
}
if (returnValue == SUCCESS)
{
// Construct the AD Converters
ADConverters_construct();
returnValue = ADConverters_construct();
}
if (returnValue == SUCCESS)
{
// Construct the DA Converters
DAConverters_construct();
returnValue = DAConverters_construct();
}
if (returnValue == SUCCESS)
{
hsb_generateStartScreen(mainDisplay);
returnValue = hsb_generateStartScreen(mainDisplay);
// Let start screen stay for 5 seconds
vTaskDelay(INIT_START_SCREEN_DELAY);
}
@@ -235,13 +248,13 @@ static void initTask(void* parameters)
if (returnValue == SUCCESS)
{
// Construct/Load the device parameters
DeviceParameters_construct(&deviceParameters, &iFlash->memoryDevice);
returnValue = DeviceParameters_construct(&deviceParameters, &iFlash->memoryDevice);
}
if (returnValue == SUCCESS)
{
// Construct the repair presets
RepairPresets_construct(&cs, &iFlash->memoryDevice);
returnValue = RepairPresets_construct(&cs, &iFlash->memoryDevice);
}
#ifdef ENABLE_HW_VALIDATION
@@ -278,7 +291,16 @@ static void initTask(void* parameters)
if (returnValue == SUCCESS)
{
// Construct the repair menu
repairMenus_construct();
returnValue = repairMenus_construct();
}
if (PowerLossDetection_isFlagSet())
{
LOGGER_ERROR(mainLog, "Powerloss detection triggered");
Error_postError(ERROR_POWER_LOSS);
returnValue = ERROR;
// Flag may be restored now
PowerLossDetector_clearBusyFlag();
}
// Delete this init task

View File

@@ -31,6 +31,7 @@
#include "DeviceParameters.h"
#include "PIDParameters.h"
#include "PowerLossDetector.h"
#include "repairMenu.h"
#include "repairMenus.h"
#include "RepairPreset.h"
@@ -254,6 +255,13 @@ void repairMenu_interlockFailed(struct RepairMenu* self, T_INTERLOCK_ID interloc
}
void repairMenu_powerLossDetected(struct RepairMenu* self)
{
MenuCore_changeState(self->menuCore, RM_ERROR_STATE);
snprintf(self->menuCore->errorMessage, sizeof(self->menuCore->errorMessage) / sizeof(self->menuCore->errorMessage[0]), MenuText_ERROR_POWER_LOSS[languageIndex]);
}
void repairMenu_processFailed(struct RepairMenu* self)
{
MenuCore_changeState(self->menuCore, RM_ERROR_STATE);
@@ -1012,6 +1020,8 @@ static void repairMenu_startRepairProcess(struct MenuCore* self)
{
// repair process is running
MenuCore_changeState(self, RM_REPAIR_RUNNING);
// Set Flag in FLASH
PowerLossDetector_setBusyFlag();
}
else
{
@@ -1060,9 +1070,17 @@ static void repairMenu_gotoLastState(struct MenuCore* self)
void repairMenu_menuStateHandle(struct MenuCore* self)
{
// Stop the buzzer from recovered error or warning
if ((self->lastMenuState == RM_ERROR_STATE) || (self->lastMenuState == RM_WARNING_STATE))
{
if ((self->menuState != RM_ERROR_STATE) && (self->menuState != RM_WARNING_STATE))
Buzzer_stop(self->buzzer);
}
// Catch ERROR state
if (self->menuState == RM_ERROR_STATE)
{
self->lastMenuState = self->menuState;
// Show ERROR message
repairMenu_printError(self);
// Handle error
@@ -1073,6 +1091,7 @@ void repairMenu_menuStateHandle(struct MenuCore* self)
}
else if (self->menuState == RM_WARNING_STATE)
{
self->lastMenuState = self->menuState;
repairMenu_printWarning(self);
}
@@ -1119,6 +1138,7 @@ void repairMenu_menuStateHandle(struct MenuCore* self)
else if (self->menuState == RM_FINISH_CONTROL)
{
repairMenu_stopRepairProcess(self);
PowerLossDetector_clearBusyFlag();
MenuCore_changeState(self, RM_FINISH);
}
else if (self->menuState == RM_FINISH)

View File

@@ -36,6 +36,7 @@
#include "Warning.h"
#include "platform.h"
#include "Buzzer.h"
#include "Logger.h"
#include "Observable.h"
#include "rtc.h"
@@ -82,13 +83,13 @@ ErrorStatus repairMenus_construct(void)
if (returnValue == SUCCESS)
{
// Create the Menu core
returnValue = MenuCore_construct(menuCore, mainDisplay, &storm700->keyboardDevice, HSB_MAINMENU_TASK_PRIORITY, HSB_MAINMENU_TASK_STACKSIZE, repairMenu_createMenuEntries, repairMenu_menuStateHandle);
returnValue = MenuCore_construct(menuCore, mainDisplay, &storm700->keyboardDevice, mainBuzzer, HSB_MAINMENU_TASK_PRIORITY, HSB_MAINMENU_TASK_STACKSIZE, repairMenu_createMenuEntries, repairMenu_menuStateHandle);
}
if (returnValue == SUCCESS)
{
// Create first repair menu
returnValue = repairMenu_construct(mainMenu, menuCore,&iFlash->memoryDevice, repairMenus_freeMainMenuRepairScreenUpdateSemaphore);
returnValue = repairMenu_construct(mainMenu, menuCore, &iFlash->memoryDevice, repairMenus_freeMainMenuRepairScreenUpdateSemaphore);
}
if (returnValue == SUCCESS)
@@ -124,9 +125,16 @@ static ErrorStatus repairMenus_errorReceive(const void* const data)
switch (errorCode)
{
case ERROR_POWER_LOSS:
{
repairMenu_powerLossDetected(mainMenu);
BUZZER_ERROR(mainBuzzer);
break;
}
case INTERLOCK_COMMON_FAIL:
{
repairMenu_interlockFailed(mainMenu, COMMON_INTERLOCK);
BUZZER_ERROR(mainBuzzer);
break;
}
case POWERENABLE_FAIL:
@@ -136,6 +144,7 @@ static ErrorStatus repairMenus_errorReceive(const void* const data)
case REPAIR_FAIL:
{
repairMenu_processFailed(mainMenu);
BUZZER_ERROR(mainBuzzer);
break;
}
case ERROR_CRC_PIN:
@@ -143,6 +152,7 @@ static ErrorStatus repairMenus_errorReceive(const void* const data)
case ERROR_CRC_PRESETS:
{
repairMenu_printCRCFailure(mainMenu, errorCode);
BUZZER_ERROR(mainBuzzer);
break;
}
default:
@@ -163,6 +173,7 @@ static ErrorStatus repairMenus_warningReceive(const void* const data)
case WARNING_INTERLOCK_COMMON_FAIL:
{
repairMenu_interlockWarning(mainMenu, COMMON_INTERLOCK);
BUZZER_WARNING(mainBuzzer);
break;
}

View File

@@ -266,7 +266,7 @@ static void repairProcess_task(void* parameters)
{
// The current ADC value is outside the error boundaries
self->row[loopCounter].errorData.outOfLimitsCounter += 1;
LOGGER_WARNING(mainLog, "Row %d outside boundaries", loopCounter);
// LOGGER_WARNING(mainLog, "Row %d outside boundaries", loopCounter);
}
else
{
@@ -282,7 +282,7 @@ static void repairProcess_task(void* parameters)
// ROW is in error state
self->row[loopCounter].lastDACValue = 0;
DAConverter_setOutputVoltage(self->row[loopCounter].dacChannel, self->row[loopCounter].lastDACValue);
LOGGER_ERROR(mainLog, "Row %d --- Row in ERROR state", loopCounter);
// LOGGER_ERROR(mainLog, "Row %d --- Row in ERROR state", loopCounter);
}
}
}

View File

@@ -50,6 +50,7 @@
// -----------------------------------------------------------------------------
static struct RepairProcess mainRepairProcess;
struct RepairProcess* const rp = &mainRepairProcess;
// -----------------------------------------------------------------------------
// Function declarations