Refactor
This commit is contained in:
+1
-3
@@ -8,7 +8,7 @@
|
||||
#include "mmr_can_types.h"
|
||||
#include "mmr_can_optimize.h"
|
||||
#include "mmr_can_binary_literals.h"
|
||||
#include "mmr_can_timer_scs.h"
|
||||
#include "mmr_can_scs_manager.h"
|
||||
|
||||
#ifndef MMR_CAN_RX_FIFO
|
||||
#define MMR_CAN_RX_FIFO CAN_RX_FIFO0
|
||||
@@ -163,6 +163,4 @@ MmrCanFilterSettings MMR_CAN_GetDefaultFilterSettings();
|
||||
HalStatus MMR_CAN_Send(CanHandle *hcan, MmrCanPacket packet);
|
||||
HalStatus MMR_CAN_Receive(CanHandle *hcan, MmrCanMessage *result);
|
||||
|
||||
HalStatus MMR_CAN_SendSCS(CanHandle *hcan, MmrCanMessageId scsId, CanMailbox *mailbox, CanId senderId);
|
||||
|
||||
#endif /* INC_MMR_CAN_H_ */
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* Constants with lower values have an higher priority.
|
||||
*/
|
||||
typedef enum {
|
||||
MMR_CAN_MESSAGE_ACK = B_(0001),
|
||||
MMR_CAN_MESSAGE_TYPE_ACK = B_(0001),
|
||||
MMR_CAN_MESSAGE_TYPE_MULTI_FRAME = B_(0010),
|
||||
MMR_CAN_MESSAGE_TYPE_MULTI_FRAME_END = B_(0011),
|
||||
MMR_CAN_MESSAGE_TYPE_NORMAL = B_(0100),
|
||||
|
||||
+39
-17
@@ -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_
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
#ifndef INC_MMR_CAN_TIMER_SCS_H_
|
||||
#define INC_MMR_CAN_TIMER_SCS_H_
|
||||
|
||||
#include "mmr_can_message_id.h"
|
||||
#include "mmr_can_types.h"
|
||||
|
||||
/**
|
||||
* Scs_timer represents the max number of counter
|
||||
* that need to checked w/current time
|
||||
*/
|
||||
#ifndef MMR_SCS_NR_TIMERS
|
||||
#define MMR_SCS_NR_TIMERS 5
|
||||
#endif
|
||||
|
||||
/**
|
||||
* It depends on how many bits the board devotes to the timer
|
||||
* Check the datasheet
|
||||
*/
|
||||
typedef uint32_t TimerRange;
|
||||
|
||||
typedef struct {
|
||||
MmrCanMessageId scsId;
|
||||
CanId receiverId;
|
||||
TimerRange counter;
|
||||
} MmrTimerSCS;
|
||||
|
||||
|
||||
/**
|
||||
* All time units are to be considered as milliseconds (1ms)
|
||||
*/
|
||||
bool MMR_CAN_ClearTimerSCS(MmrCanMessageId scsId, CanId receiverId);
|
||||
bool MMR_CAN_SetTimerSCS(MmrCanMessageId scsId, CanId receiverId, TimerRange currentTime);
|
||||
|
||||
/**
|
||||
* @brief The delay is taken individually so that the 'manager'
|
||||
* can first check the ACK and eventually reset the associated arr_timer
|
||||
*
|
||||
* @param rtrResponse the 'manager' will have to manage an array of struct RTRresponse
|
||||
* @param currentTime from __HAL_TIM_GET_COUNTER(&htimX) or directly from the CNT register
|
||||
* @param thresholdDelay by rules 500ms
|
||||
*/
|
||||
bool MMR_CAN_GetTimerSCS(MmrCanMessageId scsId, CanId receiverId, int *rtr, TimerRange currentTime, TimerRange thresholdDelay);
|
||||
|
||||
|
||||
#endif // !INC_MMR_CAN_TIMER_SCS_H_
|
||||
Reference in New Issue
Block a user