static void prvSetupHardware( void ) { GPIO_InitTypeDef GPIO_InitStruct; /* Configure Flash prefetch and Instruction cache through ART accelerator. */ #if( ART_ACCLERATOR_ENABLE != 0 ) { __HAL_FLASH_ART_ENABLE(); } #endif /* ART_ACCLERATOR_ENABLE */ /* Set Interrupt Group Priority */ HAL_NVIC_SetPriorityGrouping( NVIC_PRIORITYGROUP_4 ); /* Init the low level hardware. */ HAL_MspInit(); /* Configure the System clock to have a frequency of 200 MHz */ prvSystemClockConfig(); /* Enable GPIOB Clock (to be able to program the configuration registers) and configure for LED output. */ __GPIOG_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init( GPIOF, &GPIO_InitStruct ); /* MCO2 : Pin PC9 */ HAL_RCC_MCOConfig( RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_1 ); }
/** * @brief This function is used to initialize the HAL Library; it must be the first * instruction to be executed in the main program (before to call any other * HAL function), it performs the following: * Configure the Flash prefetch, instruction and Data caches. * Configures the SysTick to generate an interrupt each 1 millisecond, * which is clocked by the HSI (at this stage, the clock is not yet * configured and thus the system is running from the internal HSI at 16 MHz). * Set NVIC Group Priority to 4. * Calls the HAL_MspInit() callback function defined in user file * "stm32f4xx_hal_msp.c" to do the global low level hardware initialization * * @note SysTick is used as time base for the HAL_Delay() function, the application * need to ensure that the SysTick time base is always set to 1 millisecond * to have correct HAL operation. * @param None * @retval HAL status */ HAL_StatusTypeDef HAL_Init(void) { /* Configure Flash prefetch, Instruction cache, Data cache */ #if (INSTRUCTION_CACHE_ENABLE != 0) __HAL_FLASH_INSTRUCTION_CACHE_ENABLE(); #endif /* INSTRUCTION_CACHE_ENABLE */ #if (DATA_CACHE_ENABLE != 0) __HAL_FLASH_DATA_CACHE_ENABLE(); #endif /* DATA_CACHE_ENABLE */ #if (PREFETCH_ENABLE != 0) __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); #endif /* PREFETCH_ENABLE */ /* Set Interrupt Group Priority */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */ HAL_InitTick(TICK_INT_PRIORITY); /* Init the low level hardware */ HAL_MspInit(); /* Return function status */ return HAL_OK; }
/** * @brief This function configures the Flash prefetch, Flash preread and Buffer cache, * Configures time base source, NVIC and Low level hardware * @note This function is called at the beginning of program after reset and before * the clock configuration * @note The time base configuration is based on MSI clock when exiting from Reset. * Once done, time base tick start incrementing. * In the default implementation,Systick is used as source of time base. * the tick variable is incremented each 1ms in its ISR. * @retval HAL status */ HAL_StatusTypeDef HAL_Init(void) { /* Configure Buffer cache, Flash prefetch, Flash preread */ #if (BUFFER_CACHE_DISABLE != 0) __HAL_FLASH_BUFFER_CACHE_DISABLE(); #endif /* BUFFER_CACHE_DISABLE */ #if (PREREAD_ENABLE != 0) __HAL_FLASH_PREREAD_BUFFER_ENABLE(); #endif /* PREREAD_ENABLE */ #if (PREFETCH_ENABLE != 0) __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); #endif /* PREFETCH_ENABLE */ /* Use systick as time base source and configure 1ms tick (default clock after Reset is MSI) */ HAL_InitTick(TICK_INT_PRIORITY); /* Init the low level hardware */ HAL_MspInit(); /* Return function status */ return HAL_OK; }
/** * @brief This function configures the Flash prefetch, * Configures time base source, NVIC and Low level hardware * @note This function is called at the beginning of program after reset and before * the clock configuration * @note The time base configuration is based on MSI clock when exiting from Reset. * Once done, time base tick start incrementing. * In the default implementation,Systick is used as source of time base. * The tick variable is incremented each 1ms in its ISR. * @retval HAL status */ HAL_StatusTypeDef HAL_Init(void) { /* Configure Flash prefetch */ #if (PREFETCH_ENABLE != 0) #if defined(STM32F101x6) || defined(STM32F101xB) || defined(STM32F101xE) || defined(STM32F101xG) || \ defined(STM32F102x6) || defined(STM32F102xB) || \ defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || \ defined(STM32F105xC) || defined(STM32F107xC) /* Prefetch buffer is not available on value line devices */ __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); #endif #endif /* PREFETCH_ENABLE */ /* Set Interrupt Group Priority */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); /* Use systick as time base source and configure 1ms tick (default clock after Reset is MSI) */ HAL_InitTick(TICK_INT_PRIORITY); /* Init the low level hardware */ HAL_MspInit(); /* Return function status */ return HAL_OK; }
int main(void) { // Reset of all peripherals, Initializes the Flash interface and the Systick . HAL_Init(); // Configure the system clock . SystemClock_Config(); // Initialize all configured peripherals . MX_GPIO_Init(); MX_UART4_Init(); // Initializes the Global MSP . HAL_MspInit(); HAL_UART_MspInit( &huart4 ); __HAL_UART_ENABLE_IT( &huart4, UART_IT_RXNE); HAL_UART_Receive_IT( &huart4 , string , 154 ); while (1) { HAL_GPIO_WritePin( GPIOD , GPIO_PIN_15 , GPIO_PIN_SET ); delay(5000000); HAL_GPIO_WritePin( GPIOD , GPIO_PIN_15 , GPIO_PIN_RESET ); delay(5000000); } }
/** * @brief This function is used to initialize the HAL Library; it must be the first * instruction to be executed in the main program (before to call any other * HAL function), it performs the following: * Configure the Flash prefetch, and instruction cache through ART accelerator. * Configures the SysTick to generate an interrupt each 1 millisecond, * which is clocked by the HSI (at this stage, the clock is not yet * configured and thus the system is running from the internal HSI at 16 MHz). * Set NVIC Group Priority to 4. * Calls the HAL_MspInit() callback function defined in user file * "stm32f7xx_hal_msp.c" to do the global low level hardware initialization * * @note SysTick is used as time base for the HAL_Delay() function, the application * need to ensure that the SysTick time base is always set to 1 millisecond * to have correct HAL operation. * @retval HAL status */ HAL_StatusTypeDef HAL_Init(void) { /* Configure Flash prefetch and Instruction cache through ART accelerator */ #if (ART_ACCLERATOR_ENABLE != 0) __HAL_FLASH_ART_ENABLE(); #endif /* ART_ACCLERATOR_ENABLE */ /* Set Interrupt Group Priority */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */ HAL_InitTick(TICK_INT_PRIORITY); /* Init the low level hardware */ HAL_MspInit(); /* Return function status */ return HAL_OK; }
/** * @brief This function configures the Flash prefetch, * Configures time base source, NVIC and Low level hardware * * @note This function is called at the beginning of program after reset and before * the clock configuration * * @note The Systick configuration is based on HSI clock, as HSI is the clock * used after a system Reset and the NVIC configuration is set to Priority group 4 * * @note The time base configuration is based on MSI clock when exting from Reset. * Once done, time base tick start incrementing. * In the default implementation,Systick is used as source of time base. * the tick variable is incremented each 1ms in its ISR. * * @note * @retval HAL status */ HAL_StatusTypeDef HAL_Init(void) { /* Configure Flash prefetch */ #if (PREFETCH_ENABLE != 0) __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); #endif /* PREFETCH_ENABLE */ /* Set Interrupt Group Priority */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); /* Enable systick and configure 1ms tick (default clock after Reset is HSI) */ HAL_InitTick(TICK_INT_PRIORITY); /* Init the low level hardware */ HAL_MspInit(); /* Return function status */ return HAL_OK; }
int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f4xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ SystemClock_Config(); uint8_t lcd_status = LCD_OK; HAL_MspInit(); HAL_Init(); BSP_SDRAM_Init(); // uint32_t i; int i; __HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOG_CLK_ENABLE(); __HAL_RCC_GPIOK_CLK_ENABLE(); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStructure.Speed = GPIO_SPEED_HIGH; GPIO_InitStructure.Pull = GPIO_NOPULL; //GPIO_PULLDOWN;//GPIO_PULLUP;// GUI_Conf.border=8; GPIO_InitStructure.Pin = GPIO_PIN_6; HAL_GPIO_Init(GPIOG,&GPIO_InitStructure); GPIO_InitStructure.Pin = GPIO_PIN_5; HAL_GPIO_Init(GPIOD,&GPIO_InitStructure); GPIO_InitStructure.Pin = GPIO_PIN_4; HAL_GPIO_Init(GPIOD,&GPIO_InitStructure); GPIO_InitStructure.Pin = GPIO_PIN_3; HAL_GPIO_Init(GPIOK,&GPIO_InitStructure); BSP_LCD_Reset(); BSP_LCD_MspInit(); //lcd_status = BSP_LCD_InitEx(LCD_ORIENTATION_PORTRAIT); //lcd_status = BSP_LCD_InitEx(LCD_ORIENTATION_LANDSCAPE); lcd_status = BSP_LCD_Init(); BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS); BSP_LCD_SelectLayer(0); BSP_LCD_DisplayOn(); BSP_LCD_SetTransparency(0,0xff); if(lcd_status!=LCD_OK) f_error(); BSP_LCD_Clear(LCD_COLOR_BLACK); BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 0,BSP_LCD_GetXSize(),BSP_LCD_GetYSize()); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_FillRect(GUI_Conf.border, GUI_Conf.border,BSP_LCD_GetXSize()-2*GUI_Conf.border,BSP_LCD_GetYSize()-2*GUI_Conf.border); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_SetFont(&Font16); BSP_LCD_SetBackColor(LCD_COLOR_TRANSPARENT); BSP_LCD_DisplayStringAtLine(1, (uint8_t *)" FAT SD"); while(1){ Delay(1000); switch(i%4){ case 0: HAL_GPIO_TogglePin(GPIOG,GPIO_PIN_6); break; case 1: HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_4); break; case 2: HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_5); break; case 3: HAL_GPIO_TogglePin(GPIOK,GPIO_PIN_3); break; } i++; if(! i%4) i=0; } }