void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) { if(htim_base->Instance==TIM6) { /* USER CODE BEGIN TIM6_MspInit 0 */ /* USER CODE END TIM6_MspInit 0 */ /* Peripheral clock enable */ __TIM6_CLK_ENABLE(); /* Peripheral interrupt init*/ HAL_NVIC_SetPriority(TIM6_DAC_IRQn, 3, 0); HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn); /* USER CODE BEGIN TIM6_MspInit 1 */ /* USER CODE END TIM6_MspInit 1 */ } else if(htim_base->Instance==TIM7) { /* USER CODE BEGIN TIM7_MspInit 0 */ /* USER CODE END TIM7_MspInit 0 */ /* Peripheral clock enable */ __TIM7_CLK_ENABLE(); /* Peripheral interrupt init*/ HAL_NVIC_SetPriority(TIM7_IRQn, 4, 0); HAL_NVIC_EnableIRQ(TIM7_IRQn); /* USER CODE BEGIN TIM7_MspInit 1 */ /* USER CODE END TIM7_MspInit 1 */ } }
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) { #ifdef USE_SCOPE if(htim_base->Instance==TIM3) { /* USER CODE BEGIN TIM3_MspInit 0 */ /* USER CODE END TIM3_MspInit 0 */ /* Peripheral clock enable */ __TIM3_CLK_ENABLE(); /* USER CODE BEGIN TIM3_MspInit 1 */ /* USER CODE END TIM3_MspInit 1 */ } #endif //USE_SCOPE #ifdef USE_GEN if(htim_base->Instance==TIM6){ __TIM6_CLK_ENABLE(); } if(htim_base->Instance==TIM7){ __TIM7_CLK_ENABLE(); } #endif //USE_GEN }
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) { GPIO_InitTypeDef GPIO_InitStruct; if(htim_base->Instance==TIM3) { /* USER CODE BEGIN TIM3_MspInit 0 */ /* USER CODE END TIM3_MspInit 0 */ /* Peripheral clock enable */ __TIM3_CLK_ENABLE(); /**TIM3 GPIO Configuration PA6 ------> TIM3_CH1 PA7 ------> TIM3_CH2 PB0 ------> TIM3_CH3 PB1 ------> TIM3_CH4 */ GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF2_TIM3; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF2_TIM3; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* USER CODE BEGIN TIM3_MspInit 1 */ /* USER CODE END TIM3_MspInit 1 */ } else if(htim_base->Instance==TIM7) { /* USER CODE BEGIN TIM7_MspInit 0 */ /* USER CODE END TIM7_MspInit 0 */ /* Peripheral clock enable */ __TIM7_CLK_ENABLE(); /* Peripheral interrupt init*/ HAL_NVIC_SetPriority(TIM7_IRQn, 5, 0); HAL_NVIC_EnableIRQ(TIM7_IRQn); /* USER CODE BEGIN TIM7_MspInit 1 */ /* USER CODE END TIM7_MspInit 1 */ } }
/* TIM7 init function - 1 usec timebase 16-bit */ void MX_TIM7_Init(void) { TIM_MasterConfigTypeDef sMasterConfig; /* Peripheral clock enable */ __TIM7_CLK_ENABLE(); /* Peripheral configuration */ htim7.Instance = TIM7; htim7.Init.Prescaler = 48; htim7.Init.CounterMode = TIM_COUNTERMODE_DOWN; htim7.Init.Period = 1; HAL_TIM_Base_Init(&htim7); sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; HAL_TIMEx_MasterConfigSynchronization(&htim7, &sMasterConfig); }
//------------------------------------------------------------------------------------------------------------------------------------------------------ void Hardware_Init(void) { HAL_Init(); SystemClock_Config(); __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOE_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); __DMA1_CLK_ENABLE(); // Для DAC1 (бикалка) __TIM7_CLK_ENABLE(); // Для DAC1 (бикалка) __DAC_CLK_ENABLE(); // Для бикалки __PWR_CLK_ENABLE(); __SYSCFG_CLK_ENABLE(); HAL_NVIC_SetPriority(SysTick_IRQn, PRIORITY_SYS_TICK); // Timer ///////////////////////////////////////////////////////////////// //RCC_PCLK1Config(RCC_HCLK_Div1); // Таймер для мс HAL_NVIC_SetPriority(TIM6_DAC_IRQn, PRIORITY_TIMER_TIM6); HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn); Timer_Init(); Panel_Init(); FSMC_Init(); FSMC_SetMode(ModeFSMC_FPGA); FDrive_Init(); }
void Hardware_Init() { HAL_Init(); SystemClock_Config(); __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOE_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); __DMA1_CLK_ENABLE(); // Для DAC1 (бикалка) __TIM6_CLK_ENABLE(); // Для отсчёта миллисекунд __TIM2_CLK_ENABLE(); // Для тиков __TIM7_CLK_ENABLE(); // Для DAC1 (бикалка) __DAC_CLK_ENABLE(); // Для бикалки __PWR_CLK_ENABLE(); __SYSCFG_CLK_ENABLE(); HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); // Timer ///////////////////////////////////////////////////////////////// //RCC_PCLK1Config(RCC_HCLK_Div1); // Таймер для мс HAL_NVIC_SetPriority(TIM6_DAC_IRQn, 2, 0); HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn); if (HAL_TIM_Base_Init(&handleTIM6forTimer) != HAL_OK) { HARDWARE_ERROR } if (HAL_TIM_Base_Start_IT(&handleTIM6forTimer) != HAL_OK) { HARDWARE_ERROR } // Таймер для тиков TIM_HandleTypeDef tim2handle = { TIM2, { 0, TIM_COUNTERMODE_UP, 0xffffffff, TIM_CLOCKDIVISION_DIV1 } }; if (HAL_TIM_Base_Init(&tim2handle) != HAL_OK) { HARDWARE_ERROR } if (HAL_TIM_Base_Start(&tim2handle) != HAL_OK) { HARDWARE_ERROR } Sound_Init(); #ifdef SPI_ENABLE Panel_Init(); #endif FSMC_Init(); ADC_Init(); FDrive_Init(); // Analog and DAC programmable SPI //////////////////////////////////////// GPIO_InitTypeDef isGPIOG = { GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5 | GPIO_PIN_7, // GPIO_PIN_1 - для работы с дисплеем GPIO_MODE_OUTPUT_PP, GPIO_NOPULL, GPIO_SPEED_HIGH, GPIO_AF0_MCO }; HAL_GPIO_Init(GPIOG, &isGPIOG); isGPIOG.Pin = GPIO_PIN_1; isGPIOG.Mode = GPIO_MODE_OUTPUT_PP; isGPIOG.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOG, &isGPIOG); HAL_GPIO_WritePin(GPIOG, GPIO_PIN_1, GPIO_PIN_RESET); // PG1 - когда равен 1, чтение дисплея, в остальных случаях 0 RTC_Init(); }
//------------------------------------------------------------------------------------------------------------------------------------------------------ void Hardware_Init(void) { HAL_Init(); SystemClock_Config(); #ifndef _MS_VS __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOE_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); __DMA1_CLK_ENABLE(); // Для DAC1 (бикалка) __TIM7_CLK_ENABLE(); // Для DAC1 (бикалка) __DAC_CLK_ENABLE(); // Для бикалки __PWR_CLK_ENABLE(); __SYSCFG_CLK_ENABLE(); #endif HAL_NVIC_SetPriority(SysTick_IRQn, PRIORITY_SYS_TICK); // Timer ///////////////////////////////////////////////////////////////// //RCC_PCLK1Config(RCC_HCLK_Div1); // Таймер для мс HAL_NVIC_SetPriority(TIM6_DAC_IRQn, PRIORITY_TIMER_TIM6); HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn); Timer_Init(); Sound_Init(); Panel_Init(); FSMC_Init(); FSMC_SetMode(ModeFSMC_FPGA); RAM_Init(); FDrive_Init(); // Analog and DAC programmable SPI //////////////////////////////////////// GPIO_InitTypeDef isGPIO = { GPIO_PIN_10 | GPIO_PIN_12, // SPI SCLK, DATA GPIO_MODE_OUTPUT_PP, GPIO_NOPULL, GPIO_SPEED_HIGH, GPIO_AF0_MCO }; HAL_GPIO_Init(GPIOC, &isGPIO); isGPIO.Pin = GPIO_PIN_3 | GPIO_PIN_6; // SPI select1, select2 HAL_GPIO_Init(GPIOD, &isGPIO); isGPIO.Pin = GPIO_PIN_10 | GPIO_PIN_15; // SPI select3, select4 HAL_GPIO_Init(GPIOG, &isGPIO); RTC_Init(); }
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) { if(htim_base->Instance==TIM1) { /* USER CODE BEGIN TIM1_MspInit 0 */ /* USER CODE END TIM1_MspInit 0 */ /* Peripheral clock enable */ __TIM1_CLK_ENABLE(); /* Peripheral interrupt init*/ HAL_NVIC_SetPriority(TIM1_BRK_TIM9_IRQn, 5, 0); HAL_NVIC_EnableIRQ(TIM1_BRK_TIM9_IRQn); HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn, 5, 0); HAL_NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn); HAL_NVIC_SetPriority(TIM1_CC_IRQn, 5, 0); HAL_NVIC_EnableIRQ(TIM1_CC_IRQn); /* USER CODE BEGIN TIM1_MspInit 1 */ /* USER CODE END TIM1_MspInit 1 */ } else if(htim_base->Instance==TIM4) { /* USER CODE BEGIN TIM4_MspInit 0 */ /* USER CODE END TIM4_MspInit 0 */ /* Peripheral clock enable */ __TIM4_CLK_ENABLE(); /* Peripheral interrupt init*/ HAL_NVIC_SetPriority(TIM4_IRQn, 5, 0); HAL_NVIC_EnableIRQ(TIM4_IRQn); /* USER CODE BEGIN TIM4_MspInit 1 */ /* USER CODE END TIM4_MspInit 1 */ } else if(htim_base->Instance==TIM6) { /* USER CODE BEGIN TIM6_MspInit 0 */ /* USER CODE END TIM6_MspInit 0 */ /* Peripheral clock enable */ __TIM6_CLK_ENABLE(); /* Peripheral interrupt init*/ HAL_NVIC_SetPriority(TIM6_DAC_IRQn, 5, 0); HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn); /* USER CODE BEGIN TIM6_MspInit 1 */ /* USER CODE END TIM6_MspInit 1 */ } else if(htim_base->Instance==TIM7) { /* USER CODE BEGIN TIM7_MspInit 0 */ /* USER CODE END TIM7_MspInit 0 */ /* Peripheral clock enable */ __TIM7_CLK_ENABLE(); /* USER CODE BEGIN TIM7_MspInit 1 */ /* USER CODE END TIM7_MspInit 1 */ } else if(htim_base->Instance==TIM9) { /* USER CODE BEGIN TIM9_MspInit 0 */ /* USER CODE END TIM9_MspInit 0 */ /* Peripheral clock enable */ __TIM9_CLK_ENABLE(); /* Peripheral interrupt init*/ HAL_NVIC_SetPriority(TIM1_BRK_TIM9_IRQn, 5, 0); HAL_NVIC_EnableIRQ(TIM1_BRK_TIM9_IRQn); /* USER CODE BEGIN TIM9_MspInit 1 */ /* USER CODE END TIM9_MspInit 1 */ } else if(htim_base->Instance==TIM10) { /* USER CODE BEGIN TIM10_MspInit 0 */ /* USER CODE END TIM10_MspInit 0 */ /* Peripheral clock enable */ __TIM10_CLK_ENABLE(); /* Peripheral interrupt init*/ HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn, 5, 0); HAL_NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn); /* USER CODE BEGIN TIM10_MspInit 1 */ /* USER CODE END TIM10_MspInit 1 */ } else if(htim_base->Instance==TIM11) { /* USER CODE BEGIN TIM11_MspInit 0 */ /* USER CODE END TIM11_MspInit 0 */ /* Peripheral clock enable */ __TIM11_CLK_ENABLE(); /* USER CODE BEGIN TIM11_MspInit 1 */ /* USER CODE END TIM11_MspInit 1 */ } else if(htim_base->Instance==TIM13) { /* USER CODE BEGIN TIM13_MspInit 0 */ /* USER CODE END TIM13_MspInit 0 */ /* Peripheral clock enable */ __TIM13_CLK_ENABLE(); /* Peripheral interrupt init*/ HAL_NVIC_SetPriority(TIM8_UP_TIM13_IRQn, 5, 0); HAL_NVIC_EnableIRQ(TIM8_UP_TIM13_IRQn); /* USER CODE BEGIN TIM13_MspInit 1 */ /* USER CODE END TIM13_MspInit 1 */ } }