Обновление 23.06.2026

This commit is contained in:
Дарья Бараева 2026-06-24 13:58:08 +03:00
parent c96c36a0b8
commit 1e4fd372c8
2 changed files with 30 additions and 2 deletions

View File

@ -458,4 +458,7 @@ void FLEXCAN_IRQHandler(uint8_t u8CanIndex);
/** @}*/
bool IsTxBufferFree_ByCode(uint8_t canIndex, uint8_t handler);
#endif

View File

@ -2174,7 +2174,7 @@ FLEXCAN_ErrorType FLEXCAN_TransmitData(uint8_t u8CanIndex, const FLEXCAN_TxMsgTy
}
// -------------------------------
/*
if (pTxMsg->bWaitTxCompleted)
{
u32TempAddr = 0U;
@ -2200,7 +2200,7 @@ FLEXCAN_ErrorType FLEXCAN_TransmitData(uint8_t u8CanIndex, const FLEXCAN_TxMsgTy
tRetVal = FLEXCAN_ERROR_TIMEOUT;
}
}
*/
// --------------------------
}
@ -2213,6 +2213,31 @@ FLEXCAN_ErrorType FLEXCAN_TransmitData(uint8_t u8CanIndex, const FLEXCAN_TxMsgTy
}
bool IsTxBufferFree_ByCode(uint8_t canIndex, uint8_t handler) {
FLEXCAN_Type *pCan = s_aFlexCan_InstanceTable[canIndex];
FLEXCAN_SettingType *pCurSetting = &s_aFlexCan_Setting_Table[canIndex];
if (handler >= pCurSetting->u8TxMbCnt1) {
return false; // Неверный handler
}
uint8_t realIndex = pCurSetting->u8TxMbStart1 + handler;
// Читаем код из первого слова MB
uint32_t addr = (uint32_t)FLEXCAN_MB_WORDN_ADDR(
&(pCan->RAM[0U]), realIndex, pCurSetting->eMbDataWidth, 0U);
uint32_t code = FLEXCAN_MB_CODE_GET(addr);
// Коды состояния буфера:
// 0x0 = EMPTY (не использовался) - СВОБОДЕН
// 0x8 = INACTIVE (неактивен) - СВОБОДЕН
// 0xC = TRANSMITTING (передаёт) - ЗАНЯТ
// 0x9 = ABORTING (прерывается) - ЗАНЯТ
return (code == 0x0 || code == 0x8);
}
/**
* @brief Process flag after transmit
*