Commit e4e0d6d36d703330bffb33a96fbf03c0e03555b4

Authored by Imanol-Mikel Barba Sabariego
1 parent 28327759

--no commit message

Project/applications/smartcities/adc.c
... ... @@ -10,22 +10,6 @@
10 10  
11 11 void adc_batt_init()
12 12 {
13   - adc_batt_peripheralInit();
14   -}
15   -
16   -uint32_t adc_batt_process()
17   -{
18   - uint16_t adcRegisterValue;
19   - uint32_t analogValue;
20   -
21   - adcRegisterValue = adc_batt_read();
22   - analogValue = ADCbatt_VREF_MINUS + (((adcRegisterValue - ADCbatt_MIN_VALUE)*(ADCbatt_VREF_PLUS - ADCbatt_VREF_MINUS))/(ADCbatt_MAX_VALUE - ADCbatt_MIN_VALUE));
23   - DBG_ADC("Register value is %4u [%4u milliVolts are currently given to gpio %s]\r\n",adcRegisterValue, analogValue, ADCbatt_GPIO_STR);
24   - return analogValue;
25   -}
26   -
27   -void adc_batt_peripheralInit()
28   -{
29 13 GPIO_InitTypeDef GPIO_InitStructure;
30 14 ADC_InitTypeDef ADC_InitStructure;
31 15 RCC_APB2PeriphClockCmd(ADCbatt_GPIO_RCC, ENABLE);
... ... @@ -55,6 +39,17 @@ void adc_batt_peripheralInit()
55 39 while(ADC_GetCalibrationStatus(ADCbatt));
56 40 }
57 41  
  42 +uint32_t adc_batt_process()
  43 +{
  44 + uint16_t adcRegisterValue;
  45 + uint32_t analogValue;
  46 +
  47 + adcRegisterValue = adc_batt_read();
  48 + analogValue = ADCbatt_VREF_MINUS + (((adcRegisterValue - ADCbatt_MIN_VALUE)*(ADCbatt_VREF_PLUS - ADCbatt_VREF_MINUS))/(ADCbatt_MAX_VALUE - ADCbatt_MIN_VALUE));
  49 + DBG_ADC("Register value is %4u [%4u milliVolts are currently given to gpio %s]\r\n",adcRegisterValue, analogValue, ADCbatt_GPIO_STR);
  50 + return analogValue;
  51 +}
  52 +
58 53 uint16_t adc_batt_read()
59 54 {
60 55 ADC_SoftwareStartConvCmd(ADCbatt, ENABLE);
... ... @@ -64,22 +59,6 @@ uint16_t adc_batt_read()
64 59  
65 60 void adc_sound_init()
66 61 {
67   - adc_sound_peripheralInit();
68   -}
69   -
70   -uint32_t adc_sound_process()
71   -{
72   - uint16_t adcRegisterValue;
73   - uint32_t analogValue;
74   -
75   - adcRegisterValue = adc_sound_read();
76   - analogValue = ADCsound_VREF_MINUS + (((adcRegisterValue - ADCsound_MIN_VALUE)*(ADCsound_VREF_PLUS - ADCsound_VREF_MINUS))/(ADCsound_MAX_VALUE - ADCsound_MIN_VALUE));
77   - DBG_ADC("Register value is %4u [%4u milliVolts are currently given to gpio %s]\r\n",adcRegisterValue, analogValue, ADCsound_GPIO_STR);
78   - return analogValue;
79   -}
80   -
81   -void adc_sound_peripheralInit()
82   -{
83 62 GPIO_InitTypeDef GPIO_InitStructure;
84 63 ADC_InitTypeDef ADC_InitStructure;
85 64 RCC_APB2PeriphClockCmd(ADCsound_GPIO_RCC, ENABLE);
... ... @@ -109,6 +88,17 @@ void adc_sound_peripheralInit()
109 88 while(ADC_GetCalibrationStatus(ADCsound));
110 89 }
111 90  
  91 +uint32_t adc_sound_process()
  92 +{
  93 + uint16_t adcRegisterValue;
  94 + uint32_t analogValue;
  95 +
  96 + adcRegisterValue = adc_sound_read();
  97 + analogValue = ADCsound_VREF_MINUS + (((adcRegisterValue - ADCsound_MIN_VALUE)*(ADCsound_VREF_PLUS - ADCsound_VREF_MINUS))/(ADCsound_MAX_VALUE - ADCsound_MIN_VALUE));
  98 + DBG_ADC("Register value is %4u [%4u milliVolts are currently given to gpio %s]\r\n",adcRegisterValue, analogValue, ADCsound_GPIO_STR);
  99 + return analogValue;
  100 +}
  101 +
112 102 uint16_t adc_sound_read()
113 103 {
114 104 ADC_SoftwareStartConvCmd(ADCsound, ENABLE);
... ...
Project/applications/smartcities/doc/doxygen/Doxyfile
... ... @@ -351,7 +351,7 @@ LOOKUP_CACHE_SIZE = 0
351 351 # Private class members and static file members will be hidden unless
352 352 # the EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES
353 353  
354   -EXTRACT_ALL = NO
  354 +EXTRACT_ALL = YES
355 355  
356 356 # If the EXTRACT_PRIVATE tag is set to YES all private members of a class
357 357 # will be included in the documentation.
... ...
Project/applications/smartcities/include/adc.h
... ... @@ -39,35 +39,62 @@
39 39 //! Minimum sound ADC analog value
40 40 #define ADCsound_VREF_MINUS (0)
41 41  
42   -
  42 +//! ADC used for battery
43 43 #define ADCbatt ADC1
44   -#define ADCbatt_RCC RCC_APB2Periph_ADC1 /* */
45   -#define ADCbatt_DIVIDER RCC_PCLK2_Div4 /* Can be 2/4/6/8. PCLK2 runs at 32Mhz, and max ADC clock is 14Mhz */
46   -#define ADCbatt_CHANNEL ADC_Channel_1 /* 0/17 */
  44 +//! Real-Time Clock Control used for battery
  45 +#define ADCbatt_RCC RCC_APB2Periph_ADC1
  46 +//! Battery clock divisor
  47 +#define ADCbatt_DIVIDER RCC_PCLK2_Div4
  48 +//! Battery ADC channel
  49 +#define ADCbatt_CHANNEL ADC_Channel_1
  50 +//! Battery ADC sample time
47 51 #define ADCbatt_SAMPLETIME ADC_SampleTime_239Cycles5
  52 +//! Battery ADC GPIO pin number
48 53 #define ADCbatt_GPIO_PIN GPIO_Pin_1
  54 +//! Battery ADC GPIO port
49 55 #define ADCbatt_GPIO_PORT GPIOA
  56 +//! Battery ADC GPIO Real-time Clock Control
50 57 #define ADCbatt_GPIO_RCC RCC_APB2Periph_GPIOA
  58 +//! Battery ADC GPIO human-readable identification for pin
51 59 #define ADCbatt_GPIO_STR "PA1"
52 60  
  61 +//! ADC used for sound
53 62 #define ADCsound ADC2
54   -#define ADCsound_RCC RCC_APB2Periph_ADC2 /* */
55   -#define ADCsound_DIVIDER RCC_PCLK2_Div4 /* Can be 2/4/6/8. PCLK2 runs at 32Mhz, and max ADC clock is 14Mhz */
56   -#define ADCsound_CHANNEL ADC_Channel_2 /* 0/17 */
  63 +//! Real-Time Clock Control used for sound
  64 +#define ADCsound_RCC RCC_APB2Periph_ADC2
  65 +//! Sound clock divisor
  66 +#define ADCsound_DIVIDER RCC_PCLK2_Div4
  67 +//! Sound ADC channel
  68 +#define ADCsound_CHANNEL ADC_Channel_2
  69 +//! Sound ADC sample time
57 70 #define ADCsound_SAMPLETIME ADC_SampleTime_239Cycles5
  71 +//! Sound ADC GPIO pin number
58 72 #define ADCsound_GPIO_PIN GPIO_Pin_2
  73 +//! Sound ADC GPIO port
59 74 #define ADCsound_GPIO_PORT GPIOA
  75 +//! Sound ADC GPIO Real-time Clock Control
60 76 #define ADCsound_GPIO_RCC RCC_APB2Periph_GPIOA
  77 + //! Sound ADC GPIO human-readable identification for pin
61 78 #define ADCsound_GPIO_STR "PA2"
62 79  
  80 +//! Battery ADC initialization function
  81 +/*! This function initializes the base HW to start battery ADC conversion */
63 82 void adc_batt_init(void);
  83 +//! Battery ADC processing function
  84 +/*! This function calls adc_batt_read and converts the raw digital value to the analog scale defined for the battery ADC */
64 85 uint32_t adc_batt_process(void);
  86 +//! Battery ADC raw read function
  87 +/*! This function starts an ADC conversion and returns the raw 12 bit digital value */
65 88 uint16_t adc_batt_read(void);
66   -void adc_batt_peripheralInit(void);
67 89  
  90 +//! Battery ADC initialization function
  91 +/*! This function initializes the base HW to start sound ADC conversion */
68 92 void adc_sound_init(void);
  93 +//! Battery ADC processing function
  94 +/*! This function calls adc_batt_read and converts the raw digital value to the analog scale defined for the sound ADC */
69 95 uint32_t adc_sound_process(void);
  96 +//! Battery ADC raw read function
  97 +/*! This function starts an ADC conversion and returns the raw 12 bit digital value */
70 98 uint16_t adc_sound_read(void);
71   -void adc_sound_peripheralInit(void);
72 99  
73 100 #endif
74 101 \ No newline at end of file
... ...