Alexandre Buche / Mbed 2 deprecated HERTZ_STM32_Print_PC

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 /*------------------------------------------------------------------------------
00004 Before to use this example, ensure that you an hyperterminal installed on your
00005 computer. More info here: https://developer.mbed.org/handbook/Terminals
00006 
00007 The default serial comm port uses the SERIAL_TX and SERIAL_RX pins (see their
00008 definition in the PinNames.h file).
00009 
00010 The default serial configuration in this case is 9600 bauds, 8-bit data, no parity
00011 
00012 If you want to change the baudrate for example, you have to redeclare the
00013 serial object in your code:
00014 
00015 Serial pc(SERIAL_TX, SERIAL_RX);
00016 
00017 Then, you can modify the baudrate and print like this:
00018 
00019 pc.baud(115200);
00020 pc.printf("Hello World !\n");
00021 ------------------------------------------------------------------------------*/
00022 
00023 //Serial pc(PA_9, PA_10);
00024 
00025 Serial regis(PA_10, PA_11);
00026 
00027 DigitalOut led(LED1);
00028 DigitalOut led2(LED2);
00029 
00030 int main()
00031 {
00032     const int bufferSize = 1024;
00033     int * buffer = new int [bufferSize];
00034     int i = 1;
00035     char c = 'w';
00036     //pc.printf("Hello World !\n");
00037     led = 0;
00038     led2= 0;
00039     while(1) {
00040         //pc.printf("This program runs since %d seconds.\r\n", i++);
00041         c = regis.getc();
00042         if (c == 'w'){
00043             led = 1;
00044         } else{
00045             led2 = 1;
00046         }
00047         //pc.printf("Char: %c", c);
00048         //if(regis.readable()){
00049         //    pc.printf("Woooooow\r\n");
00050         //}
00051         i++;
00052         if(i % 10 == 0){
00053             led2 = !led2;
00054         }
00055     }
00056 }