significant progress on frontend

This commit is contained in:
2020-11-01 18:48:39 +01:00
parent a2fba1f34d
commit 690ca7817e
3 changed files with 53 additions and 9 deletions

View File

@ -5,13 +5,16 @@
#include <loopCtrl.h>
#include <led.h>
#include <logger.h>
#include <frontend.h>
typedef enum {
IDLE,
SEND,
SEND_CONT,
SENDING
SENDING,
ENABLE_FRONTEND,
DISABLE_FRONTEND
} e_mbusCommState;
typedef struct {
@ -56,19 +59,34 @@ static void handleRequestEngine(void *handle) {
localMbusCommHandle->retryCnt = 0;
HAL_UART_Transmit_IT(&mbusUart, localMbusCommHandle->sendBuf, 5);
localMbusCommHandle->state = SENDING;
schAdd(handleRequestEngine, handle, 5, 0); // ask me again in 1ms in the next state ...
schAdd(handleRequestEngine, handle, 15, 0); // ask me again in 15ms in the next state ...
}
break;
case SENDING:
logMsg("hre state SENDING");
if (HAL_UART_GetState(&mbusUart) == HAL_UART_STATE_READY) { // ... whether I'm done
localMbusCommHandle->state = IDLE;
localMbusCommHandle->state = ENABLE_FRONTEND;
schAdd(handleRequestEngine, handle, 3, 0);
} else {
schAdd(handleRequestEngine, handle, 5, 0); // not yet done, ask me again in 1ms
schAdd(handleRequestEngine, handle, 1, 0); // not yet done, ask me again in 1ms
}
break;
case ENABLE_FRONTEND:
logMsg("hre state ENABLE_FRONTEND");
frontendEnable();
localMbusCommHandle->state = DISABLE_FRONTEND;
schAdd(handleRequestEngine, handle, 20, 0);
break;
case DISABLE_FRONTEND:
logMsg("hre state DISABLE_FRONTEND");
frontendDisable();
localMbusCommHandle->state = IDLE;
break;
default:
localMbusCommHandle->state = IDLE;
break;