📄 mco.c
字号:
/**************************************************************************
MODULE: MCO
CONTAINS: MicroCANopen implementation
COPYRIGHT: Embedded Systems Academy, Inc. 2002-2003.
All rights reserved. www.microcanopen.com
This software was written in accordance to the guidelines at
www.esacademy.com/software/softwarestyleguide.pdf
DISCLAIM: Read and understand our disclaimer before using this code!
www.esacademy.com/disclaim.htm
LICENSE: Users that have purchased a license for PCANopenMagic
(www.esacademy.com/software/pcanopenmagic)
may use this code in commercial projects.
Otherwise only educational use is acceptable.
VERSION: 1.20, Pf/Aa/Ck 28-MAY-03
---------------------------------------------------------------------------
HISTORY: 1.20, Pf 28-MAY-03, Made OD an include, part of mco.h
changed OD to indefinite length with end of table record
added support for CANopen RUN and ERR LED
1.01, Pf 17-DEC-02, Made Object Dictionary more readable
1.00, Pf 07-OCT-02, First Published Version
***************************************************************************/
#include "mco.h"
#include "mcohw.h"
#include <string.h>
/**************************************************************************
MACROS FOR OBJECT DICTIONARY ENTRIES
***************************************************************************/
#define GETBYTE(val,pos) ((val >> pos) & 0xFF)
#define GETBYTES16(val) GETBYTE(val, 0), GETBYTE(val, 8)
#define GETBYTES32(val) GETBYTE(val, 0), GETBYTE(val, 8), GETBYTE(val,16), GETBYTE(val,24)
#define SDOREPLY(index,sub,len,val) 0x43 | ((4-len)<<2), GETBYTES16(index), sub, GETBYTES32(val)
#define SDOREPLY4(index,sub,len,d1,d2,d3,d4) 0x43 | ((4-len)<<2), GETBYTES16(index), sub, d1, d2, d3, d4
/**************************************************************************
GLOBAL VARIABLES
***************************************************************************/
#ifdef USE_LED
// CAN Run and Err LED
extern BYTE data gRLED; // Current pattern on run led
extern BYTE data gELED; // Current pattern on error led
#endif
// This structure holds all node specific configuration
MCO_CONFIG gMCOConfig;
#if NR_OF_TPDOS > 0
// This structure holds all the TPDO configuration data for up to 4 TPDOs
TPDO_CONFIG gTPDOConfig[NR_OF_TPDOS];
// This is the next TPDO to be checked in MCO_ProcessStack
BYTE gTPDONr = NR_OF_TPDOS;
#endif
#if NR_OF_RPDOS > 0
// This structure holds all the RPDO configuration data for up to 4 RPDOs
RPDO_CONFIG gRPDOConfig[NR_OF_RPDOS];
#endif
// This structure holds the current receive message
CAN_MSG data gRxCAN;
// This structure holds the CAN message for SDO responses or aborts
CAN_MSG data gTxSDO;
// Table with SDO Responses for read requests to OD
BYTE const code SDOResponseTable[] = {
// Each Row has 8 Bytes:
// Command Specifier for SDO Response (1 byte)
// bits 2+3 contain: '4'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -