Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of TUKS-COURSE-TIMER by
main.c
00001 #define USE_STM32L476G_DISCO_REVC 00002 #include "stm32l476g_discovery.h" 00003 #include "stm32l476g_discovery_glass_lcd.h" 00004 00005 00006 /************** TODO ********************** 00007 - Find and fix bug in ADC initialization code 00008 - Perform actual measurement 00009 - Output actual calibrated temperature value (RTFM) 00010 */ 00011 int main() 00012 { 00013 //Init and test LCD 00014 BSP_LCD_GLASS_Init(); 00015 BSP_LCD_GLASS_DisplayBar(LCD_BAR_3); 00016 00017 __HAL_RCC_ADC_CLK_ENABLE(); 00018 __HAL_RCC_ADC_FORCE_RESET(); 00019 __HAL_RCC_ADC_RELEASE_RESET(); 00020 __HAL_RCC_ADC_CONFIG(RCC_ADCCLKSOURCE_SYSCLK); 00021 00022 ADC_HandleTypeDef hAdc; 00023 hAdc.Instance = ADC1; 00024 hAdc.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV256; 00025 hAdc.Init.Resolution = ADC_RESOLUTION_12B; 00026 hAdc.Init.DataAlign = ADC_DATAALIGN_RIGHT; 00027 hAdc.Init.ScanConvMode = ADC_SCAN_DISABLE; 00028 hAdc.Init.EOCSelection = ADC_EOC_SINGLE_CONV; 00029 hAdc.Init.LowPowerAutoWait = DISABLE; 00030 hAdc.Init.ContinuousConvMode = DISABLE; 00031 hAdc.Init.ExternalTrigConv = ADC_SOFTWARE_START; 00032 hAdc.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN; 00033 hAdc.Init.OversamplingMode = DISABLE; 00034 00035 ADC_ChannelConfTypeDef adcChannel; 00036 adcChannel.Channel = ADC_CHANNEL_VBAT; 00037 adcChannel.Rank = ADC_REGULAR_RANK_1; 00038 adcChannel.SamplingTime = ADC_SAMPLETIME_247CYCLES_5; 00039 adcChannel.SingleDiff = ADC_SINGLE_ENDED; 00040 adcChannel.OffsetNumber = ADC_OFFSET_NONE; 00041 00042 HAL_ADC_Init(&hAdc); 00043 HAL_ADC_ConfigChannel(&hAdc,&adcChannel); 00044 00045 HAL_ADCEx_Calibration_Start(&hAdc,ADC_SINGLE_ENDED); 00046 00047 while(1) { 00048 /// TBD: Start ADC, wait for end of onversion, read value 00049 uint8_t text[7]; 00050 00051 snprintf((char *)text, sizeof text,"%+04d~C", -999); 00052 BSP_LCD_GLASS_DisplayChar(&text[0], POINT_OFF, DOUBLEPOINT_OFF,LCD_DIGIT_POSITION_1); 00053 BSP_LCD_GLASS_DisplayChar(&text[1], POINT_OFF, DOUBLEPOINT_OFF,LCD_DIGIT_POSITION_2); 00054 BSP_LCD_GLASS_DisplayChar(&text[2], POINT_ON, DOUBLEPOINT_OFF,LCD_DIGIT_POSITION_3); 00055 BSP_LCD_GLASS_DisplayChar(&text[3], POINT_OFF, DOUBLEPOINT_OFF,LCD_DIGIT_POSITION_4); 00056 BSP_LCD_GLASS_DisplayChar(&text[4], POINT_OFF, DOUBLEPOINT_OFF,LCD_DIGIT_POSITION_5); 00057 BSP_LCD_GLASS_DisplayChar(&text[5], POINT_OFF, DOUBLEPOINT_OFF,LCD_DIGIT_POSITION_6); 00058 HAL_Delay(500); 00059 } 00060 }
Generated on Tue Jul 12 2022 17:38:48 by
1.7.2
