]> mj.ucw.cz Git - home-hw.git/blobdiff - ssr/Src/main.c
SSR: Re-generated code
[home-hw.git] / ssr / Src / main.c
index e934fa9ce2ffd911f87a278c2e714fa4e340f977..5601e5cc70ee7a51b8be36beacdcc285f83b45ac 100644 (file)
@@ -62,10 +62,9 @@ struct usb usb;
 /* Private function prototypes -----------------------------------------------*/
 void SystemClock_Config(void);
 static void MX_GPIO_Init(void);
-static void MX_I2C1_Init(void);
-static void MX_I2C2_Init(void);
 static void MX_USB_PCD_Init(void);
 static void MX_TIM4_Init(void);
+static void MX_USART1_UART_Init(void);
 
 /* USER CODE BEGIN PFP */
 /* Private function prototypes -----------------------------------------------*/
@@ -118,10 +117,9 @@ int main(void)
   LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_13);
   LL_mDelay(1000);
 
-  MX_I2C1_Init();
-  MX_I2C2_Init();
   MX_USB_PCD_Init();
   MX_TIM4_Init();
+  MX_USART1_UART_Init();
   /* USER CODE BEGIN 2 */
   display_init();
   usb_start(&usb);
@@ -232,92 +230,6 @@ void SystemClock_Config(void)
   NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
 }
 
-/* I2C1 init function */
-static void MX_I2C1_Init(void)
-{
-
-  LL_I2C_InitTypeDef I2C_InitStruct;
-
-  LL_GPIO_InitTypeDef GPIO_InitStruct;
-
-  /**I2C1 GPIO Configuration  
-  PB6   ------> I2C1_SCL
-  PB7   ------> I2C1_SDA 
-  */
-  GPIO_InitStruct.Pin = LL_GPIO_PIN_6|LL_GPIO_PIN_7;
-  GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
-  GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
-  GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
-  LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-
-  /* Peripheral clock enable */
-  LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_I2C1);
-
-  /* I2C1 interrupt Init */
-  NVIC_SetPriority(I2C1_EV_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
-  NVIC_EnableIRQ(I2C1_EV_IRQn);
-
-    /**I2C Initialization 
-    */
-  I2C_InitStruct.PeripheralMode = LL_I2C_MODE_I2C;
-  I2C_InitStruct.ClockSpeed = 400000;
-  I2C_InitStruct.DutyCycle = LL_I2C_DUTYCYCLE_2;
-  I2C_InitStruct.OwnAddress1 = 0;
-  I2C_InitStruct.TypeAcknowledge = LL_I2C_ACK;
-  I2C_InitStruct.OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT;
-  LL_I2C_Init(I2C1, &I2C_InitStruct);
-
-  LL_I2C_SetOwnAddress2(I2C1, 0);
-
-  LL_I2C_DisableOwnAddress2(I2C1);
-
-  LL_I2C_DisableGeneralCall(I2C1);
-
-  LL_I2C_EnableClockStretching(I2C1);
-
-}
-
-/* I2C2 init function */
-static void MX_I2C2_Init(void)
-{
-
-  LL_I2C_InitTypeDef I2C_InitStruct;
-
-  LL_GPIO_InitTypeDef GPIO_InitStruct;
-
-  /**I2C2 GPIO Configuration  
-  PB10   ------> I2C2_SCL
-  PB11   ------> I2C2_SDA 
-  */
-  GPIO_InitStruct.Pin = LL_GPIO_PIN_10|LL_GPIO_PIN_11;
-  GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
-  GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
-  GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
-  LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-
-  /* Peripheral clock enable */
-  LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_I2C2);
-
-    /**I2C Initialization 
-    */
-  I2C_InitStruct.PeripheralMode = LL_I2C_MODE_I2C;
-  I2C_InitStruct.ClockSpeed = 400000;
-  I2C_InitStruct.DutyCycle = LL_I2C_DUTYCYCLE_2;
-  I2C_InitStruct.OwnAddress1 = 0;
-  I2C_InitStruct.TypeAcknowledge = LL_I2C_ACK;
-  I2C_InitStruct.OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT;
-  LL_I2C_Init(I2C2, &I2C_InitStruct);
-
-  LL_I2C_SetOwnAddress2(I2C2, 0);
-
-  LL_I2C_DisableOwnAddress2(I2C2);
-
-  LL_I2C_DisableGeneralCall(I2C2);
-
-  LL_I2C_EnableClockStretching(I2C2);
-
-}
-
 /* TIM4 init function */
 static void MX_TIM4_Init(void)
 {
@@ -357,6 +269,45 @@ static void MX_TIM4_Init(void)
 
 }
 
+/* USART1 init function */
+static void MX_USART1_UART_Init(void)
+{
+
+  LL_USART_InitTypeDef USART_InitStruct;
+
+  LL_GPIO_InitTypeDef GPIO_InitStruct;
+
+  /* Peripheral clock enable */
+  LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1);
+  
+  /**USART1 GPIO Configuration  
+  PA9   ------> USART1_TX
+  PA10   ------> USART1_RX 
+  */
+  GPIO_InitStruct.Pin = LL_GPIO_PIN_9;
+  GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
+  GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
+  GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
+  LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+  GPIO_InitStruct.Pin = LL_GPIO_PIN_10;
+  GPIO_InitStruct.Mode = LL_GPIO_MODE_FLOATING;
+  LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+  USART_InitStruct.BaudRate = 115200;
+  USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
+  USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
+  USART_InitStruct.Parity = LL_USART_PARITY_NONE;
+  USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX;
+  USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE;
+  LL_USART_Init(USART1, &USART_InitStruct);
+
+  LL_USART_ConfigAsyncMode(USART1);
+
+  LL_USART_Enable(USART1);
+
+}
+
 /* USB init function */
 static void MX_USB_PCD_Init(void)
 {
@@ -396,6 +347,9 @@ static void MX_GPIO_Init(void)
   /**/
   LL_GPIO_ResetOutputPin(LED_GPIO_Port, LED_Pin);
 
+  /**/
+  LL_GPIO_ResetOutputPin(GPIOB, SSR3_Pin|SSR4_Pin|SSR1_Pin|SSR2_Pin);
+
   /**/
   GPIO_InitStruct.Pin = LED_Pin;
   GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
@@ -404,9 +358,11 @@ static void MX_GPIO_Init(void)
   LL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct);
 
   /**/
-  GPIO_InitStruct.Pin = BMP_DONE_Pin;
-  GPIO_InitStruct.Mode = LL_GPIO_MODE_FLOATING;
-  LL_GPIO_Init(BMP_DONE_GPIO_Port, &GPIO_InitStruct);
+  GPIO_InitStruct.Pin = SSR3_Pin|SSR4_Pin|SSR1_Pin|SSR2_Pin;
+  GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
+  GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
+  GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
+  LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 
 }