训练营PLSR题目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1113 line
40 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_adc_ex.c
  4. * @author MCD Application Team
  5. * @brief This file provides firmware functions to manage the following
  6. * functionalities of the ADC extension peripheral:
  7. * + Extended features functions
  8. *
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * Copyright (c) 2017 STMicroelectronics.
  13. * All rights reserved.
  14. *
  15. * This software is licensed under terms that can be found in the LICENSE file
  16. * in the root directory of this software component.
  17. * If no LICENSE file comes with this software, it is provided AS-IS.
  18. *
  19. ******************************************************************************
  20. @verbatim
  21. ==============================================================================
  22. ##### How to use this driver #####
  23. ==============================================================================
  24. [..]
  25. (#)Initialize the ADC low level resources by implementing the HAL_ADC_MspInit():
  26. (##) Enable the ADC interface clock using __HAL_RCC_ADC_CLK_ENABLE()
  27. (##) ADC pins configuration
  28. (+++) Enable the clock for the ADC GPIOs using the following function:
  29. __HAL_RCC_GPIOx_CLK_ENABLE()
  30. (+++) Configure these ADC pins in analog mode using HAL_GPIO_Init()
  31. (##) In case of using interrupts (e.g. HAL_ADC_Start_IT())
  32. (+++) Configure the ADC interrupt priority using HAL_NVIC_SetPriority()
  33. (+++) Enable the ADC IRQ handler using HAL_NVIC_EnableIRQ()
  34. (+++) In ADC IRQ handler, call HAL_ADC_IRQHandler()
  35. (##) In case of using DMA to control data transfer (e.g. HAL_ADC_Start_DMA())
  36. (+++) Enable the DMAx interface clock using __HAL_RCC_DMAx_CLK_ENABLE()
  37. (+++) Configure and enable two DMA streams stream for managing data
  38. transfer from peripheral to memory (output stream)
  39. (+++) Associate the initialized DMA handle to the ADC DMA handle
  40. using __HAL_LINKDMA()
  41. (+++) Configure the priority and enable the NVIC for the transfer complete
  42. interrupt on the two DMA Streams. The output stream should have higher
  43. priority than the input stream.
  44. (#) Configure the ADC Prescaler, conversion resolution and data alignment
  45. using the HAL_ADC_Init() function.
  46. (#) Configure the ADC Injected channels group features, use HAL_ADC_Init()
  47. and HAL_ADC_ConfigChannel() functions.
  48. (#) Three operation modes are available within this driver:
  49. *** Polling mode IO operation ***
  50. =================================
  51. [..]
  52. (+) Start the ADC peripheral using HAL_ADCEx_InjectedStart()
  53. (+) Wait for end of conversion using HAL_ADC_PollForConversion(), at this stage
  54. user can specify the value of timeout according to his end application
  55. (+) To read the ADC converted values, use the HAL_ADCEx_InjectedGetValue() function.
  56. (+) Stop the ADC peripheral using HAL_ADCEx_InjectedStop()
  57. *** Interrupt mode IO operation ***
  58. ===================================
  59. [..]
  60. (+) Start the ADC peripheral using HAL_ADCEx_InjectedStart_IT()
  61. (+) Use HAL_ADC_IRQHandler() called under ADC_IRQHandler() Interrupt subroutine
  62. (+) At ADC end of conversion HAL_ADCEx_InjectedConvCpltCallback() function is executed and user can
  63. add his own code by customization of function pointer HAL_ADCEx_InjectedConvCpltCallback
  64. (+) In case of ADC Error, HAL_ADCEx_InjectedErrorCallback() function is executed and user can
  65. add his own code by customization of function pointer HAL_ADCEx_InjectedErrorCallback
  66. (+) Stop the ADC peripheral using HAL_ADCEx_InjectedStop_IT()
  67. *** Multi mode ADCs Regular channels configuration ***
  68. ======================================================
  69. [..]
  70. (+) Select the Multi mode ADC regular channels features (dual or triple mode)
  71. and configure the DMA mode using HAL_ADCEx_MultiModeConfigChannel() functions.
  72. (+) Start the ADC peripheral using HAL_ADCEx_MultiModeStart_DMA(), at this stage the user specify the length
  73. of data to be transferred at each end of conversion
  74. (+) Read the ADCs converted values using the HAL_ADCEx_MultiModeGetValue() function.
  75. @endverbatim
  76. */
  77. /* Includes ------------------------------------------------------------------*/
  78. #include "stm32f4xx_hal.h"
  79. /** @addtogroup STM32F4xx_HAL_Driver
  80. * @{
  81. */
  82. /** @defgroup ADCEx ADCEx
  83. * @brief ADC Extended driver modules
  84. * @{
  85. */
  86. #ifdef HAL_ADC_MODULE_ENABLED
  87. /* Private typedef -----------------------------------------------------------*/
  88. /* Private define ------------------------------------------------------------*/
  89. /* Private macro -------------------------------------------------------------*/
  90. /* Private variables ---------------------------------------------------------*/
  91. /** @addtogroup ADCEx_Private_Functions
  92. * @{
  93. */
  94. /* Private function prototypes -----------------------------------------------*/
  95. static void ADC_MultiModeDMAConvCplt(DMA_HandleTypeDef *hdma);
  96. static void ADC_MultiModeDMAError(DMA_HandleTypeDef *hdma);
  97. static void ADC_MultiModeDMAHalfConvCplt(DMA_HandleTypeDef *hdma);
  98. /**
  99. * @}
  100. */
  101. /* Exported functions --------------------------------------------------------*/
  102. /** @defgroup ADCEx_Exported_Functions ADC Exported Functions
  103. * @{
  104. */
  105. /** @defgroup ADCEx_Exported_Functions_Group1 Extended features functions
  106. * @brief Extended features functions
  107. *
  108. @verbatim
  109. ===============================================================================
  110. ##### Extended features functions #####
  111. ===============================================================================
  112. [..] This section provides functions allowing to:
  113. (+) Start conversion of injected channel.
  114. (+) Stop conversion of injected channel.
  115. (+) Start multimode and enable DMA transfer.
  116. (+) Stop multimode and disable DMA transfer.
  117. (+) Get result of injected channel conversion.
  118. (+) Get result of multimode conversion.
  119. (+) Configure injected channels.
  120. (+) Configure multimode.
  121. @endverbatim
  122. * @{
  123. */
  124. /**
  125. * @brief Enables the selected ADC software start conversion of the injected channels.
  126. * @param hadc pointer to a ADC_HandleTypeDef structure that contains
  127. * the configuration information for the specified ADC.
  128. * @retval HAL status
  129. */
  130. HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef* hadc)
  131. {
  132. __IO uint32_t counter = 0U;
  133. uint32_t tmp1 = 0U, tmp2 = 0U;
  134. ADC_Common_TypeDef *tmpADC_Common;
  135. /* Process locked */
  136. __HAL_LOCK(hadc);
  137. /* Enable the ADC peripheral */
  138. /* Check if ADC peripheral is disabled in order to enable it and wait during
  139. Tstab time the ADC's stabilization */
  140. if((hadc->Instance->CR2 & ADC_CR2_ADON) != ADC_CR2_ADON)
  141. {
  142. /* Enable the Peripheral */
  143. __HAL_ADC_ENABLE(hadc);
  144. /* Delay for ADC stabilization time */
  145. /* Compute number of CPU cycles to wait for */
  146. counter = (ADC_STAB_DELAY_US * (SystemCoreClock / 1000000U));
  147. while(counter != 0U)
  148. {
  149. counter--;
  150. }
  151. }
  152. /* Start conversion if ADC is effectively enabled */
  153. if(HAL_IS_BIT_SET(hadc->Instance->CR2, ADC_CR2_ADON))
  154. {
  155. /* Set ADC state */
  156. /* - Clear state bitfield related to injected group conversion results */
  157. /* - Set state bitfield related to injected operation */
  158. ADC_STATE_CLR_SET(hadc->State,
  159. HAL_ADC_STATE_READY | HAL_ADC_STATE_INJ_EOC,
  160. HAL_ADC_STATE_INJ_BUSY);
  161. /* Check if a regular conversion is ongoing */
  162. /* Note: On this device, there is no ADC error code fields related to */
  163. /* conversions on group injected only. In case of conversion on */
  164. /* going on group regular, no error code is reset. */
  165. if (HAL_IS_BIT_CLR(hadc->State, HAL_ADC_STATE_REG_BUSY))
  166. {
  167. /* Reset ADC all error code fields */
  168. ADC_CLEAR_ERRORCODE(hadc);
  169. }
  170. /* Process unlocked */
  171. /* Unlock before starting ADC conversions: in case of potential */
  172. /* interruption, to let the process to ADC IRQ Handler. */
  173. __HAL_UNLOCK(hadc);
  174. /* Clear injected group conversion flag */
  175. /* (To ensure of no unknown state from potential previous ADC operations) */
  176. __HAL_ADC_CLEAR_FLAG(hadc, ADC_FLAG_JEOC);
  177. /* Pointer to the common control register to which is belonging hadc */
  178. /* (Depending on STM32F4 product, there may be up to 3 ADC and 1 common */
  179. /* control register) */
  180. tmpADC_Common = ADC_COMMON_REGISTER(hadc);
  181. /* Check if Multimode enabled */
  182. if(HAL_IS_BIT_CLR(tmpADC_Common->CCR, ADC_CCR_MULTI))
  183. {
  184. tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN);
  185. tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO);
  186. if(tmp1 && tmp2)
  187. {
  188. /* Enable the selected ADC software conversion for injected group */
  189. hadc->Instance->CR2 |= ADC_CR2_JSWSTART;
  190. }
  191. }
  192. else
  193. {
  194. tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN);
  195. tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO);
  196. if((hadc->Instance == ADC1) && tmp1 && tmp2)
  197. {
  198. /* Enable the selected ADC software conversion for injected group */
  199. hadc->Instance->CR2 |= ADC_CR2_JSWSTART;
  200. }
  201. }
  202. }
  203. else
  204. {
  205. /* Update ADC state machine to error */
  206. SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL);
  207. /* Set ADC error code to ADC IP internal error */
  208. SET_BIT(hadc->ErrorCode, HAL_ADC_ERROR_INTERNAL);
  209. }
  210. /* Return function status */
  211. return HAL_OK;
  212. }
  213. /**
  214. * @brief Enables the interrupt and starts ADC conversion of injected channels.
  215. * @param hadc pointer to a ADC_HandleTypeDef structure that contains
  216. * the configuration information for the specified ADC.
  217. *
  218. * @retval HAL status.
  219. */
  220. HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef* hadc)
  221. {
  222. __IO uint32_t counter = 0U;
  223. uint32_t tmp1 = 0U, tmp2 = 0U;
  224. ADC_Common_TypeDef *tmpADC_Common;
  225. /* Process locked */
  226. __HAL_LOCK(hadc);
  227. /* Enable the ADC peripheral */
  228. /* Check if ADC peripheral is disabled in order to enable it and wait during
  229. Tstab time the ADC's stabilization */
  230. if((hadc->Instance->CR2 & ADC_CR2_ADON) != ADC_CR2_ADON)
  231. {
  232. /* Enable the Peripheral */
  233. __HAL_ADC_ENABLE(hadc);
  234. /* Delay for ADC stabilization time */
  235. /* Compute number of CPU cycles to wait for */
  236. counter = (ADC_STAB_DELAY_US * (SystemCoreClock / 1000000U));
  237. while(counter != 0U)
  238. {
  239. counter--;
  240. }
  241. }
  242. /* Start conversion if ADC is effectively enabled */
  243. if(HAL_IS_BIT_SET(hadc->Instance->CR2, ADC_CR2_ADON))
  244. {
  245. /* Set ADC state */
  246. /* - Clear state bitfield related to injected group conversion results */
  247. /* - Set state bitfield related to injected operation */
  248. ADC_STATE_CLR_SET(hadc->State,
  249. HAL_ADC_STATE_READY | HAL_ADC_STATE_INJ_EOC,
  250. HAL_ADC_STATE_INJ_BUSY);
  251. /* Check if a regular conversion is ongoing */
  252. /* Note: On this device, there is no ADC error code fields related to */
  253. /* conversions on group injected only. In case of conversion on */
  254. /* going on group regular, no error code is reset. */
  255. if (HAL_IS_BIT_CLR(hadc->State, HAL_ADC_STATE_REG_BUSY))
  256. {
  257. /* Reset ADC all error code fields */
  258. ADC_CLEAR_ERRORCODE(hadc);
  259. }
  260. /* Process unlocked */
  261. /* Unlock before starting ADC conversions: in case of potential */
  262. /* interruption, to let the process to ADC IRQ Handler. */
  263. __HAL_UNLOCK(hadc);
  264. /* Clear injected group conversion flag */
  265. /* (To ensure of no unknown state from potential previous ADC operations) */
  266. __HAL_ADC_CLEAR_FLAG(hadc, ADC_FLAG_JEOC);
  267. /* Enable end of conversion interrupt for injected channels */
  268. __HAL_ADC_ENABLE_IT(hadc, ADC_IT_JEOC);
  269. /* Pointer to the common control register to which is belonging hadc */
  270. /* (Depending on STM32F4 product, there may be up to 3 ADC and 1 common */
  271. /* control register) */
  272. tmpADC_Common = ADC_COMMON_REGISTER(hadc);
  273. /* Check if Multimode enabled */
  274. if(HAL_IS_BIT_CLR(tmpADC_Common->CCR, ADC_CCR_MULTI))
  275. {
  276. tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN);
  277. tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO);
  278. if(tmp1 && tmp2)
  279. {
  280. /* Enable the selected ADC software conversion for injected group */
  281. hadc->Instance->CR2 |= ADC_CR2_JSWSTART;
  282. }
  283. }
  284. else
  285. {
  286. tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN);
  287. tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO);
  288. if((hadc->Instance == ADC1) && tmp1 && tmp2)
  289. {
  290. /* Enable the selected ADC software conversion for injected group */
  291. hadc->Instance->CR2 |= ADC_CR2_JSWSTART;
  292. }
  293. }
  294. }
  295. else
  296. {
  297. /* Update ADC state machine to error */
  298. SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL);
  299. /* Set ADC error code to ADC IP internal error */
  300. SET_BIT(hadc->ErrorCode, HAL_ADC_ERROR_INTERNAL);
  301. }
  302. /* Return function status */
  303. return HAL_OK;
  304. }
  305. /**
  306. * @brief Stop conversion of injected channels. Disable ADC peripheral if
  307. * no regular conversion is on going.
  308. * @note If ADC must be disabled and if conversion is on going on
  309. * regular group, function HAL_ADC_Stop must be used to stop both
  310. * injected and regular groups, and disable the ADC.
  311. * @note If injected group mode auto-injection is enabled,
  312. * function HAL_ADC_Stop must be used.
  313. * @note In case of auto-injection mode, HAL_ADC_Stop must be used.
  314. * @param hadc ADC handle
  315. * @retval None
  316. */
  317. HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef* hadc)
  318. {
  319. HAL_StatusTypeDef tmp_hal_status = HAL_OK;
  320. /* Check the parameters */
  321. assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
  322. /* Process locked */
  323. __HAL_LOCK(hadc);
  324. /* Stop potential conversion and disable ADC peripheral */
  325. /* Conditioned to: */
  326. /* - No conversion on the other group (regular group) is intended to */
  327. /* continue (injected and regular groups stop conversion and ADC disable */
  328. /* are common) */
  329. /* - In case of auto-injection mode, HAL_ADC_Stop must be used. */
  330. if(((hadc->State & HAL_ADC_STATE_REG_BUSY) == RESET) &&
  331. HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO) )
  332. {
  333. /* Stop potential conversion on going, on regular and injected groups */
  334. /* Disable ADC peripheral */
  335. __HAL_ADC_DISABLE(hadc);
  336. /* Check if ADC is effectively disabled */
  337. if(HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_ADON))
  338. {
  339. /* Set ADC state */
  340. ADC_STATE_CLR_SET(hadc->State,
  341. HAL_ADC_STATE_REG_BUSY | HAL_ADC_STATE_INJ_BUSY,
  342. HAL_ADC_STATE_READY);
  343. }
  344. }
  345. else
  346. {
  347. /* Update ADC state machine to error */
  348. SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_CONFIG);
  349. tmp_hal_status = HAL_ERROR;
  350. }
  351. /* Process unlocked */
  352. __HAL_UNLOCK(hadc);
  353. /* Return function status */
  354. return tmp_hal_status;
  355. }
  356. /**
  357. * @brief Poll for injected conversion complete
  358. * @param hadc pointer to a ADC_HandleTypeDef structure that contains
  359. * the configuration information for the specified ADC.
  360. * @param Timeout Timeout value in millisecond.
  361. * @retval HAL status
  362. */
  363. HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout)
  364. {
  365. uint32_t tickstart = 0U;
  366. /* Get tick */
  367. tickstart = HAL_GetTick();
  368. /* Check End of conversion flag */
  369. while(!(__HAL_ADC_GET_FLAG(hadc, ADC_FLAG_JEOC)))
  370. {
  371. /* Check for the Timeout */
  372. if(Timeout != HAL_MAX_DELAY)
  373. {
  374. if((Timeout == 0U)||((HAL_GetTick() - tickstart ) > Timeout))
  375. {
  376. /* New check to avoid false timeout detection in case of preemption */
  377. if(!(__HAL_ADC_GET_FLAG(hadc, ADC_FLAG_JEOC)))
  378. {
  379. hadc->State= HAL_ADC_STATE_TIMEOUT;
  380. /* Process unlocked */
  381. __HAL_UNLOCK(hadc);
  382. return HAL_TIMEOUT;
  383. }
  384. }
  385. }
  386. }
  387. /* Clear injected group conversion flag */
  388. __HAL_ADC_CLEAR_FLAG(hadc, ADC_FLAG_JSTRT | ADC_FLAG_JEOC);
  389. /* Update ADC state machine */
  390. SET_BIT(hadc->State, HAL_ADC_STATE_INJ_EOC);
  391. /* Determine whether any further conversion upcoming on group injected */
  392. /* by external trigger, continuous mode or scan sequence on going. */
  393. /* Note: On STM32F4, there is no independent flag of end of sequence. */
  394. /* The test of scan sequence on going is done either with scan */
  395. /* sequence disabled or with end of conversion flag set to */
  396. /* of end of sequence. */
  397. if(ADC_IS_SOFTWARE_START_INJECTED(hadc) &&
  398. (HAL_IS_BIT_CLR(hadc->Instance->JSQR, ADC_JSQR_JL) ||
  399. HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_EOCS) ) &&
  400. (HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO) &&
  401. (ADC_IS_SOFTWARE_START_REGULAR(hadc) &&
  402. (hadc->Init.ContinuousConvMode == DISABLE) ) ) )
  403. {
  404. /* Set ADC state */
  405. CLEAR_BIT(hadc->State, HAL_ADC_STATE_INJ_BUSY);
  406. if (HAL_IS_BIT_CLR(hadc->State, HAL_ADC_STATE_REG_BUSY))
  407. {
  408. SET_BIT(hadc->State, HAL_ADC_STATE_READY);
  409. }
  410. }
  411. /* Return ADC state */
  412. return HAL_OK;
  413. }
  414. /**
  415. * @brief Stop conversion of injected channels, disable interruption of
  416. * end-of-conversion. Disable ADC peripheral if no regular conversion
  417. * is on going.
  418. * @note If ADC must be disabled and if conversion is on going on
  419. * regular group, function HAL_ADC_Stop must be used to stop both
  420. * injected and regular groups, and disable the ADC.
  421. * @note If injected group mode auto-injection is enabled,
  422. * function HAL_ADC_Stop must be used.
  423. * @param hadc ADC handle
  424. * @retval None
  425. */
  426. HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef* hadc)
  427. {
  428. HAL_StatusTypeDef tmp_hal_status = HAL_OK;
  429. /* Check the parameters */
  430. assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
  431. /* Process locked */
  432. __HAL_LOCK(hadc);
  433. /* Stop potential conversion and disable ADC peripheral */
  434. /* Conditioned to: */
  435. /* - No conversion on the other group (regular group) is intended to */
  436. /* continue (injected and regular groups stop conversion and ADC disable */
  437. /* are common) */
  438. /* - In case of auto-injection mode, HAL_ADC_Stop must be used. */
  439. if(((hadc->State & HAL_ADC_STATE_REG_BUSY) == RESET) &&
  440. HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO) )
  441. {
  442. /* Stop potential conversion on going, on regular and injected groups */
  443. /* Disable ADC peripheral */
  444. __HAL_ADC_DISABLE(hadc);
  445. /* Check if ADC is effectively disabled */
  446. if(HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_ADON))
  447. {
  448. /* Disable ADC end of conversion interrupt for injected channels */
  449. __HAL_ADC_DISABLE_IT(hadc, ADC_IT_JEOC);
  450. /* Set ADC state */
  451. ADC_STATE_CLR_SET(hadc->State,
  452. HAL_ADC_STATE_REG_BUSY | HAL_ADC_STATE_INJ_BUSY,
  453. HAL_ADC_STATE_READY);
  454. }
  455. }
  456. else
  457. {
  458. /* Update ADC state machine to error */
  459. SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_CONFIG);
  460. tmp_hal_status = HAL_ERROR;
  461. }
  462. /* Process unlocked */
  463. __HAL_UNLOCK(hadc);
  464. /* Return function status */
  465. return tmp_hal_status;
  466. }
  467. /**
  468. * @brief Gets the converted value from data register of injected channel.
  469. * @param hadc pointer to a ADC_HandleTypeDef structure that contains
  470. * the configuration information for the specified ADC.
  471. * @param InjectedRank the ADC injected rank.
  472. * This parameter can be one of the following values:
  473. * @arg ADC_INJECTED_RANK_1: Injected Channel1 selected
  474. * @arg ADC_INJECTED_RANK_2: Injected Channel2 selected
  475. * @arg ADC_INJECTED_RANK_3: Injected Channel3 selected
  476. * @arg ADC_INJECTED_RANK_4: Injected Channel4 selected
  477. * @retval None
  478. */
  479. uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank)
  480. {
  481. __IO uint32_t tmp = 0U;
  482. /* Check the parameters */
  483. assert_param(IS_ADC_INJECTED_RANK(InjectedRank));
  484. /* Clear injected group conversion flag to have similar behaviour as */
  485. /* regular group: reading data register also clears end of conversion flag. */
  486. __HAL_ADC_CLEAR_FLAG(hadc, ADC_FLAG_JEOC);
  487. /* Return the selected ADC converted value */
  488. switch(InjectedRank)
  489. {
  490. case ADC_INJECTED_RANK_4:
  491. {
  492. tmp = hadc->Instance->JDR4;
  493. }
  494. break;
  495. case ADC_INJECTED_RANK_3:
  496. {
  497. tmp = hadc->Instance->JDR3;
  498. }
  499. break;
  500. case ADC_INJECTED_RANK_2:
  501. {
  502. tmp = hadc->Instance->JDR2;
  503. }
  504. break;
  505. case ADC_INJECTED_RANK_1:
  506. {
  507. tmp = hadc->Instance->JDR1;
  508. }
  509. break;
  510. default:
  511. break;
  512. }
  513. return tmp;
  514. }
  515. /**
  516. * @brief Enables ADC DMA request after last transfer (Multi-ADC mode) and enables ADC peripheral
  517. *
  518. * @note Caution: This function must be used only with the ADC master.
  519. *
  520. * @param hadc pointer to a ADC_HandleTypeDef structure that contains
  521. * the configuration information for the specified ADC.
  522. * @param pData Pointer to buffer in which transferred from ADC peripheral to memory will be stored.
  523. * @param Length The length of data to be transferred from ADC peripheral to memory.
  524. * @retval HAL status
  525. */
  526. HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length)
  527. {
  528. __IO uint32_t counter = 0U;
  529. ADC_Common_TypeDef *tmpADC_Common;
  530. /* Check the parameters */
  531. assert_param(IS_FUNCTIONAL_STATE(hadc->Init.ContinuousConvMode));
  532. assert_param(IS_ADC_EXT_TRIG_EDGE(hadc->Init.ExternalTrigConvEdge));
  533. assert_param(IS_FUNCTIONAL_STATE(hadc->Init.DMAContinuousRequests));
  534. /* Process locked */
  535. __HAL_LOCK(hadc);
  536. /* Check if ADC peripheral is disabled in order to enable it and wait during
  537. Tstab time the ADC's stabilization */
  538. if((hadc->Instance->CR2 & ADC_CR2_ADON) != ADC_CR2_ADON)
  539. {
  540. /* Enable the Peripheral */
  541. __HAL_ADC_ENABLE(hadc);
  542. /* Delay for temperature sensor stabilization time */
  543. /* Compute number of CPU cycles to wait for */
  544. counter = (ADC_STAB_DELAY_US * (SystemCoreClock / 1000000U));
  545. while(counter != 0U)
  546. {
  547. counter--;
  548. }
  549. }
  550. /* Start conversion if ADC is effectively enabled */
  551. if(HAL_IS_BIT_SET(hadc->Instance->CR2, ADC_CR2_ADON))
  552. {
  553. /* Set ADC state */
  554. /* - Clear state bitfield related to regular group conversion results */
  555. /* - Set state bitfield related to regular group operation */
  556. ADC_STATE_CLR_SET(hadc->State,
  557. HAL_ADC_STATE_READY | HAL_ADC_STATE_REG_EOC | HAL_ADC_STATE_REG_OVR,
  558. HAL_ADC_STATE_REG_BUSY);
  559. /* If conversions on group regular are also triggering group injected, */
  560. /* update ADC state. */
  561. if (READ_BIT(hadc->Instance->CR1, ADC_CR1_JAUTO) != RESET)
  562. {
  563. ADC_STATE_CLR_SET(hadc->State, HAL_ADC_STATE_INJ_EOC, HAL_ADC_STATE_INJ_BUSY);
  564. }
  565. /* State machine update: Check if an injected conversion is ongoing */
  566. if (HAL_IS_BIT_SET(hadc->State, HAL_ADC_STATE_INJ_BUSY))
  567. {
  568. /* Reset ADC error code fields related to conversions on group regular */
  569. CLEAR_BIT(hadc->ErrorCode, (HAL_ADC_ERROR_OVR | HAL_ADC_ERROR_DMA));
  570. }
  571. else
  572. {
  573. /* Reset ADC all error code fields */
  574. ADC_CLEAR_ERRORCODE(hadc);
  575. }
  576. /* Process unlocked */
  577. /* Unlock before starting ADC conversions: in case of potential */
  578. /* interruption, to let the process to ADC IRQ Handler. */
  579. __HAL_UNLOCK(hadc);
  580. /* Set the DMA transfer complete callback */
  581. hadc->DMA_Handle->XferCpltCallback = ADC_MultiModeDMAConvCplt;
  582. /* Set the DMA half transfer complete callback */
  583. hadc->DMA_Handle->XferHalfCpltCallback = ADC_MultiModeDMAHalfConvCplt;
  584. /* Set the DMA error callback */
  585. hadc->DMA_Handle->XferErrorCallback = ADC_MultiModeDMAError ;
  586. /* Manage ADC and DMA start: ADC overrun interruption, DMA start, ADC */
  587. /* start (in case of SW start): */
  588. /* Clear regular group conversion flag and overrun flag */
  589. /* (To ensure of no unknown state from potential previous ADC operations) */
  590. __HAL_ADC_CLEAR_FLAG(hadc, ADC_FLAG_EOC);
  591. /* Enable ADC overrun interrupt */
  592. __HAL_ADC_ENABLE_IT(hadc, ADC_IT_OVR);
  593. /* Pointer to the common control register to which is belonging hadc */
  594. /* (Depending on STM32F4 product, there may be up to 3 ADC and 1 common */
  595. /* control register) */
  596. tmpADC_Common = ADC_COMMON_REGISTER(hadc);
  597. if (hadc->Init.DMAContinuousRequests != DISABLE)
  598. {
  599. /* Enable the selected ADC DMA request after last transfer */
  600. tmpADC_Common->CCR |= ADC_CCR_DDS;
  601. }
  602. else
  603. {
  604. /* Disable the selected ADC EOC rising on each regular channel conversion */
  605. tmpADC_Common->CCR &= ~ADC_CCR_DDS;
  606. }
  607. /* Enable the DMA Stream */
  608. HAL_DMA_Start_IT(hadc->DMA_Handle, (uint32_t)&tmpADC_Common->CDR, (uint32_t)pData, Length);
  609. /* if no external trigger present enable software conversion of regular channels */
  610. if((hadc->Instance->CR2 & ADC_CR2_EXTEN) == RESET)
  611. {
  612. /* Enable the selected ADC software conversion for regular group */
  613. hadc->Instance->CR2 |= (uint32_t)ADC_CR2_SWSTART;
  614. }
  615. }
  616. else
  617. {
  618. /* Update ADC state machine to error */
  619. SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL);
  620. /* Set ADC error code to ADC IP internal error */
  621. SET_BIT(hadc->ErrorCode, HAL_ADC_ERROR_INTERNAL);
  622. }
  623. /* Return function status */
  624. return HAL_OK;
  625. }
  626. /**
  627. * @brief Disables ADC DMA (multi-ADC mode) and disables ADC peripheral
  628. * @param hadc pointer to a ADC_HandleTypeDef structure that contains
  629. * the configuration information for the specified ADC.
  630. * @retval HAL status
  631. */
  632. HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef* hadc)
  633. {
  634. HAL_StatusTypeDef tmp_hal_status = HAL_OK;
  635. ADC_Common_TypeDef *tmpADC_Common;
  636. /* Check the parameters */
  637. assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
  638. /* Process locked */
  639. __HAL_LOCK(hadc);
  640. /* Stop potential conversion on going, on regular and injected groups */
  641. /* Disable ADC peripheral */
  642. __HAL_ADC_DISABLE(hadc);
  643. /* Pointer to the common control register to which is belonging hadc */
  644. /* (Depending on STM32F4 product, there may be up to 3 ADC and 1 common */
  645. /* control register) */
  646. tmpADC_Common = ADC_COMMON_REGISTER(hadc);
  647. /* Check if ADC is effectively disabled */
  648. if(HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_ADON))
  649. {
  650. /* Disable the selected ADC DMA mode for multimode */
  651. tmpADC_Common->CCR &= ~ADC_CCR_DDS;
  652. /* Disable the DMA channel (in case of DMA in circular mode or stop while */
  653. /* DMA transfer is on going) */
  654. tmp_hal_status = HAL_DMA_Abort(hadc->DMA_Handle);
  655. /* Disable ADC overrun interrupt */
  656. __HAL_ADC_DISABLE_IT(hadc, ADC_IT_OVR);
  657. /* Set ADC state */
  658. ADC_STATE_CLR_SET(hadc->State,
  659. HAL_ADC_STATE_REG_BUSY | HAL_ADC_STATE_INJ_BUSY,
  660. HAL_ADC_STATE_READY);
  661. }
  662. /* Process unlocked */
  663. __HAL_UNLOCK(hadc);
  664. /* Return function status */
  665. return tmp_hal_status;
  666. }
  667. /**
  668. * @brief Returns the last ADC1, ADC2 and ADC3 regular conversions results
  669. * data in the selected multi mode.
  670. * @param hadc pointer to a ADC_HandleTypeDef structure that contains
  671. * the configuration information for the specified ADC.
  672. * @retval The converted data value.
  673. */
  674. uint32_t HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef* hadc)
  675. {
  676. ADC_Common_TypeDef *tmpADC_Common;
  677. /* Pointer to the common control register to which is belonging hadc */
  678. /* (Depending on STM32F4 product, there may be up to 3 ADC and 1 common */
  679. /* control register) */
  680. tmpADC_Common = ADC_COMMON_REGISTER(hadc);
  681. /* Return the multi mode conversion value */
  682. return tmpADC_Common->CDR;
  683. }
  684. /**
  685. * @brief Injected conversion complete callback in non blocking mode
  686. * @param hadc pointer to a ADC_HandleTypeDef structure that contains
  687. * the configuration information for the specified ADC.
  688. * @retval None
  689. */
  690. __weak void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc)
  691. {
  692. /* Prevent unused argument(s) compilation warning */
  693. UNUSED(hadc);
  694. /* NOTE : This function Should not be modified, when the callback is needed,
  695. the HAL_ADC_InjectedConvCpltCallback could be implemented in the user file
  696. */
  697. }
  698. /**
  699. * @brief Configures for the selected ADC injected channel its corresponding
  700. * rank in the sequencer and its sample time.
  701. * @param hadc pointer to a ADC_HandleTypeDef structure that contains
  702. * the configuration information for the specified ADC.
  703. * @param sConfigInjected ADC configuration structure for injected channel.
  704. * @retval None
  705. */
  706. HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef* hadc, ADC_InjectionConfTypeDef* sConfigInjected)
  707. {
  708. #ifdef USE_FULL_ASSERT
  709. uint32_t tmp = 0U;
  710. #endif /* USE_FULL_ASSERT */
  711. ADC_Common_TypeDef *tmpADC_Common;
  712. /* Check the parameters */
  713. assert_param(IS_ADC_CHANNEL(sConfigInjected->InjectedChannel));
  714. assert_param(IS_ADC_INJECTED_RANK(sConfigInjected->InjectedRank));
  715. assert_param(IS_ADC_SAMPLE_TIME(sConfigInjected->InjectedSamplingTime));
  716. assert_param(IS_ADC_EXT_INJEC_TRIG(sConfigInjected->ExternalTrigInjecConv));
  717. assert_param(IS_ADC_INJECTED_LENGTH(sConfigInjected->InjectedNbrOfConversion));
  718. assert_param(IS_FUNCTIONAL_STATE(sConfigInjected->AutoInjectedConv));
  719. assert_param(IS_FUNCTIONAL_STATE(sConfigInjected->InjectedDiscontinuousConvMode));
  720. #ifdef USE_FULL_ASSERT
  721. tmp = ADC_GET_RESOLUTION(hadc);
  722. assert_param(IS_ADC_RANGE(tmp, sConfigInjected->InjectedOffset));
  723. #endif /* USE_FULL_ASSERT */
  724. if(sConfigInjected->ExternalTrigInjecConv != ADC_INJECTED_SOFTWARE_START)
  725. {
  726. assert_param(IS_ADC_EXT_INJEC_TRIG_EDGE(sConfigInjected->ExternalTrigInjecConvEdge));
  727. }
  728. /* Process locked */
  729. __HAL_LOCK(hadc);
  730. /* if ADC_Channel_10 ... ADC_Channel_18 is selected */
  731. if (sConfigInjected->InjectedChannel > ADC_CHANNEL_9)
  732. {
  733. /* Clear the old sample time */
  734. hadc->Instance->SMPR1 &= ~ADC_SMPR1(ADC_SMPR1_SMP10, sConfigInjected->InjectedChannel);
  735. /* Set the new sample time */
  736. hadc->Instance->SMPR1 |= ADC_SMPR1(sConfigInjected->InjectedSamplingTime, sConfigInjected->InjectedChannel);
  737. }
  738. else /* ADC_Channel include in ADC_Channel_[0..9] */
  739. {
  740. /* Clear the old sample time */
  741. hadc->Instance->SMPR2 &= ~ADC_SMPR2(ADC_SMPR2_SMP0, sConfigInjected->InjectedChannel);
  742. /* Set the new sample time */
  743. hadc->Instance->SMPR2 |= ADC_SMPR2(sConfigInjected->InjectedSamplingTime, sConfigInjected->InjectedChannel);
  744. }
  745. /*---------------------------- ADCx JSQR Configuration -----------------*/
  746. hadc->Instance->JSQR &= ~(ADC_JSQR_JL);
  747. hadc->Instance->JSQR |= ADC_SQR1(sConfigInjected->InjectedNbrOfConversion);
  748. /* Rank configuration */
  749. /* Clear the old SQx bits for the selected rank */
  750. hadc->Instance->JSQR &= ~ADC_JSQR(ADC_JSQR_JSQ1, sConfigInjected->InjectedRank,sConfigInjected->InjectedNbrOfConversion);
  751. /* Set the SQx bits for the selected rank */
  752. hadc->Instance->JSQR |= ADC_JSQR(sConfigInjected->InjectedChannel, sConfigInjected->InjectedRank,sConfigInjected->InjectedNbrOfConversion);
  753. /* Enable external trigger if trigger selection is different of software */
  754. /* start. */
  755. /* Note: This configuration keeps the hardware feature of parameter */
  756. /* ExternalTrigConvEdge "trigger edge none" equivalent to */
  757. /* software start. */
  758. if(sConfigInjected->ExternalTrigInjecConv != ADC_INJECTED_SOFTWARE_START)
  759. {
  760. /* Select external trigger to start conversion */
  761. hadc->Instance->CR2 &= ~(ADC_CR2_JEXTSEL);
  762. hadc->Instance->CR2 |= sConfigInjected->ExternalTrigInjecConv;
  763. /* Select external trigger polarity */
  764. hadc->Instance->CR2 &= ~(ADC_CR2_JEXTEN);
  765. hadc->Instance->CR2 |= sConfigInjected->ExternalTrigInjecConvEdge;
  766. }
  767. else
  768. {
  769. /* Reset the external trigger */
  770. hadc->Instance->CR2 &= ~(ADC_CR2_JEXTSEL);
  771. hadc->Instance->CR2 &= ~(ADC_CR2_JEXTEN);
  772. }
  773. if (sConfigInjected->AutoInjectedConv != DISABLE)
  774. {
  775. /* Enable the selected ADC automatic injected group conversion */
  776. hadc->Instance->CR1 |= ADC_CR1_JAUTO;
  777. }
  778. else
  779. {
  780. /* Disable the selected ADC automatic injected group conversion */
  781. hadc->Instance->CR1 &= ~(ADC_CR1_JAUTO);
  782. }
  783. if (sConfigInjected->InjectedDiscontinuousConvMode != DISABLE)
  784. {
  785. /* Enable the selected ADC injected discontinuous mode */
  786. hadc->Instance->CR1 |= ADC_CR1_JDISCEN;
  787. }
  788. else
  789. {
  790. /* Disable the selected ADC injected discontinuous mode */
  791. hadc->Instance->CR1 &= ~(ADC_CR1_JDISCEN);
  792. }
  793. switch(sConfigInjected->InjectedRank)
  794. {
  795. case 1U:
  796. /* Set injected channel 1 offset */
  797. hadc->Instance->JOFR1 &= ~(ADC_JOFR1_JOFFSET1);
  798. hadc->Instance->JOFR1 |= sConfigInjected->InjectedOffset;
  799. break;
  800. case 2U:
  801. /* Set injected channel 2 offset */
  802. hadc->Instance->JOFR2 &= ~(ADC_JOFR2_JOFFSET2);
  803. hadc->Instance->JOFR2 |= sConfigInjected->InjectedOffset;
  804. break;
  805. case 3U:
  806. /* Set injected channel 3 offset */
  807. hadc->Instance->JOFR3 &= ~(ADC_JOFR3_JOFFSET3);
  808. hadc->Instance->JOFR3 |= sConfigInjected->InjectedOffset;
  809. break;
  810. default:
  811. /* Set injected channel 4 offset */
  812. hadc->Instance->JOFR4 &= ~(ADC_JOFR4_JOFFSET4);
  813. hadc->Instance->JOFR4 |= sConfigInjected->InjectedOffset;
  814. break;
  815. }
  816. /* Pointer to the common control register to which is belonging hadc */
  817. /* (Depending on STM32F4 product, there may be up to 3 ADC and 1 common */
  818. /* control register) */
  819. tmpADC_Common = ADC_COMMON_REGISTER(hadc);
  820. /* if ADC1 Channel_18 is selected enable VBAT Channel */
  821. if ((hadc->Instance == ADC1) && (sConfigInjected->InjectedChannel == ADC_CHANNEL_VBAT))
  822. {
  823. /* Enable the VBAT channel*/
  824. tmpADC_Common->CCR |= ADC_CCR_VBATE;
  825. }
  826. /* if ADC1 Channel_16 or Channel_17 is selected enable TSVREFE Channel(Temperature sensor and VREFINT) */
  827. if ((hadc->Instance == ADC1) && ((sConfigInjected->InjectedChannel == ADC_CHANNEL_TEMPSENSOR) || (sConfigInjected->InjectedChannel == ADC_CHANNEL_VREFINT)))
  828. {
  829. /* Enable the TSVREFE channel*/
  830. tmpADC_Common->CCR |= ADC_CCR_TSVREFE;
  831. }
  832. /* Process unlocked */
  833. __HAL_UNLOCK(hadc);
  834. /* Return function status */
  835. return HAL_OK;
  836. }
  837. /**
  838. * @brief Configures the ADC multi-mode
  839. * @param hadc pointer to a ADC_HandleTypeDef structure that contains
  840. * the configuration information for the specified ADC.
  841. * @param multimode pointer to an ADC_MultiModeTypeDef structure that contains
  842. * the configuration information for multimode.
  843. * @retval HAL status
  844. */
  845. HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef* hadc, ADC_MultiModeTypeDef* multimode)
  846. {
  847. ADC_Common_TypeDef *tmpADC_Common;
  848. /* Check the parameters */
  849. assert_param(IS_ADC_MODE(multimode->Mode));
  850. assert_param(IS_ADC_DMA_ACCESS_MODE(multimode->DMAAccessMode));
  851. assert_param(IS_ADC_SAMPLING_DELAY(multimode->TwoSamplingDelay));
  852. /* Process locked */
  853. __HAL_LOCK(hadc);
  854. /* Pointer to the common control register to which is belonging hadc */
  855. /* (Depending on STM32F4 product, there may be up to 3 ADC and 1 common */
  856. /* control register) */
  857. tmpADC_Common = ADC_COMMON_REGISTER(hadc);
  858. /* Set ADC mode */
  859. tmpADC_Common->CCR &= ~(ADC_CCR_MULTI);
  860. tmpADC_Common->CCR |= multimode->Mode;
  861. /* Set the ADC DMA access mode */
  862. tmpADC_Common->CCR &= ~(ADC_CCR_DMA);
  863. tmpADC_Common->CCR |= multimode->DMAAccessMode;
  864. /* Set delay between two sampling phases */
  865. tmpADC_Common->CCR &= ~(ADC_CCR_DELAY);
  866. tmpADC_Common->CCR |= multimode->TwoSamplingDelay;
  867. /* Process unlocked */
  868. __HAL_UNLOCK(hadc);
  869. /* Return function status */
  870. return HAL_OK;
  871. }
  872. /**
  873. * @}
  874. */
  875. /**
  876. * @brief DMA transfer complete callback.
  877. * @param hdma pointer to a DMA_HandleTypeDef structure that contains
  878. * the configuration information for the specified DMA module.
  879. * @retval None
  880. */
  881. static void ADC_MultiModeDMAConvCplt(DMA_HandleTypeDef *hdma)
  882. {
  883. /* Retrieve ADC handle corresponding to current DMA handle */
  884. ADC_HandleTypeDef* hadc = ( ADC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
  885. /* Update state machine on conversion status if not in error state */
  886. if (HAL_IS_BIT_CLR(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL | HAL_ADC_STATE_ERROR_DMA))
  887. {
  888. /* Update ADC state machine */
  889. SET_BIT(hadc->State, HAL_ADC_STATE_REG_EOC);
  890. /* Determine whether any further conversion upcoming on group regular */
  891. /* by external trigger, continuous mode or scan sequence on going. */
  892. /* Note: On STM32F4, there is no independent flag of end of sequence. */
  893. /* The test of scan sequence on going is done either with scan */
  894. /* sequence disabled or with end of conversion flag set to */
  895. /* of end of sequence. */
  896. if(ADC_IS_SOFTWARE_START_REGULAR(hadc) &&
  897. (hadc->Init.ContinuousConvMode == DISABLE) &&
  898. (HAL_IS_BIT_CLR(hadc->Instance->SQR1, ADC_SQR1_L) ||
  899. HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_EOCS) ) )
  900. {
  901. /* Disable ADC end of single conversion interrupt on group regular */
  902. /* Note: Overrun interrupt was enabled with EOC interrupt in */
  903. /* HAL_ADC_Start_IT(), but is not disabled here because can be used */
  904. /* by overrun IRQ process below. */
  905. __HAL_ADC_DISABLE_IT(hadc, ADC_IT_EOC);
  906. /* Set ADC state */
  907. CLEAR_BIT(hadc->State, HAL_ADC_STATE_REG_BUSY);
  908. if (HAL_IS_BIT_CLR(hadc->State, HAL_ADC_STATE_INJ_BUSY))
  909. {
  910. SET_BIT(hadc->State, HAL_ADC_STATE_READY);
  911. }
  912. }
  913. /* Conversion complete callback */
  914. HAL_ADC_ConvCpltCallback(hadc);
  915. }
  916. else
  917. {
  918. /* Call DMA error callback */
  919. hadc->DMA_Handle->XferErrorCallback(hdma);
  920. }
  921. }
  922. /**
  923. * @brief DMA half transfer complete callback.
  924. * @param hdma pointer to a DMA_HandleTypeDef structure that contains
  925. * the configuration information for the specified DMA module.
  926. * @retval None
  927. */
  928. static void ADC_MultiModeDMAHalfConvCplt(DMA_HandleTypeDef *hdma)
  929. {
  930. ADC_HandleTypeDef* hadc = ( ADC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
  931. /* Conversion complete callback */
  932. HAL_ADC_ConvHalfCpltCallback(hadc);
  933. }
  934. /**
  935. * @brief DMA error callback
  936. * @param hdma pointer to a DMA_HandleTypeDef structure that contains
  937. * the configuration information for the specified DMA module.
  938. * @retval None
  939. */
  940. static void ADC_MultiModeDMAError(DMA_HandleTypeDef *hdma)
  941. {
  942. ADC_HandleTypeDef* hadc = ( ADC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
  943. hadc->State= HAL_ADC_STATE_ERROR_DMA;
  944. /* Set ADC error code to DMA error */
  945. hadc->ErrorCode |= HAL_ADC_ERROR_DMA;
  946. HAL_ADC_ErrorCallback(hadc);
  947. }
  948. /**
  949. * @}
  950. */
  951. #endif /* HAL_ADC_MODULE_ENABLED */
  952. /**
  953. * @}
  954. */
  955. /**
  956. * @}
  957. */