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.
main.cpp
00001 #include "mbed.h" 00002 #include "main.h" 00003 #include "rtos.h" 00004 00005 00006 void get_which_dac_to_use() { 00007 int dac = 1; 00008 while(1) { 00009 serial.puts("\r\n"); 00010 serial.puts("Select which DAC to use:\r\n"); 00011 serial.puts(" 1 : DAC 1 (PA_4)\r\n"); 00012 serial.puts(" 2 : DAC 2 (PA_5)\r\n"); 00013 serial.puts("Choice: "); 00014 serial.flush(); 00015 serial.gets(buffer, BUFFER_SIZE); 00016 char* str = buffer; 00017 if(0==strcmp(str, "1")) { dac=1; break; } 00018 if(0==strcmp(str, "2")) { dac=2; break; } 00019 serial.puts("Invalid selection!\r\n"); 00020 } 00021 if(dac==1) aout = new AnalogOut(PA_4); 00022 if(dac==2) aout = new AnalogOut(PA_5); 00023 serial.printf("Done: %d.\r\n", dac); 00024 } 00025 00026 00027 void get_serial_port_ready() { 00028 for(int i=10; i>0; i--) { 00029 serial.printf("Wait %ds\r\n", i*2); 00030 wait(2); 00031 } 00032 serial.puts("***************************************\r\n"); 00033 serial.puts("*** Welcome to my Signal Generator! ***\r\n"); 00034 serial.puts("***************************************\r\n"); 00035 } 00036 00037 00038 int main() { 00039 get_serial_port_ready(); 00040 get_which_dac_to_use(); 00041 Thread generateSignal(generateSignalFunc); 00042 userInterfaceFunc(NULL); 00043 } 00044
Generated on Thu Jul 14 2022 20:41:36 by
1.7.2