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 Laster_Radar_test by
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 #include "cdef.h" 00004 #include "I2C.h" 00005 DigitalOut myled(LED1); 00006 TextLCD display(PA_9, PC_7, PB_5, PB_4, PB_10, PA_8, TextLCD::LCD16x2); 00007 Serial pc(SERIAL_TX, SERIAL_RX); 00008 00009 00010 00011 /****************************************************** 00012 * void vInitSystemClock(void) 00013 * Purpose: 00014 * Initialisiert Clocksystem HSI,HSE,PLL, Setzt HSE als 00015 * Taktquelle und PLL für SystemClock = 84 Mhz. 00016 * Aktiviert Clock Secuity System für fall das HSE versagt 00017 * Parameter: 00018 * -Keine Parameter- 00019 * Return value: 00020 * -Keine Return Values 00021 * Interrupt: 00022 * Im HSE Ausfall wird RCC Interrupt aufgerufen 00023 *******************************************************/ 00024 void vInitSystemClock(void) 00025 { 00026 00027 /***Flash wait states 2 */ 00028 FLASH->ACR |= Bit1 ; 00029 /** Enable the High Speed Internal Clock and wait for HSI to be stable.*/ 00030 RCC->CR |= RCC_CR_HSION; 00031 while (!(RCC->CR & RCC_CR_HSIRDY)); 00032 RCC->CFGR = 0x00000000; // HSI enabled and used as System Clock. No Clock Division. 00033 while( (RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_HSI ); // WAITING HSI IS SYSTEM CLOCK 00034 /**ENABLE HSE CLOCK and wait for HSE to be stable */ 00035 RCC->CR |= RCC_CR_HSEON ; 00036 while( (RCC->CR & RCC_CR_HSERDY) == 0); 00037 RCC->CR &= ~(RCC_CR_PLLI2SON 00038 | RCC_CR_CSSON 00039 | RCC_CR_PLLON) 00040 ; // Turn off PLL and CSS (clock security system). 00041 while(RCC->CR & RCC_CR_PLLRDY); // WAITING PLL OF 00042 /** Disable all clock generated interrupts. */ 00043 RCC->CIR = 0x00000000; 00044 RCC->PLLCFGR = 0x20000000; // SETZE PLL COMFIG REGISTERINHALT KOMPLETT AUF 0 00045 /** SETTINGS FOR PLL OVER HSE 8Mhz **/ 00046 RCC->PLLCFGR |= (8 << 0) // 16 / 8 = 2MHz 00047 |(168 << 6) // 2 * 168 = 336MHz 00048 |(1 << 16) // 336MHz / 4 = 84MHz (0x01 corresponds to /4) 00049 |(RCC_PLLCFGR_PLLSRC_HSI) // HSI selected. 00050 |(7 << 24); // 336Mhz / 7 = 48MHz 00051 RCC->CFGR |= RCC_CFGR_PPRE1_DIV2; // Low speed peripheral clock setup set to 42Mhz. (84Mhz / 2) 00052 RCC->CR |= (RCC_CR_PLLON); // Start the PLL clock. 00053 while (!(RCC->CR & RCC_CR_PLLRDY)); // Wait for the PLL to start. 00054 RCC->CFGR &= ~(RCC_CFGR_SW); // SET PLL AS SYSTEM CLOCK 00055 RCC->CFGR |= RCC_CFGR_SW_PLL; 00056 while ((RCC->CFGR & RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL); // Wait for configuration to take place. 00057 /** ENABLE CLOCK SECUITY SYSTEM */ 00058 RCC->CR |= Bit19 ; 00059 NVIC_EnableIRQ(RCC_IRQn); 00060 00061 } 00062 00063 00064 00065 00066 00067 00068 00069 00070 int main() 00071 { 00072 display.cls(); 00073 vInitSystemClock(); 00074 PRESSURE_vInit(); 00075 PRESSURE_vget_CALDATA(); 00076 PRESSURE_vwrite_EEPROM_REGISTER(BMP180_register_CONTROLL,0x2E); 00077 wait(0.2); 00078 PRESSURE_DATA.i_RAW_TEMPERATUR = PRESSURE_vread_EEPROM_REGISTER(BMP180_register_ADC_ERG); 00079 wait(0.1); 00080 PRESSURE_vwrite_EEPROM_REGISTER(BMP180_register_CONTROLL,0xB4); // HIGH RESULUTUIN 00081 wait(0.1); 00082 PRESSURE_DATA.i_RAW_PRESSURE = ( (PRESSURE_vread_EEPROM_REGISTER(BMP180_register_ADC_ERG))<<8 ) >>(8-BMP180_oss_high_resulution ); 00083 PRESSURE_vCALCULATE_TEMPANDPRESSURE(); 00084 00085 while(1) { 00086 myled = 1; // LED is ON 00087 PRESSURE_vwrite_EEPROM_REGISTER(BMP180_register_CONTROLL,0x2E); 00088 wait(0.2); 00089 PRESSURE_DATA.i_RAW_TEMPERATUR = PRESSURE_vread_EEPROM_REGISTER(BMP180_register_ADC_ERG); 00090 PRESSURE_vwrite_EEPROM_REGISTER(BMP180_register_CONTROLL,0xB4); // HIGH RESULUTUIN 00091 wait(0.1); 00092 PRESSURE_DATA.i_RAW_PRESSURE = ( (PRESSURE_vread_EEPROM_REGISTER(BMP180_register_ADC_ERG))<<8 ) >>(8-BMP180_oss_high_resulution ); 00093 PRESSURE_vCALCULATE_TEMPANDPRESSURE(); 00094 myled = 0; // LED is OFF 00095 wait(0.1); // 1 sec 00096 display.cls(); 00097 display.printf("TEMP:%d.%d C\n", (PRESSURE_DATA.i_TEMPERATURE)/10, (PRESSURE_DATA.i_TEMPERATURE)%10 ); 00098 display.locate(0,1); 00099 display.printf("Press: %d PA\n",PRESSURE_DATA.i_PRESSURE ); 00100 pc.printf("TestPrintPCDisplay\n"); 00101 } 00102 }
Generated on Wed Jul 13 2022 19:27:57 by
1.7.2
