STM8L15x Standard Peripherals Drivers
|
Interrupts and flags management functions. More...
Functions | |
void | SPI_ClearFlag (SPI_TypeDef *SPIx, SPI_FLAG_TypeDef SPI_FLAG) |
Clears the SPI flags. | |
void | SPI_ClearITPendingBit (SPI_TypeDef *SPIx, SPI_IT_TypeDef SPI_IT) |
Clears the interrupt pending bits. | |
FlagStatus | SPI_GetFlagStatus (SPI_TypeDef *SPIx, SPI_FLAG_TypeDef SPI_FLAG) |
Checks whether the specified SPI flag is set or not. | |
ITStatus | SPI_GetITStatus (SPI_TypeDef *SPIx, SPI_IT_TypeDef SPI_IT) |
Checks whether the specified interrupt has occurred or not. | |
void | SPI_ITConfig (SPI_TypeDef *SPIx, SPI_IT_TypeDef SPI_IT, FunctionalState NewState) |
Enables or disables the specified interrupts. |
Detailed Description
Interrupts and flags management functions.
=============================================================================== Interrupts and flags management functions =============================================================================== This section provides a set of functions allowing to configure the SPI Interrupts sources and check or clear the flags or pending bits status. The user should identify which mode will be used in his application to manage the communication: Polling mode, Interrupt mode or DMA mode. Polling Mode ============= In Polling Mode, the SPI communication can be managed by 6 flags: 1. SPI_FLAG_TXE: to indicate the status of the transmit buffer register 2. SPI_FLAG_RXNE: to indicate the status of the receive buffer register 3. SPI_FLAG_WKUP: to indicate the state of the Wakeup event. 4. SPI_FLAG_CRCERR: to indicate if a CRC Calculation error occurs 5. SPI_FLAG_MODF: to indicate if a Mode Fault error occurs 6. SPI_FLAG_OVR: to indicate if an Overrun error occurs In this Mode it is advised to use the following functions: - FlagStatus SPI_GetFlagStatus(SPI_TypeDef* SPIx, SPI_FLAG_TypeDef SPI_FLAG); - void SPI_ClearFlag(SPI_TypeDef* SPIx, SPI_FLAG_TypeDef SPI_FLAG); Interrupt Mode =============== In Interrupt Mode, the SPI communication can be managed by 4 interrupt sources and 6 pending bits: Pending Bits: ------------- 1. SPI_IT_TXE: to indicate the status of the transmit buffer register 2. SPI_IT_RXNE: to indicate the status of the receive buffer register 3. SPI_IT_CRCERR: to indicate if a CRC Calculation error occurs 4. SPI_IT_MODF: to indicate if a Mode Fault error occurs 5. SPI_IT_OVR: to indicate if an Overrun error occurs 6. SPI_IT_WKUP: to indicate if an Wake_up event occurs Interrupt Source: ----------------- 1. SPI_IT_TXE: specifies the interrupt source for the Tx buffer empty interrupt. 2. SPI_IT_RXNE: specifies the interrupt source for the Rx buffer not empty interrupt. 3. SPI_IT_ERR: specifies the interrupt source for the errors interrupt. 4. SPI_IT_WKUP: specifies the interrupt source for the Wake-up interrupt. In this Mode it is advised to use the following functions: - void SPI_ITConfig(SPI_TypeDef* SPIx, SPI_IT_TypeDef SPI_IT, FunctionalState NewState); - ITStatus SPI_GetITStatus(SPI_TypeDef* SPIx, SPI_IT_TypeDef SPI_IT); - void SPI_ClearITPendingBit(SPI_TypeDef* SPIx, SPI_IT_TypeDef SPI_IT); DMA Mode ======== In DMA Mode, the SPI communication can be managed by 2 DMA Channel requests: 1. SPI_DMAReq_Tx: specifies the Tx buffer DMA transfer request 2. SPI_DMAReq_Rx: specifies the Rx buffer DMA transfer request In this Mode it is advised to use the following function: - void SPI_DMACmd(SPI_TypeDef* SPIx, SPI_DMAReq_TypeDef SPI_DMAReq, FunctionalState NewState);
Function Documentation
void SPI_ClearFlag | ( | SPI_TypeDef * | SPIx, |
SPI_FLAG_TypeDef | SPI_FLAG | ||
) |
Clears the SPI flags.
- Note:
- OVR (OverRun Error) interrupt pending bit is cleared by software sequence: a read operation to SPI_DR register (SPI_ReceiveData()) followed by a read operation to SPI_SR register (SPI_GetFlagStatus()).
- MODF (Mode Fault) interrupt pending bit is cleared by software sequence: a read/write operation to SPI_SR register (SPI_GetFlagStatus()) followed by a write operation to SPI_CR1 register (SPI_Cmd() to enable the SPI).
Definition at line 690 of file stm8l15x_spi.c.
References IS_SPI_CLEAR_FLAG, and SPI_struct::SR.
void SPI_ClearITPendingBit | ( | SPI_TypeDef * | SPIx, |
SPI_IT_TypeDef | SPI_IT | ||
) |
Clears the interrupt pending bits.
- Note:
- OVR (OverRun Error) interrupt pending bit is cleared by software sequence: a read operation to SPI_DR register (SPI_ReceiveData()) followed by a read operation to SPI_SR register (SPI_GetITStatus()).
- MODF (Mode Fault) interrupt pending bit is cleared by software sequence: a read/write operation to SPI_SR register (SPI_GetITStatus()) followed by a write operation to SPI_CR1 register (SPI_Cmd() to enable the SPI).
Definition at line 758 of file stm8l15x_spi.c.
References IS_SPI_CLEAR_IT, and SPI_struct::SR.
FlagStatus SPI_GetFlagStatus | ( | SPI_TypeDef * | SPIx, |
SPI_FLAG_TypeDef | SPI_FLAG | ||
) |
Checks whether the specified SPI flag is set or not.
Definition at line 655 of file stm8l15x_spi.c.
References IS_SPI_FLAG, RESET, SET, and SPI_struct::SR.
ITStatus SPI_GetITStatus | ( | SPI_TypeDef * | SPIx, |
SPI_IT_TypeDef | SPI_IT | ||
) |
Checks whether the specified interrupt has occurred or not.
Definition at line 711 of file stm8l15x_spi.c.
References __IO, SPI_struct::CR3, IS_SPI_GET_IT, RESET, SET, and SPI_struct::SR.
void SPI_ITConfig | ( | SPI_TypeDef * | SPIx, |
SPI_IT_TypeDef | SPI_IT, | ||
FunctionalState | NewState | ||
) |
Enables or disables the specified interrupts.
Definition at line 620 of file stm8l15x_spi.c.
References SPI_struct::CR3, DISABLE, IS_FUNCTIONAL_STATE, and IS_SPI_CONFIG_IT.