--- a/drivers/hcs12/canOpenDriver.c Tue May 16 17:18:56 2006 +0200
+++ b/drivers/hcs12/canOpenDriver.c Tue May 16 17:21:14 2006 +0200
@@ -28,11 +28,11 @@
#include "../include/hcs12/asm-m68hc12/portsaccess.h"
#include "../include/hcs12/asm-m68hc12/ports_def.h"
#include "../include/hcs12/asm-m68hc12/ports.h"
+#include "../include/data.h"
#include "../include/hcs12/applicfg.h"
#include "../include/hcs12/candriver.h"
#include "../include/hcs12/interrupt.h"
#include "../include/hcs12/canOpenDriver.h"
-
#include "../include/can.h"
#include "../include/objdictdef.h"
#include "../include/timer.h"
@@ -247,6 +247,22 @@
}
/***************************************************************************/
+char canChangeFilter(UNS16 adrCAN, canBusFilterInit fi)
+{
+ /* If not in init mode, go to sleep before going in init mode*/
+ if (! canTestInitMode(adrCAN)) {
+ canSleepMode(adrCAN);
+ canInitMode(adrCAN);
+ }
+ //update the filters configuration
+ canInitFilter(adrCAN, fi);
+ canInitModeQ(adrCAN);
+ canSleepModeQ(adrCAN);
+ canSetInterrupt(adrCAN);
+ return 0;
+}
+
+/***************************************************************************/
char canEnable(UNS16 adrCAN)
{
/* Register CANCTL1
@@ -287,8 +303,7 @@
/* rxfrm is cleared, mupe also (should be before)*/
IO_PORTS_8(adrCAN + CANCTL0) &= 0x53; /* Clr the bits that may be modified */
IO_PORTS_8(adrCAN + CANCTL0) = (bi.cswai << 5) | (bi.time << 3);
- IO_PORTS_8(adrCAN + CANRIER) = 0X01; /* Allow interruptions on receive */
- IO_PORTS_8(adrCAN + CANTIER) = 0X00; /* disallow interruptions on transmit */
+ canSetInterrupt(adrCAN);
canInitModeQ(adrCAN); /* Leave the init mode */
canSleepModeQ(adrCAN); /* Leave the sleep mode */
return 0;
@@ -427,6 +442,13 @@
}
/***************************************************************************/
+char canSetInterrupt(UNS16 adrCAN)
+{
+ IO_PORTS_8(adrCAN + CANRIER) = 0X01; /* Allow interruptions on receive */
+ IO_PORTS_8(adrCAN + CANTIER) = 0X00; /* disallow interruptions on transmit */
+ return 0;
+}
+/***************************************************************************/
char canSleepMode(UNS16 adrCAN)
{
IO_PORTS_8(adrCAN + CANCTL0) &= 0xFB; /* clr the bit WUPE to avoid a wake-up*/
@@ -562,7 +584,7 @@
IO_PORTS_8(CAN0 + CANRFLG) |= 0x01;
// Not very usefull
IO_PORTS_8(CAN0 + CANCTL0) |= 0x80;
- IO_PORTS_8(PORTB) |= 0x40; // led 6 port B : ON
+ IO_PORTS_8(PORTB) |= 0x40; // led 6 port B : OFF
unlock();
}
--- a/include/hcs12/candriver.h Tue May 16 17:18:56 2006 +0200
+++ b/include/hcs12/candriver.h Tue May 16 17:21:14 2006 +0200
@@ -168,6 +168,7 @@
extern canBusInit bi;
+
/*
For the received messsage, add a Identificator to
the list of ID to accept.
@@ -189,6 +190,12 @@
);
/*
+ Use this function to change the CAN message acceptance filters and masks.
+ */
+char canChangeFilter (UNS16 adrCAN, canBusFilterInit fi);
+
+
+/*
Enable one of the 5 MSCAN.
Must be done only one time after a reset of the CPU.
To do before any CAN initialisation
@@ -286,6 +293,11 @@
);
/*
+ Set the interruptions. Must be call just after having left the init mode.
+ */
+char canSetInterrupt (UNS16 adrCAN);
+
+/*
Put one of the 5 mscan in sleep mode
Beware! If some messages are to be sent,
or if it is receiving, going into sleep mode