Corrected menu items

Added all tests except eeprom and keypad

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@243 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
swo
2017-10-06 13:37:21 +00:00
parent e54e15da18
commit 0e69a81570
2 changed files with 285 additions and 130 deletions

View File

@@ -43,12 +43,13 @@
// Constant and macro definitions // Constant and macro definitions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#define ANSI_TERMINAL_RESET "\x1b[2J" #define ANSI_TERMINAL_RESET "\x1b[2J"
#define ANSI_TERMINAL_HOME "\x1b[H" #define ANSI_TERMINAL_HOME "\x1b[H"
#define CON_INF_MAX_MENU_ITEMS (15) #define CON_INF_MAX_MENU_ITEMS (15)
#define HW_VAL_MENU_OUTPUT_BUFFER_SIZE (64)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Type definitions. // Type definitions.
@@ -84,6 +85,7 @@ struct HwValidationMenu
int menuItemSelected; int menuItemSelected;
struct IODevice* ioDevice; struct IODevice* ioDevice;
bool initialized; bool initialized;
char outputBuffer[HW_VAL_MENU_OUTPUT_BUFFER_SIZE];
}; };

View File

@@ -30,6 +30,9 @@
#include "DisplayDevice.h" #include "DisplayDevice.h"
#include "gpio.h" #include "gpio.h"
#include "adc.h" #include "adc.h"
#include "PCBA.h"
#include "MAX5715.h"
#include "nhd0420.h"
#include "Logger.h" #include "Logger.h"
@@ -41,6 +44,8 @@
#define CMD_BUFFER_SIZE (10) #define CMD_BUFFER_SIZE (10)
#define HW_VALIDATION_MENU_DAC_MAX_VALUE (4095)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Type definitions // Type definitions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@@ -50,14 +55,12 @@ typedef enum
CONSOLE_MAIN_MENU, CONSOLE_MAIN_MENU,
CONSOLE_TEST_POWER, CONSOLE_TEST_POWER,
CONSOLE_TEST_DISPLAY, CONSOLE_TEST_DISPLAY,
CONSOLE_TEST_KEYPAD,
CONSOLE_TEST_ADC, CONSOLE_TEST_ADC,
CONSOLE_TEST_DAC, CONSOLE_TEST_DAC,
CONSOLE_TEST_INTERLOCK, CONSOLE_TEST_INTERLOCK,
CONSOLE_TEST_SOLENOID, CONSOLE_TEST_SOLENOID,
CONSOLE_TEST_RELAY, CONSOLE_TEST_RELAY,
CONSOLE_TEST_PCB_VARIANT, CONSOLE_TEST_GENERIC,
CONSOLE_TEST_EEPROM,
CONSOLE_IDLE CONSOLE_IDLE
}Menu_States_t; }Menu_States_t;
@@ -66,14 +69,12 @@ typedef enum
DISPLAY_MENU_MAIN, DISPLAY_MENU_MAIN,
DISPLAY_MENU_POWER, DISPLAY_MENU_POWER,
DISPLAY_MENU_DISPLAY, DISPLAY_MENU_DISPLAY,
DISPLAY_MENU_KEYPAD,
DISPLAY_MENU_ADC, DISPLAY_MENU_ADC,
DISPLAY_MENU_DAC, DISPLAY_MENU_DAC,
DISPLAY_MENU_INTERLOCK, DISPLAY_MENU_INTERLOCK,
DISPLAY_MENU_SOLENOID, DISPLAY_MENU_SOLENOID,
DISPLAY_MENU_RELAY, DISPLAY_MENU_RELAY,
DISPLAY_MENU_PCB_VARIANT, DISPLAY_MENU_GENERIC
DISPLAY_MENU_EEPROM
}Display_States_t; }Display_States_t;
typedef enum typedef enum
@@ -100,37 +101,37 @@ static const char conInfHeader[] =
" \r\n"; " \r\n";
static const char conInfMainMenu[] = static const char conInfMainMenu[] =
ANSI_TERMINAL_RESET
ANSI_TERMINAL_HOME
" MAIN MENU \r\n" " MAIN MENU \r\n"
" Select one of the options: \r\n" " Select one of the options: \r\n"
" [%c] Test Power \r\n" " [%c] Test Power \r\n"
" [%c] Test Display \r\n" " [%c] Test Display \r\n"
" [%c] Test Keypad \r\n"
" [%c] Test ADCs \r\n" " [%c] Test ADCs \r\n"
" [%c] Test DACs \r\n" " [%c] Test DACs \r\n"
" [%c] Test Interlocks \r\n" " [%c] Test Interlocks \r\n"
" [%c] Test Solenoids \r\n" " [%c] Test Solenoids \r\n"
" [%c] Test relays \r\n" " [%c] Test relays \r\n"
" [%c] Test PCB variant \r\n" " [%c] Test Keypad/EEPROM/PCB variant \r\n"
" [%c] Test EEPROM \r\n"
" \r\n"; " \r\n";
enum enum
{ {
MENU_MAIN_POWER, MENU_MAIN_POWER,
MENU_MAIN_DISPLAY, MENU_MAIN_DISPLAY,
MENU_MAIN_KEYPAD,
MENU_MAIN_ADC, MENU_MAIN_ADC,
MENU_MAIN_DAC, MENU_MAIN_DAC,
MENU_MAIN_INTERLOCK, MENU_MAIN_INTERLOCK,
MENU_MAIN_SOLENOID, MENU_MAIN_SOLENOID,
MENU_MAIN_RELAY, MENU_MAIN_RELAY,
MENU_MAIN_PCB_VARIANT, MENU_MAIN_GENERIC,
MENU_MAIN_EEPROM,
MENU_MAIN_LAST MENU_MAIN_LAST
}; };
static const char conTestPower[] = static const char conTestPower[] =
ANSI_TERMINAL_RESET
ANSI_TERMINAL_HOME
" TEST POWER \r\n" " TEST POWER \r\n"
" \r\n" " \r\n"
" Control the 6V5 power supply \r\n" " Control the 6V5 power supply \r\n"
@@ -150,6 +151,8 @@ enum
static const char conTestDisplay[] = static const char conTestDisplay[] =
ANSI_TERMINAL_RESET
ANSI_TERMINAL_HOME
" TEST Display \r\n" " TEST Display \r\n"
" \r\n" " \r\n"
" Test the display and backlight \r\n" " Test the display and backlight \r\n"
@@ -175,6 +178,8 @@ enum
static const char conTestADC[] = static const char conTestADC[] =
ANSI_TERMINAL_RESET
ANSI_TERMINAL_HOME
" TEST ADC[0-2] \r\n" " TEST ADC[0-2] \r\n"
" \r\n" " \r\n"
" Test the ADC channel 0-2 \r\n" " Test the ADC channel 0-2 \r\n"
@@ -195,6 +200,8 @@ enum
}; };
static const char conTestDAC[] = static const char conTestDAC[] =
ANSI_TERMINAL_RESET
ANSI_TERMINAL_HOME
" TEST DAC[0-2] \r\n" " TEST DAC[0-2] \r\n"
" \r\n" " \r\n"
" Test the DAC channel 0-2 \r\n" " Test the DAC channel 0-2 \r\n"
@@ -232,6 +239,8 @@ enum
}; };
static const char conTestInterlock[] = static const char conTestInterlock[] =
ANSI_TERMINAL_RESET
ANSI_TERMINAL_HOME
" TEST Interlock \r\n" " TEST Interlock \r\n"
" \r\n" " \r\n"
" Test the interlock [1-2] \r\n" " Test the interlock [1-2] \r\n"
@@ -250,6 +259,8 @@ enum
}; };
static const char conTestSolenoid[] = static const char conTestSolenoid[] =
ANSI_TERMINAL_RESET
ANSI_TERMINAL_HOME
" TEST Solenoid \r\n" " TEST Solenoid \r\n"
" \r\n" " \r\n"
" Test the interlock [1-2] \r\n" " Test the interlock [1-2] \r\n"
@@ -266,6 +277,8 @@ enum
static const char conTestRelays[] = static const char conTestRelays[] =
ANSI_TERMINAL_RESET
ANSI_TERMINAL_HOME
" TEST Relays \r\n" " TEST Relays \r\n"
" \r\n" " \r\n"
" Test the relays [1-6] \r\n" " Test the relays [1-6] \r\n"
@@ -276,7 +289,6 @@ static const char conTestRelays[] =
" [%c] Toggle Relay 4 \r\n" " [%c] Toggle Relay 4 \r\n"
" [%c] Toggle Relay 5 \r\n" " [%c] Toggle Relay 5 \r\n"
" [%c] Toggle Relay 6 \r\n" " [%c] Toggle Relay 6 \r\n"
" [%c] Clear all relays \r\n"
" [%c] Back \r\n" " [%c] Back \r\n"
" \r\n"; " \r\n";
@@ -288,12 +300,33 @@ enum
MENU_TEST_RELAYS_TOGGLE_4, MENU_TEST_RELAYS_TOGGLE_4,
MENU_TEST_RELAYS_TOGGLE_5, MENU_TEST_RELAYS_TOGGLE_5,
MENU_TEST_RELAYS_TOGGLE_6, MENU_TEST_RELAYS_TOGGLE_6,
MENU_TEST_RELAYS_CLEAR_ALL,
MENU_TEST_RELAYS_BACK, MENU_TEST_RELAYS_BACK,
MENU_TEST_RELAYS_LAST MENU_TEST_RELAYS_LAST
}; };
static const char conTestGeneric[] =
ANSI_TERMINAL_RESET
ANSI_TERMINAL_HOME
" TEST KEYPAD/EEPROM/PCB VARIANT \r\n"
" \r\n"
" Test the relays [1-6] \r\n"
" \r\n"
" [%c] Read keypad \r\n"
" [%c] Test EEPROM \r\n"
" [%c] Get PCB variant \r\n"
" [%c] Back \r\n"
" \r\n";
enum
{
MENU_TEST_GENERIC_KEYPAD,
MENU_TEST_GENERIC_EEPROM,
MENU_TEST_GENERIC_PCB_VARIANT,
MENU_TEST_GENERIC_BACK,
MENU_TEST_GENERIC_LAST
};
@@ -308,6 +341,7 @@ static void hwValidationMenuUpdate( struct HwValidationMenu* self );
static void hwValidationMenuDisplay(struct HwValidationMenu* self, Display_States_t display ); static void hwValidationMenuDisplay(struct HwValidationMenu* self, Display_States_t display );
static ErrorStatus hwValidationMenuReceiveMessage(struct HwValidationMenu* self, uint8_t * pData, uint16_t numBytes ); static ErrorStatus hwValidationMenuReceiveMessage(struct HwValidationMenu* self, uint8_t * pData, uint16_t numBytes );
static ErrorStatus hwValidationMenuSetDac(struct HwValidationMenu* self, struct MAX5715_DAC* dac, uint16_t value);
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Function definitions // Function definitions
@@ -323,6 +357,8 @@ ErrorStatus HwValidationMenu_construct(struct HwValidationMenu* self, struct IOD
{ {
self->ioDevice = ioDevice; self->ioDevice = ioDevice;
self->testItems = testItems;
self->taskPriority = taskPriority; self->taskPriority = taskPriority;
self->stackSize = stackSize; self->stackSize = stackSize;
@@ -417,7 +453,6 @@ void hwValidationMenuUpdate( struct HwValidationMenu* self )
static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t button ) static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t button )
{ {
static Menu_States_t menuState = CONSOLE_IDLE; static Menu_States_t menuState = CONSOLE_IDLE;
char outputBuffer[128];
int outputBufferLength = 0; int outputBufferLength = 0;
switch( menuState ) switch( menuState )
@@ -455,62 +490,50 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
if( self->menuItemSelected == MENU_MAIN_POWER ) if( self->menuItemSelected == MENU_MAIN_POWER )
{ {
self->menuItemSelected = 0; self->menuItemSelected = 0;
menuState = CONSOLE_TEST_DISPLAY; menuState = CONSOLE_TEST_POWER;
hwValidationMenuDisplay(self, DISPLAY_MENU_POWER ); hwValidationMenuDisplay(self, DISPLAY_MENU_POWER );
} }
else if( self->menuItemSelected == MENU_MAIN_POWER )
{
self->menuItemSelected = 0;
menuState = CONSOLE_TEST_DISPLAY;
hwValidationMenuDisplay(self, DISPLAY_MENU_DISPLAY );
}
else if( self->menuItemSelected == MENU_MAIN_DISPLAY) else if( self->menuItemSelected == MENU_MAIN_DISPLAY)
{ {
self->menuItemSelected = 0; self->menuItemSelected = 0;
menuState = CONSOLE_TEST_DISPLAY; menuState = CONSOLE_TEST_DISPLAY;
hwValidationMenuDisplay(self, MENU_MAIN_KEYPAD ); hwValidationMenuDisplay(self, DISPLAY_MENU_DISPLAY );
}
else if( self->menuItemSelected == MENU_MAIN_KEYPAD )
{
self->menuItemSelected = 0;
menuState = CONSOLE_TEST_DISPLAY;
hwValidationMenuDisplay(self, MENU_MAIN_ADC );
} }
else if( self->menuItemSelected == MENU_MAIN_ADC) else if( self->menuItemSelected == MENU_MAIN_ADC)
{ {
self->menuItemSelected = 0; self->menuItemSelected = 0;
menuState = CONSOLE_TEST_DISPLAY; menuState = CONSOLE_TEST_ADC;
hwValidationMenuDisplay(self, DISPLAY_MENU_DAC ); hwValidationMenuDisplay(self, DISPLAY_MENU_ADC );
} }
else if( self->menuItemSelected == MENU_MAIN_DAC ) else if( self->menuItemSelected == MENU_MAIN_DAC )
{ {
self->menuItemSelected = 0; self->menuItemSelected = 0;
menuState = CONSOLE_TEST_DISPLAY; menuState = CONSOLE_TEST_DAC;
hwValidationMenuDisplay(self, DISPLAY_MENU_INTERLOCK ); hwValidationMenuDisplay(self, DISPLAY_MENU_DAC );
} }
else if( self->menuItemSelected == MENU_MAIN_INTERLOCK ) else if( self->menuItemSelected == MENU_MAIN_INTERLOCK )
{ {
self->menuItemSelected = 0; self->menuItemSelected = 0;
menuState = CONSOLE_TEST_DISPLAY; menuState = CONSOLE_TEST_INTERLOCK;
hwValidationMenuDisplay(self, DISPLAY_MENU_SOLENOID ); hwValidationMenuDisplay(self, DISPLAY_MENU_INTERLOCK );
} }
else if( self->menuItemSelected == MENU_MAIN_SOLENOID ) else if( self->menuItemSelected == MENU_MAIN_SOLENOID )
{ {
self->menuItemSelected = 0; self->menuItemSelected = 0;
menuState = CONSOLE_TEST_DISPLAY; menuState = CONSOLE_TEST_SOLENOID;
hwValidationMenuDisplay(self, DISPLAY_MENU_RELAY ); hwValidationMenuDisplay(self, DISPLAY_MENU_SOLENOID );
} }
else if( self->menuItemSelected == MENU_MAIN_RELAY ) else if( self->menuItemSelected == MENU_MAIN_RELAY )
{ {
self->menuItemSelected = 0; self->menuItemSelected = 0;
menuState = CONSOLE_TEST_DISPLAY; menuState = CONSOLE_TEST_RELAY;
hwValidationMenuDisplay(self, DISPLAY_MENU_PCB_VARIANT ); hwValidationMenuDisplay(self, DISPLAY_MENU_RELAY );
} }
else if( self->menuItemSelected == MENU_MAIN_EEPROM ) else if( self->menuItemSelected == MENU_MAIN_GENERIC )
{ {
self->menuItemSelected = 0; self->menuItemSelected = 0;
menuState = CONSOLE_TEST_DISPLAY; menuState = CONSOLE_TEST_GENERIC;
hwValidationMenuDisplay(self, DISPLAY_MENU_EEPROM ); hwValidationMenuDisplay(self, DISPLAY_MENU_GENERIC );
} }
} }
@@ -544,26 +567,26 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
// Turn on 6V5 power ( enable active low ) // Turn on 6V5 power ( enable active low )
if(GPIO_setValue(self->testItems->power6v5Enable, false) == SUCCESS) if(GPIO_setValue(self->testItems->power6v5Enable, false) == SUCCESS)
{ {
outputBufferLength = sprintf(outputBuffer, "Power: Off\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Power: Off\r\n");
} }
else else
{ {
outputBufferLength = sprintf(outputBuffer, "Power: Failure\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Power: Failure\r\n");
} }
IODevice_write(self->ioDevice, outputBuffer, outputBufferLength); IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
} }
else if (self->menuItemSelected == MENU_TEST_POWER_OFF ) else if (self->menuItemSelected == MENU_TEST_POWER_OFF )
{ {
//Turn on 6V5 power ( enable active low ) //Turn on 6V5 power ( enable active low )
if( GPIO_setValue(self->testItems->power6v5Enable, true) == SUCCESS) if( GPIO_setValue(self->testItems->power6v5Enable, true) == SUCCESS)
{ {
outputBufferLength = sprintf(outputBuffer, "Power: Off\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Power: Off\r\n");
} }
else else
{ {
outputBufferLength = sprintf(outputBuffer, "Power: Failure\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Power: Failure\r\n");
} }
IODevice_write(self->ioDevice, outputBuffer, outputBufferLength); IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
} }
else if (self->menuItemSelected == MENU_TEST_POWER_BACK ) else if (self->menuItemSelected == MENU_TEST_POWER_BACK )
{ {
@@ -601,67 +624,67 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
if( self->menuItemSelected == MENU_TEST_DISPLAY_BL_10) if( self->menuItemSelected == MENU_TEST_DISPLAY_BL_10)
{ {
// Set display backlight to 10% // Set display backlight to 10%
if( DisplayDevice_setBrightness(self->testItems->display, 10) == SUCCESS) if( DisplayDevice_setBrightness(self->testItems->display, 1) == SUCCESS)
{ {
outputBufferLength = sprintf(outputBuffer, "Display: bl set to 10%%\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Display: bl set to 10%%\r\n");
} }
else else
{ {
outputBufferLength = sprintf(outputBuffer, "Display: failed to set bl\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Display: failed to set bl\r\n");
} }
IODevice_write(self->ioDevice, outputBuffer, outputBufferLength); IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
} }
else if (self->menuItemSelected == MENU_TEST_DISPLAY_BL_50 ) else if (self->menuItemSelected == MENU_TEST_DISPLAY_BL_50 )
{ {
// Set display backlight to 50% // Set display backlight to 50%
if( DisplayDevice_setBrightness(self->testItems->display, 50) == SUCCESS) if( DisplayDevice_setBrightness(self->testItems->display, 4) == SUCCESS)
{ {
outputBufferLength = sprintf(outputBuffer, "Display: bl set to 50%%\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Display: bl set to 50%%\r\n");
} }
else else
{ {
outputBufferLength = sprintf(outputBuffer, "Display: failed to set bl\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Display: failed to set bl\r\n");
} }
IODevice_write(self->ioDevice, outputBuffer, outputBufferLength); IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
} }
else if (self->menuItemSelected == MENU_TEST_DISPLAY_BL_100 ) else if (self->menuItemSelected == MENU_TEST_DISPLAY_BL_100 )
{ {
// Set display backlight to 100% // Set display backlight to 100%
if( DisplayDevice_setBrightness(self->testItems->display, 100) == SUCCESS) if( DisplayDevice_setBrightness(self->testItems->display, 8) == SUCCESS)
{ {
outputBufferLength = sprintf(outputBuffer, "Display: bl set to 100%%\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Display: bl set to 100%%\r\n");
} }
else else
{ {
outputBufferLength = sprintf(outputBuffer, "Display: failed to set bl\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Display: failed to set bl\r\n");
} }
IODevice_write(self->ioDevice, outputBuffer, outputBufferLength); IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
} }
else if (self->menuItemSelected == MENU_TEST_DISPLAY_SHOW_TEXT ) else if (self->menuItemSelected == MENU_TEST_DISPLAY_SHOW_TEXT )
{ {
const char buffer[] = "Display Test Text"; const char buffer[] = "Display Test Text";
if( DisplayDevice_write(self->testItems->display, buffer, sizeof(buffer), 2, 2) == SUCCESS) if( DisplayDevice_write(self->testItems->display, buffer, sizeof(buffer), 2, 2) == SUCCESS)
{ {
outputBufferLength = sprintf(outputBuffer, "Display: text written\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Display: text written\r\n");
} }
else else
{ {
outputBufferLength = sprintf(outputBuffer, "Display: write failed\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Display: write failed\r\n");
} }
IODevice_write(self->ioDevice, outputBuffer, outputBufferLength); IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
} }
else if (self->menuItemSelected == MENU_TEST_DISPLAY_CLEAR_DISPLAY ) else if (self->menuItemSelected == MENU_TEST_DISPLAY_CLEAR_DISPLAY )
{ {
// Clear display // Clear display
if( DisplayDevice_clear(self->testItems->display) == SUCCESS) if( DisplayDevice_clear(self->testItems->display) == SUCCESS)
{ {
outputBufferLength = sprintf(outputBuffer, "Display: cleared\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Display: cleared\r\n");
} }
else else
{ {
outputBufferLength = sprintf(outputBuffer, "Display: Clear failed\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Display: Clear failed\r\n");
} }
IODevice_write(self->ioDevice, outputBuffer, outputBufferLength); IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
} }
else if (self->menuItemSelected == MENU_TEST_DISPLAY_BACK ) else if (self->menuItemSelected == MENU_TEST_DISPLAY_BACK )
{ {
@@ -674,10 +697,12 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
break; break;
case CONSOLE_TEST_KEYPAD: // case CONSOLE_TEST_KEYPAD:
// No sub items // outputBufferLength = sprintf(self->outputBuffer, "[TODO] KEYPAD TEST\r\n");
// TODO: Implement test // IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
break; // // No sub items
// // TODO: Implement test
// break;
case CONSOLE_TEST_ADC: case CONSOLE_TEST_ADC:
if( button == BUTTON_UP ) if( button == BUTTON_UP )
@@ -705,37 +730,37 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
{ {
if(ADCChannel_read(&self->testItems->internalADC->channel[0], &adcValue) == SUCCESS) if(ADCChannel_read(&self->testItems->internalADC->channel[0], &adcValue) == SUCCESS)
{ {
outputBufferLength = sprintf(outputBuffer, "ADC0 value:%d\r\n", adcValue); outputBufferLength = sprintf(self->outputBuffer, "ADC0 value:%d\r\n", adcValue);
} }
else else
{ {
outputBufferLength = sprintf(outputBuffer, "ADC0: failed to read\r\n"); outputBufferLength = sprintf(self->outputBuffer, "ADC0: failed to read\r\n");
} }
IODevice_write(self->ioDevice, outputBuffer, outputBufferLength); IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
} }
else if (self->menuItemSelected == MENU_TEST_ADC_CH_1 ) else if (self->menuItemSelected == MENU_TEST_ADC_CH_1 )
{ {
if(ADCChannel_read(&self->testItems->internalADC->channel[0], &adcValue) == SUCCESS) if(ADCChannel_read(&self->testItems->internalADC->channel[1], &adcValue) == SUCCESS)
{ {
outputBufferLength = sprintf(outputBuffer, "ADC1 value:%d\r\n", adcValue); outputBufferLength = sprintf(self->outputBuffer, "ADC1 value:%d\r\n", adcValue);
} }
else else
{ {
outputBufferLength = sprintf(outputBuffer, "ADC1: failed to read\r\n"); outputBufferLength = sprintf(self->outputBuffer, "ADC1: failed to read\r\n");
} }
IODevice_write(self->ioDevice, outputBuffer, outputBufferLength); IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
} }
else if (self->menuItemSelected == MENU_TEST_ADC_CH_2 ) else if (self->menuItemSelected == MENU_TEST_ADC_CH_2 )
{ {
if(ADCChannel_read(&self->testItems->internalADC->channel[2], &adcValue) == SUCCESS) if(ADCChannel_read(&self->testItems->internalADC->channel[2], &adcValue) == SUCCESS)
{ {
outputBufferLength = sprintf(outputBuffer, "ADC2 value:%d\r\n", adcValue); outputBufferLength = sprintf(self->outputBuffer, "ADC2 value:%d\r\n", adcValue);
} }
else else
{ {
outputBufferLength = sprintf(outputBuffer, "ADC2: failed to read\r\n"); outputBufferLength = sprintf(self->outputBuffer, "ADC2: failed to read\r\n");
} }
IODevice_write(self->ioDevice, outputBuffer, outputBufferLength); IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
} }
else if (self->menuItemSelected == MENU_TEST_ADC_BACK ) else if (self->menuItemSelected == MENU_TEST_ADC_BACK )
{ {
@@ -751,73 +776,73 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
if( button == BUTTON_UP ) if( button == BUTTON_UP )
{ {
if( self->menuItemSelected == 0 ) if( self->menuItemSelected == 0 )
self->menuItemSelected = (MENU_TEST_ADC_LAST - 1); self->menuItemSelected = (MENU_TEST_DAC_LAST - 1);
else else
self->menuItemSelected--; self->menuItemSelected--;
hwValidationMenuDisplay(self, DISPLAY_MENU_ADC ); hwValidationMenuDisplay(self, DISPLAY_MENU_DAC );
} }
else if( button == BUTTON_DOWN ) else if( button == BUTTON_DOWN )
{ {
if( self->menuItemSelected == (MENU_TEST_ADC_LAST - 1) ) if( self->menuItemSelected == (MENU_TEST_DAC_LAST - 1) )
self->menuItemSelected = 0; self->menuItemSelected = 0;
else else
self->menuItemSelected++; self->menuItemSelected++;
hwValidationMenuDisplay(self, DISPLAY_MENU_ADC ); hwValidationMenuDisplay(self, DISPLAY_MENU_DAC );
} }
else if( button == BUTTON_ENTER ) else if( button == BUTTON_ENTER )
{ {
// DAC 0 // DAC 0
if( self->menuItemSelected == MENU_TEST_DAC_CH_0_0V0) if( self->menuItemSelected == MENU_TEST_DAC_CH_0_0V0)
{ {
hwValidationMenuSetDac(self, &self->testItems->externalDAC->dac[0], 0);
} }
else if (self->menuItemSelected == MENU_TEST_DAC_CH_0_1V25 ) else if (self->menuItemSelected == MENU_TEST_DAC_CH_0_1V25 )
{ {
//TODO: Implement test hwValidationMenuSetDac(self, &self->testItems->externalDAC->dac[0], HW_VALIDATION_MENU_DAC_MAX_VALUE / 4);
} }
else if (self->menuItemSelected == MENU_TEST_DAC_CH_0_2V5 ) else if (self->menuItemSelected == MENU_TEST_DAC_CH_0_2V5 )
{ {
//TODO: Implement test hwValidationMenuSetDac(self, &self->testItems->externalDAC->dac[0], HW_VALIDATION_MENU_DAC_MAX_VALUE / 2);
} }
else if (self->menuItemSelected == MENU_TEST_DAC_CH_0_5V0 ) else if (self->menuItemSelected == MENU_TEST_DAC_CH_0_5V0 )
{ {
//TODO: Implement test hwValidationMenuSetDac(self, &self->testItems->externalDAC->dac[0], HW_VALIDATION_MENU_DAC_MAX_VALUE);
} }
// DAC 1 // DAC 1
else if( self->menuItemSelected == MENU_TEST_DAC_CH_1_0V0) else if( self->menuItemSelected == MENU_TEST_DAC_CH_1_0V0)
{ {
//TODO: Implement test hwValidationMenuSetDac(self, &self->testItems->externalDAC->dac[1], 0);
} }
else if (self->menuItemSelected == MENU_TEST_DAC_CH_1_1V25 ) else if (self->menuItemSelected == MENU_TEST_DAC_CH_1_1V25 )
{ {
//TODO: Implement test hwValidationMenuSetDac(self, &self->testItems->externalDAC->dac[1], HW_VALIDATION_MENU_DAC_MAX_VALUE / 4);
} }
else if (self->menuItemSelected == MENU_TEST_DAC_CH_1_2V5 ) else if (self->menuItemSelected == MENU_TEST_DAC_CH_1_2V5 )
{ {
//TODO: Implement test hwValidationMenuSetDac(self, &self->testItems->externalDAC->dac[1], HW_VALIDATION_MENU_DAC_MAX_VALUE / 2);
} }
else if (self->menuItemSelected == MENU_TEST_DAC_CH_1_5V0 ) else if (self->menuItemSelected == MENU_TEST_DAC_CH_1_5V0 )
{ {
//TODO: Implement test hwValidationMenuSetDac(self, &self->testItems->externalDAC->dac[1], HW_VALIDATION_MENU_DAC_MAX_VALUE);
} }
// DAC 2 // DAC 2
else if( self->menuItemSelected == MENU_TEST_DAC_CH_2_0V0) else if( self->menuItemSelected == MENU_TEST_DAC_CH_2_0V0)
{ {
//TODO: Implement test hwValidationMenuSetDac(self, &self->testItems->externalDAC->dac[2], 0);
} }
else if (self->menuItemSelected == MENU_TEST_DAC_CH_2_1V25 ) else if (self->menuItemSelected == MENU_TEST_DAC_CH_2_1V25 )
{ {
//TODO: Implement test hwValidationMenuSetDac(self, &self->testItems->externalDAC->dac[2], HW_VALIDATION_MENU_DAC_MAX_VALUE / 4);
} }
else if (self->menuItemSelected == MENU_TEST_DAC_CH_2_2V5 ) else if (self->menuItemSelected == MENU_TEST_DAC_CH_2_2V5 )
{ {
//TODO: Implement test hwValidationMenuSetDac(self, &self->testItems->externalDAC->dac[2], HW_VALIDATION_MENU_DAC_MAX_VALUE / 2);
} }
else if (self->menuItemSelected == MENU_TEST_DAC_CH_2_5V0 ) else if (self->menuItemSelected == MENU_TEST_DAC_CH_2_5V0 )
{ {
//TODO: Implement test hwValidationMenuSetDac(self, &self->testItems->externalDAC->dac[2], HW_VALIDATION_MENU_DAC_MAX_VALUE);
} }
else if (self->menuItemSelected == MENU_TEST_DAC_BACK) else if (self->menuItemSelected == MENU_TEST_DAC_BACK)
{ {
@@ -854,24 +879,24 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
if( self->menuItemSelected == MENU_TEST_INTERLOCK_1) if( self->menuItemSelected == MENU_TEST_INTERLOCK_1)
{ {
if( GPIO_getValue(self->testItems->interlock1, &value) == SUCCESS ){ if( GPIO_getValue(self->testItems->interlock1, &value) == SUCCESS ){
outputBufferLength = sprintf(outputBuffer, "Interlock: %d\r\n", value); outputBufferLength = sprintf(self->outputBuffer, "Interlock: %d\r\n", value);
} }
else else
{ {
outputBufferLength = sprintf(outputBuffer, "Interlock: Failure\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Interlock: Failure\r\n");
} }
IODevice_write(self->ioDevice, outputBuffer, outputBufferLength); IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
} }
else if (self->menuItemSelected == MENU_TEST_INTERLOCK_2 ) else if (self->menuItemSelected == MENU_TEST_INTERLOCK_2 )
{ {
if( GPIO_getValue(self->testItems->interlock2, &value) == SUCCESS ){ if( GPIO_getValue(self->testItems->interlock2, &value) == SUCCESS ){
outputBufferLength = sprintf(outputBuffer, "Interlock: %d\r\n", value); outputBufferLength = sprintf(self->outputBuffer, "Interlock: %d\r\n", value);
} }
else else
{ {
outputBufferLength = sprintf(outputBuffer, "Interlock: Failure\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Interlock: Failure\r\n");
} }
IODevice_write(self->ioDevice, outputBuffer, outputBufferLength); IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
} }
else if (self->menuItemSelected == MENU_TEST_INTERLOCK_BACK ) else if (self->menuItemSelected == MENU_TEST_INTERLOCK_BACK )
{ {
@@ -913,18 +938,18 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
value = !value; value = !value;
if( GPIO_setValue(self->testItems->interlock1, value) == SUCCESS) if( GPIO_setValue(self->testItems->interlock1, value) == SUCCESS)
{ {
outputBufferLength = sprintf(outputBuffer, "Solenoid: Toggled\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Solenoid: Toggled\r\n");
} }
else else
{ {
outputBufferLength = sprintf(outputBuffer, "Solenoid: Failed to set value\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Solenoid: Failed to set value\r\n");
} }
} }
else else
{ {
outputBufferLength = sprintf(outputBuffer, "Solenoid: Failed to get value\r\n"); outputBufferLength = sprintf(self->outputBuffer, "Solenoid: Failed to get value\r\n");
} }
IODevice_write(self->ioDevice, outputBuffer, outputBufferLength); IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
} }
else if (self->menuItemSelected == MENU_TEST_SOLENOID_BACK ) else if (self->menuItemSelected == MENU_TEST_SOLENOID_BACK )
{ {
@@ -959,33 +984,59 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
{ {
struct Gpio* relay = NULL; struct Gpio* relay = NULL;
bool value = false;
if( (self->menuItemSelected >= MENU_TEST_RELAYS_TOGGLE_1) && (self->menuItemSelected <= MENU_TEST_RELAYS_TOGGLE_6) ) if( (self->menuItemSelected >= MENU_TEST_RELAYS_TOGGLE_1) && (self->menuItemSelected <= MENU_TEST_RELAYS_TOGGLE_6) )
{ {
switch(self->menuItemSelected) switch(self->menuItemSelected)
{ {
case MENU_TEST_RELAYS_TOGGLE_1: case MENU_TEST_RELAYS_TOGGLE_1:
relay = self->testItems->mcp0Relay;
break; break;
case MENU_TEST_RELAYS_TOGGLE_2: case MENU_TEST_RELAYS_TOGGLE_2:
relay = self->testItems->mcp1Relay;
break; break;
case MENU_TEST_RELAYS_TOGGLE_3: case MENU_TEST_RELAYS_TOGGLE_3:
relay = self->testItems->mcp2Relay;
break; break;
case MENU_TEST_RELAYS_TOGGLE_4: case MENU_TEST_RELAYS_TOGGLE_4:
relay = self->testItems->cat0Relay;
break; break;
case MENU_TEST_RELAYS_TOGGLE_5: case MENU_TEST_RELAYS_TOGGLE_5:
relay = self->testItems->cat1Relay;
break; break;
case MENU_TEST_RELAYS_TOGGLE_6: case MENU_TEST_RELAYS_TOGGLE_6:
relay = self->testItems->cat1Relay;
break;
default:
relay = NULL;
break; break;
} }
if( GPIO_getValue(relay, &value) == SUCCESS )
{
value = !value;
if(GPIO_setValue(relay, value) == SUCCESS)
{
outputBufferLength = sprintf(self->outputBuffer, "Relay: set value to: %d\r\n", value);
}
else
{
outputBufferLength = sprintf(self->outputBuffer, "Relay: Failed to set value\r\n");
}
}
else
{
outputBufferLength = sprintf(self->outputBuffer, "Relay: Failed to get current value\r\n");
} }
else if( self->menuItemSelected == MENU_TEST_RELAYS_CLEAR_ALL) IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
{
//TODO: Implement test
} }
else if (self->menuItemSelected == MENU_TEST_RELAYS_BACK ) else if (self->menuItemSelected == MENU_TEST_RELAYS_BACK )
{ {
@@ -997,14 +1048,74 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
} }
break; break;
case CONSOLE_TEST_PCB_VARIANT: // case CONSOLE_TEST_PCB_VARIANT:
// No sub test
//TODO: implement test
break;
case CONSOLE_TEST_EEPROM: // if(self->testItems->pcba)
// No sub test // {
//TODO: implement test // const struct Pcba* pcba = self->testItems->pcba;
// outputBufferLength = sprintf(self->outputBuffer, "PCBA: %d - %s\r\n", (int)pcba->pcba, pcba->name);
// }
// IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
// break;
// case CONSOLE_TEST_EEPROM:
// // No sub test
// //TODO: implement test
// outputBufferLength = sprintf(self->outputBuffer, "[TODO] EEPROM TEST\r\n");
// IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
// break;
case CONSOLE_TEST_GENERIC:
if( button == BUTTON_UP )
{
if( self->menuItemSelected == 0 )
self->menuItemSelected = (MENU_TEST_GENERIC_LAST- 1);
else
self->menuItemSelected--;
hwValidationMenuDisplay(self, DISPLAY_MENU_GENERIC );
}
else if( button == BUTTON_DOWN )
{
if( self->menuItemSelected == (MENU_TEST_GENERIC_LAST - 1) )
self->menuItemSelected = 0;
else
self->menuItemSelected++;
hwValidationMenuDisplay(self, DISPLAY_MENU_GENERIC );
}
else if( button == BUTTON_ENTER )
{
bool value = false;
if( self->menuItemSelected == MENU_TEST_GENERIC_KEYPAD)
{
outputBufferLength = sprintf(self->outputBuffer, "[TODO] KEYPAD TEST\r\n");
IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
}
else if( self->menuItemSelected == MENU_TEST_GENERIC_EEPROM)
{
outputBufferLength = sprintf(self->outputBuffer, "[TODO] EEPROM TEST\r\n");
IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
}
else if( self->menuItemSelected == MENU_TEST_GENERIC_PCB_VARIANT)
{
if(self->testItems->pcba)
{
const struct Pcba* pcba = self->testItems->pcba;
outputBufferLength = sprintf(self->outputBuffer, "PCBA: %d - %s\r\n", (int)pcba->pcba, pcba->name);
}
IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
}
else if (self->menuItemSelected == MENU_TEST_GENERIC_BACK )
{
// Back to main menu
self->menuItemSelected = 0;
menuState = CONSOLE_MAIN_MENU;
hwValidationMenuDisplay(self, DISPLAY_MENU_MAIN );
}
}
break; break;
default: default:
@@ -1037,14 +1148,12 @@ static void hwValidationMenuDisplay(struct HwValidationMenu* self, Display_State
menu_length = sprintf( menuBuffer, conInfMainMenu, menu_length = sprintf( menuBuffer, conInfMainMenu,
menuItems[MENU_MAIN_POWER], menuItems[MENU_MAIN_POWER],
menuItems[MENU_MAIN_DISPLAY], menuItems[MENU_MAIN_DISPLAY],
menuItems[MENU_MAIN_KEYPAD],
menuItems[MENU_MAIN_ADC], menuItems[MENU_MAIN_ADC],
menuItems[MENU_MAIN_DAC], menuItems[MENU_MAIN_DAC],
menuItems[MENU_MAIN_INTERLOCK], menuItems[MENU_MAIN_INTERLOCK],
menuItems[MENU_MAIN_SOLENOID], menuItems[MENU_MAIN_SOLENOID],
menuItems[MENU_MAIN_RELAY], menuItems[MENU_MAIN_RELAY],
menuItems[MENU_MAIN_PCB_VARIANT], menuItems[MENU_MAIN_GENERIC]
menuItems[MENU_MAIN_EEPROM]
); );
// Write message to debout interface // Write message to debout interface
@@ -1094,9 +1203,6 @@ static void hwValidationMenuDisplay(struct HwValidationMenu* self, Display_State
break; break;
//case DISPLAY_MENU_KEYPAD:
//break;
case DISPLAY_MENU_ADC: case DISPLAY_MENU_ADC:
// Put an asterisk (*) at the selected item in the menu // Put an asterisk (*) at the selected item in the menu
for( menuIndex = 0; menuIndex < MENU_TEST_ADC_LAST; menuIndex++ ) for( menuIndex = 0; menuIndex < MENU_TEST_ADC_LAST; menuIndex++ )
@@ -1201,7 +1307,6 @@ static void hwValidationMenuDisplay(struct HwValidationMenu* self, Display_State
menuItems[MENU_TEST_RELAYS_TOGGLE_4], menuItems[MENU_TEST_RELAYS_TOGGLE_4],
menuItems[MENU_TEST_RELAYS_TOGGLE_5], menuItems[MENU_TEST_RELAYS_TOGGLE_5],
menuItems[MENU_TEST_RELAYS_TOGGLE_6], menuItems[MENU_TEST_RELAYS_TOGGLE_6],
menuItems[MENU_TEST_RELAYS_CLEAR_ALL],
menuItems[MENU_TEST_RELAYS_BACK] menuItems[MENU_TEST_RELAYS_BACK]
); );
@@ -1209,12 +1314,37 @@ static void hwValidationMenuDisplay(struct HwValidationMenu* self, Display_State
IODevice_write(self->ioDevice, relayMenuBuffer, menu_length); IODevice_write(self->ioDevice, relayMenuBuffer, menu_length);
break; break;
// case DISPLAY_MENU_KEYPAD:
// break;
// case DISPLAY_MENU_PCB_VARIANT: // case DISPLAY_MENU_PCB_VARIANT:
// break; // break;
// case DISPLAY_MENU_EEPROM: // case DISPLAY_MENU_EEPROM:
// break; // break;
case DISPLAY_MENU_GENERIC:
// Put an asterisk (*) at the selected item in the menu
for( menuIndex = 0; menuIndex < MENU_TEST_GENERIC_LAST; menuIndex++ )
{
MENU_DRAW_SELECTED(menuIndex);
}
// Fill buffer with menu items
char genericMenuBuffer[ sizeof( conTestGeneric) ];
menu_length = sprintf( genericMenuBuffer, conTestGeneric,
menuItems[MENU_TEST_GENERIC_KEYPAD],
menuItems[MENU_TEST_GENERIC_EEPROM],
menuItems[MENU_TEST_GENERIC_PCB_VARIANT],
menuItems[MENU_TEST_GENERIC_BACK]
);
// Write message to debout interface
IODevice_write(self->ioDevice, genericMenuBuffer, menu_length);
break;
default: default:
//Do nothing //Do nothing
break; break;
@@ -1241,7 +1371,30 @@ static ErrorStatus hwValidationMenuReceiveMessage(struct HwValidationMenu* self,
returnValue = ERROR; returnValue = ERROR;
break; break;
} }
vTaskDelay(1);
} }
return returnValue; return returnValue;
} }
static ErrorStatus hwValidationMenuSetDac(struct HwValidationMenu* self, struct MAX5715_DAC* dac, uint16_t value)
{
int outputBufferLength = 0;
ErrorStatus returnValue = SUCCESS;
if( MAX5715Channel_setValue(dac, value) == SUCCESS)
{
outputBufferLength = sprintf(self->outputBuffer, "DAC: Set to %d\r\n", value);
}
else
{
outputBufferLength = sprintf(self->outputBuffer, "DAC: Failed to set\r\n");
returnValue = ERROR;
}
IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
return returnValue;
}