11/* mbed Microcontroller Library
2- * Copyright (c) 2016, STMicroelectronics
3- * All rights reserved.
2+ * SPDX-License-Identifier: BSD-3-Clause
3+ ******************************************************************************
44 *
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.
77 *
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
1612 *
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+ ******************************************************************************
2714 */
15+
2816#include "mbed_assert.h"
2917#include "analogin_api.h"
3018
@@ -313,12 +301,11 @@ void analogin_free(analogin_t *obj)
313301#if defined(ADC1 )
314302 if ((ADCName )obj -> handle .Instance == ADC_1 ) {
315303 adc1_en_counter -- ;
316- if (ADC1_EN_CTR == 0 )
317- {
304+ if (ADC1_EN_CTR == 0 ) {
318305 HAL_ADC_DeInit (& obj -> handle );
319306
320307 // Disable clock if ADC2 is also unused
321- if (ADC2_EN_CTR == 0 ) {
308+ if (ADC2_EN_CTR == 0 ) {
322309 LL_AHB2_GRP1_DisableClock (LL_AHB2_GRP1_PERIPH_ADC12 );
323310 }
324311 }
@@ -327,12 +314,11 @@ void analogin_free(analogin_t *obj)
327314#if defined(ADC2 )
328315 if ((ADCName )obj -> handle .Instance == ADC_2 ) {
329316 adc2_en_counter -- ;
330- if (ADC2_EN_CTR == 0 )
331- {
317+ if (ADC2_EN_CTR == 0 ) {
332318 HAL_ADC_DeInit (& obj -> handle );
333319
334320 // Disable clock if ADC1 is also unused
335- if (ADC1_EN_CTR == 0 ) {
321+ if (ADC1_EN_CTR == 0 ) {
336322 LL_AHB2_GRP1_DisableClock (LL_AHB2_GRP1_PERIPH_ADC12 );
337323 }
338324 }
@@ -341,12 +327,11 @@ void analogin_free(analogin_t *obj)
341327#if defined(ADC3 )
342328 if ((ADCName )obj -> handle .Instance == ADC_3 ) {
343329 adc3_en_counter -- ;
344- if (ADC3_EN_CTR == 0 )
345- {
330+ if (ADC3_EN_CTR == 0 ) {
346331 HAL_ADC_DeInit (& obj -> handle );
347332
348333 // 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 ) {
350335 LL_AHB2_GRP1_DisableClock (LL_AHB2_GRP1_PERIPH_ADC345 );
351336 }
352337 }
@@ -355,12 +340,11 @@ void analogin_free(analogin_t *obj)
355340#if defined(ADC4 )
356341 if ((ADCName )obj -> handle .Instance == ADC_4 ) {
357342 adc4_en_counter -- ;
358- if (ADC4_EN_CTR == 0 )
359- {
343+ if (ADC4_EN_CTR == 0 ) {
360344 HAL_ADC_DeInit (& obj -> handle );
361345
362346 // 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 ) {
364348 LL_AHB2_GRP1_DisableClock (LL_AHB2_GRP1_PERIPH_ADC345 );
365349 }
366350 }
@@ -370,12 +354,11 @@ void analogin_free(analogin_t *obj)
370354#if defined(ADC5 )
371355 if ((ADCName )obj -> handle .Instance == ADC_5 ) {
372356 adc5_en_counter -- ;
373- if (ADC5_EN_CTR == 0 )
374- {
357+ if (ADC5_EN_CTR == 0 ) {
375358 HAL_ADC_DeInit (& obj -> handle );
376359
377360 // 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 ) {
379362 LL_AHB2_GRP1_DisableClock (LL_AHB2_GRP1_PERIPH_ADC345 );
380363 }
381364 }
0 commit comments