// ----------------------------------------------------------------------------- /// @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 #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_NUMBER_OF_ROWS (4) #define KEYPAD_NUMBER_OF_COLUMNS (4) // ----------------------------------------------------------------------------- // Type definitions. // ----------------------------------------------------------------------------- struct KeypadQueueItem { char byte; }; typedef enum { RELEASED = 0, PRESSED = (!RELEASED) }Keypad_KeyState; struct keypadElement { T_PL_GPIO gpio; EXTI_InitTypeDef EXTI_InitStruct; }; struct Keypad { struct IODevice device; struct keypadElement row[KEYPAD_NUMBER_OF_ROWS]; 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; }; // ----------------------------------------------------------------------------- // Function declarations // ----------------------------------------------------------------------------- /** ---------------------------------------------------------------------------- * Keypad_construct * contructor for the Keypad driver * * @param self Keypad object to initialize * @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, 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_ */