Implementation of spacecraft launch specification
Fork of Accelerometer_example by
Revision 4:86592f025a07, committed 2018-02-22
- Comitter:
- natgovor
- Date:
- Thu Feb 22 16:41:00 2018 +0000
- Parent:
- 3:f8a95cb07150
- Commit message:
- added final comments
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f8a95cb07150 -r 86592f025a07 main.cpp --- a/main.cpp Wed Feb 21 21:15:02 2018 +0000 +++ b/main.cpp Thu Feb 22 16:41:00 2018 +0000 @@ -11,6 +11,10 @@ enum states { flat, right, left, down, up, over, intermediate }; +// Had to implement with shared variable because with mailbox it did not work +volatile states accState = intermediate; // code for shared variable implementation + +// code for Mail implementation, not working // Message type /*typedef struct { states accState; // Accelerometer state @@ -21,14 +25,6 @@ Serial pc(USBTX, USBRX); // tx, rx -volatile states accState = intermediate; - -/*Timeout timeoutFunc; - -void timerError() { - pc.printf("Timer error"); -}*/ - void stateOfTrigger() { DigitalOut redLed(LED1); DigitalOut greenLed(LED2); @@ -38,9 +34,10 @@ redLed = 1; greenLed = 1; systemStates state = flat_start; - //states accState = flat; + //states accState = flat; // code for Mail implementation, not working while (true) { + // code for Mail implementation, not working correctly /*osEvent evt = mailbox.get(); // wait for mail if (evt.status == osEventMail) { message_t* mess = (message_t*)evt.value.p ; @@ -197,7 +194,6 @@ pc.printf("MMA8451 ID: %d\n\r", acc.getWhoAmI()); while (true) { - //pc.printf("Main thread\n\r"); float x, y, z; x = acc.getAccX(); y = acc.getAccY(); @@ -256,12 +252,13 @@ pc.printf("over\n\r"); break; } + // code for Mail implementation, not working /*message_t *mess = mailbox.alloc(); if (mess) { mess->accState = state; mailbox.put(mess); }*/ - accState = state; + accState = state; // code for shared variable implementation } Thread::wait(200);