impl printf
This commit is contained in:
		
							parent
							
								
									375ab76a2e
								
							
						
					
					
						commit
						7f4f50f9b7
					
				
					 5 changed files with 429 additions and 0 deletions
				
			
		
							
								
								
									
										65
									
								
								myapps/printf-test/src/main.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								myapps/printf-test/src/main.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,65 @@ | |||
| 
 | ||||
| 
 | ||||
| #define LED_Pin LL_GPIO_PIN_4 | ||||
| #define LED_GPIO_Port GPIOA | ||||
| 
 | ||||
| #include "stm32g0xx_ll_rcc.h" | ||||
| #include "stm32g0xx_ll_bus.h" | ||||
| #include "stm32g0xx_ll_crs.h" | ||||
| #include "stm32g0xx_ll_system.h" | ||||
| #include "stm32g0xx_ll_exti.h" | ||||
| #include "stm32g0xx_ll_cortex.h" | ||||
| #include "stm32g0xx_ll_utils.h" | ||||
| #include "stm32g0xx_ll_pwr.h" | ||||
| #include "stm32g0xx_ll_dma.h" | ||||
| #include "my_printf.h" | ||||
| 
 | ||||
| void SystemClock_Config(void) | ||||
| { | ||||
|   LL_FLASH_SetLatency(LL_FLASH_LATENCY_2); | ||||
|   while(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_2); | ||||
| 
 | ||||
|   /* HSI configuration and activation */ | ||||
|   LL_RCC_HSI_Enable(); | ||||
|   while(LL_RCC_HSI_IsReady() != 1); | ||||
| 
 | ||||
|   /* Main PLL configuration and activation */ | ||||
|   LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_1, 8, LL_RCC_PLLR_DIV_2); | ||||
|   LL_RCC_PLL_Enable(); | ||||
|   LL_RCC_PLL_EnableDomain_SYS(); | ||||
|   while(LL_RCC_PLL_IsReady() != 1); | ||||
| 
 | ||||
|   /* Set AHB prescaler*/ | ||||
|   LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); | ||||
| 
 | ||||
|   /* Sysclk activation on the main PLL */ | ||||
|   LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); | ||||
|   while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL); | ||||
| 
 | ||||
|   /* Set APB1 prescaler*/ | ||||
|   LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); | ||||
|   LL_Init1msTick(64000000); | ||||
|   /* Update CMSIS variable (which can be updated also through SystemCoreClockUpdate function) */ | ||||
|   LL_SetSystemCoreClock(64000000); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int main(void) | ||||
| { | ||||
|   /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ | ||||
|   LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG); | ||||
|   LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR); | ||||
|   /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral */ | ||||
|   //LL_SYSCFG_DisableDBATT(LL_SYSCFG_UCPD1_STROBE | LL_SYSCFG_UCPD2_STROBE);
 | ||||
|    | ||||
|   SystemClock_Config(); | ||||
|   my_printf_config(115200); | ||||
|    | ||||
|    | ||||
|   while(1) | ||||
|   { | ||||
|     printf("Hello World\r\n"); | ||||
|     LL_mDelay(250); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue