fix(esc_lan9252): 修复LAN9252 HBI访问模型和IRQ输出使能问题
- 修正HBI访问模型:将ESC核心CSR(0x0000-0x0FFF)改为通过ECAT_CSR_CMD/DATA 间接端口访问,解决此前直接寻址导致核心寄存器恒读0/写丢弃的问题 - 新增csrRead/csrWrite/pramRead/pramWrite接口,正确实现LAN9252访问端口操作 - 添加PDI就绪检测:等待DL_STATUS bit0置位确认EEPROM加载完成和EtherCAT核心使能 - 实现IRQ引脚输出使能:配置IRQ_CFG和INT_EN寄存器,使EtherCAT事件能到达PB1, 解决PDI_Isr未触发导致SAFEOP->OP无限挂起的问题 - 为ESC_EXMC硬件诊断添加CONFIG_ESC_EXMC_DIAG门控,默认关闭避免影响正常运行 - 修正system_gd32e50x.c中HXTAL故障诊断的寄存器偏移和位设置错
This commit is contained in:
@@ -657,13 +657,15 @@ static void system_clock_hxtal(void)
|
||||
|
||||
/* if fail */
|
||||
if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
|
||||
/* HXTAL failed: output diagnostic via USART0 at IRC8M */
|
||||
*((volatile uint32_t *)0x40021018U) |= (1U << 2) | (1U << 0);
|
||||
/* HXTAL failed: output diagnostic via USART0 at IRC8M.
|
||||
* 修正(1.5.34):原段把 CTL0 写到 STAT0 偏移(0x40013800)且漏开 USART0EN(APB2EN bit14),
|
||||
* 该诊断从未真正发出;正确布局:CTL0 @ USART0+0x0C,APB2EN bit14|bit2|bit0。 */
|
||||
*((volatile uint32_t *)0x40021018U) |= (1U << 14) | (1U << 2) | (1U << 0);
|
||||
{ volatile uint32_t _ctl = *((volatile uint32_t *)0x40010804U);
|
||||
_ctl &= ~(0xFU << 4); _ctl |= (0xBU << 4);
|
||||
*((volatile uint32_t *)0x40010804U) = _ctl; }
|
||||
*((volatile uint32_t *)0x40013808U) = 69U; /* 8MHz/115200 */
|
||||
*((volatile uint32_t *)0x40013800U) = (1U << 3) | (1U << 13);
|
||||
*((volatile uint32_t *)0x4001380CU) = (1U << 3) | (1U << 13);
|
||||
{ const char *_msg = "HXTAL FAIL\r\n";
|
||||
for(int i=0; _msg[i]; i++){
|
||||
*((volatile uint32_t *)0x40013804U) = _msg[i];
|
||||
@@ -713,13 +715,15 @@ static void system_clock_72m_hxtal(void)
|
||||
|
||||
/* if fail */
|
||||
if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
|
||||
/* HXTAL failed: output diagnostic via USART0 at IRC8M */
|
||||
*((volatile uint32_t *)0x40021018U) |= (1U << 2) | (1U << 0);
|
||||
/* HXTAL failed: output diagnostic via USART0 at IRC8M.
|
||||
* 修正(1.5.34):原段把 CTL0 写到 STAT0 偏移(0x40013800)且漏开 USART0EN(APB2EN bit14),
|
||||
* 该诊断从未真正发出;正确布局:CTL0 @ USART0+0x0C,APB2EN bit14|bit2|bit0。 */
|
||||
*((volatile uint32_t *)0x40021018U) |= (1U << 14) | (1U << 2) | (1U << 0);
|
||||
{ volatile uint32_t _ctl = *((volatile uint32_t *)0x40010804U);
|
||||
_ctl &= ~(0xFU << 4); _ctl |= (0xBU << 4);
|
||||
*((volatile uint32_t *)0x40010804U) = _ctl; }
|
||||
*((volatile uint32_t *)0x40013808U) = 69U; /* 8MHz/115200 */
|
||||
*((volatile uint32_t *)0x40013800U) = (1U << 3) | (1U << 13);
|
||||
*((volatile uint32_t *)0x4001380CU) = (1U << 3) | (1U << 13);
|
||||
{ const char *_msg = "HXTAL FAIL\r\n";
|
||||
for(int i=0; _msg[i]; i++){
|
||||
*((volatile uint32_t *)0x40013804U) = _msg[i];
|
||||
@@ -831,13 +835,15 @@ static void system_clock_120m_hxtal(void)
|
||||
|
||||
/* if fail */
|
||||
if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
|
||||
/* HXTAL failed: output diagnostic via USART0 at IRC8M */
|
||||
*((volatile uint32_t *)0x40021018U) |= (1U << 2) | (1U << 0);
|
||||
/* HXTAL failed: output diagnostic via USART0 at IRC8M.
|
||||
* 修正(1.5.34):原段把 CTL0 写到 STAT0 偏移(0x40013800)且漏开 USART0EN(APB2EN bit14),
|
||||
* 该诊断从未真正发出;正确布局:CTL0 @ USART0+0x0C,APB2EN bit14|bit2|bit0。 */
|
||||
*((volatile uint32_t *)0x40021018U) |= (1U << 14) | (1U << 2) | (1U << 0);
|
||||
{ volatile uint32_t _ctl = *((volatile uint32_t *)0x40010804U);
|
||||
_ctl &= ~(0xFU << 4); _ctl |= (0xBU << 4);
|
||||
*((volatile uint32_t *)0x40010804U) = _ctl; }
|
||||
*((volatile uint32_t *)0x40013808U) = 69U; /* 8MHz/115200 */
|
||||
*((volatile uint32_t *)0x40013800U) = (1U << 3) | (1U << 13);
|
||||
*((volatile uint32_t *)0x4001380CU) = (1U << 3) | (1U << 13);
|
||||
{ const char *_msg = "HXTAL FAIL\r\n";
|
||||
for(int i=0; _msg[i]; i++){
|
||||
*((volatile uint32_t *)0x40013804U) = _msg[i];
|
||||
@@ -950,13 +956,15 @@ static void system_clock_168m_hxtal(void)
|
||||
|
||||
/* if fail */
|
||||
if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
|
||||
/* HXTAL failed: output diagnostic via USART0 at IRC8M */
|
||||
*((volatile uint32_t *)0x40021018U) |= (1U << 2) | (1U << 0);
|
||||
/* HXTAL failed: output diagnostic via USART0 at IRC8M.
|
||||
* 修正(1.5.34):原段把 CTL0 写到 STAT0 偏移(0x40013800)且漏开 USART0EN(APB2EN bit14),
|
||||
* 该诊断从未真正发出;正确布局:CTL0 @ USART0+0x0C,APB2EN bit14|bit2|bit0。 */
|
||||
*((volatile uint32_t *)0x40021018U) |= (1U << 14) | (1U << 2) | (1U << 0);
|
||||
{ volatile uint32_t _ctl = *((volatile uint32_t *)0x40010804U);
|
||||
_ctl &= ~(0xFU << 4); _ctl |= (0xBU << 4);
|
||||
*((volatile uint32_t *)0x40010804U) = _ctl; }
|
||||
*((volatile uint32_t *)0x40013808U) = 69U; /* 8MHz/115200 */
|
||||
*((volatile uint32_t *)0x40013800U) = (1U << 3) | (1U << 13);
|
||||
*((volatile uint32_t *)0x4001380CU) = (1U << 3) | (1U << 13);
|
||||
{ const char *_msg = "HXTAL FAIL\r\n";
|
||||
for(int i=0; _msg[i]; i++){
|
||||
*((volatile uint32_t *)0x40013804U) = _msg[i];
|
||||
@@ -1069,13 +1077,15 @@ static void system_clock_180m_hxtal(void)
|
||||
|
||||
/* if fail */
|
||||
if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
|
||||
/* HXTAL failed: output diagnostic via USART0 at IRC8M */
|
||||
*((volatile uint32_t *)0x40021018U) |= (1U << 2) | (1U << 0);
|
||||
/* HXTAL failed: output diagnostic via USART0 at IRC8M.
|
||||
* 修正(1.5.34):原段把 CTL0 写到 STAT0 偏移(0x40013800)且漏开 USART0EN(APB2EN bit14),
|
||||
* 该诊断从未真正发出;正确布局:CTL0 @ USART0+0x0C,APB2EN bit14|bit2|bit0。 */
|
||||
*((volatile uint32_t *)0x40021018U) |= (1U << 14) | (1U << 2) | (1U << 0);
|
||||
{ volatile uint32_t _ctl = *((volatile uint32_t *)0x40010804U);
|
||||
_ctl &= ~(0xFU << 4); _ctl |= (0xBU << 4);
|
||||
*((volatile uint32_t *)0x40010804U) = _ctl; }
|
||||
*((volatile uint32_t *)0x40013808U) = 69U; /* 8MHz/115200 */
|
||||
*((volatile uint32_t *)0x40013800U) = (1U << 3) | (1U << 13);
|
||||
*((volatile uint32_t *)0x4001380CU) = (1U << 3) | (1U << 13);
|
||||
{ const char *_msg = "HXTAL FAIL\r\n";
|
||||
for(int i=0; _msg[i]; i++){
|
||||
*((volatile uint32_t *)0x40013804U) = _msg[i];
|
||||
|
||||
Reference in New Issue
Block a user