Pdb_Adc_Ip_HwAccess.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : ADC
  5. * Dependencies : none
  6. *
  7. * Autosar Version : 4.4.0
  8. * Autosar Revision : ASR_REL_4_4_REV_0000
  9. * Autosar Conf.Variant :
  10. * SW Version : 1.0.0
  11. * Build Version : S32K1_RTD_1_0_0_HF01_D2109_ASR_REL_4_4_REV_0000_20210907
  12. *
  13. * (c) Copyright 2020-2021 NXP Semiconductors
  14. * All Rights Reserved.
  15. *
  16. * NXP Confidential. This software is owned or controlled by NXP and may only be
  17. * used strictly in accordance with the applicable license terms. By expressly
  18. * accepting such terms or by downloading, installing, activating and/or otherwise
  19. * using the software, you are agreeing that you have read, and that you agree to
  20. * comply with and are bound by, such license terms. If you do not agree to be
  21. * bound by the applicable license terms, then you may not retain, install,
  22. * activate or otherwise use the software.
  23. ==================================================================================================*/
  24. #ifndef PDB_PDB_ADC_IP_HW_ACCESS_H
  25. #define PDB_PDB_ADC_IP_HW_ACCESS_H
  26. /**
  27. * @file
  28. *
  29. * @internal
  30. * @addtogroup pdb_adc_ip Pdb Adc IPL
  31. * @{
  32. */
  33. #include "StandardTypes.h"
  34. /*******************************************************************************
  35. * Source file version information
  36. ******************************************************************************/
  37. #define PDB_ADC_IP_VENDOR_ID_HWACCESS_H 43
  38. #define PDB_ADC_IP_AR_RELEASE_MAJOR_VERSION_HWACCESS_H 4
  39. #define PDB_ADC_IP_AR_RELEASE_MINOR_VERSION_HWACCESS_H 4
  40. #define PDB_ADC_IP_AR_RELEASE_REVISION_VERSION_HWACCESS_H 0
  41. #define PDB_ADC_IP_SW_MAJOR_VERSION_HWACCESS_H 1
  42. #define PDB_ADC_IP_SW_MINOR_VERSION_HWACCESS_H 0
  43. #define PDB_ADC_IP_SW_PATCH_VERSION_HWACCESS_H 0
  44. /*******************************************************************************
  45. * File version checks
  46. ******************************************************************************/
  47. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  48. /* Check if Pdb_Adc_Ip_HwAccess.h file and StandardTypes.h file are of the same Autosar version */
  49. #if ((PDB_ADC_IP_AR_RELEASE_MAJOR_VERSION_HWACCESS_H != STD_AR_RELEASE_MAJOR_VERSION) || \
  50. (PDB_ADC_IP_AR_RELEASE_MINOR_VERSION_HWACCESS_H != STD_AR_RELEASE_MINOR_VERSION) \
  51. )
  52. #error "AutoSar Version Numbers of Pdb_Adc_Ip_HwAccess.h and StandardTypes.h are different"
  53. #endif
  54. #endif /* DISABLE_MCAL_INTERMODULE_ASR_CHECK */
  55. #if defined (__cplusplus)
  56. extern "C" {
  57. #endif
  58. /*******************************************************************************
  59. * Code
  60. ******************************************************************************/
  61. #define ADC_START_SEC_CODE
  62. #include "Adc_MemMap.h"
  63. static inline void Pdb_Adc_HwAcc_SetAdcPretriggerMask(PDB_Type * const Base, const uint8 ChanIdx, const uint32 Mask, const boolean Value)
  64. {
  65. /* Set C1 register of a channel based on mask */
  66. if (Value == TRUE)
  67. {
  68. Base->CH[ChanIdx].C1 |= Mask;
  69. }
  70. else
  71. {
  72. Base->CH[ChanIdx].C1 &= ~(Mask);
  73. }
  74. }
  75. static inline void Pdb_Adc_HwAcc_DisablePdb(PDB_Type * const Base)
  76. {
  77. /* Disable PDB by clearing PDBEN bit of SC register */
  78. Base->SC &= ~(PDB_SC_PDBEN_MASK);
  79. }
  80. static inline void Pdb_Adc_HwAcc_SetContinuousMode(PDB_Type * const Base, const boolean State)
  81. {
  82. /* Update ContinuousMode value found in SC register */
  83. if (State == TRUE)
  84. {
  85. Base->SC |= PDB_SC_CONT_MASK;
  86. }
  87. else
  88. {
  89. Base->SC &= ~(PDB_SC_CONT_MASK);
  90. }
  91. }
  92. static inline void Pdb_Adc_HwAcc_ConfigAdcPretriggers(PDB_Type * const Base, const uint8 ChanIdx, const Pdb_Adc_Ip_PretriggersConfigType * const Config)
  93. {
  94. /* Configure all channel's pretriggers by updating all fields of the C1 register */
  95. uint32 C1Reg = Base->CH[ChanIdx].C1;
  96. C1Reg &= ~(PDB_C1_EN_MASK | PDB_C1_TOS_MASK | PDB_C1_BB_MASK);
  97. C1Reg |= PDB_C1_EN(Config->EnableMask);
  98. C1Reg |= PDB_C1_TOS(Config->EnableDelayMask);
  99. C1Reg |= PDB_C1_BB(Config->BackToBackEnableMask);
  100. Base->CH[ChanIdx].C1 = C1Reg;
  101. }
  102. static inline void Pdb_Adc_HwAcc_ClearAdcPretriggerFlags(PDB_Type * const Base, const uint8 ChanIdx, const uint16 PretriggMask)
  103. {
  104. /* Clear pretrigger status flags found in S register based on PretriggMask */
  105. Base->CH[ChanIdx].S &= ~PDB_S_CF(PretriggMask);
  106. }
  107. #define ADC_STOP_SEC_CODE
  108. #include "Adc_MemMap.h"
  109. #if defined (__cplusplus)
  110. }
  111. #endif
  112. /** @} */
  113. #endif /* PDB_PDB_ADC_IP_HW_ACCESS_H */