353 {
354 if (cand == NULL)
355 return;
356
357 if (cand->state != CAN_READY) {
358 efiPrintf("Interface is not ready");
359 return;
360 }
361
362#if STM32_CAN_USE_CAN1 || STM32_CAN_USE_CAN2
363 if (cand->can == NULL) {
364 efiPrintf("No device assigned!");
365 }
366
367 uint32_t
esr = cand->can->ESR;
368 efiPrintf(
"Receive error counter %ld", (
esr >> 24) & 0xff);
369 efiPrintf(
"Transmit error counter %ld", (
esr >> 16) & 0xff);
370 efiPrintf(
"Last error %ld", (
esr >> 4) & 0x7);
371 efiPrintf("Flags: %s %s %s",
372 (
esr & 0x4) ?
"BOFF" :
"",
373 (
esr & 0x2) ?
"EPVF" :
"",
374 (
esr & 0x1) ?
"EWGF" :
"");
375#elif STM32_CAN_USE_FDCAN1 || STM32_CAN_USE_FDCAN2 || STM32_CAN_USE_FDCAN3
376 if (cand->fdcan == NULL) {
377 efiPrintf("No device assigned!");
378 }
379
380 uint32_t cccr = cand->fdcan->CCCR;
381 efiPrintf("CCCR: %s %s %s",
382 (cccr & FDCAN_CCCR_MON) ? "Bus monitoring mode" : "",
383 (cccr & FDCAN_CCCR_ASM) ? "ASM restricted operation mode" : "",
384 (cccr & FDCAN_CCCR_INIT) ? "INIT" : "");
385
386 uint32_t ecr = cand->fdcan->ECR;
387 efiPrintf("CAN error logging counter %ld",
388 (ecr & FDCAN_ECR_CEL_Msk) >> FDCAN_ECR_CEL_Pos);
389 if (ecr & FDCAN_ECR_RP) {
390 efiPrintf("Receive error passive 128+");
391 } else {
392 efiPrintf("Receive error counter %ld",
393 (ecr & FDCAN_ECR_REC_Msk) >> FDCAN_ECR_REC_Pos);
394 }
395 efiPrintf("Transmit error counter %ld",
396 (ecr & FDCAN_ECR_TEC_Msk) >> FDCAN_ECR_TEC_Pos);
397
398 uint32_t psr = cand->fdcan->PSR;
399 efiPrintf("Flags: %s %s %s %s",
400 (psr & FDCAN_PSR_PXE) ? "PXE" : "",
401 (psr & FDCAN_PSR_BO) ? "Bus_Off" : "",
402 (psr & FDCAN_PSR_EW) ? "EW" : "",
403 (psr & FDCAN_PSR_EP) ? "Error passive" : "");
404
405 static const char *lec_names[8] = {
406 "No error",
407 "Stuff error",
408 "Form error",
409 "AckError",
410 "Bit1Error",
411 "Bit0Error",
412 "CRCError",
413 "NoChange"
414 };
415
416 efiPrintf("Last error %s", lec_names[psr & 0x7]);
417#endif
418}
esr("WBO: ESR", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 1956, 1.0, 0.0, 10000.0, "ohm")