S32 SDK
cmp_hal.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 - 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016 NXP
4  * All rights reserved.
5  *
6  * THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
7  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
8  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
9  * IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
10  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
11  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
12  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
14  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
15  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
16  * THE POSSIBILITY OF SUCH DAMAGE.
17  */
42 #ifndef CMP_HAL_H
43 #define CMP_HAL_H
44 
45 #include <stdint.h>
46 #include <stdbool.h>
47 #include "device_registers.h"
48 
56 #define CMP_INPUT_FLAGS_MASK 0xFF0000
57 #define CMP_INPUT_FLAGS_SHIFT 16U
58 #define CMP_ROUND_ROBIN_CHANNELS_MASK 0xFF0000
59 #define CMP_ROUND_ROBIN_CHANNELS_SHIFT 16U
60 
61 /*******************************************************************************
62  * Enumerations.
63  ******************************************************************************/
67 typedef enum
68 {
72 
76 typedef enum
77 {
78  CMP_VIN1 = 0U,
79  CMP_VIN2 = 1U
81 
85 typedef enum
86 {
87  CMP_DAC = 0U,
88  CMP_MUX = 1U
90 
94 typedef enum
95 {
96  CMP_NORMAL = 0U,
97  CMP_INVERT = 1U
99 
103 typedef enum
104 {
105  CMP_COUT = 0U,
106  CMP_COUTA = 1U
108 
112 typedef enum
113 {
117 
121 typedef enum
122 {
125 } cmp_offset_t;
126 
130 typedef enum
131 {
137 
141 typedef enum
142 {
146 
150 typedef enum
151 {
157 
161 typedef enum
162 {
172 } cmp_mode_t;
173 
180 typedef uint8_t cmp_ch_list_t;
181 
185 typedef uint8_t cmp_ch_number_t;
186 
187 
188 
189 /*******************************************************************************
190  * API
191  ******************************************************************************/
197  #if defined(__cplusplus)
198 extern "C" {
199 #endif
200 
205 void CMP_HAL_Init(CMP_Type* baseAddr);
206 
223 
242 void CMP_HAL_SetFunctionalMode(CMP_Type* baseAddr, cmp_mode_t mode, uint8_t filter_sample_count, uint8_t filter_sample_period);
243 
252 static inline bool CMP_HAL_GetDMATriggerState(const CMP_Type* baseAddr)
253 {
254  return (bool)(((baseAddr->C0) >> (CMP_C0_DMAEN_SHIFT)) & 1U);
255 }
256 
266 static inline void CMP_HAL_SetDMATriggerState(CMP_Type* baseAddr, bool to_set)
267 {
268  baseAddr->C0 = (baseAddr->C0 & (~(CMP_C0_DMAEN_MASK))) | ((uint32_t)to_set << CMP_C0_DMAEN_SHIFT);
269 }
270 
282 {
283  bool rising_enabled = (bool)(((baseAddr->C0) >> CMP_C0_IER_SHIFT) & 1U);
284  bool falling_enabled = (bool)(((baseAddr->C0) >> CMP_C0_IEF_SHIFT) & 1U);
285  return (cmp_output_trigger_t) (((uint32_t)rising_enabled << (uint32_t)1U) | ((uint32_t)falling_enabled));
286 }
287 
300 {
301  uint32_t tmp = baseAddr->C0;
302  tmp &= ~(CMP_C0_IER_MASK) & ~(CMP_C0_IEF_MASK);
303  tmp |= CMP_C0_IER((uint32_t)to_set>>1) | CMP_C0_IEF((uint32_t)to_set & (uint32_t)0x01);
304  baseAddr->C0 = tmp;
305 }
306 
318 {
319  bool rising_enabled = (bool)(((baseAddr->C0) >> CMP_C0_CFR_SHIFT) & 1U);
320  bool falling_enabled = (bool)(((baseAddr->C0) >> CMP_C0_CFF_SHIFT) & 1U);
321  return (cmp_output_trigger_t) (((uint32_t)rising_enabled << (uint32_t)1U) | ((uint32_t)falling_enabled));
322 }
323 
330 static inline void CMP_HAL_ClearOutputEvent(CMP_Type* baseAddr)
331 {
332  uint32_t tmp = baseAddr->C0;
333  tmp &= ~(CMP_C0_CFR_MASK);
334  tmp |= CMP_C0_CFR(1);
335  tmp &= ~(CMP_C0_CFF_MASK);
336  tmp |= CMP_C0_CFF(1);
337  baseAddr->C0 = tmp;
338 
339  #ifdef ERRATA_E9005
340  (void)baseAddr->C0;
341  #endif
342 }
343 
352 static inline bool CMP_HAL_GetOutputRisingFlag(const CMP_Type* baseAddr)
353 {
354  return (bool)(((baseAddr->C0) >> CMP_C0_CFR_SHIFT) & 1U);
355 }
356 
363 static inline void CMP_HAL_ClearOutputRisingFlag(CMP_Type* baseAddr)
364 {
365  (baseAddr->C0) |= ((uint32_t)1U << CMP_C0_CFR_SHIFT);
366 
367  #ifdef ERRATA_E9005
368  (void)baseAddr->C0;
369  #endif
370 }
371 
380 static inline bool CMP_HAL_GetOutputFallingFlag(const CMP_Type* baseAddr)
381 {
382  return (bool)(((baseAddr->C0) >> CMP_C0_CFF_SHIFT) & 1U);
383 }
384 
391 static inline void CMP_HAL_ClearOutputFallingFlag(CMP_Type* baseAddr)
392 {
393  (baseAddr->C0)|= (uint32_t)1U << CMP_C0_CFF_SHIFT;
394 
395  #ifdef ERRATA_E9005
396  (void)baseAddr->C0;
397  #endif
398 }
399 
406 static inline bool CMP_HAL_GetComparatorOutput(const CMP_Type* baseAddr)
407 {
408  return (bool)(((baseAddr->C0) >> CMP_C0_COUT_SHIFT) & 1U);
409 }
410 
417 static inline uint8_t CMP_HAL_GetFilterSamplePeriod(const CMP_Type* baseAddr)
418 {
419  uint32_t tmp = baseAddr->C0;
420  tmp = (tmp & CMP_C0_FPR_MASK) >> CMP_C0_FPR_SHIFT;
421  return ( uint8_t ) (tmp);
422 }
423 
431 static inline void CMP_HAL_SetFilterSamplePeriod(CMP_Type* baseAddr, uint8_t to_set)
432 {
433  uint32_t tmp = baseAddr->C0;
434  baseAddr->C0 &= ~(CMP_C0_FPR_MASK);
435  tmp &= ~(CMP_C0_FPR_MASK);
436  tmp |= CMP_C0_FPR(to_set);
437  baseAddr->C0 = tmp;
438 }
439 
448 static inline bool CMP_HAL_GetSamplingState(const CMP_Type* baseAddr)
449 {
450  return (bool)(((baseAddr->C0) >> CMP_C0_SE_SHIFT) & 1U);
451 }
452 
462 static inline void CMP_HAL_SetSamplingState(CMP_Type* baseAddr, bool to_set)
463 {
464  (baseAddr->C0) = ((baseAddr->C0) & (~(CMP_C0_SE_MASK))) | ((uint32_t)to_set << CMP_C0_SE_SHIFT);
465 }
466 
475 static inline bool CMP_HAL_GetWindowingModeState(const CMP_Type* baseAddr)
476 {
477  return (bool)(((baseAddr->C0) >> CMP_C0_WE_SHIFT) & 1U);
478 }
479 
489 static inline void CMP_HAL_SetWindowingModeState(CMP_Type* baseAddr, bool to_set)
490 {
491  (baseAddr->C0) = ((baseAddr->C0) & (~(CMP_C0_WE_MASK))) | ((uint32_t)to_set << CMP_C0_WE_SHIFT);
492 }
493 
502 static inline cmp_power_mode_t CMP_HAL_GetPowerMode(const CMP_Type* baseAddr)
503 {
504  return (cmp_power_mode_t)(((baseAddr->C0) >> CMP_C0_PMODE_SHIFT) & 1U);
505 }
506 
515 static inline void CMP_HAL_SetPowerMode(CMP_Type* baseAddr, cmp_power_mode_t to_set)
516 {
517  (baseAddr->C0) = ((baseAddr->C0) & (~(CMP_C0_PMODE_MASK))) | ((uint32_t)to_set << CMP_C0_PMODE_SHIFT);
518 }
519 
528 static inline cmp_inverter_t CMP_HAL_GetInverterState(const CMP_Type* baseAddr)
529 {
530  return (cmp_inverter_t)(((baseAddr->C0) >> CMP_C0_INVT_SHIFT) & 1U);
531 }
532 
542 static inline void CMP_HAL_SetInverterState(CMP_Type* baseAddr, cmp_inverter_t to_set)
543 {
544  (baseAddr->C0) = ((baseAddr->C0) & (~(CMP_C0_INVT_MASK))) | ((uint32_t)to_set << CMP_C0_INVT_SHIFT);
545 }
546 
556 {
557  return (cmp_output_select_t)(((baseAddr->C0) >> CMP_C0_COS_SHIFT) & 1U);
558 }
559 
570 {
571  (baseAddr->C0) = ((baseAddr->C0) & (~(CMP_C0_COS_MASK))) | ((uint32_t)to_set << CMP_C0_COS_SHIFT);
572 }
573 
583 {
584  return (cmp_output_enable_t)(((baseAddr->C0) >> CMP_C0_OPE_SHIFT) & 1U);
585 }
586 
596 static inline void CMP_HAL_SetOutputPinState(CMP_Type* baseAddr, cmp_output_enable_t to_set)
597 {
598 
599  (baseAddr->C0) = ((baseAddr->C0) & (~(CMP_C0_OPE_MASK))) | ((uint32_t)to_set << CMP_C0_OPE_SHIFT);
600 }
601 
610 static inline bool CMP_HAL_GetAnalogComparatorState(const CMP_Type* baseAddr)
611 {
612  return (bool)(((baseAddr->C0) >> CMP_C0_EN_SHIFT) & 1U);
613 }
614 
623 static inline void CMP_HAL_SetAnalogComparatorState(CMP_Type* baseAddr, bool to_set)
624 {
625  (baseAddr->C0) = ((baseAddr->C0) & (~(CMP_C0_EN_MASK))) | ((uint32_t)to_set << CMP_C0_EN_SHIFT);
626 }
627 
635 static inline uint8_t CMP_HAL_GetFilterSampleCount(const CMP_Type* baseAddr)
636 {
637  uint32_t tmp = baseAddr->C0;
639  return ( uint8_t ) (tmp);
640 }
641 
650 static inline void CMP_HAL_SetFilterSampleCount(CMP_Type* baseAddr, uint8_t to_set)
651 {
652  uint32_t tmp = baseAddr->C0;
653  baseAddr->C0 &= ~(CMP_C0_FILTER_CNT_MASK);
654  tmp &= ~(CMP_C0_FILTER_CNT_MASK);
655  tmp |= CMP_C0_FILTER_CNT(to_set);
656  baseAddr->C0 = tmp;
657 }
658 
667 static inline cmp_offset_t CMP_HAL_GetOffset(const CMP_Type* baseAddr)
668 {
669  return (cmp_offset_t)(((baseAddr->C0) >> CMP_C0_OFFSET_SHIFT) & 1U);
670 }
671 
681 static inline void CMP_HAL_SetOffset(CMP_Type* baseAddr, cmp_offset_t to_set)
682 {
683  uint32_t tmp = baseAddr->C0;
684  tmp &= ~(CMP_C0_OFFSET_MASK);
685  tmp |= CMP_C0_OFFSET(to_set);
686  baseAddr->C0 = tmp;
687 }
688 
699 static inline cmp_hysteresis_t CMP_HAL_GetHysteresis(const CMP_Type* baseAddr)
700 {
701  uint32_t tmp = baseAddr->C0;
702  tmp = (tmp & CMP_C0_HYSTCTR_MASK) >> CMP_C0_HYSTCTR_SHIFT;
703  return ( cmp_hysteresis_t ) (tmp);
704 }
705 
717 static inline void CMP_HAL_SetHysteresis(CMP_Type* baseAddr, cmp_hysteresis_t to_set)
718 {
719  uint32_t tmp = baseAddr->C0;
720  tmp &= ~(CMP_C0_HYSTCTR_MASK);
721  tmp |= CMP_C0_HYSTCTR(to_set);
722  baseAddr->C0 = tmp;
723 }
724 
734 static inline void CMP_HAL_SetDACOutputState(CMP_Type* baseAddr, bool to_set)
735 {
736  (baseAddr->C0) = ((baseAddr->C0) & (~(CMP_C0_EN_MASK))) | ((uint32_t)to_set << CMP_C0_EN_SHIFT);
737 }
738 
748 static inline bool CMP_HAL_GetDACOutputState(const CMP_Type* baseAddr)
749 {
750  return (bool)(((baseAddr->C0) & (CMP_C0_EN_MASK)) >> (uint32_t)CMP_C0_EN_SHIFT);
751 }
752 
762 {
763  uint32_t tmp = baseAddr->C1;
764  tmp = (tmp & CMP_C1_INPSEL_MASK) >> CMP_C1_INPSEL_SHIFT;
765  return ( cmp_port_mux_t ) (tmp);
766 }
767 
777 static inline void CMP_HAL_SetPositivePortInput(CMP_Type* baseAddr, cmp_port_mux_t to_set)
778 {
779  uint32_t tmp = baseAddr->C1;
780  tmp &= ~(CMP_C1_INPSEL_MASK);
781  tmp |= CMP_C1_INPSEL(to_set);
782  baseAddr->C1 = tmp;
783 }
784 
794 {
795  uint32_t tmp = baseAddr->C1;
796  tmp = (tmp & CMP_C1_INNSEL_MASK) >> CMP_C1_INNSEL_SHIFT;
797  return ( cmp_port_mux_t ) (tmp);
798 }
799 
809 static inline void CMP_HAL_SetNegativePortInput(CMP_Type* baseAddr, cmp_port_mux_t to_set)
810 {
811  uint32_t tmp = baseAddr->C1;
812  tmp &= ~(CMP_C1_INNSEL_MASK);
813  tmp |= CMP_C1_INNSEL(to_set);
814  baseAddr->C1 = tmp;
815 }
816 
827 {
828  uint32_t tmp = baseAddr->C1;
829  tmp = tmp & (uint32_t)CMP_ROUND_ROBIN_CHANNELS_MASK;
831 }
832 
843 static inline void CMP_HAL_SetRoundRobinChannels(CMP_Type* baseAddr, cmp_ch_list_t to_set)
844 {
845  uint32_t tmp = baseAddr->C1;
846  tmp &= ~(uint32_t)(CMP_ROUND_ROBIN_CHANNELS_MASK);
847  tmp |= (uint32_t)to_set << (uint32_t)CMP_ROUND_ROBIN_CHANNELS_SHIFT;
848  baseAddr->C1 = tmp;
849 }
850 
859 static inline bool CMP_HAL_GetDACState(const CMP_Type* baseAddr)
860 {
861  return (bool)(((baseAddr->C1) >> CMP_C1_DACEN_SHIFT) & 1U);
862 }
863 
873 static inline void CMP_HAL_SetDACState(CMP_Type* baseAddr, bool to_set)
874 {
875  (baseAddr->C1) = ((baseAddr->C1) & (~(CMP_C1_DACEN_MASK))) | ((uint32_t)to_set << CMP_C1_DACEN_SHIFT);
876 }
877 
887 {
888  return (cmp_voltage_reference_t)(((baseAddr->C1) >> CMP_C1_VRSEL_SHIFT) & 1U);
889 }
890 
900 static inline void CMP_HAL_SetVoltageReference(CMP_Type* baseAddr, cmp_voltage_reference_t to_set)
901 {
902  (baseAddr->C1) = ((baseAddr->C1) & (~(CMP_C1_VRSEL_SHIFT))) | ((uint32_t)to_set << CMP_C1_VRSEL_SHIFT);
903 }
904 
911 static inline cmp_ch_number_t CMP_HAL_GetPlusMUXControl(const CMP_Type* baseAddr)
912 {
913  uint32_t tmp = baseAddr->C1;
914  tmp = (tmp & CMP_C1_PSEL_MASK) >> CMP_C1_PSEL_SHIFT;
915  return ( cmp_ch_number_t ) (tmp);
916 }
917 
925 static inline void CMP_HAL_SetPlusMuxControl(CMP_Type* baseAddr, cmp_ch_number_t to_set)
926 {
927  uint32_t tmp = baseAddr->C1;
928  tmp &= ~(CMP_C1_PSEL_MASK);
929  tmp |= CMP_C1_PSEL(to_set);
930  baseAddr->C1 = tmp;
931 }
932 
940 {
941  uint32_t tmp = baseAddr->C1;
942  tmp = (tmp & CMP_C1_MSEL_MASK) >> CMP_C1_MSEL_SHIFT;
943  return ( cmp_ch_number_t ) (tmp);
944 }
945 
953 static inline void CMP_HAL_SetMinusMUXControl(CMP_Type* baseAddr, cmp_ch_number_t to_set)
954 {
955  uint32_t tmp = baseAddr->C1;
956  tmp &= ~(CMP_C1_MSEL_MASK);
957  tmp |= CMP_C1_MSEL(to_set);
958  baseAddr->C1 = tmp;
959 }
960 
967 static inline uint8_t CMP_HAL_GetVoltage(const CMP_Type* baseAddr)
968 {
969  uint32_t tmp = baseAddr->C1;
970  tmp = (tmp & CMP_C1_VOSEL_MASK) >> CMP_C1_VOSEL_SHIFT;
971  return ( uint8_t ) (tmp);
972 }
973 
981 static inline void CMP_HAL_SetVoltage(CMP_Type* baseAddr, uint8_t to_set)
982 {
983  uint32_t tmp = baseAddr->C1;
984  tmp &= ~(CMP_C1_VOSEL_MASK);
985  tmp |= CMP_C1_VOSEL(to_set);
986  baseAddr->C1 = tmp;
987 }
988 
997 static inline bool CMP_HAL_GetRoundRobinState(const CMP_Type* baseAddr)
998 {
999  return (bool)(((baseAddr->C2) >> CMP_C2_RRE_SHIFT) & 1U);
1000 }
1001 
1011 static inline void CMP_HAL_SetRoundRobinState(CMP_Type* baseAddr, bool to_set)
1012 {
1013  (baseAddr->C2) = ((baseAddr->C2) &(~(CMP_C2_RRE_MASK))) | ((uint32_t)to_set << CMP_C2_RRE_SHIFT);
1014 }
1015 
1024 static inline bool CMP_HAL_GetRoundRobinInterruptState(const CMP_Type* baseAddr)
1025 {
1026  return (bool)(((baseAddr->C2) >> CMP_C2_RRIE_SHIFT) & 1U);
1027 }
1028 
1038 static inline void CMP_HAL_SetRoundRobinInterruptState(CMP_Type* baseAddr, bool to_set)
1039 {
1040  (baseAddr->C2) = ((baseAddr->C2) & (~(CMP_C2_RRIE_SHIFT))) | ((uint32_t)to_set << CMP_C2_RRIE_SHIFT);
1041 }
1042 
1049 static inline cmp_fixed_port_t CMP_HAL_GetFixedPort(const CMP_Type* baseAddr)
1050 {
1051  return (cmp_fixed_port_t)(((baseAddr->C2) >> CMP_C2_FXMP_SHIFT) & 1U);
1052 }
1053 
1063 static inline void CMP_HAL_SetFixedPort(CMP_Type* baseAddr, cmp_fixed_port_t to_set)
1064 {
1065  (baseAddr->C2) = ((baseAddr->C2) & (~(CMP_C2_FXMP_MASK))) | ((uint32_t)to_set << CMP_C2_FXMP_SHIFT);
1066 }
1067 
1076 static inline cmp_ch_number_t CMP_HAL_GetFixedChannel(const CMP_Type* baseAddr)
1077 {
1078  uint32_t tmp = baseAddr->C2;
1079  tmp = (tmp & CMP_C2_FXMXCH_MASK) >> CMP_C2_FXMXCH_SHIFT;
1080  return ( cmp_ch_number_t ) (tmp);
1081 }
1082 
1090 static inline void CMP_HAL_SetFixedChannel(CMP_Type* baseAddr, cmp_ch_number_t to_set)
1091 {
1092  uint32_t tmp = baseAddr->C2;
1093  tmp &= ~(CMP_C2_FXMXCH_MASK);
1094  tmp |= CMP_C2_FXMXCH(to_set);
1095  baseAddr->C2 = tmp;
1096 }
1097 
1108 {
1109  uint32_t tmp = baseAddr->C2;
1110  tmp = (tmp & (uint32_t)CMP_INPUT_FLAGS_MASK) >> CMP_INPUT_FLAGS_SHIFT;
1111  return ( cmp_ch_list_t ) (tmp);
1112 }
1113 
1120 static inline void CMP_HAL_ClearInputChangedFlags(CMP_Type* baseAddr)
1121 {
1122  uint32_t tmp = baseAddr->C2;
1123  tmp |= (uint32_t)CMP_INPUT_FLAGS_MASK;
1124  baseAddr->C2 = tmp;
1125  #ifdef ERRATA_E9005
1126  (void)baseAddr->C2;
1127  #endif
1128 }
1129 
1136 static inline uint8_t CMP_HAL_GetRoundRobinSamplesNumber(const CMP_Type* baseAddr)
1137 {
1138  uint32_t tmp = baseAddr->C2;
1139  tmp = (tmp & CMP_C2_NSAM_MASK) >> CMP_C2_NSAM_SHIFT;
1140  return ( uint8_t ) (tmp);
1141 }
1142 
1150 static inline void CMP_HAL_SetRoundRobinSamplesNumber(CMP_Type* baseAddr, uint8_t to_set)
1151 {
1152  uint32_t tmp = baseAddr->C2;
1153  tmp &= ~(CMP_C2_NSAM_MASK);
1154  tmp |= CMP_C2_NSAM(to_set);
1155  baseAddr->C2 = tmp;
1156 }
1157 
1164 static inline uint8_t CMP_HAL_GetInitDelay(const CMP_Type* baseAddr)
1165 {
1166  uint32_t tmp = baseAddr->C2;
1167  tmp = (tmp & CMP_C2_INITMOD_MASK) >> CMP_C2_INITMOD_SHIFT;
1168  return ( uint8_t ) (tmp);
1169 }
1170 
1178 static inline void CMP_HAL_SetInitDelay(CMP_Type* baseAddr, uint8_t to_set)
1179 {
1180  uint32_t tmp = baseAddr->C2;
1181  tmp &= ~(CMP_C2_INITMOD_MASK);
1182  tmp |= CMP_C2_INITMOD(to_set);
1183  baseAddr->C2 = tmp;
1184 }
1185 
1193 {
1194  uint32_t tmp = baseAddr->C2;
1195  tmp = (tmp & CMP_C2_ACOn_MASK) >> CMP_C2_ACOn_SHIFT;
1196  return ( cmp_ch_list_t ) (tmp);
1197 }
1198 
1206 static inline void CMP_HAL_SetPresetState(CMP_Type* baseAddr, cmp_ch_list_t to_set)
1207 {
1208  uint32_t tmp = baseAddr->C2;
1209  tmp &= ~(CMP_C2_ACOn_MASK);
1210  tmp |= CMP_C2_ACOn(to_set);
1211  baseAddr->C2 = tmp;
1212 }
1213 
1215 #if defined(__cplusplus)
1216 }
1217 #endif
1218 
1221 #endif /* __CMP_HAL_H__*/
1222 /*******************************************************************************
1223  * EOF
1224  ******************************************************************************/
1225 
#define CMP_C2_INITMOD_SHIFT
Definition: S32K144.h:1926
static cmp_hysteresis_t CMP_HAL_GetHysteresis(const CMP_Type *baseAddr)
Return the current hysteresis level.
Definition: cmp_hal.h:699
#define CMP_C0_IEF_MASK
Definition: S32K144.h:1847
static void CMP_HAL_SetInitDelay(CMP_Type *baseAddr, uint8_t to_set)
Set the comparator and DAC initialization delay.
Definition: cmp_hal.h:1178
static void CMP_HAL_ClearOutputRisingFlag(CMP_Type *baseAddr)
Clear rising edge flag.
Definition: cmp_hal.h:363
static cmp_ch_number_t CMP_HAL_GetFixedChannel(const CMP_Type *baseAddr)
Return which channel is selected for fixed mux port(as fixed reference)
Definition: cmp_hal.h:1076
#define CMP_C0_WE_SHIFT
Definition: S32K144.h:1824
#define CMP_C1_INNSEL_SHIFT
Definition: S32K144.h:1913
#define CMP_C0_PMODE_MASK
Definition: S32K144.h:1819
static cmp_ch_list_t CMP_HAL_GetInputChangedFlags(const CMP_Type *baseAddr)
Return all input changed flags.
Definition: cmp_hal.h:1107
#define CMP_C2_FXMXCH(x)
Definition: S32K144.h:1968
#define CMP_C1_INPSEL_MASK
Definition: S32K144.h:1916
static void CMP_HAL_SetAnalogComparatorState(CMP_Type *baseAddr, bool to_set)
Set the analog comparator module state.
Definition: cmp_hal.h:623
#define CMP_C1_INNSEL(x)
Definition: S32K144.h:1915
#define CMP_C0_FILTER_CNT(x)
Definition: S32K144.h:1802
static void CMP_HAL_SetInverterState(CMP_Type *baseAddr, cmp_inverter_t to_set)
Configure the comparator output inverter mode.
Definition: cmp_hal.h:542
#define CMP_C0_FPR(x)
Definition: S32K144.h:1834
#define CMP_C0_INVT_SHIFT
Definition: S32K144.h:1816
#define CMP_C0_COS_MASK
Definition: S32K144.h:1811
static cmp_output_trigger_t CMP_HAL_GetOutputEvent(const CMP_Type *baseAddr)
Return type of event occurred at the comparator output.
Definition: cmp_hal.h:317
#define CMP_C1_VOSEL_MASK
Definition: S32K144.h:1860
static void CMP_HAL_SetFilterSamplePeriod(CMP_Type *baseAddr, uint8_t to_set)
Set the filter sample period(clock cycles)
Definition: cmp_hal.h:431
#define CMP_C0_SE_SHIFT
Definition: S32K144.h:1828
#define CMP_INPUT_FLAGS_SHIFT
Definition: cmp_hal.h:57
static void CMP_HAL_SetOutputInterruptTrigger(CMP_Type *baseAddr, cmp_output_trigger_t to_set)
Set the comparator output interrupts source configuration(none, rising edge, falling edge or both edg...
Definition: cmp_hal.h:299
static void CMP_HAL_SetVoltageReference(CMP_Type *baseAddr, cmp_voltage_reference_t to_set)
Set the voltage reference.
Definition: cmp_hal.h:900
cmp_power_mode_t
Power Modes selection Implements : cmp_power_mode_t_Class.
Definition: cmp_hal.h:67
#define CMP_C2_RRIE_SHIFT
Definition: S32K144.h:1974
#define CMP_C1_INPSEL_SHIFT
Definition: S32K144.h:1917
#define CMP_C2_FXMP_SHIFT
Definition: S32K144.h:1970
static void CMP_HAL_SetComparatorOutputSource(CMP_Type *baseAddr, cmp_output_select_t to_set)
Select the comparator output signal source.
Definition: cmp_hal.h:569
#define CMP_C2_ACOn_MASK
Definition: S32K144.h:1921
#define CMP_C2_NSAM(x)
Definition: S32K144.h:1932
static void CMP_HAL_SetDMATriggerState(CMP_Type *baseAddr, bool to_set)
Configure the DMA transfer trigger.
Definition: cmp_hal.h:266
static void CMP_HAL_SetPositivePortInput(CMP_Type *baseAddr, cmp_port_mux_t to_set)
Set the source for positive port of the comparator.
Definition: cmp_hal.h:777
cmp_port_mux_t
Port Mux Source selection Implements : cmp_port_mux_t_Class.
Definition: cmp_hal.h:85
#define CMP_C1_PSEL_MASK
Definition: S32K144.h:1868
cmp_output_trigger_t
Comparator output interrupt configuration Implements : cmp_output_trigger_t_Class.
Definition: cmp_hal.h:150
#define CMP_C0_IER(x)
Definition: S32K144.h:1854
static void CMP_HAL_SetDACState(CMP_Type *baseAddr, bool to_set)
Set the DAC state (enabled/disabled)
Definition: cmp_hal.h:873
#define CMP_C0_FILTER_CNT_MASK
Definition: S32K144.h:1799
#define CMP_C0_FPR_SHIFT
Definition: S32K144.h:1832
#define CMP_C1_MSEL(x)
Definition: S32K144.h:1867
#define CMP_C0_WE_MASK
Definition: S32K144.h:1823
#define CMP_ROUND_ROBIN_CHANNELS_MASK
Definition: cmp_hal.h:58
static cmp_ch_number_t CMP_HAL_GetMinusMUXControl(const CMP_Type *baseAddr)
Determine which input is selected for the minus mux.
Definition: cmp_hal.h:939
#define CMP_C2_FXMXCH_SHIFT
Definition: S32K144.h:1966
static void CMP_HAL_SetRoundRobinState(CMP_Type *baseAddr, bool to_set)
Set the round robin operation state.
Definition: cmp_hal.h:1011
#define CMP_C1_DACEN_MASK
Definition: S32K144.h:1876
static void CMP_HAL_ClearOutputEvent(CMP_Type *baseAddr)
Clear all output flags.
Definition: cmp_hal.h:330
void CMP_HAL_SetFunctionalMode(CMP_Type *baseAddr, cmp_mode_t mode, uint8_t filter_sample_count, uint8_t filter_sample_period)
Sets the comparator functional mode (mode, filter count, filter period)
Definition: cmp_hal.c:81
__IO uint32_t C1
Definition: S32K144.h:1757
#define CMP_C1_PSEL(x)
Definition: S32K144.h:1871
#define CMP_C0_EN_MASK
Definition: S32K144.h:1803
static void CMP_HAL_SetPowerMode(CMP_Type *baseAddr, cmp_power_mode_t to_set)
Set the power mode.
Definition: cmp_hal.h:515
static uint8_t CMP_HAL_GetVoltage(const CMP_Type *baseAddr)
Return the current output voltage level(0-255)
Definition: cmp_hal.h:967
static void CMP_HAL_SetVoltage(CMP_Type *baseAddr, uint8_t to_set)
Set the output voltage level.
Definition: cmp_hal.h:981
cmp_mode_t CMP_HAL_GetFunctionalMode(const CMP_Type *baseAddr)
Gets the comparator functional mode. If you want to get filter count and filter period please use CMP...
Definition: cmp_hal.c:150
static cmp_voltage_reference_t CMP_HAL_GetVoltageReference(const CMP_Type *baseAddr)
Return the current voltage reference.
Definition: cmp_hal.h:886
static bool CMP_HAL_GetOutputRisingFlag(const CMP_Type *baseAddr)
Verify if a rising edge occurred on COUT.
Definition: cmp_hal.h:352
static bool CMP_HAL_GetWindowingModeState(const CMP_Type *baseAddr)
Definition: cmp_hal.h:475
#define CMP_C0_CFR(x)
Definition: S32K144.h:1846
#define CMP_C1_PSEL_SHIFT
Definition: S32K144.h:1869
#define CMP_C0_IEF(x)
Definition: S32K144.h:1850
uint8_t cmp_ch_list_t
Comparator channels list (1bit/channel) |------—|------—|--—|------—|------—| |CH7_state|CH6_sta...
Definition: cmp_hal.h:180
static bool CMP_HAL_GetComparatorOutput(const CMP_Type *baseAddr)
Return the analog comparator output value.
Definition: cmp_hal.h:406
static cmp_offset_t CMP_HAL_GetOffset(const CMP_Type *baseAddr)
Return the current offset level.
Definition: cmp_hal.h:667
#define CMP_C2_FXMXCH_MASK
Definition: S32K144.h:1965
static cmp_ch_list_t CMP_HAL_GetRoundRobinChannels(const CMP_Type *baseAddr)
Return which channels are used for round-robin checker.
Definition: cmp_hal.h:826
static cmp_output_enable_t CMP_HAL_GetOutputPinState(const CMP_Type *baseAddr)
Verify if the comparator output state(available/not available in a packaged pin)
Definition: cmp_hal.h:582
static void CMP_HAL_SetPresetState(CMP_Type *baseAddr, cmp_ch_list_t to_set)
Defines the pre-set state of input channels.
Definition: cmp_hal.h:1206
#define CMP_C0_HYSTCTR_MASK
Definition: S32K144.h:1791
#define CMP_C0_FPR_MASK
Definition: S32K144.h:1831
uint8_t cmp_ch_number_t
Number of channel Implements : cmp_ch_number_t_Class.
Definition: cmp_hal.h:185
static bool CMP_HAL_GetDACOutputState(const CMP_Type *baseAddr)
Get if the DAC output is enabled to go outside of this block.
Definition: cmp_hal.h:748
static cmp_inverter_t CMP_HAL_GetInverterState(const CMP_Type *baseAddr)
Return the current comparator output inverter.
Definition: cmp_hal.h:528
#define CMP_C0_EN_SHIFT
Definition: S32K144.h:1804
#define CMP_C0_HYSTCTR(x)
Definition: S32K144.h:1794
#define CMP_C0_SE_MASK
Definition: S32K144.h:1827
static cmp_port_mux_t CMP_HAL_GetNegativePortInput(const CMP_Type *baseAddr)
Return the current source for negative port of the comparator.
Definition: cmp_hal.h:793
#define CMP_C0_IER_MASK
Definition: S32K144.h:1851
#define CMP_C1_INPSEL(x)
Definition: S32K144.h:1919
static void CMP_HAL_ClearInputChangedFlags(CMP_Type *baseAddr)
Clear all input changed flags.
Definition: cmp_hal.h:1120
#define CMP_C2_RRE_SHIFT
Definition: S32K144.h:1978
static cmp_ch_list_t CMP_HAL_GetLastComparisonResult(const CMP_Type *baseAddr)
Return last input comparison results for all channels.
Definition: cmp_hal.h:1192
static uint8_t CMP_HAL_GetInitDelay(const CMP_Type *baseAddr)
Return the comparator and DAC initialization delay.
Definition: cmp_hal.h:1164
static cmp_port_mux_t CMP_HAL_GetPositivePortInput(const CMP_Type *baseAddr)
Return the current source for positive port of the comparator.
Definition: cmp_hal.h:761
static void CMP_HAL_SetSamplingState(CMP_Type *baseAddr, bool to_set)
Set the sampling mode state.
Definition: cmp_hal.h:462
static void CMP_HAL_SetOffset(CMP_Type *baseAddr, cmp_offset_t to_set)
Set the offset level.
Definition: cmp_hal.h:681
static void CMP_HAL_SetFixedChannel(CMP_Type *baseAddr, cmp_ch_number_t to_set)
Set which channel is used as the fixed reference input for the fixed mux port.
Definition: cmp_hal.h:1090
#define CMP_C0_FILTER_CNT_SHIFT
Definition: S32K144.h:1800
static uint8_t CMP_HAL_GetFilterSamplePeriod(const CMP_Type *baseAddr)
Return the sample period for filter(clock cycles)
Definition: cmp_hal.h:417
#define CMP_C2_INITMOD_MASK
Definition: S32K144.h:1925
#define CMP_C0_CFF_SHIFT
Definition: S32K144.h:1840
#define CMP_C0_OFFSET_SHIFT
Definition: S32K144.h:1796
#define CMP_C0_DMAEN_SHIFT
Definition: S32K144.h:1856
#define CMP_C2_ACOn_SHIFT
Definition: S32K144.h:1922
cmp_offset_t
Comparator hard block offset control Implements : cmp_offset_t_Class.
Definition: cmp_hal.h:121
#define CMP_C0_CFR_SHIFT
Definition: S32K144.h:1844
cmp_output_enable_t
Comparator output pin enable selection Implements : cmp_output_enable_t_Class.
Definition: cmp_hal.h:112
#define CMP_INPUT_FLAGS_MASK
Definition: cmp_hal.h:56
static bool CMP_HAL_GetDMATriggerState(const CMP_Type *baseAddr)
Verify if the DMA transfer trigger is enabled.
Definition: cmp_hal.h:252
static uint8_t CMP_HAL_GetFilterSampleCount(const CMP_Type *baseAddr)
Return the number of consecutive samples that must agree prior to the comparator output filter accept...
Definition: cmp_hal.h:635
#define CMP_C1_VOSEL_SHIFT
Definition: S32K144.h:1861
cmp_mode_t
Comparator functional modes Implements : cmp_mode_t_Class.
Definition: cmp_hal.h:161
#define CMP_C0_COS_SHIFT
Definition: S32K144.h:1812
#define CMP_C2_NSAM_SHIFT
Definition: S32K144.h:1930
#define CMP_C1_MSEL_MASK
Definition: S32K144.h:1864
static void CMP_HAL_SetRoundRobinSamplesNumber(CMP_Type *baseAddr, uint8_t to_set)
Set how many round-robin clock cycles takes sampling.
Definition: cmp_hal.h:1150
static cmp_output_trigger_t CMP_HAL_GetOutputInterruptTrigger(const CMP_Type *baseAddr)
Return the comparator output interrupts source configuration(none, rising edge, falling edge or both ...
Definition: cmp_hal.h:281
#define CMP_C2_ACOn(x)
Definition: S32K144.h:1924
static cmp_power_mode_t CMP_HAL_GetPowerMode(const CMP_Type *baseAddr)
Return the current power mode.
Definition: cmp_hal.h:502
static void CMP_HAL_SetRoundRobinChannels(CMP_Type *baseAddr, cmp_ch_list_t to_set)
Set which channels are use for round-robin checker.
Definition: cmp_hal.h:843
#define CMP_C1_VOSEL(x)
Definition: S32K144.h:1863
#define CMP_ROUND_ROBIN_CHANNELS_SHIFT
Definition: cmp_hal.h:59
#define CMP_C0_DMAEN_MASK
Definition: S32K144.h:1855
cmp_hysteresis_t
Comparator hysteresis control Implements : cmp_hysteresis_t_Class.
Definition: cmp_hal.h:130
static uint8_t CMP_HAL_GetRoundRobinSamplesNumber(const CMP_Type *baseAddr)
Return how many round-robin clock cycles takes sampling.
Definition: cmp_hal.h:1136
#define CMP_C2_NSAM_MASK
Definition: S32K144.h:1929
void CMP_HAL_Init(CMP_Type *baseAddr)
Initializes the comparator registers with reset values.
Definition: cmp_hal.c:42
static void CMP_HAL_ClearOutputFallingFlag(CMP_Type *baseAddr)
Clear falling edge flag.
Definition: cmp_hal.h:391
static void CMP_HAL_SetMinusMUXControl(CMP_Type *baseAddr, cmp_ch_number_t to_set)
Select input for the minus mux.
Definition: cmp_hal.h:953
static bool CMP_HAL_GetSamplingState(const CMP_Type *baseAddr)
Verify if the sampling mode is selected.
Definition: cmp_hal.h:448
#define CMP_C2_RRE_MASK
Definition: S32K144.h:1977
#define CMP_C0_CFR_MASK
Definition: S32K144.h:1843
cmp_inverter_t
Comparator output invert selection Implements : cmp_inverter_t_Class.
Definition: cmp_hal.h:94
static void CMP_HAL_SetRoundRobinInterruptState(CMP_Type *baseAddr, bool to_set)
Set the round robin interrupt state.
Definition: cmp_hal.h:1038
static void CMP_HAL_SetOutputPinState(CMP_Type *baseAddr, cmp_output_enable_t to_set)
Set the comparator output pin state(available/not available in a packaged pin)
Definition: cmp_hal.h:596
static void CMP_HAL_SetWindowingModeState(CMP_Type *baseAddr, bool to_set)
Set the windowing mode state.
Definition: cmp_hal.h:489
#define CMP_C0_IER_SHIFT
Definition: S32K144.h:1852
#define CMP_C2_FXMP_MASK
Definition: S32K144.h:1969
static void CMP_HAL_SetDACOutputState(CMP_Type *baseAddr, bool to_set)
Set if the DAC output is enabled to go outside of this block.
Definition: cmp_hal.h:734
static void CMP_HAL_SetPlusMuxControl(CMP_Type *baseAddr, cmp_ch_number_t to_set)
Select input for the plus mux.
Definition: cmp_hal.h:925
static cmp_ch_number_t CMP_HAL_GetPlusMUXControl(const CMP_Type *baseAddr)
Determine which input is selected for the plus mux.
Definition: cmp_hal.h:911
#define CMP_C2_INITMOD(x)
Definition: S32K144.h:1928
#define CMP_C0_OFFSET(x)
Definition: S32K144.h:1798
static void CMP_HAL_SetFilterSampleCount(CMP_Type *baseAddr, uint8_t to_set)
Set the number of consecutive samples that must agree prior to the comparator output filter accepting...
Definition: cmp_hal.h:650
static void CMP_HAL_SetHysteresis(CMP_Type *baseAddr, cmp_hysteresis_t to_set)
Set the hysteresis level.
Definition: cmp_hal.h:717
static bool CMP_HAL_GetAnalogComparatorState(const CMP_Type *baseAddr)
Verify if the analog comparator module is enabled.
Definition: cmp_hal.h:610
#define CMP_C0_OPE_MASK
Definition: S32K144.h:1807
__IO uint32_t C0
Definition: S32K144.h:1756
static void CMP_HAL_SetNegativePortInput(CMP_Type *baseAddr, cmp_port_mux_t to_set)
Set the source for negative port of the comparator.
Definition: cmp_hal.h:809
static void CMP_HAL_SetFixedPort(CMP_Type *baseAddr, cmp_fixed_port_t to_set)
Set the fixed port for round-robin operation.
Definition: cmp_hal.h:1063
#define CMP_C0_CFF_MASK
Definition: S32K144.h:1839
#define CMP_C0_OPE_SHIFT
Definition: S32K144.h:1808
static cmp_fixed_port_t CMP_HAL_GetFixedPort(const CMP_Type *baseAddr)
Return the port fixed for round-robin operation.
Definition: cmp_hal.h:1049
#define CMP_C0_CFF(x)
Definition: S32K144.h:1842
cmp_fixed_port_t
Comparator Round-Robin fixed port Implements : cmp_fixed_port_t_Class.
Definition: cmp_hal.h:141
__IO uint32_t C2
Definition: S32K144.h:1758
#define CMP_C1_MSEL_SHIFT
Definition: S32K144.h:1865
#define CMP_C0_IEF_SHIFT
Definition: S32K144.h:1848
static bool CMP_HAL_GetOutputFallingFlag(const CMP_Type *baseAddr)
Verify if a falling-edge occurred on COUT.
Definition: cmp_hal.h:380
#define CMP_C1_INNSEL_MASK
Definition: S32K144.h:1912
static cmp_output_select_t CMP_HAL_GetComparatorOutputSource(const CMP_Type *baseAddr)
Return the current comparator output selected.
Definition: cmp_hal.h:555
cmp_voltage_reference_t
Voltage Reference selection Implements : cmp_voltage_reference_t_Class.
Definition: cmp_hal.h:76
#define CMP_C0_PMODE_SHIFT
Definition: S32K144.h:1820
static bool CMP_HAL_GetRoundRobinState(const CMP_Type *baseAddr)
Verify if the round robin operation is enabled.
Definition: cmp_hal.h:997
#define CMP_C1_VRSEL_SHIFT
Definition: S32K144.h:1873
static bool CMP_HAL_GetRoundRobinInterruptState(const CMP_Type *baseAddr)
Verify if the round robin interrupt is enabled.
Definition: cmp_hal.h:1024
#define CMP_C0_COUT_SHIFT
Definition: S32K144.h:1836
#define CMP_C0_OFFSET_MASK
Definition: S32K144.h:1795
#define CMP_C0_HYSTCTR_SHIFT
Definition: S32K144.h:1792
cmp_output_select_t
Comparator output select selection Implements : cmp_output_select_t_Class.
Definition: cmp_hal.h:103
#define CMP_C1_DACEN_SHIFT
Definition: S32K144.h:1877
static bool CMP_HAL_GetDACState(const CMP_Type *baseAddr)
Verify if the DAC is enabled.
Definition: cmp_hal.h:859
#define CMP_C0_INVT_MASK
Definition: S32K144.h:1815