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

@@ -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_ */