示例#1
0
文件: spi_lld.c 项目: Paluche/Hubert
/**
 * @brief   Deactivates the SPI peripheral.
 *
 * @param[in] spip      pointer to the @p SPIDriver object
 *
 * @notapi
 */
void spi_lld_stop(SPIDriver *spip) {

  /* If in ready state then disables the SPI clock.*/
  if (spip->state == SPI_READY) {

    /* SPI disable.*/
    spip->spi->CR1 = 0;
    spip->spi->CR2 = 0;
    dmaStreamRelease(spip->dmarx);
    dmaStreamRelease(spip->dmatx);

#if STM32_SPI_USE_SPI1
    if (&SPID1 == spip)
      rccDisableSPI1(FALSE);
#endif
#if STM32_SPI_USE_SPI2
    if (&SPID2 == spip)
      rccDisableSPI2(FALSE);
#endif
#if STM32_SPI_USE_SPI3
    if (&SPID3 == spip)
      rccDisableSPI3(FALSE);
#endif
  }
}
示例#2
0
/**
 * @brief   Deactivates the I2S peripheral.
 *
 * @param[in] i2sp      pointer to the @p I2SDriver object
 *
 * @notapi
 */
void i2s_lld_stop(I2SDriver *i2sp) {

  /* If in ready state then disables the SPI clock.*/
  if (i2sp->state == I2S_READY) {

    /* SPI disable.*/
    i2sp->spi->CR2 = 0;
    if (NULL != i2sp->dmarx)
      dmaStreamRelease(i2sp->dmarx);
    if (NULL != i2sp->dmatx)
      dmaStreamRelease(i2sp->dmatx);

#if STM32_I2S_USE_SPI2
    if (&I2SD2 == i2sp)
      rccDisableSPI2(FALSE);
#endif
#if STM32_I2S_USE_SPI3
    if (&I2SD3 == i2sp)
      rccDisableSPI3(FALSE);
#endif
  }
}