diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/.settings/language.settings.xml b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/.settings/language.settings.xml index 9f8c89a..019e756 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/.settings/language.settings.xml +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/Leds.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/Leds.h index 6ee1d1f..282c704 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/Leds.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/Leds.h @@ -120,4 +120,6 @@ extern void Led_off(Led led); */ extern bool Led_getStatus(Led led); + + #endif /* INC_LEDS_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/Leds.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/Leds.c index f9c94ed..1dce736 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/Leds.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/Leds.c @@ -191,3 +191,4 @@ extern bool Led_getStatus(Led led) } return returnValue; } + diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/platform.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/platform.h index ea5883b..06611a9 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/platform.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/platform.h @@ -83,7 +83,21 @@ extern struct Storm700* const storm700; // internal FLASH extern struct InternalFlash* const iFlash; // Export of GPIOs +extern struct Gpio* const ledBicolourGreen; +extern struct Gpio* const ledBicolourRed; +extern struct Gpio* const solenoid; +extern struct Gpio* const buzzer; +extern struct Gpio* const mcp0Relay; +extern struct Gpio* const mcp1Relay; +extern struct Gpio* const mcp2Relay; +extern struct Gpio* const cat0Relay; +extern struct Gpio* const cat1Relay; +extern struct Gpio* const cat2Relay; +extern struct Gpio* const teslaRelay; +extern struct Gpio* const hv0Present; +extern struct Gpio* const hv1Present; +extern struct Gpio* const hv2Present; extern struct Interlock* const interlock; diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/keypadMatrix.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/keypadMatrix.c index 58f2306..1a5e90d 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/keypadMatrix.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/keypadMatrix.c @@ -127,66 +127,66 @@ ErrorStatus Keypad_construct(struct Keypad* self, size_t numberOfRows, size_t nu LOGGER_INFO(mainLog, "Keypad task started"); self->initialized = true; -// // TUBE REPAIR -// struct KeypadQueueItem rxQueueItem; -// rxQueueItem.rowCoordinate = 0; -// rxQueueItem.columnCoordinate = 0; -// rxQueueItem.keyEvent = PRESSED; -// // Put event in queue -// xQueueSend(self->rxQueue, &rxQueueItem, 0); -// rxQueueItem.rowCoordinate = 0; -// rxQueueItem.columnCoordinate = 0; -// rxQueueItem.keyEvent = RELEASED; -// // Put event in queue -// xQueueSend(self->rxQueue, &rxQueueItem, 0); -// -// // SELECT CATHODE -// rxQueueItem.rowCoordinate = 0; -// rxQueueItem.columnCoordinate = 0; -// rxQueueItem.keyEvent = PRESSED; -// // Put event in queue -// xQueueSend(self->rxQueue, &rxQueueItem, 0); -// rxQueueItem.rowCoordinate = 0; -// rxQueueItem.columnCoordinate = 0; -// rxQueueItem.keyEvent = RELEASED; -// // Put event in queue -// xQueueSend(self->rxQueue, &rxQueueItem, 0); -// -// // SELECT PRESET -// rxQueueItem.rowCoordinate = 0; -// rxQueueItem.columnCoordinate = 0; -// rxQueueItem.keyEvent = PRESSED; -// // Put event in queue -// xQueueSend(self->rxQueue, &rxQueueItem, 0); -// rxQueueItem.rowCoordinate = 0; -// rxQueueItem.columnCoordinate = 0; -// rxQueueItem.keyEvent = RELEASED; -// // Put event in queue -// xQueueSend(self->rxQueue, &rxQueueItem, 0); -// -// // SELECT PRESET 7 -// rxQueueItem.rowCoordinate = 2; -// rxQueueItem.columnCoordinate = 0; -// rxQueueItem.keyEvent = PRESSED; -// // Put event in queue -// xQueueSend(self->rxQueue, &rxQueueItem, 0); -// rxQueueItem.rowCoordinate = 2; -// rxQueueItem.columnCoordinate = 0; -// rxQueueItem.keyEvent = RELEASED; -// // Put event in queue -// xQueueSend(self->rxQueue, &rxQueueItem, 0); -// -// // START -// rxQueueItem.rowCoordinate = 0; -// rxQueueItem.columnCoordinate = 1; -// rxQueueItem.keyEvent = PRESSED; -// // Put event in queue -// xQueueSend(self->rxQueue, &rxQueueItem, 0); -// rxQueueItem.rowCoordinate = 0; -// rxQueueItem.columnCoordinate = 1; -// rxQueueItem.keyEvent = RELEASED; -// // Put event in queue -// xQueueSend(self->rxQueue, &rxQueueItem, 0); + // TUBE REPAIR + struct KeypadQueueItem rxQueueItem; + rxQueueItem.rowCoordinate = 0; + rxQueueItem.columnCoordinate = 0; + rxQueueItem.keyEvent = PRESSED; + // Put event in queue + xQueueSend(self->rxQueue, &rxQueueItem, 0); + rxQueueItem.rowCoordinate = 0; + rxQueueItem.columnCoordinate = 0; + rxQueueItem.keyEvent = RELEASED; + // Put event in queue + xQueueSend(self->rxQueue, &rxQueueItem, 0); + + // SELECT CATHODE + rxQueueItem.rowCoordinate = 0; + rxQueueItem.columnCoordinate = 0; + rxQueueItem.keyEvent = PRESSED; + // Put event in queue + xQueueSend(self->rxQueue, &rxQueueItem, 0); + rxQueueItem.rowCoordinate = 0; + rxQueueItem.columnCoordinate = 0; + rxQueueItem.keyEvent = RELEASED; + // Put event in queue + xQueueSend(self->rxQueue, &rxQueueItem, 0); + + // SELECT PRESET + rxQueueItem.rowCoordinate = 0; + rxQueueItem.columnCoordinate = 0; + rxQueueItem.keyEvent = PRESSED; + // Put event in queue + xQueueSend(self->rxQueue, &rxQueueItem, 0); + rxQueueItem.rowCoordinate = 0; + rxQueueItem.columnCoordinate = 0; + rxQueueItem.keyEvent = RELEASED; + // Put event in queue + xQueueSend(self->rxQueue, &rxQueueItem, 0); + + // SELECT PRESET 7 + rxQueueItem.rowCoordinate = 2; + rxQueueItem.columnCoordinate = 0; + rxQueueItem.keyEvent = PRESSED; + // Put event in queue + xQueueSend(self->rxQueue, &rxQueueItem, 0); + rxQueueItem.rowCoordinate = 2; + rxQueueItem.columnCoordinate = 0; + rxQueueItem.keyEvent = RELEASED; + // Put event in queue + xQueueSend(self->rxQueue, &rxQueueItem, 0); + + // START + rxQueueItem.rowCoordinate = 0; + rxQueueItem.columnCoordinate = 1; + rxQueueItem.keyEvent = PRESSED; + // Put event in queue + xQueueSend(self->rxQueue, &rxQueueItem, 0); + rxQueueItem.rowCoordinate = 0; + rxQueueItem.columnCoordinate = 1; + rxQueueItem.keyEvent = RELEASED; + // Put event in queue + xQueueSend(self->rxQueue, &rxQueueItem, 0); } else diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/uart.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/uart.c index eaf0252..0d9c595 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/uart.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/uart.c @@ -267,7 +267,7 @@ ErrorStatus Uart_read (struct Uart* self, char* buffer, size_t length, size_t* a void USART1_IRQHandler(void) { - static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; + signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; //! Transmission register empty interrupt @@ -316,7 +316,7 @@ void USART1_IRQHandler(void) void USART3_IRQHandler(void) { - static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; + signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; //! Transmission register empty interrupt diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h index e48468e..9809cd2 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h @@ -54,6 +54,7 @@ extern "C" { #endif + /** @addtogroup Library_configuration_section * @{ */ @@ -102,7 +103,7 @@ In this case, these drivers will not be included and the application code will be based on direct access to peripherals registers */ - /*#define USE_STDPERIPH_DRIVER*/ + #define USE_STDPERIPH_DRIVER #endif /** diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc/misc.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc/misc.h index 7d401ca..6c7c4a0 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc/misc.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc/misc.h @@ -177,6 +177,7 @@ typedef struct * @} */ + /** * @} */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/src/misc.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/src/misc.c index ec9165f..8f33ce0 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/src/misc.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/src/misc.c @@ -210,6 +210,7 @@ void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource) } } + /** * @} */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Makefile b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Makefile index fc214f7..3fcb139 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Makefile +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/STM32F10x_StdPeriph_Lib_V3.5.0/Makefile @@ -17,7 +17,7 @@ OBJDIR = $(OBJDIR_PREFIX)_$(BUILD)_$(LANG) CROSS_COMPILE = arm-none-eabi- CC = $(CROSS_COMPILE)gcc -CCFLAGS = -c -O2 -g -fno-common -mcpu=cortex-m3 -mthumb -DUSE_FULL_ASSERT $(INCLUDE_DIRS) -I. -Wall -Werror -D"assert_param(expr)=((void)0)" +CCFLAGS = -c -O2 -g -fno-common -mcpu=cortex-m3 -mthumb -DUSE_FULL_ASSERT $(INCLUDE_DIRS) -I. -Wall -Werror AR = $(CROSS_COMPILE)ar ARFLAGS = rs diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/.cproject b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/.cproject index f16082f..f15d2b7 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/.cproject +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/.cproject @@ -11,54 +11,19 @@ + + + - + - + @@ -69,6 +34,7 @@ + @@ -80,49 +46,19 @@ + + + - + - + @@ -136,7 +72,7 @@ - + @@ -160,11 +96,20 @@ make + all true true true + + make + + clean + true + true + true + diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/.settings/language.settings.xml b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/.settings/language.settings.xml index 0087b6c..51fa9e5 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/.settings/language.settings.xml +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/.settings/language.settings.xml @@ -6,10 +6,6 @@ - - - - @@ -18,10 +14,6 @@ - - - - diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hwValidationMenu.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hwValidationMenu.h index 4f795e9..46e7937 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hwValidationMenu.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hwValidationMenu.h @@ -60,7 +60,6 @@ struct HwValidationMenuItems struct DisplayDevice* display; // DisplayDevice to talk to struct Adc* internalADC; // Internal ADC with channel array struct MAX5715* externalDAC; // External DAC with channel array - struct Gpio* power6v5Enable; struct Gpio* interlockNO; struct Gpio* interlockNC; struct Gpio* TeslaSecurity; @@ -71,9 +70,14 @@ struct HwValidationMenuItems struct Gpio* cat0Relay; struct Gpio* cat1Relay; struct Gpio* cat2Relay; + struct Gpio* hv0; + struct Gpio* hv1; + struct Gpio* hv2; + struct Gpio* bicolourGreen; + struct Gpio* bicolourRed; struct Pcba* pcba; struct Keypad *keypad; -// struct Buzzer* buzzer; + struct Buzzer* buzzer; }; struct HwValidationMenu diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/FreeRTOSFixes.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/FreeRTOSFixes.c index bba2a86..5f3e6d7 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/FreeRTOSFixes.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/FreeRTOSFixes.c @@ -30,6 +30,7 @@ #include #include +#include "Leds.h" #include "Logger.h" #include "platform.h" @@ -103,6 +104,7 @@ caddr_t _sbrk(int incr) // Stack overflow hook void vApplicationStackOverflowHook(xTaskHandle xTask, signed portCHAR* pcTaskName) { +// Led_on(LED_ONBOARD_ORANGE); LOGGER_ERROR(mainLog, "STACK OVERFLOW IN TASK %s", pcTaskName); } @@ -115,5 +117,6 @@ void vApplicationMallocFailedHook(void) // Assert for StdPeriph library void assert_failed(uint8_t* file, uint32_t line) { -// Logger_log((char*)file, "", line, LOGTYPE_ERROR, "assert failed"); + LOGGER_ERROR(mainLog, "assert failed! File %s - line %d", file, (int)line); + } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/hwValidationMenu.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/hwValidationMenu.c index 2c72755..071a1c8 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/hwValidationMenu.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/hwValidationMenu.c @@ -28,12 +28,14 @@ #include "hwValidationMenu.h" #include "DisplayDevice.h" + #include "gpio.h" #include "internalADC.h" #include "PCBA.h" #include "MAX5715.h" #include "nhd0420.h" +#include "Buzzer.h" #include "Logger.h" #include "keypadMatrix.h" @@ -55,7 +57,7 @@ typedef enum { CONSOLE_MAIN_MENU, - CONSOLE_TEST_POWER, + CONSOLE_TEST_LED, CONSOLE_TEST_DISPLAY, CONSOLE_TEST_ADC, CONSOLE_TEST_DAC, @@ -63,6 +65,7 @@ typedef enum CONSOLE_TEST_TESLA_SECURITY, CONSOLE_TEST_SOLENOID, CONSOLE_TEST_RELAY, + CONSOLE_TEST_BUZZER, CONSOLE_TEST_GENERIC, CONSOLE_IDLE }Menu_States_t; @@ -70,7 +73,7 @@ typedef enum typedef enum { DISPLAY_MENU_MAIN, - DISPLAY_MENU_POWER, + DISPLAY_MENU_LED, DISPLAY_MENU_DISPLAY, DISPLAY_MENU_ADC, DISPLAY_MENU_DAC, @@ -78,6 +81,7 @@ typedef enum DISPLAY_MENU_TESLA_SECURITY, DISPLAY_MENU_SOLENOID, DISPLAY_MENU_RELAY, + DISPLAY_MENU_BUZZER, DISPLAY_MENU_GENERIC }Display_States_t; @@ -109,7 +113,7 @@ static const char conInfMainMenu[] = ANSI_TERMINAL_HOME " MAIN MENU \r\n" " Select one of the options: \r\n" - " [%c] Test Power \r\n" + " [%c] Test LEDs \r\n" " [%c] Test Display \r\n" " [%c] Test ADCs \r\n" " [%c] Test DACs \r\n" @@ -117,12 +121,13 @@ static const char conInfMainMenu[] = " [%c] Test Tesla security \r\n" " [%c] Test Solenoids \r\n" " [%c] Test relays \r\n" + " [%c] Test buzzer \r\n" " [%c] Test Keypad/PCB variant \r\n" " \r\n"; enum { - MENU_MAIN_POWER, + MENU_MAIN_LED, MENU_MAIN_DISPLAY, MENU_MAIN_ADC, MENU_MAIN_DAC, @@ -130,29 +135,30 @@ enum MENU_MAIN_TESLA_SECURITY, MENU_MAIN_SOLENOID, MENU_MAIN_RELAY, + MENU_MAIN_BUZZER, MENU_MAIN_GENERIC, MENU_MAIN_LAST }; -static const char conTestPower[] = +static const char conTestLed[] = ANSI_TERMINAL_RESET ANSI_TERMINAL_HOME - " TEST POWER \r\n" + " TEST LEDs \r\n" " \r\n" - " Control the 6V5 power supply \r\n" + " Control the BiColour LED \r\n" " \r\n" - " [%c] Power on 6V5 \r\n" - " [%c] Power off 6V5 \r\n" + " [%c] GREEN TOGGLE \r\n" + " [%c] RED TOGGLE \r\n" " [%c] Back \r\n" " \r\n"; enum { - MENU_TEST_POWER_ON, - MENU_TEST_POWER_OFF, - MENU_TEST_POWER_BACK, - MENU_TEST_POWER_LAST + MENU_TEST_LED_GREEN, + MENU_TEST_LED_RED, + MENU_TEST_LED_BACK, + MENU_TEST_LED_LAST }; @@ -326,6 +332,23 @@ enum MENU_TEST_RELAYS_LAST }; +static const char conTestBuzzer[] = + ANSI_TERMINAL_RESET + ANSI_TERMINAL_HOME + " TEST Buzzer \r\n" + " \r\n" + " Test the Buzzer \r\n" + " \r\n" + " [%c] Toggle buzzer \r\n" + " [%c] Back \r\n" + " \r\n"; + +enum +{ + MENU_TEST_BUZZER_TOGGLE, + MENU_TEST_BUZZER_BACK, + MENU_TEST_BUZZER_LAST +}; static const char conTestGeneric[] = ANSI_TERMINAL_RESET @@ -507,11 +530,11 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b else if( button == BUTTON_ENTER ) { // Go to selected menu - if( self->menuItemSelected == MENU_MAIN_POWER ) + if( self->menuItemSelected == MENU_MAIN_LED ) { self->menuItemSelected = 0; - menuState = CONSOLE_TEST_POWER; - hwValidationMenuDisplay(self, DISPLAY_MENU_POWER ); + menuState = CONSOLE_TEST_LED; + hwValidationMenuDisplay(self, DISPLAY_MENU_LED ); } else if( self->menuItemSelected == MENU_MAIN_DISPLAY) { @@ -555,6 +578,12 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b menuState = CONSOLE_TEST_RELAY; hwValidationMenuDisplay(self, DISPLAY_MENU_RELAY ); } + else if( self->menuItemSelected == MENU_MAIN_BUZZER ) + { + self->menuItemSelected = 0; + menuState = CONSOLE_TEST_BUZZER; + hwValidationMenuDisplay(self, DISPLAY_MENU_BUZZER ); + } else if( self->menuItemSelected == MENU_MAIN_GENERIC ) { self->menuItemSelected = 0; @@ -566,55 +595,73 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b break; - case CONSOLE_TEST_POWER: + case CONSOLE_TEST_LED: if( button == BUTTON_UP ) { if( self->menuItemSelected == 0 ) - self->menuItemSelected = (MENU_TEST_POWER_LAST - 1); + self->menuItemSelected = (MENU_TEST_LED_LAST - 1); else self->menuItemSelected--; - hwValidationMenuDisplay(self, DISPLAY_MENU_POWER ); + hwValidationMenuDisplay(self, DISPLAY_MENU_LED ); } else if( button == BUTTON_DOWN ) { - if( self->menuItemSelected == (MENU_TEST_POWER_LAST - 1) ) + if( self->menuItemSelected == (MENU_TEST_LED_LAST - 1) ) self->menuItemSelected = 0; else self->menuItemSelected++; - hwValidationMenuDisplay(self, DISPLAY_MENU_POWER ); + hwValidationMenuDisplay(self, DISPLAY_MENU_LED ); } else if( button == BUTTON_ENTER ) { - if( self->menuItemSelected == MENU_TEST_POWER_ON ) + if( self->menuItemSelected == MENU_TEST_LED_GREEN ) { - // Turn on 6V5 power ( enable active low ) - if(GPIO_setValue(self->testItems->power6v5Enable, false) == SUCCESS) + bool value = false; + if( GPIO_getValue(self->testItems->bicolourGreen, &value) == SUCCESS) { - outputBufferLength = sprintf(self->outputBuffer, "Power: Off\r\n"); + // Invert current value + value = !value; + if( GPIO_setValue(self->testItems->bicolourGreen, value) == SUCCESS) + { + outputBufferLength = sprintf(self->outputBuffer, "GREEN LED: Toggled\r\n"); + } + else + { + outputBufferLength = sprintf(self->outputBuffer, "GREEN LED: Failed to set value\r\n"); + } } - else + else { - outputBufferLength = sprintf(self->outputBuffer, "Power: Failure\r\n"); + outputBufferLength = sprintf(self->outputBuffer, "GREEN LED: Failed to get value\r\n"); } - IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength); + IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength); } - else if (self->menuItemSelected == MENU_TEST_POWER_OFF ) + else if (self->menuItemSelected == MENU_TEST_LED_RED ) { - //Turn on 6V5 power ( enable active low ) - if( GPIO_setValue(self->testItems->power6v5Enable, true) == SUCCESS) + bool value = false; + if( GPIO_getValue(self->testItems->bicolourRed, &value) == SUCCESS) { - outputBufferLength = sprintf(self->outputBuffer, "Power: Off\r\n"); + // Invert current value + value = !value; + if( GPIO_setValue(self->testItems->bicolourRed, value) == SUCCESS) + { + outputBufferLength = sprintf(self->outputBuffer, "RED LED: Toggled\r\n"); + } + else + { + outputBufferLength = sprintf(self->outputBuffer, "RED LED: Failed to set value\r\n"); + } } - else + else { - outputBufferLength = sprintf(self->outputBuffer, "Power: Failure\r\n"); + outputBufferLength = sprintf(self->outputBuffer, "RED LED: Failed to get value\r\n"); } - IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength); + IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength); } - else if (self->menuItemSelected == MENU_TEST_POWER_BACK ) + else if (self->menuItemSelected == MENU_TEST_LED_BACK ) { // Back to main menu self->menuItemSelected = 0; @@ -928,14 +975,14 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b case CONSOLE_TEST_TESLA_SECURITY: if( button == BUTTON_UP ) - { - if( self->menuItemSelected == 0 ) - self->menuItemSelected = (MENU_TEST_TESLA_LAST- 1); - else - self->menuItemSelected--; + { + if( self->menuItemSelected == 0 ) + self->menuItemSelected = (MENU_TEST_TESLA_LAST- 1); + else + self->menuItemSelected--; - hwValidationMenuDisplay(self, DISPLAY_MENU_TESLA_SECURITY ); - } + hwValidationMenuDisplay(self, DISPLAY_MENU_TESLA_SECURITY ); + } else if( button == BUTTON_DOWN ) { if( self->menuItemSelected == (MENU_TEST_TESLA_LAST - 1) ) @@ -1119,6 +1166,59 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b } break; + case CONSOLE_TEST_BUZZER: + if( button == BUTTON_UP ) + { + if( self->menuItemSelected == 0 ) + self->menuItemSelected = (MENU_TEST_BUZZER_LAST- 1); + else + self->menuItemSelected--; + + hwValidationMenuDisplay(self, DISPLAY_MENU_BUZZER ); + } + else if( button == BUTTON_DOWN ) + { + if( self->menuItemSelected == (MENU_TEST_BUZZER_LAST - 1) ) + self->menuItemSelected = 0; + else + self->menuItemSelected++; + + hwValidationMenuDisplay(self, DISPLAY_MENU_BUZZER ); + } + else if( button == BUTTON_ENTER ) + { + bool value = false; + if( self->menuItemSelected == MENU_TEST_BUZZER_TOGGLE) + { + if( GPIO_getValue(self->testItems->buzzer->gpio, &value) == SUCCESS) + { + // Invert current value + value = !value; + if( GPIO_setValue(self->testItems->buzzer->gpio, value) == SUCCESS) + { + outputBufferLength = sprintf(self->outputBuffer, "Buzzer: Toggled\r\n"); + } + else + { + outputBufferLength = sprintf(self->outputBuffer, "buzzer: Failed to set value\r\n"); + } + } + else + { + outputBufferLength = sprintf(self->outputBuffer, "buzzer: Failed to get value\r\n"); + } + IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength); + } + else if (self->menuItemSelected == MENU_TEST_BUZZER_BACK ) + { + // Back to main menu + self->menuItemSelected = 0; + menuState = CONSOLE_MAIN_MENU; + hwValidationMenuDisplay(self, DISPLAY_MENU_MAIN ); + } + } + break; + // case CONSOLE_TEST_PCB_VARIANT: // if(self->testItems->pcba) @@ -1129,13 +1229,6 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b // 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: @@ -1259,7 +1352,7 @@ static void hwValidationMenuDisplay(struct HwValidationMenu* self, Display_State // Fill buffer with menu items char menuBuffer[ sizeof( conInfMainMenu ) ]; menu_length = sprintf( menuBuffer, conInfMainMenu, - menuItems[MENU_MAIN_POWER], + menuItems[MENU_MAIN_LED], menuItems[MENU_MAIN_DISPLAY], menuItems[MENU_MAIN_ADC], menuItems[MENU_MAIN_DAC], @@ -1267,6 +1360,7 @@ static void hwValidationMenuDisplay(struct HwValidationMenu* self, Display_State menuItems[MENU_MAIN_TESLA_SECURITY], menuItems[MENU_MAIN_SOLENOID], menuItems[MENU_MAIN_RELAY], + menuItems[MENU_MAIN_BUZZER], menuItems[MENU_MAIN_GENERIC] ); @@ -1274,23 +1368,23 @@ static void hwValidationMenuDisplay(struct HwValidationMenu* self, Display_State IODevice_write(self->ioDevice, menuBuffer, menu_length); break; - case DISPLAY_MENU_POWER: + case DISPLAY_MENU_LED: // Put an asterisk (*) at the selected item in the menu - for( menuIndex = 0; menuIndex < MENU_TEST_POWER_LAST; menuIndex++ ) + for( menuIndex = 0; menuIndex < MENU_TEST_LED_LAST; menuIndex++ ) { MENU_DRAW_SELECTED(menuIndex); } // Fill buffer with menu items - char powerMenuBuffer[ sizeof( conTestPower ) ]; - menu_length = sprintf( powerMenuBuffer, conTestPower, - menuItems[MENU_TEST_POWER_ON], - menuItems[MENU_TEST_POWER_OFF], - menuItems[MENU_TEST_POWER_BACK] + char ledMenuBuffer[ sizeof( conTestLed ) ]; + menu_length = sprintf( ledMenuBuffer, conTestLed, + menuItems[MENU_TEST_LED_GREEN], + menuItems[MENU_TEST_LED_RED], + menuItems[MENU_TEST_LED_BACK] ); // Write message to debout interface - IODevice_write(self->ioDevice, powerMenuBuffer, menu_length); + IODevice_write(self->ioDevice, ledMenuBuffer, menu_length); break; @@ -1445,6 +1539,25 @@ static void hwValidationMenuDisplay(struct HwValidationMenu* self, Display_State IODevice_write(self->ioDevice, relayMenuBuffer, menu_length); break; + case DISPLAY_MENU_BUZZER: + + // Put an asterisk (*) at the selected item in the menu + for( menuIndex = 0; menuIndex < MENU_TEST_BUZZER_LAST; menuIndex++ ) + { + MENU_DRAW_SELECTED(menuIndex); + } + + // Fill buffer with menu items + char buzzerMenuBuffer[ sizeof( conTestBuzzer ) ]; + menu_length = sprintf( buzzerMenuBuffer, conTestBuzzer, + menuItems[MENU_TEST_BUZZER_TOGGLE], + menuItems[MENU_TEST_BUZZER_BACK] + ); + + // Write message to debout interface + IODevice_write(self->ioDevice, buzzerMenuBuffer, menu_length); + break; + // case DISPLAY_MENU_KEYPAD: // break; diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c index 21fb6e4..8a2d202 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c @@ -173,35 +173,36 @@ static ErrorStatus systeminfoCommandHandler(void) LOGGER_INFO(mainLog, text); // vTaskList(taskList); -// IODevice_write((struct IODevice*)uart1, taskList, 600); +// IODevice_write((struct IODevice*)uart1, taskList, strlen(taskList)); +// IODevice_write((struct IODevice*)uart1, "\n\r\n\r", 5); - vTaskDelay(100); + vTaskDelay(50); OS_logTaskInfo(initTaskHandle); - vTaskDelay(100); + vTaskDelay(50); OS_logTaskInfo(errorTaskHandle); - vTaskDelay(100); + vTaskDelay(50); OS_logTaskInfo(warningTaskHandle); - vTaskDelay(100); + vTaskDelay(50); OS_logTaskInfo(interlock->taskHandle); - vTaskDelay(100); + vTaskDelay(50); OS_logTaskInfo(mainLog->taskHandle); - vTaskDelay(100); + vTaskDelay(50); OS_logTaskInfo(keypad->taskHandle); - vTaskDelay(100); + vTaskDelay(50); OS_logTaskInfo(mainBuzzer->taskHandle); - vTaskDelay(100); - vTaskDelay(100); + vTaskDelay(50); OS_logTaskInfo(mainDisplay->taskHandle); #ifdef ENABLE_HW_VALIDATION + vTaskDelay(50); OS_logTaskInfo(hwValidation->taskHandle); #endif - vTaskDelay(100); + vTaskDelay(50); OS_logTaskInfo(sysTaskHandle); - vTaskDelay(100); + vTaskDelay(50); OS_logTaskInfo(ledTaskHandle); - vTaskDelay(100); + vTaskDelay(50); OS_logTaskInfo(mainMenu->menuCore->taskHandle); - vTaskDelay(100); + vTaskDelay(50); OS_logTaskInfo(rp->taskHandle); @@ -286,17 +287,22 @@ static void initTask(void* parameters) hwTestItems.display = &nhd0420->displayDevice; hwTestItems.internalADC = adc1; hwTestItems.externalDAC = max5715; -// hwTestItems.power6v5Enable = Power6V5Supply_getGPIO(); hwTestItems.interlockNO = interlock->NO.io; hwTestItems.interlockNC = interlock->NC.io; - hwTestItems.TeslaSecurity = TeslaGunSafety_getGpio(); - hwTestItems.solenoid = CoverSolenoid_getGpio(); - hwTestItems.mcp0Relay = CathodeMCP_getInstance()->mcp0; - hwTestItems.mcp1Relay = CathodeMCP_getInstance()->mcp1; - hwTestItems.mcp2Relay = CathodeMCP_getInstance()->mcp2; - hwTestItems.cat0Relay = CathodeMCP_getInstance()->cat0; - hwTestItems.cat1Relay = CathodeMCP_getInstance()->cat1; - hwTestItems.cat2Relay = CathodeMCP_getInstance()->cat2; + hwTestItems.TeslaSecurity = teslaRelay; + hwTestItems.solenoid = solenoid; + hwTestItems.mcp0Relay = mcp0Relay; + hwTestItems.mcp1Relay = mcp1Relay; + hwTestItems.mcp2Relay = mcp2Relay; + hwTestItems.cat0Relay = cat0Relay; + hwTestItems.cat1Relay = cat1Relay; + hwTestItems.cat2Relay = cat2Relay; + hwTestItems.buzzer = mainBuzzer; + hwTestItems.bicolourRed = ledBicolourRed; + hwTestItems.bicolourGreen = ledBicolourGreen; + hwTestItems.hv0 = hv0Present; + hwTestItems.hv1 = hv1Present; + hwTestItems.hv2 = hv2Present; hwTestItems.pcba = PCBA_getInstance(); hwTestItems.keypad = keypad; // EEPROM TO BE DONE @@ -340,7 +346,7 @@ static void ledBlinkTask (void* parameters) int frequency = arguments->frequency; while (1) { - Led_on(arguments->led); +// Led_on(arguments->led); if (PCBA_getInstance()->pcba == PCBA_CathodeMCP) { @@ -354,7 +360,7 @@ static void ledBlinkTask (void* parameters) } vTaskDelay(configTICK_RATE_HZ / (frequency * 2)); - Led_off(arguments->led); +// Led_off(arguments->led); indicator[0] = ' '; // Display_write(mainDisplay, indicator, 1, 20); vTaskDelay(configTICK_RATE_HZ / (frequency * 2)); diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/stm32f10x_it.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/stm32f10x_it.c index 6cd37bb..08bbef3 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/stm32f10x_it.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/stm32f10x_it.c @@ -43,6 +43,7 @@ #include "repairMenu.h" #include "repairProcess.h" +#include "Leds.h" #include "Logger.h" #include "platform.h" #include "rtc.h" @@ -132,6 +133,10 @@ void IRQ_setKeypadEXTI(struct Keypad* self, FunctionalState command) // } +void HardFault_Handler(void) +{ + while (1); +} /** ---------------------------------------------------------------------------- * @brief Function: SPI1_IRQHandler @@ -145,7 +150,7 @@ void IRQ_setKeypadEXTI(struct Keypad* self, FunctionalState command) */ void SPI1_IRQHandler (void) { - static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; + signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; //! Transmission register empty interrupt if(SPI_I2S_GetITStatus(SPI1, SPI_I2S_IT_TXE) != RESET) @@ -195,7 +200,7 @@ void SPI1_IRQHandler (void) */ void SPI3_IRQHandler (void) { - static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; + signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; //! Transmission register empty interrupt if(SPI_I2S_GetITStatus(SPI3, SPI_I2S_IT_TXE) != RESET) @@ -235,10 +240,13 @@ void SPI3_IRQHandler (void) void EXTI0_IRQHandler(void) { - static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; + signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; - xSemaphoreGiveFromISR(interlock->semaphore, &higherPriorityTaskWoken); - EXTI_ClearITPendingBit(EXTI_Line0); + if(EXTI_GetITStatus(EXTI_Line0) != RESET) + { + xSemaphoreGiveFromISR(interlock->semaphore, &higherPriorityTaskWoken); + EXTI_ClearITPendingBit(EXTI_Line0); + } portEND_SWITCHING_ISR(higherPriorityTaskWoken); } @@ -246,10 +254,13 @@ void EXTI0_IRQHandler(void) void EXTI1_IRQHandler(void) { - static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; + signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; - xSemaphoreGiveFromISR(interlock->semaphore, &higherPriorityTaskWoken); - EXTI_ClearITPendingBit(EXTI_Line1); + if(EXTI_GetITStatus(EXTI_Line1) != RESET) + { + xSemaphoreGiveFromISR(interlock->semaphore, &higherPriorityTaskWoken); + EXTI_ClearITPendingBit(EXTI_Line1); + } portEND_SWITCHING_ISR(higherPriorityTaskWoken); } @@ -257,46 +268,55 @@ void EXTI1_IRQHandler(void) void EXTI4_IRQHandler(void) { - static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; + signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; - IRQ_setKeypadEXTI(keypad, DISABLE); - xSemaphoreGiveFromISR(keypad->scanSemaphore, &higherPriorityTaskWoken); - EXTI_ClearITPendingBit(EXTI_Line4); + if(EXTI_GetFlagStatus(EXTI_Line4) != RESET) + { + EXTI_ClearFlag(EXTI_Line4); + IRQ_setKeypadEXTI(keypad, DISABLE); + xSemaphoreGiveFromISR(keypad->scanSemaphore, &higherPriorityTaskWoken); + } portEND_SWITCHING_ISR(higherPriorityTaskWoken); } void EXTI9_5_IRQHandler (void) { - static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; + signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; - if (EXTI_GetITStatus(EXTI_Line5) != RESET) + Led_on(LED_ONBOARD_GREEN); + + if (EXTI_GetFlagStatus(EXTI_Line5) != RESET) { + EXTI_ClearFlag(EXTI_Line5); IRQ_setKeypadEXTI(keypad, DISABLE); xSemaphoreGiveFromISR(keypad->scanSemaphore, &higherPriorityTaskWoken); - EXTI_ClearITPendingBit(EXTI_Line5); } - else if (EXTI_GetITStatus(EXTI_Line6) != RESET) + + else if (EXTI_GetFlagStatus(EXTI_Line6) != RESET) { + EXTI_ClearFlag(EXTI_Line6); IRQ_setKeypadEXTI(keypad, DISABLE); xSemaphoreGiveFromISR(keypad->scanSemaphore, &higherPriorityTaskWoken); - EXTI_ClearITPendingBit(EXTI_Line6); } - else if (EXTI_GetITStatus(EXTI_Line7) != RESET) + + else if (EXTI_GetFlagStatus(EXTI_Line7) != RESET) { + EXTI_ClearFlag(EXTI_Line7); IRQ_setKeypadEXTI(keypad, DISABLE); xSemaphoreGiveFromISR(keypad->scanSemaphore, &higherPriorityTaskWoken); - EXTI_ClearITPendingBit(EXTI_Line7); } - else if (EXTI_GetITStatus(EXTI_Line8) != RESET) + else if (EXTI_GetFlagStatus(EXTI_Line8) != RESET) { - EXTI_ClearITPendingBit(EXTI_Line8); + EXTI_ClearFlag(EXTI_Line8); } - else if (EXTI_GetITStatus(EXTI_Line9) != RESET) + else if (EXTI_GetFlagStatus(EXTI_Line9) != RESET) { - EXTI_ClearITPendingBit(EXTI_Line9); + EXTI_ClearFlag(EXTI_Line9); } + Led_off(LED_ONBOARD_GREEN); + portEND_SWITCHING_ISR(higherPriorityTaskWoken); }