/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * Copyright (c) 2023 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD */ /* USER CODE END PTD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ #define SIZE 1024*32 /* USER CODE END PD */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ /* USER CODE END PM */ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ GPIO_PinState pinstate; UART_HandleTypeDef uart = {0}; volatile unsigned int abstime_ms = 0; volatile unsigned int zakasnitev = 500; volatile uint8_t sporocilo[10]; extern volatile uint8_t sprejeto; uint8_t buffer[] = "LED 1 ON"; uint8_t izvor[SIZE]; uint8_t ponor[SIZE]; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); /* USER CODE BEGIN PFP */ void myDelay(unsigned int zakasnitev); void start_timer(); void stop_timer(); uint32_t get_time(); /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * @brief The application entry point. * @retval int */ int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ /* USER CODE BEGIN 2 */ __HAL_RCC_GPIOB_CLK_ENABLE(); GPIO_InitTypeDef init_structure; init_structure.Pin = GPIO_PIN_10 | GPIO_PIN_11; init_structure.Mode = GPIO_MODE_AF_PP; init_structure.Pull = GPIO_NOPULL; init_structure.Speed = GPIO_SPEED_FREQ_LOW; init_structure.Alternate = GPIO_AF7_USART3; HAL_GPIO_Init(GPIOB, &init_structure); __HAL_RCC_USART3_CLK_ENABLE(); uart.Instance = USART3; uart.Init.BaudRate = 115200; uart.Init.WordLength = UART_WORDLENGTH_8B; uart.Init.StopBits = UART_STOPBITS_1; uart.Init.Parity = UART_PARITY_NONE; uart.Init.Mode = UART_MODE_TX_RX; uart.Init.HwFlowCtl = UART_HWCONTROL_NONE; HAL_UART_Init(&uart); // Prekini me, ko RDR Not empty: __HAL_UART_ENABLE_IT(&uart, UART_IT_RXNE); // Omogoči prekinitve iz UART3 na NVIC: HAL_NVIC_SetPriority(USART3_IRQn, 12, 0); HAL_NVIC_EnableIRQ(USART3_IRQn); HAL_GPIO_WritePin(GPIOD, GPIO_PIN_3, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOD, GPIO_PIN_3, GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOI, GPIO_PIN_13, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOI, GPIO_PIN_13, GPIO_PIN_SET); pinstate = GPIO_PIN_SET; for(int i=0; i