fork download
  1. /**
  2.   ******************************************************************************
  3.   * @file GPIO/GPIO_IOToggle/Src/main.c
  4.   * @author MCD Application Team
  5.   * @version V1.0.1
  6.   * @date 22-April-2016
  7.   * @brief This example describes how to configure and use GPIOs through
  8.   * the STM32F7xx HAL API.
  9.   ******************************************************************************
  10.   * @attention
  11.   *
  12.   * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
  13.   *
  14.   * Redistribution and use in source and binary forms, with or without modification,
  15.   * are permitted provided that the following conditions are met:
  16.   * 1. Redistributions of source code must retain the above copyright notice,
  17.   * this list of conditions and the following disclaimer.
  18.   * 2. Redistributions in binary form must reproduce the above copyright notice,
  19.   * this list of conditions and the following disclaimer in the documentation
  20.   * and/or other materials provided with the distribution.
  21.   * 3. Neither the name of STMicroelectronics nor the names of its contributors
  22.   * may be used to endorse or promote products derived from this software
  23.   * without specific prior written permission.
  24.   *
  25.   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26.   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27.   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  28.   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  29.   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30.   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  31.   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  32.   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  33.   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34.   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35.   *
  36.   ******************************************************************************
  37.   */
  38.  
  39. /* Includes ------------------------------------------------------------------*/
  40. #include "main.h"
  41.  
  42. /** @addtogroup STM32F7xx_HAL_Examples
  43.   * @{
  44.   */
  45.  
  46. /** @addtogroup GPIO_IOToggle
  47.   * @{
  48.   */
  49.  
  50. /* Private typedef -----------------------------------------------------------*/
  51. /* Private define ------------------------------------------------------------*/
  52. /* Private macro -------------------------------------------------------------*/
  53. /* Private variables ---------------------------------------------------------*/
  54. static GPIO_InitTypeDef GPIO_InitStruct;
  55.  
  56. /* Private function prototypes -----------------------------------------------*/
  57. static void SystemClock_Config(void);
  58. static void CPU_CACHE_Enable(void);
  59.  
  60. /* Private functions ---------------------------------------------------------*/
  61.  
  62. /**
  63.   * @brief Main program
  64.   * @param None
  65.   * @retval None
  66.   */
  67. int main(void)
  68. {
  69. /* Enable the CPU Cache */
  70. CPU_CACHE_Enable();
  71.  
  72. /* This sample code shows how to use GPIO HAL API to toggle GPIOA-GPIO_PIN_5 IO
  73.   in an infinite loop. It is possible to connect a LED between GPIOA-GPIO_PIN_5
  74.   output and ground via a 330ohm resistor to see this external LED blink.
  75.   Otherwise an oscilloscope can be used to see the output GPIO signal */
  76.  
  77. /* STM32F7xx HAL library initialization:
  78.   - Configure the Flash ART accelerator
  79.   - Systick timer is configured by default as source of time base, but user
  80.   can eventually implement his proper time base source (a general purpose
  81.   timer for example or other time source), keeping in mind that Time base
  82.   duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
  83.   handled in milliseconds basis.
  84.   - Set NVIC Group Priority to 4
  85.   - Low Level Initialization
  86.   */
  87. HAL_Init();
  88.  
  89. /* Configure the system clock to 216 MHz */
  90. SystemClock_Config();
  91.  
  92. /* -1- Enable GPIO Clock (to be able to program the configuration registers) */
  93. __HAL_RCC_GPIOB_CLK_ENABLE();
  94.  
  95. /* -2- Configure IO in output push-pull mode to drive external LEDs */
  96. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  97. GPIO_InitStruct.Pull = GPIO_PULLUP;
  98. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  99.  
  100. GPIO_InitStruct.Pin = GPIO_PIN_0;
  101. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  102.  
  103. /* -3- Toggle IO in an infinite loop */
  104. while (1)
  105. {
  106. HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
  107. /* Insert delay 100 ms */
  108. HAL_Delay(100);
  109. }
  110. }
  111.  
  112. /**
  113.   * @brief System Clock Configuration
  114.   * The system Clock is configured as follow :
  115.   * System Clock source = PLL (HSE)
  116.   * SYSCLK(Hz) = 216000000
  117.   * HCLK(Hz) = 216000000
  118.   * AHB Prescaler = 1
  119.   * APB1 Prescaler = 4
  120.   * APB2 Prescaler = 2
  121.   * HSE Frequency(Hz) = 8000000
  122.   * PLL_M = 8
  123.   * PLL_N = 432
  124.   * PLL_P = 2
  125.   * PLL_Q = 7
  126.   * VDD(V) = 3.3
  127.   * Main regulator output voltage = Scale1 mode
  128.   * Flash Latency(WS) = 7
  129.   * @param None
  130.   * @retval None
  131.   */
  132. static void SystemClock_Config(void)
  133. {
  134. RCC_ClkInitTypeDef RCC_ClkInitStruct;
  135. RCC_OscInitTypeDef RCC_OscInitStruct;
  136. HAL_StatusTypeDef ret = HAL_OK;
  137.  
  138. /* Enable HSE Oscillator and activate PLL with HSE as source */
  139. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  140. RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
  141. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  142. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  143. RCC_OscInitStruct.PLL.PLLM = 8;
  144. RCC_OscInitStruct.PLL.PLLN = 432;
  145. RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  146. RCC_OscInitStruct.PLL.PLLQ = 7;
  147. ret = HAL_RCC_OscConfig(&RCC_OscInitStruct);
  148.  
  149. if(ret != HAL_OK)
  150. {
  151. while(1) {};
  152. }
  153.  
  154. /* Activate the OverDrive to reach the 216 MHz Frequency */
  155. ret = HAL_PWREx_EnableOverDrive();
  156. if(ret != HAL_OK)
  157. {
  158. while(1) {};
  159. }
  160.  
  161. /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
  162.   clocks dividers */
  163. RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
  164. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  165. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  166. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
  167. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
  168. ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);
  169. if(ret != HAL_OK)
  170. {
  171. while(1) {};
  172. }
  173. }
  174.  
  175. /**
  176.   * @brief CPU L1-Cache enable.
  177.   * @param None
  178.   * @retval None
  179.   */
  180. static void CPU_CACHE_Enable(void)
  181. {
  182. /* Enable I-Cache */
  183. SCB_EnableICache();
  184.  
  185. /* Enable D-Cache */
  186. SCB_EnableDCache();
  187. }
  188.  
  189. #ifdef USE_FULL_ASSERT
  190. /**
  191.   * @brief Reports the name of the source file and the source line number
  192.   * where the assert_param error has occurred.
  193.   * @param file: pointer to the source file name
  194.   * @param line: assert_param error line source number
  195.   * @retval None
  196.   */
  197. void assert_failed(uint8_t *file, uint32_t line)
  198. {
  199. /* User can add his own implementation to report the file name and line number,
  200.   ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  201.  
  202. /* Infinite loop */
  203. while (1)
  204. {
  205. }
  206. }
  207. #endif
  208.  
  209. /**
  210.   * @}
  211.   */
  212.  
  213. /**
  214.   * @}
  215.   */
  216.  
  217. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
  218.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:40:18: fatal error: main.h: No such file or directory
compilation terminated.
stdout
Standard output is empty