- added IODevice support

- fixed some issues with the logger and stack sizes

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@216 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-09-26 11:11:33 +00:00
parent 7bcde7ff5d
commit 1bcb4809db
48 changed files with 1033 additions and 11740 deletions

View File

@@ -0,0 +1,133 @@
// -----------------------------------------------------------------------------
/// @file keypadMatrix.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 keypadMatrix.c
/// @ingroup {group_name}
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include <stdbool.h>
#include <stdio.h>
#include "FreeRTOS.h"
#include "task.h"
#include "FreeRTOSFixes.h"
#include "Logger.h"
#include "keypadMatrix.h"
#include "platform.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
#define KEYPAD_STACK_SIZE (512)
#define KEYPAD_TASK_PRIORITY (3)
// -----------------------------------------------------------------------------
// Type definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// File-scope variables
// -----------------------------------------------------------------------------
static bool initialized = false;
static xTaskHandle keypadTaskHandle = NULL;
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
static void KeypadTask(void* parameters);
// -----------------------------------------------------------------------------
// Function definitions
// -----------------------------------------------------------------------------
ErrorStatus Keypad_construct(void)
{
ErrorStatus returnValue = SUCCESS;
BaseType_t taskCreateReturn;
if(!initialized)
{
if(returnValue == SUCCESS)
{
taskCreateReturn = xTaskCreate(KeypadTask, (const char*)"keypadTask", KEYPAD_STACK_SIZE, NULL, KEYPAD_TASK_PRIORITY, &keypadTaskHandle);
if(taskCreateReturn != pdPASS)
{
returnValue = ERROR;
}
}
if(returnValue == SUCCESS)
{
initialized = true;
LOGGER_INFO("Keypad task started");
// GPIO_SetBits(kRow1->rowGpio.GPIO_Typedef, kRow1->rowGpio.GPIO_InitStruct.GPIO_Pin);
}
else
{
LOGGER_ERROR("Keypad task FAILED with code %x", (unsigned int)taskCreateReturn);
}
}
return returnValue;
}
ErrorStatus Keypad_logModuleInfo(void)
{
ErrorStatus errorStatus = SUCCESS;
OS_logTaskInfo(keypadTaskHandle);
return errorStatus;
}
void Keypad_Destruct (void)
{
initialized = false;
}
static void KeypadTask(void* parameters)
{
while (1)
{
vTaskDelay(1000);
LOGGER_DEBUG("ROW1: %d, ROW2: %d, ROW3: %d, ROW4: %d - Col1: %d, Col2: %d, Col3: %d, Col4: %d",
GPIO_ReadOutputDataBit(keypad->row[0].gpio.GPIO_Typedef, keypad->row[0].gpio.GPIO_InitStruct.GPIO_Pin),
GPIO_ReadOutputDataBit(keypad->row[1].gpio.GPIO_Typedef, keypad->row[1].gpio.GPIO_InitStruct.GPIO_Pin),
GPIO_ReadOutputDataBit(keypad->row[2].gpio.GPIO_Typedef, keypad->row[2].gpio.GPIO_InitStruct.GPIO_Pin),
GPIO_ReadOutputDataBit(keypad->row[3].gpio.GPIO_Typedef, keypad->row[3].gpio.GPIO_InitStruct.GPIO_Pin),
GPIO_ReadInputDataBit(keypad->column[0].gpio.GPIO_Typedef, keypad->column[0].gpio.GPIO_InitStruct.GPIO_Pin),
GPIO_ReadInputDataBit(keypad->column[1].gpio.GPIO_Typedef, keypad->column[1].gpio.GPIO_InitStruct.GPIO_Pin),
GPIO_ReadInputDataBit(keypad->column[2].gpio.GPIO_Typedef, keypad->column[2].gpio.GPIO_InitStruct.GPIO_Pin),
GPIO_ReadInputDataBit(keypad->column[3].gpio.GPIO_Typedef, keypad->column[3].gpio.GPIO_InitStruct.GPIO_Pin)
);
}
}