From: Michal Horn Date: Tue, 26 Aug 2014 08:40:36 +0000 (+0200) Subject: Fixed bug in CAN configuration, fiiltering settings X-Git-Tag: rm48-exp-before-uncrustify~65 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/pes-rpp/rpp-lib.git/commitdiff_plain/a088872092f6497ff1b27d5c361bdd7b9eb2fe4a Fixed bug in CAN configuration, fiiltering settings This bug caused the message filtering malfunction when mask was defined. Now the standart, extended and mixed message ID filtering with mask definition is supported. When mixed is selected, only he higher bits of the Mask and ID registers are used. --- diff --git a/rpp/src/rpp/can.c b/rpp/src/rpp/can.c index 0a1847a..f184569 100644 --- a/rpp/src/rpp/can.c +++ b/rpp/src/rpp/can.c @@ -184,7 +184,17 @@ static int8_t init_tx_box(struct rpp_can_tx_config cfg) /** * 31 Set whether use of std/ext ID should have effect on acceptance filtering */ - controller->IF1MSK = ((cfg.type == RPP_CAN_MIXED ? 0 : 1) << 31); + switch (cfg.type) { + case RPP_CAN_STANDARD: + controller->IF1MSK = 0 << 31; + break; + case RPP_CAN_MIXED: + controller->IF1MSK = 1 << 31; + break; + case RPP_CAN_EXTENDED: + controller->IF1MSK = 1 << 31; + break; + } /** * 31 Message object is valid @@ -233,8 +243,17 @@ static int8_t init_rx_box(struct rpp_can_rx_config cfg) * 31 Set whether use of std/ext ID should have effect on acceptance filtering * 28-1 Set mask */ - controller->IF2MSK = ((cfg.type == RPP_CAN_MIXED ? 0 : 1U) << 31) - | cfg.mask; + switch (cfg.type) { + case RPP_CAN_STANDARD: + controller->IF2MSK = (1 << 31) | (cfg.mask << 18); + break; + case RPP_CAN_MIXED: + controller->IF2MSK = (0 << 31) | cfg.mask; + break; + case RPP_CAN_EXTENDED: + controller->IF2MSK = (1 << 31) | cfg.mask; + break; + } /** * 31 Message object is valid @@ -242,11 +261,10 @@ static int8_t init_rx_box(struct rpp_can_rx_config cfg) * 29 Direction is read * 28-18 / 28-1 Object ID */ - controller->IF2ARB = (1U << 31) + controller->IF2ARB = (1U << 31) // MsgVal | ((cfg.type == RPP_CAN_STANDARD ? 0 : 1) << 30) - | (0 << 29) + | (0 << 29) // Dir | cfg.id << (cfg.type == RPP_CAN_STANDARD ? 18 : 0); - /** * 12 Use mask for filtering * 7 End of buffer