![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Contains all code needed for analog digital and oscope
Diff: main.cpp
- Revision:
- 5:6b72bf1da751
- Parent:
- 4:374219f35b8e
- Child:
- 6:f2c589ad6241
diff -r 374219f35b8e -r 6b72bf1da751 main.cpp --- a/main.cpp Wed Apr 22 19:42:30 2020 +0000 +++ b/main.cpp Wed Apr 22 20:19:52 2020 +0000 @@ -26,8 +26,11 @@ #define ms1000 0b00000111 #define rise 0b00010000 #define fall 0b00000000 -#define timeMask 0b00001111 -#define trigger 0b00010000 +#define timeMask 0b00000111 +#define triggerType 0b00010000 +#define triggerVolt 0b00001000 +#define volt11 0b00000000 +#define volt22 0b00001000 DigitalOut myled(LED1); DigitalOut DigitalStatus(LED2); //Led for when Digital read is running @@ -69,6 +72,8 @@ volatile unsigned char oScopeArray[20000]; volatile int oScopeCount=0; volatile unsigned char oScopeTriggerType; +volatile unsigned char oScopeTriggerVoltageBit; +volatile unsigned char oScopeTriggerVoltageVal; void digital_sample_func(void) //sampling function, samples each pin specified and Ors it @@ -135,6 +140,8 @@ myled=1; unsigned char trig; int state =0; + if(oScopeTriggerVoltageBit == volt11){oScopeTriggerVoltageVal=85;} + else{oScopeTriggerVoltageVal=169;} while(nTriggered){ @@ -142,17 +149,17 @@ switch(state){ case 0: - if((trig < 85) & (oScopeTriggerType == rise) ){state = 1;} - else if((trig > 85) & (oScopeTriggerType == fall) ){state = 2;} + if((trig < oScopeTriggerVoltageVal) & (oScopeTriggerType == rise) ){state = 1;} + else if((trig > oScopeTriggerVoltageVal) & (oScopeTriggerType == fall) ){state = 2;} else { state = 0;} break; case 1: - if(trig < 85){state=1;} - if(trig > 85){state=3;} + if(trig < oScopeTriggerVoltageVal){state=1;} + if(trig > oScopeTriggerVoltageVal){state=3;} break; case 2: - if(trig > 85){state = 2;} - if(trig < 85){state = 3;} + if(trig > oScopeTriggerVoltageVal){state = 2;} + if(trig < oScopeTriggerVoltageVal){state = 3;} break; case 3: nTriggered=false; @@ -234,7 +241,8 @@ oScopeTime=command & timeMask; oScope_poll=true; oScopeStatus=1; - oScopeTriggerType= command & trigger; + oScopeTriggerType= command & triggerType; + oScopeTriggerVoltageBit = command & triggerVolt; break; } }