refactor(can): apply filters based on filter ID for standard or extended IDs instead of mask ID
Changes filter application logic to determine standard or extended filter based on the filter ID instead of the mask IDstable
parent
d722738591
commit
37c087aaed
|
|
@ -57,3 +57,26 @@ encoding//Debug/subdir_rules.mk=UTF-8
|
||||||
encoding//Debug/subdir_vars.mk=UTF-8
|
encoding//Debug/subdir_vars.mk=UTF-8
|
||||||
encoding//Debug/utils/subdir_rules.mk=UTF-8
|
encoding//Debug/utils/subdir_rules.mk=UTF-8
|
||||||
encoding//Debug/utils/subdir_vars.mk=UTF-8
|
encoding//Debug/utils/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/Core/Source/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/Core/Source/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/Generated\ Codes/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/Generated\ Codes/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/TM1650_SDK/src/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/TM1650_SDK/src/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_APP/src/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_APP/src/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_ECU/ivec_ecu_can/src/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_ECU/ivec_ecu_can/src/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_ECU/ivec_ecu_common/src/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_ECU/ivec_ecu_common/src/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_ECU/ivec_ecu_uart/src/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_ECU/ivec_ecu_uart/src/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_RTE/src/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_RTE/src/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/makefile=UTF-8
|
||||||
|
encoding//Test__GNU/objects.mk=UTF-8
|
||||||
|
encoding//Test__GNU/sources.mk=UTF-8
|
||||||
|
encoding//Test__GNU/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/utils/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/utils/subdir_vars.mk=UTF-8
|
||||||
|
|
|
||||||
|
|
@ -226,8 +226,8 @@ static const DL_MCAN_StdMsgIDFilterElement gMCAN0StdFiltelem1 = {
|
||||||
//static const DL_MCAN_StdMsgIDFilterElement gMCAN0StdFiltelem1 = {
|
//static const DL_MCAN_StdMsgIDFilterElement gMCAN0StdFiltelem1 = {
|
||||||
// .sfec = 001,
|
// .sfec = 001,
|
||||||
// .sft = 10,
|
// .sft = 10,
|
||||||
// .sfid1 = 0xc8,
|
// .sfid1 = 0x3ff,
|
||||||
// .sfid2 = 0x7fe,
|
// .sfid2 = 0x400,
|
||||||
//}; // apply mask pass only 200 and 201 id
|
//}; // apply mask pass only 200 and 201 id
|
||||||
|
|
||||||
static const DL_MCAN_StdMsgIDFilterElement gMCAN0StdFiltelem2 = {
|
static const DL_MCAN_StdMsgIDFilterElement gMCAN0StdFiltelem2 = {
|
||||||
|
|
@ -259,10 +259,10 @@ static const DL_MCAN_StdMsgIDFilterElement gMCAN0StdFiltelem5 = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const DL_MCAN_ExtMsgIDFilterElement gMCAN0ExtFiltelem1 = {
|
static const DL_MCAN_ExtMsgIDFilterElement gMCAN0ExtFiltelem1 = {
|
||||||
.efec = 0x1,
|
.efec = 001,
|
||||||
.eft = 0x0,
|
.eft = 10,
|
||||||
.efid1 = 2047,
|
.efid1 = 0x1fffff69,
|
||||||
.efid2 = 0x1FFFFFFF,
|
.efid2 = 0xff,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const DL_MCAN_ExtMsgIDFilterElement gMCAN0ExtFiltelem2 = {
|
static const DL_MCAN_ExtMsgIDFilterElement gMCAN0ExtFiltelem2 = {
|
||||||
|
|
@ -467,7 +467,7 @@ IVEC_McalStatus_e xMCAL_MCANInit(MCAN_Regs* MCAN, xCAN_baud_t BAUD)
|
||||||
DL_MCAN_msgRAMConfig(MCAN, (DL_MCAN_MsgRAMConfigParams*) &gMCAN0MsgRAMConfigParams);
|
DL_MCAN_msgRAMConfig(MCAN, (DL_MCAN_MsgRAMConfigParams*) &gMCAN0MsgRAMConfigParams);
|
||||||
|
|
||||||
/* Configure Standard ID filter element */
|
/* Configure Standard ID filter element */
|
||||||
// DL_MCAN_addStdMsgIDFilter(MCAN, 0U, (DL_MCAN_StdMsgIDFilterElement *) &gMCAN0StdFiltelem1);
|
//DL_MCAN_addStdMsgIDFilter(MCAN, 0U, (DL_MCAN_StdMsgIDFilterElement *) &gMCAN0StdFiltelem1);
|
||||||
//
|
//
|
||||||
///DL_MCAN_addStdMsgIDFilter(MCAN, 1U, (DL_MCAN_StdMsgIDFilterElement *) &gMCAN0StdFiltelem2);
|
///DL_MCAN_addStdMsgIDFilter(MCAN, 1U, (DL_MCAN_StdMsgIDFilterElement *) &gMCAN0StdFiltelem2);
|
||||||
//
|
//
|
||||||
|
|
@ -477,7 +477,7 @@ IVEC_McalStatus_e xMCAL_MCANInit(MCAN_Regs* MCAN, xCAN_baud_t BAUD)
|
||||||
//
|
//
|
||||||
// DL_MCAN_addStdMsgIDFilter(MCAN, 4U, (DL_MCAN_StdMsgIDFilterElement *) &gMCAN0StdFiltelem5);
|
// DL_MCAN_addStdMsgIDFilter(MCAN, 4U, (DL_MCAN_StdMsgIDFilterElement *) &gMCAN0StdFiltelem5);
|
||||||
//
|
//
|
||||||
// DL_MCAN_addExtMsgIDFilter(MCAN, 0U,(DL_MCAN_ExtMsgIDFilterElement *)&gMCAN0ExtFiltelem1);
|
//DL_MCAN_addExtMsgIDFilter(MCAN, 0U,(DL_MCAN_ExtMsgIDFilterElement *)&gMCAN0ExtFiltelem1);
|
||||||
//
|
//
|
||||||
// DL_MCAN_addExtMsgIDFilter(MCAN, 1U,(DL_MCAN_ExtMsgIDFilterElement *)&gMCAN0ExtFiltelem2);
|
// DL_MCAN_addExtMsgIDFilter(MCAN, 1U,(DL_MCAN_ExtMsgIDFilterElement *)&gMCAN0ExtFiltelem2);
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,23 @@ void vCanFilterMaskSaveVal(uint8_t ucIdx, uint32_t mask, bool isExtended)
|
||||||
{
|
{
|
||||||
maskCount = ucIdx;
|
maskCount = ucIdx;
|
||||||
maskValues[maskCount] = mask;
|
maskValues[maskCount] = mask;
|
||||||
|
// isExtendedID[maskCount++] = isExtended;
|
||||||
|
// if(isExtended)
|
||||||
|
// {
|
||||||
|
// extendedFilter++;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// standardFilter++;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void vCanFilterSaveVal(uint8_t ucIdx, uint32_t Filter, bool isExtended)
|
||||||
|
{
|
||||||
|
filterCount = ucIdx;
|
||||||
|
// Store filter value
|
||||||
|
filterValues[filterCount] = Filter;
|
||||||
isExtendedID[maskCount++] = isExtended;
|
isExtendedID[maskCount++] = isExtended;
|
||||||
if(isExtended)
|
if(isExtended)
|
||||||
{
|
{
|
||||||
|
|
@ -229,15 +246,7 @@ void vCanFilterMaskSaveVal(uint8_t ucIdx, uint32_t mask, bool isExtended)
|
||||||
{
|
{
|
||||||
standardFilter++;
|
standardFilter++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void vCanFilterSaveVal(uint8_t ucIdx, uint32_t Filter, bool isExtended)
|
|
||||||
{
|
|
||||||
filterCount = ucIdx;
|
|
||||||
// Store filter value
|
|
||||||
filterValues[filterCount] = Filter;
|
|
||||||
isExtendedID[filterCount++] = isExtended;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -274,17 +283,16 @@ void vCanConfigFilter() {
|
||||||
xECU_CanReInit(CANFD0,g_u16CanSpeed);
|
xECU_CanReInit(CANFD0,g_u16CanSpeed);
|
||||||
DL_MCAN_setOpMode(CANFD0, DL_MCAN_OPERATION_MODE_SW_INIT);
|
DL_MCAN_setOpMode(CANFD0, DL_MCAN_OPERATION_MODE_SW_INIT);
|
||||||
|
|
||||||
gMCAN0MsgRAMConfigParamsFiltered.lse = extendedFilter; //0; // Set dynamically based on actual filters
|
gMCAN0MsgRAMConfigParamsFiltered.lse = extendedFilter; //0; // Set dynamically based on actual filters
|
||||||
gMCAN0MsgRAMConfigParamsFiltered.lss = standardFilter; //1; // Set dynamically based on actual filters
|
gMCAN0MsgRAMConfigParamsFiltered.lss = standardFilter; //1; // Set dynamically based on actual filters
|
||||||
DL_MCAN_config(CANFD0, (DL_MCAN_ConfigParams*) &gMCAN0ConfigParamsFiltered);
|
DL_MCAN_config(CANFD0, (DL_MCAN_ConfigParams*) &gMCAN0ConfigParamsFiltered);
|
||||||
DL_MCAN_msgRAMConfig(CANFD0, (DL_MCAN_MsgRAMConfigParams*) &gMCAN0MsgRAMConfigParamsFiltered);
|
DL_MCAN_msgRAMConfig(CANFD0, (DL_MCAN_MsgRAMConfigParams*) &gMCAN0MsgRAMConfigParamsFiltered);
|
||||||
|
|
||||||
// maskCount = 1;
|
uint8_t extendedFilterNumber = 0;
|
||||||
// isExtendedID[0] = 0;
|
uint8_t stadardFilterNumber = 0;
|
||||||
// filterValues[0] = 0xc8;
|
|
||||||
// maskValues[0] = 0X7FE;
|
|
||||||
for (int i = 0; i < maskCount; i++) {
|
for (int i = 0; i < maskCount; i++) {
|
||||||
|
// filterValues[0] = 0x3ff;
|
||||||
|
// maskValues[0] = 0x400;
|
||||||
if (isExtendedID[i]) {
|
if (isExtendedID[i]) {
|
||||||
// Extended ID filter
|
// Extended ID filter
|
||||||
DL_MCAN_ExtMsgIDFilterElement extFilterElement;
|
DL_MCAN_ExtMsgIDFilterElement extFilterElement;
|
||||||
|
|
@ -293,6 +301,7 @@ void vCanConfigFilter() {
|
||||||
extFilterElement.efec = 001;
|
extFilterElement.efec = 001;
|
||||||
extFilterElement.eft = 10;
|
extFilterElement.eft = 10;
|
||||||
DL_MCAN_addExtMsgIDFilter(CANFD0, i, (DL_MCAN_StdMsgIDFilterElement *) &extFilterElement);
|
DL_MCAN_addExtMsgIDFilter(CANFD0, i, (DL_MCAN_StdMsgIDFilterElement *) &extFilterElement);
|
||||||
|
extendedFilterNumber++;
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -304,7 +313,8 @@ void vCanConfigFilter() {
|
||||||
// stdFilterElement.sfid2 = 0x7fe;
|
// stdFilterElement.sfid2 = 0x7fe;
|
||||||
stdFilterElement.sfec = 001;
|
stdFilterElement.sfec = 001;
|
||||||
stdFilterElement.sft = 10;
|
stdFilterElement.sft = 10;
|
||||||
DL_MCAN_addStdMsgIDFilter(CANFD0, i,(DL_MCAN_StdMsgIDFilterElement *) &stdFilterElement);
|
DL_MCAN_addStdMsgIDFilter(CANFD0, stadardFilterNumber,(DL_MCAN_StdMsgIDFilterElement *) &stdFilterElement);
|
||||||
|
stadardFilterNumber++;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -312,19 +322,16 @@ void vCanConfigFilter() {
|
||||||
/* Set Extended ID Mask. */
|
/* Set Extended ID Mask. */
|
||||||
DL_MCAN_setExtIDAndMask(CANFD0, (0x1FFFFFFFU));
|
DL_MCAN_setExtIDAndMask(CANFD0, (0x1FFFFFFFU));
|
||||||
/* Take MCAN out of the SW initialization mode */
|
/* Take MCAN out of the SW initialization mode */
|
||||||
DL_MCAN_setOpMode(CANFD0, DL_MCAN_OPERATION_MODE_NORMAL);
|
DL_MCAN_setOpMode(CANFD0, DL_MCAN_OPERATION_MODE_NORMAL);
|
||||||
|
|
||||||
// gMCAN0MsgRAMConfigParamsFiltered.lse = standardFilter; // Set dynamically based on actual filters
|
|
||||||
// gMCAN0MsgRAMConfigParamsFiltered.lss = extendedFilter; // Set dynamically based on actual filters
|
|
||||||
// DL_MCAN_config(CANFD0, (DL_MCAN_ConfigParams*) &gMCAN0ConfigParamsFiltered);
|
|
||||||
// DL_MCAN_msgRAMConfig(CANFD0, &gMCAN0MsgRAMConfigParamsFiltered);
|
|
||||||
|
|
||||||
// Reset counters after applying filters
|
// Reset counters after applying filters
|
||||||
maskCount = 0;
|
maskCount = 0;
|
||||||
filterCount = 0;
|
filterCount = 0;
|
||||||
|
extendedFilterNumber = 0;
|
||||||
// // Re-enable CAN after filters
|
stadardFilterNumber = 0;
|
||||||
//CANInitF(CANFD0,g_u16CanSpeed);
|
extendedFilter = 0;
|
||||||
|
standardFilter = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue