/*! \brief reset GPIO port \param[in] gpio_periph: GPIOx(x = A,B,C,F) only one parameter can be selected which is shown as below: \arg GPIOx(x = A,B,C,F) \param[out] none \retval none */ void gpio_deinit(uint32_t gpio_periph) { switch(gpio_periph){ case GPIOA: /* reset GPIOA */ rcu_periph_reset_enable(RCU_GPIOARST); rcu_periph_reset_disable(RCU_GPIOARST); break; case GPIOB: /* reset GPIOB */ rcu_periph_reset_enable(RCU_GPIOBRST); rcu_periph_reset_disable(RCU_GPIOBRST); break; case GPIOC: /* reset GPIOC */ rcu_periph_reset_enable(RCU_GPIOCRST); rcu_periph_reset_disable(RCU_GPIOCRST); break; case GPIOF: /* reset GPIOF */ rcu_periph_reset_enable(RCU_GPIOFRST); rcu_periph_reset_disable(RCU_GPIOFRST); break; default: break; } }
/*! \brief reset USART \param[in] usart_periph: USARTx(x=0,1) \param[out] none \retval none */ void usart_deinit(uint32_t usart_periph) { switch(usart_periph){ case USART0: rcu_periph_reset_enable(RCU_USART0RST); rcu_periph_reset_disable(RCU_USART0RST); break; case USART1: rcu_periph_reset_enable(RCU_USART1RST); rcu_periph_reset_disable(RCU_USART1RST); break; default: break; } }
/** Reset I2C peripheral by hardware method. Most of the implementation enable RCU reset. * * @param obj The I2C object */ static void i2c_hw_reset(i2c_t *obj) { struct i2c_s *obj_s = I2C_S(obj); switch (obj_s->i2c) { case I2C_0: rcu_periph_reset_enable(RCU_I2C0RST); rcu_periph_reset_disable(RCU_I2C0RST); break; case I2C_1: rcu_periph_reset_enable(RCU_I2C1RST); rcu_periph_reset_disable(RCU_I2C1RST); break; } }
/*! \brief reset I2C \param[in] i2c_periph: I2Cx(x=0,1) \param[out] none \retval none */ void i2c_deinit(uint32_t i2c_periph) { switch (i2c_periph) { case I2C0: /* reset I2C0 */ rcu_periph_reset_enable(RCU_I2C0RST); rcu_periph_reset_disable(RCU_I2C0RST); break; case I2C1: /* reset I2C1 */ rcu_periph_reset_enable(RCU_I2C1RST); rcu_periph_reset_disable(RCU_I2C1RST); break; default: break; } }
/*! \brief deinitialize CAN \param[in] can_periph \arg CANx(x=0,1),the CAN1 only for GD32F30X_CL \param[out] none \retval none */ void can_deinit(uint32_t can_periph) { #ifdef GD32F30X_CL if(CAN0 == can_periph){ rcu_periph_reset_enable(RCU_CAN0RST); rcu_periph_reset_disable(RCU_CAN0RST); }else{ rcu_periph_reset_enable(RCU_CAN1RST); rcu_periph_reset_disable(RCU_CAN1RST); } #else if(CAN0 == can_periph){ rcu_periph_reset_enable(RCU_CAN0RST); rcu_periph_reset_disable(RCU_CAN0RST); } #endif }
/*! \brief reset GPIO port \param[in] port \arg GPIOx(x = A,B,C,D,F) \param[out] none \retval none */ void gpio_deinit(uint32_t port) { if(GPIOA == port){ rcu_periph_reset_enable(RCU_GPIOARST); rcu_periph_reset_disable(RCU_GPIOARST); }else if(GPIOB == port){ rcu_periph_reset_enable(RCU_GPIOBRST); rcu_periph_reset_disable(RCU_GPIOBRST); }else if(GPIOC == port){ rcu_periph_reset_enable(RCU_GPIOCRST); rcu_periph_reset_disable(RCU_GPIOCRST); }else if(GPIOD == port){ rcu_periph_reset_enable(RCU_GPIODRST); rcu_periph_reset_disable(RCU_GPIOCRST); }else if(GPIOF == port){ rcu_periph_reset_enable(RCU_GPIOFRST); rcu_periph_reset_disable(RCU_GPIOFRST); } }
/*! \brief deinitialize SPI and I2S \param[in] spi_periph: SPIx(x=0,1,2,3,4,5),include I2S1_ADD and I2S2_ADD \param[out] none \retval none */ void spi_i2s_deinit(uint32_t spi_periph) { switch (spi_periph) { case SPI0: /* reset SPI0 */ rcu_periph_reset_enable(RCU_SPI0RST); rcu_periph_reset_disable(RCU_SPI0RST); break; case SPI1: /* reset SPI1,I2S1 and I2S1_ADD */ rcu_periph_reset_enable(RCU_SPI1RST); rcu_periph_reset_disable(RCU_SPI1RST); break; case SPI2: /* reset SPI2,I2S2 and I2S2_ADD */ rcu_periph_reset_enable(RCU_SPI2RST); rcu_periph_reset_disable(RCU_SPI2RST); break; case SPI3: /* reset SPI3 */ rcu_periph_reset_enable(RCU_SPI3RST); rcu_periph_reset_disable(RCU_SPI3RST); break; case SPI4: /* reset SPI4 */ rcu_periph_reset_enable(RCU_SPI4RST); rcu_periph_reset_disable(RCU_SPI4RST); break; case SPI5: /* reset SPI5 */ rcu_periph_reset_enable(RCU_SPI5RST); rcu_periph_reset_disable(RCU_SPI5RST); break; default : break; } }
/*! \brief deinit IVREF \param[in] none \param[out] none \retval none */ void ivref_deinit(void) { rcu_periph_reset_enable(RCU_OPAIVREFRST); rcu_periph_reset_disable(RCU_OPAIVREFRST); }
/*! \brief deinitialize DAC \param[in] none \param[out] none \retval none */ void dac_deinit(void) { rcu_periph_reset_enable(RCU_DACRST); rcu_periph_reset_disable(RCU_DACRST); }
/*! \brief deinitialize IPA registers \param[in] none \param[out] none \retval none */ void ipa_deinit(void) { rcu_periph_reset_enable(RCU_IPAENRST); rcu_periph_reset_disable(RCU_IPAENRST); }
/*! \brief deinitialize the SDIO \param[in] none \param[out] none \retval none */ void sdio_deinit(void) { rcu_periph_reset_enable(RCU_SDIORST); rcu_periph_reset_disable(RCU_SDIORST); }
/*! \brief reset the window watchdog timer configuration \param[in] none \param[out] none \retval none */ void wwdgt_deinit(void) { rcu_periph_reset_enable(RCU_WWDGTRST); rcu_periph_reset_disable(RCU_WWDGTRST); }
/*! \brief reset CTC clock trim controller \param[in] none \param[out] none \retval none */ void ctc_deinit(void) { /* reset CTC */ rcu_periph_reset_enable(RCU_CTCRST); rcu_periph_reset_disable(RCU_CTCRST); }