diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/Makefile b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/Makefile index 88abb8e..1e832f7 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/Makefile +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/Makefile @@ -25,9 +25,11 @@ ARFLAGS = rs OBJECTS = \ DisplayDevice.o \ IODevice.o \ +KeyboardDevice.o \ Logger.o \ MAX5715.o \ -nhd0420.o +nhd0420.o \ +storm700.o vpath %.o $(OBJDIR) diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/KeyboardDevice.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/KeyboardDevice.h index d44d7c6..253f344 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/KeyboardDevice.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/KeyboardDevice.h @@ -31,6 +31,11 @@ // Include files // ----------------------------------------------------------------------------- +#include + +#include "stm32f10x.h" + +#include "keypadMatrix.h" // ----------------------------------------------------------------------------- // Constant and macro definitions @@ -43,10 +48,30 @@ // ----------------------------------------------------------------------------- +struct KeyboardDevice; + + +typedef ErrorStatus (*KeyboardReadFunction)(const struct KeyboardDevice* self, char* buffer, Keypad_KeyState* keyState); + + +struct KeyboardDeviceParameters +{ + int numberOfKeys; +}; + +struct KeyboardDevice +{ + KeyboardReadFunction _read; + struct KeyboardDeviceParameters parameters; + bool initialized; +}; // ----------------------------------------------------------------------------- // Function declarations // ----------------------------------------------------------------------------- +extern ErrorStatus KeyboardDevice_construct (struct KeyboardDevice* self, struct KeyboardDeviceParameters* parameters, KeyboardReadFunction read); + +extern ErrorStatus KeyboardDevice_read(const struct KeyboardDevice* self, char* buffer, Keypad_KeyState* keyState); #endif /* INC_KEYBOARDDEVICE_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/PID.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/PID.h new file mode 100644 index 0000000..3fa058c --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/PID.h @@ -0,0 +1,93 @@ +// ----------------------------------------------------------------------------- +/// @file PID.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 PID.h +/// @ingroup {group_name} + +#ifndef INC_PID_H_ +#define INC_PID_H_ + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + +#include + +#include "stm32f10x.h" + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Type definitions. +// ----------------------------------------------------------------------------- + +struct Pid +{ + int Kp; // proportional constant + int Ki; // integration constant + int Kd; // differential constant + int input_d1; // Input t-1 + bool initialized; +}; + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + +/** ---------------------------------------------------------------------------- + * PID_construct + * Constructor for a PID regulator + * + * @param self PID object to construct + * @param Kp proportional constant + * @param Ki integration constant + * @param Kd differential constant + * + * @return ErrorStatus SUCCESS if initialisation was successful + * ERRROR otherwise + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus PID_construct(struct Pid* self, int Kp, int Ki, int Kd); + + +/** ---------------------------------------------------------------------------- + * PID_calculate + * Calculate + * + * @param self The PID object + * @param error the error input to calculate + * + * @return int calculated value + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern int PID_calculate(struct Pid* self, int error); + +#endif /* INC_PID_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/nhd0420.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/nhd0420.h index a47b7d6..3a0c26f 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/nhd0420.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/nhd0420.h @@ -148,7 +148,7 @@ extern ErrorStatus NHD0420_construct(struct NHD0420* self, const struct IODevice * NHD0420_destruct * Destructor for the NHD0420 instance * - * @param interface The interface to use + * @param interface The object to destruct * * @return void * diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/storm700.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/storm700.h new file mode 100644 index 0000000..03ba18c --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/storm700.h @@ -0,0 +1,110 @@ +// ----------------------------------------------------------------------------- +/// @file storm700.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 storm700.h +/// @ingroup {group_name} + +#ifndef INC_STORM700_H_ +#define INC_STORM700_H_ + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + +#include "stm32f10x.h" + +#include "KeyboardDevice.h" +#include "keypadMatrix.h" + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + +#define STORM700_NUMBER_OF_ROWS (4) +#define STORM700_NUMBER_OF_COLUMNS (4) + +// ----------------------------------------------------------------------------- +// Type definitions. +// ----------------------------------------------------------------------------- + +struct Storm700 +{ + struct KeyboardDevice keyboardDevice; + const struct IODevice* device; + bool initialized; +}; + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + + +/** ---------------------------------------------------------------------------- + * Storm700_construct + * Constructor for Storm700 keypad + * + * @param self Keypad object to construct + * @param device The IO device that is used to communicate + * + * @return ErrorStatus SUCCESS if initialisation was successful + * ERROR otherwise + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus Storm700_construct(struct Storm700* self, const struct IODevice* device); + + +/** ---------------------------------------------------------------------------- + * Storm700_destruct + * Destructor for the Storm700 instance + * + * @param self The object to destruct + * + * @return void + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void Storm700_destruct(struct Storm700* self); + + +/** ---------------------------------------------------------------------------- + * Storm700_readKey + * Read a key from the storm700 keypad + * + * @param self Keypad instance + * @param key The key that has been read. Will be + * formatted ins ASCII code + * @param keyState Indicates whether key was pressed or + * released + * + * @return ErrorStatus SUCCESS if reading was successful + * ERROR otherwise + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus Storm700_readKey(const struct Storm700* self, char* key, Keypad_KeyState* keyState); + +#endif /* INC_STORM700_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/DisplayDevice.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/DisplayDevice.c index 414e341..da4006e 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/DisplayDevice.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/DisplayDevice.c @@ -27,6 +27,8 @@ #include "DisplayDevice.h" +#include "Logger.h" + // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- @@ -78,6 +80,8 @@ ErrorStatus DisplayDevice_construct (struct DisplayDevice* self, struct DisplayD self->_setContrast = setContrast; self->_invert = invert; + self->initialized = true; + self->parameters = *parameters; } else @@ -91,7 +95,7 @@ ErrorStatus DisplayDevice_construct (struct DisplayDevice* self, struct DisplayD ErrorStatus DisplayDevice_reset(const struct DisplayDevice* self) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { if (self->_reset != NULL) { @@ -109,7 +113,7 @@ ErrorStatus DisplayDevice_reset(const struct DisplayDevice* self) ErrorStatus DisplayDevice_setState(const struct DisplayDevice* self, DisplayDevice_functionalState state) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { if (self->_setState != NULL) { @@ -127,7 +131,7 @@ ErrorStatus DisplayDevice_setState(const struct DisplayDevice* self, DisplayDevi ErrorStatus DisplayDevice_write(const struct DisplayDevice* self, const char* buffer, size_t length, size_t row, size_t column) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { if (self->_write != NULL) { @@ -145,7 +149,7 @@ ErrorStatus DisplayDevice_write(const struct DisplayDevice* self, const char* bu ErrorStatus DisplayDevice_clear(const struct DisplayDevice* self) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { if (self->_clear != NULL) { @@ -163,7 +167,7 @@ ErrorStatus DisplayDevice_clear(const struct DisplayDevice* self) ErrorStatus DisplayDevice_clearLine(const struct DisplayDevice* self, size_t row) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { if (self->_clearLine != NULL) { @@ -181,7 +185,7 @@ ErrorStatus DisplayDevice_clearLine(const struct DisplayDevice* self, size_t row ErrorStatus DisplayDevice_setBrightness(const struct DisplayDevice* self, size_t brightness) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { if (self->_setBrightness != NULL) { @@ -199,7 +203,7 @@ ErrorStatus DisplayDevice_setBrightness(const struct DisplayDevice* self, size_t ErrorStatus DisplayDevice_setContrast(const struct DisplayDevice* self, size_t contrast) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { if (self->_setContrast != NULL) { @@ -217,7 +221,7 @@ ErrorStatus DisplayDevice_setContrast(const struct DisplayDevice* self, size_t c ErrorStatus DisplayDevice_invert(const struct DisplayDevice* self) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { if (self->_invert != NULL) { diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/KeyboardDevice.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/KeyboardDevice.c new file mode 100644 index 0000000..35a5796 --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/KeyboardDevice.c @@ -0,0 +1,88 @@ +// ----------------------------------------------------------------------------- +/// @file KeyboardDevice.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 KeyboardDevice.c +/// @ingroup {group_name} + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + +#include + +#include "KeyboardDevice.h" + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Type definitions +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// File-scope variables +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Function definitions +// ----------------------------------------------------------------------------- + + +ErrorStatus KeyboardDevice_construct (struct KeyboardDevice* self, struct KeyboardDeviceParameters* parameters, KeyboardReadFunction read) +{ + ErrorStatus returnValue = SUCCESS; + + if (!self->initialized) + { + self->_read = read; + self->parameters = *parameters; + self->initialized = true; + } + else + { + returnValue = ERROR; + } + + return returnValue; +} + +ErrorStatus KeyboardDevice_read(const struct KeyboardDevice* self, char* buffer, Keypad_KeyState* keyState) +{ + ErrorStatus returnValue = SUCCESS; + + if (self->_read != NULL) + { + returnValue = self->_read(self, buffer, keyState); + } + + return returnValue; +} diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/PID.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/PID.c new file mode 100644 index 0000000..fec88a7 --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/PID.c @@ -0,0 +1,92 @@ +// ----------------------------------------------------------------------------- +/// @file PID.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 PID.c +/// @ingroup {group_name} + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + +#include "PID.h" + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Type definitions +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// File-scope variables +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Function definitions +// ----------------------------------------------------------------------------- + + +ErrorStatus PID_construct(struct Pid* self, int Kp, int Ki, int Kd) +{ + ErrorStatus returnValue = SUCCESS; + + if (!self->initialized) + { + self->Kd = Kd; + self->Ki = Ki; + self->Kp = Kp; + self->input_d1 = 0; + self->initialized = true; + } + else + { + returnValue = ERROR; + } + return returnValue; +} + + +int PID_calculate(struct Pid* self, int error) +{ + int returnValue = 0; + + if (self->initialized) + { + + } + + return returnValue; + + + + +} diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/nhd0420.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/nhd0420.c index 9d9ab07..4ab212e 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/nhd0420.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/nhd0420.c @@ -34,6 +34,8 @@ #include "spi.h" +#include "Logger.h" + // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- @@ -67,7 +69,7 @@ static int nhd0420_cursorRowOffset[NHD0420_NUMBER_OF_ROWS] = static ErrorStatus setState(const struct DisplayDevice* self, DisplayDevice_functionalState state); static ErrorStatus write(const struct DisplayDevice* self, const char* buffer, size_t length, size_t row, size_t column); static ErrorStatus clear(const struct DisplayDevice* self); -static ErrorStatus clearLine(const struct DisplayDevice* self); +static ErrorStatus clearLine(const struct DisplayDevice* self, size_t row); static ErrorStatus setBrightness(const struct DisplayDevice* self, size_t brightness); static ErrorStatus setContrast(const struct DisplayDevice* self, size_t contrast); @@ -94,6 +96,9 @@ ErrorStatus NHD0420_construct(struct NHD0420* self, const struct IODevice* devic ddParameters.contrastMin = NHD0420_CONTRAST_MIN; ddParameters.contrastMax = NHD0420_CONTRAST_MAX; DisplayDevice_construct(&self->displayDevice, &ddParameters, NULL, setState, write, clear, clearLine, setBrightness, setContrast, NULL); + + self->initialized = true; + NHD0420_sendData(self, "Hallo", 5); } else { @@ -163,7 +168,7 @@ ErrorStatus NHD0420_getSpiParameters(struct SpiParameters* parameters) ErrorStatus NHD0420_setCursorToPosition(const struct NHD0420* self, size_t row, size_t column) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { // Setting cursor requires sending a command sequence with an additional // address parameter representing the line/column @@ -198,7 +203,7 @@ ErrorStatus NHD0420_setCursorToPosition(const struct NHD0420* self, size_t row, ErrorStatus NHD0420_setContrast(const struct NHD0420* self, char contrast) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { // Setting contrast requires sending a command sequence with an additional // parameter representing the contrast @@ -229,7 +234,7 @@ ErrorStatus NHD0420_setContrast(const struct NHD0420* self, char contrast) ErrorStatus NHD0420_setBacklightBrightness(const struct NHD0420* self, char brightness) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { // Setting backlight brightness requires sending a command sequence with an // additional parameter representing the brightness @@ -260,7 +265,7 @@ ErrorStatus NHD0420_setBacklightBrightness(const struct NHD0420* self, char brig ErrorStatus NHD0420_setRS232Baudrate(const struct NHD0420* self, char baudrate) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { // Setting baudrate requires sending a command sequence with an // additional parameter representing the baudrate @@ -290,7 +295,7 @@ ErrorStatus NHD0420_setRS232Baudrate(const struct NHD0420* self, char baudrate) ErrorStatus NHD0420_setI2CAddress(const struct NHD0420* self, char address) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { // Setting I2C requires sending a command sequence with an // additional parameter representing the address @@ -331,7 +336,7 @@ ErrorStatus NHD0420_setI2CAddress(const struct NHD0420* self, char address) ErrorStatus NHD0420_sendCommand(const struct NHD0420* self, char command) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { char buffer[NHD0420_CMD_LENGTH] = {NHD0420_CMD_PREFIX, command}; @@ -348,7 +353,7 @@ ErrorStatus NHD0420_sendCommand(const struct NHD0420* self, char command) ErrorStatus NHD0420_sendData(const struct NHD0420* self, const char* buffer, size_t length) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { returnValue = IODevice_write(self->device, buffer, length); } @@ -363,7 +368,7 @@ ErrorStatus NHD0420_sendData(const struct NHD0420* self, const char* buffer, siz static ErrorStatus setState(const struct DisplayDevice* self, DisplayDevice_functionalState state) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { if (state == ON) { @@ -385,7 +390,7 @@ static ErrorStatus setState(const struct DisplayDevice* self, DisplayDevice_func static ErrorStatus write(const struct DisplayDevice* self, const char* buffer, size_t length, size_t row, size_t column) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { // Set cursor on display returnValue = NHD0420_setCursorToPosition((const struct NHD0420*)self, row, column); @@ -405,7 +410,7 @@ static ErrorStatus write(const struct DisplayDevice* self, const char* buffer, s static ErrorStatus clear(const struct DisplayDevice* self) { - if (!self->initialized) + if (self->initialized) { return NHD0420_clearScreen((const struct NHD0420*)self); } @@ -421,12 +426,18 @@ static ErrorStatus clearLine(const struct DisplayDevice* self, size_t row) { ErrorStatus returnValue = SUCCESS; - if (!self->initialized) + if (self->initialized) { // Set cursor on display returnValue = NHD0420_setCursorToPosition((const struct NHD0420*)self, row, 1); - char buffer[self->parameters.numberOfColumns] = {0x20,}; + char buffer[self->parameters.numberOfColumns]; + + int loopcounter; + for (loopcounter = 0; loopcounter < self->parameters.numberOfColumns; loopcounter++) + { + buffer[loopcounter] = 0x20; + } if (returnValue == SUCCESS) { @@ -444,7 +455,7 @@ static ErrorStatus clearLine(const struct DisplayDevice* self, size_t row) static ErrorStatus setBrightness(const struct DisplayDevice* self, size_t brightness) { - if (!self->initialized) + if (self->initialized) { return NHD0420_setBacklightBrightness((const struct NHD0420*)self, brightness); } @@ -457,7 +468,7 @@ static ErrorStatus setBrightness(const struct DisplayDevice* self, size_t bright static ErrorStatus setContrast(const struct DisplayDevice* self, size_t contrast) { - if (!self->initialized) + if (self->initialized) { return NHD0420_setContrast((const struct NHD0420*)self, contrast); } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/storm700.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/storm700.c new file mode 100644 index 0000000..290290b --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/storm700.c @@ -0,0 +1,131 @@ +// ----------------------------------------------------------------------------- +/// @file storm700.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 storm700.c +/// @ingroup {group_name} + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + +#include "storm700.h" + +#include "keypadMatrix.h" + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Type definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// File-scope variables +// ----------------------------------------------------------------------------- + +static char keyLookupTable[STORM700_NUMBER_OF_ROWS][STORM700_NUMBER_OF_COLUMNS] = +{ + { '1', '2', '3', 'X' }, + { '4', '5', '6', 'U' }, + { '7', '8', '9', 'D' }, + { 'L', '0', 'R', '\n'} +}; + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + +static ErrorStatus read(const struct KeyboardDevice* self, char* buffer, Keypad_KeyState* keyState); + +// ----------------------------------------------------------------------------- +// Function definitions +// ----------------------------------------------------------------------------- + +ErrorStatus Storm700_construct(struct Storm700* self, const struct IODevice* device) +{ + ErrorStatus returnValue = SUCCESS; + + if (!self->initialized) + { + if (device != NULL) + { + self->device = device; + + struct KeyboardDeviceParameters kbParameters; + kbParameters.numberOfKeys = STORM700_NUMBER_OF_ROWS * STORM700_NUMBER_OF_COLUMNS; + + KeyboardDevice_construct(&self->keyboardDevice, &kbParameters, read); + + self->initialized = true; + } + } + + return returnValue; +} + + +void Storm700_destruct(struct Storm700* self) +{ + self->initialized= false; + self->device = NULL; +} + + + +ErrorStatus Storm700_readKey(const struct Storm700* self, char* key, Keypad_KeyState* keyState) +{ + ErrorStatus returnValue = SUCCESS; + + if (self->initialized) + { + size_t actualLength; + char buffer[sizeof(struct KeypadQueueItem) / sizeof(char)]; + returnValue = IODevice_read(self->device, buffer, sizeof(struct KeypadQueueItem) / sizeof(char), &actualLength); + + if (returnValue == SUCCESS) + { + struct KeypadQueueItem* rxQueueItem = (struct KeypadQueueItem*)buffer; + + *key = keyLookupTable[rxQueueItem->rowCoordinate][rxQueueItem->columnCoordinate]; + *keyState = rxQueueItem->keyEvent; + } + else + { + returnValue = ERROR; + } + } + else + { + returnValue = ERROR; + } + + return returnValue; +} + + +static ErrorStatus read(const struct KeyboardDevice* self, char* buffer, Keypad_KeyState* keyState) +{ + return Storm700_readKey((const struct Storm700*)self, buffer, keyState); +} diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/keypadMatrix.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/keypadMatrix.h index 9180860..e328cd9 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/keypadMatrix.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/keypadMatrix.h @@ -47,23 +47,26 @@ // Constant and macro definitions // ----------------------------------------------------------------------------- -#define KEYPAD_NUMBER_OF_ROWS (4) -#define KEYPAD_NUMBER_OF_COLUMNS (4) +#define KEYPAD_MAX_NUMBER_OF_ROWS (6) +#define KEYPAD_MAX_NUMBER_OF_COLUMNS (6) // ----------------------------------------------------------------------------- // Type definitions. // ----------------------------------------------------------------------------- -struct KeypadQueueItem -{ - char byte; -}; typedef enum { RELEASED = 0, PRESSED = (!RELEASED) -}Keypad_KeyState; +} Keypad_KeyState; + +struct KeypadQueueItem +{ + size_t rowCoordinate; + size_t columnCoordinate; + Keypad_KeyState keyEvent; +}; struct keypadElement { @@ -74,9 +77,9 @@ struct keypadElement struct Keypad { struct IODevice device; - struct keypadElement row[KEYPAD_NUMBER_OF_ROWS]; - struct keypadElement column[KEYPAD_NUMBER_OF_COLUMNS]; - Keypad_KeyState lastState[KEYPAD_NUMBER_OF_ROWS][KEYPAD_NUMBER_OF_COLUMNS]; + struct keypadElement row[KEYPAD_MAX_NUMBER_OF_ROWS]; + struct keypadElement column[KEYPAD_MAX_NUMBER_OF_COLUMNS]; + Keypad_KeyState lastState[KEYPAD_MAX_NUMBER_OF_ROWS][KEYPAD_MAX_NUMBER_OF_COLUMNS]; xTaskHandle taskHandle; int taskPriority; uint16_t stackSize; @@ -85,7 +88,8 @@ struct Keypad size_t rxQueueSize; bool initialized; int waitToDebounce_ms; - + size_t numberOfRows; + size_t numberOfColumns; }; // ----------------------------------------------------------------------------- @@ -97,6 +101,8 @@ struct Keypad * contructor for the Keypad driver * * @param self Keypad object to initialize + * @param numberOfRows Number of rows of the keypad matrix + * @param numberOfColumns Number of columns of the keypad matrix * @param debounceTime debounce time for the keypad to use * @param taskPriority Priority of the keypad task * @param stackSize Stacksize for the task @@ -107,7 +113,7 @@ struct Keypad * @todo * ----------------------------------------------------------------------------- */ -extern ErrorStatus Keypad_construct(struct Keypad* self, int debounceTime, int taskPriority, uint16_t stackSize, size_t rxQueueSize); +extern ErrorStatus Keypad_construct(struct Keypad* self, size_t numberOfRows, size_t numberOfColumns, int debounceTime, int taskPriority, uint16_t stackSize, size_t rxQueueSize); /** ---------------------------------------------------------------------------- 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 dfe6589..b2a807c 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 @@ -27,6 +27,7 @@ #include #include +#include #include "FreeRTOSFixes.h" #include "Logger.h" @@ -56,6 +57,7 @@ // Function declarations // ----------------------------------------------------------------------------- +// IO device without WRITE static ErrorStatus read(const struct IODevice* self, char* buffer, size_t length, size_t* actualLength); static void KeypadTask(void* parameters); @@ -64,7 +66,7 @@ static void KeypadTask(void* parameters); // ----------------------------------------------------------------------------- -ErrorStatus Keypad_construct(struct Keypad* self, int debounceTime, int taskPriority, uint16_t stackSize, size_t rxQueueSize) +ErrorStatus Keypad_construct(struct Keypad* self, size_t numberOfRows, size_t numberOfColumns, int debounceTime, int taskPriority, uint16_t stackSize, size_t rxQueueSize) { int rowCounter = 0; int colCounter = 0; @@ -81,14 +83,16 @@ ErrorStatus Keypad_construct(struct Keypad* self, int debounceTime, int taskPrio } self->waitToDebounce_ms = debounceTime; - self->rxQueueSize = rxQueueSize; - self->stackSize = stackSize; - self->taskPriority = taskPriority; + self->rxQueueSize = rxQueueSize; + self->stackSize = stackSize; + self->taskPriority = taskPriority; + self->numberOfRows = numberOfRows; + self->numberOfColumns = numberOfColumns; // Initialize memory to keep track of state changes per key - for (rowCounter = 0; rowCounter < KEYPAD_NUMBER_OF_ROWS; rowCounter++) + for (rowCounter = 0; rowCounter < self->numberOfRows; rowCounter++) { - for (colCounter = 0; colCounter < KEYPAD_NUMBER_OF_COLUMNS; colCounter++) + for (colCounter = 0; colCounter < self->numberOfColumns; colCounter++) { self->lastState[rowCounter][colCounter] = RELEASED; } @@ -151,7 +155,13 @@ static ErrorStatus read(const struct IODevice* self, char* buffer, size_t length if (keypad->initialized) { - *actualLength = 1; + struct KeypadQueueItem rxQueueItem; + + if (xQueueReceive(keypad->rxQueue, &rxQueueItem, portMAX_DELAY) == pdTRUE) + { + *actualLength = sizeof(struct KeypadQueueItem) / sizeof (char); + memcpy(buffer, &rxQueueItem, sizeof(struct KeypadQueueItem) / sizeof (char)); + } } else { @@ -176,25 +186,31 @@ static void KeypadTask(void* parameters) vTaskDelay(self->waitToDebounce_ms); // Set all row outputs - for (rowCounter = 0; rowCounter < KEYPAD_NUMBER_OF_ROWS; rowCounter++) + for (rowCounter = 0; rowCounter < self->numberOfRows; rowCounter++) { GPIO_SetBits(self->row[rowCounter].gpio.GPIO_Typedef, self->row[rowCounter].gpio.GPIO_InitStruct.GPIO_Pin); } // Scan through each row individually by resetting it (output level low) and check all column levels - for (rowCounter = 0; rowCounter < KEYPAD_NUMBER_OF_ROWS; rowCounter++) + for (rowCounter = 0; rowCounter < self->numberOfRows; rowCounter++) { GPIO_ResetBits(self->row[rowCounter].gpio.GPIO_Typedef, self->row[rowCounter].gpio.GPIO_InitStruct.GPIO_Pin); - for (colCounter = 0; colCounter < KEYPAD_NUMBER_OF_COLUMNS; colCounter++) + for (colCounter = 0; colCounter < self->numberOfColumns; colCounter++) { if (GPIO_ReadInputDataBit(self->column[colCounter].gpio.GPIO_Typedef, self->column[colCounter].gpio.GPIO_InitStruct.GPIO_Pin) == (uint8_t)Bit_SET) { if (self->lastState[rowCounter][colCounter] == PRESSED) { - self->lastState[rowCounter][colCounter] = RELEASED; // Key has been released + struct KeypadQueueItem rxQueueItem; + rxQueueItem.rowCoordinate = rowCounter; + rxQueueItem.columnCoordinate = colCounter; + rxQueueItem.keyEvent = RELEASED; + // Put event in queue + xQueueSend(self->rxQueue, &rxQueueItem, 0); + self->lastState[rowCounter][colCounter] = RELEASED; } else { @@ -205,8 +221,14 @@ static void KeypadTask(void* parameters) { if (self->lastState[rowCounter][colCounter] == RELEASED) { - self->lastState[rowCounter][colCounter] = PRESSED; // Key has been pressed + struct KeypadQueueItem rxQueueItem; + rxQueueItem.rowCoordinate = rowCounter; + rxQueueItem.columnCoordinate = colCounter; + rxQueueItem.keyEvent = PRESSED; + // Put event in queue + xQueueSend(self->rxQueue, &rxQueueItem, 0); + self->lastState[rowCounter][colCounter] = PRESSED; } else { @@ -218,7 +240,7 @@ static void KeypadTask(void* parameters) } // Reset all row outputs and return to IRQ status - for (rowCounter = 0; rowCounter < KEYPAD_NUMBER_OF_ROWS; rowCounter++) + for (rowCounter = 0; rowCounter < self->numberOfRows; rowCounter++) { GPIO_ResetBits(self->row[rowCounter].gpio.GPIO_Typedef, self->row[rowCounter].gpio.GPIO_InitStruct.GPIO_Pin); } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/oli_stm32_h107.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/oli_stm32_h107.c index dd39ffd..8c6f59b 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/oli_stm32_h107.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/oli_stm32_h107.c @@ -363,7 +363,7 @@ ErrorStatus initPlatform(void) IRQ_setInterruptProperties(EXTI4_IRQn, 12, 12, ENABLE); IRQ_setInterruptProperties(EXTI9_5_IRQn, 12, 12, ENABLE); - Keypad_construct(keypad, KEYPAD_DEBOUNCE_TIME_MS, KEYPAD_TASK_PRIORITY, KEYPAD_STACK_SIZE, KEYPAD_DEF_QUEUESIZE); + Keypad_construct(keypad, 4, 4, KEYPAD_DEBOUNCE_TIME_MS, KEYPAD_TASK_PRIORITY, KEYPAD_STACK_SIZE, KEYPAD_DEF_QUEUESIZE); /* --------------------------------------------------------------------*/ /* GPIOs */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Display.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Display.h index d8ba183..33fd36c 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Display.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Display.h @@ -131,6 +131,23 @@ extern void Display_destruct(struct Display* self); extern ErrorStatus Display_clearScreen(struct Display* self); +/** ---------------------------------------------------------------------------- + * Display_clearLine + * Clears one particular line on the display + * + * @param self The display information to use + * @param line Linenumber to clear + * + * @return ErrorStatus SUCCESS if clearing line was OK + * ERROR otherwise, e.g. line number out of + * bound + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus Display_clearLine(struct Display* self, size_t line); + + /** ---------------------------------------------------------------------------- * Display_setState * Sets the display state diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c index 1543a73..9d80e92 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c @@ -136,6 +136,12 @@ ErrorStatus Display_clearScreen(struct Display* self) } +ErrorStatus Display_clearLine(struct Display* self, size_t line) +{ + return DisplayDevice_clearLine(self->displayDevice, line); +} + + ErrorStatus Display_setState(struct Display* self, DisplayDevice_functionalState state) { return DisplayDevice_setState(self->displayDevice, state); 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 e966d3a..7db3edf 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 @@ -42,8 +42,10 @@ #include "stm32f10x_rcc.h" #include "DisplayDevice.h" +#include "KeyboardDevice.h" #include "MAX5715.h" #include "nhd0420.h" +#include "storm700.h" #include "platform.h" #include "internalADC.h" @@ -104,6 +106,9 @@ struct MAX5715* dac = &max5715; struct RepairMenu* rm = &_rm; struct HwValidationMenu* hwValidation = &_hwValidation; +static struct Storm700 _storm700 = {.initialized = false}; +struct Storm700* storm700 = &_storm700; + // ----------------------------------------------------------------------------- // Function declarations // ----------------------------------------------------------------------------- @@ -194,6 +199,8 @@ static void initTask(void* parameters) Logger_construct(mainLog, &uart3->device, 1, 512); + Storm700_construct(storm700, &keypad->device); + NHD0420_construct(&nhd0420, &spiDisplay->device); Display_construct(display, &nhd0420.displayDevice, 2, 256, 10, 1000, 10000); @@ -249,9 +256,10 @@ static void initTask(void* parameters) // EEPROM TO BE DONE HwValidationMenu_construct(hwValidation, &uart1->device, &hwTestItems, 1, 512); + // Construct the repair menu repairMenu_construct(rm, display, 2, 512); - // Delete this init task + // Delete this init task vTaskDelete(NULL); } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c index 6625cf2..4b9904b 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c @@ -36,6 +36,9 @@ #include "internalADC.h" #include "MAX5715.h" +#include "KeyboardDevice.h" +#include "storm700.h" + // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- @@ -134,11 +137,24 @@ 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_write(self->display, " ", 20, 3, 1); + Display_clearLine(self->display, 3); + + char key; + Keypad_KeyState keyState; + if (Storm700_readKey(storm700, &key, &keyState) == SUCCESS) + { + LOGGER_DEBUG(mainLog, "Got key %c %d", key, keyState); + } + else + { + LOGGER_ERROR(mainLog, "Getting key failed"); + } + struct RepairProcessParameters rpParameters; rpParameters.adcRow1 = &adc1->channel[0]; @@ -148,10 +164,8 @@ static void repairMenu_task(void* parameters) rpParameters.dacRow2 = &dac->dac[1]; rpParameters.dacRow3 = &dac->dac[2]; - MAX5715Channel_setValue(&dac->dac[1], 0xE00); - - struct RepairPresetParameters presetStage1 = {.voltage = 0xA00, .duration = 5000, .softstartDuration = 1000}; - struct RepairPresetParameters presetStage2 = {.voltage = 0xE00, .duration = 1000, .softstartDuration = 2000}; + struct RepairPresetParameters presetStage1 = {.voltage = 0xA00, .duration = 300, .softstartDuration = 120}; + struct RepairPresetParameters presetStage2 = {.voltage = 0xE00, .duration = 120, .softstartDuration = 30}; struct RepairPreset repairPreset; repairPreset.numberOfStages = 2; diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairProcess.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairProcess.c index 2b87a7a..373afa9 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairProcess.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairProcess.c @@ -61,7 +61,9 @@ static void repairProcess_task(void* parameters); -static void calculateSoftStartStep (uint32_t currentTime, uint32_t softStartDuration, int targetVoltage, uint16_t* dacValue); +static void SignalProfileGenerator(); + + // ----------------------------------------------------------------------------- // Function definitions @@ -209,24 +211,24 @@ static void repairProcess_task(void* parameters) { // Perform softstart / ramp-up - if (PCBA_getInstance()->pcba == Tesla) - { - // Tesla repair only runs ADC row2 and DAC row2 - calculateSoftStartStep(self->secondsCounter, softStartTimer, voltageTarget, &voltageRow2); - LOGGER_DEBUG(mainLog, "Softstart running -> new target is %x", voltageRow2); - MAX5715Channel_setValue(self->dacRow2, voltageRow2); - } - else if ((PCBA_getInstance()->pcba == Anode) || (PCBA_getInstance()->pcba == CathodeMCP)) - { - calculateSoftStartStep(self->secondsCounter, softStartTimer, voltageTarget, &voltageRow1); - calculateSoftStartStep(self->secondsCounter, softStartTimer, voltageTarget, &voltageRow2); - calculateSoftStartStep(self->secondsCounter, softStartTimer, voltageTarget, &voltageRow3); - LOGGER_DEBUG(mainLog, "Softstart running -> new target is %x %x %x", voltageRow1, voltageRow2, voltageRow3); - - MAX5715Channel_setValue(self->dacRow1, voltageRow1); - MAX5715Channel_setValue(self->dacRow2, voltageRow2); - MAX5715Channel_setValue(self->dacRow3, voltageRow3); - } +// if (PCBA_getInstance()->pcba == Tesla) +// { +// // Tesla repair only runs ADC row2 and DAC row2 +// calculateSoftStartStep(self->secondsCounter, softStartTimer, voltageTarget, &voltageRow2); +// LOGGER_DEBUG(mainLog, "Softstart running -> new target is %x", voltageRow2); +// MAX5715Channel_setValue(self->dacRow2, voltageRow2); +// } +// else if ((PCBA_getInstance()->pcba == Anode) || (PCBA_getInstance()->pcba == CathodeMCP)) +// { +// calculateSoftStartStep(self->secondsCounter, softStartTimer, voltageTarget, &voltageRow1); +// calculateSoftStartStep(self->secondsCounter, softStartTimer, voltageTarget, &voltageRow2); +// calculateSoftStartStep(self->secondsCounter, softStartTimer, voltageTarget, &voltageRow3); +// LOGGER_DEBUG(mainLog, "Softstart running -> new target is %x %x %x", voltageRow1, voltageRow2, voltageRow3); +// +// MAX5715Channel_setValue(self->dacRow1, voltageRow1); +// MAX5715Channel_setValue(self->dacRow2, voltageRow2); +// MAX5715Channel_setValue(self->dacRow3, voltageRow3); +// } // Check for end of softstart if (softStartTimer < self->secondsCounter) @@ -282,6 +284,12 @@ static void repairProcess_task(void* parameters) // A next stage is available presetIndex++; self->currentState = PREPARE; + LOGGER_DEBUG(mainLog, "Another stage is available"); + } + else + { + self->currentState = FINISHED; + LOGGER_DEBUG(mainLog, "last stage reached"); } break; } @@ -313,13 +321,4 @@ static void repairProcess_task(void* parameters) } -static void calculateSoftStartStep (uint32_t currentTime, uint32_t softStartDuration, int targetVoltage, uint16_t* dacValue) -{ - int value; - value = ((currentTime * 1000) / softStartDuration) * targetVoltage; - - value = value / 1000; - - *dacValue = (uint16_t)value; -} 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 6473606..39c9755 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 @@ -89,11 +89,14 @@ void IRQ_setInterruptProperties(uint8_t irqChannel, uint8_t preemptionPriority, void IRQ_setKeypadEXTI(struct Keypad* self, FunctionalState command) { - int colCounter; - for (colCounter = 0; colCounter < KEYPAD_NUMBER_OF_COLUMNS; colCounter++) + if (self->initialized) { - self->column[colCounter].EXTI_InitStruct.EXTI_LineCmd = command; - EXTI_Init(&self->column[colCounter].EXTI_InitStruct); + int colCounter; + for (colCounter = 0; colCounter < self->numberOfColumns; colCounter++) + { + self->column[colCounter].EXTI_InitStruct.EXTI_LineCmd = command; + EXTI_Init(&self->column[colCounter].EXTI_InitStruct); + } } }