|
@@ -1,12 +1,4 @@
|
|
|
#include "board.h"
|
|
|
-#include "stm32g0xx_ll_rcc.h"
|
|
|
-#include "stm32g0xx_ll_bus.h"
|
|
|
-#include "stm32g0xx_ll_gpio.h"
|
|
|
-#include "stm32g0xx_ll_usart.h"
|
|
|
-#include "stm32g0xx_ll_dma.h"
|
|
|
-#include "stm32g0xx_ll_dmamux.h"
|
|
|
-#include "stm32g0xx_ll_i2c.h"
|
|
|
-#include "stm32g0xx_ll_spi.h"
|
|
|
|
|
|
/* private variables */
|
|
|
|
|
@@ -25,8 +17,11 @@ static void USART1_UART_Init(void);
|
|
|
/* Board perephireal Configuration */
|
|
|
void Board_Init(void)
|
|
|
{
|
|
|
- RCC->APBENR2 |= RCC_APBENR2_SYSCFGEN;
|
|
|
- RCC->APBENR1 |= RCC_APBENR1_PWREN;
|
|
|
+ /* Main peripheral clock enable */
|
|
|
+ RCC->APBENR1 = (RCC_APBENR1_PWREN | RCC_APBENR1_I2C1EN | RCC_APBENR1_TIM3EN);
|
|
|
+ RCC->APBENR2 = (RCC_APBENR2_SYSCFGEN | RCC_APBENR2_SPI1EN | RCC_APBENR2_TIM1EN);
|
|
|
+ /* GPIO Ports Clock Enable */
|
|
|
+ RCC->IOPENR = (RCC_IOPENR_GPIOAEN | RCC_IOPENR_GPIOBEN | RCC_IOPENR_GPIOCEN);
|
|
|
|
|
|
/* Peripheral interrupt init*/
|
|
|
/* RCC_IRQn interrupt configuration */
|
|
@@ -56,7 +51,7 @@ void Board_Init(void)
|
|
|
//TIM16_Init();
|
|
|
//TIM17_Init();
|
|
|
|
|
|
- USART1_UART_Init();
|
|
|
+ //USART1_UART_Init();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -110,9 +105,6 @@ void SystemClock_Config(void)
|
|
|
*/
|
|
|
static void GPIO_Init(void)
|
|
|
{
|
|
|
- /* GPIO Ports Clock Enable */
|
|
|
- RCC->IOPENR |= (RCC_IOPENR_GPIOAEN | RCC_IOPENR_GPIOBEN | RCC_IOPENR_GPIOCEN);
|
|
|
-
|
|
|
/* EXTI Line: falling, no pull, input */
|
|
|
// mode
|
|
|
EXTI->EMR1 &= ~(EXTI_IMR1_IM14);
|
|
@@ -172,10 +164,10 @@ static void GPIO_Init(void)
|
|
|
*/
|
|
|
static void DMA_Init(void)
|
|
|
{
|
|
|
-
|
|
|
- /* Init with LL driver */
|
|
|
/* DMA controller clock enable */
|
|
|
- RCC->AHBSMENR |= RCC_AHBENR_DMA1EN;
|
|
|
+ RCC->AHBENR |= RCC_AHBENR_DMA1EN;
|
|
|
+ /* enable DMA1 clock in Sleep/Stop mode */
|
|
|
+ //RCC->AHBSMENR |= RCC_AHBSMENR_DMA1SMEN;
|
|
|
|
|
|
/* DMA interrupt init */
|
|
|
/* DMA1_Channel1_IRQn interrupt configuration */
|
|
@@ -194,10 +186,6 @@ static void DMA_Init(void)
|
|
|
*/
|
|
|
static void I2C1_Init(void)
|
|
|
{
|
|
|
- /* Peripheral clock enable */
|
|
|
- RCC->APBENR1 |= RCC_APBENR1_I2C1EN;
|
|
|
- RCC->IOPENR |= RCC_IOPENR_GPIOBEN;
|
|
|
-
|
|
|
/** I2C1 GPIO Configuration
|
|
|
PB8 ------> I2C1_SCL
|
|
|
PB9 ------> I2C1_SDA
|
|
@@ -240,10 +228,6 @@ static void I2C1_Init(void)
|
|
|
*/
|
|
|
static void SPI1_Init(void)
|
|
|
{
|
|
|
- /* Peripheral clock enable */
|
|
|
- RCC->APBENR2 |= RCC_APBENR2_SPI1EN;
|
|
|
- RCC->IOPENR |= RCC_IOPENR_GPIOBEN;
|
|
|
-
|
|
|
/**SPI1 GPIO Configuration
|
|
|
PB3 ------> SPI1_SCK
|
|
|
PB5 ------> SPI1_MOSI
|
|
@@ -280,12 +264,7 @@ static void SPI1_Init(void)
|
|
|
*/
|
|
|
static void TIM1_Init(void)
|
|
|
{
|
|
|
- /* Peripheral clock TIM1 enable */
|
|
|
- RCC->APBENR2 |= RCC_APBENR2_TIM1EN;
|
|
|
- /* Peripheral clock GPIOA enable */
|
|
|
- RCC->IOPENR |= RCC_IOPENR_GPIOAEN;
|
|
|
-
|
|
|
- /* target clock - 200 Hz */
|
|
|
+ /* target clock */
|
|
|
TIM1->PSC = TIM1_PSC; // prescaler
|
|
|
TIM1->ARR = TIM1_ARR; // auto reload value
|
|
|
TIM1->CR1 = TIM_CR1_ARPE;
|
|
@@ -341,12 +320,7 @@ static void TIM1_Init(void)
|
|
|
*/
|
|
|
static void TIM3_Init(void)
|
|
|
{
|
|
|
- /* Peripheral clock TIM1 enable */
|
|
|
- RCC->APBENR1 |= RCC_APBENR1_TIM3EN;
|
|
|
- /* Peripheral clock GPIOA and GPIOB enable */
|
|
|
- RCC->IOPENR |= (RCC_IOPENR_GPIOAEN | RCC_IOPENR_GPIOBEN);
|
|
|
-
|
|
|
- /* target clock - 200 Hz */
|
|
|
+ /* target clock */
|
|
|
TIM3->PSC = TIM3_PSC; // prescaler
|
|
|
TIM3->ARR = TIM3_ARR; // auto reload value
|
|
|
TIM3->CR1 = TIM_CR1_ARPE;
|
|
@@ -531,7 +505,6 @@ static void USART1_UART_Init(void)
|
|
|
{
|
|
|
/* Peripheral clock enable */
|
|
|
RCC->APBENR2 |= RCC_APBENR2_USART1EN;
|
|
|
- RCC->IOPENR |= RCC_IOPENR_GPIOBEN;
|
|
|
|
|
|
/**USART1 GPIO Configuration
|
|
|
PB6 ------> USART1_TX
|