Subversion Repositories LedShow

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 9
Line 4... Line 4...
4
  * @author  MCD Application Team
4
  * @author  MCD Application Team
5
  * @brief   Header file containing functions prototypes of ADC HAL library.
5
  * @brief   Header file containing functions prototypes of ADC HAL library.
6
  ******************************************************************************
6
  ******************************************************************************
7
  * @attention
7
  * @attention
8
  *
8
  *
9
  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
-
 
10
  *
9
  *
11
  * Redistribution and use in source and binary forms, with or without modification,
-
 
12
  * are permitted provided that the following conditions are met:
-
 
13
  *   1. Redistributions of source code must retain the above copyright notice,
-
 
14
  *      this list of conditions and the following disclaimer.
-
 
15
  *   2. Redistributions in binary form must reproduce the above copyright notice,
-
 
16
  *      this list of conditions and the following disclaimer in the documentation
-
 
17
  *      and/or other materials provided with the distribution.
10
  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
18
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-
 
19
  *      may be used to endorse or promote products derived from this software
-
 
20
  *      without specific prior written permission.
11
  * All rights reserved.</center></h2>
21
  *
12
  *
22
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13
  * This software component is licensed by ST under BSD 3-Clause license,
23
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-
 
24
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-
 
25
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-
 
26
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-
 
27
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
14
  * the "License"; You may not use this file except in compliance with the
28
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
15
  * License. You may obtain a copy of the License at:
29
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-
 
30
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-
 
31
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16
  *                        opensource.org/licenses/BSD-3-Clause
32
  *
17
  *
33
  ******************************************************************************
18
  ******************************************************************************
34
  */
19
  */
35
 
20
 
36
/* Define to prevent recursive inclusion -------------------------------------*/
21
/* Define to prevent recursive inclusion -------------------------------------*/
Line 64... Line 49...
64
  * @note   The setting of these parameters with function HAL_ADC_Init() is conditioned to ADC state.
49
  * @note   The setting of these parameters with function HAL_ADC_Init() is conditioned to ADC state.
65
  *         ADC can be either disabled or enabled without conversion on going on regular group.
50
  *         ADC can be either disabled or enabled without conversion on going on regular group.
66
  */
51
  */
67
typedef struct
52
typedef struct
68
{
53
{
69
  uint32_t DataAlign;             /*!< Specifies ADC data alignment to right (MSB on register bit 11 and LSB on register bit 0) (default setting)
54
  uint32_t DataAlign;                        /*!< Specifies ADC data alignment to right (MSB on register bit 11 and LSB on register bit 0) (default setting)
70
                                       or to left (if regular group: MSB on register bit 15 and LSB on register bit 4, if injected group (MSB kept as signed value due to potential negative value after offset application): MSB on register bit 14 and LSB on register bit 3).
55
                                                  or to left (if regular group: MSB on register bit 15 and LSB on register bit 4, if injected group (MSB kept as signed value due to potential negative value after offset application): MSB on register bit 14 and LSB on register bit 3).
71
                                       This parameter can be a value of @ref ADC_Data_align */
56
                                                  This parameter can be a value of @ref ADC_Data_align */
72
  uint32_t ScanConvMode;          /*!< Configures the sequencer of regular and injected groups.
57
  uint32_t ScanConvMode;                     /*!< Configures the sequencer of regular and injected groups.
73
                                       This parameter can be associated to parameter 'DiscontinuousConvMode' to have main sequence subdivided in successive parts.
58
                                                  This parameter can be associated to parameter 'DiscontinuousConvMode' to have main sequence subdivided in successive parts.
74
                                       If disabled: Conversion is performed in single mode (one channel converted, the one defined in rank 1).
59
                                                  If disabled: Conversion is performed in single mode (one channel converted, the one defined in rank 1).
75
                                                    Parameters 'NbrOfConversion' and 'InjectedNbrOfConversion' are discarded (equivalent to set to 1).
60
                                                               Parameters 'NbrOfConversion' and 'InjectedNbrOfConversion' are discarded (equivalent to set to 1).
76
                                       If enabled:  Conversions are performed in sequence mode (multiple ranks defined by 'NbrOfConversion'/'InjectedNbrOfConversion' and each channel rank).
61
                                                  If enabled:  Conversions are performed in sequence mode (multiple ranks defined by 'NbrOfConversion'/'InjectedNbrOfConversion' and each channel rank).
77
                                                    Scan direction is upward: from rank1 to rank 'n'.
62
                                                               Scan direction is upward: from rank1 to rank 'n'.
78
                                       This parameter can be a value of @ref ADC_Scan_mode
63
                                                  This parameter can be a value of @ref ADC_Scan_mode
79
                                       Note: For regular group, this parameter should be enabled in conversion either by polling (HAL_ADC_Start with Discontinuous mode and NbrOfDiscConversion=1)
64
                                                  Note: For regular group, this parameter should be enabled in conversion either by polling (HAL_ADC_Start with Discontinuous mode and NbrOfDiscConversion=1)
80
                                             or by DMA (HAL_ADC_Start_DMA), but not by interruption (HAL_ADC_Start_IT): in scan mode, interruption is triggered only on the
65
                                                        or by DMA (HAL_ADC_Start_DMA), but not by interruption (HAL_ADC_Start_IT): in scan mode, interruption is triggered only on the
81
                                             the last conversion of the sequence. All previous conversions would be overwritten by the last one.
66
                                                        the last conversion of the sequence. All previous conversions would be overwritten by the last one.
82
                                             Injected group used with scan mode has not this constraint: each rank has its own result register, no data is overwritten. */
67
                                                        Injected group used with scan mode has not this constraint: each rank has its own result register, no data is overwritten. */
83
  uint32_t ContinuousConvMode;    /*!< Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group,
68
  FunctionalState ContinuousConvMode;         /*!< Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group,
84
                                       after the selected trigger occurred (software start or external trigger).
69
                                                  after the selected trigger occurred (software start or external trigger).
85
                                       This parameter can be set to ENABLE or DISABLE. */
70
                                                  This parameter can be set to ENABLE or DISABLE. */
86
  uint32_t NbrOfConversion;       /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
71
  uint32_t NbrOfConversion;                  /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
87
                                       To use regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
72
                                                  To use regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
88
                                       This parameter must be a number between Min_Data = 1 and Max_Data = 16. */
73
                                                  This parameter must be a number between Min_Data = 1 and Max_Data = 16. */
89
  uint32_t DiscontinuousConvMode; /*!< Specifies whether the conversions sequence of regular group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
74
  FunctionalState  DiscontinuousConvMode;    /*!< Specifies whether the conversions sequence of regular group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
90
                                       Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
75
                                                  Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
91
                                       Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
76
                                                  Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
92
                                       This parameter can be set to ENABLE or DISABLE. */
77
                                                  This parameter can be set to ENABLE or DISABLE. */
93
  uint32_t NbrOfDiscConversion;   /*!< Specifies the number of discontinuous conversions in which the  main sequence of regular group (parameter NbrOfConversion) will be subdivided.
78
  uint32_t NbrOfDiscConversion;              /*!< Specifies the number of discontinuous conversions in which the  main sequence of regular group (parameter NbrOfConversion) will be subdivided.
94
                                       If parameter 'DiscontinuousConvMode' is disabled, this parameter is discarded.
79
                                                  If parameter 'DiscontinuousConvMode' is disabled, this parameter is discarded.
95
                                       This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
80
                                                  This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
96
  uint32_t ExternalTrigConv;      /*!< Selects the external event used to trigger the conversion start of regular group.
81
  uint32_t ExternalTrigConv;                 /*!< Selects the external event used to trigger the conversion start of regular group.
97
                                       If set to ADC_SOFTWARE_START, external triggers are disabled.
82
                                                  If set to ADC_SOFTWARE_START, external triggers are disabled.
98
                                       If set to external trigger source, triggering is on event rising edge.
83
                                                  If set to external trigger source, triggering is on event rising edge.
99
                                       This parameter can be a value of @ref ADC_External_trigger_source_Regular */
84
                                                  This parameter can be a value of @ref ADC_External_trigger_source_Regular */
100
}ADC_InitTypeDef;
85
}ADC_InitTypeDef;
101
 
86
 
102
/**
87
/**
103
  * @brief  Structure definition of ADC channel for regular group  
88
  * @brief  Structure definition of ADC channel for regular group  
104
  * @note   The setting of these parameters with function HAL_ADC_ConfigChannel() is conditioned to ADC state.
89
  * @note   The setting of these parameters with function HAL_ADC_ConfigChannel() is conditioned to ADC state.
Line 137... Line 122...
137
  uint32_t WatchdogMode;      /*!< Configures the ADC analog watchdog mode: single/all channels, regular/injected group.
122
  uint32_t WatchdogMode;      /*!< Configures the ADC analog watchdog mode: single/all channels, regular/injected group.
138
                                   This parameter can be a value of @ref ADC_analog_watchdog_mode. */
123
                                   This parameter can be a value of @ref ADC_analog_watchdog_mode. */
139
  uint32_t Channel;           /*!< Selects which ADC channel to monitor by analog watchdog.
124
  uint32_t Channel;           /*!< Selects which ADC channel to monitor by analog watchdog.
140
                                   This parameter has an effect only if watchdog mode is configured on single channel (parameter WatchdogMode)
125
                                   This parameter has an effect only if watchdog mode is configured on single channel (parameter WatchdogMode)
141
                                   This parameter can be a value of @ref ADC_channels. */
126
                                   This parameter can be a value of @ref ADC_channels. */
142
  uint32_t ITMode;            /*!< Specifies whether the analog watchdog is configured in interrupt or polling mode.
127
  FunctionalState  ITMode;    /*!< Specifies whether the analog watchdog is configured in interrupt or polling mode.
143
                                   This parameter can be set to ENABLE or DISABLE */
128
                                   This parameter can be set to ENABLE or DISABLE */
144
  uint32_t HighThreshold;     /*!< Configures the ADC analog watchdog High threshold value.
129
  uint32_t HighThreshold;     /*!< Configures the ADC analog watchdog High threshold value.
145
                                   This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */
130
                                   This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */
146
  uint32_t LowThreshold;      /*!< Configures the ADC analog watchdog High threshold value.
131
  uint32_t LowThreshold;      /*!< Configures the ADC analog watchdog High threshold value.
147
                                   This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */
132
                                   This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */
Line 182... Line 167...
182
 
167
 
183
/* States of ADC multi-mode */
168
/* States of ADC multi-mode */
184
#define HAL_ADC_STATE_MULTIMODE_SLAVE   0x00100000U    /*!< ADC in multimode slave state, controlled by another ADC master ( */
169
#define HAL_ADC_STATE_MULTIMODE_SLAVE   0x00100000U    /*!< ADC in multimode slave state, controlled by another ADC master ( */
185
 
170
 
186
 
171
 
187
/**
172
/**
188
  * @brief  ADC handle Structure definition  
173
  * @brief  ADC handle Structure definition  
189
  */
174
  */
190
typedef struct
175
typedef struct __ADC_HandleTypeDef
191
{
176
{
192
  ADC_TypeDef                   *Instance;              /*!< Register base address */
177
  ADC_TypeDef                   *Instance;              /*!< Register base address */
193
 
178
 
194
  ADC_InitTypeDef               Init;                   /*!< ADC required parameters */
179
  ADC_InitTypeDef               Init;                   /*!< ADC required parameters */
195
 
180
 
Line 198... Line 183...
198
  HAL_LockTypeDef               Lock;                   /*!< ADC locking object */
183
  HAL_LockTypeDef               Lock;                   /*!< ADC locking object */
199
 
184
 
200
  __IO uint32_t                 State;                  /*!< ADC communication state (bitmap of ADC states) */
185
  __IO uint32_t                 State;                  /*!< ADC communication state (bitmap of ADC states) */
201
 
186
 
202
  __IO uint32_t                 ErrorCode;              /*!< ADC Error code */
187
  __IO uint32_t                 ErrorCode;              /*!< ADC Error code */
-
 
188
 
-
 
189
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
-
 
190
  void (* ConvCpltCallback)(struct __ADC_HandleTypeDef *hadc);              /*!< ADC conversion complete callback */
-
 
191
  void (* ConvHalfCpltCallback)(struct __ADC_HandleTypeDef *hadc);          /*!< ADC conversion DMA half-transfer callback */
-
 
192
  void (* LevelOutOfWindowCallback)(struct __ADC_HandleTypeDef *hadc);      /*!< ADC analog watchdog 1 callback */
-
 
193
  void (* ErrorCallback)(struct __ADC_HandleTypeDef *hadc);                 /*!< ADC error callback */
-
 
194
  void (* InjectedConvCpltCallback)(struct __ADC_HandleTypeDef *hadc);      /*!< ADC group injected conversion complete callback */       /*!< ADC end of sampling callback */
-
 
195
  void (* MspInitCallback)(struct __ADC_HandleTypeDef *hadc);               /*!< ADC Msp Init callback */
-
 
196
  void (* MspDeInitCallback)(struct __ADC_HandleTypeDef *hadc);             /*!< ADC Msp DeInit callback */
-
 
197
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
203
}ADC_HandleTypeDef;
198
}ADC_HandleTypeDef;
-
 
199
 
-
 
200
 
-
 
201
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
-
 
202
/**
-
 
203
  * @brief  HAL ADC Callback ID enumeration definition
-
 
204
  */
-
 
205
typedef enum
-
 
206
{
-
 
207
  HAL_ADC_CONVERSION_COMPLETE_CB_ID     = 0x00U,  /*!< ADC conversion complete callback ID */
-
 
208
  HAL_ADC_CONVERSION_HALF_CB_ID         = 0x01U,  /*!< ADC conversion DMA half-transfer callback ID */
-
 
209
  HAL_ADC_LEVEL_OUT_OF_WINDOW_1_CB_ID   = 0x02U,  /*!< ADC analog watchdog 1 callback ID */
-
 
210
  HAL_ADC_ERROR_CB_ID                   = 0x03U,  /*!< ADC error callback ID */
-
 
211
  HAL_ADC_INJ_CONVERSION_COMPLETE_CB_ID = 0x04U,  /*!< ADC group injected conversion complete callback ID */
-
 
212
  HAL_ADC_MSPINIT_CB_ID                 = 0x09U,  /*!< ADC Msp Init callback ID          */
-
 
213
  HAL_ADC_MSPDEINIT_CB_ID               = 0x0AU   /*!< ADC Msp DeInit callback ID        */
-
 
214
} HAL_ADC_CallbackIDTypeDef;
-
 
215
 
-
 
216
/**
-
 
217
  * @brief  HAL ADC Callback pointer definition
-
 
218
  */
-
 
219
typedef  void (*pADC_CallbackTypeDef)(ADC_HandleTypeDef *hadc); /*!< pointer to a ADC callback function */
-
 
220
 
-
 
221
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
-
 
222
 
204
/**
223
/**
205
  * @}
224
  * @}
206
  */
225
  */
207
 
226
 
208
 
227
 
Line 220... Line 239...
220
#define HAL_ADC_ERROR_INTERNAL            0x01U   /*!< ADC IP internal error: if problem of clocking, 
239
#define HAL_ADC_ERROR_INTERNAL            0x01U   /*!< ADC IP internal error: if problem of clocking, 
221
                                                       enable/disable, erroneous state                       */
240
                                                       enable/disable, erroneous state                       */
222
#define HAL_ADC_ERROR_OVR                 0x02U   /*!< Overrun error                                         */
241
#define HAL_ADC_ERROR_OVR                 0x02U   /*!< Overrun error                                         */
223
#define HAL_ADC_ERROR_DMA                 0x04U   /*!< DMA transfer error                                    */
242
#define HAL_ADC_ERROR_DMA                 0x04U   /*!< DMA transfer error                                    */
224
 
243
 
-
 
244
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
-
 
245
#define HAL_ADC_ERROR_INVALID_CALLBACK  (0x10U)   /*!< Invalid Callback error */
-
 
246
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
225
/**
247
/**
226
  * @}
248
  * @}
227
  */
249
  */
228
 
250
 
229
 
251
 
Line 560... Line 582...
560
 
582
 
561
/** @brief  Reset ADC handle state
583
/** @brief  Reset ADC handle state
562
  * @param  __HANDLE__: ADC handle
584
  * @param  __HANDLE__: ADC handle
563
  * @retval None
585
  * @retval None
564
  */
586
  */
-
 
587
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
-
 
588
#define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__)                               \
-
 
589
  do{                                                                          \
-
 
590
     (__HANDLE__)->State = HAL_ADC_STATE_RESET;                                \
-
 
591
     (__HANDLE__)->MspInitCallback = NULL;                                     \
-
 
592
     (__HANDLE__)->MspDeInitCallback = NULL;                                   \
-
 
593
    } while(0)
-
 
594
#else
565
#define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__)                               \
595
#define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__)                               \
566
  ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
596
  ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
-
 
597
#endif
567
 
598
 
568
/**
599
/**
569
  * @}
600
  * @}
570
  */
601
  */
571
 
602
 
Line 864... Line 895...
864
/* Initialization and de-initialization functions  **********************************/
895
/* Initialization and de-initialization functions  **********************************/
865
HAL_StatusTypeDef       HAL_ADC_Init(ADC_HandleTypeDef* hadc);
896
HAL_StatusTypeDef       HAL_ADC_Init(ADC_HandleTypeDef* hadc);
866
HAL_StatusTypeDef       HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
897
HAL_StatusTypeDef       HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
867
void                    HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
898
void                    HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
868
void                    HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
899
void                    HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
-
 
900
 
-
 
901
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
-
 
902
/* Callbacks Register/UnRegister functions  ***********************************/
-
 
903
HAL_StatusTypeDef HAL_ADC_RegisterCallback(ADC_HandleTypeDef *hadc, HAL_ADC_CallbackIDTypeDef CallbackID, pADC_CallbackTypeDef pCallback);
-
 
904
HAL_StatusTypeDef HAL_ADC_UnRegisterCallback(ADC_HandleTypeDef *hadc, HAL_ADC_CallbackIDTypeDef CallbackID);
-
 
905
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
-
 
906
 
869
/**
907
/**
870
  * @}
908
  * @}
871
  */
909
  */
872
 
910
 
873
/* IO operation functions  *****************************************************/
911
/* IO operation functions  *****************************************************/