This commit is contained in:
Stefano Calabretti
2022-02-17 18:55:16 +01:00
parent 607817389c
commit 2e4a409a92
7 changed files with 160 additions and 198 deletions
+39 -17
View File
@@ -2,15 +2,32 @@
#define INC_MMR_CAN_SCS_MANAGER_H_
#include "mmr_can.h"
#include "mmr_can_timer_scs.h"
/**
* TODO:
* - GetCurrentTime
* - ACK
* - Reset timer
* - Setup method
* Scs_timer represents the max number of counter
* that need to checked w/current time
*/
#ifndef MMR_CAN_SCS_ENTRIES_COUNT
#define MMR_CAN_SCS_ENTRIES_COUNT 5
#endif
/**
* @brief
* Maximum timeout before first retransmission,
* in milliseconds
*/
#ifndef MMR_CAN_MAX_TIMEOUT
#define MMR_CAN_MAX_TIMEOUT 500
#endif
/**
* It depends on how many bits the board devotes to the timer
* Check the datasheet
*/
typedef uint32_t TimerRange;
/**
@@ -18,20 +35,25 @@
* and allows to interface with the associated SCS's timer
*/
typedef struct {
MmrCanMessageId scsId;
CanId receiverId;
MmrCanHeader header;
TimerRange counter;
int rtr;
} RTRresponse;
} MmrCanScsEntry;
/**
* It is used to iterate the RTRresponse array in the CheckSCS function
*/
static int counter;
typedef enum {
MMR_CAN_SCS_CHECK_OK,
MMR_CAN_SCS_CHECK_RTR,
MMR_CAN_SCS_CHECK_ERROR,
} MmrCanScsCheckResult;
bool MMR_CAN_SetRTRresponse(MmrCanMessageId scsId, CanId receiverId, int rtr);
TimerRange MMR_CAN_GetCurrentTime();
void MMR_CAN_CheckSCS(); // What is necessary to do ritrasmission (mmr_can_send_scs)
bool MMR_CAN_MaybeHandleACK(MmrCanHeader header);
HalStatus MMR_CAN_HandleNextScs(CanHandle *hcan);
HalStatus MMR_CAN_SendSCS(
CanHandle *hcan,
MmrCanMessageId scsId,
CanId senderId
);
#endif // !INC_MMR_CAN_SCS_MANAGER_H_
#endif // !INC_MMR_CAN_SCS_MANAGER_H_