Skip to content

Commit 928aecd

Browse files
committed
simplelink_lpf3: ti: devices: cc23x0r5: adc: Add support for DMA mode
Add support to ADC API for DMA Trigger Event Publisher (INT_EVENT2). The ADC module provides four interrupt sources (one for each conversion result storage register) which can be configured to source the DMA trigger. Signed-off-by: Julien Panis <[email protected]>
1 parent 0c68fb3 commit 928aecd

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

simplelink_lpf3/source/ti/devices/cc23x0r5/driverlib/adc.h

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,126 @@ __STATIC_INLINE void ADCClearInterrupt(uint32_t intFlags)
587587
HWREG(ADC_BASE + ADC_O_ICLR0) = intFlags;
588588
}
589589

590+
//*****************************************************************************
591+
//
592+
//! \brief Enable DMA trigger for data transfer.
593+
//!
594+
//! This function enables DMA trigger for data transfer. DMAEN bit is cleared by hardware
595+
//! based on DMA done signal at the end of data transfer. Software has to re-enable DMAEN
596+
//! bit for ADC to generate DMA triggers.
597+
//!
598+
//! \return None
599+
//
600+
//*****************************************************************************
601+
__STATIC_INLINE void ADCEnableDMATrigger(void)
602+
{
603+
HWREG(ADC_BASE + ADC_O_CTL2) |= ADC_CTL2_DMAEN;
604+
}
605+
606+
//*****************************************************************************
607+
//
608+
//! \brief Enables individual ADC interrupt sources for DMA Trigger Event Publisher (INT_EVENT2).
609+
//!
610+
//! This function enables the indicated ADC interrupt sources (INT_EVENT2).
611+
//!
612+
//! \param intFlags is the bit mask of the interrupt sources to be enabled.
613+
//! The parameter is the bitwise OR of any of the following:
614+
//! - ADC_INT_MEMRES_N (\ref ADC_INT_MEMRES_00, \ref ADC_INT_MEMRES_01, etc)
615+
//!
616+
//! \return None
617+
//
618+
//*****************************************************************************
619+
__STATIC_INLINE void ADCEnableDMAInterrupt(uint32_t intFlags)
620+
{
621+
// Enable the specified interrupts.
622+
HWREG(ADC_BASE + ADC_O_IMASK2) |= intFlags;
623+
}
624+
625+
//*****************************************************************************
626+
//
627+
//! \brief Disables individual ADC interrupt sources for DMA Trigger Event Publisher (INT_EVENT2).
628+
//!
629+
//! This function disables the indicated ADC interrupt sources (INT_EVENT2).
630+
//!
631+
//! \param intFlags is the bit mask of the interrupt sources to be disabled.
632+
//! The parameter is the bitwise OR of any of the following:
633+
//! - ADC_INT_MEMRES_N (\ref ADC_INT_MEMRES_00, \ref ADC_INT_MEMRES_01, etc)
634+
//!
635+
//! \return None
636+
//
637+
//*****************************************************************************
638+
__STATIC_INLINE void ADCDisableDMAInterrupt(uint32_t intFlags)
639+
{
640+
// Disable the specified interrupts.
641+
HWREG(ADC_BASE + ADC_O_IMASK2) &= ~(intFlags);
642+
}
643+
644+
//*****************************************************************************
645+
//
646+
//! \brief Gets the current raw interrupt status for DMA Trigger Event Publisher (INT_EVENT2).
647+
//!
648+
//! This function returns the raw interrupt status for the ADC (INT_EVENT2).
649+
//!
650+
//! \return Returns the current interrupt status, enumerated as a bit field of:
651+
//! - ADC_INT_MEMRES_N (\ref ADC_INT_MEMRES_00, \ref ADC_INT_MEMRES_01, etc)
652+
//
653+
//*****************************************************************************
654+
__STATIC_INLINE uint32_t ADCRawDMAInterruptStatus(void)
655+
{
656+
return (HWREG(ADC_BASE + ADC_O_RIS2));
657+
}
658+
659+
//*****************************************************************************
660+
//
661+
//! \brief Gets the current masked interrupt status for DMA Trigger Event Publisher (INT_EVENT2).
662+
//!
663+
//! This function returns the masked interrupt status for the ADC (INT_EVENT2).
664+
//!
665+
//! \return Returns the current interrupt status, enumerated as a bit field of:
666+
//! - ADC_INT_MEMRES_N (\ref ADC_INT_MEMRES_00, \ref ADC_INT_MEMRES_01, etc)
667+
//
668+
//*****************************************************************************
669+
__STATIC_INLINE uint32_t ADCMaskedDMAInterruptStatus(void)
670+
{
671+
return (HWREG(ADC_BASE + ADC_O_MIS2));
672+
}
673+
674+
//*****************************************************************************
675+
//
676+
//! \brief Clears ADC interrupt sources for DMA Trigger Event Publisher (INT_EVENT2).
677+
//!
678+
//! The specified ADC interrupt sources are cleared, so that they no longer
679+
//! assert. This function must be called in the interrupt handler to keep the
680+
//! interrupt from being recognized again immediately upon exit.
681+
//!
682+
//! \note Due to write buffers and synchronizers in the system it may take several
683+
//! clock cycles from a register write clearing an event in a module and until the
684+
//! event is actually cleared in the NVIC of the system CPU. It is recommended to
685+
//! clear the event source early in the interrupt service routine (ISR) to allow
686+
//! the event clear to propagate to the NVIC before returning from the ISR.
687+
//! At the same time, an early event clear allows new events of the same type to be
688+
//! pended instead of ignored if the event is cleared later in the ISR.
689+
//! It is the responsibility of the programmer to make sure that enough time has passed
690+
//! before returning from the ISR to avoid false re-triggering of the cleared event.
691+
//! A simple, although not necessarily optimal, way of clearing an event before
692+
//! returning from the ISR is:
693+
//! -# Write to clear event (interrupt source). (buffered write)
694+
//! -# Dummy read from the event source module. (making sure the write has propagated)
695+
//! -# Wait two system CPU clock cycles (user code or two NOPs). (allowing cleared event to propagate through any
696+
//! synchronizers)
697+
//!
698+
//! \param intFlags is a bit mask of the interrupt sources to be cleared.
699+
//! - ADC_INT_MEMRES_N (\ref ADC_INT_MEMRES_00, \ref ADC_INT_MEMRES_01, etc)
700+
//!
701+
//! \return None
702+
//
703+
//*****************************************************************************
704+
__STATIC_INLINE void ADCClearDMAInterrupt(uint32_t intFlags)
705+
{
706+
// Clear the requested interrupt sources
707+
HWREG(ADC_BASE + ADC_O_ICLR2) = intFlags;
708+
}
709+
590710
//*****************************************************************************
591711
//
592712
//! \brief Returns ADC gain value for given reference

0 commit comments

Comments
 (0)