BULME_AHEL20
/
LPC_HL_FUNC_GENERATOR_DAC
Function generator
ProcVisDemo.cpp@1:e88b745f2ca2, 2015-10-09 (annotated)
- Committer:
- hollegha2
- Date:
- Fri Oct 09 07:58:26 2015 +0000
- Revision:
- 1:e88b745f2ca2
- Parent:
- 0:9ac39e20730c
V2.0
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 | 1:e88b745f2ca2 | 7 | // V2.0 |
hollegha2 | 1:e88b745f2ca2 | 8 | // BusOut leds(LED1,LED2,LED3,LED4); Bertl14 |
hollegha2 | 1:e88b745f2ca2 | 9 | // M0-Board |
hollegha2 | 1:e88b745f2ca2 | 10 | BusOut leds(P1_13,P1_12,P1_7,P1_6,P1_4,P1_3,P1_1,P1_0,LED4,LED3,LED2,LED1); |
hollegha2 | 1:e88b745f2ca2 | 11 | |
hollegha2 | 0:9ac39e20730c | 12 | |
hollegha2 | 0:9ac39e20730c | 13 | void CommandHandler(); |
hollegha2 | 0:9ac39e20730c | 14 | |
hollegha2 | 0:9ac39e20730c | 15 | int main(void) |
hollegha2 | 0:9ac39e20730c | 16 | { |
hollegha2 | 0:9ac39e20730c | 17 | pc.format(8,SerialBLK::None,1); |
hollegha2 | 0:9ac39e20730c | 18 | pc.baud(115200); |
hollegha2 | 0:9ac39e20730c | 19 | leds = 9; |
hollegha2 | 0:9ac39e20730c | 20 | |
hollegha2 | 0:9ac39e20730c | 21 | ua0.SvMessage("SvTest_Serial_HL"); // Meldung zum PC senden |
hollegha2 | 0:9ac39e20730c | 22 | |
hollegha2 | 0:9ac39e20730c | 23 | int16_t sv1=0, sv2=100; |
hollegha2 | 0:9ac39e20730c | 24 | Timer stw; |
hollegha2 | 0:9ac39e20730c | 25 | stw.start(); |
hollegha2 | 0:9ac39e20730c | 26 | while(1) { |
hollegha2 | 0:9ac39e20730c | 27 | CommandHandler(); |
hollegha2 | 0:9ac39e20730c | 28 | if( ua0.acqON && (stw.read_ms()>100) ) { // 10Hz |
hollegha2 | 0:9ac39e20730c | 29 | // dieser Teil wird mit 10Hz aufgerufen |
hollegha2 | 0:9ac39e20730c | 30 | stw.reset(); |
hollegha2 | 0:9ac39e20730c | 31 | sv1++; |
hollegha2 | 0:9ac39e20730c | 32 | sv2++; |
hollegha2 | 0:9ac39e20730c | 33 | if( ua0.acqON ) { |
hollegha2 | 0:9ac39e20730c | 34 | // nur wenn vom PC aus das Senden eingeschaltet wurde |
hollegha2 | 0:9ac39e20730c | 35 | // wird auch etwas gesendet |
hollegha2 | 0:9ac39e20730c | 36 | ua0.WriteSvI16(1, sv1); |
hollegha2 | 0:9ac39e20730c | 37 | ua0.WriteSvI16(2, sv2); |
hollegha2 | 0:9ac39e20730c | 38 | } |
hollegha2 | 0:9ac39e20730c | 39 | } |
hollegha2 | 0:9ac39e20730c | 40 | } |
hollegha2 | 0:9ac39e20730c | 41 | return 1; |
hollegha2 | 0:9ac39e20730c | 42 | } |
hollegha2 | 0:9ac39e20730c | 43 | |
hollegha2 | 0:9ac39e20730c | 44 | void CommandHandler() |
hollegha2 | 0:9ac39e20730c | 45 | { |
hollegha2 | 0:9ac39e20730c | 46 | uint8_t cmd; |
hollegha2 | 0:9ac39e20730c | 47 | int16_t idata1, idata2; |
hollegha2 | 0:9ac39e20730c | 48 | |
hollegha2 | 0:9ac39e20730c | 49 | // Fragen ob überhaupt etwas im RX-Reg steht |
hollegha2 | 0:9ac39e20730c | 50 | if( !pc.IsDataAvail() ) |
hollegha2 | 0:9ac39e20730c | 51 | return; |
hollegha2 | 0:9ac39e20730c | 52 | |
hollegha2 | 0:9ac39e20730c | 53 | // wenn etwas im RX-Reg steht |
hollegha2 | 0:9ac39e20730c | 54 | // Kommando lesen |
hollegha2 | 0:9ac39e20730c | 55 | cmd = ua0.GetCommand(); |
hollegha2 | 0:9ac39e20730c | 56 | |
hollegha2 | 0:9ac39e20730c | 57 | if( cmd==2 ) { |
hollegha2 | 0:9ac39e20730c | 58 | // cmd2 hat 2 int16 Parameter |
hollegha2 | 0:9ac39e20730c | 59 | idata1 = ua0.ReadI16(); |
hollegha2 | 0:9ac39e20730c | 60 | idata2 = ua0.ReadI16(); |
hollegha2 | 0:9ac39e20730c | 61 | // für die Analyse den Wert einfach nur zum PC zurücksenden |
hollegha2 | 0:9ac39e20730c | 62 | ua0.SvPrintf("Command2 %d %d", idata1, idata2); |
hollegha2 | 0:9ac39e20730c | 63 | } |
hollegha2 | 0:9ac39e20730c | 64 | } |
hollegha2 | 0:9ac39e20730c | 65 | |
hollegha2 | 0:9ac39e20730c | 66 |