|
該源碼是當(dāng)前流行的機(jī)器人控制系統(tǒng)倍福所采用的構(gòu)架Ethercat 總線
xml文件是設(shè)備描述文件,燒寫在了EEPROM 里面 從站站 (ET11000)上電后 會從 eeprom 加載配置參數(shù)
完成初始化過程
文件中有對應(yīng)IO 及AD 全局變量的定義
extern uint16_t uhADCxConvertedValue;
#define SWITCH_1 PCin(7)// PCin(8) // PORTDbits.RD7 /**< \brief Access to switch 1 input*/
#define SWITCH_2 PCin(8)// PCin(9) // PORTDbits.RD6 /**< \brief Access to switch 2 input*/
#define SWITCH_3 PCin(9)// PAin(11) // PORTDbits.RD5 /**< \brief Access to switch 3 input*/
#define SWITCH_4 PGin(11)// PAin(12) // PORTDbits.RD4 /**< \brief Access to switch 4 input*/
#define SWITCH_5 PGin(12)// PAin(13) // PORTDbits.RD3 /**< \brief Access to switch 5 input*/
#define SWITCH_6 PGin(13)// PAin(14) // PORTDbits.RD2 /**< \brief Access to switch 6 input*/
#define SWITCH_7 PGin(14)// PAin(15) // PORTDbits.RD1 /**< \brief Access to switch 7 input*/
#define SWITCH_8 PGin(15)// PCin(12) // PORTDbits.RD0 /**< \brief Access to switch 8 input*/
#define LED_1 PCout(6) // PCout(7) // LATBbits.LATB8 /**< \brief Access to led 1 output*/
#define LED_2 PGout(8) // PCout(6) //3////LATBbits.LATB9 /**< \brief Access to led 2 output*/
#define LED_3 PGout(7)// PGout(8) // LATBbits.LATB10 /**< \brief Access to led 3 output*/
#define LED_4 PGout(6)// PGout(7) //LATBbits.LATB11 /**< \brief Access to led 4 output*/
#define LED_5 PGout(5)// PGout(6) // LATBbits.LATB12 /**< \brief Access to led 5 output*/
#define LED_6 PGout(4)// PGout(5) // LATBbits.LATB13 /**< \brief Access to led 6 output*/
#define LED_7 PGout(3)// PGout(4) //LATBbits.LATB14 /**< \brief Access to led 7 output*/
#define LED_8 PDout(13)// PGout(3)
部分源碼如
/////////////////////////////////////////////////////////////////////////////////////////
/**
\return 0(ALSTATUSCODE_NOERROR), NOERROR_INWORK
\param pInputSize pointer to save the input process data length
\param pOutputSize pointer to save the output process data length
\brief This function calculates the process data sizes from the actual SM-PDO-Assign
and PDO mapping
*////////////////////////////////////////////////////////////////////////////////////////
UINT16 APPL_GenerateMapping(UINT16* pInputSize,UINT16* pOutputSize)
{
#if COE_SUPPORTED
UINT16 result = ALSTATUSCODE_NOERROR;
UINT16 PDOAssignEntryCnt = 0;
OBJCONST TOBJECT OBJMEM * pPDO = NULL;
UINT16 PDOSubindex0 = 0;
UINT32 *pPDOEntry = NULL;
UINT16 PDOEntryCnt = 0;
UINT16 InputSize = 0;
UINT16 OutputSize = 0;
/*Scan object 0x1C12 RXPDO assign*/
for(PDOAssignEntryCnt = 0; PDOAssignEntryCnt < sRxPDOassign.u16SubIndex0; PDOAssignEntryCnt++)
{
pPDO = OBJ_GetObjectHandle(sRxPDOassign.aEntries[PDOAssignEntryCnt]);
if(pPDO != NULL)
{
PDOSubindex0 = *((UINT16 *)pPDO->pVarPtr);
for(PDOEntryCnt = 0; PDOEntryCnt < PDOSubindex0; PDOEntryCnt++)
{
// result = *(UINT8 *)pPDO->pVarPtr;
// result=(OBJ_GetEntryOffset((PDOEntryCnt+1),pPDO)>>3);
pPDOEntry = (UINT32 *)((UINT8 *)pPDO->pVarPtr + (OBJ_GetEntryOffset((PDOEntryCnt+1),pPDO)>>3)); //goto PDO entry
// we increment the expected output size depending on the mapped Entry
OutputSize += (UINT16) ((*pPDOEntry) & 0xFF);
}
}
else
{
/*assigned PDO was not found in object dictionary. return invalid mapping*/
OutputSize = 0;
result = ALSTATUSCODE_INVALIDOUTPUTMAPPING;
break;
}
}
OutputSize = (OutputSize + 7) >> 3;// +7
下載:
STM32實現(xiàn) Ethercat 從站源碼.rar
(1.19 MB, 下載次數(shù): 98)
2022-3-29 18:30 上傳
點擊文件名下載附件
STM32 EtherCAT從站 下載積分: 黑幣 -5
UC16-R1.rar
(4.54 KB, 下載次數(shù): 53)
2022-3-29 18:31 上傳
點擊文件名下載附件
對應(yīng)xml文件 下載積分: 黑幣 -5
|
評分
-
查看全部評分
|