![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This is some awesome robot code
Dependencies: mbed-rtos mbed QEI
Fork of ICRSEurobot13 by
Communication/coprocserial.cpp
- Committer:
- madcowswe
- Date:
- 2013-04-10
- Revision:
- 26:7cb3a21d9a2e
- Parent:
- 20:70d651156779
- Child:
- 48:254b124cef02
File content as of revision 26:7cb3a21d9a2e:
#include "Kalman.h" #include "mbed.h" #include "globals.h" Serial coprocserial(NC, P_SERIAL_RX); //DigitalOut OLED1(LED1); DigitalOut OLED3(LED3); // bytes packing typedef union { struct _data{ unsigned char sync[3]; unsigned char ID; float value; float variance; } data; unsigned char type_char[12]; } bytepack_t; bytepack_t incbuff; volatile int buffprintflag = 0; void printbuff(){ while(!buffprintflag); buffprintflag = 0; for(int i = 0; i < 9; i++){ printf("%x ", incbuff.type_char[i]); } printf("\r\n"); } void procserial(){ //Fetch the byte in a "clear interrupt" sense unsigned char c = LPC_UART1->RBR; //OLED1 = !OLED1; static int ctr = 0; if (ctr < 3){ if (c == 0xFF) ctr++; else ctr = 0; } else { incbuff.type_char[ctr] = c; if (++ctr == 12){ ctr = 0; OLED3 = !OLED3; buffprintflag = 1; //runupdate Kalman::runupdate((Kalman::measurement_t)incbuff.data.ID, incbuff.data.value, incbuff.data.variance); } } } void InitSerial(){ coprocserial.baud(115200); printf("attachserial\r\n"); coprocserial.attach(procserial); }