David Salmon
/
ES_CW2_Starter_MDMA
ES2017 coursework 2
Fork of ES_CW2_Starter by
Diff: main.cpp
- Revision:
- 23:d48d51e5db97
- Parent:
- 22:1c329584282b
- Child:
- 24:4032857546f4
--- a/main.cpp Fri Mar 10 18:53:47 2017 +0000 +++ b/main.cpp Fri Mar 10 19:53:08 2017 +0000 @@ -123,6 +123,7 @@ { //revsec set to zero prevents recurring interrupt for constant speed revsec = 0; + wait(spinWait); //0x2A turns all motor transistors off to prevent any power usage motor = 0x2A; } @@ -148,13 +149,15 @@ void fixedSpeed() { - intState = readRotorState(); - //Increment state machine to next state - motorOut(intState); //If spinning is required, attach the necessary wait to the //timeout interrupt to call this function again and //keep the motor spinning at the right speed if(revsec) spinTimer.attach(&fixedSpeed, spinWait); + + intState = readRotorState(); + //Increment state machine to next state + motorOut(intState); + } //void spinToPos() @@ -467,6 +470,7 @@ //Print error message motorStop(); pc.printf("Error in received data 0\n\r"); + motorStop(); break; } }