Going on with structure
Added observer/observable for RTC git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@251 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -13,9 +13,11 @@ sysmem.o \
|
||||
startup_stm32f10x_cl.o \
|
||||
\
|
||||
Display.o \
|
||||
Displays.o \
|
||||
FreeRTOSFixes.o \
|
||||
hwValidationMenu.o \
|
||||
repairMenu.o \
|
||||
repairMenus.o \
|
||||
repairProcess.o \
|
||||
\
|
||||
heap_2.o\
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file Displays.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 Displays.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
#ifndef DISPLAYS_H_
|
||||
#define DISPLAYS_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "Display.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
extern struct Display* const mainDisplay;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Displays_construct
|
||||
* Constructor for all displays
|
||||
*
|
||||
* @return ErrorStatus
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus Displays_construct(void);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Displays_destruct
|
||||
* Destructor for all displays
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern void Displays_destruct(void);
|
||||
#endif /* DISPLAYS_H_ */
|
||||
@@ -0,0 +1,72 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file hsb-mrts.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 hsb-mrts.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
#ifndef HSB_MRTS_H_
|
||||
#define HSB_MRTS_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define HSB_MAINMENU_TASK_PRIORITY (2)
|
||||
#define HSB_MAINMENU_TASK_STACKSIZE (1024)
|
||||
|
||||
#define HSB_MAINDISP_TASK_PRIORITY (2)
|
||||
#define HSB_MAINDISP_TASK_STACKSIZE (512)
|
||||
|
||||
|
||||
// Exports of objects on application level
|
||||
extern struct Display* const mainDisplay;
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* hsb_generateStartScreen
|
||||
* Description of function
|
||||
*
|
||||
* @param Display
|
||||
* @param
|
||||
* @return ErrorStatus
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus hsb_generateStartScreen(struct Display* Display);
|
||||
#endif /* HSB_MRTS_H_ */
|
||||
@@ -49,6 +49,14 @@
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MAINMENU,
|
||||
REPAIRMENU
|
||||
} T_MenuState;
|
||||
|
||||
struct RepairMenu
|
||||
{
|
||||
TaskHandle_t taskHandle;
|
||||
@@ -58,6 +66,7 @@ struct RepairMenu
|
||||
SemaphoreHandle_t secondsSyncronisation;
|
||||
bool initialized;
|
||||
struct Display* display;
|
||||
T_MenuState menuState;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file repairMenus.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 repairMenus.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
#ifndef REPAIRMENUS_H_
|
||||
#define REPAIRMENUS_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* repairMenus_construct
|
||||
* Constructor for repair menus
|
||||
*
|
||||
* @return ErrorStatus
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus repairMenus_construct(void);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* repairMenus_destruct
|
||||
* Destructor for repair menus
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern void repairMenus_destruct(void);
|
||||
|
||||
|
||||
#endif /* REPAIRMENUS_H_ */
|
||||
@@ -0,0 +1,113 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file Displays.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 Displays.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "stm32f10x.h"
|
||||
#include "Displays.h"
|
||||
#include "hsb-mrts.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "nhd0420.h"
|
||||
#include "rtc.h"
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define MAINDISP_MAX_CHAR_CHUNK (10)
|
||||
#define MAINDISP_REFRESH_FEED_MS (1000)
|
||||
#define MAINDISP_REFRESH_PERIOD (5000)
|
||||
|
||||
#define MAINDISP_DEFAULT_BRIGHTNESS (5)
|
||||
#define MAINDISP_DEFAULT_CONTRAST (40)
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static struct Display _mainDisplay = {.initialized = false};
|
||||
struct Display* const mainDisplay = &_mainDisplay;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static ErrorStatus Displays_mainDisplayObserverFromISR(const void* const data);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ErrorStatus Displays_construct(void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = Display_construct(mainDisplay, &nhd0420->displayDevice, HSB_MAINDISP_TASK_PRIORITY, HSB_MAINDISP_TASK_STACKSIZE, MAINDISP_MAX_CHAR_CHUNK, MAINDISP_REFRESH_FEED_MS, MAINDISP_REFRESH_PERIOD);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = Observable_addObserver(RTC_getObservable(rtc), Displays_mainDisplayObserverFromISR);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = Display_clearScreen(mainDisplay);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = Display_setBrightness(mainDisplay, MAINDISP_DEFAULT_BRIGHTNESS);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = Display_setContrast(mainDisplay, MAINDISP_DEFAULT_CONTRAST);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
extern void Displays_destruct(void)
|
||||
{
|
||||
Observable_deleteObserver(RTC_getObservable(rtc), Displays_mainDisplayObserverFromISR);
|
||||
Display_destruct(mainDisplay);
|
||||
}
|
||||
|
||||
|
||||
static ErrorStatus Displays_mainDisplayObserverFromISR(const void* const data)
|
||||
{
|
||||
Display_feedRefreshCounter(mainDisplay);
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file hsb-mrts.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 hsb-mrts.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "hsb-mrts.h"
|
||||
|
||||
#include "Display.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "PCBA.h"
|
||||
#include "Version.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
ErrorStatus hsb_generateStartScreen(struct Display* Display)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = Display_write(mainDisplay, pcba->name, strlen(pcba->name), 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
char buffer[20];
|
||||
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "SW V. %d.%d.%d.%d", Version_getInstance()->major,
|
||||
Version_getInstance()->minor,
|
||||
Version_getInstance()->branch,
|
||||
Version_getInstance()->patch);
|
||||
Display_write(mainDisplay, buffer, strlen(buffer), 3, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
@@ -33,9 +33,11 @@
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
#include "Display.h"
|
||||
#include "Displays.h"
|
||||
#include "hsb-mrts.h"
|
||||
#include "hwValidationMenu.h"
|
||||
#include "repairMenu.h"
|
||||
#include "repairMenus.h"
|
||||
#include "repairProcess.h"
|
||||
|
||||
#include "misc.h"
|
||||
@@ -45,9 +47,9 @@
|
||||
#include "KeyboardDevice.h"
|
||||
#include "MAX5715.h"
|
||||
#include "nhd0420.h"
|
||||
#include "storm700.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "Interlock.h"
|
||||
#include "internalADC.h"
|
||||
#include "gpio.h"
|
||||
#include "IODevice.h"
|
||||
@@ -57,7 +59,6 @@
|
||||
#include "uart.h"
|
||||
#include "spi.h"
|
||||
#include "spiDevice.h"
|
||||
#include "Version.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
@@ -91,23 +92,13 @@ static xTaskHandle initTaskHandle;
|
||||
static xTaskHandle ledTaskHandle;
|
||||
static xTaskHandle sysTaskHandle;
|
||||
|
||||
static struct Display _display = {.initialized = false};
|
||||
struct Display* display = &_display;
|
||||
|
||||
static struct NHD0420 nhd0420 = {.initialized = false};
|
||||
static struct MAX5715 max5715 = {.initialized = false};
|
||||
|
||||
static struct RepairMenu _rm = {.initialized = false};
|
||||
static struct HwValidationMenu _hwValidation = {.initialized = false};
|
||||
static struct HwValidationMenuItems hwTestItems;
|
||||
|
||||
struct MAX5715* dac = &max5715;
|
||||
|
||||
struct RepairMenu* rm = &_rm;
|
||||
|
||||
struct HwValidationMenu* hwValidation = &_hwValidation;
|
||||
|
||||
static struct Storm700 _storm700 = {.initialized = false};
|
||||
struct Storm700* storm700 = &_storm700;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
@@ -175,72 +166,35 @@ static ErrorStatus systeminfoCommandHandler(void)
|
||||
OS_logTaskInfo(ledTaskHandle);
|
||||
vTaskDelay(10);
|
||||
OS_logTaskInfo(sysTaskHandle);
|
||||
vTaskDelay(10);
|
||||
OS_logTaskInfo(display->taskHandle);
|
||||
vTaskDelay(10);
|
||||
OS_logTaskInfo(mainLog->taskHandle);
|
||||
vTaskDelay(10);
|
||||
OS_logTaskInfo(keypad->taskHandle);
|
||||
vTaskDelay(10);
|
||||
// OS_logTaskInfo(rp->taskHandle);
|
||||
vTaskDelay(10);
|
||||
OS_logTaskInfo(rm->taskHandle);
|
||||
vTaskDelay(10);
|
||||
OS_logTaskInfo(hwValidation->taskHandle);
|
||||
|
||||
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
static void initTask(void* parameters)
|
||||
{
|
||||
// Initialize the platform first
|
||||
// All IO is initialized here
|
||||
// Also, all periphery and platform-specifics are initialized here
|
||||
// IRQs are defined here
|
||||
initPlatform();
|
||||
|
||||
// Create a small task that only blinks a LED and flashes the identification letter on the display
|
||||
xTaskCreate(ledBlinkTask, (const char* const)"ledTask", 100, &ledTaskArguments, 0, &ledTaskHandle);
|
||||
|
||||
Logger_construct(mainLog, &uart1->device, 1, 512);
|
||||
|
||||
Storm700_construct(storm700, &keypad->device);
|
||||
|
||||
NHD0420_construct(&nhd0420, &spiDisplay->device);
|
||||
|
||||
Display_construct(display, &nhd0420.displayDevice, 2, 256, 10, 1000, 10000);
|
||||
|
||||
Display_clearScreen(display);
|
||||
|
||||
Display_setBrightness(display, 6);
|
||||
|
||||
Display_setContrast(display, 40);
|
||||
|
||||
Display_write(display, pcba->name, strlen(pcba->name), 1, 1);
|
||||
|
||||
char buffer[20];
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "SW V. %d.%d.%d.%d", Version_getInstance()->major,
|
||||
Version_getInstance()->minor,
|
||||
Version_getInstance()->branch,
|
||||
Version_getInstance()->patch);
|
||||
Display_write(display, buffer, strlen(buffer), 3, 4);
|
||||
|
||||
MAX5715_construct(&max5715, &spiDAC->device);
|
||||
|
||||
MAX5715_writeREF_ON_2V5(&max5715);
|
||||
|
||||
MAX5715_writePOWER_NORMAL(&max5715, MAX5715_SEL_DACA | MAX5715_SEL_DACB | MAX5715_SEL_DACC);
|
||||
|
||||
MAX5715_writeCONFIG_LATCH_OFF(&max5715, MAX5715_SEL_DACA | MAX5715_SEL_DACB | MAX5715_SEL_DACC);
|
||||
|
||||
MAX5715Channel_construct(&dac->dac[0], dac, 0);
|
||||
MAX5715Channel_construct(&dac->dac[1], dac, 1);
|
||||
MAX5715Channel_construct(&dac->dac[2], dac, 2);
|
||||
// Construct the displays
|
||||
Displays_construct();
|
||||
|
||||
// xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 0, &sysTaskHandle);
|
||||
|
||||
hsb_generateStartScreen(mainDisplay);
|
||||
// Let start screen stay for 5 seconds
|
||||
vTaskDelay(INIT_START_SCREEN_DELAY);
|
||||
|
||||
|
||||
hwTestItems.display = &nhd0420.displayDevice;
|
||||
hwTestItems.display = &nhd0420->displayDevice;
|
||||
hwTestItems.internalADC = adc1;
|
||||
hwTestItems.externalDAC = &max5715;
|
||||
hwTestItems.externalDAC = max5715;
|
||||
hwTestItems.power6v5Enable = power6v5Enable;
|
||||
hwTestItems.interlockNO = interlockNO;
|
||||
hwTestItems.interlockNC = interlockNC;
|
||||
@@ -258,8 +212,14 @@ static void initTask(void* parameters)
|
||||
// EEPROM TO BE DONE
|
||||
// HwValidationMenu_construct(hwValidation, &uart1->device, &hwTestItems, 1, 1024);
|
||||
|
||||
Interlock_setEXTI(interlock, ENABLE);
|
||||
if (PCBA_getInstance()->pcba == Tesla)
|
||||
{
|
||||
Interlock_setEXTI(teslalock, ENABLE);
|
||||
}
|
||||
|
||||
// Construct the repair menu
|
||||
repairMenu_construct(rm, display, 2, 512);
|
||||
repairMenus_construct();
|
||||
|
||||
// Delete this init task
|
||||
vTaskDelete(NULL);
|
||||
@@ -276,10 +236,10 @@ static void ledBlinkTask (void* parameters)
|
||||
while (1)
|
||||
{
|
||||
IODevice_write(&gpio->device, &high, 1);
|
||||
Display_write(display, pcba->name, 1, 1, 20);
|
||||
Display_write(mainDisplay, pcba->name, 1, 1, 20);
|
||||
vTaskDelay(configTICK_RATE_HZ / (frequency * 2));
|
||||
IODevice_write(&gpio->device, &low, 1);
|
||||
Display_write(display, " ", 1, 1, 20);
|
||||
Display_write(mainDisplay, " ", 1, 1, 20);
|
||||
vTaskDelay(configTICK_RATE_HZ / (frequency * 2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "MAX5715.h"
|
||||
|
||||
#include "KeyboardDevice.h"
|
||||
#include "PCBA.h"
|
||||
#include "storm700.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -45,6 +46,11 @@
|
||||
|
||||
|
||||
|
||||
//static const char menuMain[4][20] =
|
||||
// " 1.Tube repair"
|
||||
// " 2.Operator"
|
||||
// " 3.Calibration";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -62,6 +68,9 @@
|
||||
|
||||
static void repairMenu_task(void* parameters);
|
||||
|
||||
static void repairMenu_selectMenu(struct RepairMenu* self, char key);
|
||||
static void repairMenu_printMenu(struct RepairMenu* self);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -90,6 +99,7 @@ ErrorStatus repairMenu_construct(struct RepairMenu* self, struct Display* displa
|
||||
self->runTask = true;
|
||||
self->initialized = true;
|
||||
self->display = display;
|
||||
self->menuState = MAINMENU;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -120,6 +130,7 @@ void repairMenu_feedSecondsCounter(struct RepairMenu* self)
|
||||
|
||||
}
|
||||
|
||||
|
||||
void repairMenu_feedSecondsCounterFromISR(struct RepairMenu* self)
|
||||
{
|
||||
portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||
@@ -134,73 +145,66 @@ void repairMenu_feedSecondsCounterFromISR(struct RepairMenu* self)
|
||||
}
|
||||
|
||||
|
||||
static struct RepairProcess _rp = {.initialized = false};
|
||||
struct RepairProcess* rp = &_rp;
|
||||
extern struct MAX5715* dac;
|
||||
extern struct Storm700* storm700;
|
||||
static void repairMenu_task(void* parameters)
|
||||
{
|
||||
struct RepairMenu* self = (struct RepairMenu*)parameters;
|
||||
|
||||
Display_clearLine(self->display, 3);
|
||||
|
||||
struct RepairProcessParameters rpParameters;
|
||||
rpParameters.adcRow1 = &adc1->channel[0];
|
||||
rpParameters.adcRow2 = &adc1->channel[1];
|
||||
rpParameters.adcRow3 = &adc1->channel[2];
|
||||
rpParameters.dacRow1 = &dac->dac[0];
|
||||
rpParameters.dacRow2 = &dac->dac[1];
|
||||
rpParameters.dacRow3 = &dac->dac[2];
|
||||
|
||||
// struct RepairPresetParameters presetStage1 = {.voltage = 0xE00, .duration = 300, .softstartDuration = 120};
|
||||
// struct RepairPresetParameters presetStage2 = {.voltage = 0x600, .duration = 120, .softstartDuration = 30};
|
||||
|
||||
struct RepairPresetParameters presetStage1 = {.voltage = 0xE00, .duration = 7200, .softstartDuration = 1800};
|
||||
struct RepairPresetParameters presetStage2 = {.voltage = 0x600, .duration = 1800, .softstartDuration = 900};
|
||||
|
||||
struct RepairPreset repairPreset;
|
||||
repairPreset.numberOfStages = 2;
|
||||
repairPreset.preset[0] = presetStage1;
|
||||
repairPreset.preset[1] = presetStage2;
|
||||
|
||||
rp->repairPreset = &repairPreset;
|
||||
|
||||
repairProcess_construct(rp, &rpParameters, 2, 512);
|
||||
|
||||
|
||||
while(self->runTask)
|
||||
{
|
||||
xSemaphoreTake(self->secondsSyncronisation, portMAX_DELAY);
|
||||
|
||||
uint32_t secondsCounter;
|
||||
repairProcess_getRepairTime(rp, &secondsCounter);
|
||||
int hours = (secondsCounter / (60 * 60));
|
||||
int minutes = (secondsCounter - (hours * 60 * 60)) / 60;
|
||||
int seconds = (secondsCounter - (hours * 60 * 60) - (minutes * 60));
|
||||
char buffer[20];
|
||||
snprintf (buffer, sizeof(buffer) / sizeof(buffer[0]), "%02d:%02d:%02d", hours, minutes, seconds);
|
||||
Display_write(self->display, buffer, strlen(buffer), 2, 7);
|
||||
|
||||
Display_write(self->display, "R1", strlen("R1"), 3, 3);
|
||||
Display_write(self->display, "R2", strlen("R2"), 3, 10);
|
||||
Display_write(self->display, "R3", strlen("R3"), 3, 17);
|
||||
|
||||
uint16_t value;
|
||||
ADCChannel_read(rp->adc[0], &value);
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%04xV", value);
|
||||
Display_write(self->display, buffer, strlen(buffer), 4, 1);
|
||||
|
||||
ADCChannel_read(rp->adc[1], &value);
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%04xV", value);
|
||||
Display_write(self->display, buffer, strlen(buffer), 4, 8);
|
||||
|
||||
ADCChannel_read(rp->adc[2], &value);
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%04xV", value);
|
||||
Display_write(self->display, buffer, strlen(buffer), 4, 15);
|
||||
|
||||
char key;
|
||||
Keypad_KeyState keyState;
|
||||
|
||||
// Get a new key from keyboard
|
||||
if (KeyboardDevice_read(&storm700->keyboardDevice, &key, &keyState) == SUCCESS)
|
||||
{
|
||||
// New key read
|
||||
if (keyState == RELEASED)
|
||||
{
|
||||
LOGGER_INFO(mainLog, "Key %c is released", key);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_INFO(mainLog, "Key %c is pressed", key);
|
||||
}
|
||||
}
|
||||
vTaskDelay(100);
|
||||
}
|
||||
|
||||
LOGGER_INFO(mainLog, "Deleting RepairMenu task");
|
||||
vTaskDelete(self->taskHandle);
|
||||
}
|
||||
|
||||
|
||||
static void repairMenu_selectMenu(struct RepairMenu* self, char key)
|
||||
{
|
||||
switch (self->menuState)
|
||||
{
|
||||
case MAINMENU:
|
||||
{
|
||||
repairMenu_printMenu(self);
|
||||
break;
|
||||
}
|
||||
case REPAIRMENU:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void repairMenu_printMenu(struct RepairMenu* self)
|
||||
{
|
||||
switch (self->menuState)
|
||||
{
|
||||
case MAINMENU:
|
||||
{
|
||||
Display_write(self->display, PCBA_getInstance()->name, strlen(PCBA_getInstance()->name), 1, 1);
|
||||
break;
|
||||
}
|
||||
case REPAIRMENU:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file repairMenus.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 repairMenus.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "hsb-mrts.h"
|
||||
|
||||
#include "repairMenus.h"
|
||||
#include "repairMenu.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "Observable.h"
|
||||
#include "rtc.h"
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static struct RepairMenu _mainMenu = {.initialized = false};
|
||||
struct RepairMenu* const mainMenu = &_mainMenu;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static ErrorStatus repairMenus_mainMenuObserverFromISR(const void* const data);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
//TODO REMOVE
|
||||
extern struct Display* display;
|
||||
ErrorStatus repairMenus_construct(void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
// Create first repair menu
|
||||
returnValue = repairMenu_construct(mainMenu, mainDisplay, HSB_MAINMENU_TASK_PRIORITY, HSB_MAINMENU_TASK_STACKSIZE);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = Observable_addObserver(RTC_getObservable(rtc), repairMenus_mainMenuObserverFromISR);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void repairMenus_destruct(void)
|
||||
{
|
||||
Observable_deleteObserver(RTC_getObservable(rtc), repairMenus_mainMenuObserverFromISR);
|
||||
repairMenu_destruct(mainMenu);
|
||||
}
|
||||
|
||||
|
||||
static ErrorStatus repairMenus_mainMenuObserverFromISR(const void* const data)
|
||||
{
|
||||
repairMenu_feedSecondsCounterFromISR(mainMenu);
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -238,14 +238,11 @@ static int SignalProfileGenerator(struct RepairProcess* self)
|
||||
{
|
||||
case PREPARE:
|
||||
{
|
||||
LOGGER_DEBUG(mainLog, "Repair Process: Preparing new stage of repair process");
|
||||
// Prepare a new repair process
|
||||
//Load the timers
|
||||
self->startTime = self->secondsCounter;
|
||||
self->softStartTimer = self->secondsCounter + self->repairPreset->preset[self->currentPresetIndex].softstartDuration;
|
||||
LOGGER_DEBUG(mainLog, "Softstart timer is %d (%d + %d)", self->softStartTimer, self->secondsCounter, self->repairPreset->preset[self->currentPresetIndex].softstartDuration);
|
||||
self->voltageHoldTimer = self->secondsCounter + self->repairPreset->preset[self->currentPresetIndex].duration;
|
||||
LOGGER_DEBUG(mainLog, "Voltagehold timer is %d (%d + %d)", self->voltageHoldTimer, self->secondsCounter, self->repairPreset->preset[self->currentPresetIndex].duration);
|
||||
|
||||
self->currentState = SOFTSTART;
|
||||
|
||||
@@ -309,12 +306,10 @@ static int SignalProfileGenerator(struct RepairProcess* self)
|
||||
// A next stage is available
|
||||
self->currentPresetIndex++;
|
||||
self->currentState = PREPARE;
|
||||
LOGGER_DEBUG(mainLog, "Another stage is available");
|
||||
}
|
||||
else
|
||||
{
|
||||
self->currentState = FINISHED;
|
||||
LOGGER_DEBUG(mainLog, "last stage reached");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "queue.h"
|
||||
#include "semphr.h"
|
||||
|
||||
#include "hsb-mrts.h"
|
||||
#include "stm32f10x_it.h"
|
||||
|
||||
#include "stm32f10x_exti.h"
|
||||
@@ -53,12 +54,12 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -231,7 +232,26 @@ void SPI3_IRQHandler (void)
|
||||
}
|
||||
|
||||
|
||||
void EXTI0_IRQHandler(void)
|
||||
{
|
||||
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
EXTI_ClearITPendingBit(EXTI_Line0);
|
||||
LOGGER_ERROR_ISR(mainLog, "EXTI0 IRQ TRIGGERED");
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
|
||||
void EXTI1_IRQHandler(void)
|
||||
{
|
||||
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
EXTI_ClearITPendingBit(EXTI_Line1);
|
||||
LOGGER_ERROR_ISR(mainLog, "EXTI1 IRQ TRIGGERED");
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
|
||||
void EXTI4_IRQHandler(void)
|
||||
@@ -274,15 +294,47 @@ void EXTI9_5_IRQHandler (void)
|
||||
else if (EXTI_GetITStatus(EXTI_Line9) != RESET)
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line9);
|
||||
LOGGER_ERROR_ISR(mainLog, "EXTI9 IRQ TRIGGERED");
|
||||
}
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
|
||||
void EXTI15_10_IRQHandler (void)
|
||||
{
|
||||
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
if (EXTI_GetITStatus(EXTI_Line10) != RESET)
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line10);
|
||||
LOGGER_ERROR_ISR(mainLog, "EXTI10 IRQ TRIGGERED");
|
||||
}
|
||||
else if (EXTI_GetITStatus(EXTI_Line11) != RESET)
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line11);
|
||||
}
|
||||
else if (EXTI_GetITStatus(EXTI_Line12) != RESET)
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line12);
|
||||
}
|
||||
else if (EXTI_GetITStatus(EXTI_Line13) != RESET)
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line13);
|
||||
}
|
||||
else if (EXTI_GetITStatus(EXTI_Line14) != RESET)
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line14);
|
||||
}
|
||||
else if (EXTI_GetITStatus(EXTI_Line15) != RESET)
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line15);
|
||||
}
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
|
||||
extern struct Display* display;
|
||||
extern struct RepairProcess* rp;
|
||||
extern struct RepairMenu* rm;
|
||||
|
||||
void RTC_IRQHandler(void)
|
||||
{
|
||||
@@ -294,9 +346,8 @@ void RTC_IRQHandler(void)
|
||||
RTC_ClearITPendingBit(RTC_IT_SEC);
|
||||
|
||||
xSemaphoreGiveFromISR(rtc->secondSync, &higherPriorityTaskWoken);
|
||||
Display_feedRefreshCounter(display);
|
||||
repairProcess_feedSecondsCounterFromISR(rp);
|
||||
repairMenu_feedSecondsCounterFromISR(rm);
|
||||
|
||||
Observable_notifyObservers(RTC_getObservable(rtc), NULL);
|
||||
|
||||
|
||||
/* Wait until last write operation on RTC registers has finished */
|
||||
|
||||
Reference in New Issue
Block a user