update for SWO - hw validation menu integrated

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@239 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-10-06 07:46:54 +00:00
parent ab3301889c
commit 5105d55089
12 changed files with 143 additions and 84 deletions

View File

@@ -32,6 +32,8 @@
// Include files
// -----------------------------------------------------------------------------
#include <stdbool.h>
#include "FreeRTOS.h"
#include "semphr.h"
#include "task.h"
@@ -76,14 +78,14 @@ struct Keypad
struct keypadElement column[KEYPAD_NUMBER_OF_COLUMNS];
Keypad_KeyState lastState[KEYPAD_NUMBER_OF_ROWS][KEYPAD_NUMBER_OF_COLUMNS];
xTaskHandle taskHandle;
int taskPriority;
uint16_t stackSize;
SemaphoreHandle_t scanSemaphore;
xQueueHandle rxQueue;
size_t rxQueueSize;
bool initialized;
int waitToDebounce_ms;
};
struct KeypadParameters
{
int rxQueueSize;
};
// -----------------------------------------------------------------------------
@@ -95,8 +97,9 @@ struct KeypadParameters
* contructor for the Keypad driver
*
* @param self Keypad object to initialize
* @param parameters Parameters to use for initialisation
* @param debounceTime debounce time for the keypad to use
* @param taskPriority Priority of the keypad task
* @param stackSize Stacksize for the task
*
* @return ErrorStatus SUCCESS if initialisation was successful
* ERROR otherwise
@@ -104,7 +107,7 @@ struct KeypadParameters
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* parameters, int debounceTime);
extern ErrorStatus Keypad_construct(struct Keypad* self, int debounceTime, int taskPriority, uint16_t stackSize, size_t rxQueueSize);
/** ----------------------------------------------------------------------------
@@ -121,21 +124,6 @@ extern ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters
*/
extern void Keypad_destruct (const struct Keypad* self);
/** ----------------------------------------------------------------------------
* Keypad_getDefaultParameters
* Returns default parameters for a keypad
*
* @param parameters Keypad parameters struct that will be
* filled with default values
*
* @return ErrorStatus SUCCESS if initialisation was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus Keypad_getDefaultParameters(struct KeypadParameters* parameters);
#endif /* KEYPAD_INC_KEYPADMATRIX_H_ */

View File

@@ -40,9 +40,6 @@
// Constant and macro definitions
// -----------------------------------------------------------------------------
#define KEYPAD_STACK_SIZE (512)
#define KEYPAD_TASK_PRIORITY (3)
#define KEYPAD_DEF_QUEUESIZE (32)
// -----------------------------------------------------------------------------
// Type definitions
@@ -67,13 +64,13 @@ static void KeypadTask(void* parameters);
// -----------------------------------------------------------------------------
ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* parameters, int debounceTime)
ErrorStatus Keypad_construct(struct Keypad* self, int debounceTime, int taskPriority, uint16_t stackSize, size_t rxQueueSize)
{
int rowCounter = 0;
int colCounter = 0;
ErrorStatus returnValue = SUCCESS;
if(keypad != NULL)
if(!self->initialized)
{
IODevice_construct(&self->device, read, NULL);
@@ -84,6 +81,9 @@ ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* param
}
self->waitToDebounce_ms = debounceTime;
self->rxQueueSize = rxQueueSize;
self->stackSize = stackSize;
self->taskPriority = taskPriority;
// Initialize memory to keep track of state changes per key
for (rowCounter = 0; rowCounter < KEYPAD_NUMBER_OF_ROWS; rowCounter++)
@@ -95,7 +95,7 @@ ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* param
}
//! Create a new FREERTOS queue to handle data from Keypad input to app
self->rxQueue = xQueueCreate(parameters->rxQueueSize, sizeof(struct KeypadQueueItem));
self->rxQueue = xQueueCreate(self->rxQueueSize, sizeof(struct KeypadQueueItem));
if (self->rxQueue == 0)
{
//! Queue identifier is 0 -> error
@@ -104,7 +104,7 @@ ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* param
if(returnValue == SUCCESS)
{
xTaskCreate(KeypadTask, (const char*)"keypadTask", KEYPAD_STACK_SIZE, keypad, KEYPAD_TASK_PRIORITY, self->taskHandle);
xTaskCreate(KeypadTask, (const char*)"keypadTask", self->stackSize, keypad, self->taskPriority, &self->taskHandle);
}
if(returnValue == SUCCESS)
@@ -120,12 +120,17 @@ ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* param
if(returnValue == SUCCESS)
{
LOGGER_INFO(mainLog, "Keypad task started");
self->initialized = true;
}
else
{
LOGGER_ERROR(mainLog, "Keypad task FAILED");
}
}
else
{
returnValue = ERROR;
}
return returnValue;
}
@@ -138,22 +143,22 @@ void Keypad_Destruct (const struct Keypad* self)
}
ErrorStatus Keypad_getDefaultParameters(struct KeypadParameters* parameters)
{
ErrorStatus errorStatus = SUCCESS;
parameters->rxQueueSize = KEYPAD_DEF_QUEUESIZE;
return errorStatus;
}
static ErrorStatus read(const struct IODevice* self, char* buffer, size_t length, size_t* actualLength)
{
ErrorStatus errorStatus = SUCCESS;
ErrorStatus returnValue = SUCCESS;
*actualLength = 1;
const struct Keypad* keypad = (const struct Keypad*)self;
return errorStatus;
if (keypad->initialized)
{
*actualLength = 1;
}
else
{
returnValue = ERROR;
}
return returnValue;
}

View File

@@ -62,7 +62,7 @@
#define UART_LOG_TX_QUEUE (256)
// UART3 Settings (Developer terminal)
#define UART_TER_BAUDRATE (115200)
#define UART_TER_BAUDRATE (57600)
#define UART_TER_TX_QUEUE (512)
// SPI1 settings
@@ -74,6 +74,9 @@
// Keypad Settings
#define KEYPAD_DEBOUNCE_TIME_MS (20)
#define KEYPAD_STACK_SIZE (128)
#define KEYPAD_TASK_PRIORITY (3)
#define KEYPAD_DEF_QUEUESIZE (32)
// -----------------------------------------------------------------------------
// Type definitions
// -----------------------------------------------------------------------------
@@ -120,7 +123,6 @@ static struct SpiDevice _spiEEPROM;
// Keypad
static struct Keypad _keypad;
static struct KeypadParameters _keypadParameters;
// The following pointers are for export (see platform.h) and external use.
@@ -153,7 +155,6 @@ struct SpiDevice* const spiEEPROM = &_spiEEPROM;
struct SpiParameters* const spiEEPROMParam = &_spi3EEPROMParameters;
struct Keypad* const keypad = &_keypad;
struct KeypadParameters* const keypadParam = &_keypadParameters;
// -----------------------------------------------------------------------------
// Function declarations
@@ -350,8 +351,7 @@ ErrorStatus initPlatform(void)
IRQ_setInterruptProperties(EXTI4_IRQn, 12, 12, ENABLE);
IRQ_setInterruptProperties(EXTI9_5_IRQn, 12, 12, ENABLE);
Keypad_getDefaultParameters(keypadParam);
Keypad_construct(keypad, keypadParam, KEYPAD_DEBOUNCE_TIME_MS);
Keypad_construct(keypad, KEYPAD_DEBOUNCE_TIME_MS, KEYPAD_TASK_PRIORITY, KEYPAD_STACK_SIZE, KEYPAD_DEF_QUEUESIZE);
}
return returnValue;

View File

@@ -91,6 +91,10 @@ ErrorStatus RTC_construct(struct Rtc* self)
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
// Reset the counter
RTC_SetCounter(0x00);
return returnValue;
}