dcan.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. /**
  2. * \file dcan.h
  3. *
  4. * \brief DCAN APIs and macros.
  5. *
  6. * This file contains the driver API prototypes and macro definitions for
  7. * DCAN peripheral.
  8. */
  9. /*
  10. * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
  11. */
  12. /*
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions
  15. * are met:
  16. *
  17. * Redistributions of source code must retain the above copyright
  18. * notice, this list of conditions and the following disclaimer.
  19. *
  20. * Redistributions in binary form must reproduce the above copyright
  21. * notice, this list of conditions and the following disclaimer in the
  22. * documentation and/or other materials provided with the
  23. * distribution.
  24. *
  25. * Neither the name of Texas Instruments Incorporated nor the names of
  26. * its contributors may be used to endorse or promote products derived
  27. * from this software without specific prior written permission.
  28. *
  29. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  30. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  31. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  32. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  33. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  34. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  35. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  36. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  37. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  39. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. *
  41. */
  42. #ifndef __DCAN_H__
  43. #define __DCAN_H__
  44. #include "hw_dcan.h"
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. /******************************************************************************/
  49. /*
  50. ** Values that can be passed to DCAN APIs
  51. */
  52. /******************************************************************************/
  53. /*
  54. ** Values that can be passed to 'DCANIntLineEnable' and 'DCANIntLineDisable'APIs
  55. ** as 'enableLine' and 'disableLine' respectively.
  56. ** 'enableLine','disableLine' can take both the values.
  57. ** For e.g. (DCAN_INT_LINE0 | DCAN_INT_LINE1) can be passed.
  58. */
  59. /* Enable/Disable Interrupt line 0 of DCAN peripheral */
  60. #define DCAN_INT_LINE0 (DCAN_CTL_IE0)
  61. /* Enable/Disable Interrupt line 1 of DCAN peripheral */
  62. #define DCAN_INT_LINE1 (DCAN_CTL_IE1)
  63. /******************************************************************************/
  64. /*
  65. ** Values that can be passed to 'DCANIntEnable' and 'DCANIntDisable' APIs as
  66. ** 'intFlags'.
  67. ** 'intFlags' can take more than one value.
  68. ** For e.g. (DCAN_STATUS_CHANGE_INT | DCAN_ERROR_INT) can be passed.
  69. */
  70. /* Enable/Disable the Status change interrupt of DCAN peripheral */
  71. #define DCAN_STATUS_CHANGE_INT (0x00000004u)
  72. /* Enable/Disable the error interrupt of DCAN peripheral */
  73. #define DCAN_ERROR_INT (0x00000008u)
  74. /******************************************************************************/
  75. /*
  76. ** Values that can be passed to 'DCANAutoReTransmitControl' API as 'autoReTxn'.
  77. */
  78. /* Enable Auto Re-transmission of DCAN peripheral */
  79. #define DCAN_AUTO_RETXN_ENABLE (0x00000000u)
  80. /* Disable Auto Re-transmission of DCAN peripheral */
  81. #define DCAN_AUTO_RETXN_DISABLE (0x00000020u)
  82. /******************************************************************************/
  83. /*
  84. ** Values that can be passed to 'DCANConfigRegWriteAccessControl' API as
  85. ** 'regConfig'.
  86. */
  87. /* CPU has write access to the configuration registers */
  88. #define DCAN_CONF_REG_WR_ACCESS_ENABLE (DCAN_CTL_CCE)
  89. /* CPU has no write access to the configuration registers */
  90. #define DCAN_CONF_REG_WR_ACCESS_DISABLE (DCAN_CTL_CCE_NOACCESS)
  91. /******************************************************************************/
  92. /*
  93. ** Values that can be passed to 'DCANTestModeControl' API as 'testMode'.
  94. */
  95. /* Enable Test mode of operation */
  96. #define DCAN_TEST_MODE_ENABLE (DCAN_CTL_TEST)
  97. /* Disable Test mode of operation */
  98. #define DCAN_TEST_MODE_DISABLE (DCAN_CTL_TEST_NORMALMODE)
  99. /******************************************************************************/
  100. /*
  101. ** Values that can be passed to 'DCANAutoBusOnControl' API as 'busControl'.
  102. */
  103. /* Enable the Auto-bus-on feature */
  104. #define DCAN_AUTO_BUS_ON_ENABLE (DCAN_CTL_ABO)
  105. /* Disable the Auto-bus-on feature */
  106. #define DCAN_AUTO_BUS_ON_DISABLE (DCAN_CTL_ABO_DISABLED)
  107. /******************************************************************************/
  108. /*
  109. ** Values that can be passed to 'DCANParityControl' API as 'paritySet'.
  110. */
  111. /* Enable Parity function */
  112. #define DCAN_PARITY_FUNC_ENABLE (DCAN_CTL_PMD_ENABLED << \
  113. DCAN_CTL_PMD_SHIFT)
  114. /* Disable Parity function */
  115. #define DCAN_PARITY_FUNC_DISABLE (DCAN_CTL_PMD_DISABLED << \
  116. DCAN_CTL_PMD_SHIFT)
  117. /******************************************************************************/
  118. /*
  119. ** Values that can be passed to 'DCANDmaRequestLineEnable' and
  120. ** 'DCANDmaRequestLineDisable' APIs as 'ifRegFlags'.
  121. ** 'ifRegFlags' can take more than one value.
  122. ** For e.g. (DCAN_DMA_REQUEST_LINE_ENABLE_IF1 | DCAN_DMA_REQUEST_LINE_ENABLE_IF2)
  123. ** can be passed as 'ifRegFlags'
  124. */
  125. /* Enable/Disable DMA request line for IF1 */
  126. #define DCAN_DMA_REQUEST_LINE_IF1 (DCAN_CTL_DE1)
  127. /* Enable/Disable DMA request line for IF2 */
  128. #define DCAN_DMA_REQUEST_LINE_IF2 (DCAN_CTL_DE2)
  129. /* Enable/Disable DMA request line for IF3 */
  130. #define DCAN_DMA_REQUEST_LINE_IF3 (DCAN_CTL_DE3)
  131. /******************************************************************************/
  132. /*
  133. ** Values that can be used to check the status of DCAN_ES register got from
  134. ** 'DCANErrAndStatusRegInfoGet' API.
  135. */
  136. /* No error is detected */
  137. #define DCAN_LST_ERRCODE_NO_ERR (DCAN_ES_LEC_NOERROR)
  138. /* Stuff error is detected */
  139. #define DCAN_LST_ERRCODE_STUFF_ERR (DCAN_ES_LEC_STUFFERROR)
  140. /* Form error is detected */
  141. #define DCAN_LST_ERRCODE_FORM_ERR (DCAN_ES_LEC_FORMERROR)
  142. /* Ack error is detected */
  143. #define DCAN_LST_ERRCODE_ACK_ERR (DCAN_ES_LEC_ACKERROR)
  144. /* Bit1 error is detected */
  145. #define DCAN_LST_ERRCODE_BIT1_ERR (DCAN_ES_LEC_BIT1ERROR)
  146. /* Bit0 error is detected */
  147. #define DCAN_LST_ERRCODE_BIT0_ERR (DCAN_ES_LEC_BIT0ERROR)
  148. /* CRC error detected */
  149. #define DCAN_LST_ERRCODE_CRC_ERR (DCAN_ES_LEC_CRCERROR)
  150. /* No event is generated on the CAN bus since last read of DCAN_ES */
  151. #define DCAN_NO_EVENT_ON_CAN_BUS (DCAN_ES_LEC_NOEVENT)
  152. /* DCAN transmitted message successfully */
  153. #define DCAN_TXD_MSG_SUCCESSFULLY (DCAN_ES_TXOK)
  154. /* DCAN received message successfully */
  155. #define DCAN_RXD_MSG_SUCCESSFULLY (DCAN_ES_RXOK)
  156. /* DCAN is in error passive state */
  157. #define DCAN_CORE_IN_ERR_PASSIVE (DCAN_ES_EPASS)
  158. /* Atleast one of the counters have reached the error warning limit */
  159. #define DCAN_ERR_WARN_STATE_RCHD (DCAN_ES_EWARN)
  160. /* DCAN is in Bus off state */
  161. #define DCAN_MOD_IN_BUS_OFF_STATE (DCAN_ES_BOFF)
  162. /* Parity error detected */
  163. #define DCAN_PARITY_ERR_DETECTED (DCAN_ES_PER)
  164. /* DCAN initiated system wakeup */
  165. #define DCAN_INITIATED_SYSTEM_WKUP (DCAN_ES_WAKEUPPND)
  166. /* DCAN is in local power down mode */
  167. #define DCAN_IN_LOCAL_PWR_DWN_MODE (DCAN_ES_PDA)
  168. /******************************************************************************/
  169. /*
  170. ** Values that can be sent to 'DCANErrCntrRegStatusGet' API as 'cntrFlags'.
  171. ** 'cntrFlags' can take more than one value.
  172. ** For e.g. (DCAN_TX_ERR_CNTR | DCAN_RX_ERR_CNTR | DCAN_RX_ERR_PASSIVE) can be
  173. ** sent as 'cntrFlags'.
  174. */
  175. /* Macro used to return the status of TEC[7:0] field of DCAN_ERRC register */
  176. #define DCAN_TX_ERR_CNTR (DCAN_ERRC_TEC)
  177. /* Macro used to return the status of REC[6:0] field of DCAN_ERRC register*/
  178. #define DCAN_RX_ERR_CNTR (DCAN_ERRC_REC)
  179. /* Macro used to return the status of RP field of DCAN_ERRC register */
  180. #define DCAN_RX_ERR_PASSIVE (DCAN_ERRC_RP)
  181. /******************************************************************************/
  182. /*
  183. ** Values that can be passed to 'DCANIntRegStatusGet' API as 'intLnFlag'.
  184. ** 'intLnFlag' can take more than one value.
  185. ** For e.g. (DCAN_INT_LINE0_STAT | DCAN_INT_LINE1_STAT) can be passed as
  186. ** 'intLnFlag'.
  187. */
  188. /* Macro used to return the status of INT0ID[15:0] field of DCAN_INT register */
  189. #define DCAN_INT_LINE0_STAT (DCAN_INT_INT0ID)
  190. /* Macro used to return the status of INT1ID[23:16] field of DCAN_INT register */
  191. #define DCAN_INT_LINE1_STAT (DCAN_INT_INT1ID)
  192. /******************************************************************************/
  193. /*
  194. ** Values that can be passed to 'DCANTestModesEnable' and 'DCANTestModesDisable'
  195. ** API as 'tstMode'.
  196. */
  197. /* Macro that can be used to enable/disable silent mode */
  198. #define DCAN_TST_SILENT_MD (DCAN_TEST_SILENT)
  199. /* Macro that can be used to enable/disable loopback mode */
  200. #define DCAN_TST_LPBCK_MD (DCAN_TEST_LBACK)
  201. /* Macro that can be used to enable/disable external loopback mode */
  202. #define DCAN_TST_EXTLPBCK_MD (DCAN_TEST_EXL)
  203. /* Macro that can be used to enable/disable loopback with silent mode */
  204. #define DCAN_TST_LPBCK_SILENT_MD (DCAN_TEST_LBACK | \
  205. DCAN_TEST_SILENT)
  206. /* Macro that can be used to enable/disable direct access to RAM */
  207. #define DCAN_TST_RAM_DIRECT_ACCESS (DCAN_TEST_RDA)
  208. /******************************************************************************/
  209. /*
  210. ** Values that can be passed to 'DCANTxPinControl' API as 'pinCtl'.
  211. */
  212. /* CAN_TX pin is controlled by CAN core */
  213. #define DCAN_TST_TX_NRML_OP (DCAN_TEST_TX_NORMAL)
  214. /* Sample point can be monitored at CAN_TX pin */
  215. #define DCAN_TST_TX_SAMPLE_PT_MNTR (DCAN_TEST_TX_SAMPLEPOINT << \
  216. DCAN_TEST_TX_SHIFT)
  217. /* CAN_TX pin drives a dominant value */
  218. #define DCAN_TST_TX_DRIV_DOM_VAL (DCAN_TEST_TX_DOMINANT << \
  219. DCAN_TEST_TX_SHIFT)
  220. /* CAN_TX pin drives a recessive value */
  221. #define DCAN_TST_TX_DRIV_RSV_VAL (DCAN_TEST_TX_RECESSIVE << \
  222. DCAN_TEST_TX_SHIFT)
  223. /******************************************************************************/
  224. /*
  225. ** Values that can be used to check the status received from 'DCANRxPinStatusGet'
  226. ** API.
  227. */
  228. /* CAN bus is dominant */
  229. #define DCAN_TST_RX_IS_DOM (DCAN_TEST_RX_DOMINANT)
  230. /* CAN bus is recessive */
  231. #define DCAN_TST_RX_IS_RSV (DCAN_TEST_RX)
  232. /******************************************************************************/
  233. /*
  234. ** Values that can be used to check the status received from
  235. ** 'DCANParityErrCdRegStatusGet' API.
  236. */
  237. /* Macro used to return the message number status from DCAN_PERR register */
  238. #define DCAN_PARITY_ERR_MSG_NUM (DCAN_PERR_MESSAGE_NUMBER)
  239. /* Macro used to return the word number status from DCAN_PERR register */
  240. #define DCAN_PARITY_ERR_WRD_NUM (DCAN_PERR_WORD_NUMBER)
  241. /******************************************************************************/
  242. /*
  243. ** Value that can be used while checking the status obtained from
  244. ** 'DCANTxRqstXStatusGet' API.
  245. ** 'n' can take these values
  246. ** 1 <= n <= 8.
  247. */
  248. /* Value that can be used to check the status of DCAN_TXRQST_X register */
  249. #define DCAN_TXRQST_X_REG(n) (DCAN_TXRQ_X_TXRQSTREG1 << \
  250. (((n) - 1) * 2))
  251. /******************************************************************************/
  252. /*
  253. ** Value that can be used while checking the status obtained from
  254. ** 'DCANNewDataXStatusGet' API.
  255. ** 'n' can take these values
  256. ** 1 <= n <= 8.
  257. */
  258. /* Value that can be used to check the status of DCAN_NWDAT_X register */
  259. #define DCAN_NEWDAT_X_REG(n) (DCAN_NWDAT_X_NEWDATREG1 << \
  260. (((n) - 1) * 2))
  261. /******************************************************************************/
  262. /*
  263. ** Value that can be used while checking the status obtained from
  264. ** 'DCANMsgValidXStatusGet' API.
  265. ** 'n' can take these values
  266. ** 1 <= n <= 8.
  267. */
  268. /* Value that can be used to check the status of DCAN_MSGVAL_X register */
  269. #define DCAN_MSGVAL_X_REG(n) (DCAN_MSGVAL_X_MSGVALREG1 << \
  270. (((n) - 1) * 2))
  271. /******************************************************************************/
  272. /*
  273. ** Value that can be used while checking the status obtained from
  274. ** 'DCANIntPendingXStatusGet' API.
  275. ** 'n' can take these values
  276. ** 1 <= n <= 8.
  277. */
  278. /* Value that can be used to check the status of DCAN_INTPND_X register */
  279. #define DCAN_INTPND_X_REG(n) (DCAN_INTPND_X_INTPNDREG1 << \
  280. (((n) - 1) * 2))
  281. /******************************************************************************/
  282. /*
  283. ** Values can be used to check the status obtained from 'DCANIFBusyStatusGet'
  284. ** API.
  285. */
  286. /* Transfer between IF1/IF2 register set and message RAM is in progress */
  287. #define DCAN_IF_BUSY (DCAN_IFCMD_BUSY)
  288. /* No transfer between IF1/IF2 register set and message RAM */
  289. #define DCAN_IF_NOT_BUSY (DCAN_IFCMD_BUSY_NOTRANSFER)
  290. /******************************************************************************/
  291. /*
  292. ** Values that can be sent to 'DCANMsgIdSet' API as 'idLength'.
  293. */
  294. /* Identifier of 11 bit size is used */
  295. #define DCAN_11_BIT_ID (DCAN_IFARB_XTD_11_BIT)
  296. /* Identifier of 29 bit size is used */
  297. #define DCAN_29_BIT_ID (DCAN_IFARB_XTD)
  298. /******************************************************************************/
  299. /*
  300. ** Values that can be sent to 'DCANIntMuxConfig' API as 'intLine'
  301. */
  302. /* DCANINT0 line is active if corresponding IntPnd flag is one */
  303. #define DCAN_INT0_ACTIVE (0x00000000u)
  304. /* DCANINT1 line is active if corresponding IntPnd flag is one */
  305. #define DCAN_INT1_ACTIVE (0x00000001u)
  306. /******************************************************************************/
  307. /*
  308. ** Values that can be sent to 'DCANMsgObjValidate', 'DCANMsgObjInvalidate,
  309. ** 'DCANCommandRegSet', 'DCANIFBusyStatusGet, 'DCANMsgIdSet',
  310. ** 'DCANMsgDirectionSet', 'DCANDataWrite', 'DCANDataRead',
  311. ** 'DCANDataLengthCodeSet', 'DCANMsgObjIntEnable', 'DCANMsgObjIntDisable',
  312. ** 'DCANFIFOEndOfBlockControl', 'DCANMsgObjectDirectionConfig',
  313. ** 'DCANMsgObjectMskConfig', APIs as ''regNum'.
  314. */
  315. /* Interface register 1 is used */
  316. #define DCAN_IF1_REG (1u)
  317. /* Interface register 2 is used */
  318. #define DCAN_IF2_REG (2u)
  319. /* Interface register 3 is used */
  320. #define DCAN_IF3_REG (3u)
  321. /******************************************************************************/
  322. /*
  323. ** Values that can be sent to 'DCANMsgDirectionSet' API as 'msgDir'.
  324. */
  325. /* Message object set to transmit a message*/
  326. #define DCAN_TX_DIR (DCAN_IFARB_DIR)
  327. /* Message object set to receive a message*/
  328. #define DCAN_RX_DIR (DCAN_IFARB_DIR_RECEIVE)
  329. /******************************************************************************/
  330. /*
  331. ** Values that can be sent to 'DCANMsgObjIntEnable' and 'DCANMsgObjIntDisable'
  332. ** APIs as 'intFlags'.
  333. */
  334. /* Enable/disable transmit interrupt */
  335. #define DCAN_TRANSMIT_INT (DCAN_IFMCTL_TXIE)
  336. /* Enable/disable receive interrupt */
  337. #define DCAN_RECEIVE_INT (DCAN_IFMCTL_RXIE)
  338. /******************************************************************************/
  339. /*
  340. ** Values that can be sent to 'DCANFIFOEndOfBlockControl' API as 'eob'.
  341. */
  342. /* Enable end of block */
  343. #define DCAN_END_OF_BLOCK_ENABLE (DCAN_IFMCTL_EOB)
  344. /* Disable end of block */
  345. #define DCAN_END_OF_BLOCK_DISABLE (0x00000000u)
  346. /******************************************************************************/
  347. /*
  348. ** Values that can be passed to 'DCANCommandRegSet' API as 'cmdFlags'.
  349. ** 'cmdFlags' can be passed by combining more than one macro.
  350. ** For e.g. (DCAN_DMA_ACTIVE | DCAN_DAT_A_ACCESS | DCAN_DAT_B_ACCESS)
  351. */
  352. /* Enable DMA feature */
  353. #define DCAN_DMA_ACTIVE (DCAN_IFCMD_DMAACTIVE)
  354. /* Access data from IF DataA register */
  355. #define DCAN_DAT_A_ACCESS (DCAN_IFCMD_DATAA)
  356. /* Access data from IF DataB register */
  357. #define DCAN_DAT_B_ACCESS (DCAN_IFCMD_DATAB)
  358. /* Access the TxRqst bit */
  359. #define DCAN_TXRQST_ACCESS (DCAN_IFCMD_TXRQST_NEWDAT)
  360. /* Clear the IntPnd bit */
  361. #define DCAN_CLR_INTPND (DCAN_IFCMD_CLRINTPND)
  362. /* Access control bits */
  363. #define DCAN_ACCESS_CTL_BITS (DCAN_IFCMD_CONTROL)
  364. /* Access Arbitration bits */
  365. #define DCAN_ACCESS_ARB_BITS (DCAN_IFCMD_ARB)
  366. /* Access the mask bits */
  367. #define DCAN_ACCESS_MSK_BITS (DCAN_IFCMD_MASK)
  368. /* Transfer direction is from IF registers to message RAM */
  369. #define DCAN_MSG_WRITE (DCAN_IFCMD_WR_RD)
  370. /* Transfer direction is from message RAM to IF registers */
  371. #define DCAN_MSG_READ (0x00000000u)
  372. /******************************************************************************/
  373. /*
  374. ** Values that can be passed to 'DCAN_IDENTIFIER_MSK' macro as idType.
  375. */
  376. /* 11 bit id is used */
  377. #define DCAN_ID_MSK_11_BIT (18u)
  378. /* 29 bit id is used */
  379. #define DCAN_ID_MSK_29_BIT (0u)
  380. /******************************************************************************/
  381. /*
  382. ** Value that can be passed to 'DCANMsgObjectMskConfig' API as 'idMsk'.
  383. ** 'mask' can take values between 0 <= idMsk <= 0x1FFFFFFF \n
  384. ** 'idType' can take the following values \n
  385. ** DCAN_ID_MSK_11_BIT - 11 bit identifier is used \n
  386. ** DCAN_ID_MSK_29_BIT - 29 bit identifier is used \n
  387. */
  388. #define DCAN_IDENTIFIER_MSK(mask, idType) (mask << idType)
  389. /******************************************************************************/
  390. /*
  391. ** Values that can be passed to 'DCANMsgObjectMskConfig' API as 'msgDir'.
  392. */
  393. /* Message direction bit is used for acceptance filtering */
  394. #define DCAN_MSK_MSGDIR_ENABLE (DCAN_IFMSK_MDIR)
  395. /* Message direction bit has no effect on acceptance filtering */
  396. #define DCAN_MSK_MSGDIR_DISABLE (DCAN_IFMSK_MDIR_NOTUSED)
  397. /******************************************************************************/
  398. /*
  399. ** Values that can be passed to 'DCANMsgObjectMskConfig' API as 'extId'.
  400. */
  401. /* The IDE bit is used for acceptance filtering */
  402. #define DCAN_MSK_EXT_ID_ENABLE (DCAN_IFMSK_MXTD)
  403. /* The IDE bit is not used for acceptance filtering */
  404. #define DCAN_MSK_EXT_ID_DISABLE (DCAN_IFMSK_MXTD_NOTUSED)
  405. /******************************************************************************/
  406. /*
  407. ** Values that can be passed to 'DCANIF3ObservationFlagSet' API as 'obsFlags'.
  408. ** 'obsFlags' can take more than 1 value.
  409. ** For e.g. (DCAN_MASK_DATA | DCAN_ARB_DATA)
  410. */
  411. /* Mask data read observation */
  412. #define DCAN_MASK_DATA (DCAN_IF3OBS_MASK)
  413. /* Arbitration data read observation */
  414. #define DCAN_ARB_DATA (DCAN_IF3OBS_ARB)
  415. /* Ctrl read observation */
  416. #define DCAN_CTRL_DATA (DCAN_IF3OBS_CTRL)
  417. /* Data A read observation */
  418. #define DCAN_DAT_A_DATA (DCAN_IF3OBS_DATAA)
  419. /* Data B read observation */
  420. #define DCAN_DAT_B_DATA (DCAN_IF3OBS_DATAB)
  421. /******************************************************************************/
  422. /*
  423. ** Values that can be used to check the status obtained from
  424. ** 'DCANIF3ObservationFlagStatGet' API.
  425. */
  426. /* IF3 status of Mask data read access */
  427. #define DCAN_IF3_MASK_STATUS (DCAN_IF3OBS_IF3SM)
  428. /* IF3 status of Arbitration data read access */
  429. #define DCAN_IF3_ARB_STATUS (DCAN_IF3OBS_IF3SA)
  430. /* IF3 status of Control bits read access */
  431. #define DCAN_IF3_CTRL_STATUS (DCAN_IF3OBS_IF3SC)
  432. /* IF3 status of Data A read access */
  433. #define DCAN_IF3_DAT_A_STATUS (DCAN_IF3OBS_IF3SDA)
  434. /* IF3 status of Data B read access */
  435. #define DCAN_IF3_DAT_B_STATUS (DCAN_IF3OBS_IF3SDB)
  436. /* IF3 Update data status */
  437. #define DCAN_IF3_UPDATE_STATUS (DCAN_IF3OBS_IF3UPD)
  438. /******************************************************************************/
  439. /*
  440. ** Values that can be used to check the status obtained from
  441. ** 'DCANIFMaskStatusGet' API.
  442. */
  443. /* Read Identifier mask */
  444. #define DCAN_ID_MSK_READ (DCAN_IF3MSK_MSK)
  445. /* Read mask message direction */
  446. #define DCAN_MSK_MSG_DIR_READ (DCAN_IF3MSK_MDIR)
  447. /* Read mask extended identifier */
  448. #define DCAN_MSK_EXT_ID_READ (DCAN_IF3MSK_MXTD)
  449. /******************************************************************************/
  450. /*
  451. ** Values that can be used to check the status obtained from 'DCANIFArbStatusGet'
  452. ** API.
  453. */
  454. /* Read message identifier */
  455. #define DCAN_MSG_ID_READ (DCAN_IF3ARB_MSK)
  456. /* Read message direction */
  457. #define DCAN_MSG_DIR_READ (DCAN_IF3ARB_DIR)
  458. /* Read extended identifier */
  459. #define DCAN_EXT_ID_READ (DCAN_IF3ARB_XTD)
  460. /* Read message valid status */
  461. #define DCAN_MSGVAL_READ (DCAN_IF3ARB_MSGVAL)
  462. /******************************************************************************/
  463. /*
  464. ** Values that can be used to check the status obtained from
  465. ** 'DCANIFMsgCtlStatusGet' API.
  466. */
  467. /* Read data length code */
  468. #define DCAN_DAT_LEN_CODE_READ (DCAN_IF3MCTL_DATALENGTHCODE)
  469. /* Read end of block bit */
  470. #define DCAN_END_OF_BLOCK_READ (DCAN_IF3MCTL_EOB)
  471. /* Read transmit request bit */
  472. #define DCAN_TXRQST_READ (DCAN_IF3MCTL_TXRQST)
  473. /* Read remote enable bit */
  474. #define DCAN_RMT_ENABLE_READ (DCAN_IF3MCTL_RMTEN)
  475. /* Read Rx interrupt enable bit */
  476. #define DCAN_RX_INT_ENABLE_READ (DCAN_IF3MCTL_RXIE)
  477. /* Read Tx interrupt enable bit */
  478. #define DCAN_TX_INT_ENABLE_READ (DCAN_IF3MCTL_TXIE)
  479. /* Read use acceptance mask bit */
  480. #define DCAN_UMASK_READ (DCAN_IF3MCTL_UMASK)
  481. /* Read interrupt pending status */
  482. #define DCAN_INTPND_READ (DCAN_IF3MCTL_INTPND)
  483. /* Read message lost status */
  484. #define DCAN_MSG_LOST_READ (DCAN_IF3MCTL_MSGLST)
  485. /* Read new data status */
  486. #define DCAN_NEWDAT_READ (DCAN_IF3MCTL_NEWDAT)
  487. /******************************************************************************/
  488. /*
  489. ** Values that can be passed to 'DCANNewDataControl' API as 'newDat'.
  490. */
  491. /* Set NewDat */
  492. #define DCAN_NEW_DAT_SET (DCAN_IFMCTL_NEWDAT)
  493. /* Clear NewDat */
  494. #define DCAN_NEW_DAT_CLR (DCAN_IFMCTL_NEWDAT_NONEWDATA)
  495. /******************************************************************************/
  496. /*
  497. ** Values that can be passed to 'DCANUseAcceptanceMaskControl' API as 'uMask'
  498. */
  499. /* Use acceptance mask */
  500. #define DCAN_MASK_USED (DCAN_IFMCTL_UMASK)
  501. /* Acceptance mask not used */
  502. #define DCAN_MASK_IGNORED (DCAN_IFMCTL_UMASK_IGNORED)
  503. /******************************************************************************/
  504. /*
  505. ** Values that can be passed to 'DCANTransmitRequestControl' API as 'txRqst'
  506. */
  507. /* Request for transmission */
  508. #define DCAN_TRANSMIT_REQUESTED (DCAN_IFMCTL_TXRQST)
  509. /* Transmission not requested */
  510. #define DCAN_TRANSMIT_NOT_REQUESTED (DCAN_IFMCTL_TXRQST_NOREQUESTED)
  511. /******************************************************************************/
  512. /* DCAN API PROTOTYPES */
  513. /******************************************************************************/
  514. extern void DCANInitModeSet(unsigned int baseAdd);
  515. extern void DCANNormalModeSet(unsigned int baseAdd);
  516. extern void DCANBitTimingConfig(unsigned int baseAdd,
  517. unsigned int btrValue);
  518. extern void DCANReset(unsigned int baseAdd);
  519. extern void DCANIntEnable(unsigned int baseAdd, unsigned int intFlags);
  520. extern void DCANIntDisable(unsigned int baseAdd, unsigned int intFlags);
  521. extern void DCANAutoReTransmitControl(unsigned int baseAdd, unsigned int autoReTxn);
  522. extern void DCANConfigRegWriteAccessControl(unsigned int baseAdd,
  523. unsigned int regConfig);
  524. extern void DCANTestModeControl(unsigned int baseAdd, unsigned int testMode);
  525. extern void DCANAutoBusOnControl(unsigned int baseAdd, unsigned int busControl);
  526. extern void DCANParityControl(unsigned int baseAdd, unsigned int paritySet);
  527. extern void DCANIntLineEnable(unsigned int baseAdd, unsigned int enableLine);
  528. extern void DCANIntLineDisable(unsigned int baseAdd, unsigned int disableLine);
  529. extern void DCANDmaRequestLineEnable(unsigned int baseAdd, unsigned int ifRegFlags);
  530. extern void DCANDmaRequestLineDisable(unsigned int baseAdd, unsigned int ifRegFlags);
  531. extern unsigned int DCANIntRegStatusGet(unsigned int baseAdd, unsigned int intLnFlag);
  532. extern unsigned int DCANErrAndStatusRegInfoGet(unsigned int baseAdd);
  533. extern unsigned int DCANErrCntrRegStatusGet(unsigned int baseAdd,
  534. unsigned int cntrFlags);
  535. extern void DCANTestModesEnable(unsigned int baseAdd, unsigned int tstMode);
  536. extern void DCANTestModesDisable(unsigned int baseAdd, unsigned int tstMode);
  537. extern void DCANTxPinControl(unsigned int baseAdd, unsigned int pinCtl);
  538. extern unsigned int DCANRxPinStatusGet(unsigned int baseAdd);
  539. extern unsigned int DCANParityErrCdRegStatusGet(unsigned int baseAdd,
  540. unsigned int statFlg);
  541. extern void DCANAutoBusOnTimeValSet(unsigned int baseAdd, unsigned int timeVal);
  542. extern unsigned int DCANAutoBusOnTimeValGet(unsigned int baseAdd);
  543. extern unsigned int DCANTxRqstXStatusGet(unsigned int baseAdd);
  544. extern unsigned int DCANTxRqstStatusGet(unsigned int baseAdd, unsigned int msgNum);
  545. extern unsigned int DCANTxRqstStatGet(unsigned int baseAdd);
  546. extern unsigned int DCANNewDataXStatusGet(unsigned int baseAdd);
  547. extern unsigned int DCANNewDataStatusGet(unsigned int baseAdd, unsigned int msgNum);
  548. extern unsigned int DCANNewDataStatGet(unsigned int baseAdd);
  549. extern void DCANMsgObjValidate(unsigned int baseAdd, unsigned int regNum);
  550. extern void DCANMsgObjInvalidate(unsigned baseAdd, unsigned int regNum);
  551. extern void DCANCommandRegSet(unsigned int baseAdd, unsigned int cmdFlags,
  552. unsigned int objNum, unsigned int regNum);
  553. extern unsigned int DCANIntPendingXStatusGet(unsigned int baseAdd);
  554. extern unsigned int DCANIntPendingStatusGet(unsigned int baseAdd, unsigned int msgNum);
  555. extern unsigned int DCANMsgValidXStatusGet(unsigned int baseAdd);
  556. extern unsigned int DCANMsgValidStatusGet(unsigned int baseAdd, unsigned int msgNum);
  557. extern void DCANIntMuxConfig(unsigned int baseAdd, unsigned int intLine,
  558. unsigned int msgNum);
  559. extern unsigned int DCANIFBusyStatusGet(unsigned int baseAdd, unsigned int regNum);
  560. extern void DCANMsgIdSet(unsigned int baseAdd, unsigned int msgId,
  561. unsigned int idLength, unsigned int regNum);
  562. extern void DCANMsgDirectionSet(unsigned int baseAdd, unsigned int msgDir,
  563. unsigned int regNum);
  564. extern void DCANDataWrite(unsigned int baseAdd, unsigned int* dataPtr,
  565. unsigned int regNum);
  566. extern void DCANDataRead(unsigned int baseAdd, unsigned int* data, unsigned int regNum);
  567. extern void DCANDataLengthCodeSet(unsigned int baseAdd, unsigned int dlc,
  568. unsigned int regNum);
  569. extern void DCANMsgObjIntEnable(unsigned int baseAdd, unsigned int intFlags,
  570. unsigned int regNum);
  571. extern void DCANMsgObjIntDisable(unsigned int baseAdd, unsigned int intFlags,
  572. unsigned int regNum);
  573. extern void DCANFIFOEndOfBlockControl(unsigned int baseAdd, unsigned int eob,
  574. unsigned int regNum);
  575. extern void DCANMsgObjectMskConfig(unsigned int baseAdd, unsigned int idMsk,
  576. unsigned int msgDir, unsigned int extId,
  577. unsigned int regNum);
  578. extern void DCANIF3RegUpdateEnableSet(unsigned int baseAdd,
  579. unsigned int msgNum);
  580. extern unsigned char DCANIF3ObservationFlagStatGet(unsigned int baseAdd);
  581. extern void DCANIF3ObservationFlagSet(unsigned int baseAdd, unsigned int obsFlags);
  582. extern void DCANIF3ObservationFlagClear(unsigned int baseAdd, unsigned int obsFlags);
  583. extern unsigned int DCANIFMaskStatusGet(unsigned int baseAdd, unsigned int regNum);
  584. extern unsigned int DCANIFArbStatusGet(unsigned int baseAdd, unsigned int regNum);
  585. extern unsigned int DCANIFMsgCtlStatusGet(unsigned int baseAdd, unsigned int regNum);
  586. extern void DCANClrIntPnd(unsigned int baseAdd, unsigned int regNum);
  587. extern void DCANNewDataControl(unsigned int baseAdd, unsigned int newDat,
  588. unsigned int regNum);
  589. extern void DCANUseAcceptanceMaskControl(unsigned int baseAdd, unsigned int uMask,
  590. unsigned int regNum);
  591. extern void DCANTransmitRequestControl(unsigned int baseAdd, unsigned int txRqst,
  592. unsigned int regNum);
  593. #ifdef __cplusplus
  594. }
  595. #endif
  596. #endif