Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refined CAN Settings Logic in the Code #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MaRuolang
Copy link

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 the UMASK bit in the CAN_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:

    • Before: CAN_SetRxMsgObjAndMsk(tCAN, MSG(0), CAN_STD_ID, 0x003, (0x00F << 2) << 16, TRUE);
    • After: CAN_SetRxMsgObjAndMsk(tCAN, MSG(0), CAN_STD_ID, 0x003, 0x00F, TRUE);
  • Extended ID Setup:

    • Before: CAN_SetRxMsgObjAndMsk(tCAN, MSG(0), CAN_EXT_ID, 0x00000003, CAN_IF_MASK2_MXTD_Msk | 0x0000000F, TRUE);
    • After: 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.

1. Remove incorrect UMask bit setting in CAN_IFn_MCON within CAN_SetRxMsgObj.
2. Align CAN_IFn_MASK setting logic with CAN_IFn_ARB in CAN_SetRxMsgObjAndMsk.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant