pwm uart gipo i2c
This commit is contained in:
@@ -40,6 +40,8 @@
|
||||
|
||||
#include "ti_msp_dl_config.h"
|
||||
|
||||
DL_TimerA_backupConfig gPWM_0Backup;
|
||||
|
||||
/*
|
||||
* ======== SYSCFG_DL_init ========
|
||||
* Perform any initialization needed before using any board APIs
|
||||
@@ -50,23 +52,50 @@ SYSCONFIG_WEAK void SYSCFG_DL_init(void)
|
||||
SYSCFG_DL_GPIO_init();
|
||||
/* Module-Specific Initializations*/
|
||||
SYSCFG_DL_SYSCTL_init();
|
||||
SYSCFG_DL_PWM_0_init();
|
||||
SYSCFG_DL_I2C_1_init();
|
||||
SYSCFG_DL_UART_0_init();
|
||||
SYSCFG_DL_DMA_init();
|
||||
/* Ensure backup structures have no valid state */
|
||||
gPWM_0Backup.backupRdy = false;
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
* User should take care to save and restore register configuration in application.
|
||||
* See Retention Configuration section for more details.
|
||||
*/
|
||||
SYSCONFIG_WEAK bool SYSCFG_DL_saveConfiguration(void)
|
||||
{
|
||||
bool retStatus = true;
|
||||
|
||||
retStatus &= DL_TimerA_saveConfiguration(PWM_0_INST, &gPWM_0Backup);
|
||||
|
||||
return retStatus;
|
||||
}
|
||||
|
||||
|
||||
SYSCONFIG_WEAK bool SYSCFG_DL_restoreConfiguration(void)
|
||||
{
|
||||
bool retStatus = true;
|
||||
|
||||
retStatus &= DL_TimerA_restoreConfiguration(PWM_0_INST, &gPWM_0Backup, false);
|
||||
|
||||
return retStatus;
|
||||
}
|
||||
|
||||
SYSCONFIG_WEAK void SYSCFG_DL_initPower(void)
|
||||
{
|
||||
DL_GPIO_reset(GPIOA);
|
||||
DL_GPIO_reset(GPIOB);
|
||||
DL_TimerA_reset(PWM_0_INST);
|
||||
DL_I2C_reset(I2C_1_INST);
|
||||
DL_UART_Main_reset(UART_0_INST);
|
||||
|
||||
|
||||
DL_GPIO_enablePower(GPIOA);
|
||||
DL_GPIO_enablePower(GPIOB);
|
||||
DL_TimerA_enablePower(PWM_0_INST);
|
||||
DL_I2C_enablePower(I2C_1_INST);
|
||||
DL_UART_Main_enablePower(UART_0_INST);
|
||||
|
||||
@@ -76,6 +105,13 @@ SYSCONFIG_WEAK void SYSCFG_DL_initPower(void)
|
||||
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_initPeripheralOutputFunction(GPIO_PWM_0_C1_IOMUX,GPIO_PWM_0_C1_IOMUX_FUNC);
|
||||
DL_GPIO_enableOutput(GPIO_PWM_0_C1_PORT, GPIO_PWM_0_C1_PIN);
|
||||
DL_GPIO_initPeripheralOutputFunction(GPIO_PWM_0_C2_IOMUX,GPIO_PWM_0_C2_IOMUX_FUNC);
|
||||
DL_GPIO_enableOutput(GPIO_PWM_0_C2_PORT, GPIO_PWM_0_C2_PIN);
|
||||
|
||||
DL_GPIO_initPeripheralInputFunctionFeatures(GPIO_I2C_1_IOMUX_SDA,
|
||||
GPIO_I2C_1_IOMUX_SDA_FUNC, DL_GPIO_INVERSION_DISABLE,
|
||||
DL_GPIO_RESISTOR_NONE, DL_GPIO_HYSTERESIS_DISABLE,
|
||||
@@ -116,6 +152,66 @@ SYSCONFIG_WEAK void SYSCFG_DL_SYSCTL_init(void)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Timer clock configuration to be sourced by / 2 (16000000 Hz)
|
||||
* timerClkFreq = (timerClkSrc / (timerClkDivRatio * (timerClkPrescale + 1)))
|
||||
* 16000000 Hz = 16000000 Hz / (2 * (0 + 1))
|
||||
*/
|
||||
static const DL_TimerA_ClockConfig gPWM_0ClockConfig = {
|
||||
.clockSel = DL_TIMER_CLOCK_BUSCLK,
|
||||
.divideRatio = DL_TIMER_CLOCK_DIVIDE_2,
|
||||
.prescale = 0U
|
||||
};
|
||||
|
||||
static const DL_TimerA_PWMConfig gPWM_0Config = {
|
||||
.pwmMode = DL_TIMER_PWM_MODE_CENTER_ALIGN,
|
||||
.period = 2000,
|
||||
.isTimerWithFourCC = true,
|
||||
.startTimer = DL_TIMER_STOP,
|
||||
};
|
||||
|
||||
SYSCONFIG_WEAK void SYSCFG_DL_PWM_0_init(void) {
|
||||
|
||||
DL_TimerA_setClockConfig(
|
||||
PWM_0_INST, (DL_TimerA_ClockConfig *) &gPWM_0ClockConfig);
|
||||
|
||||
DL_TimerA_initPWMMode(
|
||||
PWM_0_INST, (DL_TimerA_PWMConfig *) &gPWM_0Config);
|
||||
|
||||
// Set Counter control to the smallest CC index being used
|
||||
DL_TimerA_setCounterControl(PWM_0_INST,DL_TIMER_CZC_CCCTL0_ZCOND,DL_TIMER_CAC_CCCTL0_ACOND,DL_TIMER_CLC_CCCTL0_LCOND);
|
||||
|
||||
DL_TimerA_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_TIMERA_CAPTURE_COMPARE_0_INDEX);
|
||||
|
||||
DL_TimerA_setCaptCompUpdateMethod(PWM_0_INST, DL_TIMER_CC_UPDATE_METHOD_IMMEDIATE, DL_TIMERA_CAPTURE_COMPARE_0_INDEX);
|
||||
DL_TimerA_setCaptureCompareValue(PWM_0_INST, 750, DL_TIMER_CC_0_INDEX);
|
||||
|
||||
DL_TimerA_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_TIMERA_CAPTURE_COMPARE_1_INDEX);
|
||||
|
||||
DL_TimerA_setCaptCompUpdateMethod(PWM_0_INST, DL_TIMER_CC_UPDATE_METHOD_IMMEDIATE, DL_TIMERA_CAPTURE_COMPARE_1_INDEX);
|
||||
DL_TimerA_setCaptureCompareValue(PWM_0_INST, 500, DL_TIMER_CC_1_INDEX);
|
||||
|
||||
DL_TimerA_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_TIMERA_CAPTURE_COMPARE_2_INDEX);
|
||||
|
||||
DL_TimerA_setCaptCompUpdateMethod(PWM_0_INST, DL_TIMER_CC_UPDATE_METHOD_IMMEDIATE, DL_TIMERA_CAPTURE_COMPARE_2_INDEX);
|
||||
DL_TimerA_setCaptureCompareValue(PWM_0_INST, 250, DL_TIMER_CC_2_INDEX);
|
||||
|
||||
DL_TimerA_enableClock(PWM_0_INST);
|
||||
|
||||
|
||||
|
||||
DL_TimerA_setCCPDirection(PWM_0_INST , DL_TIMER_CC0_OUTPUT | DL_TIMER_CC1_OUTPUT | DL_TIMER_CC2_OUTPUT );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
static const DL_I2C_ClockConfig gI2C_1ClockConfig = {
|
||||
.clockSel = DL_I2C_CLOCK_BUSCLK,
|
||||
.divideRatio = DL_I2C_CLOCK_DIVIDE_1,
|
||||
|
||||
Reference in New Issue
Block a user