STM32F4 Standard Peripheral bibliotheek  1.0
ST Microelectronics bibliotheek documentatie voor de STM32F4 Standard Peripheral Library
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
Interrupts and flags management functions

Interrupts and flags management functions. More...

Functions

FunctionalState DMA_GetCmdStatus (DMA_Stream_TypeDef *DMAy_Streamx)
 Returns the status of EN bit for the specified DMAy Streamx. More...
 
uint32_t DMA_GetFIFOStatus (DMA_Stream_TypeDef *DMAy_Streamx)
 Returns the current DMAy Streamx FIFO filled level. More...
 
FlagStatus DMA_GetFlagStatus (DMA_Stream_TypeDef *DMAy_Streamx, uint32_t DMA_FLAG)
 Checks whether the specified DMAy Streamx flag is set or not. More...
 
void DMA_ClearFlag (DMA_Stream_TypeDef *DMAy_Streamx, uint32_t DMA_FLAG)
 Clears the DMAy Streamx's pending flags. More...
 
void DMA_ITConfig (DMA_Stream_TypeDef *DMAy_Streamx, uint32_t DMA_IT, FunctionalState NewState)
 Enables or disables the specified DMAy Streamx interrupts. More...
 
ITStatus DMA_GetITStatus (DMA_Stream_TypeDef *DMAy_Streamx, uint32_t DMA_IT)
 Checks whether the specified DMAy Streamx interrupt has occurred or not. More...
 
void DMA_ClearITPendingBit (DMA_Stream_TypeDef *DMAy_Streamx, uint32_t DMA_IT)
 Clears the DMAy Streamx's interrupt pending bits. More...
 

Detailed Description

Interrupts and flags management functions.

 ===============================================================================
                  Interrupts and flags management functions
 ===============================================================================  

  This subsection provides functions allowing to
   - Check the DMA enable status
   - Check the FIFO status 
   - Configure the DMA Interrupts sources and check or clear the flags or pending bits status.   
   
 1. DMA Enable status:
   After configuring the DMA Stream (DMA_Init() function) and enabling the stream,
   it is recommended to check (or wait until) the DMA Stream is effectively enabled.
   A Stream may remain disabled if a configuration parameter is wrong.
   After disabling a DMA Stream, it is also recommended to check (or wait until) the DMA
   Stream is effectively disabled. If a Stream is disabled while a data transfer is ongoing, 
   the current data will be transferred and the Stream will be effectively disabled only after
   this data transfer completion.
   To monitor this state it is possible to use the following function:
     - FunctionalState DMA_GetCmdStatus(DMA_Stream_TypeDef* DMAy_Streamx); 
 
 2. FIFO Status:
   It is possible to monitor the FIFO status when a transfer is ongoing using the following 
   function:
     - uint32_t DMA_GetFIFOStatus(DMA_Stream_TypeDef* DMAy_Streamx); 
 
 3. DMA Interrupts and Flags:
  The user should identify which mode will be used in his application to manage the
  DMA controller events: Polling mode or Interrupt mode. 
    
  Polling Mode
  =============
    Each DMA stream can be managed through 4 event Flags:
    (x : DMA Stream number )
       1. DMA_FLAG_FEIFx  : to indicate that a FIFO Mode Transfer Error event occurred.
       2. DMA_FLAG_DMEIFx : to indicate that a Direct Mode Transfer Error event occurred.
       3. DMA_FLAG_TEIFx  : to indicate that a Transfer Error event occurred.
       4. DMA_FLAG_HTIFx  : to indicate that a Half-Transfer Complete event occurred.
       5. DMA_FLAG_TCIFx  : to indicate that a Transfer Complete event occurred .       

   In this Mode it is advised to use the following functions:
      - FlagStatus DMA_GetFlagStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG);
      - void DMA_ClearFlag(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG);

  Interrupt Mode
  ===============
    Each DMA Stream can be managed through 4 Interrupts:

    Interrupt Source
    ----------------
       1. DMA_IT_FEIFx  : specifies the interrupt source for the  FIFO Mode Transfer Error event.
       2. DMA_IT_DMEIFx : specifies the interrupt source for the Direct Mode Transfer Error event.
       3. DMA_IT_TEIFx  : specifies the interrupt source for the Transfer Error event.
       4. DMA_IT_HTIFx  : specifies the interrupt source for the Half-Transfer Complete event.
       5. DMA_IT_TCIFx  : specifies the interrupt source for the a Transfer Complete event. 
     
  In this Mode it is advised to use the following functions:
     - void DMA_ITConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT, FunctionalState NewState);
     - ITStatus DMA_GetITStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT);
     - void DMA_ClearITPendingBit(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT);

Function Documentation

void DMA_ClearFlag ( DMA_Stream_TypeDef *  DMAy_Streamx,
uint32_t  DMA_FLAG 
)

Clears the DMAy Streamx's pending flags.

Parameters
DMAy_Streamx,:where y can be 1 or 2 to select the DMA and x can be 0 to 7 to select the DMA Stream.
DMA_FLAG,:specifies the flag to clear. This parameter can be any combination of the following values:
  • DMA_FLAG_TCIFx: Streamx transfer complete flag
  • DMA_FLAG_HTIFx: Streamx half transfer complete flag
  • DMA_FLAG_TEIFx: Streamx transfer error flag
  • DMA_FLAG_DMEIFx: Streamx direct mode error flag
  • DMA_FLAG_FEIFx: Streamx FIFO error flag Where x can be 0 to 7 to select the DMA Stream.
Return values
None
void DMA_ClearITPendingBit ( DMA_Stream_TypeDef *  DMAy_Streamx,
uint32_t  DMA_IT 
)

Clears the DMAy Streamx's interrupt pending bits.

Parameters
DMAy_Streamx,:where y can be 1 or 2 to select the DMA and x can be 0 to 7 to select the DMA Stream.
DMA_IT,:specifies the DMA interrupt pending bit to clear. This parameter can be any combination of the following values:
  • DMA_IT_TCIFx: Streamx transfer complete interrupt
  • DMA_IT_HTIFx: Streamx half transfer complete interrupt
  • DMA_IT_TEIFx: Streamx transfer error interrupt
  • DMA_IT_DMEIFx: Streamx direct mode error interrupt
  • DMA_IT_FEIFx: Streamx FIFO error interrupt Where x can be 0 to 7 to select the DMA Stream.
Return values
None
FunctionalState DMA_GetCmdStatus ( DMA_Stream_TypeDef *  DMAy_Streamx)

Returns the status of EN bit for the specified DMAy Streamx.

Parameters
DMAy_Streamx,:where y can be 1 or 2 to select the DMA and x can be 0 to 7 to select the DMA Stream.
Note
After configuring the DMA Stream (DMA_Init() function) and enabling the stream, it is recommended to check (or wait until) the DMA Stream is effectively enabled. A Stream may remain disabled if a configuration parameter is wrong. After disabling a DMA Stream, it is also recommended to check (or wait until) the DMA Stream is effectively disabled. If a Stream is disabled while a data transfer is ongoing, the current data will be transferred and the Stream will be effectively disabled only after the transfer of this single data is finished.
Return values
Currentstate of the DMAy Streamx (ENABLE or DISABLE).
uint32_t DMA_GetFIFOStatus ( DMA_Stream_TypeDef *  DMAy_Streamx)

Returns the current DMAy Streamx FIFO filled level.

Parameters
DMAy_Streamx,:where y can be 1 or 2 to select the DMA and x can be 0 to 7 to select the DMA Stream.
Return values
TheFIFO filling state.
  • DMA_FIFOStatus_Less1QuarterFull: when FIFO is less than 1 quarter-full and not empty.
  • DMA_FIFOStatus_1QuarterFull: if more than 1 quarter-full.
  • DMA_FIFOStatus_HalfFull: if more than 1 half-full.
  • DMA_FIFOStatus_3QuartersFull: if more than 3 quarters-full.
  • DMA_FIFOStatus_Empty: when FIFO is empty
  • DMA_FIFOStatus_Full: when FIFO is full
FlagStatus DMA_GetFlagStatus ( DMA_Stream_TypeDef *  DMAy_Streamx,
uint32_t  DMA_FLAG 
)

Checks whether the specified DMAy Streamx flag is set or not.

Parameters
DMAy_Streamx,:where y can be 1 or 2 to select the DMA and x can be 0 to 7 to select the DMA Stream.
DMA_FLAG,:specifies the flag to check. This parameter can be one of the following values:
  • DMA_FLAG_TCIFx: Streamx transfer complete flag
  • DMA_FLAG_HTIFx: Streamx half transfer complete flag
  • DMA_FLAG_TEIFx: Streamx transfer error flag
  • DMA_FLAG_DMEIFx: Streamx direct mode error flag
  • DMA_FLAG_FEIFx: Streamx FIFO error flag Where x can be 0 to 7 to select the DMA Stream.
Return values
Thenew state of DMA_FLAG (SET or RESET).
ITStatus DMA_GetITStatus ( DMA_Stream_TypeDef *  DMAy_Streamx,
uint32_t  DMA_IT 
)

Checks whether the specified DMAy Streamx interrupt has occurred or not.

Parameters
DMAy_Streamx,:where y can be 1 or 2 to select the DMA and x can be 0 to 7 to select the DMA Stream.
DMA_IT,:specifies the DMA interrupt source to check. This parameter can be one of the following values:
  • DMA_IT_TCIFx: Streamx transfer complete interrupt
  • DMA_IT_HTIFx: Streamx half transfer complete interrupt
  • DMA_IT_TEIFx: Streamx transfer error interrupt
  • DMA_IT_DMEIFx: Streamx direct mode error interrupt
  • DMA_IT_FEIFx: Streamx FIFO error interrupt Where x can be 0 to 7 to select the DMA Stream.
Return values
Thenew state of DMA_IT (SET or RESET).
void DMA_ITConfig ( DMA_Stream_TypeDef *  DMAy_Streamx,
uint32_t  DMA_IT,
FunctionalState  NewState 
)

Enables or disables the specified DMAy Streamx interrupts.

Parameters
DMAy_Streamx,:where y can be 1 or 2 to select the DMA and x can be 0 to 7 to select the DMA Stream.
DMA_IT,:specifies the DMA interrupt sources to be enabled or disabled. This parameter can be any combination of the following values:
  • DMA_IT_TC: Transfer complete interrupt mask
  • DMA_IT_HT: Half transfer complete interrupt mask
  • DMA_IT_TE: Transfer error interrupt mask
  • DMA_IT_FE: FIFO error interrupt mask
NewState,:new state of the specified DMA interrupts. This parameter can be: ENABLE or DISABLE.
Return values
None