Files
hsb/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/keypadMatrix.h
mmi 088ce81dc7 Most parts of the menu structure are functional.
Error handler added
Screens for warning, pause, FINISH etc yet to be added

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@255 05563f52-14a8-4384-a975-3d1654cca0fa
2017-10-17 15:23:56 +00:00

137 lines
4.2 KiB
C

// -----------------------------------------------------------------------------
/// @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 <stdbool.h>
#include "FreeRTOS.h"
#include "semphr.h"
#include "task.h"
#include "platform.h"
#include "IODevice.h"
#include "stm32f10x_exti.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
#define KEYPAD_MAX_NUMBER_OF_ROWS (6)
#define KEYPAD_MAX_NUMBER_OF_COLUMNS (6)
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
typedef enum
{
RELEASED = 0,
PRESSED = (!RELEASED),
NUMBER_OF_KEY_EVENTS
} Keypad_KeyState;
struct KeypadQueueItem
{
size_t rowCoordinate;
size_t columnCoordinate;
Keypad_KeyState keyEvent;
};
struct keypadElement
{
T_PL_GPIO gpio;
EXTI_InitTypeDef EXTI_InitStruct;
};
struct Keypad
{
struct IODevice device;
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;
SemaphoreHandle_t scanSemaphore;
xQueueHandle rxQueue;
size_t rxQueueSize;
bool initialized;
int waitToDebounce_ms;
size_t numberOfRows;
size_t numberOfColumns;
};
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
/** ----------------------------------------------------------------------------
* Keypad_construct
* 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
*
* @return ErrorStatus SUCCESS if initialisation was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus Keypad_construct(struct Keypad* self, size_t numberOfRows, size_t numberOfColumns, int debounceTime, int taskPriority, uint16_t stackSize, size_t rxQueueSize);
/** ----------------------------------------------------------------------------
* Keypad_destruct
* destructor for the Keypad driver
*
* @param self Keypad object to destruct
*
* @return ErrorStatus SUCCESS if initialisation was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void Keypad_destruct (const struct Keypad* self);
#endif /* KEYPAD_INC_KEYPADMATRIX_H_ */