i can solve this problem . I can grab error in calback function. after ican restart can modul with bus_off. But important function sendnonblocking method. if user use like sdk is hangup in while statement
while (!txComplete)
{
}
txComplete = false;
user must control sendnonblocikng methode return value. If valu is sucsec u can use while statement.
sts=MCAN_TransferSendNonBlocking(EXAMPLE_MCAN, &mcanHandle, &txXfer);
switch (sts)
{
case kStatus_Success:
{
while (!txComplete)
{
}
txComplete = false;
}
break;
case kStatus_Fail:
{
psr=EXAMPLE_MCAN->PSR&CAN_PSR_LEC_MASK;
ecer=EXAMPLE_MCAN->ECR&CAN_ECR_TEC_MASK;
busof=(EXAMPLE_MCAN->PSR&CAN_PSR_BO_MASK)>>CAN_PSR_BO_SHIFT;
ccr=EXAMPLE_MCAN->CCCR;
sts=0;
}
break;
case kStatus_MCAN_TxBusy:
{
}
default:
break;
}
call back func:
static void mcan_callback(CAN_Type *base, mcan_handle_t *handle, status_t status, uint32_t result, void *userData)
{
BaseType_t xHigherPriorityTaskWoken;
/* The xHigherPriorityTaskWoken parameter must be initialized to pdFALSE as
it will get set to pdTRUE inside the interrupt safe API function if a
context switch is required. */
xHigherPriorityTaskWoken = pdFALSE;
/* 'Give' the semaphore to unblock the task. */
/* Pass the xHigherPriorityTaskWoken value into portYIELD_FROM_ISR(). If
xHigherPriorityTaskWoken was set to pdTRUE inside xSemaphoreGiveFromISR()
then calling portYIELD_FROM_ISR() will request a context switch. If
xHigherPriorityTaskWoken is still pdFALSE then calling
portYIELD_FROM_ISR() will have no effect. The implementation of
portYIELD_FROM_ISR() used by the Windows port includes a return statement,
which is why this function does not explicitly return a value. */
// printf("Callback status: 0x%x", status);
//printf(" IR: 0x%x \r\n", base->IR);
switch (status)
{
case kStatus_MCAN_RxFifo0Idle:
{
xSemaphoreGiveFromISR( semaphoreRX, &xHigherPriorityTaskWoken );
rxComplete = true;
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}
break;
case kStatus_MCAN_TxIdle:
{
xSemaphoreGiveFromISR( semaphorum, &xHigherPriorityTaskWoken );
txComplete = true;
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}
break;
case kStatus_MCAN_ErrorStatus:
{
if (EXAMPLE_MCAN->CCCR &= CAN_CCCR_INIT_MASK)
{
EXAMPLE_MCAN->CCCR &= ~CAN_CCCR_INIT_MASK;
while (0U != (EXAMPLE_MCAN->CCCR & CAN_CCCR_INIT_MASK))
{
}
}
mcanreset();
//txError=true;
txComplete = true;
xSemaphoreGiveFromISR( semaphorum, &xHigherPriorityTaskWoken );
txComplete = true;
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}
default:
break;
}
}
in calback function i send xsemaphore to my rtos but this is only evaluate .
sory this code only evaluate. im writing all is next day.