rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions | Variables
COMP

Data Structures

struct  COMPConfig
 Driver configuration structure. More...
 
struct  COMPDriver
 Structure representing an COMP driver. More...
 

Enumerations

enum  comp_output_mode_t { COMP_OUTPUT_NORMAL = 0 , COMP_OUTPUT_INVERTED = 1 }
 COMP output mode. More...
 
enum  comp_irq_mode_t { COMP_IRQ_RISING = kACMP_OutputRisingEventFlag , COMP_IRQ_FALLING = kACMP_OutputFallingEventFlag , COMP_IRQ_BOTH = (COMP_IRQ_RISING | COMP_IRQ_FALLING) }
 COMP interrupt mode. More...
 

Functions

void comp_lld_init (void)
 Low level COMP driver initialization.
 
static void comp_lld_irq_handler (COMPDriver *compp)
 
 OSAL_IRQ_HANDLER (KINETIS_COMP0_IRQ_VECTOR)
 COMP1, COMP2, COMP3 interrupt handler.
 
 OSAL_IRQ_HANDLER (KINETIS_COMP1_IRQ_VECTOR)
 
 OSAL_IRQ_HANDLER (KINETIS_COMP2_IRQ_VECTOR)
 
void comp_lld_channel_enable (COMPDriver *compp, uint32_t channel)
 Configures and activates an EXT channel (used by comp)
 
void comp_lld_channel_disable (COMPDriver *compp, uint32_t channel)
 Deactivate an EXT channel (used by comp)
 
void comp_lld_set_dac_value (COMPDriver *compp, uint32_t value)
 Set the DAC value used by comp.
 
void comp_lld_start (COMPDriver *compp)
 Configures and activates the COMP peripheral.
 
void comp_lld_stop (COMPDriver *compp)
 Deactivates the comp peripheral.
 
void comp_lld_enable (COMPDriver *compp)
 Enables the output.
 
void comp_lld_disable (COMPDriver *compp)
 Disables the output.
 
uint32_t comp_lld_get_status (COMPDriver *compp)
 

Variables

COMPDriver COMPD1
 COMPD1 driver identifier.
 
COMPDriver COMPD2
 COMPD2 driver identifier.
 
COMPDriver COMPD3
 COMPD3 driver identifier.
 
COMPDriver COMPD1
 COMPD1 driver identifier.
 
COMPDriver COMPD2
 COMPD2 driver identifier.
 
COMPDriver COMPD3
 COMPD3 driver identifier.
 

Detailed Description

Enumeration Type Documentation

◆ comp_irq_mode_t

COMP interrupt mode.

Enumerator
COMP_IRQ_RISING 
COMP_IRQ_FALLING 
COMP_IRQ_BOTH 

Definition at line 150 of file hal_comp_lld.h.

150 {
comp_irq_mode_t
COMP interrupt mode.
@ COMP_IRQ_FALLING
@ COMP_IRQ_RISING
@ COMP_IRQ_BOTH
@ kACMP_OutputFallingEventFlag
Definition fsl_acmp.h:46
@ kACMP_OutputRisingEventFlag
Definition fsl_acmp.h:45

◆ comp_output_mode_t

COMP output mode.

Enumerator
COMP_OUTPUT_NORMAL 
COMP_OUTPUT_INVERTED 

Definition at line 142 of file hal_comp_lld.h.

142 {
comp_output_mode_t
COMP output mode.
@ COMP_OUTPUT_INVERTED
@ COMP_OUTPUT_NORMAL

Function Documentation

◆ comp_lld_channel_disable()

void comp_lld_channel_disable ( COMPDriver compp,
uint32_t  channel 
)

Deactivate an EXT channel (used by comp)

Parameters
[in]compppointer to the COMPDriver object
[in]channelEXT channel

@notapi

Definition at line 178 of file hal_comp_lld.c.

178 {
179 // todo: implement
180}

◆ comp_lld_channel_enable()

void comp_lld_channel_enable ( COMPDriver compp,
uint32_t  channel 
)

Configures and activates an EXT channel (used by comp)

Parameters
[in]compppointer to the COMPDriver object
[in]channelEXT channel (0..7)

@notapi

Definition at line 160 of file hal_comp_lld.c.

160 {
161 osalDbgAssert(channel <= 7, "invalid channel number");
162 memset(&compp->acmpChannelCfg, 0, sizeof(compp->acmpChannelCfg));
166 compp->acmpChannelCfg.minusMuxInput = 0U;
168}
uint16_t channel
Definition adc_inputs.h:104
void ACMP_SetChannelConfig(CMP_Type *base, const acmp_channel_config_t *config)
Sets the channel configuration.
Definition fsl_acmp.c:230
uint32_t minusMuxInput
Definition fsl_acmp.h:139
acmp_port_input_t positivePortInput
Definition fsl_acmp.h:133
acmp_port_input_t negativePortInput
Definition fsl_acmp.h:137
uint32_t plusMuxInput
Definition fsl_acmp.h:135
@ kACMP_PortInputFromDAC
Definition fsl_acmp.h:90
@ kACMP_PortInputFromMux
Definition fsl_acmp.h:91
COMP_DRIVER_EXT_FIELDS COMP_TypeDef * reg
Pointer to the COMPx registers block.
acmp_channel_config_t acmpChannelCfg
ACMP driver channel config.

Referenced by startTriggerInputPins().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ comp_lld_disable()

void comp_lld_disable ( COMPDriver compp)

Disables the output.

Parameters
[in]compppointer to the COMPDriver object

@notapi

Definition at line 263 of file hal_comp_lld.c.

263 {
264 ACMP_Enable(compp->reg, false);
265 ACMP_DisableInterrupts(compp->reg, compp->irq_mask);
266 compp->irq_mask = 0;
267}
void ACMP_Enable(CMP_Type *base, bool enable)
Enables or disables the ACMP.
Definition fsl_acmp.c:172
void ACMP_DisableInterrupts(CMP_Type *base, uint32_t mask)
Disables interrupts.
Definition fsl_acmp.c:522
uint32_t irq_mask
Here is the call graph for this function:

◆ comp_lld_enable()

void comp_lld_enable ( COMPDriver compp)

Enables the output.

Parameters
[in]compppointer to the COMPDriver object

@notapi

Definition at line 243 of file hal_comp_lld.c.

243 {
244 compp->irq_mask = 0;
245
246 /* Programming edge registers.*/
247 if (compp->config->irq_mode == COMP_IRQ_RISING || compp->config->irq_mode == COMP_IRQ_BOTH)
249 if (compp->config->irq_mode == COMP_IRQ_FALLING || compp->config->irq_mode == COMP_IRQ_BOTH)
251
252 ACMP_EnableInterrupts(compp->reg, compp->irq_mask);
253 ACMP_Enable(compp->reg, true);
254}
void ACMP_EnableInterrupts(CMP_Type *base, uint32_t mask)
Enables interrupts.
Definition fsl_acmp.c:485
@ kACMP_OutputFallingInterruptEnable
Definition fsl_acmp.h:38
@ kACMP_OutputRisingInterruptEnable
Definition fsl_acmp.h:37
comp_irq_mode_t irq_mode
Ouput mode.
const COMPConfig * config
Current configuration data.
Here is the call graph for this function:

◆ comp_lld_get_status()

uint32_t comp_lld_get_status ( COMPDriver compp)

Definition at line 269 of file hal_comp_lld.c.

269 {
270 uint32_t status = ACMP_GetStatusFlags(compp->reg);
271 // clear flags to continue
272 ACMP_ClearStatusFlags(compp->reg, status);
273 return status;
274}
uint32_t ACMP_GetStatusFlags(CMP_Type *base)
Gets status flags.
Definition fsl_acmp.c:559
void ACMP_ClearStatusFlags(CMP_Type *base, uint32_t mask)
Clears status flags.
Definition fsl_acmp.c:589

Referenced by comp_shaft_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ comp_lld_init()

void comp_lld_init ( void  )

Low level COMP driver initialization.

@notapi

Definition at line 89 of file hal_comp_lld.c.

89 {
90#if KINETIS_COMP_USE_COMP0
91 /* Driver initialization.*/
92 compObjectInit(&COMPD1);
93 COMPD1.reg = CMP0;
94 nvicEnableVector(CMP0_IRQn, KINETIS_COMP_IRQ_PRIORITY);
95#endif
96
97#if KINETIS_COMP_USE_COMP1
98 /* Driver initialization.*/
99 compObjectInit(&COMPD2);
100 COMPD2.reg = CMP1;
101 nvicEnableVector(CMP1_IRQn, KINETIS_COMP_IRQ_PRIORITY);
102#endif
103
104#if KINETIS_COMP_USE_COMP2
105 /* Driver initialization.*/
106 compObjectInit(&COMPD3);
107 COMPD3.reg = CMP2;
108 nvicEnableVector(CMP2_IRQn, KINETIS_COMP_IRQ_PRIORITY);
109#endif
110}
COMPDriver COMPD1
COMPD1 driver identifier.
COMPDriver COMPD2
COMPD2 driver identifier.
COMPDriver COMPD3
COMPD3 driver identifier.

◆ comp_lld_irq_handler()

static void comp_lld_irq_handler ( COMPDriver compp)
static

Definition at line 112 of file hal_comp_lld.c.

112 {
113 if (compp->config->cb != NULL)
114 compp->config->cb(compp);
115
116 /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
117 exception return operation might vector to incorrect interrupt */
118#if defined __CORTEX_M && (__CORTEX_M == 4U)
119 __DSB();
120#endif
121}
compcallback_t cb
Callback.

Referenced by OSAL_IRQ_HANDLER(), OSAL_IRQ_HANDLER(), and OSAL_IRQ_HANDLER().

Here is the caller graph for this function:

◆ comp_lld_set_dac_value()

void comp_lld_set_dac_value ( COMPDriver compp,
uint32_t  value 
)

Set the DAC value used by comp.

Parameters
[in]compppointer to the COMPDriver object
[in]valueDAC value (0..255?)

@notapi

Definition at line 190 of file hal_comp_lld.c.

190 {
191 compp->acmpDacCfg.DACValue = value;
192 ACMP_SetDACConfig(compp->reg, &compp->acmpDacCfg);
193}
uint32_t DACValue
Definition fsl_acmp.h:154
void ACMP_SetDACConfig(CMP_Type *base, const acmp_dac_config_t *config)
Configures the internal DAC.
Definition fsl_acmp.c:348
acmp_dac_config_t acmpDacCfg
ACMP driver DAC config.

Referenced by setHysteresis(), and startTriggerInputPins().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ comp_lld_start()

void comp_lld_start ( COMPDriver compp)

Configures and activates the COMP peripheral.

Parameters
[in]compppointer to the COMPDriver object

@notapi

Definition at line 202 of file hal_comp_lld.c.

202 {
205 compp->acmpCfg.enableInvertOutput = true;
206 compp->acmpCfg.enableHighSpeed = true;
207 compp->acmpCfg.useUnfilteredOutput = true; //false;
208 compp->acmpCfg.hysteresisMode = kACMP_HysteresisLevel2; // L1=~16mV, L2=~32mV
209
210 ACMP_Init(compp->reg, &compp->acmpCfg);
211 compp->irq_mask = 0;
212
213#if 0
214 acmp_filter_config_t filterCfg = { 0 };
215 filterCfg.filterCount = 2U;
216 filterCfg.filterPeriod = 2U;
217 filterCfg.enableSample = false;
218 ACMP_SetFilterConfig(compp->reg, &filterCfg);
219#endif
220
221 memset(&compp->acmpDacCfg, 0, sizeof(compp->acmpDacCfg));
222 compp->acmpDacCfg.referenceVoltageSource = kACMP_VrefSourceVin1; // connected to VDDA on KE1xF
223}
void ACMP_SetFilterConfig(CMP_Type *base, const acmp_filter_config_t *config)
Configures the filter.
Definition fsl_acmp.c:315
acmp_hysteresis_mode_t hysteresisMode
Definition fsl_acmp.h:117
bool enableHighSpeed
Definition fsl_acmp.h:118
bool enableInvertOutput
Definition fsl_acmp.h:119
void ACMP_Init(CMP_Type *base, const acmp_config_t *config)
Initializes the ACMP.
Definition fsl_acmp.c:70
uint32_t filterPeriod
Definition fsl_acmp.h:147
bool useUnfilteredOutput
Definition fsl_acmp.h:120
acmp_reference_voltage_source_t referenceVoltageSource
Definition fsl_acmp.h:153
void ACMP_GetDefaultConfig(acmp_config_t *config)
Gets the default configuration for ACMP.
Definition fsl_acmp.c:148
uint32_t filterCount
Definition fsl_acmp.h:146
@ kACMP_VrefSourceVin1
Definition fsl_acmp.h:82
@ kACMP_HysteresisLevel2
Definition fsl_acmp.h:75
Configuration for filter.
Definition fsl_acmp.h:144
comp_output_mode_t output_mode
Ouput mode.
acmp_config_t acmpCfg
ACMP driver config.
Here is the call graph for this function:

◆ comp_lld_stop()

void comp_lld_stop ( COMPDriver compp)

Deactivates the comp peripheral.

Parameters
[in]compppointer to the COMPDriver object

@notapi

Definition at line 232 of file hal_comp_lld.c.

232 {
233 ACMP_Deinit(compp->reg);
234}
void ACMP_Deinit(CMP_Type *base)
Deinitializes the ACMP.
Definition fsl_acmp.c:120
Here is the call graph for this function:

◆ OSAL_IRQ_HANDLER() [1/3]

OSAL_IRQ_HANDLER ( KINETIS_COMP0_IRQ_VECTOR  )

COMP1, COMP2, COMP3 interrupt handler.

@isr

Definition at line 129 of file hal_comp_lld.c.

129 {
130 OSAL_IRQ_PROLOGUE();
132 OSAL_IRQ_EPILOGUE();
133}
static void comp_lld_irq_handler(COMPDriver *compp)
Here is the call graph for this function:

◆ OSAL_IRQ_HANDLER() [2/3]

OSAL_IRQ_HANDLER ( KINETIS_COMP1_IRQ_VECTOR  )

Definition at line 137 of file hal_comp_lld.c.

137 {
138 OSAL_IRQ_PROLOGUE();
140 OSAL_IRQ_EPILOGUE();
141}
Here is the call graph for this function:

◆ OSAL_IRQ_HANDLER() [3/3]

OSAL_IRQ_HANDLER ( KINETIS_COMP2_IRQ_VECTOR  )

Definition at line 145 of file hal_comp_lld.c.

145 {
146 OSAL_IRQ_PROLOGUE();
148 OSAL_IRQ_EPILOGUE();
149}
Here is the call graph for this function:

Variable Documentation

◆ COMPD1 [1/2]

COMPDriver COMPD1

COMPD1 driver identifier.

Note
The driver COMPD1 allocates the comparator COMP1 when enabled.

Definition at line 47 of file hal_comp_lld.c.

Referenced by comp_lld_init(), and OSAL_IRQ_HANDLER().

◆ COMPD1 [2/2]

COMPDriver COMPD1
extern

COMPD1 driver identifier.

Note
The driver COMPD1 allocates the comparator COMP1 when enabled.

Definition at line 47 of file hal_comp_lld.c.

Referenced by comp_lld_init(), and OSAL_IRQ_HANDLER().

◆ COMPD2 [1/2]

COMPDriver COMPD2

COMPD2 driver identifier.

Note
The driver COMPD2 allocates the comparator COMP2 when enabled.

Definition at line 55 of file hal_comp_lld.c.

Referenced by comp_lld_init(), and OSAL_IRQ_HANDLER().

◆ COMPD2 [2/2]

COMPDriver COMPD2
extern

COMPD2 driver identifier.

Note
The driver COMPD2 allocates the comparator COMP2 when enabled.

Definition at line 55 of file hal_comp_lld.c.

Referenced by comp_lld_init(), and OSAL_IRQ_HANDLER().

◆ COMPD3 [1/2]

COMPDriver COMPD3

COMPD3 driver identifier.

Note
The driver COMPD3 allocates the comparator COMP3 when enabled.

Definition at line 63 of file hal_comp_lld.c.

Referenced by comp_lld_init(), and OSAL_IRQ_HANDLER().

◆ COMPD3 [2/2]

COMPDriver COMPD3
extern

COMPD3 driver identifier.

Note
The driver COMPD3 allocates the comparator COMP3 when enabled.

Definition at line 63 of file hal_comp_lld.c.

Referenced by comp_lld_init(), and OSAL_IRQ_HANDLER().