/** * Enable DMA controller clock */ void MX_DMA_Init(void) { /* DMA controller clock enable */ __DMA1_CLK_ENABLE(); /* DMA interrupt init */ /* Sets the priority grouping field */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); HAL_NVIC_SetPriority(DMA1_Stream3_IRQn, 0, 0); HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn); /* Sets the priority grouping field */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); HAL_NVIC_SetPriority(DMA1_Stream7_IRQn, 0, 1); HAL_NVIC_EnableIRQ(DMA1_Stream7_IRQn); }
/** * Initializes the Global MSP. */ void HAL_MspInit(void) { /* USER CODE BEGIN MspInit 0 */ /* USER CODE END MspInit 0 */ __HAL_RCC_AFIO_CLK_ENABLE(); HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); /* System interrupt init*/ /* MemoryManagement_IRQn interrupt configuration */ HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); /* BusFault_IRQn interrupt configuration */ HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); /* UsageFault_IRQn interrupt configuration */ HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); /* SVCall_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0); /* DebugMonitor_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0); /* PendSV_IRQn interrupt configuration */ HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0); /* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); /**DISABLE: JTAG-DP Disabled and SW-DP Disabled */ __HAL_AFIO_REMAP_SWJ_DISABLE(); /* USER CODE BEGIN MspInit 1 */ /* USER CODE END MspInit 1 */ }
/** * Initializes the Global MSP. */ void HAL_MspInit(void) { /* USER CODE BEGIN MspInit 0 */ /* USER CODE END MspInit 0 */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); /* System interrupt init*/ /* BusFault_IRQn interrupt configuration */ HAL_NVIC_SetPriority(BusFault_IRQn, 0, 7); /* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 7); /* DebugMonitor_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 3); /* UsageFault_IRQn interrupt configuration */ HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 7); /* MemoryManagement_IRQn interrupt configuration */ HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 7); /* RCC_IRQn interrupt configuration */ HAL_NVIC_SetPriority(RCC_IRQn, 0, 0); HAL_NVIC_EnableIRQ(RCC_IRQn); /* USER CODE BEGIN MspInit 1 */ /* USER CODE END MspInit 1 */ }
/** * Initializes the Global MSP. */ void HAL_MspInit(void) { /* USER CODE BEGIN MspInit 0 */ /* USER CODE END MspInit 0 */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_2); /* System interrupt init*/ /* MemoryManagement_IRQn interrupt configuration */ HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); /* BusFault_IRQn interrupt configuration */ HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); /* UsageFault_IRQn interrupt configuration */ HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); /* SVCall_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0); /* DebugMonitor_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DebugMonitor_IRQn, 2, 1); /* PendSV_IRQn interrupt configuration */ HAL_NVIC_SetPriority(PendSV_IRQn, 2, 0); /* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 3, 0); /* USER CODE BEGIN MspInit 1 */ /* USER CODE END MspInit 1 */ }
/** * @brief A function used to configure and init the accelerometer * @param none * @retval none */ void configure_init_accelerometer(void) { //Configure the accelerometer initialization struct LIS3DSH_InitStruct.Power_Mode_Output_DataRate = LIS3DSH_DATARATE_25; /* Ppower down or /active mode with output data rate 3.125 / 6.25 / 12.5 / 25 / 50 / 100 / 400 / 800 / 1600 HZ */ LIS3DSH_InitStruct.Axes_Enable = LIS3DSH_XYZ_ENABLE; /* Axes enable */ LIS3DSH_InitStruct.Continous_Update = LIS3DSH_ContinousUpdate_Disabled; /* Block or update Low/High registers of data until all data is read */ LIS3DSH_InitStruct.AA_Filter_BW = LIS3DSH_AA_BW_50; /* Choose anti-aliasing filter BW 800 / 400 / 200 / 50 Hz*/ LIS3DSH_InitStruct.Full_Scale = LIS3DSH_FULLSCALE_2; /* Full scale 2 / 4 / 6 / 8 / 16 g */ LIS3DSH_InitStruct.Self_Test = LIS3DSH_SELFTEST_NORMAL; /* Self test */ //Configure the accelerometer interrupt struct LIS3DSH_IntConfigStruct.Dataready_Interrupt = LIS3DSH_DATA_READY_INTERRUPT_ENABLED; /* Enable/Disable data ready interrupt */ LIS3DSH_IntConfigStruct.Interrupt_signal = LIS3DSH_ACTIVE_HIGH_INTERRUPT_SIGNAL; /* Interrupt Signal Active Low / Active High */ LIS3DSH_IntConfigStruct.Interrupt_type = LIS3DSH_INTERRUPT_REQUEST_PULSED; /* Interrupt type as latched or pulsed */ //Enable the interrupt line HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); HAL_NVIC_EnableIRQ(EXTI0_IRQn); HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 1); //Initialize the accelerometer LIS3DSH_Init(&LIS3DSH_InitStruct); //Setting the interrupt configuration of the accelerometer LIS3DSH_DataReadyInterruptConfig(&LIS3DSH_IntConfigStruct); }
void SystemClock_Config(void) { RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_OscInitTypeDef RCC_OscInitStruct; RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = 8; RCC_OscInitStruct.PLL.PLLN = 336; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 4; HAL_RCC_OscConfig(&RCC_OscInitStruct); RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5); HAL_RCC_EnableCSS(); HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); HAL_SYSTICK_Config(SystemCoreClock / 1000); }
void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) { GPIO_InitTypeDef GPIO_InitStruct; if(hpcd->Instance==USB) { /* Peripheral clock enable */ __USB_CLK_ENABLE(); /**USB GPIO Configuration PA11 ------> USB_DM PA12 ------> USB_DP */ GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF14_USB; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Peripheral interrupt init*/ /* Sets the priority grouping field */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); HAL_NVIC_SetPriority(USB_LP_CAN_RX0_IRQn, 0, 0); HAL_NVIC_EnableIRQ(USB_LP_CAN_RX0_IRQn); } }
int main() { /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, Flash preread and Buffer caches - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Low Level Initialization */ HAL_Init(); /* Configure the system clock to 168 MHz */ SystemClock_Config(); HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress ); xTaskCreate(prvInit, "Init", 1000, NULL, 3, NULL); vTaskStartScheduler(); return 0; }
void systemInit(void) { checkForBootLoaderRequest(); //SystemClock_Config(); // Configure NVIC preempt/priority groups HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITY_GROUPING); // cache RCC->CSR value to use it in isMPUSoftReset() and others cachedRccCsrValue = RCC->CSR; /* Accounts for OP Bootloader, set the Vector Table base address as specified in .ld file */ //extern void *isr_vector_table_base; //NVIC_SetVectorTable((uint32_t)&isr_vector_table_base, 0x0); //__HAL_RCC_USB_OTG_FS_CLK_DISABLE; //RCC_ClearFlag(); enableGPIOPowerUsageAndNoiseReductions(); // Init cycle counter cycleCounterInit(); // SysTick //SysTick_Config(SystemCoreClock / 1000); HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); }
/** * Initializes the Global MSP. */ void HAL_MspInit(void) { /* USER CODE BEGIN MspInit 0 */ /* USER CODE END MspInit 0 */ __HAL_RCC_AFIO_CLK_ENABLE(); HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); /* System interrupt init*/ /* MemoryManagement_IRQn interrupt configuration */ HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); /* BusFault_IRQn interrupt configuration */ HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); /* UsageFault_IRQn interrupt configuration */ HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); /* DebugMonitor_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0); /* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 2, 0); /* USER CODE BEGIN MspInit 1 */ /* USER CODE END MspInit 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; }
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 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; }
/* this function is needed to peform hardware initialization that must happen * before the uVisor; the whole SystemInit function for the STM32F4 cannot be * put here as it depends on some APIs that need uVisor to be enabled */ HAL_StatusTypeDef HAL_InitPre(void) { /* Set Interrupt Group Priority */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); /* Return function status */ return HAL_OK; }
void HAL_MspInit(void) { HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); }
/** * Initializes the Global MSP. */ void HAL_MspInit(void) { HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); /* System interrupt init*/ /* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); }
/** * @brief Initializes the Global MSP. * @note This function is called from HAL_Init() function to perform system * level initialization (GPIOs, clock, DMA, interrupt). * @retval None */ void HAL_MspInit(void) { HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); SystemClock_Config(); /* Initialize LEDs */ BSP_LED_Init(LED2); BSP_LED_Off(LED2); }
void hubInit(void) { initIO(); calculatePeriod(); hubLUTInit(); initRows(); hubOrientation = HUB_ROTATE_0; hubSetOrient(hubOrientation); clearScreen(); //fillScreen(COLOR_RGB(255, 255, 255)); hubTestBmp(); screenRedraw(); // 100 Hz * 16 Phases HUB_TIMER_CLK_ENABLE(); TIM_ClockConfigTypeDef sClockSourceConfig; hubtim.Instance = HUB_TIMER; hubtim.Init.Prescaler = HUB_PRESCALER - 1; hubtim.Init.CounterMode = TIM_COUNTERMODE_UP; hubtim.Init.Period = period0 - 1; hubtim.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; HAL_TIM_Base_Init(&hubtim); sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; HAL_TIM_ConfigClockSource(&hubtim, &sClockSourceConfig); HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); HAL_NVIC_SetPriority(TIM1_BRK_TIM9_IRQn, 0, 0); HAL_NVIC_EnableIRQ(TIM1_BRK_TIM9_IRQn); HAL_TIM_Base_Start_IT(&hubtim); // Timer 2 for NOE HUB_TIMER2_CLK_ENABLE(); TIM_OC_InitTypeDef sConfigOC; hubtim2.Instance = HUB_TIMER2; hubtim2.Init.Prescaler = 0; hubtim2.Init.CounterMode = TIM_COUNTERMODE_UP; hubtim2.Init.Period = 0xffff; hubtim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; HAL_TIM_Base_Init(&hubtim2); HAL_TIM_OC_Init(&hubtim2); sConfigOC.OCMode = TIM_OCMODE_PWM1; sConfigOC.Pulse = period2Min; sConfigOC.OCPolarity = TIM_OCPOLARITY_LOW; sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; HAL_TIM_OC_ConfigChannel(&hubtim2, &sConfigOC, NOE_TIM_CHANNEL); HAL_TIM_PWM_Start(&hubtim2, NOE_TIM_CHANNEL); }
/** * @brief Initializes the Global MSP. * @param None * @retval None */ void HAL_MspInit(void) { /* NOTE : This function is generated automatically by STM32CubeMX and eventually modified by the user */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); /* System interrupt init*/ /* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); }
int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ Task_Info_t TaskState=TASK_INFO_INIT; /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* System interrupt init*/ /* Sets the priority grouping field */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_USART6_UART_Init(); MX_USART1_UART_Init(); MX_USART2_UART_Init(); MX_USART3_UART_Init(); MX_TimerDynamixel_Init(&TimHandle2 , TIM2); MX_TimerDynamixel_Init(&TimHandle3 , TIM3); MX_TimerDynamixel_Init(&TimHandle4 , TIM4); Trace_Init(); HAL_Delay(1000); Trace_Raw("Medula control board start...\n\r"); Dynamixel_Init(); IO_Data_init(); while (0) { Dynamixel_test(&TaskState); Trace_Task(); } while (1) { HAL_Delay(10); IO_Data_Scan_In(); Appli(&TaskState); Trace_Task(); HAL_Delay(5); IO_Data_Scan_Out(); } /* USER CODE END 3 */ }
/** * Initializes the Global MSP. */ void HAL_MspInit(void) { /* USER CODE BEGIN MspInit 0 */ /* USER CODE END MspInit 0 */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); /* System interrupt init*/ /* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); /* USER CODE BEGIN MspInit 1 */ /* USER CODE END MspInit 1 */ }
/** * Initializes the Global MSP. */ void HAL_MspInit(void) { HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); /* System interrupt init*/ /* MemoryManagement_IRQn interrupt configuration */ HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); /* BusFault_IRQn interrupt configuration */ HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); /* UsageFault_IRQn interrupt configuration */ HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); /* DebugMonitor_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0); /* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); }
int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* System interrupt init*/ /* Sets the priority grouping field */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_I2C1_Init(); MX_I2S2_Init(); MX_I2S3_Init(); MX_SPI1_Init(); MX_SPI4_Init(); MX_TIM3_Init(); MX_USART2_UART_Init(); MX_USB_DEVICE_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /*## FatFS: Link the USER disk I/O driver ###############################*/ USER_DriverNum = FATFS_LinkDriver(&USER_Driver, USER_Path); /* USER CODE BEGIN 3 */ dabstick_loop(); // endless return 0; /* USER CODE END 3 */ }
/** * @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; }
/** * Initializes the Global MSP. */ void HAL_MspInit(void) { /* USER CODE BEGIN MspInit 0 */ /* USER CODE END MspInit 0 */ __COMP_CLK_ENABLE(); __SYSCFG_CLK_ENABLE(); HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); /* System interrupt init*/ /* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 15, 0); /* USER CODE BEGIN MspInit 1 */ /* USER CODE END MspInit 1 */ }
/** * @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) { // By customising __initialize_args() it is possible to pass arguments, // for example when running tests with semihosting you can pass various // options to the test. // trace_dump_args(argc, argv); // Send a greeting to the trace device (skipped on Release). trace_puts("Hello ARM World!"); // The standard output and the standard error should be forwarded to // the trace device. For this to work, a redirection in _write.c is // required. puts("Standard output message."); fprintf(stderr, "Standard error message.\n"); // At this stage the system clock should have already been configured // at high speed. //trace_printf("System clock: %uHz\n", SystemCoreClock); //timer_start(); HAL_Init(); blink_led_init(); HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); blink_led_off(); // Infinite loop while (1) { blink_led_on(); HAL_Delay(1000); //timer_sleep(BLINK_ON_TICKS); //delay(1000U); blink_led_off(); //timer_sleep(BLINK_OFF_TICKS); HAL_Delay(1000); // Count seconds on the trace device. trace_printf("Second\n"); } // Infinite loop, never return. }
/** * Initializes the Global MSP. */ void HAL_MspInit(void) { /* USER CODE BEGIN MspInit 0 */ /* USER CODE END MspInit 0 */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); /* System interrupt init*/ /* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); /**DISABLE: JTAG-DP Disabled and SW-DP Disabled */ __HAL_AFIO_REMAP_SWJ_DISABLE(); /* USER CODE BEGIN MspInit 1 */ /* USER CODE END MspInit 1 */ }
void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) { GPIO_InitTypeDef GPIO_InitStruct; if(hpcd->Instance==USB_OTG_FS) { /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ /* USER CODE END USB_OTG_FS_MspInit 0 */ /* Peripheral clock enable */ __USB_OTG_FS_CLK_ENABLE(); /**USB_OTG_FS GPIO Configuration PA11 ------> USB_OTG_FS_DM PA12 ------> USB_OTG_FS_DP */ GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); /* Set USBFS Interrupt priority to 6 */ //HAL_NVIC_SetPriority(OTG_FS_IRQn, 6, 0); HAL_NVIC_SetPriority(OTG_FS_IRQn, 3, 2); HAL_NVIC_EnableIRQ(OTG_FS_IRQn); if(hpcd->Init.low_power_enable == 1) { /* Enable EXTI Line 18 for USB wakeup */ __HAL_USB_FS_EXTI_CLEAR_FLAG(); __HAL_USB_FS_EXTI_SET_RISING_EGDE_TRIGGER(); __HAL_USB_FS_EXTI_ENABLE_IT(); HAL_NVIC_SetPriority(OTG_FS_WKUP_IRQn, 3, 2); HAL_NVIC_EnableIRQ(OTG_FS_WKUP_IRQn); } /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ /* USER CODE END USB_OTG_FS_MspInit 1 */ } }
int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* System interrupt init*/ /* Sets the priority grouping field */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_ADC1_Init(); MX_DAC_Init(); MX_TIM2_Init(); /* USER CODE BEGIN 2 */ HAL_ADC_Start(&hadc1); HAL_DAC_Start(&hdac, DAC_CHANNEL_1); /* USER CODE END 2 */ /* USER CODE BEGIN 3 */ /* Infinite loop */ while (1) { } /* USER CODE END 3 */ }