/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * *

© Copyright (c) 2022 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license * SLA0044, the "License"; You may not use this file except in compliance with * the License. You may obtain a copy of the License at: * www.st.com/SLA0044 * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "tim.h" #include "my.h" #include "stm32f7xx_hal.h" #include "adc.h" #include "dma.h" #include "dma2d.h" #include "ltdc.h" #include "spi.h" #include "tim.h" #include "gpio.h" #include "arm_math.h" #include "usart.h" #include /* Private variables ---------------------------------------------------------*/ extern volatile bool FlagAsk; extern __IO uint16_t timerAsk; extern volatile bool NeedOff; extern volatile bool needDispOn; extern volatile uint8_t menu; extern volatile bool screen; extern volatile bool KeysIsReady; extern volatile bool measuring; extern volatile UserData_TypeDef pardata, pardata_old; volatile bool clbr; extern __IO bool ASK_COMPLETE; extern __IO bool BT_NeedStartMeas, BT_NeedStopMeas; extern __IO uint64_t pWrite, pRead; extern __IO uint32_t SendBuf; extern __IO bool GoSend; extern __IO uint8_t READY; extern __IO uint8_t menupos; extern float32_t FreqFran; extern __IO uint8_t CALC_FREQ; extern __IO uint32_t ACTIVE_CHANNEL; extern __IO uint32_t CNT_CHANNELS; extern uint8_t iobuf[256]; extern uint8_t rx[256]; /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MPU_Config(void); /******************************************************************************/ static void MPU_Config(void) { MPU_Region_InitTypeDef MPU_InitStruct; HAL_MPU_Disable(); HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); } void DisableWakeUpPins(void) { } extern __IO bool needSend; const char _VERSION[] = "VER 2.203.0\0"; volatile char _SERIAL_DRAW[10] = {'S', 'N', ' ', '2', '3', '0', '0', '1', 0, 0}; int main(void) { uint32_t cnt = 0, i, j, k, l; float32_t f; char str[50]; uint32_t keys = 0; HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); initFlash(); MX_DMA2D_Init(); MX_TIM7_Init(); MX_LTDC_Init(); initKeys(); /////////////////////////////// todo CNT_CHANNELS = 4; ACTIVE_CHANNEL = Ch1; menupos = Hp; for(i = 0; i < 16; i++) { pardata.amplif[i].IIN = CHARGE; pardata.amplif[i].IFV = Hp0_2; pardata.amplif[i].IFN = Lp100000; pardata.amplif[i].IKU = Ku1000; pardata.amplif[i].IKS = 0; pardata.amplif[i].IKD = 0; pardata.amplif[i].IKE = 1; pardata.amplif[i].IPZ = 0; pardata.amplif[i].OPZ = 0; pardata.amplif[i].VAL = Accel; pardata.amplif[i].KCOND = 1.00f; pardata.amplif[i].SENS = 10.00f; pardata.amplif[i].ACCEL = 100.00f; } pardata.OWN = 18; pardata.BAUD = 7; pardata.INFB = 0; //pardata.LANG = RUS; ///////////////////////////// MX_UART7_Init(); EXTI_Config(); Logo(); while(HAL_GPIO_ReadPin(OFF_GPIO_Port, OFF_Pin) == GPIO_PIN_SET) { RedrawScreen(); } KeysIsReady = true; for(k = 0; k < 30; k++) { keys = kbhit(); if((keys == KEY_UP) || (keys == (KEY_UP + KEY_OK))) { clbr = true; break; } } HAL_Delay(1000); AskChannels(); //menu = MAIN; //todo timerAsk = msec1900; FlagAsk = 0; while(1) { RedrawScreen(); keyIns(); if(FlagAsk) { FlagAsk = 0; AskPeriodic(); } } } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3); RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.LSEState = RCC_LSE_BYPASS; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; RCC_OscInitStruct.PLL.PLLM = 16; RCC_OscInitStruct.PLL.PLLN = 432; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV8; RCC_OscInitStruct.PLL.PLLQ = 9; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) { Error_Handler(); } PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC |RCC_PERIPHCLK_UART7; PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; PeriphClkInitStruct.PLLSAI.PLLSAIR = 4; PeriphClkInitStruct.PLLSAI.PLLSAIQ = 2; PeriphClkInitStruct.PLLSAI.PLLSAIP = RCC_PLLSAIP_DIV4; PeriphClkInitStruct.PLLSAIDivQ = 1; PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2; PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; PeriphClkInitStruct.Uart7ClockSelection = RCC_UART7CLKSOURCE_PCLK1; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); } /* __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); /////// 216 MHZ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.LSEState = RCC_LSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = 25; RCC_OscInitStruct.PLL.PLLN = 432; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 9; if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } if(HAL_PWREx_EnableOverDrive() != HAL_OK) { Error_Handler(); } RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6) != HAL_OK) { Error_Handler(); } PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC|RCC_PERIPHCLK_RTC |RCC_PERIPHCLK_UART7|RCC_PERIPHCLK_I2C1 |RCC_PERIPHCLK_SDMMC1|RCC_PERIPHCLK_CLK48; PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; PeriphClkInitStruct.PLLSAI.PLLSAIR = 4; PeriphClkInitStruct.PLLSAI.PLLSAIQ = 2; PeriphClkInitStruct.PLLSAI.PLLSAIP = RCC_PLLSAIP_DIV4; PeriphClkInitStruct.PLLSAIDivQ = 1; PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2; PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; PeriphClkInitStruct.Uart7ClockSelection = RCC_UART7CLKSOURCE_PCLK1; PeriphClkInitStruct.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1; PeriphClkInitStruct.Clk48ClockSelection = RCC_CLK48SOURCE_PLL; PeriphClkInitStruct.Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_CLK48; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); }*/ } /* USER CODE BEGIN 4 */ /* USER CODE END 4 */ /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) { } /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/