/** * @brief Deactivates the PWM peripheral. * * @param[in] pwmp pointer to a @p PWMDriver object */ void pwm_lld_stop(PWMDriver *pwmp) { /* If in ready state then disables the PWM clock.*/ if (pwmp->pd_state == PWM_READY) { stop_channels(pwmp); pwmp->pd_tim->CR1 = 0; pwmp->pd_tim->BDTR = 0; pwmp->pd_tim->DIER = 0; #if USE_STM32_PWM1 if (&PWMD1 == pwmp) { NVICDisableVector(TIM1_UP_IRQn); NVICDisableVector(TIM1_CC_IRQn); RCC->APB2ENR &= ~RCC_APB2ENR_TIM1EN; } #endif #if USE_STM32_PWM2 if (&PWMD2 == pwmp) { NVICDisableVector(TIM2_IRQn); RCC->APB1ENR &= ~RCC_APB1ENR_TIM2EN; } #endif #if USE_STM32_PWM3 if (&PWMD3 == pwmp) { NVICDisableVector(TIM3_IRQn); RCC->APB1ENR &= ~RCC_APB1ENR_TIM3EN; } #endif #if USE_STM32_PWM2 if (&PWMD4 == pwmp) { NVICDisableVector(TIM4_IRQn); RCC->APB1ENR &= ~RCC_APB1ENR_TIM4EN; } #endif } }
/** * @brief Deactivates the USB peripheral. * * @param[in] usbp pointer to the @p USBDriver object * * @notapi */ void usb_lld_stop(USBDriver *usbp) { /* If in ready state then disables the USB clock.*/ if (usbp->state == USB_STOP) { #if STM32_USB_USE_USB1 if (&USBD1 == usbp) { NVICDisableVector(19); NVICDisableVector(20); STM32_USB->CNTR = CNTR_PDWN | CNTR_FRES; rccDisableUSB(FALSE); } #endif } }
/** * @brief Deactivates the PWM peripheral. * * @param[in] pwmp pointer to a @p PWMDriver object */ void pwm_lld_stop(PWMDriver *pwmp) { /* If in ready state then disables the PWM clock.*/ if (pwmp->pd_state == PWM_READY) { pwmp->pd_enabled_channels = 0; /* All channels disabled. */ pwmp->pd_tim->CR1 = 0; pwmp->pd_tim->CR2 = 0; pwmp->pd_tim->CCER = 0; /* Outputs disabled. */ pwmp->pd_tim->CCR1 = 0; /* Comparator 1 disabled. */ pwmp->pd_tim->CCR2 = 0; /* Comparator 2 disabled. */ pwmp->pd_tim->CCR3 = 0; /* Comparator 3 disabled. */ pwmp->pd_tim->CCR4 = 0; /* Comparator 4 disabled. */ pwmp->pd_tim->BDTR = 0; pwmp->pd_tim->DIER = 0; pwmp->pd_tim->SR = 0; pwmp->pd_tim->EGR = TIM_EGR_UG; /* Update event. */ #if USE_STM32_PWM1 if (&PWMD1 == pwmp) { NVICDisableVector(TIM1_UP_IRQn); NVICDisableVector(TIM1_CC_IRQn); RCC->APB2ENR &= ~RCC_APB2ENR_TIM1EN; } #endif #if USE_STM32_PWM2 if (&PWMD2 == pwmp) { NVICDisableVector(TIM2_IRQn); RCC->APB1ENR &= ~RCC_APB1ENR_TIM2EN; } #endif #if USE_STM32_PWM3 if (&PWMD3 == pwmp) { NVICDisableVector(TIM3_IRQn); RCC->APB1ENR &= ~RCC_APB1ENR_TIM3EN; } #endif #if USE_STM32_PWM4 if (&PWMD4 == pwmp) { NVICDisableVector(TIM4_IRQn); RCC->APB1ENR &= ~RCC_APB1ENR_TIM4EN; } #endif } }
/** * @brief Low level serial driver stop. * @details De-initializes the UART, stops the associated clock, resets the * interrupt vector. * * @param[in] sdp pointer to a @p SerialDriver object */ void sd_lld_stop(SerialDriver *sdp) { if (sdp->state == SD_READY) { uart_deinit(sdp->uart); #if USE_LPC13xx_UART0 if (&SD1 == sdp) { LPC_SYSCON->SYSAHBCLKCTRL &= ~(1 << 12); NVICDisableVector(UART_IRQn); return; } #endif } }
/** * @brief Deactivates the SDC peripheral. * * @param[in] sdcp pointer to the @p SDCDriver object * * @notapi */ void sdc_lld_stop(SDCDriver *sdcp) { if ((sdcp->state == SDC_READY) || (sdcp->state == SDC_ACTIVE)) { SDIO->POWER = 0; SDIO->CLKCR = 0; SDIO->DCTRL = 0; SDIO->DTIMER = 0; /* Clock deactivation.*/ NVICDisableVector(SDIO_IRQn); dmaStreamRelease(STM32_DMA2_STREAM4); rccDisableSDIO(FALSE); } }
/** * @brief Deactivates the SPI peripheral. * * @param[in] spip pointer to the @p SPIDriver object * * @notapi */ void spi_lld_stop(SPIDriver *spip) { if (spip->spd_state != SPI_STOP) { spip->spd_ssp->CR1 = 0; spip->spd_ssp->CR0 = 0; spip->spd_ssp->CPSR = 0; #if LPC11xx_SPI_USE_SSP0 if (&SPID1 == spip) { LPC_SYSCON->PRESETCTRL &= ~1; LPC_SYSCON->SYSAHBCLKCTRL &= ~(1 << 11); LPC_SYSCON->SSP0CLKDIV = 0; NVICDisableVector(SSP0_IRQn); } #endif #if LPC11xx_SPI_USE_SSP1 if (&SPID2 == spip) { LPC_SYSCON->PRESETCTRL &= ~4; LPC_SYSCON->SYSAHBCLKCTRL &= ~(1 << 18); LPC_SYSCON->SSP1CLKDIV = 0; NVICDisableVector(SSP1_IRQn); } #endif } }
/** * @brief Releases a DMA stream. * @details The stream is freed and, if required, the DMA clock disabled. * Trying to release a unallocated stream is an illegal operation * and is trapped if assertions are enabled. * @pre The stream must have been allocated using @p dmaStreamAllocate(). * @post The stream is again available. * @note This function can be invoked in both ISR or thread context. * * @param[in] dmastp pointer to a stm32_dma_stream_t structure * * @special */ void dmaStreamRelease(const stm32_dma_stream_t *dmastp) { chDbgCheck(dmastp != NULL, "dmaRelease"); /* Check if the streams is not taken.*/ chDbgAssert((dma_streams_mask & (1 << dmastp->selfindex)) != 0, "dmaRelease(), #1", "not allocated"); /* Disables the associated IRQ vector.*/ NVICDisableVector(dmastp->vector); /* Marks the stream as not allocated.*/ dma_streams_mask &= ~(1 << dmastp->selfindex); /* Shutting down clocks that are no more required, if any.*/ if ((dma_streams_mask & STM32_DMA1_STREAMS_MASK) == 0) rccDisableDMA1(FALSE); #if STM32_HAS_DMA2 if ((dma_streams_mask & STM32_DMA2_STREAMS_MASK) == 0) rccDisableDMA2(FALSE); #endif }