stm32f0/f3: adc: extract beginnings of common v2 periph
The f0, f30x and l0 have a very similar "v2" adc peripheral. Start extracting out some of the common code, and fix the glaring bug in adc_power_down that was affecting them both. This is not intended to be a fully comprehensive extraction, just the first easy steps.
This commit is contained in:
54
include/libopencm3/stm32/common/adc_common_v2.h
Normal file
54
include/libopencm3/stm32/common/adc_common_v2.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/** @addtogroup adc_defines
|
||||
|
||||
@author @htmlonly © @endhtmlonly 2015 Karl Palsson <karlp@tweak.net.au>
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* Copyright (C) 2015 Karl Palsson <karlp@tweak.net.au>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**@{*/
|
||||
|
||||
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA ADC.H
|
||||
The order of header inclusion is important. adc.h includes the device
|
||||
specific memorymap.h header before including this header file.*/
|
||||
|
||||
/** @cond */
|
||||
#ifdef LIBOPENCM3_ADC_H
|
||||
/** @endcond */
|
||||
#ifndef LIBOPENCM3_ADC_COMMON_V2_H
|
||||
#define LIBOPENCM3_ADC_COMMON_V2_H
|
||||
|
||||
|
||||
/* --- Function prototypes ------------------------------------------------- */
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
void adc_power_on_async(uint32_t adc);
|
||||
void adc_power_on(uint32_t adc);
|
||||
bool adc_is_power_on(uint32_t adc);
|
||||
void adc_power_off_async(uint32_t adc);
|
||||
void adc_power_off(uint32_t adc);
|
||||
bool adc_is_power_off(uint32_t adc);
|
||||
|
||||
END_DECLS
|
||||
|
||||
#endif
|
||||
#endif /* LIBOPENCM3_ADC_H */
|
||||
/**@}*/
|
||||
@@ -33,6 +33,8 @@
|
||||
#ifndef LIBOPENCM3_ADC_H
|
||||
#define LIBOPENCM3_ADC_H
|
||||
|
||||
#include <libopencm3/stm32/common/adc_common_v2.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Module definitions */
|
||||
/*****************************************************************************/
|
||||
@@ -305,8 +307,6 @@ void adc_enable_eoc_interrupt(uint32_t adc);
|
||||
void adc_disable_eoc_interrupt(uint32_t adc);
|
||||
|
||||
/* Basic configuration */
|
||||
void adc_power_off(uint32_t adc);
|
||||
void adc_power_on(uint32_t adc);
|
||||
void adc_set_clk_source(uint32_t adc, uint32_t source);
|
||||
void adc_set_regular_sequence(uint32_t adc, uint8_t length, uint8_t channel[]);
|
||||
void adc_set_sample_time_on_all_channels(uint32_t adc, uint8_t time);
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#ifndef LIBOPENCM3_ADC_H
|
||||
#define LIBOPENCM3_ADC_H
|
||||
|
||||
#include <libopencm3/stm32/common/adc_common_v2.h>
|
||||
|
||||
#define ADC1 ADC1_BASE
|
||||
#define ADC2 ADC2_BASE
|
||||
#define ADC3 ADC3_BASE
|
||||
@@ -863,8 +865,6 @@
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
void adc_power_on(uint32_t adc);
|
||||
void adc_power_off(uint32_t adc);
|
||||
void adc_enable_analog_watchdog_regular(uint32_t adc);
|
||||
void adc_disable_analog_watchdog_regular(uint32_t adc);
|
||||
void adc_enable_analog_watchdog_injected(uint32_t adc);
|
||||
|
||||
Reference in New Issue
Block a user