git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@427 05563f52-14a8-4384-a975-3d1654cca0fa
144 lines
4.3 KiB
C
144 lines
4.3 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
|
|
// -----------------------------------------------------------------------------
|
|
|
|
/**
|
|
* %Keypad implementation
|
|
* \defgroup Keypad Package Keypad
|
|
* \ingroup Platform
|
|
* @{
|
|
*/
|
|
|
|
|
|
#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;
|
|
};
|
|
|
|
/**
|
|
* \class Keypad
|
|
* \extends IODevice
|
|
*/
|
|
struct Keypad
|
|
{
|
|
struct IODevice device; //!< \private
|
|
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_ */
|
|
|
|
/** @} */
|