1 | #include "stm32f7xx.h"
|
2 | #include "stm32f7xx_hal_def.h"
|
3 | #include "../Utilities/STM32746G-Discovery/stm32746g_discovery.h"
|
4 |
|
5 | static void SystemClock_Config(void);
|
6 | static void MX_GPIO_Init(void);
|
7 | void Error_Handler(void);
|
8 |
|
9 | int main(void)
|
10 | {
|
11 |
|
12 | HAL_Init();
|
13 | //NVIC_SetPriority(SysTick_IRQn, -1);
|
14 |
|
15 | /* Configure the system clock to 216 MHz */
|
16 | SystemClock_Config();
|
17 |
|
18 | MX_GPIO_Init();
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | while (1)
|
24 | {
|
25 | HAL_Delay(5);
|
26 | HAL_Delay(500);
|
27 | //HAL_GPIO_TogglePin( GPIOI , GPIO_PIN_8);
|
28 | HAL_GPIO_TogglePin( GPIOA , GPIO_PIN_7);
|
29 | }
|
30 | }
|
31 |
|
32 | static void SystemClock_Config(void)
|
33 | {
|
34 | RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
35 | RCC_OscInitTypeDef RCC_OscInitStruct;
|
36 |
|
37 | /* Enable Power Control clock */
|
38 | __HAL_RCC_PWR_CLK_ENABLE();
|
39 |
|
40 | /* The voltage scaling allows optimizing the power consumption when the device is
|
41 | clocked below the maximum system frequency, to update the voltage scaling value
|
42 | regarding system frequency refer to product datasheet. */
|
43 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
44 |
|
45 | /*##-1- System Clock Configuration #########################################*/
|
46 | /* Enable HSE Oscillator and activate PLL with HSE as source */
|
47 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
48 | RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
49 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
50 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
51 | RCC_OscInitStruct.PLL.PLLM = 25;
|
52 | RCC_OscInitStruct.PLL.PLLN = 400;
|
53 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
54 | RCC_OscInitStruct.PLL.PLLQ = 8;
|
55 | HAL_RCC_OscConfig(&RCC_OscInitStruct);
|
56 |
|
57 | /* Activate the Over-Drive mode */
|
58 | HAL_PWREx_EnableOverDrive();
|
59 |
|
60 | /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
|
61 | clocks dividers */
|
62 | RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
|
63 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
64 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
65 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
66 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
|
67 | HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6);
|
68 |
|
69 | }
|
70 |
|
71 | static void MX_GPIO_Init(void)
|
72 | {
|
73 | GPIO_InitTypeDef GPIO_InitStruct = {0};
|
74 |
|
75 | /* GPIO Ports Clock Enable */
|
76 | //__HAL_RCC_GPIOB_CLK_ENABLE();
|
77 | __HAL_RCC_GPIOI_CLK_ENABLE();
|
78 | __HAL_RCC_GPIOA_CLK_ENABLE();
|
79 |
|
80 | /*Configure GPIO pin : PI13 */
|
81 | GPIO_InitStruct.Pin = GPIO_PIN_13;
|
82 | GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
83 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
84 | HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
|
85 |
|
86 | GPIO_InitStruct.Pin = GPIO_PIN_7;
|
87 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
88 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
89 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
90 |
|
91 | GPIO_InitStruct.Pin = GPIO_PIN_8;
|
92 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
93 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
94 | HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
|
95 |
|
96 | /* EXTI interrupt init*/
|
97 | HAL_NVIC_SetPriority(EXTI15_10_IRQn, 5, 0);
|
98 | HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
|
99 | //NVIC_SetPriority(SysTick_IRQn, -1);
|
100 |
|
101 | }
|
102 |
|
103 | /* USER CODE BEGIN 4 */
|
104 | void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
105 | {
|
106 | //HAL_GPIO_TogglePin( GPIOI , GPIO_PIN_8);
|
107 | //HAL_GPIO_TogglePin( GPIOA , GPIO_PIN_7);
|
108 | /*
|
109 | if(GPIO_Pin == GPIO_PIN_13)
|
110 | {
|
111 | }
|
112 | */
|
113 | //__NOP();
|
114 | }
|
115 | /* USER CODE END 4 */
|
116 | void Error_Handler(void)
|
117 | {
|
118 | /* USER CODE BEGIN Error_Handler_Debug */
|
119 | /* User can add his own implementation to report the HAL error return state */
|
120 | /* USER CODE END Error_Handler_Debug */
|
121 | }
|