Added some IO modules (teslaGun, solenoid, powerEnable) as dedicated modules instead of general IO
Fixed code behind them git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@266 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -108,7 +108,7 @@ static int calculateVoltage(const struct ADConverter* self, uint32_t adcValue)
|
||||
returnValue = returnValue / maxAdcValue;
|
||||
returnValue = returnValue + self->minVoltage;
|
||||
|
||||
LOGGER_DEBUG(mainLog, "%X, %d, %d, %d", adcValue, self->maxVoltage, self->minVoltage, returnValue);
|
||||
LOGGER_DEBUG(mainLog, "%X, %d, %d, %d", (unsigned int)adcValue, self->maxVoltage, self->minVoltage, returnValue);
|
||||
// if (returnValue < self->minVoltage)
|
||||
// {
|
||||
// returnValue = self->minVoltage;
|
||||
|
||||
@@ -105,7 +105,7 @@ void SignalProfileGenerator_calculate(struct SignalProfileGenerator* self)
|
||||
self->softStartTimer = self->secondsCounter + self->repairPreset->preset[self->currentPresetIndex].softstartDuration;
|
||||
self->voltageHoldTimer = self->secondsCounter + self->repairPreset->preset[self->currentPresetIndex].duration;
|
||||
|
||||
LOGGER_DEBUG(mainLog, "startTime %d - softStartTime %d - HoldTimer %d", self->startTime, self->softStartTimer, self->voltageHoldTimer);
|
||||
LOGGER_DEBUG(mainLog, "startTime %d - softStartTime %d - HoldTimer %d", (unsigned int)self->startTime, (unsigned int)self->softStartTimer, (unsigned int)self->voltageHoldTimer);
|
||||
|
||||
// If first preset, start voltage is 0
|
||||
if (self->currentPresetIndex == 0)
|
||||
|
||||
@@ -33,9 +33,11 @@
|
||||
#include "Error.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "CoverSolenoid.h"
|
||||
#include "Interlock.h"
|
||||
#include "Logger.h"
|
||||
#include "PCBA.h"
|
||||
#include "Power6V5Supply.h"
|
||||
#include "Version.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -97,16 +99,6 @@ ErrorStatus hsb_generateStartScreen(struct Display* Display)
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus hsb_solenoidLock (void)
|
||||
{
|
||||
return GPIO_setValue(solenoid, false);
|
||||
}
|
||||
|
||||
ErrorStatus hsb_solenoidUnlock (void)
|
||||
{
|
||||
return GPIO_setValue(solenoid, true);
|
||||
}
|
||||
|
||||
ErrorStatus hsb_enableSafety(void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
@@ -114,7 +106,7 @@ ErrorStatus hsb_enableSafety(void)
|
||||
// First, Lock the cover
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
hsb_solenoidLock();
|
||||
CoverSolenoid_lock();
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
@@ -132,33 +124,11 @@ ErrorStatus hsb_enableSafety(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
// TESLA has a second interlock that must be closed
|
||||
if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||
{
|
||||
if (Interlock_isClosed(teslalock))
|
||||
{
|
||||
// Enable Interrupt for tesla interlock switch
|
||||
Interlock_setEXTI(teslalock, ENABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
Error_postError(INTERLOCK_TESLA_FAIL);
|
||||
returnValue = ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if Interlock(s) closed, continue procedure
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
// Power the circuit
|
||||
if (GPIO_setValue(power6v5Enable, false) != SUCCESS)
|
||||
{
|
||||
Error_postError(POWERENABLE_FAIL);
|
||||
returnValue = ERROR;
|
||||
}
|
||||
Power6V5Supply_on();
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
@@ -168,19 +138,10 @@ ErrorStatus hsb_disableSafety(void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
// Power the circuit
|
||||
if (GPIO_setValue(power6v5Enable, true) != SUCCESS)
|
||||
{
|
||||
Error_postError(POWERENABLE_FAIL);
|
||||
returnValue = ERROR;
|
||||
}
|
||||
// Un-Power the circuit
|
||||
Power6V5Supply_off();
|
||||
|
||||
Interlock_setEXTI(interlock, DISABLE);
|
||||
// TESLA has a second interlock that must be closed
|
||||
if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||
{
|
||||
Interlock_setEXTI(teslalock, DISABLE);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@@ -172,8 +172,6 @@ static ErrorStatus systeminfoCommandHandler(void)
|
||||
vTaskDelay(10);
|
||||
OS_logTaskInfo(interlock->taskHandle);
|
||||
vTaskDelay(10);
|
||||
OS_logTaskInfo(teslalock->taskHandle);
|
||||
vTaskDelay(10);
|
||||
OS_logTaskInfo(keypad->taskHandle);
|
||||
vTaskDelay(10);
|
||||
OS_logTaskInfo(mainDisplay->taskHandle);
|
||||
@@ -197,9 +195,6 @@ static void initTask(void* parameters)
|
||||
// IRQs are defined here
|
||||
initPlatform();
|
||||
|
||||
// Disable power
|
||||
GPIO_setValue(power6v5Enable, false);
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -217,39 +212,28 @@ static void initTask(void* parameters)
|
||||
vTaskDelay(INIT_START_SCREEN_DELAY);
|
||||
|
||||
|
||||
hwTestItems.display = &nhd0420->displayDevice;
|
||||
hwTestItems.internalADC = adc1;
|
||||
hwTestItems.externalDAC = max5715;
|
||||
hwTestItems.power6v5Enable = power6v5Enable;
|
||||
hwTestItems.interlockNO = interlockNO;
|
||||
hwTestItems.interlockNC = interlockNC;
|
||||
hwTestItems.teslaNO = teslaNO;
|
||||
hwTestItems.teslaNC = teslaNC;
|
||||
hwTestItems.solenoid = solenoid;
|
||||
hwTestItems.mcp0Relay = mcp0Relay;
|
||||
hwTestItems.mcp1Relay = mcp1Relay;
|
||||
hwTestItems.mcp2Relay = mcp2Relay;
|
||||
hwTestItems.cat0Relay = cat0Relay;
|
||||
hwTestItems.cat1Relay = cat1Relay;
|
||||
hwTestItems.cat2Relay = cat2Relay;
|
||||
hwTestItems.pcba = PCBA_getInstance();
|
||||
hwTestItems.keypad = keypad;
|
||||
///TODO MUST BE UPDATED
|
||||
// hwTestItems.display = &nhd0420->displayDevice;
|
||||
// hwTestItems.internalADC = adc1;
|
||||
// hwTestItems.externalDAC = max5715;
|
||||
// hwTestItems.power6v5Enable = power6v5Enable;
|
||||
// hwTestItems.interlockNO = interlockNO;
|
||||
// hwTestItems.interlockNC = interlockNC;
|
||||
// hwTestItems.solenoid = solenoid;
|
||||
// hwTestItems.mcp0Relay = mcp0Relay;
|
||||
// hwTestItems.mcp1Relay = mcp1Relay;
|
||||
// hwTestItems.mcp2Relay = mcp2Relay;
|
||||
// hwTestItems.cat0Relay = cat0Relay;
|
||||
// hwTestItems.cat1Relay = cat1Relay;
|
||||
// hwTestItems.cat2Relay = cat2Relay;
|
||||
// hwTestItems.pcba = PCBA_getInstance();
|
||||
// hwTestItems.keypad = keypad;
|
||||
// EEPROM TO BE DONE
|
||||
// HwValidationMenu_construct(hwValidation, &uart1->device, &hwTestItems, 1, 1024);
|
||||
|
||||
// Construct the repair menu
|
||||
repairMenus_construct();
|
||||
|
||||
// DAConverter_setOutputVoltage(dacRow1, -500);
|
||||
// DAConverter_setOutputVoltage(dacRow2, -400);
|
||||
// DAConverter_setOutputVoltage(dacRow3, -300);
|
||||
//
|
||||
// while (1)
|
||||
// {
|
||||
// LOGGER_DEBUG(mainLog, "%i %i %i", ADConverter_getInputVoltage(adcRow1), ADConverter_getInputVoltage(adcRow2), ADConverter_getInputVoltage(adcRow3));
|
||||
// vTaskDelay(1000);
|
||||
// }
|
||||
|
||||
|
||||
// xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 0, &sysTaskHandle);
|
||||
|
||||
|
||||
@@ -38,10 +38,12 @@
|
||||
#include "Error.h"
|
||||
#include "hsb-mrts.h"
|
||||
|
||||
#include "CoverSolenoid.h"
|
||||
#include "Logger.h"
|
||||
#include "Interlock.h"
|
||||
#include "internalADC.h"
|
||||
#include "MAX5715.h"
|
||||
#include "TeslaGunSafety.h"
|
||||
|
||||
#include "KeyboardDevice.h"
|
||||
#include "PCBA.h"
|
||||
@@ -268,10 +270,6 @@ void repairMenu_interlockFailed(struct RepairMenu* self, T_INTERLOCK_ID interloc
|
||||
{
|
||||
snprintf(self->errorMessage, sizeof(self->errorMessage) / sizeof(self->errorMessage[0]), "COVER OPEN");
|
||||
}
|
||||
else if (interlockID == TESLA_INTERLOCK)
|
||||
{
|
||||
snprintf(self->errorMessage, sizeof(self->errorMessage) / sizeof(self->errorMessage[0]), "SAFETY TUBE MISSING");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -676,13 +674,13 @@ static void repairMenu_selectPreset(struct RepairMenu* self, int cursorIndex)
|
||||
|
||||
static void repairMenu_solenoidLock(struct RepairMenu* self, int cursorIndex)
|
||||
{
|
||||
hsb_solenoidLock();
|
||||
CoverSolenoid_lock();
|
||||
}
|
||||
|
||||
|
||||
static void repairMenu_solenoidUnlock(struct RepairMenu* self, int cursorIndex)
|
||||
{
|
||||
hsb_solenoidUnlock();
|
||||
CoverSolenoid_unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -704,12 +702,11 @@ static void repairMenu_startRepairProcess(struct RepairMenu* self, int cursorInd
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
// For MCP/Cathode, the right settings must be made
|
||||
if (PCBA_getInstance()->pcba == PCBA_CathodeMCP)
|
||||
// In case of a TESLA repair, release the teslaGunSafety
|
||||
if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||
{
|
||||
|
||||
TeslaGunSafety_release();
|
||||
}
|
||||
///TODO
|
||||
}
|
||||
|
||||
// If all is OK, start the repair process
|
||||
@@ -741,6 +738,10 @@ static void repairMenu_startRepairProcess(struct RepairMenu* self, int cursorInd
|
||||
|
||||
static void repairMenu_stopRepairProcess(struct RepairMenu* self, int cursorIndex)
|
||||
{
|
||||
if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||
{
|
||||
TeslaGunSafety_block();
|
||||
}
|
||||
repairProcesses_mainRepairProcessRemoveObserver(self->observer);
|
||||
repairProcesses_abortMainRepairProcess();
|
||||
hsb_disableSafety();
|
||||
|
||||
@@ -110,10 +110,6 @@ static ErrorStatus repairMenu_errorReceive(const void* const data)
|
||||
{
|
||||
repairMenu_interlockFailed(mainMenu, COMMON_INTERLOCK);
|
||||
}
|
||||
else if (errorCode == INTERLOCK_TESLA_FAIL)
|
||||
{
|
||||
repairMenu_interlockFailed(mainMenu, TESLA_INTERLOCK);
|
||||
}
|
||||
else if (errorCode == POWERENABLE_FAIL)
|
||||
{
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "Interlock.h"
|
||||
#include "Logger.h"
|
||||
#include "PCBA.h"
|
||||
#include "Power6V5Supply.h"
|
||||
#include "rtc.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -79,13 +80,9 @@ ErrorStatus repairProcesses_startMainRepairProcess(const struct RepairPreset* re
|
||||
void repairProcesses_abortMainRepairProcess(void)
|
||||
{
|
||||
Interlock_setEXTI(interlock, DISABLE);
|
||||
if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||
{
|
||||
Interlock_setEXTI(teslalock, DISABLE);
|
||||
}
|
||||
|
||||
// DISABLE external power
|
||||
GPIO_setValue(power6v5Enable, true);
|
||||
Power6V5Supply_off();
|
||||
|
||||
repairProcess_destruct(&mainRepairProcess);
|
||||
Observable_deleteObserver(RTC_getObservable(rtc), repairProcesses_feedMainRepairProcessSecondsCounter);
|
||||
|
||||
@@ -295,44 +295,9 @@ void EXTI9_5_IRQHandler (void)
|
||||
else if (EXTI_GetITStatus(EXTI_Line9) != RESET)
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line9);
|
||||
|
||||
xSemaphoreGiveFromISR(teslalock->semaphore, &higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
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);
|
||||
xSemaphoreGiveFromISR(teslalock->semaphore, &higherPriorityTaskWoken);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user