G32R430 Device Driver Layer v1.0.4
G32R4xx Device Driver Layer API Reference
g32r4xx_ddl_comp.h
Go to the documentation of this file.
1
40
41/* Define to prevent recursive inclusion -------------------------------------*/
42#ifndef _G32R4XX_DDL_COMP_H__
43#define _G32R4XX_DDL_COMP_H__
44
45#ifdef __cplusplus
46 extern "C" {
47#endif
48
49/* Includes ------------------------------------------------------------------*/
50#include "g32r4xx.h"
51
55
56#if defined (COMP1) || defined (COMP2) || defined (COMP3) || defined (COMP4)
57
61
62/* Private types -------------------------------------------------------------*/
63/* Private variables ---------------------------------------------------------*/
64/* Private constants ---------------------------------------------------------*/
65/* Private macros ------------------------------------------------------------*/
66/* Exported types ------------------------------------------------------------*/
67#if defined(USE_FULL_DDL_DRIVER)
71
75typedef struct
76{
77 uint32_t InputPlus;
82
83 uint32_t InputMinus;
87
88 uint32_t OutputPol;
92
93 uint32_t OutputBlank;
98
102#endif /* USE_FULL_DDL_DRIVER */
103
104/* Exported constants --------------------------------------------------------*/
108
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)
116
120
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)
128
132
136#define DDL_COMP_OUTPUTPOL_NONINVERTED (0x00000000UL)
137#define DDL_COMP_OUTPUTPOL_INVERTED (COMP_CSTS_POL)
141
145#define DDL_COMP_HYS_DISABLE (0x00000000UL)
146
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)
153
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)
167
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)
190
194#define DDL_COMP_OUTPUT_LEVEL_LOW (0x00000000UL)
195#define DDL_COMP_OUTPUT_LEVEL_HIGH (COMP_CSTS_OUTVAL)
199
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)
214
218
219/* Delay for comparator startup time */
220#define DDL_COMP_DELAY_STARTUP_US (80UL)
224
228
229/* Exported macro ------------------------------------------------------------*/
236
244#define DDL_COMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
245
252#define DDL_COMP_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
256
260
261/* Exported functions --------------------------------------------------------*/
265
269
280__STATIC_INLINE void DDL_COMP_SetHysteresis(COMP_TypeDef *COMPx, uint32_t Hysteresis)
281{
282 MODIFY_REG(COMPx->CxCSR, COMP_CSTS_HYS, Hysteresis);
283}
284
294__STATIC_INLINE uint32_t DDL_COMP_GetHysteresis(COMP_TypeDef *COMPx)
295{
296 return (uint32_t)READ_BIT(COMPx->CxCSR, COMP_CSTS_HYS);
297}
298
312__STATIC_INLINE void DDL_COMP_SetOutputBlank(COMP_TypeDef *COMPx,
313 uint32_t Blank)
314{
315 MODIFY_REG(COMPx->CxCSR, COMP_CSTS_BLANKSEL, Blank);
316}
317
330__STATIC_INLINE uint32_t DDL_COMP_GetOutputBlank(COMP_TypeDef *COMPx)
331{
332 return (uint32_t)(READ_BIT(COMPx->CxCSR, COMP_CSTS_BLANKSEL));
333}
334
338
342
356__STATIC_INLINE void DDL_COMP_SetInputPlus(COMP_TypeDef *COMPx,
357 uint32_t InputPlus)
358{
359 MODIFY_REG(COMPx->CxCSR, COMP_CSTS_VP_SEL, InputPlus);
360}
361
370__STATIC_INLINE uint32_t DDL_COMP_GetInputPlus(COMP_TypeDef *COMPx)
371{
372 return (uint32_t)(READ_BIT(COMPx->CxCSR, COMP_CSTS_VP_SEL));
373}
374
388__STATIC_INLINE void DDL_COMP_SetInputMinus(COMP_TypeDef *COMPx,
389 uint32_t InputMinus)
390{
391 /* Note: Input minus is available only for COMP1 and COMP2. */
392 MODIFY_REG(COMPx->CxCSR, COMP_CSTS_VN_SEL, InputMinus);
393}
394
403__STATIC_INLINE uint32_t DDL_COMP_GetInputMinus(COMP_TypeDef *COMPx)
404{
405 return (uint32_t)(READ_BIT(COMPx->CxCSR, COMP_CSTS_VN_SEL));
406}
407
411
415
437__STATIC_INLINE void DDL_COMP_SetOutputSelect(COMP_TypeDef *COMPx,
438 uint32_t OutputSel)
439{
440 MODIFY_REG(COMPx->CxCSR, COMP_CSTS_TMR_SEL, OutputSel);
441}
442
463__STATIC_INLINE uint32_t DDL_COMP_GetOutputSelect(COMP_TypeDef *COMPx)
464{
465 return (uint32_t)(READ_BIT(COMPx->CxCSR, COMP_CSTS_TMR_SEL));
466}
467
476__STATIC_INLINE void DDL_COMP_SetOutputPolarity(COMP_TypeDef *COMPx,
477 uint32_t OutputPol)
478{
479 MODIFY_REG(COMPx->CxCSR, COMP_CSTS_POL, OutputPol);
480}
481
489__STATIC_INLINE uint32_t DDL_COMP_GetOutputPolarity(COMP_TypeDef *COMPx)
490{
491 return (uint32_t)(READ_BIT(COMPx->CxCSR, COMP_CSTS_POL));
492}
493
497
501
508__STATIC_INLINE void DDL_COMP_Enable(COMP_TypeDef *COMPx)
509{
510 SET_BIT(COMPx->CxCSR, COMP_CSTS_EN);
511}
512
518__STATIC_INLINE void DDL_COMP_Disable(COMP_TypeDef *COMPx)
519{
520 CLEAR_BIT(COMPx->CxCSR, COMP_CSTS_EN);
521}
522
530__STATIC_INLINE uint32_t DDL_COMP_IsEnabled(COMP_TypeDef *COMPx)
531{
532 return ((READ_BIT(COMPx->CxCSR, COMP_CSTS_EN) == (COMP_CSTS_EN)) ? 1UL : 0UL);
533}
534
542__STATIC_INLINE void DDL_COMP_Lock(COMP_TypeDef *COMPx)
543{
544 SET_BIT(COMPx->CxCSR, COMP_CSTS_LOCK);
545}
546
554__STATIC_INLINE uint32_t DDL_COMP_IsLocked(COMP_TypeDef *COMPx)
555{
556 return ((READ_BIT(COMPx->CxCSR, COMP_CSTS_LOCK) == (COMP_CSTS_LOCK)) ? 1UL : 0UL);
557}
558
573__STATIC_INLINE uint32_t DDL_COMP_ReadOutputLevel(COMP_TypeDef *COMPx)
574{
575 return((READ_BIT(COMPx->CxCSR, COMP_CSTS_OUTVAL) == (COMP_CSTS_OUTVAL)) ? 1UL : 0UL);
576}
577
581
585
600__STATIC_INLINE void DDL_COMP_SetFilter(COMP_TypeDef *COMPx, uint32_t Filter)
601{
602 MODIFY_REG(COMPx->CxCSR, COMP_CSTS_FILTER, Filter);
603}
604
618__STATIC_INLINE uint32_t DDL_COMP_GetFilter(COMP_TypeDef *COMPx)
619{
620 return (uint32_t)(READ_BIT(COMPx->CxCSR, COMP_CSTS_FILTER));
621}
622
626
627#if defined(USE_FULL_DDL_DRIVER)
631
632ErrorStatus DDL_COMP_Init(COMP_TypeDef *COMPx, DDL_COMP_InitTypeDef *COMP_InitStruct);
633ErrorStatus DDL_COMP_DeInit(COMP_TypeDef *COMPx);
634void DDL_COMP_StructInit(DDL_COMP_InitTypeDef *COMP_InitStruct);
635
639#endif /* USE_FULL_DDL_DRIVER */
640
644
648
649#endif /* COMP1 || COMP2 || COMP3 || COMP4 */
650
654
655#ifdef __cplusplus
656}
657#endif
658
659#endif /* _G32R4XX_DDL_COMP_H__ */
660
__STATIC_INLINE uint32_t DDL_COMP_GetInputPlus(COMP_TypeDef *COMPx)
Get comparator input plus.
__STATIC_INLINE void DDL_COMP_SetInputMinus(COMP_TypeDef *COMPx, uint32_t InputMinus)
Set comparator input minus.
__STATIC_INLINE void DDL_COMP_SetInputPlus(COMP_TypeDef *COMPx, uint32_t InputPlus)
Set comparator input plus.
__STATIC_INLINE uint32_t DDL_COMP_GetInputMinus(COMP_TypeDef *COMPx)
Get comparator input minus.
__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.