MCUSW
Loading...
Searching...
No Matches
Can.h
Go to the documentation of this file.
1/*
2*
3* Copyright (c) 2024 Texas Instruments Incorporated
4*
5* All rights reserved not granted herein.
6*
7* Limited License.
8*
9* Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
10* license under copyrights and patents it now or hereafter owns or controls to make,
11* have made, use, import, offer to sell and sell ("Utilize") this software subject to the
12* terms herein. With respect to the foregoing patent license, such license is granted
13* solely to the extent that any such patent is necessary to Utilize the software alone.
14* The patent license shall not apply to any combinations which include this software,
15* other than combinations with devices manufactured by or for TI ("TI Devices").
16* No hardware patent is licensed hereunder.
17*
18* Redistributions must preserve existing copyright notices and reproduce this license
19* (including the above copyright notice and the disclaimer and (if applicable) source
20* code license limitations below) in the documentation and/or other materials provided
21* with the distribution
22*
23* Redistribution and use in binary form, without modification, are permitted provided
24* that the following conditions are met:
25*
26* * No reverse engineering, decompilation, or disassembly of this software is
27* permitted with respect to any software provided in binary form.
28*
29* * any redistribution and use are licensed by TI for use only with TI Devices.
30*
31* * Nothing shall obligate TI to provide you with source code for the software
32* licensed and provided to you in object code.
33*
34* If software source code is provided to you, modification and redistribution of the
35* source code are permitted provided that the following conditions are met:
36*
37* * any redistribution and use of the source code, including any resulting derivative
38* works, are licensed by TI for use only with TI Devices.
39*
40* * any redistribution and use of any object code compiled from the source code
41* and any resulting derivative works, are licensed by TI for use only with TI Devices.
42*
43* Neither the name of Texas Instruments Incorporated nor the names of its suppliers
44*
45* may be used to endorse or promote products derived from this software without
46* specific prior written permission.
47*
48* DISCLAIMER.
49*
50* THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
51* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
52* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53* IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
54* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
55* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
57* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
58* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
59* OF THE POSSIBILITY OF SUCH DAMAGE.
60*
61*/
62
87/*
88 * Below are the global design requirements which are met by this CAN
89 * driver which can't be mapped to a particular source ID
90 */
91
92/*
93 * Design: MCAL-6059,MCAL-5955,MCAL-6022,MCAL-5977,MCAL-6046,MCAL-6127,MCAL-6081,MCAL-5921,MCAL-5987,MCAL-6005,MCAL-5970
94 */
95
96#ifndef CAN_H_
97#define CAN_H_
98
99/* ========================================================================== */
100/* Include Files */
101/* ========================================================================== */
102/*
103 * Design: MCAL-5993,MCAL-6004,MCAL-6075,MCAL-5904,MCAL-5980,MCAL-6098
104 */
105#include "Std_Types.h"
106#include "ComStack_Types.h"
107#include "Can_GeneralTypes.h"
108#include "Can_Cfg.h"
109
110/*
111 * Design: MCAL-6106,MCAL-6144
112 */
113#include "Os.h"
114
115#ifdef __cplusplus
116extern "C"
117{
118#endif
119
120/* ========================================================================== */
121/* Macros & Typedefs */
122/* ========================================================================== */
123
132#define CAN_SW_MAJOR_VERSION (10U)
135#define CAN_SW_MINOR_VERSION (2U)
137/* @} */
138#define CAN_SW_PATCH_VERSION (4U)
139
147#define CAN_AR_RELEASE_MAJOR_VERSION (4U)
149#define CAN_AR_RELEASE_MINOR_VERSION (3U)
151/* @} */
152#define CAN_AR_RELEASE_REVISION_VERSION (1U)
153
154/* Global Macros */
160#define CAN_VENDOR_ID (44U)
162#define CAN_MODULE_ID (80U)
164#define CAN_INSTANCE_ID (0U)
165/* @} */
166
172#define CAN_UNINIT ((uint8)0U)
174#define CAN_READY ((uint8)1U)
175/* @} */
176
185#define CAN_INIT_ID (0x00U)
187#define CAN_MAINFCT_WRITE_ID (0x01U)
189#define CAN_SETCTR_ID (0x03U)
191#define CAN_DIINT_ID (0x04U)
193#define CAN_ENINT_ID (0x05U)
195#define CAN_WRITE_ID (0x06U)
197#define CAN_VERSION_ID (0x07U)
199#define CAN_MAINFCT_READ_ID (0x08U)
201#define CAN_MAINFCT_BO_ID (0x09U)
203#define CAN_MAINFCT_WU_ID (0x0AU)
205#define CAN_CKWAKEUP_ID (0x0BU)
207#define CAN_MAINFCT_MODE_ID (0x0CU)
209#define CAN_SETBAUDRATE_ID (0x0FU)
211#define CAN_DEINIT_ID (0x10U)
213#define CAN_GETCTRERRST_ID (0x11U)
215#define CAN_GETCTRMODE_ID (0x12U)
217#define CAN_LOOPBACK_ID (0x20U)
219#define CAN_RXPROCESS_ID (0x21U)
220
221/* @} */
222
229#ifndef CAN_E_PARAM_POINTER
230#define CAN_E_PARAM_POINTER (0x01U)
232#endif
233#ifndef CAN_E_PARAM_HANDLE
234#define CAN_E_PARAM_HANDLE (0x02U)
236#endif
237#ifndef CAN_E_PARAM_DLC
238#define CAN_E_PARAM_DLC (0x03U)
240#endif
241#ifndef CAN_E_PARAM_CONTROLLER
242#define CAN_E_PARAM_CONTROLLER (0x04U)
244#endif
245#ifndef CAN_E_UNINIT
246#define CAN_E_UNINIT (0x05U)
248#endif
249#ifndef CAN_E_TRANSITION
250#define CAN_E_TRANSITION (0x06U)
252#endif
253#ifndef CAN_E_DATALOST
254#define CAN_E_DATALOST (0x07U)
256#endif
257#ifndef CAN_E_PARAM_BAUDRATE
258#define CAN_E_PARAM_BAUDRATE (0x08U)
260#endif
261#ifndef CAN_E_ICOM_CONFIG_INVALID
262#define CAN_E_ICOM_CONFIG_INVALID (0x09U)
264#endif
265#ifndef CAN_E_INIT_FAILED
266#define CAN_E_INIT_FAILED (0x0AU)
268#endif
269/* @} */
270
279#define CAN_CFG_ID_0 (0x01U)
282#define CAN_CFG_ID_1 (0x02U)
284#define CAN_CFG_ID_2 (0x04U)
286#define CAN_CFG_ID_3 (0x08U)
289#define CAN_CFG_ID_4 (0x10U)
292#define CAN_CFG_ID_5 (0x20U)
294#define CAN_CFG_ID_6 (0x40U)
296#define CAN_CFG_ID_7 (0x80U)
297
298#define CAN_CFG_ID_8 (0x81U)
299
300#define CAN_CFG_ID_9 (0x82U)
301
302/* @} */
303
309#define MIXED_MODE_MB_ID (2U)
310/* @} */
311
312#if (STD_ON == CAN_SAFETY_DIAGNOSTIC)
320#define MCAN_ERR_TYPE_PEA_ERROR (1U)
322#define MCAN_ERR_TYPE_TOO_ERROR (2U)
323/* @} */
324
330#define MCAN_LSB_BIT_SET (1U)
331/* @} */
332#endif /* (STD_ON == CAN_SAFETY_DIAGNOSTIC) */
333
334/* ========================================================================== */
335/* Structures and Enums */
336/* ========================================================================== */
352
356typedef enum
357{
358 CAN_FULL = 0x0U,
360 CAN_BASIC = 0x1U
363
376
377#if (STD_ON == CAN_SAFETY_DIAGNOSTIC)
402#endif /* (STD_ON == CAN_SAFETY_DIAGNOSTIC) */
403
408
413
417typedef struct Can_MaskStruct
418{
419 uint32 MaskValue;
422
426typedef struct Can_HwFilterStruct
427{
428 Can_IdType IDValue;
430 uint32 Mask;
433
437typedef struct Can_FdBaudConfigStruct
438{
439 uint16 Baud;
441 uint8 PropSeg;
443 uint8 Pseg1;
445 uint8 Pseg2;
447 uint8 Sjw;
451 uint16 BrpValue;
455 boolean BrsSwitch;
458
462typedef struct Can_BaudConfigStruct
463{
464 uint16 Baud;
466 uint8 PropSeg;
468 uint8 Pseg1;
470 uint8 Pseg2;
472 uint8 Sjw;
476 uint16 BrpValue;
481
492
515
546
550typedef struct Can_MailboxStruct_PC
551{
555
559typedef struct
560{
561 uint32 Reserved;
564
565/*
566 * Design: MCAL-5980
567 */
586
587#if (STD_ON == CAN_REGISTER_READBACK_API)
636#endif /* (STD_ON == CAN_REGISTER_READBACK_API) */
637
638/* @} */
639
640/* ========================================================================== */
641/* Function Declarations */
642/* ========================================================================== */
643
644#if (CAN_VERSION_INFO_API == STD_ON)
665FUNC(void,
666 CAN_CODE) Can_GetVersionInfo(P2VAR(Std_VersionInfoType, AUTOMATIC,
667 CAN_APPL_DATA) VersionInfo);
668#endif
669
688FUNC(void, CAN_CODE) Can_Init(P2CONST(Can_ConfigType, AUTOMATIC,
689 CAN_PBCFG) CfgPtr);
690
718FUNC(Std_ReturnType, CAN_CODE) Can_SetControllerMode(
719 uint8 Controller, Can_ControllerStateType Transition);
720
751FUNC(Std_ReturnType, CAN_CODE) Can_Write(Can_HwHandleType Hth,
752 const Can_PduType *PduInfo);
753
774FUNC(void, CAN_CODE) Can_DisableControllerInterrupts(uint8 Controller);
775
795FUNC(void, CAN_CODE) Can_EnableControllerInterrupts(uint8 Controller);
796
797/* polling functions (always available for non polled systems also)*/
798
813FUNC(void, CAN_CODE) Can_MainFunction_Write(void);
814
829FUNC(void, CAN_CODE) Can_MainFunction_BusOff(void);
830
845FUNC(void, CAN_CODE) Can_MainFunction_Read(void);
846
861FUNC(void, CAN_CODE) Can_MainFunction_Wakeup(void);
862
876FUNC(void, CAN_CODE) Can_MainFunction_Mode(void);
877
878#if (STD_ON == CAN_SET_BAUDRATE_API)
879/* Baud rate functions */
905FUNC(Std_ReturnType, CAN_CODE) Can_SetBaudrate(uint8 Controller,
906 uint16 BaudRateConfigID);
907#endif
908
909#if (CAN_LOOPBACK_ENABLE == STD_ON)
936FUNC(Std_ReturnType, CAN_CODE) Can_TestLoopBackModeEnable(uint8 Controller,
937 uint8 Mode);
938
965FUNC(Std_ReturnType, CAN_CODE) Can_TestLoopBackModeDisable(uint8 Controller,
966 uint8 Mode);
967#endif
968
969#if (STD_ON == CAN_REGISTER_READBACK_API)
993Std_ReturnType Can_RegisterReadback(VAR(uint8, AUTOMATIC)Controller,
994 P2VAR(Can_RegisterReadbackType, AUTOMATIC,
995 CAN_APPL_DATA) RegRbPtr);
996#endif
997
998#if (STD_ON == CAN_SAFETY_DIAGNOSTIC)
1024Std_ReturnType Can_EnableIntr(VAR(uint8, AUTOMATIC)Controller,
1025 VAR(uint8, AUTOMATIC)CanErrVar);
1026
1052Std_ReturnType Can_DisableIntr(VAR(uint8, AUTOMATIC)Controller,
1053 VAR(uint8, AUTOMATIC)CanErrVar);
1054
1085Can_IrqStatusType Can_GetIntrStatus(VAR(uint8, AUTOMATIC)Controller);
1086
1110Std_ReturnType Can_ClearIntrStatus(VAR(uint8, AUTOMATIC)Controller);
1111#endif /* (STD_ON == CAN_SAFETY_DIAGNOSTIC) */
1112
1113/* ========================================================================== */
1114/* Function Prototypes */
1115/* ========================================================================== */
1137FUNC(void, CAN_CODE) Can_IntISR_Fun(Can_ControllerInstance CanInstanceID);
1138
1155FUNC(void, CAN_CODE) Can_DeInit(void);
1156
1183FUNC(Std_ReturnType, CAN_CODE) Can_GetControllerMode(uint8 Controller,
1184 Can_ControllerStateType* ControllerModePtr);
1185
1210FUNC(Std_ReturnType, CAN_CODE) Can_GetControllerErrorState
1211 (uint8 ControllerId, Can_ErrorStateType* ErrorStatePtr);
1212
1213#ifdef __cplusplus
1214}
1215#endif
1216
1217#endif /* CAN_H_ end file*/
1218/* End of File: Can.h */
1219
1220/* @} */
This file contains generated pre compile configuration file for CAN MCAL driver.
void Can_IntISR_Fun(Can_ControllerInstance CanInstanceID)
This function is the ISR for CAN controller 0/INT 0.
Std_ReturnType Can_DisableIntr(VAR(uint8,) Controller, VAR(uint8,) CanErrVar)
This service will Disable the Interrupts.
void Can_MainFunction_Write(void)
This function performs the polling of TX confirmation when CAN_TX_PROCESSING is set to POLLING.
Std_ReturnType Can_Write(Can_HwHandleType Hth, const Can_PduType *PduInfo)
This function is called by CanIf to pass a CAN message to CanDrv for transmission.
void Can_MainFunction_Mode(void)
This function performs the polling of CAN controller mode transitions.
uint8 CanControllerState_Type
Can Controller State enum type.
Definition Can.h:407
void Can_MainFunction_BusOff(void)
This function performs the polling of bus-off events that are configured statically as 'to be polled'...
Std_ReturnType Can_TestLoopBackModeEnable(uint8 Controller, uint8 Mode)
This service will enable CAN loopback mode.
void Can_MainFunction_Read(void)
This function performs the polling of RX indications when CAN_RX_PROCESSING is set to POLLING.
Std_ReturnType Can_SetControllerMode(uint8 Controller, Can_ControllerStateType Transition)
This function performs software triggered state transitions of the CAN controller State machine.
Can_MailBoxDirectionType
Can Mailbox direction enum.
Definition Can.h:346
void Can_GetVersionInfo(Std_VersionInfoType *VersionInfo)
Function returns the version information of this module.
Can_HandleType
Can Handle Type enum.
Definition Can.h:357
Can_TxRxProcessingType
Can Tx/Rx processing enum.
Definition Can.h:368
void Can_DeInit(void)
This function de-initializes the module.
uint32 Can_InterruptMask_Type
Can Interrupt Mask type.
Definition Can.h:412
Std_ReturnType Can_TestLoopBackModeDisable(uint8 Controller, uint8 Mode)
This service will disable CAN loopback mode.
void Can_DisableControllerInterrupts(uint8 Controller)
This function disables all interrupts for this CAN controller.
void Can_MainFunction_Wakeup(void)
This function performs the polling of wake-up events that are configured statically as 'to be polled'...
Can_IrqStatusType
CAN IRQ status enum.
Definition Can.h:382
Std_ReturnType Can_RegisterReadback(VAR(uint8,) Controller, Can_RegisterReadbackType *RegRbPtr)
This service will readback CAN registers.
Std_ReturnType Can_SetBaudrate(uint8 Controller, uint16 BaudRateConfigID)
This service shall set the baud rate configuration of the CAN controller. Depending on necessary baud...
Std_ReturnType Can_ClearIntrStatus(VAR(uint8,) Controller)
This service will clear the interrupt status.
Std_ReturnType Can_EnableIntr(VAR(uint8,) Controller, VAR(uint8,) CanErrVar)
This service will Enable the interrupts.
void Can_Init(const Can_ConfigType *CfgPtr)
This function initializes the module.
Can_IrqStatusType Can_GetIntrStatus(VAR(uint8,) Controller)
This service will provide the status of the interrupt.
void Can_EnableControllerInterrupts(uint8 Controller)
This function enables all allowed interrupts.
Std_ReturnType Can_GetControllerErrorState(uint8 ControllerId, Can_ErrorStateType *ErrorStatePtr)
This service obtains the error state of the CAN controller.
Std_ReturnType Can_GetControllerMode(uint8 Controller, Can_ControllerStateType *ControllerModePtr)
This service reports about the current status of the requested CAN controller.
Can_ControllerType ** CanControllerList
Definition Can.h:573
uint32 CanReadBackRegCTRL
Definition Can.h:605
uint8 Pseg2
Definition Can.h:470
uint32 CanReadBackRegTXESC
Definition Can.h:627
Can_ControllerInstance CanControllerInst
Definition Can.h:510
uint32 CanReadBackRegCREL
Definition Can.h:601
Can_ControllerInstance
Can Controller Instances enum.
Definition Can_Cfg.h:323
uint8 Pseg1
Definition Can.h:443
boolean CanHardwareObjectUsesPolling
Definition Can.h:543
boolean BusOffProcessingInterrupt
Definition Can.h:508
uint32 CanReadBackRegRWD
Definition Can.h:607
uint8 CanHandleType
Definition Can.h:521
uint32 CanReadBackRegPID
Definition Can.h:597
boolean BrsSwitch
Definition Can.h:455
Can_HwHandleType HwHandle
Definition Can.h:525
Can_MailboxType ** MailBoxList
Definition Can.h:577
uint32 CanReadBackRegTXBC
Definition Can.h:625
Can_IdType IDValue
Definition Can.h:428
uint32 CanReadBackRegCCCR
Definition Can.h:609
Can_HwFilterType ** HwFilterList
Definition Can.h:533
uint32 CanReadBackRegENDN
Definition Can.h:603
uint32 MaxMbCnt
Definition Can.h:579
uint16 Baud
Definition Can.h:464
uint32 CanReadBackRegRXF1C
Definition Can.h:623
uint8 CanMaxControllerCount
Definition Can.h:575
Can_TxRxProcessingType TxProcessingType
Definition Can.h:506
Can_FdBaudConfigType BaudFdRateConfig
Definition Can.h:478
uint32 CanReadBackRegGFC
Definition Can.h:613
boolean CntrActive
Definition Can.h:500
const Can_ControllerType_PC * Controller
Definition Can.h:531
uint8 ControllerId
Definition Can.h:498
uint16 BrpValue
Definition Can.h:476
Can_MailBoxDirectionType MBDir
Definition Can.h:529
uint32 CanReadBackRegSIDFC
Definition Can.h:615
uint32 CntrAddr
Definition Can.h:502
uint8 PropSeg
Definition Can.h:441
uint32 CanReadBackRegRXF0C
Definition Can.h:619
uint16 TrcvCompDelay
Definition Can.h:453
uint32 Reserved
Definition Can.h:561
#define CAN_MAX_CONTROLLER
Definition Can_Cfg.h:183
boolean CanFDModeEnabled
Definition Can.h:512
Can_DmaPrms * DmaPrms
Definition Can.h:583
uint16 TimingValues
Definition Can.h:474
uint8 Pseg1
Definition Can.h:468
uint32 Mask
Definition Can.h:430
uint32 HwFilterCnt
Definition Can.h:535
uint16 BrpValue
Definition Can.h:451
uint32 CanReadBackRegTXEFC
Definition Can.h:629
uint32 MBIdType
Definition Can.h:523
Can_BaudConfigType * DefaultBaud
Definition Can.h:487
uint16 Baud
Definition Can.h:439
uint8 CanFdPaddingValue
Definition Can.h:537
Can_BaudConfigType ** BaudRateConfigList
Definition Can.h:489
uint32 CanHwObjectCount
Definition Can.h:527
uint8 Pseg2
Definition Can.h:445
uint8 Sjw
Definition Can.h:472
uint32 CanReadBackRegXIDFC
Definition Can.h:617
Can_TxRxProcessingType RxProcessingType
Definition Can.h:504
uint32 CanReadBackRegSTAT
Definition Can.h:599
uint32 MaskValue
Definition Can.h:419
uint16 CanObjectId
Definition Can.h:552
uint8 PropSeg
Definition Can.h:466
uint32 CanReadBackRegXIDAM
Definition Can.h:633
uint32 CanReadBackRegRXESC
Definition Can.h:631
uint32 CanReadBackRegRXBC
Definition Can.h:621
uint16 TimingValues
Definition Can.h:449
uint8 Sjw
Definition Can.h:447
uint32 CanReadBackRegTDCR
Definition Can.h:611
@ CAN_MAILBOX_DIRECTION_RX
Definition Can.h:347
@ CAN_MAILBOX_DIRECTION_TX
Definition Can.h:349
@ CAN_FULL
Definition Can.h:358
@ CAN_BASIC
Definition Can.h:360
@ CAN_TX_RX_PROCESSING_POLLING
Definition Can.h:373
@ CAN_TX_RX_PROCESSING_INTERRUPT
Definition Can.h:369
@ CAN_TX_RX_PROCESSING_MIXED
Definition Can.h:371
@ CAN_IRQ_INTR_ACK_EVENT
Definition Can.h:389
@ CAN_IRQ_STATUS_READ_FAIL
Definition Can.h:399
@ CAN_IRQ_INTR_TOO_EVENT
Definition Can.h:397
@ CAN_IRQ_INTR_BIT0_EVENT
Definition Can.h:393
@ CAN_IRQ_INTR_BIT1_EVENT
Definition Can.h:391
@ CAN_IRQ_INTR_CRC_EVENT
Definition Can.h:395
@ CAN_IRQ_INTR_STUFF_EVENT
Definition Can.h:385
@ CAN_IRQ_NO_INTR_EVENT
Definition Can.h:383
@ CAN_IRQ_INTR_FORM_EVENT
Definition Can.h:387
VAR(uint8, ETH_VAR_NO_INIT_128) Eth_Ctrl_0_Egress_BufferMem_0[24576U]
Structure defining the CAN baud rate configuration.
Definition Can.h:463
Can MCAL root configuration structure.
Definition Can.h:572
Can Controller Pre Compile Configuration definition.
Definition Can.h:497
Can Controller Configuration definition.
Definition Can.h:486
Dummy structure will be used if DMA support is required.
Definition Can.h:560
Structure defining the CAN FD data phase baud rate configuration.
Definition Can.h:438
Structure defining the HW filter to be used.
Definition Can.h:427
Can mailox Pre compile configuration definition.
Definition Can.h:551
Can mailox configuration definition.
Definition Can.h:520
Structure defining the filter mask to be used.
Definition Can.h:418
Register Readback Structure.
Definition Can.h:596