Refined CAN Settings Logic in the Code #37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request improves the logic related to CAN configuration, specifically correcting the misuse of mask settings and simplifying the setup for message objects. The changes include:
Modification 1: The
CAN_SetRxMsgObj
function no longer incorrectly sets theUMASK
bit in theCAN_IFn_MCON
register, aligning with the chip manual's guidance.Modification 2: The
CAN_SetRxMsgObjAndMsk
function has been updated for clarity, making the setup for standard and extended frame IDs more intuitive.Before and After:
Standard ID Setup:
CAN_SetRxMsgObjAndMsk(tCAN, MSG(0), CAN_STD_ID, 0x003, (0x00F << 2) << 16, TRUE);
CAN_SetRxMsgObjAndMsk(tCAN, MSG(0), CAN_STD_ID, 0x003, 0x00F, TRUE);
Extended ID Setup:
CAN_SetRxMsgObjAndMsk(tCAN, MSG(0), CAN_EXT_ID, 0x00000003, CAN_IF_MASK2_MXTD_Msk | 0x0000000F, TRUE);
CAN_SetRxMsgObjAndMsk(tCAN, MSG(0), CAN_EXT_ID. 0x00000003, 0x0000000F, TRUE);
These updates ensure the CAN configuration is both correct and user-friendly, adhering closely to the intended design and documentation.