42#ifndef _G32R4XX_DDL_COMP_H__
43#define _G32R4XX_DDL_COMP_H__
56#if defined (COMP1) || defined (COMP2) || defined (COMP3) || defined (COMP4)
67#if defined(USE_FULL_DDL_DRIVER)
112#define DDL_COMP_INPUT_PLUS_INP0 (0x00000000UL)
113#define DDL_COMP_INPUT_PLUS_INP1 (COMP_CSTS_VP_SEL_0)
114#define DDL_COMP_INPUT_PLUS_DAC2 (COMP_CSTS_VP_SEL_1)
115#define DDL_COMP_INPUT_PLUS_DAC1 (COMP_CSTS_VP_SEL_1)
124#define DDL_COMP_INPUT_MINUS_INN0 (0x00000000UL)
125#define DDL_COMP_INPUT_MINUS_INN1 (COMP_CSTS_VN_SEL_0)
126#define DDL_COMP_INPUT_MINUS_DAC2 (COMP_CSTS_VN_SEL_1)
127#define DDL_COMP_INPUT_MINUS_DAC1 (COMP_CSTS_VN_SEL_1)
136#define DDL_COMP_OUTPUTPOL_NONINVERTED (0x00000000UL)
137#define DDL_COMP_OUTPUTPOL_INVERTED (COMP_CSTS_POL)
145#define DDL_COMP_HYS_DISABLE (0x00000000UL)
147#define DDL_COMP_HYS_LEVEL0 (COMP_CSTS_HYS_0)
148#define DDL_COMP_HYS_LEVEL1 (COMP_CSTS_HYS_1)
149#define DDL_COMP_HYS_LEVEL2 (COMP_CSTS_HYS_1 | COMP_CSTS_HYS_0)
157#define DDL_COMP_BLANK_0 (0x00000000UL)
158#define DDL_COMP_BLANK_1 (COMP_CSTS_BLANKSEL_0)
159#define DDL_COMP_BLANK_2 (COMP_CSTS_BLANKSEL_1)
160#define DDL_COMP_BLANK_3 (COMP_CSTS_BLANKSEL_0 | COMP_CSTS_BLANKSEL_1)
161#define DDL_COMP_BLANK_4 (COMP_CSTS_BLANKSEL_2)
162#define DDL_COMP_BLANK_6 (COMP_CSTS_BLANKSEL_2 | COMP_CSTS_BLANKSEL_1)
163#define DDL_COMP_BLANK_7 (COMP_CSTS_BLANKSEL)
171#define DDL_COMP_OUTPUT_SEL_NONE (0x00000000UL)
172#define DDL_COMP_OUTPUT_SEL_TMR1_BKIN (COMP_CSTS_TMR_SEL_0)
173#define DDL_COMP_OUTPUT_SEL_TMR1_IC1 (COMP_CSTS_TMR_SEL_1)
174#define DDL_COMP_OUTPUT_SEL_TMR1_IC2 (COMP_CSTS_TMR_SEL_1 | COMP_CSTS_TMR_SEL_0)
175#define DDL_COMP_OUTPUT_SEL_TMR1_ETR (COMP_CSTS_TMR_SEL_2)
176#define DDL_COMP_OUTPUT_SEL_TMR2_IC1 (COMP_CSTS_TMR_SEL_2 | COMP_CSTS_TMR_SEL_0)
177#define DDL_COMP_OUTPUT_SEL_TMR2_IC2 (COMP_CSTS_TMR_SEL_2 | COMP_CSTS_TMR_SEL_1)
178#define DDL_COMP_OUTPUT_SEL_TMR2_IC3 (COMP_CSTS_TMR_SEL_2 | COMP_CSTS_TMR_SEL_1 | COMP_CSTS_TMR_SEL_0)
179#define DDL_COMP_OUTPUT_SEL_TMR2_IC4 (COMP_CSTS_TMR_SEL_3)
180#define DDL_COMP_OUTPUT_SEL_TMR2_ETR (COMP_CSTS_TMR_SEL_3 | COMP_CSTS_TMR_SEL_0)
181#define DDL_COMP_OUTPUT_SEL_TMR3_IC1 (COMP_CSTS_TMR_SEL_3 | COMP_CSTS_TMR_SEL_1)
182#define DDL_COMP_OUTPUT_SEL_TMR3_IC2 (COMP_CSTS_TMR_SEL_3 | COMP_CSTS_TMR_SEL_1 | COMP_CSTS_TMR_SEL_0)
183#define DDL_COMP_OUTPUT_SEL_TMR3_ETR (COMP_CSTS_TMR_SEL_3 | COMP_CSTS_TMR_SEL_2)
184#define DDL_COMP_OUTPUT_SEL_TMR4_IC1 (COMP_CSTS_TMR_SEL_3 | COMP_CSTS_TMR_SEL_2 | COMP_CSTS_TMR_SEL_0)
185#define DDL_COMP_OUTPUT_SEL_TMR4_IC2 (COMP_CSTS_TMR_SEL_3 | COMP_CSTS_TMR_SEL_2 | COMP_CSTS_TMR_SEL_1)
186#define DDL_COMP_OUTPUT_SEL_TMR4_ETR (COMP_CSTS_TMR_SEL)
194#define DDL_COMP_OUTPUT_LEVEL_LOW (0x00000000UL)
195#define DDL_COMP_OUTPUT_LEVEL_HIGH (COMP_CSTS_OUTVAL)
203#define DDL_COMP_FILTER_NONE (0x00000000UL)
204#define DDL_COMP_FILTER_2HSICLK (COMP_CSTS_FILTER_0)
205#define DDL_COMP_FILTER_4HSICLK (COMP_CSTS_FILTER_1)
206#define DDL_COMP_FILTER_6HSICLK (COMP_CSTS_FILTER_1 | COMP_CSTS_FILTER_0)
207#define DDL_COMP_FILTER_12HSICLK (COMP_CSTS_FILTER_2)
208#define DDL_COMP_FILTER_18HSICLK (COMP_CSTS_FILTER_2 | COMP_CSTS_FILTER_0)
209#define DDL_COMP_FILTER_24HSICLK (COMP_CSTS_FILTER_2 | COMP_CSTS_FILTER_1)
210#define DDL_COMP_FILTER_30HSICLK (COMP_CSTS_FILTER)
220#define DDL_COMP_DELAY_STARTUP_US (80UL)
244#define DDL_COMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
252#define DDL_COMP_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
282 MODIFY_REG(COMPx->CxCSR, COMP_CSTS_HYS, Hysteresis);
296 return (uint32_t)READ_BIT(COMPx->CxCSR, COMP_CSTS_HYS);
315 MODIFY_REG(COMPx->CxCSR, COMP_CSTS_BLANKSEL, Blank);
332 return (uint32_t)(READ_BIT(COMPx->CxCSR, COMP_CSTS_BLANKSEL));
359 MODIFY_REG(COMPx->CxCSR, COMP_CSTS_VP_SEL, InputPlus);
372 return (uint32_t)(READ_BIT(COMPx->CxCSR, COMP_CSTS_VP_SEL));
392 MODIFY_REG(COMPx->CxCSR, COMP_CSTS_VN_SEL, InputMinus);
405 return (uint32_t)(READ_BIT(COMPx->CxCSR, COMP_CSTS_VN_SEL));
440 MODIFY_REG(COMPx->CxCSR, COMP_CSTS_TMR_SEL, OutputSel);
465 return (uint32_t)(READ_BIT(COMPx->CxCSR, COMP_CSTS_TMR_SEL));
479 MODIFY_REG(COMPx->CxCSR, COMP_CSTS_POL, OutputPol);
491 return (uint32_t)(READ_BIT(COMPx->CxCSR, COMP_CSTS_POL));
510 SET_BIT(COMPx->CxCSR, COMP_CSTS_EN);
520 CLEAR_BIT(COMPx->CxCSR, COMP_CSTS_EN);
532 return ((READ_BIT(COMPx->CxCSR, COMP_CSTS_EN) == (COMP_CSTS_EN)) ? 1UL : 0UL);
544 SET_BIT(COMPx->CxCSR, COMP_CSTS_LOCK);
556 return ((READ_BIT(COMPx->CxCSR, COMP_CSTS_LOCK) == (COMP_CSTS_LOCK)) ? 1UL : 0UL);
575 return((READ_BIT(COMPx->CxCSR, COMP_CSTS_OUTVAL) == (COMP_CSTS_OUTVAL)) ? 1UL : 0UL);
602 MODIFY_REG(COMPx->CxCSR, COMP_CSTS_FILTER, Filter);
620 return (uint32_t)(READ_BIT(COMPx->CxCSR, COMP_CSTS_FILTER));
627#if defined(USE_FULL_DDL_DRIVER)
__STATIC_INLINE uint32_t DDL_COMP_GetHysteresis(COMP_TypeDef *COMPx)
Get comparator hysteresis.
__STATIC_INLINE uint32_t DDL_COMP_GetOutputBlank(COMP_TypeDef *COMPx)
Get comparator output blank.
__STATIC_INLINE void DDL_COMP_SetHysteresis(COMP_TypeDef *COMPx, uint32_t Hysteresis)
Select comparator hysteresis.
__STATIC_INLINE void DDL_COMP_SetOutputBlank(COMP_TypeDef *COMPx, uint32_t Blank)
Set comparator output blank.
__STATIC_INLINE uint32_t DDL_COMP_GetOutputPolarity(COMP_TypeDef *COMPx)
Get comparator output polarity.
__STATIC_INLINE void DDL_COMP_SetOutputSelect(COMP_TypeDef *COMPx, uint32_t OutputSel)
Set comparator output select.
__STATIC_INLINE uint32_t DDL_COMP_GetOutputSelect(COMP_TypeDef *COMPx)
Set comparator output select.
__STATIC_INLINE void DDL_COMP_SetOutputPolarity(COMP_TypeDef *COMPx, uint32_t OutputPol)
Set comparator output polarity.
__STATIC_INLINE void DDL_COMP_SetFilter(COMP_TypeDef *COMPx, uint32_t Filter)
Set comparator filter.
__STATIC_INLINE uint32_t DDL_COMP_GetFilter(COMP_TypeDef *COMPx)
Get comparator filter.
ErrorStatus DDL_COMP_DeInit(COMP_TypeDef *COMPx)
De-Initialize COMP function.
ErrorStatus DDL_COMP_Init(COMP_TypeDef *COMPx, DDL_COMP_InitTypeDef *COMP_InitStruct)
Initialize COMP function.
void DDL_COMP_StructInit(DDL_COMP_InitTypeDef *COMP_InitStruct)
Set the fields of structure COMP_InitStruct to default values.
__STATIC_INLINE uint32_t DDL_COMP_IsLocked(COMP_TypeDef *COMPx)
Get comparator lock state.
__STATIC_INLINE void DDL_COMP_Lock(COMP_TypeDef *COMPx)
Lock comparator instance.
__STATIC_INLINE void DDL_COMP_Disable(COMP_TypeDef *COMPx)
Disable comparator instance.
__STATIC_INLINE uint32_t DDL_COMP_ReadOutputLevel(COMP_TypeDef *COMPx)
Read comparator output level.
__STATIC_INLINE void DDL_COMP_Enable(COMP_TypeDef *COMPx)
Enable comparator instance.
__STATIC_INLINE uint32_t DDL_COMP_IsEnabled(COMP_TypeDef *COMPx)
Get comparator enable state.
COMP Init structure definition.