Guest User

Untitled

a guest
Feb 6th, 2017
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. void CANIntHandler(void)
  2. {
  3. uint32_t ui32Status;
  4. tCANMsgObject sMsgObjectRx;
  5. uint8_t msg_data[8];
  6. sMsgObjectRx.pui8MsgData = msg_data;
  7.  
  8. //
  9. // Read the CAN interrupt status to find the cause of the interrupt
  10. //
  11. ui32Status = CANIntStatus(CAN0_BASE, CAN_INT_STS_CAUSE);
  12.  
  13. //
  14. // If the cause is a controller status interrupt, then get the status
  15. //
  16. if(ui32Status == CAN_INT_INTID_STATUS)
  17. {
  18. ui32Status = CANStatusGet(CAN0_BASE, CAN_STS_CONTROL);
  19. if(ui32Status & CAN_STATUS_TXOK)
  20. {
  21. ++can_tx_ok_counter;
  22. }
  23. else if(ui32Status == CAN_STATUS_RXOK)
  24. {
  25. ++can_rx_ok_counter;
  26. }
  27. else
  28. {
  29. can_err_flag = 1U;
  30. ++can_err_counter;
  31. }
  32. }
  33. else
  34. { // Service interrupts due to the various configured CAN message objects...
  35. switch(ui32Status)
  36. {
  37. case 1:
  38. CANMessageGet(CAN0_BASE, 1, &sMsgObjectRx, 1); // Clear TX interrupt
  39. serialport_highlevel_tx_isr(uart5_can_port_ptr); // Service the rest of the buffer on this comm channel
  40. break;
  41. case 2:
  42. CANMessageGet(CAN0_BASE, 2, &sMsgObjectRx, 1);
  43.  
  44. // CANMessageSet() is called from here to service circular buffer
  45. // Debug note: Printing out the "sent" characters from this routine shows
  46. // conclusively that the bytes are actually "sent" as in CANMessageSet() is in fact
  47. // called for each of the desired bytes. However, it appears that some bytes don't actually end up on
  48. // the bus...
  49. serialport_highlevel_tx_isr(uart6_can_port_ptr);
  50.  
  51. SysCtlDelay(5000); // WTF?? Without this, we miss bytes on CAN bus...
  52. break;
  53. case 3:
  54. CANMessageGet(CAN0_BASE, 3, &sMsgObjectRx, 1);
  55. serialport_highlevel_tx_isr(uart7_can_port_ptr);
  56. break;
  57. case 4:
  58. serialport_highlevel_rx_isr(uart5_can_port_ptr);
  59. break;
  60. case 5:
  61. serialport_highlevel_rx_isr(uart6_can_port_ptr);
  62. break;
  63. case 6:
  64. serialport_highlevel_rx_isr(uart7_can_port_ptr);
  65. break;
  66. default:
  67. can_err_flag = 2U;
  68. ++can_err_counter;
  69. CANMessageGet(CAN0_BASE, ui32Status, &sMsgObjectRx, 1);
  70. break;
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment