Merge pull request #3 from SummerSchool2023-RED/hotfix/can-filters

fix CAN filters
This commit is contained in:
Rémi Heredero 2023-08-25 09:16:30 +02:00 committed by GitHub
commit c2a399d15c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 58 deletions

View File

@ -109,26 +109,39 @@ void ECAN_Initialize(void)
........................................................
........................................................
*/
// mask 0 is 11 bits for filter 0 and 1
/*
* Mask 0 is 11 bits for filters 0 and 1 only
* filter set for 3 recipient bits
* Mask 1 is copy of mask 0 but for other filters
*/
convertCANid2Reg(0x070, dSTANDARD_CAN_MSG_ID_2_0B, &RXM0EIDH, &RXM0EIDL, &RXM0SIDH, &RXM0SIDL);
// filter 0 and 1 is broadcast message
convertCANid2Reg(0x070, dSTANDARD_CAN_MSG_ID_2_0B, &RXM1EIDH, &RXM1EIDL, &RXM1SIDH, &RXM1SIDL);
// filter 0 is broadcast message
convertCANid2Reg(0x000, dSTANDARD_CAN_MSG_ID_2_0B, &RXF0EIDH, &RXF0EIDL, &RXF0SIDH, &RXF0SIDL);
// filter 1 is message for controller
convertCANid2Reg(0x010, dSTANDARD_CAN_MSG_ID_2_0B, &RXF1EIDH, &RXF1EIDL, &RXF1SIDH, &RXF1SIDL);
// filter 2 is message for recipient n°7, not yet defined
convertCANid2Reg(0x070, dSTANDARD_CAN_MSG_ID_2_0B, &RXF2EIDH, &RXF2EIDL, &RXF2SIDH, &RXF2SIDL);
/**
Enable Filters
*/
RXFCON0 = 0x01; // Filter 0 is activated
RXFCON1 = 0x00;
/*
* ENABLE FILTERS
*
* Filter 0 set on mask 0
* Filter 1 set on mask 0
* Filter 2 set on mask 1
*/
RXFCON0 = 0x07;
/**
Assign Filters to Masks
*/
MSEL0 = 0x00; // filter 0 is assigned to mask 0
MSEL1 = 0x00;
MSEL2 = 0x00;
MSEL3 = 0x00;
// Filter 0 & 1 assigned to mask 0 and filter 2 assigned to mask 1
MSEL0 = 0x10;
/**
Initialize CAN Timings

View File

@ -85,9 +85,9 @@ bool CAN_processEvent(Event* ev) {
// Send a message
if (ev->id == evCAsend) {
uCAN_MSG canMsg;
canMsg.frame.idType = 0; // I don't understand what is it
canMsg.frame.dlc = 4; // 4 bytes to send
canMsg.frame.rtr = 0; // no remote frame
canMsg.frame.idType = dSTANDARD_CAN_MSG_ID_2_0B; // standard
canMsg.frame.dlc = 4; // 4 bytes to send
canMsg.frame.rtr = 0; // no remote frame
canMsg.frame.data3 = (uint8_t) data;
data = data >> 8;
canMsg.frame.data2 = (uint8_t) data;

View File

@ -210,6 +210,7 @@
<property key="debugoptions.debug-startup" value="Use system settings"/>
<property key="debugoptions.reset-behaviour" value="Use system settings"/>
<property key="debugoptions.useswbreakpoints" value="false"/>
<property key="firmware.download.all" value="false"/>
<property key="hwtoolclock.frcindebug" value="false"/>
<property key="memories.aux" value="false"/>
<property key="memories.bootflash" value="true"/>

File diff suppressed because one or more lines are too long