michael hollegha
/
DistSensTest
Dist Sensor Test
Fork of BertlTemplate2 by
DistSensTest.cpp@3:b00b6fca5c41, 2016-04-18 (annotated)
- Committer:
- hollegha2
- Date:
- Mon Apr 18 16:30:58 2016 +0000
- Revision:
- 3:b00b6fca5c41
- Parent:
- BertlTemplate.cpp@2:d24a3d2438a4
V1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hollegha2 | 0:fa9b473d690b | 1 | #include "mbed.h" |
hollegha2 | 0:fa9b473d690b | 2 | #include "Serial_HL.h" |
hollegha2 | 0:fa9b473d690b | 3 | #include "Bertl14.h" |
hollegha2 | 0:fa9b473d690b | 4 | #include "BertlObjects.h" |
hollegha2 | 0:fa9b473d690b | 5 | |
hollegha2 | 3:b00b6fca5c41 | 6 | SerialBLK pc(USBTX, USBRX); |
hollegha2 | 3:b00b6fca5c41 | 7 | SvProtocol ua0(&pc); |
hollegha2 | 3:b00b6fca5c41 | 8 | |
hollegha2 | 3:b00b6fca5c41 | 9 | void CommandHandler(); |
hollegha2 | 3:b00b6fca5c41 | 10 | |
hollegha2 | 2:d24a3d2438a4 | 11 | // main=2^0 LS ENC 2^2 |
hollegha2 | 2:d24a3d2438a4 | 12 | BusOut boardPow(p30, P1_6, P1_7); |
hollegha2 | 0:fa9b473d690b | 13 | |
hollegha2 | 0:fa9b473d690b | 14 | int main(void) |
hollegha2 | 0:fa9b473d690b | 15 | { |
hollegha2 | 3:b00b6fca5c41 | 16 | boardPow=1; |
hollegha2 | 3:b00b6fca5c41 | 17 | pc.format(8,SerialBLK::None,1); |
hollegha2 | 3:b00b6fca5c41 | 18 | pc.baud(115200); |
hollegha2 | 0:fa9b473d690b | 19 | InitBertl(); |
hollegha2 | 3:b00b6fca5c41 | 20 | pex.useISR=0; |
hollegha2 | 3:b00b6fca5c41 | 21 | leds=9; |
hollegha2 | 3:b00b6fca5c41 | 22 | wait(1.0); |
hollegha2 | 3:b00b6fca5c41 | 23 | leds=6; |
hollegha2 | 3:b00b6fca5c41 | 24 | |
hollegha2 | 3:b00b6fca5c41 | 25 | ua0.SvMessage("DistSensTest_4"); |
hollegha2 | 3:b00b6fca5c41 | 26 | |
hollegha2 | 3:b00b6fca5c41 | 27 | Timer stw; |
hollegha2 | 3:b00b6fca5c41 | 28 | stw.start(); |
hollegha2 | 3:b00b6fca5c41 | 29 | while(1) { |
hollegha2 | 3:b00b6fca5c41 | 30 | CommandHandler(); |
hollegha2 | 3:b00b6fca5c41 | 31 | if( ua0.acqON && (stw.read_ms()>10) ) { |
hollegha2 | 3:b00b6fca5c41 | 32 | stw.reset(); |
hollegha2 | 3:b00b6fca5c41 | 33 | if( ua0.acqON ) { |
hollegha2 | 3:b00b6fca5c41 | 34 | us.StartMeas(); // for next cycle |
hollegha2 | 3:b00b6fca5c41 | 35 | ua0.WriteSvI16(1, us.distCM*100.0); |
hollegha2 | 3:b00b6fca5c41 | 36 | } |
hollegha2 | 3:b00b6fca5c41 | 37 | } |
hollegha2 | 0:fa9b473d690b | 38 | } |
hollegha2 | 0:fa9b473d690b | 39 | return 1; |
hollegha2 | 0:fa9b473d690b | 40 | } |
hollegha2 | 0:fa9b473d690b | 41 | |
hollegha2 | 3:b00b6fca5c41 | 42 | void CommandHandler() |
hollegha2 | 3:b00b6fca5c41 | 43 | { |
hollegha2 | 3:b00b6fca5c41 | 44 | uint8_t cmd; |
hollegha2 | 3:b00b6fca5c41 | 45 | if( !pc.IsDataAvail() ) |
hollegha2 | 3:b00b6fca5c41 | 46 | return; |
hollegha2 | 3:b00b6fca5c41 | 47 | cmd = ua0.GetCommand(); |
hollegha2 | 3:b00b6fca5c41 | 48 | } |
hollegha2 | 0:fa9b473d690b | 49 |