ADC debugged and functional now
Added Version interface Added DisplayDevice to create an independent bridge between display app and specific display driver git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@228 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file DisplayDevice.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) 2015 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {group_name} {group_description}
|
||||
/// Description
|
||||
|
||||
/// @file DisplayDevice.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
#ifndef INC_DISPLAYDEVICE_H_
|
||||
#define INC_DISPLAYDEVICE_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
typedef enum
|
||||
{
|
||||
OFF = 0,
|
||||
ON = !OFF
|
||||
} DisplayDevice_functionalState;
|
||||
|
||||
struct DisplayDevice;
|
||||
|
||||
typedef ErrorStatus (*DisplayResetFunction)(const struct DisplayDevice* self);
|
||||
typedef ErrorStatus (*DisplaySetStateFunction)(const struct DisplayDevice* self, DisplayDevice_functionalState state);
|
||||
typedef ErrorStatus (*DisplayWriteFunction)(const struct DisplayDevice* self, const char* buffer, size_t length, size_t row, size_t column);
|
||||
typedef ErrorStatus (*DisplayClearFunction)(const struct DisplayDevice* self);
|
||||
typedef ErrorStatus (*DisplaySetBrightnessFunction)(const struct DisplayDevice* self, size_t brightness);
|
||||
typedef ErrorStatus (*DisplaySetContrastFunction)(const struct DisplayDevice* self, size_t contrast);
|
||||
typedef ErrorStatus (*DisplayInvertFunction)(const struct DisplayDevice* self);
|
||||
|
||||
struct DisplayDeviceParameters
|
||||
{
|
||||
size_t numberOfRows;
|
||||
size_t numberOfColumns;
|
||||
size_t contrastMin;
|
||||
size_t contrastMax;
|
||||
size_t brightnessMin;
|
||||
size_t brightnessMax;
|
||||
};
|
||||
|
||||
struct DisplayDevice
|
||||
{
|
||||
DisplayResetFunction _reset;
|
||||
DisplaySetStateFunction _setState;
|
||||
DisplayWriteFunction _write;
|
||||
DisplayClearFunction _clear;
|
||||
DisplaySetBrightnessFunction _setBrightness;
|
||||
DisplaySetContrastFunction _setContrast;
|
||||
DisplayInvertFunction _invert;
|
||||
struct DisplayDeviceParameters parameters;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
extern ErrorStatus DisplayDevice_construct (struct DisplayDevice* self, struct DisplayDeviceParameters* parameters,
|
||||
DisplayResetFunction reset,
|
||||
DisplaySetStateFunction setState,
|
||||
DisplayWriteFunction write,
|
||||
DisplayClearFunction clear,
|
||||
DisplaySetBrightnessFunction setBrightness,
|
||||
DisplaySetContrastFunction setContrast,
|
||||
DisplayInvertFunction invert);
|
||||
|
||||
extern ErrorStatus DisplayDevice_reset(const struct DisplayDevice* self);
|
||||
extern ErrorStatus DisplayDevice_setState(const struct DisplayDevice* self, DisplayDevice_functionalState state);
|
||||
extern ErrorStatus DisplayDevice_write(const struct DisplayDevice* self, const char* buffer, size_t length, size_t row, size_t column);
|
||||
extern ErrorStatus DisplayDevice_clear(const struct DisplayDevice* self);
|
||||
extern ErrorStatus DisplayDevice_setBrightness(const struct DisplayDevice* self, size_t brightness);
|
||||
extern ErrorStatus DisplayDevice_setContrast(const struct DisplayDevice* self, size_t contrast);
|
||||
extern ErrorStatus DisplayDevice_invert(const struct DisplayDevice* self);
|
||||
|
||||
#endif /* INC_DISPLAYDEVICE_H_ */
|
||||
@@ -1,70 +0,0 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file IODevice.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 IODevice.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
#ifndef MISC_INC_IODEVICE_H_
|
||||
#define MISC_INC_IODEVICE_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
struct IODevice;
|
||||
|
||||
typedef ErrorStatus (*ReadFunction)(const struct IODevice* self, char* buffer, size_t length, size_t* actualLength);
|
||||
typedef ErrorStatus (*WriteFunction)(const struct IODevice* self, const char* buffer, size_t length);
|
||||
|
||||
struct IODevice
|
||||
{
|
||||
ReadFunction _read;
|
||||
WriteFunction _write;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
extern ErrorStatus IODevice_construct (struct IODevice* self, ReadFunction read, WriteFunction write);
|
||||
|
||||
extern ErrorStatus IODevice_write(const struct IODevice* self, const char* buffer, size_t length);
|
||||
|
||||
extern ErrorStatus IODevice_read(const struct IODevice* self, char* buffer, size_t length, size_t* actualLength);
|
||||
|
||||
|
||||
#endif /* MISC_INC_IODEVICE_H_ */
|
||||
@@ -1,141 +0,0 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @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 "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;
|
||||
SemaphoreHandle_t scanSemaphore;
|
||||
xQueueHandle rxQueue;
|
||||
int waitToDebounce_ms;
|
||||
};
|
||||
|
||||
struct KeypadParameters
|
||||
{
|
||||
int rxQueueSize;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Keypad_construct
|
||||
* contructor for the Keypad driver
|
||||
*
|
||||
* @param self Keypad object to initialize
|
||||
* @param parameters Parameters to use for initialisation
|
||||
* @param debounceTime debounce time for the keypad to use
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if initialisation was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* parameters, int debounceTime);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* 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);
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Keypad_getDefaultParameters
|
||||
* Returns default parameters for a keypad
|
||||
*
|
||||
* @param parameters Keypad parameters struct that will be
|
||||
* filled with default values
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if initialisation was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus Keypad_getDefaultParameters(struct KeypadParameters* parameters);
|
||||
|
||||
|
||||
|
||||
#endif /* KEYPAD_INC_KEYPADMATRIX_H_ */
|
||||
@@ -32,6 +32,7 @@
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "DisplayDevice.h"
|
||||
#include "IODevice.h"
|
||||
#include "spi.h"
|
||||
|
||||
@@ -118,6 +119,7 @@
|
||||
|
||||
struct NHD0420
|
||||
{
|
||||
struct DisplayDevice displayDevice;
|
||||
const struct IODevice* device;
|
||||
};
|
||||
|
||||
@@ -182,7 +184,7 @@ extern ErrorStatus NHD0420_getSpiParameters(struct SpiParameters* parameters);
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus NHD0420_setCursorToPosition(const struct NHD0420* self, char row, char column);
|
||||
extern ErrorStatus NHD0420_setCursorToPosition(const struct NHD0420* self, size_t row, size_t column);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user