⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main_test2.c

📁 microchip公司的CANOPEN协议嶘源码
💻 C
字号:

#include 	"CO_TYPES.H"
#include	"CO_MAIN.H"
#include	"Timer.H"
#include	"DemoObj.h"
#include	"CO_DICT.h"
#include	"CO_ABERR.H"			// Abort types
#include	<P18F8680.H>


unsigned char test3[0x20];
unsigned long msgID;
unsigned char hMsg;

DICT_OBJ	_uObjRef;			// Local dictionary object, loaded during inits

void main(void)
{
	
	
	TRISD = 0;
	
	// Perform any application specific initialization

	// Init my timer
	TimerInit();

	// Set the SYNC COB ID (MCHP format)
	mSYNC_SetCOBID(0x12);
	// Set the Node ID
	mCO_SetNodeID(0x01);
	// Set the baudrate
	mCO_SetBaud(0x00);
	// Set the initial heartbeat
	mNMTE_SetHeartBeat(0x00);
	// Set the initial guard time
	mNMTE_SetGuardTime(0x00);
	// Set the initial life time
	mNMTE_SetLifeFactor(0x00);

	// Initialize CANopen to run
	mCO_InitAll();		
	
	ECANCON = 0x50;
	
	while(1)
	{
		// Set the buffer
		_uObjRef.pReqBuf = test3;

		// Set the offset into the buffer
		_uObjRef.reqOffst = 0;

		// Set the index and sub-index
//		_uObjRef.index = 0x1005L;
		_uObjRef.index = 0x1008L;
		_uObjRef.subindex = 0x00;

		// Find the object in the dictionary
		mCO_DictObjectDecode(_uObjRef);

		// If in the dictionary, then read the object
		if (mCO_DictGetRet() == E_SUCCESS)
		{
			_uObjRef.reqLen = _uObjRef.len;
			mCO_DictObjectRead(_uObjRef);
		}
	}
}




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -