Communication program for the chrobotics UM6 9-DOF IMU AHRS.

Dependencies:   MODSERIAL mbed

Committer:
lhiggs
Date:
Fri Sep 28 00:40:29 2012 +0000
Revision:
0:03c649c76388
A UM6 IMU AHRS INTERFACE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lhiggs 0:03c649c76388 1 #include "mbed.h" // MBED LIBRARY
lhiggs 0:03c649c76388 2 #include "MODSERIAL.h" // MBED BUFFERED SERIAL
lhiggs 0:03c649c76388 3
lhiggs 0:03c649c76388 4 #include "UM6_usart.h" // UM6 USART HEADER
lhiggs 0:03c649c76388 5 #include "UM6_config.h" // UM6 CONFIG HEADER
lhiggs 0:03c649c76388 6
lhiggs 0:03c649c76388 7 /////////////////////////////////////////////////////////////////////////////////////////////
lhiggs 0:03c649c76388 8 // SETUP (ASSIGN) SERIAL COMMUNICATION PINS ON MBED
lhiggs 0:03c649c76388 9 /////////////////////////////////////////////////////////////////////////////////////////////
lhiggs 0:03c649c76388 10 MODSERIAL pc(USBTX, USBRX); // PC SERIAL OVER USB PORT ON MBED
lhiggs 0:03c649c76388 11
lhiggs 0:03c649c76388 12 ////////////////////////////////////////////////////////////////////////////////////////////////
lhiggs 0:03c649c76388 13 // SETUP (ASSIGN) MBED LED (1 thru 3) FOR VISUAL DEBUGGING ON MBED
lhiggs 0:03c649c76388 14 ////////////////////////////////////////////////////////////////////////////////////////////////
lhiggs 0:03c649c76388 15 DigitalOut pc_activity(LED1); // LED1 = PC SERIAL
lhiggs 0:03c649c76388 16 DigitalOut uart_activity(LED2); // LED2 = UM6 SERIAL
lhiggs 0:03c649c76388 17
lhiggs 0:03c649c76388 18
lhiggs 0:03c649c76388 19 void rxCallback(MODSERIAL_IRQ_INFO *q) {
lhiggs 0:03c649c76388 20 if (um6_uart.rxBufferGetCount() >= MAX_PACKET_DATA) {
lhiggs 0:03c649c76388 21 uart_activity = !uart_activity; // Lights LED when uart RxBuff has > 40 bytes
lhiggs 0:03c649c76388 22 Process_um6_packet();
lhiggs 0:03c649c76388 23 }
lhiggs 0:03c649c76388 24 }
lhiggs 0:03c649c76388 25
lhiggs 0:03c649c76388 26
lhiggs 0:03c649c76388 27 int main() {
lhiggs 0:03c649c76388 28
lhiggs 0:03c649c76388 29 /////////////////////////////////////////////////////////////////////////////////////////////////////
lhiggs 0:03c649c76388 30 // SET SERIAL UART BAUD RATES
lhiggs 0:03c649c76388 31 /////////////////////////////////////////////////////////////////////////////////////////////////////
lhiggs 0:03c649c76388 32
lhiggs 0:03c649c76388 33 // set UM6 serial uart baud 9600
lhiggs 0:03c649c76388 34 um6_uart.baud(9600);
lhiggs 0:03c649c76388 35 pc.baud(9600); // pc baud for UM6 to pc interface
lhiggs 0:03c649c76388 36
lhiggs 0:03c649c76388 37 // attach interupt function to uart
lhiggs 0:03c649c76388 38 um6_uart.attach(&rxCallback, MODSERIAL::RxIrq);
lhiggs 0:03c649c76388 39
lhiggs 0:03c649c76388 40 int Roll_Counter = 0;
lhiggs 0:03c649c76388 41
lhiggs 0:03c649c76388 42 while (1) {
lhiggs 0:03c649c76388 43 Roll_Counter++;
lhiggs 0:03c649c76388 44 if (Roll_Counter > 5000000) {
lhiggs 0:03c649c76388 45 pc.printf("Gyro_Proc_X %f deg/s, ",data.Gyro_Proc_X);
lhiggs 0:03c649c76388 46 pc.printf("Gyro_Proc_Y %f deg/s, ",data.Gyro_Proc_Y);
lhiggs 0:03c649c76388 47 pc.printf("Gyro_Proc_Z %f deg/s, ",data.Gyro_Proc_Z);
lhiggs 0:03c649c76388 48 pc.printf("Roll %f deg, ",data.Roll);
lhiggs 0:03c649c76388 49 pc.printf("Pitch %f deg, ",data.Pitch);
lhiggs 0:03c649c76388 50 pc.printf("Yaw %f deg \r\n",data.Yaw);
lhiggs 0:03c649c76388 51 pc_activity = !pc_activity; // Lights LED when uart RxBuff has > 40 bytes
lhiggs 0:03c649c76388 52 Roll_Counter = 0;
lhiggs 0:03c649c76388 53 }
lhiggs 0:03c649c76388 54
lhiggs 0:03c649c76388 55 } // end while(1) loop
lhiggs 0:03c649c76388 56
lhiggs 0:03c649c76388 57 } // end main()