第一篇,ethercat 硬件初始化 HW_Init(void)
2016-06-30 12:00
1871 查看
/////////////////////////////////////////////////////////////////////////////////////////
/**
\return 0 if initialization was successful
\brief This function initialize the EtherCAT Slave Interface.
*////////////////////////////////////////////////////////////////////////////////////////
UINT16 HW_Init(void)
{
UINT32 intMask = 0;
/* 初始化:
1、同ESC的存储接口
2、ESC中断
3、ECAT看门狗时钟*/
/* 初始化ESC DPRAM与单片机的指针ESC的物理内存的开始*/
pEsc = MAKE_PTR_TO_ESC;
{
UINT16 u16PdiCtrl = 0;
/*宏定义:ESC_PDI_CONTROL_OFFSET 对应地址为0x0140;
0x0140:PDI控制寄存器 使能/终止DC单单元*/
do
{
HW_EscReadWord(u16PdiCtrl,ESC_PDI_CONTROL_OFFSET); //将u16PdiCtrl=0的值写到0x0140地址中,PDI控制寄存器
u16PdiCtrl = SWAPWORD(u16PdiCtrl);
} while (((u16PdiCtrl & 0xFF) < 0x8) || ((u16PdiCtrl & 0xFF) > 0xD) );
}
/* 初始化PDI中断源*/
INIT_ESC_INT;
/* initialize the AL_Event Mask Register:初始化AL_event mask寄存器 */
/* the AL Event-Mask register is initialized with 0, so that no ESC interrupt is generated yet,
the AL Event-Mask register will be adapted in the function StartInputHandler in ecatslv.c
when the state transition from PREOP to SAFEOP is made */
/*宏定义:ESC_AL_EVENTMASK_OFFSET 0x0204 Al时间中断请求屏蔽
AL时间请求寄存器是否映射到PDI中断信号*IRQ(B12),位定义同AL中断请求寄存器0X0220:0x0223
0:相应的中断请求位不映射
1:相应的中断请求位映射
复位0xFF;0xFF0F*/
HW_EscWriteDWord(intMask, ESC_AL_EVENTMASK_OFFSET);
/* enable the ESC-interrupt microcontroller specific,
the macro ENABLE_ESC_INT should be defined in ecat_def.h */
ENABLE_ESC_INT();
return 0;
}
void HW_Release(void)
{
}
/**
\return 0 if initialization was successful
\brief This function initialize the EtherCAT Slave Interface.
*////////////////////////////////////////////////////////////////////////////////////////
UINT16 HW_Init(void)
{
UINT32 intMask = 0;
/* 初始化:
1、同ESC的存储接口
2、ESC中断
3、ECAT看门狗时钟*/
/* 初始化ESC DPRAM与单片机的指针ESC的物理内存的开始*/
pEsc = MAKE_PTR_TO_ESC;
{
UINT16 u16PdiCtrl = 0;
/*宏定义:ESC_PDI_CONTROL_OFFSET 对应地址为0x0140;
0x0140:PDI控制寄存器 使能/终止DC单单元*/
do
{
HW_EscReadWord(u16PdiCtrl,ESC_PDI_CONTROL_OFFSET); //将u16PdiCtrl=0的值写到0x0140地址中,PDI控制寄存器
u16PdiCtrl = SWAPWORD(u16PdiCtrl);
} while (((u16PdiCtrl & 0xFF) < 0x8) || ((u16PdiCtrl & 0xFF) > 0xD) );
}
/* 初始化PDI中断源*/
INIT_ESC_INT;
/* initialize the AL_Event Mask Register:初始化AL_event mask寄存器 */
/* the AL Event-Mask register is initialized with 0, so that no ESC interrupt is generated yet,
the AL Event-Mask register will be adapted in the function StartInputHandler in ecatslv.c
when the state transition from PREOP to SAFEOP is made */
/*宏定义:ESC_AL_EVENTMASK_OFFSET 0x0204 Al时间中断请求屏蔽
AL时间请求寄存器是否映射到PDI中断信号*IRQ(B12),位定义同AL中断请求寄存器0X0220:0x0223
0:相应的中断请求位不映射
1:相应的中断请求位映射
复位0xFF;0xFF0F*/
HW_EscWriteDWord(intMask, ESC_AL_EVENTMASK_OFFSET);
/* enable the ESC-interrupt microcontroller specific,
the macro ENABLE_ESC_INT should be defined in ecat_def.h */
ENABLE_ESC_INT();
return 0;
}
void HW_Release(void)
{
}
相关文章推荐
- Cornell 感受
- Spark算子:RDD基本转换操作(5)–mapPartitions、mapPartitionsWithIndex
- 理解php-cli环境
- Chapter 2. WinForm(控件TextBox、Label、checkbox、radiobutton,容器groupbox)
- Tcl/Cmds
- Json
- 操作数据库笔记
- java对象序列化和反序列化操作记录
- LintCode
- 忘了她,就像忘了一朵花
- 用dwz+springmvc出现这个问题Http status: 200 OK ajaxOptions: parsererror thrownError
- I.MX6 AW-NB177NF wifi reset
- 【51CTO学院三周年】有梦想就要坚持
- 关于Hibernate中创建ServiceRegistry对象时找不到ServiceRegistryBuilder对象的问题
- 2052Picture
- Mysql下载安装、部署与图形化详细操作教程
- Elasticsearch java API (17)Aggregations 聚合 函数
- 学会使用临时表优化,切记不要乱用临时表(记录一)
- 物联网标准NB-IoT和LoRa,究竟谁能更胜一筹?
- Java I/O操作