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:
mmi
2017-10-04 09:06:16 +00:00
parent 802e9c64ca
commit c613e64e8a
24 changed files with 1147 additions and 231 deletions

View File

@@ -0,0 +1,70 @@
// -----------------------------------------------------------------------------
/// @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_ */

View File

@@ -69,18 +69,16 @@ struct Pcba
* PCBA_construct
* Initializes the PCBA information of the hardware.
* PCBA information is defined via placed resistors
* This function can only be called once. Within the first call an internal flag
* is set to prevent any further calling. That is because the PCBA information
* cannot change during run-time
* This function creates a singleton. Calling this function for the first time
* constructs the PCBA information. Calling it afterwards returns the already
* constructed data
*
* @param self The PCBA information
* @return struct Pcba* The PCBA information singelton
*
* @return ErrorStatus SUCCESS if construction was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus PCBA_construct(struct Pcba* self);
extern struct Pcba* PCBA_getInstance(void);
#endif /* PCBA_H_ */

View File

@@ -0,0 +1,77 @@
// -----------------------------------------------------------------------------
/// @file Version.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 Version.h
/// @ingroup {group_name}
#ifndef INC_VERSION_H_
#define INC_VERSION_H_
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include "stm32f10x.h"
#include "platform.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
struct Version
{
int major;
int minor;
int branch;
int patch;
};
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
/** ----------------------------------------------------------------------------
* Version_getInstance
* Initialises the Version information.
* Version information is supplied via macros in makefile
* This function creates a singleton. Calling this function for the first time
* constructs the Version information. Calling it afterwards returns the already
* constructed data
*
* @return struct Version* The Version information singleton
*
*
* @todo
* -----------------------------------------------------------------------------
*/
extern struct Version* Version_getInstance(void);
#endif /* INC_VERSION_H_ */

View File

@@ -31,6 +31,8 @@
// Include files
// -----------------------------------------------------------------------------
#include <stdbool.h>
#include "platform.h"
#include "IODevice.h"
@@ -42,21 +44,55 @@
// -----------------------------------------------------------------------------
#define ADC_NUMBER_OF_CHANNELS (18) // 16 IOs + Temp + Vcc
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
struct Adc; // Prototype
struct AdcChannelParameters
{
uint8_t channel;
uint8_t Rank;
uint8_t ADC_SampleTime;
};
struct AdcChannel
{
struct IODevice device;
struct Adc* parent;
uint8_t channel;
uint8_t Rank;
uint8_t ADC_SampleTime;
T_PL_GPIO input;
};
struct AdcParameters
{
uint32_t ADC_Mode;
FunctionalState ADC_ScanConvMode;
FunctionalState ADC_ContinuousConvMode;
uint32_t ADC_ExternalTrigConv;
uint32_t ADC_DataAlign;
uint8_t ADC_NbrOfChannel;
};
struct Adc
{
struct IODevice device;
ADC_InitTypeDef adc_InitStruct;
T_PL_GPIO input;
ADC_TypeDef* ADCx;
ADC_InitTypeDef ADC_InitStruct;
bool useDMA;
bool useRanks;
struct AdcChannel channel[ADC_NUMBER_OF_CHANNELS];
// Only necessary when the RANK parameter determines conversion order or RANK is used anyway
// For single conversions the READ function simply returns the converted value
// Note that the content of this array IS NOT SORTED BY CHANNEL NUMBER but sorted BY RANK NUMBER
// When initialising an ADC channel to a regular group, the RANK parameter determines the
// order of convertions. E.G. channel 5 can be put first while channel 1 can be put last.
// The array index stands for the RANK
uint16_t channelValue[ADC_NUMBER_OF_CHANNELS];
};
// -----------------------------------------------------------------------------
@@ -79,4 +115,118 @@ struct Adc
*/
extern ErrorStatus ADC_construct(struct Adc* self, struct AdcParameters* parameters);
/** ----------------------------------------------------------------------------
* ADC_destruct
* Destructor for an ADC instance
*
* @param self The ADC instance to destruct
*
* @return ErrorStatus SUCCESS if initialisation was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void ADC_destruct(struct Adc* self);
/** ----------------------------------------------------------------------------
* ADC_performInternalCalibration
* Apply internal ADC calibration to ADC instance
* ADC calibration is RESET and afterwards set.
*
* @param self The ADC instance to calibrate
*
* @return ErrorStatus SUCCESS if initialisation was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus ADC_performInternalCalibration(const struct Adc* self);
/** ----------------------------------------------------------------------------
* ADC_setStatus
* Changes the status of the ADC instance
*
* @param self The ADC instance
* @param command new command for the ADC instance
* - ENABLE
* - DISABLE
*
* @return ErrorStatus SUCCESS if initialisation was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus ADC_setStatus (struct Adc* self, FunctionalState command);
/** ----------------------------------------------------------------------------
* ADC_setDMAStatus
* Changes the status of the ADC instance's DMA
*
* @param self The ADC instance
* @param command new command for the ADC instance
* - ENABLE
* - DISABLE
*
* @return ErrorStatus SUCCESS if initialisation was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus ADC_setDMAStatus (struct Adc* self, FunctionalState command);
/** ----------------------------------------------------------------------------
* ADCChannel_construct
* Constructor for ADC channel instance
*
* @param self The ADC channel instance to initialize
* @param parameters Additional ADC parameters
*
* @return ErrorStatus SUCCESS if initialisation was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus ADCChannel_construct(struct AdcChannel* self, struct AdcChannelParameters* parameters);
/** ----------------------------------------------------------------------------
* ADCChannel_destruct
* Destructor for an ADC channel instance
*
* @param self The ADC channel instance to destruct
*
* @return ErrorStatus SUCCESS if initialisation was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void ADCChannel_destruct(struct AdcChannel* self);
/** ----------------------------------------------------------------------------
* ADCChannel_read
* Read the current conversion value of the ADC channel in argument self
*
* @param self ADC channel object
* @param value The read value
*
* @return ErrorStatus SUCCESS if initialisation was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus ADCChannel_read(struct AdcChannel* self, uint16_t* value);
#endif /* INC_ADC_H_ */

View File

@@ -0,0 +1,141 @@
// -----------------------------------------------------------------------------
/// @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_ */

View File

@@ -61,11 +61,13 @@ typedef struct
} T_PL_GPIO;
// Export of PCBA information
extern struct Pcba* const pcba;
extern struct Pcba* pcba;
// Export of LEDs
extern struct Led* const ledGreen;
extern struct Led* const ledOrange;
// Export of ADCs
extern struct Adc* const adc1;
// Export of the rtc
extern struct Rtc* const rtc;
// Export of UARTs