From e4e0d6d36d703330bffb33a96fbf03c0e03555b4 Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Sat, 7 Jun 2014 19:49:20 +0000 Subject: [PATCH] --- Project/applications/smartcities/adc.c | 54 ++++++++++++++++++++++-------------------------------- Project/applications/smartcities/doc/doxygen/Doxyfile | 2 +- Project/applications/smartcities/include/adc.h | 45 ++++++++++++++++++++++++++++++++++++--------- 3 files changed, 59 insertions(+), 42 deletions(-) diff --git a/Project/applications/smartcities/adc.c b/Project/applications/smartcities/adc.c index dda4f8a..cc59236 100644 --- a/Project/applications/smartcities/adc.c +++ b/Project/applications/smartcities/adc.c @@ -10,22 +10,6 @@ void adc_batt_init() { - adc_batt_peripheralInit(); -} - -uint32_t adc_batt_process() -{ - uint16_t adcRegisterValue; - uint32_t analogValue; - - adcRegisterValue = adc_batt_read(); - analogValue = ADCbatt_VREF_MINUS + (((adcRegisterValue - ADCbatt_MIN_VALUE)*(ADCbatt_VREF_PLUS - ADCbatt_VREF_MINUS))/(ADCbatt_MAX_VALUE - ADCbatt_MIN_VALUE)); - DBG_ADC("Register value is %4u [%4u milliVolts are currently given to gpio %s]\r\n",adcRegisterValue, analogValue, ADCbatt_GPIO_STR); - return analogValue; -} - -void adc_batt_peripheralInit() -{ GPIO_InitTypeDef GPIO_InitStructure; ADC_InitTypeDef ADC_InitStructure; RCC_APB2PeriphClockCmd(ADCbatt_GPIO_RCC, ENABLE); @@ -55,6 +39,17 @@ void adc_batt_peripheralInit() while(ADC_GetCalibrationStatus(ADCbatt)); } +uint32_t adc_batt_process() +{ + uint16_t adcRegisterValue; + uint32_t analogValue; + + adcRegisterValue = adc_batt_read(); + analogValue = ADCbatt_VREF_MINUS + (((adcRegisterValue - ADCbatt_MIN_VALUE)*(ADCbatt_VREF_PLUS - ADCbatt_VREF_MINUS))/(ADCbatt_MAX_VALUE - ADCbatt_MIN_VALUE)); + DBG_ADC("Register value is %4u [%4u milliVolts are currently given to gpio %s]\r\n",adcRegisterValue, analogValue, ADCbatt_GPIO_STR); + return analogValue; +} + uint16_t adc_batt_read() { ADC_SoftwareStartConvCmd(ADCbatt, ENABLE); @@ -64,22 +59,6 @@ uint16_t adc_batt_read() void adc_sound_init() { - adc_sound_peripheralInit(); -} - -uint32_t adc_sound_process() -{ - uint16_t adcRegisterValue; - uint32_t analogValue; - - adcRegisterValue = adc_sound_read(); - analogValue = ADCsound_VREF_MINUS + (((adcRegisterValue - ADCsound_MIN_VALUE)*(ADCsound_VREF_PLUS - ADCsound_VREF_MINUS))/(ADCsound_MAX_VALUE - ADCsound_MIN_VALUE)); - DBG_ADC("Register value is %4u [%4u milliVolts are currently given to gpio %s]\r\n",adcRegisterValue, analogValue, ADCsound_GPIO_STR); - return analogValue; -} - -void adc_sound_peripheralInit() -{ GPIO_InitTypeDef GPIO_InitStructure; ADC_InitTypeDef ADC_InitStructure; RCC_APB2PeriphClockCmd(ADCsound_GPIO_RCC, ENABLE); @@ -109,6 +88,17 @@ void adc_sound_peripheralInit() while(ADC_GetCalibrationStatus(ADCsound)); } +uint32_t adc_sound_process() +{ + uint16_t adcRegisterValue; + uint32_t analogValue; + + adcRegisterValue = adc_sound_read(); + analogValue = ADCsound_VREF_MINUS + (((adcRegisterValue - ADCsound_MIN_VALUE)*(ADCsound_VREF_PLUS - ADCsound_VREF_MINUS))/(ADCsound_MAX_VALUE - ADCsound_MIN_VALUE)); + DBG_ADC("Register value is %4u [%4u milliVolts are currently given to gpio %s]\r\n",adcRegisterValue, analogValue, ADCsound_GPIO_STR); + return analogValue; +} + uint16_t adc_sound_read() { ADC_SoftwareStartConvCmd(ADCsound, ENABLE); diff --git a/Project/applications/smartcities/doc/doxygen/Doxyfile b/Project/applications/smartcities/doc/doxygen/Doxyfile index c820568..996797c 100644 --- a/Project/applications/smartcities/doc/doxygen/Doxyfile +++ b/Project/applications/smartcities/doc/doxygen/Doxyfile @@ -351,7 +351,7 @@ LOOKUP_CACHE_SIZE = 0 # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES -EXTRACT_ALL = NO +EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. diff --git a/Project/applications/smartcities/include/adc.h b/Project/applications/smartcities/include/adc.h index 22d7a9f..835599d 100644 --- a/Project/applications/smartcities/include/adc.h +++ b/Project/applications/smartcities/include/adc.h @@ -39,35 +39,62 @@ //! Minimum sound ADC analog value #define ADCsound_VREF_MINUS (0) - +//! ADC used for battery #define ADCbatt ADC1 -#define ADCbatt_RCC RCC_APB2Periph_ADC1 /* */ -#define ADCbatt_DIVIDER RCC_PCLK2_Div4 /* Can be 2/4/6/8. PCLK2 runs at 32Mhz, and max ADC clock is 14Mhz */ -#define ADCbatt_CHANNEL ADC_Channel_1 /* 0/17 */ +//! Real-Time Clock Control used for battery +#define ADCbatt_RCC RCC_APB2Periph_ADC1 +//! Battery clock divisor +#define ADCbatt_DIVIDER RCC_PCLK2_Div4 +//! Battery ADC channel +#define ADCbatt_CHANNEL ADC_Channel_1 +//! Battery ADC sample time #define ADCbatt_SAMPLETIME ADC_SampleTime_239Cycles5 +//! Battery ADC GPIO pin number #define ADCbatt_GPIO_PIN GPIO_Pin_1 +//! Battery ADC GPIO port #define ADCbatt_GPIO_PORT GPIOA +//! Battery ADC GPIO Real-time Clock Control #define ADCbatt_GPIO_RCC RCC_APB2Periph_GPIOA +//! Battery ADC GPIO human-readable identification for pin #define ADCbatt_GPIO_STR "PA1" +//! ADC used for sound #define ADCsound ADC2 -#define ADCsound_RCC RCC_APB2Periph_ADC2 /* */ -#define ADCsound_DIVIDER RCC_PCLK2_Div4 /* Can be 2/4/6/8. PCLK2 runs at 32Mhz, and max ADC clock is 14Mhz */ -#define ADCsound_CHANNEL ADC_Channel_2 /* 0/17 */ +//! Real-Time Clock Control used for sound +#define ADCsound_RCC RCC_APB2Periph_ADC2 +//! Sound clock divisor +#define ADCsound_DIVIDER RCC_PCLK2_Div4 +//! Sound ADC channel +#define ADCsound_CHANNEL ADC_Channel_2 +//! Sound ADC sample time #define ADCsound_SAMPLETIME ADC_SampleTime_239Cycles5 +//! Sound ADC GPIO pin number #define ADCsound_GPIO_PIN GPIO_Pin_2 +//! Sound ADC GPIO port #define ADCsound_GPIO_PORT GPIOA +//! Sound ADC GPIO Real-time Clock Control #define ADCsound_GPIO_RCC RCC_APB2Periph_GPIOA + //! Sound ADC GPIO human-readable identification for pin #define ADCsound_GPIO_STR "PA2" +//! Battery ADC initialization function +/*! This function initializes the base HW to start battery ADC conversion */ void adc_batt_init(void); +//! Battery ADC processing function +/*! This function calls adc_batt_read and converts the raw digital value to the analog scale defined for the battery ADC */ uint32_t adc_batt_process(void); +//! Battery ADC raw read function +/*! This function starts an ADC conversion and returns the raw 12 bit digital value */ uint16_t adc_batt_read(void); -void adc_batt_peripheralInit(void); +//! Battery ADC initialization function +/*! This function initializes the base HW to start sound ADC conversion */ void adc_sound_init(void); +//! Battery ADC processing function +/*! This function calls adc_batt_read and converts the raw digital value to the analog scale defined for the sound ADC */ uint32_t adc_sound_process(void); +//! Battery ADC raw read function +/*! This function starts an ADC conversion and returns the raw 12 bit digital value */ uint16_t adc_sound_read(void); -void adc_sound_peripheralInit(void); #endif \ No newline at end of file -- libgit2 0.22.2