1 /** @file can.h 2 * @brief CAN Driver Header File 3 * @date 29.May.2013 4 * @version 03.05.02 5 * 6 * This file contains: 7 * - Definitions 8 * - Types 9 * - Interface Prototypes 10 * . 11 * which are relevant for the CAN driver. 12 */ 13 14 /* (c) Texas Instruments 2009-2013, All rights reserved. */ 15 16 #ifndef __CAN_H__ 17 #define __CAN_H__ 18 19 #include "reg_can.h" 20 21 22 23 /* USER CODE BEGIN (0) */ 24 /* USER CODE END */ 25 26 /* CAN General Definitions */ 27 28 /** @def canLEVEL_ACTIVE 29 * @brief Alias name for CAN error operation level active (Error counter 0-95) 30 */ 31 #define canLEVEL_ACTIVE 0x00U 32 33 /** @def canLEVEL_WARNING 34 * @brief Alias name for CAN error operation level warning (Error counter 96-127) 35 */ 36 #define canLEVEL_WARNING 0x40U 37 38 /** @def canLEVEL_PASSIVE 39 * @brief Alias name for CAN error operation level passive (Error counter 128-255) 40 */ 41 #define canLEVEL_PASSIVE 0x20U 42 43 /** @def canLEVEL_BUS_OFF 44 * @brief Alias name for CAN error operation level bus off (Error counter 256) 45 */ 46 #define canLEVEL_BUS_OFF 0x80U 47 48 /** @def canERROR_NO 49 * @brief Alias name for no CAN error occurred 50 */ 51 #define canERROR_OK 0U 52 53 /** @def canERROR_STUFF 54 * @brief Alias name for CAN stuff error an RX message 55 */ 56 #define canERROR_STUFF 1U 57 58 /** @def canERROR_FORMAT 59 * @brief Alias name for CAN form/format error an RX message 60 */ 61 #define canERROR_FORMAT 2U 62 63 /** @def canERROR_ACKNOWLEDGE 64 * @brief Alias name for CAN TX message wasn't acknowledged 65 */ 66 #define canERROR_ACKNOWLEDGE 3U 67 68 /** @def canERROR_BIT1 69 * @brief Alias name for CAN TX message sending recessive level but monitoring dominant 70 */ 71 #define canERROR_BIT1 4U 72 73 /** @def canERROR_BIT0 74 * @brief Alias name for CAN TX message sending dominant level but monitoring recessive 75 */ 76 #define canERROR_BIT0 5U 77 78 /** @def canERROR_CRC 79 * @brief Alias name for CAN RX message received wrong CRC 80 */ 81 #define canERROR_CRC 6U 82 83 /** @def canERROR_NO 84 * @brief Alias name for CAN no message has send or received since last call of CANGetLastError 85 */ 86 #define canERROR_NO 7U 87 88 /** @def canMESSAGE_BOX1 89 * @brief Alias name for CAN message box 1 90 * 91 * @note This value should be used for API argument @a messageBox 92 */ 93 #define canMESSAGE_BOX1 1U 94 95 /** @def canMESSAGE_BOX2 96 * @brief Alias name for CAN message box 2 97 * 98 * @note This value should be used for API argument @a messageBox 99 */ 100 #define canMESSAGE_BOX2 2U 101 102 /** @def canMESSAGE_BOX3 103 * @brief Alias name for CAN message box 3 104 * 105 * @note This value should be used for API argument @a messageBox 106 */ 107 #define canMESSAGE_BOX3 3U 108 109 /** @def canMESSAGE_BOX4 110 * @brief Alias name for CAN message box 4 111 * 112 * @note This value should be used for API argument @a messageBox 113 */ 114 #define canMESSAGE_BOX4 4U 115 116 /** @def canMESSAGE_BOX5 117 * @brief Alias name for CAN message box 5 118 * 119 * @note This value should be used for API argument @a messageBox 120 */ 121 #define canMESSAGE_BOX5 5U 122 123 /** @def canMESSAGE_BOX6 124 * @brief Alias name for CAN message box 6 125 * 126 * @note This value should be used for API argument @a messageBox 127 */ 128 #define canMESSAGE_BOX6 6U 129 130 /** @def canMESSAGE_BOX7 131 * @brief Alias name for CAN message box 7 132 * 133 * @note This value should be used for API argument @a messageBox 134 */ 135 #define canMESSAGE_BOX7 7U 136 137 /** @def canMESSAGE_BOX8 138 * @brief Alias name for CAN message box 8 139 * 140 * @note This value should be used for API argument @a messageBox 141 */ 142 #define canMESSAGE_BOX8 8U 143 144 /** @def canMESSAGE_BOX9 145 * @brief Alias name for CAN message box 9 146 * 147 * @note This value should be used for API argument @a messageBox 148 */ 149 #define canMESSAGE_BOX9 9U 150 151 /** @def canMESSAGE_BOX10 152 * @brief Alias name for CAN message box 10 153 * 154 * @note This value should be used for API argument @a messageBox 155 */ 156 #define canMESSAGE_BOX10 10U 157 158 /** @def canMESSAGE_BOX11 159 * @brief Alias name for CAN message box 11 160 * 161 * @note This value should be used for API argument @a messageBox 162 */ 163 #define canMESSAGE_BOX11 11U 164 165 /** @def canMESSAGE_BOX12 166 * @brief Alias name for CAN message box 12 167 * 168 * @note This value should be used for API argument @a messageBox 169 */ 170 #define canMESSAGE_BOX12 12U 171 172 /** @def canMESSAGE_BOX13 173 * @brief Alias name for CAN message box 13 174 * 175 * @note This value should be used for API argument @a messageBox 176 */ 177 #define canMESSAGE_BOX13 13U 178 179 /** @def canMESSAGE_BOX14 180 * @brief Alias name for CAN message box 14 181 * 182 * @note This value should be used for API argument @a messageBox 183 */ 184 #define canMESSAGE_BOX14 14U 185 186 /** @def canMESSAGE_BOX15 187 * @brief Alias name for CAN message box 15 188 * 189 * @note This value should be used for API argument @a messageBox 190 */ 191 #define canMESSAGE_BOX15 15U 192 193 /** @def canMESSAGE_BOX16 194 * @brief Alias name for CAN message box 16 195 * 196 * @note This value should be used for API argument @a messageBox 197 */ 198 #define canMESSAGE_BOX16 16U 199 200 /** @def canMESSAGE_BOX17 201 * @brief Alias name for CAN message box 17 202 * 203 * @note This value should be used for API argument @a messageBox 204 */ 205 #define canMESSAGE_BOX17 17U 206 207 /** @def canMESSAGE_BOX18 208 * @brief Alias name for CAN message box 18 209 * 210 * @note This value should be used for API argument @a messageBox 211 */ 212 #define canMESSAGE_BOX18 18U 213 214 /** @def canMESSAGE_BOX19 215 * @brief Alias name for CAN message box 19 216 * 217 * @note This value should be used for API argument @a messageBox 218 */ 219 #define canMESSAGE_BOX19 19U 220 221 /** @def canMESSAGE_BOX20 222 * @brief Alias name for CAN message box 20 223 * 224 * @note This value should be used for API argument @a messageBox 225 */ 226 #define canMESSAGE_BOX20 20U 227 228 /** @def canMESSAGE_BOX21 229 * @brief Alias name for CAN message box 21 230 * 231 * @note This value should be used for API argument @a messageBox 232 */ 233 #define canMESSAGE_BOX21 21U 234 235 /** @def canMESSAGE_BOX22 236 * @brief Alias name for CAN message box 22 237 * 238 * @note This value should be used for API argument @a messageBox 239 */ 240 #define canMESSAGE_BOX22 22U 241 242 /** @def canMESSAGE_BOX23 243 * @brief Alias name for CAN message box 23 244 * 245 * @note This value should be used for API argument @a messageBox 246 */ 247 #define canMESSAGE_BOX23 23U 248 249 /** @def canMESSAGE_BOX24 250 * @brief Alias name for CAN message box 24 251 * 252 * @note This value should be used for API argument @a messageBox 253 */ 254 #define canMESSAGE_BOX24 24U 255 256 /** @def canMESSAGE_BOX25 257 * @brief Alias name for CAN message box 25 258 * 259 * @note This value should be used for API argument @a messageBox 260 */ 261 #define canMESSAGE_BOX25 25U 262 263 /** @def canMESSAGE_BOX26 264 * @brief Alias name for CAN message box 26 265 * 266 * @note This value should be used for API argument @a messageBox 267 */ 268 #define canMESSAGE_BOX26 26U 269 270 /** @def canMESSAGE_BOX27 271 * @brief Alias name for CAN message box 27 272 * 273 * @note This value should be used for API argument @a messageBox 274 */ 275 #define canMESSAGE_BOX27 27U 276 277 /** @def canMESSAGE_BOX28 278 * @brief Alias name for CAN message box 28 279 * 280 * @note This value should be used for API argument @a messageBox 281 */ 282 #define canMESSAGE_BOX28 28U 283 284 /** @def canMESSAGE_BOX29 285 * @brief Alias name for CAN message box 29 286 * 287 * @note This value should be used for API argument @a messageBox 288 */ 289 #define canMESSAGE_BOX29 29U 290 291 /** @def canMESSAGE_BOX30 292 * @brief Alias name for CAN message box 30 293 * 294 * @note This value should be used for API argument @a messageBox 295 */ 296 #define canMESSAGE_BOX30 30U 297 298 /** @def canMESSAGE_BOX31 299 * @brief Alias name for CAN message box 31 300 * 301 * @note This value should be used for API argument @a messageBox 302 */ 303 #define canMESSAGE_BOX31 31U 304 305 /** @def canMESSAGE_BOX32 306 * @brief Alias name for CAN message box 32 307 * 308 * @note This value should be used for API argument @a messageBox 309 */ 310 #define canMESSAGE_BOX32 32U 311 312 /** @def canMESSAGE_BOX33 313 * @brief Alias name for CAN message box 33 314 * 315 * @note This value should be used for API argument @a messageBox 316 */ 317 #define canMESSAGE_BOX33 33U 318 319 /** @def canMESSAGE_BOX34 320 * @brief Alias name for CAN message box 34 321 * 322 * @note This value should be used for API argument @a messageBox 323 */ 324 #define canMESSAGE_BOX34 34U 325 326 /** @def canMESSAGE_BOX35 327 * @brief Alias name for CAN message box 35 328 * 329 * @note This value should be used for API argument @a messageBox 330 */ 331 #define canMESSAGE_BOX35 35U 332 333 /** @def canMESSAGE_BOX36 334 * @brief Alias name for CAN message box 36 335 * 336 * @note This value should be used for API argument @a messageBox 337 */ 338 #define canMESSAGE_BOX36 36U 339 340 /** @def canMESSAGE_BOX37 341 * @brief Alias name for CAN message box 37 342 * 343 * @note This value should be used for API argument @a messageBox 344 */ 345 #define canMESSAGE_BOX37 37U 346 347 /** @def canMESSAGE_BOX38 348 * @brief Alias name for CAN message box 38 349 * 350 * @note This value should be used for API argument @a messageBox 351 */ 352 #define canMESSAGE_BOX38 38U 353 354 /** @def canMESSAGE_BOX39 355 * @brief Alias name for CAN message box 39 356 * 357 * @note This value should be used for API argument @a messageBox 358 */ 359 #define canMESSAGE_BOX39 39U 360 361 /** @def canMESSAGE_BOX40 362 * @brief Alias name for CAN message box 40 363 * 364 * @note This value should be used for API argument @a messageBox 365 */ 366 #define canMESSAGE_BOX40 40U 367 368 /** @def canMESSAGE_BOX41 369 * @brief Alias name for CAN message box 41 370 * 371 * @note This value should be used for API argument @a messageBox 372 */ 373 #define canMESSAGE_BOX41 41U 374 375 /** @def canMESSAGE_BOX42 376 * @brief Alias name for CAN message box 42 377 * 378 * @note This value should be used for API argument @a messageBox 379 */ 380 #define canMESSAGE_BOX42 42U 381 382 /** @def canMESSAGE_BOX43 383 * @brief Alias name for CAN message box 43 384 * 385 * @note This value should be used for API argument @a messageBox 386 */ 387 #define canMESSAGE_BOX43 43U 388 389 /** @def canMESSAGE_BOX44 390 * @brief Alias name for CAN message box 44 391 * 392 * @note This value should be used for API argument @a messageBox 393 */ 394 #define canMESSAGE_BOX44 44U 395 396 /** @def canMESSAGE_BOX45 397 * @brief Alias name for CAN message box 45 398 * 399 * @note This value should be used for API argument @a messageBox 400 */ 401 #define canMESSAGE_BOX45 45U 402 403 /** @def canMESSAGE_BOX46 404 * @brief Alias name for CAN message box 46 405 * 406 * @note This value should be used for API argument @a messageBox 407 */ 408 #define canMESSAGE_BOX46 46U 409 410 /** @def canMESSAGE_BOX47 411 * @brief Alias name for CAN message box 47 412 * 413 * @note This value should be used for API argument @a messageBox 414 */ 415 #define canMESSAGE_BOX47 47U 416 417 /** @def canMESSAGE_BOX48 418 * @brief Alias name for CAN message box 48 419 * 420 * @note This value should be used for API argument @a messageBox 421 */ 422 #define canMESSAGE_BOX48 48U 423 424 /** @def canMESSAGE_BOX49 425 * @brief Alias name for CAN message box 49 426 * 427 * @note This value should be used for API argument @a messageBox 428 */ 429 #define canMESSAGE_BOX49 49U 430 431 /** @def canMESSAGE_BOX50 432 * @brief Alias name for CAN message box 50 433 * 434 * @note This value should be used for API argument @a messageBox 435 */ 436 #define canMESSAGE_BOX50 50U 437 438 /** @def canMESSAGE_BOX51 439 * @brief Alias name for CAN message box 51 440 * 441 * @note This value should be used for API argument @a messageBox 442 */ 443 #define canMESSAGE_BOX51 51U 444 445 /** @def canMESSAGE_BOX52 446 * @brief Alias name for CAN message box 52 447 * 448 * @note This value should be used for API argument @a messageBox 449 */ 450 #define canMESSAGE_BOX52 52U 451 452 /** @def canMESSAGE_BOX53 453 * @brief Alias name for CAN message box 53 454 * 455 * @note This value should be used for API argument @a messageBox 456 */ 457 #define canMESSAGE_BOX53 53U 458 459 /** @def canMESSAGE_BOX54 460 * @brief Alias name for CAN message box 54 461 * 462 * @note This value should be used for API argument @a messageBox 463 */ 464 #define canMESSAGE_BOX54 54U 465 466 /** @def canMESSAGE_BOX55 467 * @brief Alias name for CAN message box 55 468 * 469 * @note This value should be used for API argument @a messageBox 470 */ 471 #define canMESSAGE_BOX55 55U 472 473 /** @def canMESSAGE_BOX56 474 * @brief Alias name for CAN message box 56 475 * 476 * @note This value should be used for API argument @a messageBox 477 */ 478 #define canMESSAGE_BOX56 56U 479 480 /** @def canMESSAGE_BOX57 481 * @brief Alias name for CAN message box 57 482 * 483 * @note This value should be used for API argument @a messageBox 484 */ 485 #define canMESSAGE_BOX57 57U 486 487 /** @def canMESSAGE_BOX58 488 * @brief Alias name for CAN message box 58 489 * 490 * @note This value should be used for API argument @a messageBox 491 */ 492 #define canMESSAGE_BOX58 58U 493 494 /** @def canMESSAGE_BOX59 495 * @brief Alias name for CAN message box 59 496 * 497 * @note This value should be used for API argument @a messageBox 498 */ 499 #define canMESSAGE_BOX59 59U 500 501 /** @def canMESSAGE_BOX60 502 * @brief Alias name for CAN message box 60 503 * 504 * @note This value should be used for API argument @a messageBox 505 */ 506 #define canMESSAGE_BOX60 60U 507 508 /** @def canMESSAGE_BOX61 509 * @brief Alias name for CAN message box 61 510 * 511 * @note This value should be used for API argument @a messageBox 512 */ 513 #define canMESSAGE_BOX61 61U 514 515 /** @def canMESSAGE_BOX62 516 * @brief Alias name for CAN message box 62 517 * 518 * @note This value should be used for API argument @a messageBox 519 */ 520 #define canMESSAGE_BOX62 62U 521 522 /** @def canMESSAGE_BOX63 523 * @brief Alias name for CAN message box 63 524 * 525 * @note This value should be used for API argument @a messageBox 526 */ 527 #define canMESSAGE_BOX63 63U 528 529 /** @def canMESSAGE_BOX64 530 * @brief Alias name for CAN message box 64 531 * 532 * @note This value should be used for API argument @a messageBox 533 */ 534 #define canMESSAGE_BOX64 64U 535 536 537 /* USER CODE BEGIN (1) */ 538 /* USER CODE END */ 539 540 /** 541 * @defgroup CAN CAN 542 * @brief Controller Area Network Module. 543 * 544 * The Controller Area Network is a high-integrity, serial, multi-master communication protocol for distributed 545 * real-time applications. This CAN module is implemented according to ISO 11898-1 and is suitable for 546 * industrial, automotive and general embedded communications 547 * 548 * Related Files 549 * - reg_can.h 550 * - can.h 551 * - can.c 552 * @addtogroup CAN 553 * @{ 554 */ 555 556 /* CAN Interface Functions */ 557 558 void canInit(void); 559 uint32 canTransmit(canBASE_t *node, uint32 messageBox, const uint8 * data); 560 uint32 canGetData(canBASE_t *node, uint32 messageBox, uint8 * const data); 561 uint32 canIsTxMessagePending(canBASE_t *node, uint32 messageBox); 562 uint32 canIsRxMessageArrived(canBASE_t *node, uint32 messageBox); 563 uint32 canIsMessageBoxValid(canBASE_t *node, uint32 messageBox); 564 uint32 canGetLastError(canBASE_t *node); 565 uint32 canGetErrorLevel(canBASE_t *node); 566 void canEnableErrorNotification(canBASE_t *node); 567 void canDisableErrorNotification(canBASE_t *node); 568 void canIoSetDirection(canBASE_t *node,uint32 TxDir,uint32 RxDir); 569 void canIoSetPort(canBASE_t *node, uint32 TxValue, uint32 RxValue); 570 uint32 canIoTxGetBit(canBASE_t *node); 571 uint32 canIoRxGetBit(canBASE_t *node); 572 573 /** @fn void canErrorNotification(canBASE_t *node, uint32 notification) 574 * @brief Error notification 575 * @param[in] node Pointer to CAN node: 576 * - canREG1: CAN1 node pointer 577 * - canREG2: CAN2 node pointer 578 * - canREG3: CAN3 node pointer 579 * @param[in] notification Error notification code: 580 * - canLEVEL_WARNING (0x40): When RX- or TX error counter are between 96 and 127 581 * - canLEVEL_BUS_OFF (0x80): When RX- or TX error counter are above 255 582 * 583 * @note This function has to be provide by the user. 584 */ 585 void canErrorNotification(canBASE_t *node, uint32 notification); 586 587 /** @fn void canMessageNotification(canBASE_t *node, uint32 messageBox) 588 * @brief Message notification 589 * @param[in] node Pointer to CAN node: 590 * - canREG1: CAN1 node pointer 591 * - canREG2: CAN2 node pointer 592 * - canREG3: CAN3 node pointer 593 * @param[in] messageBox Message box number of CAN node: 594 * - canMESSAGE_BOX1: CAN message box 1 595 * - canMESSAGE_BOXn: CAN message box n [n: 1-64] 596 * - canMESSAGE_BOX64: CAN message box 64 597 * 598 * @note This function has to be provide by the user. 599 */ 600 void canMessageNotification(canBASE_t *node, uint32 messageBox); 601 602 /**@}*/ 603 /* USER CODE BEGIN (2) */ 604 /* USER CODE END */ 605 606 607 #endif 608