Yosef Guevara Salamanca
/
STM32_Button_Interrupt
Ejemplo Debug con calculadora
Diff: main.cpp
- Revision:
- 0:8f1d60cec8c3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Aug 17 12:43:47 2018 +0000 @@ -0,0 +1,76 @@ +#include "mbed.h" +#define DEBUG 1 + + +Serial pc(USBTX,USBRX); + +//void f_r(int N){ + + + //char c = N/100; + //char d = (N-c*100)/10; + //char u = (N-c*100-d*10); + + //pc.putc(c+0x30); + //pc.putc(d+0x30); + //pc.putc(u+0x30); + + + + //} + +void debuging(char*s,...){ + + #if DEBUG + pc.printf(s); + #endif + + } + +void main() { + + pc.baud(38400); + + + char op1; + char op2; + char tp; + int rest; + + + while(1){ + debuging("\n Ingrese el valor 1. "); + op1=pc.getc(); + debuging("\n Ingrese el valor 2. "); + op2=pc.getc(); + debuging("\n Ingrese la operacion. "); + tp=pc.getc(); + + switch(tp){ + case 1: + rest= op1*op2; + break; + case 2: + rest= op1/op2; + break; + case 3: + rest= op1+op2; + break; + case 4: + rest= op1-op2; + break; + default: + pc.putc('E'); + break; + + } + debuging("\n El resultado es. "); + pc.printf("%d",rest); + + + } + + +} + +