1 /* 2 * Copyright 2021-2024 NXP 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef CANEXCEL_IP_H_ 8 #define CANEXCEL_IP_H_ 9 10 /** 11 * @file CanEXCEL_Ip.h 12 * 13 * @addtogroup CanEXCEL 14 * @{ 15 */ 16 17 #ifdef __cplusplus 18 extern "C"{ 19 #endif 20 /*================================================================================================== 21 * INCLUDE FILES 22 * 1) system and project includes 23 * 2) needed interfaces from external units 24 * 3) internal and external interfaces from this unit 25 ==================================================================================================*/ 26 #include "CanEXCEL_Ip_DevReg.h" 27 #include "CanEXCEL_Ip_Types.h" 28 29 /*================================================================================================== 30 * SOURCE FILE VERSION INFORMATION 31 ==================================================================================================*/ 32 #define CANEXCEL_IP_VENDOR_ID_H 43 33 #define CANEXCEL_IP_AR_RELEASE_MAJOR_VERSION_H 4 34 #define CANEXCEL_IP_AR_RELEASE_MINOR_VERSION_H 7 35 #define CANEXCEL_IP_AR_RELEASE_REVISION_VERSION_H 0 36 #define CANEXCEL_IP_SW_MAJOR_VERSION_H 2 37 #define CANEXCEL_IP_SW_MINOR_VERSION_H 0 38 #define CANEXCEL_IP_SW_PATCH_VERSION_H 0 39 40 /*================================================================================================== 41 * FILE VERSION CHECKS 42 ==================================================================================================*/ 43 /* Check if current file and CanEXCEL_Ip_Types.h are of the same vendor */ 44 #if (CANEXCEL_IP_VENDOR_ID_H != CANEXCEL_IP_TYPES_VENDOR_ID_H) 45 #error "CanEXCEL_Ip.h and CanEXCEL_Ip_Types.h have different vendor ids" 46 #endif 47 /* Check if current file and CanEXCEL_Ip_Types.h are of the same Autosar version */ 48 #if ((CANEXCEL_IP_AR_RELEASE_MAJOR_VERSION_H != CANEXCEL_IP_TYPES_AR_RELEASE_MAJOR_VERSION_H) || \ 49 (CANEXCEL_IP_AR_RELEASE_MINOR_VERSION_H != CANEXCEL_IP_TYPES_AR_RELEASE_MINOR_VERSION_H) || \ 50 (CANEXCEL_IP_AR_RELEASE_REVISION_VERSION_H != CANEXCEL_IP_TYPES_AR_RELEASE_REVISION_VERSION_H) \ 51 ) 52 #error "AutoSar Version Numbers of CanEXCEL_Ip.h and CanEXCEL_Ip_Types.h are different" 53 #endif 54 /* Check if current file and CanEXCEL_Ip_Types.h are of the same Software version */ 55 #if ((CANEXCEL_IP_SW_MAJOR_VERSION_H != CANEXCEL_IP_TYPES_SW_MAJOR_VERSION_H) || \ 56 (CANEXCEL_IP_SW_MINOR_VERSION_H != CANEXCEL_IP_TYPES_SW_MINOR_VERSION_H) || \ 57 (CANEXCEL_IP_SW_PATCH_VERSION_H != CANEXCEL_IP_TYPES_SW_PATCH_VERSION_H) \ 58 ) 59 #error "Software Version Numbers of CanEXCEL_Ip.h and CanEXCEL_Ip_Types.h are different" 60 #endif 61 /*================================================================================================== 62 * CONSTANTS 63 ==================================================================================================*/ 64 65 /*================================================================================================== 66 * DEFINES AND MACROS 67 ==================================================================================================*/ 68 #define CANEXCEL_IP_MB_RXFIFO 255U 69 /*================================================================================================== 70 * GLOBAL VARIABLE DECLARATIONS 71 ==================================================================================================*/ 72 #define CAN_43_CANEXCEL_START_SEC_CONFIG_DATA_UNSPECIFIED 73 #include "Can_43_CANEXCEL_MemMap.h" 74 /* Calling the external Configuration symbols defined by CanExcel_Ip_Cfg.h */ 75 CANEXCEL_IP_CONFIG_EXT 76 #define CAN_43_CANEXCEL_STOP_SEC_CONFIG_DATA_UNSPECIFIED 77 #include "Can_43_CANEXCEL_MemMap.h" 78 79 #define CAN_43_CANEXCEL_START_SEC_VAR_CLEARED_UNSPECIFIED 80 #include "Can_43_CANEXCEL_MemMap.h" 81 CANEXCEL_IP_STATE_EXT 82 #define CAN_43_CANEXCEL_STOP_SEC_VAR_CLEARED_UNSPECIFIED 83 #include "Can_43_CANEXCEL_MemMap.h" 84 /*================================================================================================== 85 * FUNCTION PROTOTYPES 86 ==================================================================================================*/ 87 #define CAN_43_CANEXCEL_START_SEC_CODE 88 #include "Can_43_CANEXCEL_MemMap.h" 89 /** 90 * @brief Initializes the CanEXCEL peripheral. 91 * @details This function will config CanEXCEL module and will leave the module in freeze mode. 92 * @param[in] instance A CanEXCEL instance number 93 * @param[in\out] pState Pointer to the CanEXCEL driver state structure. 94 * @param[in] Config The CanEXCEL platform configuration data 95 * @return CANEXCEL_STATUS_SUCCESS if successfull;<br> 96 * CANEXCEL_STATUS_ERROR if other error occurred;<br> 97 * CANEXCEL_STATUS_TIMEOUT if fail to configure in configured timeout value.<br> 98 */ 99 Canexcel_Ip_StatusType Canexcel_Ip_Init(uint8 instance, const Canexcel_Ip_ConfigType * Config, Canexcel_Ip_StateType * pState); 100 /** 101 * @brief Sets the CanEXCEL Rx individual mask for descriptor 102 * @details This function will set directly the mask value as is provided. 103 * @param[in] instance A CanEXCEL instance number 104 * @param[in] descNo Index of the message descriptor 105 * @param[in] frameType Message format type 106 * @param[in] mask Mask value 107 * @note This function should be called from StopMode or FreezeMode. 108 * @return none 109 */ 110 void Canexcel_Ip_SetRxIndividualMask(uint8 instance, uint8 descNo, Canexcel_Ip_FrameType frameType, uint32 mask); 111 /** 112 * @brief CanEXCEL config XL Message for Tx with Id, SDT, VCAN, length 113 * @details This function will config transmit parameters form Canexcel_DataInfoType and 114 * the message Id 115 * @param[in] instance A CanEXCEL instance number 116 * @param[in] mbIdx Index of the message descriptor 117 * @param[in] id ID of the message to transmit 118 * @param[in] info Data info 119 * @param[in\out] TxMsg The CanEXCEL transmit message buffer pointer. 120 * @return none 121 */ 122 void Canexcel_Ip_ConfigXlTx(uint8 instance, uint8 mbIdx, uint32 id,const Canexcel_Ip_DataInfoType * info, Canexcel_TxXlMsgType * TxMsg); 123 /** 124 * @brief CanEXCEL receive message descriptor field configuration 125 * @details This function will config receive parameters form Canexcel_DataInfoType and 126 * the message Id, and can overwritte another MB status. 127 * @param[in] instance A CanEXCEL instance number 128 * @param[in] descNo Index of the message descriptor 129 * @param[in] info Data info 130 * @param[in] msg_id ID of the message to transmit 131 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 132 * CANEXCEL_STATUS_TIMEOUT if fail to configure in configured timeout value.<br> 133 * CANEXCEL_STATUS_BUSY if the descriptor is full. 134 */ 135 Canexcel_Ip_StatusType Canexcel_Ip_ConfigRx(uint8 instance, uint8 descNo, uint32 msgId,const Canexcel_Ip_DataInfoType * info); 136 /** 137 * @brief Set the CanEXCEL message buffer storage pointer for the descriptor 138 * @details This function will config receive message address for the descriptor where the CanEXCEL to store the received data. 139 * @param[in] instance A CanEXCEL instance number 140 * @param[in] descNo Index of the message descriptor 141 * @param[in] rxPtrList Pointer to the message buffer 142 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 143 * CANEXCEL_STATUS_TIMEOUT if fail to configure in configured timeout value.<br> 144 * CANEXCEL_STATUS_ERROR if the descriptor is not empty or inactive. 145 */ 146 Canexcel_Ip_StatusType Canexcel_Ip_RxDescriptor(uint8 instance, uint8 descNo, uint32 rxPtrList); 147 148 /** 149 * @brief Set the CanEXCEL message buffer storage pointer for the descriptor 150 * @details This function will config transmit message address for the descriptor where the CanEXCEL data to be sent are stored. 151 * @param[in] instance A CanEXCEL instance number 152 * @param[in] descNo Index of the message descriptor 153 * @param[in] txPtrList Pointer to the message buffer in ram 154 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 155 * CANEXCEL_STATUS_TIMEOUT if fail to configure in configured timeout value.<br> 156 * CANEXCEL_STATUS_ERROR if the descriptor is not empty or inactive. 157 */ 158 Canexcel_Ip_StatusType Canexcel_Ip_TxDescriptor(uint8 instance, uint8 descNo, uint32 txPtrList); 159 /** 160 * @brief Receives a CAN Classic or FD frame using the specified message buffer. 161 * @details This function receives a CAN frame using a configured message descriptor. The function 162 * returns immediately. 163 * @param[in] instance A CanEXCEL instance number 164 * @param[in] descNo Index of the message descriptor 165 * @param[out] RxMsg The CanEXCEL receive message buffer pointer. 166 * @param[in] isPolling If the message will be received using pooling(true) or interrupt(false). 167 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 168 * CANEXCEL_STATUS_TIMEOUT if fail to configure in configured timeout value.<br> 169 * CANEXCEL_STATUS_ERROR if the descriptor is not empty or inactive. 170 */ 171 Canexcel_Ip_StatusType Canexcel_Ip_ReceiveFD(uint8 instance, uint8 descNo, const Canexcel_RxFdMsg * RxMsg, boolean isPolling); 172 /** 173 * @brief Receives a CAN XL frame using the specified message buffer. 174 * @details This function receives a CAN frame using a configured message descriptor. The function 175 * returns immediately. 176 * @param[in] instance A CanEXCEL instance number 177 * @param[in] descNo Index of the message descriptor 178 * @param[out] RxMsg The CanEXCEL receive message buffer pointer. 179 * @param[in] isPolling If the message will be received using pooling(true) or interrupt(false). 180 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 181 * CANEXCEL_STATUS_TIMEOUT if fail to configure in configured timeout value.<br> 182 * CANEXCEL_STATUS_ERROR if the descriptor is not empty or inactive. 183 */ 184 Canexcel_Ip_StatusType Canexcel_Ip_ReceiveXL(uint8 instance, uint8 descNo, const Canexcel_RxXlMsg * RxMsg, boolean isPolling); 185 /** 186 * @brief Sends a CAN Classic or FD frame using the specified message buffer. 187 * @details This function configure parameters form Canexcel_DataInfoType, ID and sends data as CAN frame using a specified message buffer. 188 * @note This function doesn't support to work with Transceiver mode PWM. 189 * @param[in] instance A CanEXCEL instance number 190 * @param[in] mbIdx Index of the message descriptor 191 * @param[in] info Data info 192 * @param[in] id ID of the message to transmit 193 * @param[in] dataPtr Data Bytes of the CAN message . 194 * @param[in] TxMsg Pointer of the FD Tx Message. 195 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 196 * CANEXCEL_STATUS_TIMEOUT if fail to configure in configured timeout value.<br> 197 * CANEXCEL_STATUS_ERROR if listen only mode or PWM transceiver mode is active. 198 */ 199 Canexcel_Ip_StatusType Canexcel_Ip_SendFDMsg(uint8 instance, uint8 mbIdx,const Canexcel_Ip_DataInfoType * info, uint32 id,const uint8 * dataPtr, Canexcel_TxFdMsgType * TxMsg); 200 /** 201 * @brief Sends a CAN XL frame using the specified message buffer. 202 * @details This function configure parameters form Canexcel_DataInfoType, ID and sends data as CAN frame using a specified message buffer. 203 * @param[in] instance A CanEXCEL instance number 204 * @param[in] mbIdx Index of the message descriptor 205 * @param[in] info Data info 206 * @param[in] id ID of the message to transmit 207 * @param[in] dataPtr Data Bytes of the CAN message . 208 * @param[in] TxMsg Pointer of the XL Tx Message. 209 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 210 * CANEXCEL_STATUS_TIMEOUT if fail to configure in configured timeout value.<br> 211 * CANEXCEL_STATUS_ERROR if listen only mode is active. 212 */ 213 Canexcel_Ip_StatusType Canexcel_Ip_SendXLMsg(uint8 instance, uint8 mbIdx,const Canexcel_Ip_DataInfoType * info, uint32 id,const uint8 * dataPtr, Canexcel_TxXlMsgType * TxMsg); 214 /** 215 * @brief Returns whether the previous CanEXCEL transfer has finished. 216 * 217 * When performing an async transfer, call this function to ascertain the state of the 218 * current transfer: in progress (or busy) or complete (success). 219 * 220 * @param[in] instance The CanEXCEL instance number. 221 * @param[in] descIdx The index of the message descriptor. 222 * @return CANEXCEL_STATUS_NO_TRANSFER_IN_PROGRESS if no transfer initiated; 223 * CANEXCEL_STATUS_BUSY if a resource is busy; 224 * CANEXCEL_STATUS_ERROR in case of a OverRun error transfer; 225 * CANEXCEL_STATUS_SUCCESS if a successful transfer finished. 226 */ 227 Canexcel_Ip_StatusType Canexcel_Ip_GetTransferStatus(uint8 instance, uint8 descIdx); 228 /** 229 * @brief Enter CanEXCEL Module in Freeze Mode. 230 * @details This function will suspend bus activity of CanEXCEL module and 231 * set it to Freeze Mode to allow module configuration. 232 * @param[in] instance A CanEXCEL instance number 233 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 234 * CANEXCEL_STATUS_TIMEOUT if fail to configure in the configured timeout value.<br> 235 * 236 */ 237 Canexcel_Ip_StatusType Canexcel_Ip_EnterFreezeMode(uint8 instance); 238 /** 239 * @brief Exit CanEXCEL Module from Freeze Mode. 240 * @details This function will allow CanEXCEL module to participate to the BUS activity and 241 * restore normal opertaion of the driver. 242 * @param[in] instance A CanEXCEL instance number 243 * @note This function should be called from FreezeMode. 244 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 245 * CANEXCEL_STATUS_TIMEOUT if fail to configure in the configured timeout value.<br> 246 * 247 */ 248 Canexcel_Ip_StatusType Canexcel_Ip_ExitFreezeMode(uint8 instance); 249 /** 250 * @brief Check a receive event. 251 * @details This will check if message is received and read the message buffer or RxFifo. 252 * @param[in] instance A CanEXCEL instance number 253 * @param[in] mb_idx Index of the message buffer 254 */ 255 void Canexcel_Ip_MainFunctionRead(uint8 instance, uint8 mb_idx); 256 /** 257 * @brief Check a Transmission event. 258 * @details This function will check a specific Message Descriptor have been sent of CanEXCEL module and 259 * if was sent will reset the status of Mb and clear the status flag. 260 * @param[in] instance A CanEXCEL instance number 261 * @param[in] mb_idx message buffer number 262 * 263 */ 264 void Canexcel_Ip_MainFunctionWrite(uint8 instance, uint8 mb_idx); 265 /** 266 * @brief CanEXCEL Rx FIFO field configuration 267 * @note This function requires the module to be in Stop or Freeze Mode. 268 * @param[in] instance A CanEXCEL instance number 269 * @param[in] filterConfig Pointer to the filter configuration structure. 270 * @return CANEXCEL_STATUS_ERROR if the RxFifo wasn't activated by CanExcel_Init, or the CanExcel instance is not in freeze mode; 271 * CANEXCEL_STATUS_SUCCESS if successful. 272 */ 273 Canexcel_Ip_StatusType Canexcel_Ip_ConfigRxFifo(uint8 instance,const Canexcel_Ip_RxFifoFilter * filterConfig); 274 /** 275 * @brief Set the CanEXCEL instance in STOP mode 276 * @details Set the CanEXCEL instance in STOP mode, this will prevent instance to participate to 277 * bus transactions and allow configuration of the module. 278 * @param[in] instance A CanEXCEL instance number 279 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 280 * CANEXCEL_STATUS_TIMEOUT if fail to configure in configured timeout value.<br> 281 */ 282 Canexcel_Ip_StatusType Canexcel_Ip_SetStopMode(uint8 instance); 283 /** 284 * @brief Get Stop Mode Status 285 * @details Return if the instance is in Stop Mode 286 * @param[in] instance A CanEXCEL instance number 287 * @return True instance is in STOP Mode 288 * False instance is not in STOP Mode 289 */ 290 boolean Canexcel_Ip_GetStopMode(uint8 instance); 291 /** 292 * @brief Get Start Mode Status 293 * @details Return if the instance is in Start Mode 294 * @param[in] instance A CanEXCEL instance number 295 * @return True instance is in START Mode 296 * False instance is not in START Mode 297 * 298 */ 299 boolean Canexcel_Ip_GetStartMode(uint8 instance); 300 /** 301 * @brief Enable all interrupts configured. 302 * @details Enable all interrupts configured. 303 * @param[in] u8Instance A CanEXCEL instance number 304 * @return CANEXCEL_STATUS_SUCCESS if successful operation;<br> 305 * CANEXCEL_STATUS_ERROR if the module is not in freeze Mode;<br> 306 */ 307 Canexcel_Ip_StatusType Canexcel_Ip_EnableInterrupts(uint8 u8Instance); 308 /** 309 * @brief Disable all interrupts. 310 * @details Disable all interrupts. 311 * @param[in] u8Instance A CanEXCEL instance number 312 * @return CANEXCEL_STATUS_SUCCESS if successful operation;<br> 313 * CANEXCEL_STATUS_ERROR if the module is not in freeze Mode;<br> 314 */ 315 Canexcel_Ip_StatusType Canexcel_Ip_DisableInterrupts(uint8 u8Instance); 316 #if (CANEXCEL_IP_HAS_TS_ENABLE == STD_ON) 317 /*! 318 * @brief This function configure the timestamp settings. 319 * 320 * This function will allow to set the timestamp timer source and config the 321 * timer selected capture point for timestamp. 322 * @note Need enable clock counter for the source selected before use Time Stamp. 323 * 324 * @param[in] instance A CanEXCEL instance number 325 * @param[in] time_stamp A timestamp configuration structure 326 * @return CANEXCEL_STATUS_SUCCESS if successful operation;<br> 327 * CANEXCEL_STATUS_ERROR if the module is not in freeze Mode;<br> 328 */ 329 Canexcel_Ip_StatusType Canexcel_Ip_ConfigTimeStamp(uint8 instance, const Canexcel_Ip_TimeStampConf_Type * time_stamp); 330 #endif 331 /** 332 * @brief Check if the descriptor is configured for reception of XL frame or not. 333 * 334 * @param[in] u8Instance A CanEXCEL instance number 335 * @param[in] descNo A CanEXCEL decriptor number 336 */ 337 boolean Canexcel_Ip_IsXLFrameType(uint8 instance, uint8 descNo); 338 /** 339 * @brief Enable\Disable an Error Interrupt 340 * @note This function need to be call after the CANXL Instance is in FreezeMode 341 * 342 * @param[in] u8Instance A CanEXCEL instance number 343 * @param[in] type Error type for wich to cofig the Interrupt 344 * @param[in] enable TRUE will Enable the interrupt\FALSE will disable the interrupt 345 * 346 * @return CANEXCEL_STATUS_SUCCESS Configured successfully.<br> 347 * CANEXCEL_STATUS_ERROR Either interface is not in Freeze mode or not a valid error type.<br> 348 */ 349 Canexcel_Ip_StatusType Canexcel_Ip_SetErrorInt(uint8 u8Instance, Canexcel_Ip_ErrorIntType type, boolean enable); 350 /** 351 * @brief Get the TxError Counter 352 * 353 * @param[in] instance A CanEXCEL instance number 354 * @param[out] pValue Pointer to a variable to return the TxError Counter Value 355 * @return CANEXCEL_STATUS_ERROR It can not update and get the TxError Status 356 * CANEXCEL_STATUS_TIMEOUT The device fail to react in configured time 357 * CANEXCEL_STATUS_SUCCESS Successfully get the TxError counter value 358 */ 359 Canexcel_Ip_StatusType Canexcel_Ip_GetControllerTxErrorCounter(uint8 instance, uint8 * pValue); 360 /** 361 * @brief Get the RxError Counter. 362 * 363 * @param[in] instance A CanEXCEL instance number 364 * @param[out] pValue Pointer to a variable to return the RxError Counter Value 365 * @return CANEXCEL_STATUS_ERROR It can not update and get the RxError Status 366 * CANEXCEL_STATUS_TIMEOUT The device fail to react in configured time 367 * CANEXCEL_STATUS_SUCCESS Successfully get the RxError counter value 368 */ 369 Canexcel_Ip_StatusType Canexcel_Ip_GetControllerRxErrorCounter(uint8 instance, uint8 * pValue); 370 /** 371 * @brief Get the CanEXCEL Controller Status. 372 * 373 * @param[in] instance A CanEXCEL instance number 374 * @param[out] pValue Pointer to a variable to return the Controller Status 375 * @return CANEXCEL_STATUS_ERROR It can not update and get the Status 376 * CANEXCEL_STATUS_TIMEOUT The device fail to react in configured time 377 * CANEXCEL_STATUS_SUCCESS Successfully update and get the Controller Status 378 */ 379 Canexcel_Ip_StatusType Canexcel_Ip_GetControllerStatus(uint8 instance, uint8 * pValue); 380 /** 381 * @brief Clear Error Status of CanEXCEL 382 * @details This function will clear the error status from SYSS register in SIC module. 383 * For exact mapping of errors please refere to RM(Reference Manual) 384 * on CanEXCEL SIC->SYSS register description. 385 * @param[in] instance: A CanEXCEL instance number 386 * @param[in] error: errors flags to be cleared 387 */ 388 void Canexcel_Ip_ClearErrorStatus(uint8 instance, uint32 error); 389 /** 390 * @brief Check a bus-off event. 391 * @details This function will update the CanEXCEL Status and check bus activity of CanEXCEL module and 392 * if a bus off event is detected will report it through callback CANEXCEL_EVENT_BUSOFF. 393 * @param[in] instance A CanEXCEL instance number 394 * @return CANEXCEL_STATUS_SUCCESS if successful busoff and sucessfully update the status<br> 395 * CANEXCEL_STATUS_ERROR if no busoff event detected;<br> 396 * CANEXCEL_STATUS_TIMEOUT if fail to get the status in configured time<br> 397 * 398 */ 399 Canexcel_Ip_StatusType Canexcel_Ip_MainFunctionBusOff(uint8 instance); 400 /*! 401 * @brief Recover manually from bus-off if possible. 402 * @note This function should be used when bus-off auto recovery disabled and controller is in START mode. 403 * The function Canexcel_Ip_GetErrorStatus can be used to check FLTCONF bits to check if bus-off state is exited or not. 404 * 405 * @param[in] instance A CanEXCEL instance number 406 * @return CANEXCEL_STATUS_SUCCESS if successful operation or the controller wasn't in bus-off.<br> 407 * CANEXCEL_STATUS_ERROR if bus-off auto recovery enabled.<br> 408 * CANEXCEL_STATUS_TIMEOUT if fail to recover in configured time<br> 409 */ 410 Canexcel_Ip_StatusType Canexcel_Ip_ManualBusOffRecovery(uint8 instance); 411 /** 412 * @brief Sets the bit rate for the data phase of FD frames. 413 * @details This function requests the CanExcel module to be Freeze Mode and FD mode enabled. 414 * @param[in] Instance CanExcel instance number. 415 * @param[in] TimeSeg Pointer to the bit rate settings. 416 * @param[in] BitRateSwitch Enable/disable bit rate switching. 417 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 418 * CANEXCEL_STATUS_ERROR if fail to set;<br> 419 */ 420 Canexcel_Ip_StatusType Canexcel_Ip_SetFDBaudRate(uint8 Instance, const Canexcel_Ip_TimeSegmentType * TimeSeg, boolean BitRateSwitch); 421 /** 422 * @brief Sets the bit rate for the data phase of XL frames. 423 * @details This function requests the CanExcel module to be Freeze Mode and XL mode enabled. 424 * @param[in] Instance CanExcel instance number. 425 * @param[in] TimeSeg Pointer to the bit rate settings. 426 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 427 * CANEXCEL_STATUS_ERROR if fail to set;<br> 428 */ 429 Canexcel_Ip_StatusType Canexcel_Ip_SetXLBaudRate(uint8 Instance, const Canexcel_Ip_TimeSegmentType * TimeSeg); 430 /** 431 * @brief Sets the bit rate for the nomimal phase of classical frame and in the arbitration phase of a FD or XL frame. 432 * @details This function requests the CanExcel module to be Freeze Mode. 433 * @param[in] Instance CanExcel instance number. 434 * @param[in] TimeSeg Pointer to the bit rate settings. 435 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 436 * CANEXCEL_STATUS_ERROR if fail to set;<br> 437 */ 438 Canexcel_Ip_StatusType Canexcel_Ip_SetBaudRate(uint8 Instance, const Canexcel_Ip_TimeSegmentType * TimeSeg); 439 /** 440 * @brief Gets the bit rate for the data phase of FD frames. 441 * @details Gets the bit rate for the data phase of FD frames. 442 * @param[in] Instance CanExcel instance number. 443 * @param[out] TimeSeg Pointer to the bit rate settings. 444 */ 445 void Canexcel_Ip_GetFDBaudRate(uint8 Instance, Canexcel_Ip_TimeSegmentType * TimeSeg); 446 /** 447 * @brief Gets the bit rate for the data phase of XL frames. 448 * @details Gets the bit rate for the data phase of XL frames. 449 * @param[in] Instance CanExcel instance number. 450 * @param[out] TimeSeg Pointer to the bit rate settings. 451 */ 452 void Canexcel_Ip_GetXLBaudRate(uint8 Instance, Canexcel_Ip_TimeSegmentType * TimeSeg); 453 /** 454 * @brief Gets the bit rate for the nomimal phase of classical frame and in the arbitration phase of a FD or XL frame. 455 * @details Gets the bit rate for the nomimal phase of classical frame and in the arbitration phase of a FD or XL frame. 456 * @param[in] Instance CanExcel instance number. 457 * @param[out] TimeSeg Pointer to the bit rate settings. 458 */ 459 void Canexcel_Ip_GetBaudRate(uint8 Instance, Canexcel_Ip_TimeSegmentType * TimeSeg); 460 /** 461 * @brief Enable\Disable listen Only Mode 462 * @details This function will Enable or Disable listen Only Mode. 463 * @note This function should be called from FreezeMode. 464 * @param[in] Instance Instance number 465 * @param[in] Enable Enable\Disable Listen Only mode 466 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 467 * CANEXCEL_STATUS_ERROR if fail to set;<br> 468 * 469 */ 470 Canexcel_Ip_StatusType Canexcel_Ip_SetListenOnlyMode(uint8 Instance, boolean Enable); 471 /** 472 * @brief Get the Status of Listen Only Mode 473 * @details This function will return True if Listen Only Mode 474 * is Enable or False if is Disable. 475 * @param[in] Instance instance number 476 * @return True if Listen Only Mode is Enabled 477 * False if Listen Only Mode is Disabled. 478 * 479 */ 480 boolean Canexcel_Ip_GetListenOnlyMode(uint8 Instance); 481 /** 482 * @brief Enables/Disables the FD Transceiver Delay Compensation feature and sets 483 * the FD Transceiver Delay Compensation Offset. 484 * @details This function request the CanExcel module to be in Freeze Mode. 485 * When the transceiver delay measurement is enabled, the secondary sample point position is determined by the sum of the transceiver delay measurement plus the CAN XL TDC offset. 486 * When the transceiver delay measurement is disabled, the secondary sample point position is determined CAN XL TDC offset only. 487 * @param[in] Instance A CanExcel instance number 488 * @param[in] TDCEnable Enable/Disable Transceiver Delay Compensation 489 * @param[in] TDCMEnable Enable/Disable Transceiver Delay Compensation Measurement 490 * @param[in] Offset Transceiver Delay Compensation Offset 491 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 492 * CANEXCEL_STATUS_ERROR if fail to set;<br> 493 */ 494 Canexcel_Ip_StatusType Canexcel_Ip_SetTDCOffsetFD(uint8 Instance, boolean TDCEnable, boolean TDCMEnable, uint8 Offset); 495 /** 496 * @brief Enables/Disables the XL Transceiver Delay Compensation feature and sets 497 * the XL Transceiver Delay Compensation Offset. 498 * @details This function request the CanExcel module to be in Freeze Mode. 499 * When the transceiver delay measurement is enabled, the secondary sample point position is determined by the sum of the transceiver delay measurement plus the CAN XL TDC offset. 500 * When the transceiver delay measurement is disabled, the secondary sample point position is determined CAN XL TDC offset only. 501 * @param[in] Instance A CanExcel instance number 502 * @param[in] TDCEnable Enable/Disable Transceiver Delay Compensation 503 * @param[in] TDCMEnable Enable/Disable Transceiver Delay Compensation Measurement 504 * @param[in] Offset Transceiver Delay Compensation Offset 505 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 506 * CANEXCEL_STATUS_ERROR if fail to set;<br> 507 */ 508 Canexcel_Ip_StatusType Canexcel_Ip_SetTDCOffsetXL(uint8 Instance, boolean TDCEnable, boolean TDCMEnable, uint8 Offset); 509 /** 510 * @brief Configures Pwm phases for Pwm symbol. 511 * @details This function request the CanExcel module to be in Freeze Mode. 512 * @note When PWM mode enabled: 513 * - protocol exception must be enabled also 514 * - PWMS must be in range [1:63] 515 * - PWML must be in range [1:63] 516 * - PWMO must be in range [0:63] 517 * 518 * @param[in] Instance A CanExcel instance number 519 * @param[in] Config Transceiver configuration data 520 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 521 * CANEXCEL_STATUS_ERROR if fail to set;<br> 522 */ 523 Canexcel_Ip_StatusType Canexcel_Ip_ConfigTransceiverMode(uint8 Instance, const Canexcel_Ip_TransceiverModeType * Config); 524 /** 525 * @brief Configures Acceptance Filters for MDs on FiltersBank0. 526 * @details This function request the CanExcel module to be in Freeze Mode. 527 * @note The filters are for every bank individualy set. 528 * 529 * @param[in] Instance A CanExcel instance number 530 * @param[in] Config Filter configurations for AFs, SDUs and VCANs 531 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 532 * CANEXCEL_STATUS_ERROR if fail to set;<br> 533 */ 534 Canexcel_Ip_StatusType Canexcel_Ip_ConfigAccFltBank0(uint8 Instance, const Canexcel_Ip_BankFilter * Config); 535 /** 536 * @brief Configures Acceptance Filters for MDs on FiltersBank1. 537 * @details This function request the CanExcel module to be in Freeze Mode. 538 * @note The filters are for every bank individualy set. 539 * 540 * @param[in] Instance A CanExcel instance number 541 * @param[in] Config Filter configurations for AFs, SDUs and VCANs 542 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 543 * CANEXCEL_STATUS_ERROR if fail to set;<br> 544 */ 545 Canexcel_Ip_StatusType Canexcel_Ip_ConfigAccFltBank1(uint8 Instance, const Canexcel_Ip_BankFilter * Config); 546 /** 547 * @brief Configures Rejection Filters for MDs on FiltersBank0. 548 * @details This function request the CanExcel module to be in Freeze Mode. 549 * @note The filters are for every bank individualy set. 550 * 551 * @param[in] Instance A CanExcel instance number 552 * @param[in] Config Filter configurations for AFs, SDUs and VCANs 553 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 554 * CANEXCEL_STATUS_ERROR if fail to set;<br> 555 */ 556 Canexcel_Ip_StatusType Canexcel_Ip_ConfigRejFltBank0(uint8 Instance, const Canexcel_Ip_BankFilter * Config); 557 /** 558 * @brief Configures Rejection Filters for MDs on FiltersBank1. 559 * @details This function request the CanExcel module to be in Freeze Mode. 560 * @note The filters are for every bank individualy set. 561 * 562 * @param[in] Instance A CanExcel instance number 563 * @param[in] Config Filter configurations for AFs, SDUs and VCANs 564 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 565 * CANEXCEL_STATUS_ERROR if fail to set;<br> 566 */ 567 Canexcel_Ip_StatusType Canexcel_Ip_ConfigRejFltBank1(uint8 Instance, const Canexcel_Ip_BankFilter * Config); 568 /** 569 * @brief Configures Acceptance Address filter for a desired filter number 570 * @details This function request the CanExcel module to be in Freeze Mode. 571 * @note If the filter position is higher than the 31 it measn it is alocated in filter bank1 and is position 572 * in the filter bank is (filterNo - 32). If is lower than 32 represents the filter position from bank0. 573 * This function requires CanEXCEL instance to be set in FreezeMode. 574 * @param[in] Instance A CanExcel instance number 575 * @param[in] filterValue Filter configurations for AFs 576 * @param[in\out] filterNo The filer position allocated from memory filter bank 577 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 578 * CANEXCEL_STATUS_BUFF_OUT_OF_RANGE no available filter postion to set the filter.<br> 579 * CANEXCEL_STATUS_ERROR if fail to set; Because is not in freezeMode;<br> 580 */ 581 Canexcel_Ip_StatusType Canexcel_Ip_ConfigAccAddrFilter(uint8 Instance,const Canexcel_Ip_RxFifoFilterID_ADDR * filterValue, uint8 * filterNo); 582 /** 583 * @brief This function return the HardWare status of a specific Message Descriptor 584 * @param[in] Instance A CanExcel instance number 585 * @param[in] descNo A descriptor Number 586 * @param[in/out] sysPoint Pointer where to return the number of the Pushed Messages in the descriptor 587 * @param[in/out] hwPoint Pointer where to return the number of the HW processed Messages already pushed. 588 * @return CANEXCEL_DESC_STATE_INACTIVE the descriptor is not used. 589 CANEXCEL_DESC_STATE_EMPTY No pushed Messages in descriptor. 590 CANEXCEL_DESC_STATE_NOTFULL Can be push more messages in descriptor 591 CANEXCEL_DESC_STATE_FULL The descriptor is full no more Messages can't be push 592 CANEXCEL_DESC_STATE_OVERRUN Have been pushed more messages than the Depth of the Descriptor. 593 */ 594 Canexcel_Ip_DescState Canexcel_Ip_GetDescriptorStatus(uint8 Instance, uint8 descNo, uint8 * sysPoint, uint8 * hwPoint); 595 /** 596 * @brief This function Enable\Disable Interrput for a specific Message Descriptor 597 * @param[in] Instance A CanExcel instance number 598 * @param[in] descNo A descriptor Number to activate\deactivate interrupt 599 * @param[in] enable TRUE Enables Interrupt 600 * FALSE Disables Interrupt 601 */ 602 void Canexcel_Ip_SetMsgBuffInterrupt(uint8 instance, uint8 descNo, boolean enable); 603 /** 604 * @brief Return the Interrupt Status Flag of a Message Descriptor 605 * @param[in] instance A CanExcel instance number 606 * @param[in] descNo A descriptor Number to activate\deactivate interrupt 607 * @return The Interrupt Status Flag Value. 608 */ 609 uint8 Canexcel_Ip_GetMsgDescIntStatusFlag(uint8 instance, uint8 descNo); 610 /** 611 * @brief De-activates the given Message Descriptor. 612 * @details This function shall de-activate given Message descriptor and it can't participate in the message Tx or Rx process. 613 * @note The system pointer and hardware pointer of the Message descriptor equal to zero after de-activation. 614 * 615 * @param[in] instance A CanExcel instance number 616 * @param[in] descNo the Message Descriptor index 617 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 618 * CANEXCEL_STATUS_TIMEOUT if fail to set;<br> 619 */ 620 Canexcel_Ip_StatusType Canexcel_Ip_DeactivateMD(uint8 instance, uint8 descNo); 621 622 #if (CANXL_IP_HAS_ABORT == STD_ON) 623 /** 624 * @brief Abort the given Message Descriptor. 625 * @details This function shall abort given Message descriptor and move it to EMPTY state. 626 * @note The system pointer and hardware pointer of the Message descriptor equal to zero after abort. 627 * 628 * @param[in] instance A CanExcel instance number 629 * @param[in] descNo the Message Descriptor index 630 * @return CANEXCEL_STATUS_SUCCESS if successful;<br> 631 * CANEXCEL_STATUS_TIMEOUT if fail to set;<br> 632 * CANEXCEL_STATUS_NO_TRANSFER_IN_PROGRESS if no transfer initiated before abort;<br> 633 */ 634 Canexcel_Ip_StatusType Canexcel_Ip_AbortMD(uint8 instance, uint8 descNo); 635 #endif 636 637 /** 638 * @brief DeInitializes the CanEXCEL peripheral. 639 * @details This function will reset CanEXCEL module at reset Values. 640 * @param[in] u8Instance A CanEXCEL instance number 641 * @return CANEXCEL_STATUS_SUCCESS if successfull;<br> 642 * CANEXCEL_STATUS_ERROR if other error occurred;<br> 643 * CANEXCEL_STATUS_TIMEOUT if fail to configure in configured timeout value.<br> 644 */ 645 Canexcel_Ip_StatusType Canexcel_Ip_Deinit(uint8 u8Instance); 646 647 #define CAN_43_CANEXCEL_STOP_SEC_CODE 648 #include "Can_43_CANEXCEL_MemMap.h" 649 #ifdef __cplusplus 650 } 651 #endif /* __cplusplus */ 652 653 /** @} */ 654 655 #endif /* CANEXCEL_IP_H_ */ 656