Daniel Garcia
/
telecomando1
proyecto araña
Fork of 01-04EntregaPrimerCorte by
main.cpp
- Committer:
- danielgarciag
- Date:
- 2018-09-30
- Revision:
- 2:dc3183a4bdf4
- Parent:
- 1:526bdd5faa37
File content as of revision 2:dc3183a4bdf4:
#include "mbed.h" #include "main.h" Serial command(USBTX, USBRX); int main() { init_servo(); init_serial(); debug_m("inicio \n"); uint32_t read_cc; while(1) { read_cc=read_command(); switch (read_cc) { case 0x01: moving(); break; default: debug_m("error de comando. \nSe espera 0xFEF0 o 0xFFF0 \n");break ; } } } uint32_t read_command() { // retorna los byte recibidos concatenados en un entero, char intc=command.getc(); while(intc != 0xff) intc=command.getc(); return command.getc(); } void init_serial() { command.baud(9600); } void moving(){ debug_m("se inicia el comado mover..\n"); char nmotor=command.getc(); char grados=command.getc(); char endc=command.getc(); debug_m("MOTOR: %d grados : %d \n", nmotor, grados); mover_ser(nmotor,grados); debug_m("fin del comado mover..\n"); } void debug_m(char *s , ... ){ #if DEBUG command.printf(s); #endif }