1
1
/* mbed Microcontroller Library
2
- * Copyright (c) 2016, STMicroelectronics
3
- * All rights reserved.
2
+ * SPDX-License-Identifier: BSD-3-Clause
3
+ ******************************************************************************
4
4
*
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
5
+ * Copyright (c) 2015-2020 STMicroelectronics.
6
+ * All rights reserved.
7
7
*
8
- * 1. Redistributions of source code must retain the above copyright notice,
9
- * this list of conditions and the following disclaimer.
10
- * 2. Redistributions in binary form must reproduce the above copyright notice,
11
- * this list of conditions and the following disclaimer in the documentation
12
- * and/or other materials provided with the distribution.
13
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
14
- * may be used to endorse or promote products derived from this software
15
- * without specific prior written permission.
8
+ * This software component is licensed by ST under BSD 3-Clause license,
9
+ * the "License"; You may not use this file except in compliance with the
10
+ * License. You may obtain a copy of the License at:
11
+ * opensource.org/licenses/BSD-3-Clause
16
12
*
17
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13
+ ******************************************************************************
27
14
*/
15
+
28
16
#include "mbed_assert.h"
29
17
#include "analogin_api.h"
30
18
@@ -313,12 +301,11 @@ void analogin_free(analogin_t *obj)
313
301
#if defined(ADC1 )
314
302
if ((ADCName )obj -> handle .Instance == ADC_1 ) {
315
303
adc1_en_counter -- ;
316
- if (ADC1_EN_CTR == 0 )
317
- {
304
+ if (ADC1_EN_CTR == 0 ) {
318
305
HAL_ADC_DeInit (& obj -> handle );
319
306
320
307
// Disable clock if ADC2 is also unused
321
- if (ADC2_EN_CTR == 0 ) {
308
+ if (ADC2_EN_CTR == 0 ) {
322
309
LL_AHB2_GRP1_DisableClock (LL_AHB2_GRP1_PERIPH_ADC12 );
323
310
}
324
311
}
@@ -327,12 +314,11 @@ void analogin_free(analogin_t *obj)
327
314
#if defined(ADC2 )
328
315
if ((ADCName )obj -> handle .Instance == ADC_2 ) {
329
316
adc2_en_counter -- ;
330
- if (ADC2_EN_CTR == 0 )
331
- {
317
+ if (ADC2_EN_CTR == 0 ) {
332
318
HAL_ADC_DeInit (& obj -> handle );
333
319
334
320
// Disable clock if ADC1 is also unused
335
- if (ADC1_EN_CTR == 0 ) {
321
+ if (ADC1_EN_CTR == 0 ) {
336
322
LL_AHB2_GRP1_DisableClock (LL_AHB2_GRP1_PERIPH_ADC12 );
337
323
}
338
324
}
@@ -341,12 +327,11 @@ void analogin_free(analogin_t *obj)
341
327
#if defined(ADC3 )
342
328
if ((ADCName )obj -> handle .Instance == ADC_3 ) {
343
329
adc3_en_counter -- ;
344
- if (ADC3_EN_CTR == 0 )
345
- {
330
+ if (ADC3_EN_CTR == 0 ) {
346
331
HAL_ADC_DeInit (& obj -> handle );
347
332
348
333
// Disable clock if ADC4 and ADC5 are also unused
349
- if ((ADC4_EN_CTR + ADC5_EN_CTR ) == 0 ) {
334
+ if ((ADC4_EN_CTR + ADC5_EN_CTR ) == 0 ) {
350
335
LL_AHB2_GRP1_DisableClock (LL_AHB2_GRP1_PERIPH_ADC345 );
351
336
}
352
337
}
@@ -355,12 +340,11 @@ void analogin_free(analogin_t *obj)
355
340
#if defined(ADC4 )
356
341
if ((ADCName )obj -> handle .Instance == ADC_4 ) {
357
342
adc4_en_counter -- ;
358
- if (ADC4_EN_CTR == 0 )
359
- {
343
+ if (ADC4_EN_CTR == 0 ) {
360
344
HAL_ADC_DeInit (& obj -> handle );
361
345
362
346
// Disable clock if ADC3 and ADC5 are also unused
363
- if ((ADC3_EN_CTR + ADC5_EN_CTR ) == 0 ) {
347
+ if ((ADC3_EN_CTR + ADC5_EN_CTR ) == 0 ) {
364
348
LL_AHB2_GRP1_DisableClock (LL_AHB2_GRP1_PERIPH_ADC345 );
365
349
}
366
350
}
@@ -370,12 +354,11 @@ void analogin_free(analogin_t *obj)
370
354
#if defined(ADC5 )
371
355
if ((ADCName )obj -> handle .Instance == ADC_5 ) {
372
356
adc5_en_counter -- ;
373
- if (ADC5_EN_CTR == 0 )
374
- {
357
+ if (ADC5_EN_CTR == 0 ) {
375
358
HAL_ADC_DeInit (& obj -> handle );
376
359
377
360
// Disable clock if ADC3 and ADC4 are also unused
378
- if ((ADC3_EN_CTR + ADC4_EN_CTR ) == 0 ) {
361
+ if ((ADC3_EN_CTR + ADC4_EN_CTR ) == 0 ) {
379
362
LL_AHB2_GRP1_DisableClock (LL_AHB2_GRP1_PERIPH_ADC345 );
380
363
}
381
364
}
0 commit comments