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.cpp@0:9ac39e20730c, 2014-04-25 (annotated)
- Committer:
- hollegha2
- Date:
- Fri Apr 25 18:26:26 2014 +0000
- Revision:
- 0:9ac39e20730c
- Child:
- 1:e88b745f2ca2
X2
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| hollegha2 | 0:9ac39e20730c | 1 | #include "mbed.h" | 
| hollegha2 | 0:9ac39e20730c | 2 | #include "Serial_HL.h" | 
| hollegha2 | 0:9ac39e20730c | 3 | |
| hollegha2 | 0:9ac39e20730c | 4 | SerialBLK pc(USBTX, USBRX); | 
| hollegha2 | 0:9ac39e20730c | 5 | SvProtocol ua0(&pc); | 
| hollegha2 | 0:9ac39e20730c | 6 | |
| hollegha2 | 0:9ac39e20730c | 7 | BusOut leds(LED1,LED2,LED3,LED4); | 
| hollegha2 | 0:9ac39e20730c | 8 | |
| hollegha2 | 0:9ac39e20730c | 9 | void CommandHandler(); | 
| hollegha2 | 0:9ac39e20730c | 10 | |
| hollegha2 | 0:9ac39e20730c | 11 | int main(void) | 
| hollegha2 | 0:9ac39e20730c | 12 | { | 
| hollegha2 | 0:9ac39e20730c | 13 | pc.format(8,SerialBLK::None,1); | 
| hollegha2 | 0:9ac39e20730c | 14 | pc.baud(115200); | 
| hollegha2 | 0:9ac39e20730c | 15 | leds = 9; | 
| hollegha2 | 0:9ac39e20730c | 16 | |
| hollegha2 | 0:9ac39e20730c | 17 | ua0.SvMessage("SvTest_Serial_HL"); // Meldung zum PC senden | 
| hollegha2 | 0:9ac39e20730c | 18 | |
| hollegha2 | 0:9ac39e20730c | 19 | int16_t sv1=0, sv2=100; | 
| hollegha2 | 0:9ac39e20730c | 20 | Timer stw; | 
| hollegha2 | 0:9ac39e20730c | 21 | stw.start(); | 
| hollegha2 | 0:9ac39e20730c | 22 | while(1) { | 
| hollegha2 | 0:9ac39e20730c | 23 | CommandHandler(); | 
| hollegha2 | 0:9ac39e20730c | 24 | if( ua0.acqON && (stw.read_ms()>100) ) { // 10Hz | 
| hollegha2 | 0:9ac39e20730c | 25 | // dieser Teil wird mit 10Hz aufgerufen | 
| hollegha2 | 0:9ac39e20730c | 26 | stw.reset(); | 
| hollegha2 | 0:9ac39e20730c | 27 | sv1++; | 
| hollegha2 | 0:9ac39e20730c | 28 | sv2++; | 
| hollegha2 | 0:9ac39e20730c | 29 | if( ua0.acqON ) { | 
| hollegha2 | 0:9ac39e20730c | 30 | // nur wenn vom PC aus das Senden eingeschaltet wurde | 
| hollegha2 | 0:9ac39e20730c | 31 | // wird auch etwas gesendet | 
| hollegha2 | 0:9ac39e20730c | 32 | ua0.WriteSvI16(1, sv1); | 
| hollegha2 | 0:9ac39e20730c | 33 | ua0.WriteSvI16(2, sv2); | 
| hollegha2 | 0:9ac39e20730c | 34 | } | 
| hollegha2 | 0:9ac39e20730c | 35 | } | 
| hollegha2 | 0:9ac39e20730c | 36 | } | 
| hollegha2 | 0:9ac39e20730c | 37 | return 1; | 
| hollegha2 | 0:9ac39e20730c | 38 | } | 
| hollegha2 | 0:9ac39e20730c | 39 | |
| hollegha2 | 0:9ac39e20730c | 40 | void CommandHandler() | 
| hollegha2 | 0:9ac39e20730c | 41 | { | 
| hollegha2 | 0:9ac39e20730c | 42 | uint8_t cmd; | 
| hollegha2 | 0:9ac39e20730c | 43 | int16_t idata1, idata2; | 
| hollegha2 | 0:9ac39e20730c | 44 | |
| hollegha2 | 0:9ac39e20730c | 45 | // Fragen ob überhaupt etwas im RX-Reg steht | 
| hollegha2 | 0:9ac39e20730c | 46 | if( !pc.IsDataAvail() ) | 
| hollegha2 | 0:9ac39e20730c | 47 | return; | 
| hollegha2 | 0:9ac39e20730c | 48 | |
| hollegha2 | 0:9ac39e20730c | 49 | // wenn etwas im RX-Reg steht | 
| hollegha2 | 0:9ac39e20730c | 50 | // Kommando lesen | 
| hollegha2 | 0:9ac39e20730c | 51 | cmd = ua0.GetCommand(); | 
| hollegha2 | 0:9ac39e20730c | 52 | |
| hollegha2 | 0:9ac39e20730c | 53 | if( cmd==2 ) { | 
| hollegha2 | 0:9ac39e20730c | 54 | // cmd2 hat 2 int16 Parameter | 
| hollegha2 | 0:9ac39e20730c | 55 | idata1 = ua0.ReadI16(); | 
| hollegha2 | 0:9ac39e20730c | 56 | idata2 = ua0.ReadI16(); | 
| hollegha2 | 0:9ac39e20730c | 57 | // für die Analyse den Wert einfach nur zum PC zurücksenden | 
| hollegha2 | 0:9ac39e20730c | 58 | ua0.SvPrintf("Command2 %d %d", idata1, idata2); | 
| hollegha2 | 0:9ac39e20730c | 59 | } | 
| hollegha2 | 0:9ac39e20730c | 60 | } | 
| hollegha2 | 0:9ac39e20730c | 61 | |
| hollegha2 | 0:9ac39e20730c | 62 |