Solved a small bug in emcy.c (errRegMask was always '1' in EMCY_setError.
authorluis
Mon, 01 Oct 2007 14:43:01 +0200
changeset 296 03f2b8b8cb0b
parent 295 25ff2fadff89
child 297 639e5ec5a120
Solved a small bug in emcy.c (errRegMask was always '1' in EMCY_setError.
EMCY_setError has a new parameter, addInfo, a 16-bit value that will be copied to 16 most significat bits in 1003h (but it is not sent in EMCY message).
examples/TestMasterSlave/Slave.c
include/emcy.h
src/emcy.c
--- a/examples/TestMasterSlave/Slave.c	Sun Sep 30 22:41:12 2007 +0200
+++ b/examples/TestMasterSlave/Slave.c	Mon Oct 01 14:43:01 2007 +0200
@@ -90,7 +90,7 @@
 	/* send an error and recover inmediately every 12 cycles */
 	if(SlaveMap13 % 12 == 0)
 	{
-		EMCY_setError(&TestSlave_Data, 0x4200, 0x08);
+		EMCY_setError(&TestSlave_Data, 0x4200, 0x08, 0x0000);
 		EMCY_errorRecovered(&TestSlave_Data, 0x4200);
 	}
 }
--- a/include/emcy.h	Sun Sep 30 22:41:12 2007 +0200
+++ b/include/emcy.h	Mon Oct 01 14:43:01 2007 +0200
@@ -61,7 +61,7 @@
 
 /** Sets a new error with code errCode. Also sets corresponding bits in Error register (1001h)
  */
-UNS8 EMCY_setError(CO_Data* d, UNS16 errCode, UNS8 errRegMask);
+UNS8 EMCY_setError(CO_Data* d, UNS16 errCode, UNS8 errRegMask, UNS16 addInfo);
 
 /** Indicates it has recovered from error errCode. Also clears corresponding bits in Error register (1001h)
  */
--- a/src/emcy.c	Sun Sep 30 22:41:12 2007 +0200
+++ b/src/emcy.c	Mon Oct 01 14:43:01 2007 +0200
@@ -123,7 +123,7 @@
  ** @param errRegister Bits of Error register (1001h) to be set.
  ** @return 1 if error, 0 if successful
  */
-UNS8 EMCY_setError(CO_Data* d, UNS16 errCode, UNS8 errRegMask)
+UNS8 EMCY_setError(CO_Data* d, UNS16 errCode, UNS8 errRegMask, UNS16 addInfo)
 {
 	UNS8 index;
 	UNS8 errRegister_tmp;
@@ -151,7 +151,7 @@
 	}
 	
 	d->error_data[index].errCode = errCode;
-	d->error_data[index].errRegMask = 1;
+	d->error_data[index].errRegMask = errRegMask;
 	d->error_data[index].active = 1;
 	
 	/* set the new state in the error state machine */
@@ -165,7 +165,7 @@
 	/* set Pre-defined Error Field (1003h) */
 	for (index = d->error_history_size - 1; index > 0; --index)
 		*(d->error_first_element + index) = *(d->error_first_element + index - 1);
-	*(d->error_first_element) = (UNS32)errCode;
+	*(d->error_first_element) = errCode | ((UNS32)addInfo << 16);
 	if(*d->error_number < d->error_history_size) ++(*d->error_number);
 	
 	/* send EMCY message */