Skip to content

Commit 77364f9

Browse files
committed
[STM32] HAL L0: I2C / DMA updates
This is prelim update before official V1.8.0 HAL to the needed HAL API available as in F0 HAL which is using the same IP.
1 parent c57427f commit 77364f9

File tree

6 files changed

+3436
-2628
lines changed

6 files changed

+3436
-2628
lines changed

targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_dma.c

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
******************************************************************************
33
* @file stm32l0xx_hal_dma.c
44
* @author MCD Application Team
5-
* @version V1.7.0
6-
* @date 31-May-2016
5+
* @version $VERSION$
6+
* @date $DATE$
77
* @brief DMA HAL module driver.
88
*
99
* This file provides firmware functions to manage the following
@@ -480,6 +480,49 @@ HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
480480
return HAL_OK;
481481
}
482482

483+
/**
484+
* @brief Aborts the DMA Transfer in Interrupt mode.
485+
* @param hdma : pointer to a DMA_HandleTypeDef structure that contains
486+
* the configuration information for the specified DMA Stream.
487+
* @retval HAL status
488+
*/
489+
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
490+
{
491+
HAL_StatusTypeDef status = HAL_OK;
492+
493+
if(HAL_DMA_STATE_BUSY != hdma->State)
494+
{
495+
/* no transfer ongoing */
496+
hdma->ErrorCode = HAL_DMA_ERROR_NO_XFER;
497+
498+
status = HAL_ERROR;
499+
}
500+
else
501+
{
502+
/* Disable DMA IT */
503+
__HAL_DMA_DISABLE_IT(hdma, (DMA_IT_TC | DMA_IT_HT | DMA_IT_TE));
504+
505+
/* Disable the channel */
506+
__HAL_DMA_DISABLE(hdma);
507+
508+
/* Clear all flags */
509+
__HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_GI_FLAG_INDEX(hdma));
510+
511+
/* Change the DMA state */
512+
hdma->State = HAL_DMA_STATE_READY;
513+
514+
/* Process Unlocked */
515+
__HAL_UNLOCK(hdma);
516+
517+
/* Call User Abort callback */
518+
if(hdma->XferAbortCallback != NULL)
519+
{
520+
hdma->XferAbortCallback(hdma);
521+
}
522+
}
523+
return status;
524+
}
525+
483526
/**
484527
* @brief Polling for transfer complete.
485528
* @param hdma: pointer to a DMA_HandleTypeDef structure that contains

targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_dma.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
******************************************************************************
33
* @file stm32l0xx_hal_dma.h
44
* @author MCD Application Team
5-
* @version V1.7.0
6-
* @date 31-May-2016
5+
* @version $VERSION$
6+
* @date $DATE$
77
* @brief Header file of DMA HAL module.
88
******************************************************************************
99
* @attention
@@ -139,19 +139,21 @@ typedef struct __DMA_HandleTypeDef
139139

140140
DMA_InitTypeDef Init; /*!< DMA communication parameters */
141141

142-
HAL_LockTypeDef Lock; /*!< DMA locking object */
142+
HAL_LockTypeDef Lock; /*!< DMA locking object */
143143

144144
__IO HAL_DMA_StateTypeDef State; /*!< DMA transfer state */
145145

146-
void *Parent; /*!< Parent object state */
146+
void *Parent; /*!< Parent object state */
147147

148148
void (* XferCpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer complete callback */
149149

150150
void (* XferHalfCpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA Half transfer complete callback */
151151

152152
void (* XferErrorCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer error callback */
153-
154-
__IO uint32_t ErrorCode; /*!< DMA Error code */
153+
154+
void (* XferAbortCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer abort callback */
155+
156+
__IO uint32_t ErrorCode; /*!< DMA Error code */
155157

156158
} DMA_HandleTypeDef;
157159

@@ -170,6 +172,7 @@ typedef struct __DMA_HandleTypeDef
170172
*/
171173
#define HAL_DMA_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */
172174
#define HAL_DMA_ERROR_TE ((uint32_t)0x00000001U) /*!< Transfer error */
175+
#define HAL_DMA_ERROR_NO_XFER ((uint32_t)0x00000004U) /*!< no ongoing transfer */
173176
#define HAL_DMA_ERROR_TIMEOUT ((uint32_t)0x00000020U) /*!< Timeout error */
174177

175178
#if defined (STM32L011xx) || defined (STM32L021xx)
@@ -643,6 +646,7 @@ HAL_StatusTypeDef HAL_DMA_DeInit (DMA_HandleTypeDef *hdma);
643646
HAL_StatusTypeDef HAL_DMA_Start (DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
644647
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
645648
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma);
649+
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma);
646650
HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, uint32_t CompleteLevel, uint32_t Timeout);
647651
void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma);
648652
/**

0 commit comments

Comments
 (0)