CAN_LPC18xx.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* --------------------------------------------------------------------------
  2. * Copyright (c) 2013-2016 ARM Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the License); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. * $Date: 02. March 2016
  19. * $Revision: V1.0
  20. *
  21. * Project: CAN Driver Definitions for NXP LPC18xx
  22. * -------------------------------------------------------------------------- */
  23. #ifndef __CAN_LPC18XX_H
  24. #define __CAN_LPC18XX_H
  25. #include <stdint.h>
  26. #include <string.h>
  27. #include "Driver_CAN.h"
  28. #include "LPC18xx.h"
  29. #include "SCU_LPC18xx.h"
  30. #include "RTE_Device.h"
  31. #include "RTE_Components.h"
  32. #ifndef RTE_CAN_CAN0
  33. #define RTE_CAN_CAN0 (0U)
  34. #endif
  35. #ifndef RTE_CAN_CAN1
  36. #define RTE_CAN_CAN1 (0U)
  37. #endif
  38. #if ((RTE_CAN_CAN0 == 0U) && (RTE_CAN_CAN1 == 0U))
  39. #error "No CAN is enabled in the RTE_Device.h!"
  40. #endif
  41. #if (RTE_CAN_CAN1 == 1U)
  42. #define CAN_CTRL_NUM (2U)
  43. #else
  44. #define CAN_CTRL_NUM (1U)
  45. #endif
  46. // CNTL register bit definitions
  47. #define CNTL_INIT_Msk (1U << 0)
  48. #define CNTL_IE_Msk (1U << 1)
  49. #define CNTL_SIE_Msk (1U << 2)
  50. #define CNTL_EIE_Msk (1U << 3)
  51. #define CNTL_DAR_Msk (1U << 5)
  52. #define CNTL_CCE_Msk (1U << 6)
  53. #define CNTL_TEST_Msk (1U << 7)
  54. // STAT register bit definitions
  55. #define STAT_LEC_Msk (7U << 0)
  56. #define STAT_TXOK_Msk (1U << 3)
  57. #define STAT_RXOK_Msk (1U << 4)
  58. #define STAT_EPASS_Msk (1U << 5)
  59. #define STAT_EWARN_Msk (1U << 6)
  60. #define STAT_BOFF_Msk (1U << 7)
  61. // EC register bit definitions
  62. #define EC_TEC_7_0_Msk (0xFFU << 0)
  63. #define EC_REC_6_0_Msk (0x7FU << 8)
  64. #define EC_RP_Msk (1U << 15)
  65. // BT register bit definitions
  66. #define BT_BRP_Msk (0x3FU << 0)
  67. #define BT_SJW_Msk (3U << 6)
  68. #define BT_TSEG1_Msk (0x0FU << 8)
  69. #define BT_TSEG2_Msk (0x07U << 12)
  70. // TEST register bit definitions
  71. #define TEST_BASIC_Msk (1U << 2)
  72. #define TEST_SILENT_Msk (1U << 3)
  73. #define TEST_LBACK_Msk (1U << 4)
  74. #define TEST_TX1_0_Msk (3U << 5)
  75. #define TEST_RX_Msk (1U << 7)
  76. // BRPE register bit definitions
  77. #define BRPE_BRPE_Msk (0x0FU << 0)
  78. // CMDREQ register bit definitions
  79. #define IF_CMDREQ_MESSABE_NUMBER_Msk (0x3FU << 0)
  80. #define IF_CMDREQ_BUSY_Msk (1U << 15)
  81. // CMDMSK_W/R register bit definitions
  82. #define IF_CMDMSK_DATA_B_Msk (1U << 0)
  83. #define IF_CMDMSK_DATA_A_Msk (1U << 1)
  84. #define IF_CMDMSK_TXRQST_Msk (1U << 2)
  85. #define IF_CMDMSK_NEWDAT_Msk (1U << 2)
  86. #define IF_CMDMSK_CLRINTPND_Msk (1U << 3)
  87. #define IF_CMDMSK_CTRL_Msk (1U << 4)
  88. #define IF_CMDMSK_ARB_Msk (1U << 5)
  89. #define IF_CMDMSK_MASK_Msk (1U << 6)
  90. #define IF_CMDMSK_WR_RD_Msk (1U << 7)
  91. // MSK1 register bit definitions
  92. #define IF_MSK1_MSK15_0_Msk (0xFFFFU << 0)
  93. // MSK2 register bit definitions
  94. #define IF_MSK2_MSK28_16_Msk (0x1FFFU << 0)
  95. #define IF_MSK2_MDIR_Msk (1U << 14)
  96. #define IF_MSK2_MXTD_Msk (1U << 15)
  97. // ARB1 register bit definitions
  98. #define IF_ARB1_ID15_0_Msk (0xFFFFU << 0)
  99. // ARB2 register bit definitions
  100. #define IF_ARB2_ID28_16_Msk (0x1FFFU << 0)
  101. #define IF_ARB2_DIR_Msk (1U << 13)
  102. #define IF_ARB2_XTD_Msk (1U << 14)
  103. #define IF_ARB2_MSGVAL_Msk (1U << 15)
  104. // MCTRL register bit definitions
  105. #define IF_MCTRL_DLC3_0_Msk (0x0FU << 0)
  106. #define IF_MCTRL_EOB_Msk (1U << 7)
  107. #define IF_MCTRL_TXRQST_Msk (1U << 8)
  108. #define IF_MCTRL_RMTEN_Msk (1U << 9)
  109. #define IF_MCTRL_RXIE_Msk (1U << 10)
  110. #define IF_MCTRL_TXIE_Msk (1U << 11)
  111. #define IF_MCTRL_UMASK_Msk (1U << 12)
  112. #define IF_MCTRL_INTPND_Msk (1U << 13)
  113. #define IF_MCTRL_MSGLST_Msk (1U << 14)
  114. #define IF_MCTRL_NEWDAT_Msk (1U << 15)
  115. #endif // __CAN_LPC18XX_H