1 /* 2 * Copyright 2021-2024 NXP 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef EMIOS_ICU_IP_H 8 #define EMIOS_ICU_IP_H 9 10 /** 11 * @file Emios_Icu_Ip.h 12 * 13 * @addtogroup emios_icu_ip EMIOS IPL 14 * @{ 15 */ 16 17 #ifdef __cplusplus 18 extern "C" 19 { 20 #endif 21 22 /*================================================================================================== 23 INCLUDE FILES 24 1) system and project includes 25 2) needed interfaces from external units 26 3) internal and external interfaces from this unit 27 ==================================================================================================*/ 28 #include "Emios_Icu_Ip_Cfg.h" 29 30 #if (STD_ON == EMIOS_ICU_IP_USED) 31 #if (STD_ON == EMIOS_ICU_USES_MCL_DRIVER) 32 /* Include common functions of EMIOS. */ 33 #include "Emios_Mcl_Ip.h" 34 #endif 35 #endif /* EMIOS_ICU_IP_USED */ 36 37 /*================================================================================================== 38 SOURCE FILE VERSION INFORMATION 39 ==================================================================================================*/ 40 #define EMIOS_ICU_IP_VENDOR_ID 43 41 #define EMIOS_ICU_IP_AR_RELEASE_MAJOR_VERSION 4 42 #define EMIOS_ICU_IP_AR_RELEASE_MINOR_VERSION 7 43 #define EMIOS_ICU_IP_AR_RELEASE_REVISION_VERSION 0 44 #define EMIOS_ICU_IP_SW_MAJOR_VERSION 2 45 #define EMIOS_ICU_IP_SW_MINOR_VERSION 0 46 #define EMIOS_ICU_IP_SW_PATCH_VERSION 0 47 48 /*================================================================================================== 49 FILE VERSION CHECKS 50 ==================================================================================================*/ 51 #if (EMIOS_ICU_IP_VENDOR_ID != EMIOS_ICU_IP_CFG_VENDOR_ID) 52 #error "Emios_Icu_Ip.h and Emios_Icu_Ip_Cfg.h have different vendor ids" 53 #endif 54 55 /* Check if header file and Emios_Icu_Ip_Cfg.h file are of the same Autosar version */ 56 #if ((EMIOS_ICU_IP_AR_RELEASE_MAJOR_VERSION != EMIOS_ICU_IP_CFG_AR_RELEASE_MAJOR_VERSION) || \ 57 (EMIOS_ICU_IP_AR_RELEASE_MINOR_VERSION != EMIOS_ICU_IP_CFG_AR_RELEASE_MINOR_VERSION) || \ 58 (EMIOS_ICU_IP_AR_RELEASE_REVISION_VERSION != EMIOS_ICU_IP_CFG_AR_RELEASE_REVISION_VERSION)) 59 #error "AutoSar Version Numbers of Emios_Icu_Ip.h and Emios_Icu_Ip_Cfg.h are different" 60 #endif 61 62 /* Check if header file and Emios_Icu_Ip_Cfg.h file are of the same Software version */ 63 #if ((EMIOS_ICU_IP_SW_MAJOR_VERSION != EMIOS_ICU_IP_CFG_SW_MAJOR_VERSION) || \ 64 (EMIOS_ICU_IP_SW_MINOR_VERSION != EMIOS_ICU_IP_CFG_SW_MINOR_VERSION) || \ 65 (EMIOS_ICU_IP_SW_PATCH_VERSION != EMIOS_ICU_IP_CFG_SW_PATCH_VERSION)) 66 #error "Software Version Numbers of Emios_Icu_Ip.h and Emios_Icu_Ip_Cfg.h are different" 67 #endif 68 69 #if (STD_ON == EMIOS_ICU_IP_USED) 70 #if (STD_ON == EMIOS_ICU_USES_MCL_DRIVER) 71 /* Check if header file and Emios_Mcl_Ip.h file are of the same Autosar version */ 72 #if (EMIOS_ICU_IP_VENDOR_ID != EMIOS_MCL_IP_VENDOR_ID) 73 #error "Emios_Icu_Ip.h and Emios_Mcl_Ip.h have different vendor ids" 74 #endif 75 76 /* Check if header file and Emios_Mcl_Ip.h file are of the same Autosar version */ 77 #if ((EMIOS_ICU_IP_AR_RELEASE_MAJOR_VERSION != EMIOS_MCL_IP_AR_RELEASE_MAJOR_VERSION) || \ 78 (EMIOS_ICU_IP_AR_RELEASE_MINOR_VERSION != EMIOS_MCL_IP_AR_RELEASE_MINOR_VERSION) || \ 79 (EMIOS_ICU_IP_AR_RELEASE_REVISION_VERSION != EMIOS_MCL_IP_AR_RELEASE_REVISION_VERSION)) 80 #error "AutoSar Version Numbers of Emios_Icu_Ip.h and Emios_Mcl_Ip.h are different" 81 #endif 82 83 /* Check if header file and Emios_Mcl_Ip.h file are of the same Software version */ 84 #if ((EMIOS_ICU_IP_SW_MAJOR_VERSION != EMIOS_MCL_IP_SW_MAJOR_VERSION) || \ 85 (EMIOS_ICU_IP_SW_MINOR_VERSION != EMIOS_MCL_IP_SW_MINOR_VERSION) || \ 86 (EMIOS_ICU_IP_SW_PATCH_VERSION != EMIOS_MCL_IP_SW_PATCH_VERSION)) 87 #error "Software Version Numbers of Emios_Icu_Ip.h and Emios_Mcl_Ip.h are different" 88 #endif 89 #endif 90 #endif /* EMIOS_ICU_IP_USED */ 91 /*================================================================================================== 92 CONSTANTS 93 ==================================================================================================*/ 94 95 /*================================================================================================== 96 DEFINES AND MACROS 97 ==================================================================================================*/ 98 #if (STD_ON == EMIOS_ICU_IP_USED) 99 100 #if (defined EMIOS_ICU_CONFIG_EXT) 101 #define ICU_START_SEC_CONFIG_DATA_UNSPECIFIED 102 #include "Icu_MemMap.h" 103 104 /* Macro used to import Emios PB generated configurations. */ 105 EMIOS_ICU_CONFIG_EXT 106 107 #define ICU_STOP_SEC_CONFIG_DATA_UNSPECIFIED 108 #include "Icu_MemMap.h" 109 #endif 110 /*================================================================================================== 111 * GLOBAL VARIABLES 112 ==================================================================================================*/ 113 114 #if (EMIOS_ICU_IP_NO_CACHE_USED == STD_ON) 115 #define ICU_START_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE 116 #else 117 #define ICU_START_SEC_VAR_CLEARED_UNSPECIFIED 118 #endif 119 #include "Icu_MemMap.h" 120 #if (EMIOS_ICU_IP_SIGNAL_MEASUREMENT_API == STD_ON) 121 extern eMios_Icu_Ip_MeasStatusType eMios_Icu_Ip_aeInt_Counter[EMIOS_ICU_IP_NUM_OF_CHANNELS_USED]; 122 extern eMios_Icu_ValueType eMios_Icu_Ip_CapturedActivePulseWidth[EMIOS_ICU_IP_NUM_OF_CHANNELS_USED]; 123 extern eMios_Icu_ValueType eMios_Icu_Ip_TimeStart[EMIOS_ICU_IP_NUM_OF_CHANNELS_USED]; 124 #endif /* EMIOS_ICU_IP_SIGNAL_MEASUREMENT_API == STD_ON */ 125 #if (EMIOS_ICU_IP_TIMESTAMP_API == STD_ON) 126 extern eMios_Icu_ValueType eMios_Icu_Ip_BufferPtr[EMIOS_ICU_IP_NUM_OF_CHANNELS_USED]; 127 #endif /* EMIOS_ICU_IP_TIMESTAMP_API == STD_ON */ 128 129 extern eMios_Icu_Ip_ChStateType eMios_Icu_Ip_ChState[EMIOS_ICU_IP_NUM_OF_CHANNELS_USED]; 130 131 #if (defined EMIOS_ICU_IP_WSC_SUPPORT) 132 #if (EMIOS_ICU_IP_WSC_SUPPORT == STD_ON) 133 extern eMios_Icu_Ip_WsChStateType eMios_Icu_Ip_WsChState[EMIOS_ICU_IP_INSTANCE_COUNT][EMIOS_ICU_IP_WSC_NUM_OF_CHANNELS]; 134 #endif 135 #endif 136 #if (EMIOS_ICU_IP_NO_CACHE_USED == STD_ON) 137 #define ICU_STOP_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE 138 #else 139 #define ICU_STOP_SEC_VAR_CLEARED_UNSPECIFIED 140 #endif 141 #include "Icu_MemMap.h" 142 143 #if (EMIOS_ICU_IP_NO_CACHE_USED == STD_ON) 144 #define ICU_START_SEC_VAR_INIT_8_NO_CACHEABLE 145 #else 146 #define ICU_START_SEC_VAR_INIT_8 147 #endif 148 #include "Icu_MemMap.h" 149 /* This array stores the positions in the eMios_Icu_Ip_ChState array of the configured eMios channels. */ 150 extern uint8 eMios_Icu_Ip_IndexInChState[EMIOS_ICU_IP_INSTANCE_COUNT][EMIOS_ICU_IP_NUM_OF_CHANNELS]; 151 #if (EMIOS_ICU_IP_NO_CACHE_USED == STD_ON) 152 #define ICU_STOP_SEC_VAR_INIT_8_NO_CACHEABLE 153 #else 154 #define ICU_STOP_SEC_VAR_INIT_8 155 #endif 156 #include "Icu_MemMap.h" 157 158 #define ICU_START_SEC_CONST_UNSPECIFIED 159 #include "Icu_MemMap.h" 160 extern eMIOS_Type * const s_emiosBase[]; 161 #define ICU_STOP_SEC_CONST_UNSPECIFIED 162 #include "Icu_MemMap.h" 163 164 #define ICU_START_SEC_VAR_CLEARED_32_NO_CACHEABLE 165 #include "Icu_MemMap.h" 166 #if (STD_ON == EMIOS_ICU_IP_SIGNALMEASUREMENT_USES_DMA_IPL) 167 /** @brief Array for saving value of DMA **/ 168 extern volatile uint32 Emios_Icu_Ip_aDmaBuffer[EMIOS_ICU_IP_NUM_OF_CHANNELS_USED][EMIOS_ICU_IP_DMA_MAJORLOOP_COUNT]; 169 170 /** @brief Array for saving the period */ 171 extern volatile uint32 Emios_Icu_Ip_aIsSecondInterrupt[EMIOS_ICU_IP_NUM_OF_CHANNELS_USED]; 172 173 /** @brief Array for saving the period */ 174 extern volatile uint32 Emios_Icu_Ip_aFirstEdgeTimeStamp[EMIOS_ICU_IP_NUM_OF_CHANNELS_USED]; 175 176 #endif /* EMIOS_ICU_IP_SIGNALMEASUREMENT_USES_DMA_IPL */ 177 178 #define ICU_STOP_SEC_VAR_CLEARED_32_NO_CACHEABLE 179 #include "Icu_MemMap.h" 180 181 /*================================================================================================== 182 ENUMS 183 ==================================================================================================*/ 184 185 /*================================================================================================== 186 STRUCTURES AND OTHER TYPEDEFS 187 ==================================================================================================*/ 188 189 190 /*================================================================================================== 191 GLOBAL VARIABLE DECLARATIONS 192 ==================================================================================================*/ 193 194 /*================================================================================================== 195 FUNCTION PROTOTYPES 196 ==================================================================================================*/ 197 #define ICU_START_SEC_CODE 198 #include "Icu_MemMap.h" 199 200 /** 201 * @brief Emios_Icu_Ip_Init 202 * @details This function is called separately for each EMIOS hw channel corresponding to 203 * the configured Icu channels, and: 204 * - Disables the interrupt corresponding to eMIOS channel 205 * - Initializes prescaler value, channel filter, freeze enable, and bus select fields 206 * - Defines on which edge the period starts 207 * - Clears the (pending) interrupt flag corresponding to eMIOS channel 208 * - Resets the UC A register. 209 * - Enables the SAIC mode for eMIOS channels. 210 * @param[in] instance - EMIOS instance used. 211 * @param[in] userConfig - pointer to eMios configuration structure 212 */ 213 eMios_Icu_Ip_StatusType Emios_Icu_Ip_Init(uint8 instance, const eMios_Icu_Ip_ConfigType *userConfig); 214 215 #if (EMIOS_ICU_IP_DEINIT_API == STD_ON) 216 /** 217 * @brief Emios_Icu_Ip_Deinit 218 * @details This function is called separately for each EMIOS hw channel corresponding to the 219 * configured Icu channels, and: 220 * - Resets the eMIOS channel control register 221 * - Resets the UC A register. 222 * - Clears the (pending) interrupt flag corresponding to eMIOS channel 223 * @param[in] peMiosIpConfig - pointer to eMios configuration structure 224 */ 225 eMios_Icu_Ip_StatusType Emios_Icu_Ip_Deinit(uint8 instance); 226 #endif 227 228 #if (EMIOS_ICU_IP_SET_MODE_API == STD_ON) 229 /** 230 * @brief Emios_Icu_Ip_SetSleepMode 231 * @details This function is called separately for each EMIOS hw channel corresponding to the 232 * configured Icu channels, and: 233 * - Enables the interrupt for the eMIOS channel, 234 * if the wake up functionality is enabled 235 * - Disables the interrupt for the eMIOS channel, 236 * if the wake up functionality is disabled 237 * @param[in] instance - eMIOS module index 238 * @param[in] hwChannel - eMIOS encoded hardware channel 239 * @api 240 */ 241 void Emios_Icu_Ip_SetSleepMode(uint8 instance, uint8 hwChannel); 242 243 /** 244 * @brief Emios_Icu_Ip_SetNormalMode 245 * @details This function: Set normal mode 246 * 247 * @param[in] instance - eMIOS module index 248 * @param[in] hwChannel - eMIOS encoded hardware channel 249 * @api 250 */ 251 void Emios_Icu_Ip_SetNormalMode(uint8 instance, uint8 hwChannel); 252 #endif /* ICU_SET_MODE_API */ 253 254 /** 255 * @brief Icu driver function that sets activation condition of eMIOS channel 256 * @details This function enables the requested activation condition(rising, falling or both 257 * edges) for corresponding eMIOS channels. 258 * @param[in] instance - eMIOS module index 259 * @param[in] hwChannel - eMIOS channel index 260 * @param[in] edge - type of edge to be used 261 * @api 262 */ 263 void Emios_Icu_Ip_SetActivation(uint8 instance, uint8 hwChannel, eMios_Icu_Ip_EdgeType edge); 264 265 #if (EMIOS_ICU_IP_EDGE_DETECT_API == STD_ON) 266 /** 267 * @brief Emios_Icu_Ip_EnableEdgeDetection 268 * @details eMIOS IP function that starts the edge detection service for an eMIOS channel 269 * 270 * @param[in] instance - eMIOS module index 271 * @param[in] hwChannel - eMIOS encoded hardware channel 272 * 273 * @return void 274 */ 275 void Emios_Icu_Ip_EnableEdgeDetection(uint8 instance, uint8 hwChannel); 276 277 /** 278 * @brief Emios_Icu_Ip_DisableEdgeDetection 279 * @details eMIOS IP function that stops the edge detection service for an eMIOS channel 280 * 281 * @param[in] instance - eMIOS module index 282 * @param[in] hwChannel - eMIOS encoded hardware channel 283 * 284 * @return void 285 */ 286 void Emios_Icu_Ip_DisableEdgeDetection(uint8 instance, uint8 hwChannel); 287 #endif /* ICU_EDGE_DETECT_API */ 288 289 /** 290 * @brief Driver function Enable Notification. 291 * 292 * @param[in] instance Hardware instance used. 293 * @param[in] hwChannel Hardware channel used. 294 * @return void 295 */ 296 void Emios_Icu_Ip_EnableNotification(uint8 instance, uint8 hwChannel); 297 298 /** 299 * @brief Driver function Disable Notification. 300 * 301 * @param[in] instance Hardware instance used. 302 * @param[in] hwChannel Hardware channel used. 303 * @return void 304 */ 305 void Emios_Icu_Ip_DisableNotification(uint8 instance, uint8 hwChannel); 306 307 #if (EMIOS_ICU_IP_TIMESTAMP_API == STD_ON) 308 /** 309 * @brief Icu driver function that starts time stamp measurement of eMIOS channel. 310 * @details This function: 311 * - Puts the eMIOS channel into GPIO mode 312 * - Clears the pending interrupts 313 * - Enables SAIC mode for the channel 314 * - Enbales the interrupt for the channel 315 * 316 * @param[in] instance - eMIOS module index 317 * @param[in] hwChannel - eMIOS encoded hardware channel 318 * @param[in] bufferPtr - buffer pointer for results 319 * @param[in] bufferSize - size of buffer results 320 * @param[in] notifyInterval - interval for calling notification 321 * @api 322 */ 323 void Emios_Icu_Ip_StartTimestamp 324 ( 325 uint8 instance, 326 uint8 hwChannel, 327 eMios_Icu_ValueType * bufferPtr, 328 uint16 bufferSize, 329 uint16 notifyInterval 330 ); 331 332 /** 333 * @brief This function reads the timestamp index of the given channel. 334 * @details This function reentrant and reads the timestamp index of the given channel, 335 * which is next to be written. 336 * 337 * @param[in] instance - eMIOS module index 338 * @param[in] hwChannel - Logical number of the ICU channel 339 * 340 * @return uint16 - Timestamp index of the given channel 341 * @pre Emios_Icu_Ip_Init must be called before. Icu_StartTimestamp must be called before. 342 */ 343 uint16 Emios_Icu_Ip_GetTimestampIndex 344 ( 345 uint8 instance, 346 uint8 hwChannel 347 ); 348 349 /** 350 * @brief Icu driver function that stops time stamp measurement of eMIOS channel. 351 * @details This function: 352 * - Puts the eMIOS channel into GPIO mode 353 * - Disables the interrupt for the channel 354 * 355 * @param[in] instance - eMIOS module index 356 * @param[in] hwChannel - eMIOS encoded hardware channel 357 * @api 358 */ 359 void Emios_Icu_Ip_StopTimestamp(uint8 instance, uint8 hwChannel); 360 #endif /* EMIOS_ICU_IP_TIMESTAMP_API */ 361 362 #if ((EMIOS_ICU_IP_SIGNALMEASUREMENT_USES_DMA == STD_ON) || (EMIOS_ICU_IP_TIMESTAMP_USES_DMA == STD_ON)) 363 /** 364 * @brief Emios_Icu_Ip_GetStartAddress 365 * @details eMIOS IP function that stops the edge detection service for an eMIOS channel 366 * 367 * @param[in] instance - eMIOS module index 368 * @param[in] hwChannel - eMIOS encoded hardware channel 369 * 370 * @return void 371 * 372 **/ 373 uint32 Emios_Icu_Ip_GetStartAddress 374 ( 375 uint8 instance, 376 uint8 hwChannel 377 ); 378 #endif 379 380 #if (EMIOS_ICU_IP_EDGE_COUNT_API == STD_ON) 381 /** 382 * @brief Icu driver function that resets the edge counter measurement of eMIOS channel. 383 * @details The function: 384 * - Puts the eMIOS channel into GPIO mode 385 * - Resets the counter to initial value 386 * - Loads the initial value to the RegisterA 387 * - Clears the pending interrupts 388 * - Restores the previous mode 389 * 390 * @param[in] instance - eMIOS module index 391 * @param[in] hwChannel - eMIOS encoded hardware channel 392 * 393 * @api 394 */ 395 void Emios_Icu_Ip_ResetEdgeCount 396 ( 397 uint8 instance, 398 uint8 hwChannel 399 ); 400 401 /** 402 * @brief Icu driver function that enables the edge counter measurement of eMIOS channel. 403 * @details The function: 404 * - Puts the eMIOS channel into GPIO mode 405 * - Counter register is loaded with startValue 406 * - Loads initial value to RegisterA 407 * - Clears the pending interrupts 408 * - Sets the mode to Modulus counter mode 409 * - Enables the interrupt for eMIOS channel 410 * 411 * @param[in] instance - eMIOS module index 412 * @param[in] hwChannel - eMIOS encoded hardware channel 413 */ 414 void Emios_Icu_Ip_EnableEdgeCount(uint8 instance, uint8 hwChannel); 415 416 /** 417 * @brief Icu driver function that disables the edge counter measurement of eMIOS channel. 418 * @details The function: 419 * - Disables the eMIOS channel interrupt 420 * - Clears the pending interrupts 421 * - Save the current counter value before entering into GPIO mode 422 * - Puts the channel into GPIO mode 423 * - Disables MCB mode for the channel 424 * 425 * @param[in] instance - eMIOS module index 426 * @param[in] hwChannel - eMIOS encoded hardware channel 427 * 428 * @api 429 */ 430 void Emios_Icu_Ip_DisableEdgeCount 431 ( 432 uint8 instance, 433 uint8 hwChannel 434 ); 435 436 /** 437 * @brief Icu driver function that gets edge counter measurement of eMIOS channel. 438 * @details This function returns counter value (the number of counter edges) of eMIOS channel 439 * 440 * @param[in] instance - eMIOS module index 441 * @param[in] hwChannel - eMIOS encoded hardware channel 442 * 443 * @return uint32 - Counted edges number 444 * 445 * @api 446 */ 447 eMios_Icu_ValueType Emios_Icu_Ip_GetEdgeNumbers 448 ( 449 uint8 instance, 450 uint8 hwChannel 451 ); 452 453 #if (STD_ON == EMIOS_ICU_IP_SET_INITIAL_COUNTER) 454 /** 455 * @brief Icu driver function that Set Initial setting of eMIOS Counter. 456 * @details This function Set Initial setting of eMIOS Counter 457 * 458 * @param[in] instance - eMIOS module index 459 * @param[in] hwChannel - eMIOS encoded hardware channel 460 * @param[in] offsetCounter - eMios Initial counter 461 * 462 * @pre This function is not required because the counter value is 463 * set automatically. But to arbitrarily change the Initial value 464 * of the counter value, it is necessary to call this function 465 * before the Emios_Icu_Ip_EnableEdgeCount. 466 * After call Emios_Icu_Ip_ResetEdgeCount function to reset counter value 467 * to 0, the previously set Initial value will no longer be valid. 468 */ 469 void Emios_Icu_Ip_SetInitialCounterValue 470 ( 471 uint8 instance, 472 uint8 hwChannel, 473 uint32 initialCounter 474 ); 475 #endif /* STD_ON == EMIOS_ICU_IP_SET_INITIAL_COUNTER */ 476 477 #if (STD_ON == EMIOS_ICU_IP_SET_MAX_COUNTER) 478 /** 479 * @brief Icu driver function that Set Max setting of eMIOS Counter. 480 * @details This function Set Max setting of eMIOS Counter 481 * 482 * @param[in] instance - eMIOS module index 483 * @param[in] hwChannel - eMIOS encoded hardware channel 484 * @param[in] defaultCounter - eMios Max counter 485 * 486 * @pre This function is not required because the counter value is 487 * set automatically. But to arbitrarily change the Max value 488 * of the counter value, it is necessary to call this function 489 * before the Emios_Icu_Ip_EnableEdgeCount function. 490 */ 491 void Emios_Icu_Ip_SetMaxCounterValue 492 ( 493 uint8 instance, 494 uint8 hwChannel, 495 uint32 maxCounter 496 ); 497 #endif /* STD_ON == EMIOS_ICU_IP_SET_MAX_COUNTER */ 498 #endif /* EMIOS_ICU_IP_EDGE_COUNT_API == STD_ON */ 499 500 #if (EMIOS_ICU_IP_SIGNAL_MEASUREMENT_API == STD_ON) 501 /** 502 * @brief Icu driver function that starts the signal measurement of eMIOS channel. 503 * @details This function: 504 * - Disables the interrupt of eMIOS channel 505 * - Puts the eMIOS channel into GPIO mode 506 * - Sets activation condition (Rising, Falling or Both edges) 507 * - Puts the eMIOS channel into requested mode (IPWM, IPM or SAIC) 508 * - Clears pending interrupts 509 * - Enables the interrupt for eMIOS channel 510 * 511 * @param[in] instance - eMIOS module index 512 * @param[in] hwChannel - eMIOS encoded hardware channel 513 * 514 * @api 515 */ 516 void Emios_Icu_Ip_StartSignalMeasurement 517 ( 518 uint8 instance, 519 uint8 hwChannel 520 ); 521 522 /** 523 * @brief Icu driver function that stops the signal measurement of eMIOS channel. 524 * @details This function: 525 * - Puts the eMIOS channel into GPIO mode 526 * - Disables the interrupt for requsted eMIOS channel 527 * - Clears pending interrupts 528 * 529 * @param[in] instance - eMIOS module index 530 * @param[in] hwChannel - eMIOS encoded hardware channel 531 * 532 * @api 533 */ 534 void Emios_Icu_Ip_StopSignalMeasurement 535 ( 536 uint8 instance, 537 uint8 hwChannel 538 ); 539 540 /** 541 * @brief This function reads the elapsed Signal Low, High or Period Time for the given channel. 542 * @details This service is reentrant and reads the elapsed Signal Low Time for the given channel 543 * that is configured in Measurement Mode Signal Measurement, Signal Low Time. 544 * The elapsed time is measured between a falling edge and the consecutive rising edge of 545 * the channel. 546 * This service reads the elapsed Signal High Time for the given channel that is configured 547 * in Measurement Mode Signal Measurement,Signal High Time.The elapsed time is measured 548 * between a rising edge and the consecutive falling edge of the channel. 549 * This service reads the elapsed Signal Period Time for the given channel that is 550 * configured in Measurement Mode Signal Measurement, Signal Period Time.The elapsed time 551 * is measured between consecutive rising (or falling) edges of the channel. The period 552 * start edge is 553 * 554 * configurable. 555 * 556 * @param[in] instance - eMIOS module index 557 * @param[in] hwChannel - Logical number of the ICU channel 558 * 559 * @return uint16 - the elapsed Signal Low Time for the given channel that is configured in 560 * Measurement Mode Signal Measurement, Signal Low Time 561 * @pre Emios_Icu_Ip_Init must be called before. The channel must be configured in Measurement Mode Signal 562 * Measurement. 563 */ 564 eMios_Icu_ValueType Emios_Icu_Ip_GetTimeElapsed 565 ( 566 uint8 instance, 567 uint8 hwChannel 568 ); 569 570 /** 571 * @brief This function reads the coherent active time and period time for the given ICU Channel. 572 * @details The function is reentrant and reads the coherent active time and period time for 573 * the given ICU Channel, if it is configured in Measurement Mode Signal Measurement, Duty 574 * Cycle Values. 575 * 576 * @param[in] instance - eMIOS module index 577 * @param[in] hwChannel - Logical number of the ICU channel 578 * @param[out] dutyCycleValues - Pointer to a buffer where the results (active time and period time) 579 * shall be placed. 580 * 581 * @return void 582 * @pre Emios_Icu_Ip_Init must be called before. The given channel must be configured in Measurement Mode 583 * Signal Measurement, Duty Cycle Values. 584 */ 585 void Emios_Icu_Ip_GetDutyCycleValues 586 ( 587 uint8 instance, 588 uint8 hwChannel, 589 eMios_Icu_Ip_DutyCycleType* dutyCycleValues 590 ); 591 592 /** 593 * @brief Emios_Icu_Ip_SetPWandPeriod 594 * 595 * @param instance 596 * @param hwChannel 597 * @param activePulseWidth 598 * @param period 599 */ 600 void Emios_Icu_Ip_SetPWandPeriod(uint8 instance, 601 uint8 hwChannel, 602 eMios_Icu_ValueType activePulseWidth, 603 eMios_Icu_ValueType period); 604 605 #endif /* EMIOS_ICU_IP_SIGNAL_MEASUREMENT_API */ 606 607 #if (EMIOS_ICU_IP_GET_INPUT_STATE_API == STD_ON) 608 /** 609 * @brief Icu driver function that gets the input state of eMIOS channel. 610 * @details This function: 611 * - Checks if interrupt flags for corresponding eMIOS channel is set then 612 * it clears the interrupt flag and returns the value as true. 613 * 614 * @param[in] instance - eMIOS module index 615 * @param[in] hwChannel - eMIOS encoded hardware channel 616 * 617 * @return boolean 618 * @retval true - if channel is active 619 * @retval false - if channel is idle 620 * 621 * @api 622 */ 623 boolean Emios_Icu_Ip_GetInputState 624 ( 625 uint8 instance, 626 uint8 hwChannel 627 ); 628 #endif /* EMIOS_ICU_IP_GET_INPUT_STATE_API */ 629 630 #if (EMIOS_ICU_IP_GET_INPUT_LEVEL_API == STD_ON) 631 /** 632 * @brief This function returns the actual status of PIN. 633 * @details This function returns the actual status o PIN 634 * 635 * @param[in] instance - eMIOS module index 636 * @param[in] hwChannel - eMIOS encoded hardware channel 637 * 638 * @return void 639 * 640 * @api 641 */ 642 eMios_Icu_Ip_LevelType Emios_Icu_Ip_GetInputLevel 643 ( 644 uint8 instance, 645 uint8 hwChannel 646 ); 647 #endif /* EMIOS_ICU_IP_GET_INPUT_LEVEL_API == STD_ON */ 648 649 /** 650 * @brief Emios_Icu_Ip_GetOverflow 651 * @details eMIOS IP function that get the state of the overflow flag 652 * 653 * @param[in] instance - eMIOS module index 654 * @param[in] hwChannel - eMIOS encoded hardware channel 655 * 656 * @return boolean the state of the overflow flag 657 * @retval true the overflow flag is set 658 * @retval false the overflow flag is not set 659 * 660 * @return void 661 */ 662 boolean Emios_Icu_Ip_GetOverflow 663 ( 664 uint8 instance, 665 uint8 hwChannel 666 ); 667 668 #if (EMIOS_ICU_IP_DUAL_CLOCK_MODE_API == STD_ON) 669 void Emios_Icu_Ip_SetClockMode 670 ( 671 uint8 instance, 672 const eMios_Icu_Ip_ConfigType * peMiosIpConfig, 673 const eMios_Icu_Ip_ClockModeType Prescaler 674 ); 675 #endif /* EMIOS_ICU_IP_DUAL_CLOCK_MODE_API == STD_ON */ 676 677 #if ((EMIOS_ICU_IP_CAPTURERGISTER_API == STD_ON) && ((EMIOS_ICU_IP_SIGNAL_MEASUREMENT_API == STD_ON) || (EMIOS_ICU_IP_TIMESTAMP_API == STD_ON))) 678 uint32 Emios_Icu_Ip_GetCaptureRegValue 679 ( 680 uint8 instance, 681 uint8 hwChannel 682 ); 683 #endif /* EMIOS_ICU_IP_DUAL_CLOCK_MODE_API == STD_ON */ 684 685 #if ((EMIOS_ICU_IP_GET_PULSE_WIDTH_API == STD_ON) && (EMIOS_ICU_IP_SIGNAL_MEASUREMENT_API == STD_ON)) 686 /** 687 * @brief This function returns the signals High time, Low time and Period without using the 688 * channel interrupt 689 * @details This function returns the signals High time, Low time and Period without using the 690 * channel interrupt 691 * 692 * @param[in] instance - eMIOS module index 693 * @param[in] hwChannel - eMIOS hardware channel 694 */ 695 void Emios_Icu_Ip_GetPulseWidth 696 ( 697 uint8 instance, 698 uint8 hwChannel 699 ); 700 #endif /* ((EMIOS_ICU_IP_GET_PULSE_WIDTH_API == STD_ON) && (EMIOS_ICU_IP_SIGNAL_MEASUREMENT_API == STD_ON))*/ 701 702 #if ((EMIOS_ICU_IP_VALIDATE_GLOBAL_CALL == STD_ON) && ((EMIOS_ICU_IP_GET_PULSE_WIDTH_API == STD_ON) && (EMIOS_ICU_IP_SIGNAL_MEASUREMENT_API == STD_ON))) 703 Std_ReturnType Emios_Icu_Ip_ValidateSignalMeasureWithoutInterrupt 704 ( 705 uint8 instance, 706 uint8 hwChannel 707 ); 708 #endif /* ((EMIOS_ICU_IP_GET_PULSE_WIDTH_API == STD_ON) && (EMIOS_ICU_IP_SIGNAL_MEASUREMENT_API == STD_ON))*/ 709 710 /** 711 * @brief Emios_Icu_Ip_EnableInterrupt 712 * @details This function Clears the pending interrupts of eMIOS channels and 713 * enables eMIOS Channel interrupt 714 * 715 * @param[in] instance - eMIOS module index 716 * @param[in] hwChannel - eMIOS Channel index 717 * @api 718 */ 719 void Emios_Icu_Ip_EnableInterrupt(uint8 instance, uint8 hwChannel); 720 721 /** 722 * @brief Emios_Icu_Ip_DisableInterrupt 723 * @details This function disables eMIOS Channel interrupt 724 * 725 * @param[in] instance - eMIOS module index 726 * @param[in] hwChannel - eMIOS Channel index 727 * @api 728 */ 729 void Emios_Icu_Ip_DisableInterrupt(uint8 instance, uint8 hwChannel); 730 731 #if (defined EMIOS_ICU_IP_WSC_SUPPORT) 732 #if (EMIOS_ICU_IP_WSC_SUPPORT == STD_ON) 733 /** 734 * @brief Emios_Icu_Ip_GetWheelSpeedTimeMeasurement 735 * @details Get eMios Wheel Speed pulse width measurement, high time, low time or period time. 736 * 737 * @param[in] instance - eMIOS module instance number 738 * @param[in] hwWSChannel - eMIOS Wheel speed channel to be used 739 * 740 * @return uint32 The actual width measured on input signal 741 * 742 */ 743 uint32 Emios_Icu_Ip_GetWheelSpeedTimeMeasurement(uint8 instance, uint8 hwWSChannel); 744 745 /** 746 * @brief Emios_Icu_Ip_GetWheelSpeedCaptureA 747 * @details Get value of the eMios Wheel Speed capture A register. 748 * 749 * @param[in] instance - eMIOS module instance number 750 * @param[in] hwWSChannel - eMIOS Wheel speed channel to be used 751 * 752 * @return uint32 Value of the EMIOS Wheel Speed capture A register 753 * 754 */ 755 uint32 Emios_Icu_Ip_GetWheelSpeedCaptureA(uint8 instance, uint8 hwWSChannel); 756 757 /** 758 * @brief Emios_Icu_Ip_GetWheelSpeedCaptureB 759 * @details Get value of the eMios Wheel Speed capture B register. 760 * 761 * @param[in] instance - eMIOS module instance number 762 * @param[in] hwWSChannel - eMIOS Wheel speed channel to be used 763 * 764 * @return uint32 Value of the EMIOS Wheel Speed capture B register 765 * 766 */ 767 uint32 Emios_Icu_Ip_GetWheelSpeedCaptureB(uint8 instance, uint8 hwWSChannel); 768 769 /** 770 * @brief Emios_Icu_Ip_SetWheelSpeedEvent 771 * @details Set eMios Wheel Speed number of events in average speed. 772 * 773 * @param[in] instance - eMIOS module instance number 774 * @param[in] hwWSChannel - eMIOS Wheel speed channel to be used 775 * @param[in] event - number of events 776 * 777 * @return void 778 * 779 */ 780 void Emios_Icu_Ip_SetWheelSpeedEvent(uint8 instance, uint8 hwWSChannel, uint8 event); 781 782 /** 783 * @brief Emios_Icu_Ip_GetWheelSpeedCaptureEvent 784 * @details Get Value of Capture Event bits in Wheel Speed Channels Capture Event register. 785 * 786 * @param[in] instance - eMIOS module instance number 787 * @param[in] hwWSChannel - eMIOS Wheel speed channel to be used 788 * 789 * @return uint32 Value of Capture Event 790 * 791 */ 792 uint32 Emios_Icu_Ip_GetWheelSpeedCaptureEvent(uint8 instance, uint8 hwWSChannel); 793 794 /** 795 * @brief Emios_Icu_Ip_GetWheelSpeedEventCnt 796 * @details Get EMIOS Wheel Speed number of event counter. 797 * 798 * @param[in] instance - eMIOS module instance number 799 * @param[in] hwWSChannel - eMIOS Wheel speed channel to be used 800 * 801 * @return uint8 Number of event counter 802 * 803 */ 804 uint8 Emios_Icu_Ip_GetWheelSpeedEventCnt(uint8 instance, uint8 hwWSChannel); 805 806 /** 807 * @brief Emios_Icu_Ip_WheelSpeedEnableInterrupt 808 * @details Enable eMios Wheel Speed interrupt source. 809 * 810 * @param[in] instance - eMIOS module instance number 811 * @param[in] hwWSChannel - eMIOS Wheel speed channel to be used 812 * @param[in] eMios_Icu_Ip_WscIsrSourceType - ISR source 813 * 814 * @return void 815 * 816 */ 817 void Emios_Icu_Ip_WheelSpeedEnableInterrupt(uint8 instance, uint8 hwWSChannel, eMios_Icu_Ip_WscIsrSourceType isrSource); 818 819 /** 820 * @brief Emios_Icu_Ip_WheelSpeedDisableInterrupt 821 * @details Disable eMios Wheel Speed interrupt source. 822 * 823 * @param[in] instance - eMIOS module instance number 824 * @param[in] hwWSChannel - eMIOS Wheel speed channel to be used 825 * @param[in] eMios_Icu_Ip_WscIsrSourceType - ISR source 826 * 827 * @return void 828 * @pre When the value of isrSource is 0, all interrupt sources will be disabled. 829 * 830 */ 831 void Emios_Icu_Ip_WheelSpeedDisableInterrupt(uint8 instance, uint8 hwWSChannel, eMios_Icu_Ip_WscIsrSourceType isrSource); 832 833 /** 834 * @brief Emios_Icu_Ip_GetWheelSpeedFifo 835 * @details Get value of the EMIOS Wheel Speed FIFO. 836 * 837 * @param[in] instance - eMIOS module instance number 838 * @param[in] hwWSChannel - eMIOS Wheel speed channel to be used 839 * @param[in] eMios_Icu_Ip_WscFifoType - eMios Wheel Speed channel Fifo Data struct 840 * 841 * @return void 842 * 843 */ 844 void Emios_Icu_Ip_GetWheelSpeedFifo(uint8 instance, uint8 hwWSChannel, eMios_Icu_Ip_WscFifoType* eMiosWSCFifoData); 845 #endif /* EMIOS_ICU_IP_WSC_SUPPORT */ 846 #endif /* defined EMIOS_ICU_IP_WSC_SUPPORT */ 847 848 #define ICU_STOP_SEC_CODE 849 #include "Icu_MemMap.h" 850 851 #endif /* EMIOS_ICU_IP_USED */ 852 853 #if defined(__cplusplus) 854 } 855 #endif 856 857 /** @} */ 858 859 #endif /* EMIOS_ICU_IP_H */ 860