feat(cproject): 重构项目文件结构并添加EtherCAT通信支持
- 将设备相关文件重新组织为device/spi和comm分组 - 添加EtherCAT从站通信模块(esc_exmc_bus、esc_lan9252、ethercat_slave等) - 添加EXMC外设组件支持 - 统一文件命名规范为小写 refactor(canfd): 优化CANFD模块中断安全性和配置方式 - 替换自定义临界区函数为RT_CRITICAL_SAVE/RESTORE宏 - 使用配置常量CONFIG_IRQ_PREEMPT_CAN替代硬编码值 - 简化邮箱满时的处理逻辑,移除不必要的SysTick等待 - 移除废弃的中断保存头文件引用 refactor(timer): 更新定时器配置以使用配置常量 - 修复头文件包含路径大小写问题 - 使用CONFIG_NVIC_PRIORITY_GROUP配置项替代硬编码值
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "main.h"
|
||||
#include "device/usart0.h"
|
||||
#include "sys/config.h"
|
||||
#include "sys/critical.h"
|
||||
|
||||
uint8_t Usart0::s_txBuf[Usart0::kTxBufSize];
|
||||
volatile uint16_t Usart0::s_txHead = 0U;
|
||||
@@ -54,10 +55,10 @@ bool Usart0::isBufferEmpty()
|
||||
*/
|
||||
bool Usart0::putCharNonBlocking(int ch)
|
||||
{
|
||||
__disable_irq();
|
||||
uint32_t save = RT_CRITICAL_SAVE();
|
||||
const uint16_t next = nextIndex(s_txHead);
|
||||
if(next == s_txTail) {
|
||||
__enable_irq();
|
||||
RT_CRITICAL_RESTORE(save);
|
||||
s_dropCount++;
|
||||
return false;
|
||||
}
|
||||
@@ -65,7 +66,7 @@ bool Usart0::putCharNonBlocking(int ch)
|
||||
s_txBuf[s_txHead] = static_cast<uint8_t>(ch);
|
||||
s_txHead = next;
|
||||
usart_interrupt_enable(USART0, USART_INT_TBE);
|
||||
__enable_irq();
|
||||
RT_CRITICAL_RESTORE(save);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -136,7 +137,7 @@ void Usart0::init()
|
||||
usart_receive_config(USART0, USART_RECEIVE_ENABLE);
|
||||
usart_transmit_config(USART0, USART_TRANSMIT_ENABLE);
|
||||
usart_enable(USART0);
|
||||
nvic_irq_enable(USART0_IRQn, 2U, 0U);
|
||||
nvic_irq_enable(USART0_IRQn, CONFIG_IRQ_PREEMPT_SPI_USART, 0U);
|
||||
}
|
||||
|
||||
/* ----- 中断入口 / printf 重定向的 C 包装 --------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user