- 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,48 @@
CROSS_COMPILE = arm-none-eabi-
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
OBJDIR = obj
SRCDIR = src/
ROOTDIR = ../../
LIBRARY_NAME = ../libKeypad.a
CCFLAGS = -c -O2 -Wall -g -fno-common -mcpu=cortex-m3 -mthumb \
-Iinc \
-I../Platform/inc \
-I../Misc/inc \
-I$(ROOTDIR)/hsb-mrts/inc \
-I$(ROOTDIR)/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc \
-I$(ROOTDIR)/FreeRTOS/Source/include \
-I$(ROOTDIR)/FreeRTOS/Source/portable/GCC/ARM_CM3 \
-I$(ROOTDIR)/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x \
-I$(ROOTDIR)/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/CoreSupport
ARFLAGS = rs
OBJECTS = \
keypadMatrix.o \
vpath %.o $(OBJDIR)
vpath %.c $(SRCDIR)
all: $(LIBRARY_NAME)
$(LIBRARY_NAME): $(OBJDIR) $(OBJECTS)
$(AR) $(ARFLAGS) $@ $(addprefix $(OBJDIR)/, $(OBJECTS))
%.o: %.c
$(CC) $(CCFLAGS) $< -o $(OBJDIR)/$@
$(OBJDIR):
mkdir -p $@
clean:
rm -rf $(OBJDIR) $(LIBRARY_NAME)
.PHONY: all clean

View File

@@ -0,0 +1,83 @@
// -----------------------------------------------------------------------------
/// @file keypadMatrix.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) 2017 Micro-Key bv
// -----------------------------------------------------------------------------
/// @defgroup {group_name} {group_description}
/// Description
/// @file keypadMatrix.h
/// @ingroup {group_name}
#ifndef KEYPAD_INC_KEYPADMATRIX_H_
#define KEYPAD_INC_KEYPADMATRIX_H_
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include "platform.h"
#include "stm32f10x_exti.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
#define KEYPAD_NUMBER_OF_ROWS (4)
#define KEYPAD_NUMBER_OF_COLUMNS (4)
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
struct keypadElement
{
T_PL_GPIO gpio;
EXTI_InitTypeDef EXTI_InitStruct;
};
struct Keypad
{
struct keypadElement row[KEYPAD_NUMBER_OF_ROWS];
struct keypadElement column[KEYPAD_NUMBER_OF_COLUMNS];
};
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
/** ----------------------------------------------------------------------------
* Keypad_construct
* contructor for the Keypad driver
*
* @return ErrorStatus SUCCESS if initialisation was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus Keypad_construct(void);
extern ErrorStatus Keypad_logModuleInfo(void);
#endif /* KEYPAD_INC_KEYPADMATRIX_H_ */

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)
);
}
}