/*! * @file apm32f4xx_adc.h * * @brief This file contains all the functions prototypes for the ADC firmware library * * @version V1.0.2 * * @date 2022-06-23 * * @attention * * Copyright (C) 2021-2022 Geehy Semiconductor * * You may not use this file except in compliance with the * GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE). * * The program is only for reference, which is distributed in the hope * that it will be usefull and instructional for customers to develop * their software. Unless required by applicable law or agreed to in * writing, the program is distributed on an "AS IS" BASIS, WITHOUT * ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied. * See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions * and limitations under the License. */ /* Define to prevent recursive inclusion */ #ifndef __APM32F4XX_ADC_H #define __APM32F4XX_ADC_H #ifdef __cplusplus extern "C" { #endif /* Includes */ #include "apm32f4xx.h" /** @addtogroup APM32F4xx_StdPeriphDriver @{ */ /** @addtogroup ADC_Driver @{ */ /** @defgroup ADC_Enumerations @{ */ /** * @brief ADC Common mode */ typedef enum { /* All the ADCs independent */ ADC_MODE_INDEPENDENT = (uint8_t)0x00, /*!< Independent mode */ /* ADC1 and ADC2 working together but ADC3 is independent */ ADC_MODE_DUAL_REGSIMULT_INJECSIMULT = (uint8_t)0x01, /*!< regular simultaneous + injected simultaneous */ ADC_MODE_DUAL_REGSIMULT_ALTERTRIG = (uint8_t)0x02, /*!< regular simultaneous + alternate trigger */ ADC_MODE_DUAL_INJECSIMULT = (uint8_t)0x05, /*!< Injected simultaneous mode only */ ADC_MODE_DUAL_REGSIMULT = (uint8_t)0x06, /*!< Regular simultaneous mode only */ ADC_MODE_DUAL_INTERL = (uint8_t)0x07, /*!< Interleaved mode only */ ADC_MODE_DUAL_ALTERTRIG = (uint8_t)0x09, /*!< Alternate trigger mode only */ /* ADC1, ADC2 and ADC3 working together */ ADC_MODE_TRIPLE_REGSIMULT_INJECSIMULT = (uint8_t)0x11, /*!< regular simultaneous + injected simultaneous */ ADC_MODE_TRIPLE_REGSIMULT_ALTERTRIG = (uint8_t)0x12, /*!< regular simultaneous + alternate trigger */ ADC_MODE_TRIPLE_INJECSIMULT = (uint8_t)0x15, /*!< Injected simultaneous mode only */ ADC_MODE_TRIPLE_REGSIMULT = (uint8_t)0x16, /*!< Regular simultaneous mode only */ ADC_MODE_TRIPLE_INTERL = (uint8_t)0x17, /*!< Interleaved mode only */ ADC_MODE_TRIPLE_ALTERTRIG = (uint8_t)0x19 /*!< Alternate trigger mode only */ } ADC_MODE_T; /** * @brief ADC Prescaler */ typedef enum { ADC_PRESCALER_DIV2, /*!< PCLK2 2 divided frequency */ ADC_PRESCALER_DIV4, /*!< PCLK2 4 divided frequency */ ADC_PRESCALER_DIV6, /*!< PCLK2 6 divided frequency */ ADC_PRESCALER_DIV8 /*!< PCLK2 8 divided frequency */ } ADC_PRESCALER_T; /** * @brief ADC Direct memory access mode for multi mode */ typedef enum { ADC_ACCESS_MODE_DISABLED, /*!< DMA mode disabled */ ADC_ACCESS_MODE_1, /*!< DMA mode 1 enabled (2/3 half-words one by one - 1 then 2 then 3) */ ADC_ACCESS_MODE_2, /*!< DMA mode 2 enabled (2/3 half-words by pairs - 2&1 then 1&3 then 3&2) */ ADC_ACCESS_MODE_3 /*!< DMA mode 3 enabled (2/3 bytes by pairs - 2&1 then 1&3 then 3&2) */ } ADC_ACCESS_MODE_T; /** * @brief ADC Delay between 2 sampling phases */ typedef enum { ADC_TWO_SAMPLING_5CYCLES, /*!< 5*Tadcclk delay between 2 sampling phases */ ADC_TWO_SAMPLING_6CYCLES, /*!< 6*Tadcclk delay between 2 sampling phases */ ADC_TWO_SAMPLING_7CYCLES, /*!< 7*Tadcclk delay between 2 sampling phases */ ADC_TWO_SAMPLING_8CYCLES, /*!< 8*Tadcclk delay between 2 sampling phases */ ADC_TWO_SAMPLING_9CYCLES, /*!< 9*Tadcclk delay between 2 sampling phases */ ADC_TWO_SAMPLING_10CYCLES, /*!< 10*Tadcclk delay between 2 sampling phases */ ADC_TWO_SAMPLING_11CYCLES, /*!< 11*Tadcclk delay between 2 sampling phases */ ADC_TWO_SAMPLING_12CYCLES, /*!< 12*Tadcclk delay between 2 sampling phases */ ADC_TWO_SAMPLING_13CYCLES, /*!< 13*Tadcclk delay between 2 sampling phases */ ADC_TWO_SAMPLING_14CYCLES, /*!< 14*Tadcclk delay between 2 sampling phases */ ADC_TWO_SAMPLING_15CYCLES, /*!< 15*Tadcclk delay between 2 sampling phases */ ADC_TWO_SAMPLING_16CYCLES, /*!< 16*Tadcclk delay between 2 sampling phases */ ADC_TWO_SAMPLING_17CYCLES, /*!< 17*Tadcclk delay between 2 sampling phases */ ADC_TWO_SAMPLING_18CYCLES, /*!< 18*Tadcclk delay between 2 sampling phases */ ADC_TWO_SAMPLING_19CYCLES, /*!< 19*Tadcclk delay between 2 sampling phases */ ADC_TWO_SAMPLING_20CYCLES /*!< 20*Tadcclk delay between 2 sampling phases */ } ADC_TWO_SAMPLING_T; /** * @brief ADC_resolution */ typedef enum { ADC_RESOLUTION_12BIT, /*!< ADC Resolution is 12 bits */ ADC_RESOLUTION_10BIT, /*!< ADC Resolution is 10 bits */ ADC_RESOLUTION_8BIT, /*!< ADC Resolution is 8 bits */ ADC_RESOLUTION_6BIT /*!< ADC Resolution is 6 bits */ } ADC_RESOLUTION_T; /** * @brief ADC External trigger edge for regular channels conversion */ typedef enum { ADC_EXT_TRIG_EDGE_NONE, /*!