Files
StepMotorCtrl/bsp/hardware_init.c
T

50 lines
1.3 KiB
C
Raw Normal View History

#include "hardware_init.h"
#include "py32md530.h"
#include "system_py32md530.h"
#include "config.h"
ret_code_t hardware_init(void)
{
SystemInit();
RCC->AHBENR |= RCC_AHBENR_GPIOAEN
| RCC_AHBENR_GPIOBEN
| RCC_AHBENR_GPIOCEN
| RCC_AHBENR_GPIOFEN;
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN
| RCC_APB2ENR_USART1EN
| RCC_APB2ENR_TIM1EN;
RCC->APB1ENR |= RCC_APB1ENR_UART1EN
| RCC_APB1ENR_LPUART1EN
| RCC_APB1ENR_I2C1EN
| RCC_APB1ENR_TIM3EN
| RCC_APB1ENR_TIM14EN;
RCC->AHBENR |= RCC_AHBENR_DMAEN;
return RET_OK;
}
ret_code_t hardware_deinit(void)
{
RCC->AHBENR &= ~(RCC_AHBENR_GPIOAEN
| RCC_AHBENR_GPIOBEN
| RCC_AHBENR_GPIOCEN
| RCC_AHBENR_GPIOFEN
| RCC_AHBENR_DMAEN);
RCC->APB2ENR &= ~(RCC_APB2ENR_SYSCFGEN
| RCC_APB2ENR_USART1EN
| RCC_APB2ENR_TIM1EN);
RCC->APB1ENR &= ~(RCC_APB1ENR_UART1EN
| RCC_APB1ENR_LPUART1EN
| RCC_APB1ENR_I2C1EN
| RCC_APB1ENR_TIM3EN
| RCC_APB1ENR_TIM14EN);
return RET_OK;
}