MSP432E4 DriverLib API Guide
1.11.00.03
|
Functions | |
void | ComparatorConfigure (uint32_t ui32Base, uint32_t ui32Comp, uint32_t ui32Config) |
void | ComparatorRefSet (uint32_t ui32Base, uint32_t ui32Ref) |
bool | ComparatorValueGet (uint32_t ui32Base, uint32_t ui32Comp) |
void | ComparatorIntRegister (uint32_t ui32Base, uint32_t ui32Comp, void(*pfnHandler)(void)) |
void | ComparatorIntUnregister (uint32_t ui32Base, uint32_t ui32Comp) |
void | ComparatorIntEnable (uint32_t ui32Base, uint32_t ui32Comp) |
void | ComparatorIntDisable (uint32_t ui32Base, uint32_t ui32Comp) |
bool | ComparatorIntStatus (uint32_t ui32Base, uint32_t ui32Comp, bool bMasked) |
void | ComparatorIntClear (uint32_t ui32Base, uint32_t ui32Comp) |
The comparator API provides a set of functions for programming and using the analog comparators. A comparator can compare a test voltage against an individual external reference voltage, a shared single external reference voltage, or a shared internal reference voltage. It can provide its output to a device pin, acting as a replacement for an analog comparator on the board, or it can be used to signal the application via interrupts or triggers to the ADC to start capturing a sample sequence. The interrupt generation logic is independent from the ADC triggering logic. As a result, the comparator can generate an interrupt based on one event and an ADC trigger based on another event. For example, an interrupt can be generated on a rising edge and the ADC triggered on a falling edge.
The comparator API is fairly simple, like the comparators themselves. There are functions for configuring a comparator and reading its output (ComparatorConfigure(), ComparatorRefSet() and ComparatorValueGet()) and functions for dealing with an interrupt handler for the comparator (ComparatorIntRegister(), ComparatorIntUnregister(), ComparatorIntEnable(), ComparatorIntDisable(), ComparatorIntStatus(), and ComparatorIntClear()).
The following example shows how to use the comparator API to configure the comparator and read its value.
void ComparatorConfigure | ( | uint32_t | ui32Base, |
uint32_t | ui32Comp, | ||
uint32_t | ui32Config | ||
) |
Configures a comparator.
ui32Base | is the base address of the comparator module. |
ui32Comp | is the index of the comparator to configure. |
ui32Config | is the configuration of the comparator. |
This function configures a comparator. The ui32Config parameter is the result of a logical OR operation between the COMP_TRIG_xxx, COMP_INT_xxx, COMP_ASRCP_xxx, and COMP_OUTPUT_xxx values.
The COMP_TRIG_xxx term can take on the following values:
The COMP_INT_xxx term can take on the following values:
The COMP_ASRCP_xxx term can take on the following values:
The COMP_OUTPUT_xxx term can take on the following values:
References ASSERT, COMP_O_ACCTL0, and HWREG.
void ComparatorRefSet | ( | uint32_t | ui32Base, |
uint32_t | ui32Ref | ||
) |
Sets the internal reference voltage.
ui32Base | is the base address of the comparator module. |
ui32Ref | is the desired reference voltage. |
This function sets the internal reference voltage value. The voltage is specified as one of the following values:
References ASSERT, COMP_O_ACREFCTL, and HWREG.
bool ComparatorValueGet | ( | uint32_t | ui32Base, |
uint32_t | ui32Comp | ||
) |
Gets the current comparator output value.
ui32Base | is the base address of the comparator module. |
ui32Comp | is the index of the comparator. |
This function retrieves the current value of the comparator output.
References ASSERT, COMP_ACSTAT0_OVAL, COMP_O_ACSTAT0, and HWREG.
void ComparatorIntRegister | ( | uint32_t | ui32Base, |
uint32_t | ui32Comp, | ||
void(*)(void) | pfnHandler | ||
) |
Registers an interrupt handler for the comparator interrupt.
ui32Base | is the base address of the comparator module. |
ui32Comp | is the index of the comparator. |
pfnHandler | is a pointer to the function to be called when the comparator interrupt occurs. |
This function sets the handler to be called when the comparator interrupt occurs and enables the interrupt in the interrupt controller. It is the interrupt handler's responsibility to clear the interrupt source via ComparatorIntClear().
References ASSERT, COMP_O_ACINTEN, HWREG, INT_COMP0, IntEnable(), and IntRegister().
void ComparatorIntUnregister | ( | uint32_t | ui32Base, |
uint32_t | ui32Comp | ||
) |
Unregisters an interrupt handler for a comparator interrupt.
ui32Base | is the base address of the comparator module. |
ui32Comp | is the index of the comparator. |
This function clears the handler to be called when a comparator interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called.
References ASSERT, COMP_O_ACINTEN, HWREG, INT_COMP0, IntDisable(), and IntUnregister().
void ComparatorIntEnable | ( | uint32_t | ui32Base, |
uint32_t | ui32Comp | ||
) |
Enables the comparator interrupt.
ui32Base | is the base address of the comparator module. |
ui32Comp | is the index of the comparator. |
This function enables generation of an interrupt from the specified comparator. Only enabled comparator interrupts can be reflected to the processor.
References ASSERT, COMP_O_ACINTEN, and HWREG.
void ComparatorIntDisable | ( | uint32_t | ui32Base, |
uint32_t | ui32Comp | ||
) |
Disables the comparator interrupt.
ui32Base | is the base address of the comparator module. |
ui32Comp | is the index of the comparator. |
This function disables generation of an interrupt from the specified comparator. Only enabled comparator interrupts can be reflected to the processor.
References ASSERT, COMP_O_ACINTEN, and HWREG.
bool ComparatorIntStatus | ( | uint32_t | ui32Base, |
uint32_t | ui32Comp, | ||
bool | bMasked | ||
) |
Gets the current interrupt status.
ui32Base | is the base address of the comparator module. |
ui32Comp | is the index of the comparator. |
bMasked | is false if the raw interrupt status is required and true if the masked interrupt status is required. |
This function returns the interrupt status for the comparator. Either the raw or the masked interrupt status can be returned.
References ASSERT, COMP_O_ACMIS, COMP_O_ACRIS, and HWREG.
void ComparatorIntClear | ( | uint32_t | ui32Base, |
uint32_t | ui32Comp | ||
) |
Clears a comparator interrupt.
ui32Base | is the base address of the comparator module. |
ui32Comp | is the index of the comparator. |
The comparator interrupt is cleared, so that it no longer asserts. This function must be called in the interrupt handler to keep the handler from being called again immediately upon exit. Note that for a level-triggered interrupt, the interrupt cannot be cleared until it stops asserting.
References ASSERT, COMP_O_ACMIS, and HWREG.