Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ProcVisDemo_Accelerator.cpp
00001 #include "mbed.h" 00002 #include "Serial_HL.h" 00003 #include "MMA7660.h" 00004 00005 SerialBLK pc(USBTX, USBRX); 00006 SvProtocol ua0(&pc); 00007 00008 // V2.0 00009 // BusOut leds(LED1,LED2,LED3,LED4); Bertl14 00010 // M0-Board 00011 //BusOut leds(P1_13,P1_12,P1_7,P1_6,P1_4,P1_3,P1_1,P1_0,LED4,LED3,LED2,LED1); 00012 MMA7660 accel (p28, p27); 00013 00014 00015 void CommandHandler(); 00016 00017 int main(void) 00018 { 00019 pc.format(8,SerialBLK::None,1); 00020 pc.baud(115200); 00021 00022 ua0.SvMessage("Accelerator Test"); // Meldung zum PC senden 00023 00024 accel.setSampleRate(120); 00025 int val2[3]; 00026 Timer stw; 00027 stw.start(); 00028 00029 while(1) { 00030 CommandHandler(); 00031 if( ua0.acqON && (stw.read_ms()>100) ) // 10Hz 00032 { 00033 // dieser Teil wird mit 10Hz aufgerufen 00034 stw.reset(); 00035 accel.readData(val2);//X,Y,Z vom PC lesen 00036 ua0.WriteSvI16(1, val2[0]);//X,Y,Z zum PC senden 00037 ua0.WriteSvI16(2, val2[1]); 00038 ua0.WriteSvI16(3, val2[2]); 00039 } 00040 return 1; 00041 } 00042 } 00043 00044 void CommandHandler() 00045 { 00046 uint8_t cmd; 00047 int16_t idata1, idata2; 00048 00049 // Fragen ob überhaupt etwas im RX-Reg steht 00050 if( !pc.IsDataAvail() ) 00051 return; 00052 00053 // wenn etwas im RX-Reg steht 00054 // Kommando lesen 00055 cmd = ua0.GetCommand(); 00056 00057 if( cmd==2 ) { 00058 // cmd2 hat 2 int16 Parameter 00059 idata1 = ua0.ReadI16(); 00060 idata2 = ua0.ReadI16(); 00061 // für die Analyse den Wert einfach nur zum PC zurücksenden 00062 ua0.SvPrintf("Command2 %d %d", idata1, idata2); 00063 } 00064 00065 if( cmd==3 ) //leds schalten 00066 { 00067 00068 ua0.SvMessage("SetLeds Awa pronto!"); 00069 } 00070 } 00071 00072
Generated on Fri Jul 29 2022 20:34:37 by
