Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: ppCANOpen_Example DISCO-F746NG_rtos_test
Diff: include/canopen_protocol.h
- Revision:
- 3:12b3c25bdeba
- Parent:
- 2:c724ff3a4e4d
--- a/include/canopen_protocol.h Wed Dec 30 13:33:41 2015 +0000
+++ b/include/canopen_protocol.h Mon Jan 04 06:10:49 2016 +0000
@@ -26,9 +26,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef CANOPEN_PROTOCOL_H
-#define CANOPEN_PROTOCOL_H
+#ifndef PPCAN_CANOPEN_PROTOCOL_H
+#define PPCAN_CANOPEN_PROTOCOL_H
+#include "CanOpenHandle.h"
#ifdef __cplusplus
extern "C" {
@@ -52,6 +53,25 @@
CANOPEN_TYPE_REMOTE
} CanOpenType;
+ /** CANOpen Function Codes */
+ typedef enum {
+ CANOPEN_FUNCTION_CODE_NMT = 0x00,
+ CANOPEN_FUNCTION_CODE_SYNC = 0x01,
+ CANOPEN_FUNCTION_CODE_TIME = 0x02,
+ CANOPEN_FUNCTION_CODE_PDO1T = 0x03,
+ CANOPEN_FUNCTION_CODE_PD01R = 0x04,
+ CANOPEN_FUNCTION_CODE_PD02T = 0x05,
+ CANOPEN_FUNCTION_CODE_PD02R = 0x06,
+ CANOPEN_FUNCTION_CODE_PD03T = 0x07,
+ CANOPEN_FUNCTION_CODE_PD03R = 0x08,
+ CANOPEN_FUNCTION_CODE_PD04T = 0x09,
+ CANOPEN_FUNCTION_CODE_PD04R = 0x0A,
+ CANOPEN_FUNCTION_CODE_SD0T = 0x0B,
+ CANOPEN_FUNCTION_CODE_SD0R = 0x0C,
+ CANOPEN_FUNCTION_CODE_NODE_GUARD = 0x0E,
+ CANOPEN_FUNCTION_CODE_LSS = 0x0F
+ } CanOpenFunctionCodes;
+
/** CANOpen Message */
typedef struct {
unsigned int id;
@@ -61,6 +81,16 @@
unsigned char dataCount;
} CanOpenMessage;
+
+
+ /* Message Constants */
+ #define MESSAGE_NODEID_BITS 0b00001111111
+ #define MESSAGE_COMMAND_BITS 0b11110000000
+
+ /* Message Macros -----------------------------------------------------------*/
+ #define MESSAGE_GET_NODEID(cobId) (cobId & MESSAGE_NODEID_BITS)
+ #define MESSAGE_GET_COMMAND(cobId) ((cobId & MESSAGE_COMMAND_BITS) >> 7)
+
/*=========================================================================
* SDO MESSAGE PARAMETERS
*=========================================================================
@@ -128,4 +158,4 @@
};
#endif
-#endif /* CANOPEN_PROTOCOL */
+#endif /* PPCAN_CANOPEN_PROTOCOL */