fix can receive part for SM
This commit is contained in:
		| @@ -30,7 +30,7 @@ void CANINTERFACE_newMsg() { | ||||
|     data = canMsg.frame.data2; | ||||
|     data = data<<8; | ||||
|     data = canMsg.frame.data3; | ||||
|     POST(&CANINTERFACE_myself, &CANINTERFACE_processEvent, evCAinit, 0, data); | ||||
|     POST(&CANINTERFACE_myself, &CANINTERFACE_processEvent, evCAnewMsg, 0, data); | ||||
| } | ||||
| 
 | ||||
| bool CANINTERFACE_processEvent(Event* ev) { | ||||
| @@ -47,14 +47,21 @@ bool CANINTERFACE_processEvent(Event* ev) { | ||||
|     switch (me->state) {        // onState
 | ||||
|         case STCA_INIT: | ||||
|             if (ev->id == evCAinit) { | ||||
|                  | ||||
|                 me->state = STCA_WAIT; | ||||
|             } | ||||
|             break; | ||||
|          | ||||
|         case STCA_WAIT: | ||||
|             if (ev->id == evCAnewMsg) { | ||||
|                 me->state = STCA_READ; | ||||
|                 CANINTERFACE_emitDone(0); | ||||
|             } | ||||
|             break; | ||||
|          | ||||
|         case STCA_READ: | ||||
|             if (ev->id == evCAdone) { | ||||
|                 me->state = STCA_WAIT; | ||||
|             } | ||||
|             break; | ||||
|     } | ||||
| 
 | ||||
| @@ -121,3 +128,7 @@ void CANINTERFACE_onProcessCan(CANINTERFACE_CALLBACK_CAN f) { | ||||
| void CANINTERFACE_emitNewMsg(uint16_t t) { | ||||
|     POST(&CANINTERFACE_myself, &CANINTERFACE_processEvent, evCAnewMsg, t, 0); | ||||
| } | ||||
| 
 | ||||
| void CANINTERFACE_emitDone(uint16_t t) { | ||||
|     POST(&CANINTERFACE_myself, &CANINTERFACE_processEvent, evCAdone, t, 0); | ||||
| } | ||||
| @@ -7,7 +7,7 @@ | ||||
| #ifndef CANINTERFACE_H | ||||
| #define CANINTERFACE_H | ||||
| 
 | ||||
| #include "../xf/xf.h" | ||||
| #include "../../xf/xf.h" | ||||
| 
 | ||||
| typedef enum { | ||||
|     STCA_INIT, | ||||
| @@ -45,7 +45,6 @@ void CANINTERFACE_init(); | ||||
| 
 | ||||
| /**
 | ||||
|  * Start the CANINTERFACE state machine | ||||
|  * @param me the CANINTERFACE itself | ||||
|  */ | ||||
| void CANINTERFACE_startBehaviour(); | ||||
| 
 | ||||
| @@ -68,7 +67,6 @@ bool CANINTERFACE_processEvent(Event* ev); | ||||
| 
 | ||||
| /**
 | ||||
|  * Set the callback function to call when the CANINTERFACE is entering state wait | ||||
|  * @param me the CANINTERFACE itself | ||||
|  * @param f the function to call | ||||
|  * @param p the param(s) to pass to the function | ||||
|  */ | ||||
| @@ -76,7 +74,6 @@ void CANINTERFACE_onWait(CANINTERFACE_CALLBACK_FUNCTION f, void* p); | ||||
| 
 | ||||
| /**
 | ||||
|  * Set the callback function to call when the CANINTERFACE is entering state read | ||||
|  * @param me the CANINTERFACE itself | ||||
|  * @param f the function to call | ||||
|  * @param p the param(s) to pass to the function | ||||
|  */ | ||||
| @@ -94,8 +91,14 @@ void CANINTERFACE_onProcessCan(CANINTERFACE_CALLBACK_CAN f); | ||||
| 
 | ||||
| /**
 | ||||
|  * Emit the NewMsg event | ||||
|  * @param me the CANINTERFACE itself | ||||
|  * @param t time to wait in ms before triggering event | ||||
|  */void CANINTERFACE_emitNewMsg(uint16_t t); | ||||
|  */ | ||||
| void CANINTERFACE_emitNewMsg(uint16_t t); | ||||
|       | ||||
| /**
 | ||||
|  * Emit the Done event | ||||
|  * @param t time to wait in ms before triggering event | ||||
|  */ | ||||
| void CANINTERFACE_emitDone(uint16_t t); | ||||
| 
 | ||||
| #endif | ||||
		Reference in New Issue
	
	Block a user