Skip to content

Commit 1808bdd

Browse files
jpanisblvaishnavachath
authored andcommitted
simplelink_lpf3: cc23x0r5: Add missing support for Zephyr
- Add some driverlib files to CMakeLists. - Add CLKCTL driver. - Add VIMS functionality for flash. VIMS function API is needed to enable/disable buffers and check for activity before read/write/erase. - Extend GPIO functionality with GPIOSetConfigDio and GPIOGetConfigDio. - Add UARTEnable. - Add support for DMA mode in ADC driver. 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) that can be configured to source the DMA trigger. Signed-off-by: Stoyan Bogdanov <[email protected]> Signed-off-by: Julien Panis <[email protected]>
1 parent 20d5a7e commit 1808bdd

File tree

8 files changed

+929
-0
lines changed

8 files changed

+929
-0
lines changed

simplelink_lpf3/source/ti/devices/cc23x0r5/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ zephyr_library_sources(
4444
driverlib/lrfd.c
4545
driverlib/setup.c
4646
driverlib/uart.c
47+
driverlib/spi.c
48+
driverlib/vims.c
49+
driverlib/adc.c
50+
driverlib/cpu.c
51+
driverlib/i2c.c
4752
)
4853

4954
# RF patches

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
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
/******************************************************************************
2+
* Filename: clkctl.h
3+
*
4+
* Description: Defines and prototypes for the Clock Control (CLKCTL).
5+
*
6+
* Copyright (c) 2024 Texas Instruments Incorporated
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1) Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
*
14+
* 2) Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* 3) Neither the name of the copyright holder nor the names of its
19+
* contributors may be used to endorse or promote products derived from this
20+
* software without specific prior written permission.
21+
*
22+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
* POSSIBILITY OF SUCH DAMAGE.
33+
*
34+
******************************************************************************/
35+
36+
#ifndef __CLKCTL_H__
37+
#define __CLKCTL_H__
38+
39+
//*****************************************************************************
40+
//
41+
//! \addtogroup peripheral_group
42+
//! @{
43+
//! \addtogroup clkctl_api
44+
//! @{
45+
//
46+
//*****************************************************************************
47+
48+
//*****************************************************************************
49+
//
50+
// If building with a C++ compiler, make all of the definitions in this header
51+
// have a C binding.
52+
//
53+
//*****************************************************************************
54+
#ifdef __cplusplus
55+
extern "C" {
56+
#endif
57+
58+
#include <stdbool.h>
59+
#include <stdint.h>
60+
#include "../inc/hw_ints.h"
61+
#include "../inc/hw_memmap.h"
62+
#include "../inc/hw_types.h"
63+
#include "../inc/hw_clkctl.h"
64+
#include "debug.h"
65+
#include "interrupt.h"
66+
67+
//*****************************************************************************
68+
//
69+
// Values that can be passed to CLKCTLEnable() and CLKCTLDisable().
70+
//
71+
//*****************************************************************************
72+
#define CLKCTL_LGPT3 CLKCTL_CLKENSET0_LGPT3 //!< Configure LGPT3 clock enable
73+
#define CLKCTL_LGPT2 CLKCTL_CLKENSET0_LGPT2 //!< Configure LGPT2 clock enable
74+
#define CLKCTL_LGPT1 CLKCTL_CLKENSET0_LGPT1 //!< Configure LGPT1 clock enable
75+
#define CLKCTL_LGPT0 CLKCTL_CLKENSET0_LGPT0 //!< Configure LGPT0 clock enable
76+
#define CLKCTL_DMA CLKCTL_CLKENSET0_DMA //!< Configure DMA clock enable
77+
#define CLKCTL_LAES CLKCTL_CLKENSET0_LAES //!< Configure LAES clock enable
78+
#define CLKCTL_ADC0 CLKCTL_CLKENSET0_ADC0 //!< Configure ADC0 clock enable
79+
#define CLKCTL_SPI0 CLKCTL_CLKENSET0_SPI0 //!< Configure SPI0 clock enable
80+
#define CLKCTL_I2C0 CLKCTL_CLKENSET0_I2C0 //!< Configure I2C0 clock enable
81+
#define CLKCTL_UART0 CLKCTL_CLKENSET0_UART0 //!< Configure UART0 clock enable
82+
#define CLKCTL_LRFD CLKCTL_CLKENSET0_LRFD //!< Configure LRFD clock enable
83+
#define CLKCTL_GPIO CLKCTL_CLKENSET0_GPIO //!< Configure GPIO clock enable
84+
85+
//*****************************************************************************
86+
//
87+
// API Functions and prototypes.
88+
//
89+
//*****************************************************************************
90+
91+
#ifdef DRIVERLIB_DEBUG
92+
//*****************************************************************************
93+
//
94+
//! \internal
95+
//!
96+
//! \brief Checks clock control base address.
97+
//!
98+
//! This function determines if a clock controle base address is valid.
99+
//!
100+
//! \param base specifies the clock control base address.
101+
//!
102+
//! \return Returns \c true if the base address is valid and \c false
103+
//! otherwise.
104+
//
105+
//*****************************************************************************
106+
static bool CLKCTLBaseValid(uint32_t base)
107+
{
108+
return (base == CLKCTL_BASE);
109+
}
110+
#endif
111+
112+
//*****************************************************************************
113+
//
114+
//! \brief Enables the clock for a peripheral.
115+
//!
116+
//! This function enables the clock for a peripheral.
117+
//!
118+
//! \param base specifies the clock control base address.
119+
//! \param peripheral specifies the peripheral.
120+
//! The parameter can be one of the following values:
121+
//! - \ref CLKCTL_LGPT3
122+
//! - \ref CLKCTL_LGPT2
123+
//! - \ref CLKCTL_LGPT1
124+
//! - \ref CLKCTL_LGPT0
125+
//! - \ref CLKCTL_DMA
126+
//! - \ref CLKCTL_LAES
127+
//! - \ref CLKCTL_ADC0
128+
//! - \ref CLKCTL_SPI0
129+
//! - \ref CLKCTL_I2C0
130+
//! - \ref CLKCTL_UART0
131+
//! - \ref CLKCTL_LRFD
132+
//! - \ref CLKCTL_GPIO
133+
//!
134+
//! \return None
135+
//
136+
//*****************************************************************************
137+
__STATIC_INLINE void CLKCTLEnable(uint32_t base, uint32_t peripheral)
138+
{
139+
// Check the arguments
140+
ASSERT(CLKCTLBaseValid(base));
141+
142+
// Read-modify-write the set bit
143+
HWREG(base + CLKCTL_O_CLKENSET0) |= peripheral;
144+
}
145+
146+
//*****************************************************************************
147+
//
148+
//! \brief Disables the clock for a peripheral.
149+
//!
150+
//! This function disables the clock for a peripheral.
151+
//!
152+
//! \param base specifies the clock control base address.
153+
//! \param peripheral specifies the peripheral.
154+
//! The parameter can be one of the following values:
155+
//! - \ref CLKCTL_LGPT3
156+
//! - \ref CLKCTL_LGPT2
157+
//! - \ref CLKCTL_LGPT1
158+
//! - \ref CLKCTL_LGPT0
159+
//! - \ref CLKCTL_DMA
160+
//! - \ref CLKCTL_LAES
161+
//! - \ref CLKCTL_ADC0
162+
//! - \ref CLKCTL_SPI0
163+
//! - \ref CLKCTL_I2C0
164+
//! - \ref CLKCTL_UART0
165+
//! - \ref CLKCTL_LRFD
166+
//! - \ref CLKCTL_GPIO
167+
//!
168+
//! \return None
169+
//
170+
//*****************************************************************************
171+
__STATIC_INLINE void CLKCTLDisable(uint32_t base, uint32_t peripheral)
172+
{
173+
// Check the arguments
174+
ASSERT(CLKCTLBaseValid(base));
175+
176+
// Read-modify-write the clear bit
177+
HWREG(base + CLKCTL_O_CLKENCLR0) |= peripheral;
178+
}
179+
180+
//*****************************************************************************
181+
//
182+
// Mark the end of the C bindings section for C++ compilers.
183+
//
184+
//*****************************************************************************
185+
#ifdef __cplusplus
186+
}
187+
#endif
188+
189+
//*****************************************************************************
190+
//
191+
//! Close the Doxygen group.
192+
//! @}
193+
//! @}
194+
//
195+
//*****************************************************************************
196+
197+
#endif // __CLKCTL_H__

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,46 @@ __STATIC_INLINE void GPIOClearEventMultiDio(uint32_t dioMask)
581581
HWREG( GPIO_BASE + GPIO_O_ICLR ) = dioMask;
582582
}
583583

584+
//*****************************************************************************
585+
//
586+
//! \brief Set configuration to DIO.
587+
//!
588+
//! \param iocfgRegAddr is address where config should be written
589+
//! \param config is the configuration to be written
590+
//! \return None
591+
//!
592+
//! \sa \ref GPIOGetConfigDio()
593+
//
594+
//*****************************************************************************
595+
__STATIC_INLINE void GPIOSetConfigDio(uint32_t iocfgRegAddr, uint32_t config)
596+
{
597+
// Check the arguments.
598+
ASSERT(iocfgRegAddr);
599+
600+
// Set the specified DIO config.
601+
HWREG( iocfgRegAddr ) = config;
602+
}
603+
604+
//*****************************************************************************
605+
//
606+
//! \brief Get configuration for DIO.
607+
//!
608+
//! \param iocfgRegAddr is address from where config should be read
609+
//!
610+
//! \return Raw register value
611+
//!
612+
//! \sa \ref GPIOSetConfigDio()
613+
//
614+
//*****************************************************************************
615+
__STATIC_INLINE uint32_t GPIOGetConfigDio(uint32_t iocfgRegAddr)
616+
{
617+
// Check the arguments.
618+
ASSERT(iocfgRegAddr);
619+
620+
// Return Raw register value.
621+
return HWREG( iocfgRegAddr );
622+
}
623+
584624
//*****************************************************************************
585625
//
586626
// Mark the end of the C bindings section for C++ compilers.

0 commit comments

Comments
 (0)