From 628bbd78250792acefeed5103c78ec13b9e8e641 Mon Sep 17 00:00:00 2001 From: Klagarge Date: Tue, 5 Sep 2023 17:43:26 +0200 Subject: [PATCH] add bietfield for steering --- 306-controller_interface.X/app/can_message.c | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/306-controller_interface.X/app/can_message.c b/306-controller_interface.X/app/can_message.c index 5703115..ad7d86c 100644 --- a/306-controller_interface.X/app/can_message.c +++ b/306-controller_interface.X/app/can_message.c @@ -29,6 +29,31 @@ typedef union { uint16_t full; } BYTES_2; +typedef union{ + uint16_t data; + struct{ + uint8_t data[2]; + }byteSplit; + struct{ + unsigned b0:1; + unsigned b1:1; + unsigned b2:1; + unsigned b3:1; + unsigned b4:1; + unsigned b5:1; + unsigned b6:1; + unsigned b7:1; + unsigned b8:1; + unsigned b9:1; + unsigned b10:1; + unsigned b11:1; + unsigned b12:1; + unsigned b13:1; + unsigned b14:1; + unsigned b15:1; + }bitSplit; +} BITFIELD16; + void CM_processIncome(uint8_t idSender, uint8_t idMsg, bool rtr, uint32_t data){ BYTES_4 incomeData; incomeData.full = data; @@ -37,6 +62,8 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, bool rtr, uint32_t data){ revertData.separate.byte1 = incomeData.separate.byte2; revertData.separate.byte2 = incomeData.separate.byte1; revertData.separate.byte3 = incomeData.separate.byte0; + BITFIELD16 bField; + bField.data = (uint16_t) data; switch(idSender){ @@ -241,7 +268,14 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, bool rtr, uint32_t data){ KART_CST.STEERING_ALIVE_TIME = MEM_read_1_byte(MEMADD_STEERING_ALIVE_TIME); ALIVE_emitResurrect(&steering()->myChecker, 500, 0); ALIVE_emitBorn(&steering()->myChecker, 1000, 0); + ALIVE_emitReady(&steering()->myChecker, 5000, 0); } + if(bField.bitSplit.b4) { + if (steering()->myChecker.state == STAL_BORN){ + //ALIVE_emitReady(&steering()->myChecker, 1000, 0); + } + } + } break;