| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- /*
- * Copyright (c) 2023, Texas Instruments Incorporated
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- /*
- * ============ ti_msp_dl_config.c =============
- * Configured MSPM0 DriverLib module definitions
- *
- * DO NOT EDIT - This file is generated for the MSPM0L130X
- * by the SysConfig tool.
- */
- #include "ti_msp_dl_config.h"
- /*
- * ======== SYSCFG_DL_init ========
- * Perform any initialization needed before using any board APIs
- */
- SYSCONFIG_WEAK void SYSCFG_DL_init(void)
- {
- SYSCFG_DL_initPower();
- SYSCFG_DL_GPIO_init();
- /* Module-Specific Initializations*/
- SYSCFG_DL_SYSCTL_init();
- SYSCFG_DL_PWM_0_init();
- SYSCFG_DL_I2C_controller_init();
- SYSCFG_DL_I2C_target_init();
- }
- SYSCONFIG_WEAK void SYSCFG_DL_initPower(void)
- {
- DL_GPIO_reset(GPIOA);
- DL_TimerG_reset(PWM_0_INST);
- DL_I2C_reset(I2C_controller_INST);
- DL_I2C_reset(I2C_target_INST);
- DL_GPIO_enablePower(GPIOA);
- DL_TimerG_enablePower(PWM_0_INST);
- DL_I2C_enablePower(I2C_controller_INST);
- DL_I2C_enablePower(I2C_target_INST);
- delay_cycles(POWER_STARTUP_DELAY);
- }
- SYSCONFIG_WEAK void SYSCFG_DL_GPIO_init(void)
- {
- DL_GPIO_initPeripheralOutputFunction(GPIO_PWM_0_C0_IOMUX,GPIO_PWM_0_C0_IOMUX_FUNC);
- DL_GPIO_enableOutput(GPIO_PWM_0_C0_PORT, GPIO_PWM_0_C0_PIN);
-
- DL_GPIO_initPeripheralInputFunctionFeatures(
- GPIO_I2C_controller_IOMUX_SDA, GPIO_I2C_controller_IOMUX_SDA_FUNC,
- DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_PULL_UP,
- DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
- DL_GPIO_initPeripheralInputFunctionFeatures(
- GPIO_I2C_controller_IOMUX_SCL, GPIO_I2C_controller_IOMUX_SCL_FUNC,
- DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_PULL_UP,
- DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
- DL_GPIO_enableHiZ(GPIO_I2C_controller_IOMUX_SDA);
- DL_GPIO_enableHiZ(GPIO_I2C_controller_IOMUX_SCL);
-
- DL_GPIO_initPeripheralInputFunctionFeatures(
- GPIO_I2C_target_IOMUX_SDA, GPIO_I2C_target_IOMUX_SDA_FUNC,
- DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_NONE,
- DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
- DL_GPIO_initPeripheralInputFunctionFeatures(
- GPIO_I2C_target_IOMUX_SCL, GPIO_I2C_target_IOMUX_SCL_FUNC,
- DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_NONE,
- DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
- DL_GPIO_enableHiZ(GPIO_I2C_target_IOMUX_SDA);
- DL_GPIO_enableHiZ(GPIO_I2C_target_IOMUX_SCL);
- }
- SYSCONFIG_WEAK void SYSCFG_DL_SYSCTL_init(void)
- {
- //Low Power Mode is configured to be SLEEP0
- DL_SYSCTL_setBORThreshold(DL_SYSCTL_BOR_THRESHOLD_LEVEL_0);
- DL_SYSCTL_disableNRSTPin();
- DL_SYSCTL_setSYSOSCFreq(DL_SYSCTL_SYSOSC_FREQ_BASE);
- DL_SYSCTL_setMCLKDivider(DL_SYSCTL_MCLK_DIVIDER_DISABLE);
- }
- /*
- * Timer clock configuration to be sourced by / 1 (32000000 Hz)
- * timerClkFreq = (timerClkSrc / (timerClkDivRatio * (timerClkPrescale + 1)))
- * 32000000 Hz = 32000000 Hz / (1 * (0 + 1))
- */
- static const DL_TimerG_ClockConfig gPWM_0ClockConfig = {
- .clockSel = DL_TIMER_CLOCK_BUSCLK,
- .divideRatio = DL_TIMER_CLOCK_DIVIDE_1,
- .prescale = 0U
- };
- static const DL_TimerG_PWMConfig gPWM_0Config = {
- .pwmMode = DL_TIMER_PWM_MODE_EDGE_ALIGN,
- .period = 400,
- .isTimerWithFourCC = false,
- .startTimer = DL_TIMER_STOP,
- };
- SYSCONFIG_WEAK void SYSCFG_DL_PWM_0_init(void) {
- DL_TimerG_setClockConfig(
- PWM_0_INST, (DL_TimerG_ClockConfig *) &gPWM_0ClockConfig);
- DL_TimerG_initPWMMode(
- PWM_0_INST, (DL_TimerG_PWMConfig *) &gPWM_0Config);
- // Set Counter control to the smallest CC index being used
- DL_TimerG_setCounterControl(PWM_0_INST,DL_TIMER_CZC_CCCTL0_ZCOND,DL_TIMER_CAC_CCCTL0_ACOND,DL_TIMER_CLC_CCCTL0_LCOND);
- DL_TimerG_setCaptureCompareOutCtl(PWM_0_INST, DL_TIMER_CC_OCTL_INIT_VAL_LOW,
- DL_TIMER_CC_OCTL_INV_OUT_DISABLED, DL_TIMER_CC_OCTL_SRC_FUNCVAL,
- DL_TIMERG_CAPTURE_COMPARE_0_INDEX);
- DL_TimerG_setCaptCompUpdateMethod(PWM_0_INST, DL_TIMER_CC_UPDATE_METHOD_IMMEDIATE, DL_TIMERG_CAPTURE_COMPARE_0_INDEX);
- DL_TimerG_setCaptureCompareValue(PWM_0_INST, 360, DL_TIMER_CC_0_INDEX);
- DL_TimerG_enableClock(PWM_0_INST);
-
- DL_TimerG_setCCPDirection(PWM_0_INST , DL_TIMER_CC0_OUTPUT );
- }
- static const DL_I2C_ClockConfig gI2C_controllerClockConfig = {
- .clockSel = DL_I2C_CLOCK_BUSCLK,
- .divideRatio = DL_I2C_CLOCK_DIVIDE_1,
- };
- SYSCONFIG_WEAK void SYSCFG_DL_I2C_controller_init(void) {
- DL_I2C_setClockConfig(I2C_controller_INST,
- (DL_I2C_ClockConfig *) &gI2C_controllerClockConfig);
- DL_I2C_setAnalogGlitchFilterPulseWidth(I2C_controller_INST,
- DL_I2C_ANALOG_GLITCH_FILTER_WIDTH_50NS);
- DL_I2C_enableAnalogGlitchFilter(I2C_controller_INST);
- /* Configure Controller Mode */
- DL_I2C_resetControllerTransfer(I2C_controller_INST);
- /* Set frequency to 100000 Hz*/
- DL_I2C_setTimerPeriod(I2C_controller_INST, 31);
- DL_I2C_setControllerTXFIFOThreshold(I2C_controller_INST, DL_I2C_TX_FIFO_LEVEL_EMPTY);
- DL_I2C_setControllerRXFIFOThreshold(I2C_controller_INST, DL_I2C_RX_FIFO_LEVEL_BYTES_1);
- DL_I2C_enableControllerClockStretching(I2C_controller_INST);
- /* Configure Interrupts */
- DL_I2C_enableInterrupt(I2C_controller_INST,
- DL_I2C_INTERRUPT_CONTROLLER_ARBITRATION_LOST |
- DL_I2C_INTERRUPT_CONTROLLER_NACK |
- DL_I2C_INTERRUPT_CONTROLLER_RXFIFO_TRIGGER |
- DL_I2C_INTERRUPT_CONTROLLER_RX_DONE |
- DL_I2C_INTERRUPT_CONTROLLER_TXFIFO_TRIGGER |
- DL_I2C_INTERRUPT_CONTROLLER_TX_DONE);
- /* Enable module */
- DL_I2C_enableController(I2C_controller_INST);
- }
- static const DL_I2C_ClockConfig gI2C_targetClockConfig = {
- .clockSel = DL_I2C_CLOCK_BUSCLK,
- .divideRatio = DL_I2C_CLOCK_DIVIDE_1,
- };
- SYSCONFIG_WEAK void SYSCFG_DL_I2C_target_init(void) {
- DL_I2C_setClockConfig(I2C_target_INST,
- (DL_I2C_ClockConfig *) &gI2C_targetClockConfig);
- DL_I2C_setAnalogGlitchFilterPulseWidth(I2C_target_INST,
- DL_I2C_ANALOG_GLITCH_FILTER_WIDTH_50NS);
- DL_I2C_enableAnalogGlitchFilter(I2C_target_INST);
- /* Configure Target Mode */
- DL_I2C_setTargetOwnAddress(I2C_target_INST, I2C_target_TARGET_OWN_ADDR);
- DL_I2C_setTargetTXFIFOThreshold(I2C_target_INST, DL_I2C_TX_FIFO_LEVEL_EMPTY);
- DL_I2C_setTargetRXFIFOThreshold(I2C_target_INST, DL_I2C_RX_FIFO_LEVEL_BYTES_1);
- DL_I2C_enableTargetClockStretching(I2C_target_INST);
- /* Workaround for errata I2C_ERR_04 */
- DL_I2C_disableTargetWakeup(I2C_target_INST);
- /* Configure Interrupts */
- DL_I2C_enableInterrupt(I2C_target_INST,
- DL_I2C_INTERRUPT_TARGET_RXFIFO_TRIGGER |
- DL_I2C_INTERRUPT_TARGET_START |
- DL_I2C_INTERRUPT_TARGET_STOP |
- DL_I2C_INTERRUPT_TARGET_TXFIFO_TRIGGER);
- /* Enable module */
- DL_I2C_enableTarget(I2C_target_INST);
- }
|