代码拉取完成,页面将自动刷新
/*
* 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 MSPM0G350X
* by the SysConfig tool.
*/
#include "ti_msp_dl_config.h"
DL_TimerA_backupConfig gPWM_FRONT_MOTORBackup;
DL_TimerA_backupConfig gTIMER_0Backup;
/*
* ======== 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_FRONT_MOTOR_init();
SYSCFG_DL_TIMER_0_init();
SYSCFG_DL_UART_DEBUG_init();
SYSCFG_DL_UART_JY61P_init();
SYSCFG_DL_SYSTICK_init();
/* Ensure backup structures have no valid state */
gPWM_FRONT_MOTORBackup.backupRdy = false;
gTIMER_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_FRONT_MOTOR_INST, &gPWM_FRONT_MOTORBackup);
retStatus &= DL_TimerA_saveConfiguration(TIMER_0_INST, &gTIMER_0Backup);
return retStatus;
}
SYSCONFIG_WEAK bool SYSCFG_DL_restoreConfiguration(void)
{
bool retStatus = true;
retStatus &= DL_TimerA_restoreConfiguration(PWM_FRONT_MOTOR_INST, &gPWM_FRONT_MOTORBackup, false);
retStatus &= DL_TimerA_restoreConfiguration(TIMER_0_INST, &gTIMER_0Backup, false);
return retStatus;
}
SYSCONFIG_WEAK void SYSCFG_DL_initPower(void)
{
DL_GPIO_reset(GPIOA);
DL_GPIO_reset(GPIOB);
DL_TimerA_reset(PWM_FRONT_MOTOR_INST);
DL_TimerA_reset(TIMER_0_INST);
DL_UART_Main_reset(UART_DEBUG_INST);
DL_UART_Main_reset(UART_JY61P_INST);
DL_GPIO_enablePower(GPIOA);
DL_GPIO_enablePower(GPIOB);
DL_TimerA_enablePower(PWM_FRONT_MOTOR_INST);
DL_TimerA_enablePower(TIMER_0_INST);
DL_UART_Main_enablePower(UART_DEBUG_INST);
DL_UART_Main_enablePower(UART_JY61P_INST);
delay_cycles(POWER_STARTUP_DELAY);
}
SYSCONFIG_WEAK void SYSCFG_DL_GPIO_init(void)
{
DL_GPIO_initPeripheralOutputFunction(GPIO_PWM_FRONT_MOTOR_C0_IOMUX,GPIO_PWM_FRONT_MOTOR_C0_IOMUX_FUNC);
DL_GPIO_enableOutput(GPIO_PWM_FRONT_MOTOR_C0_PORT, GPIO_PWM_FRONT_MOTOR_C0_PIN);
DL_GPIO_initPeripheralOutputFunction(GPIO_PWM_FRONT_MOTOR_C1_IOMUX,GPIO_PWM_FRONT_MOTOR_C1_IOMUX_FUNC);
DL_GPIO_enableOutput(GPIO_PWM_FRONT_MOTOR_C1_PORT, GPIO_PWM_FRONT_MOTOR_C1_PIN);
DL_GPIO_initPeripheralOutputFunction(
GPIO_UART_DEBUG_IOMUX_TX, GPIO_UART_DEBUG_IOMUX_TX_FUNC);
DL_GPIO_initPeripheralInputFunction(
GPIO_UART_DEBUG_IOMUX_RX, GPIO_UART_DEBUG_IOMUX_RX_FUNC);
DL_GPIO_initPeripheralOutputFunction(
GPIO_UART_JY61P_IOMUX_TX, GPIO_UART_JY61P_IOMUX_TX_FUNC);
DL_GPIO_initPeripheralInputFunction(
GPIO_UART_JY61P_IOMUX_RX, GPIO_UART_JY61P_IOMUX_RX_FUNC);
DL_GPIO_initDigitalOutput(GPIO_GRP_MISC_PIN_BEEP_IOMUX);
DL_GPIO_initDigitalOutput(GPIO_GRP_MISC_PIN_LED_IOMUX);
DL_GPIO_initDigitalInputFeatures(GPIO_GRP_MISC_PIN_KEY_1_IOMUX,
DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_PULL_UP,
DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
DL_GPIO_initDigitalInputFeatures(GPIO_GRP_MISC_PIN_KEY_2_IOMUX,
DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_PULL_UP,
DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
DL_GPIO_initDigitalOutput(GPIO_GRP_MOTOR_PIN_FRONT_RIGHT_A_IOMUX);
DL_GPIO_initDigitalOutput(GPIO_GRP_MOTOR_PIN_FRONT_LEFT_A_IOMUX);
DL_GPIO_initDigitalOutput(GPIO_GRP_MOTOR_PIN_FRONT_RIGHT_B_IOMUX);
DL_GPIO_initDigitalOutput(GPIO_GRP_MOTOR_PIN_FRONT_LEFT_B_IOMUX);
DL_GPIO_initDigitalInput(GPIO_GRP_ENCODER_PIN_E1A_IOMUX);
DL_GPIO_initDigitalInput(GPIO_GRP_ENCODER_PIN_E1B_IOMUX);
DL_GPIO_initDigitalInput(GPIO_GRP_ENCODER_PIN_E2A_IOMUX);
DL_GPIO_initDigitalInput(GPIO_GRP_ENCODER_PIN_E2B_IOMUX);
DL_GPIO_initDigitalInputFeatures(GPIO_GRP_GRAY_PIN_SENSER_1_IOMUX,
DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_PULL_UP,
DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
DL_GPIO_initDigitalInputFeatures(GPIO_GRP_GRAY_PIN_SENSER_2_IOMUX,
DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_PULL_UP,
DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
DL_GPIO_initDigitalInputFeatures(GPIO_GRP_GRAY_PIN_SENSER_3_IOMUX,
DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_PULL_UP,
DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
DL_GPIO_initDigitalInputFeatures(GPIO_GRP_GRAY_PIN_SENSER_4_IOMUX,
DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_PULL_UP,
DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
DL_GPIO_initDigitalInputFeatures(GPIO_GRP_GRAY_PIN_SENSER_5_IOMUX,
DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_PULL_UP,
DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_DISABLE);
DL_GPIO_initDigitalOutput(GPIO_GRP_GRAY_PIN_SENSER_6_IOMUX);
DL_GPIO_initDigitalOutput(GPIO_GRP_GRAY_PIN_SENSER_7_IOMUX);
DL_GPIO_initDigitalOutput(GPIO_GRP_GRAY_PIN_SENSER_8_IOMUX);
DL_GPIO_initDigitalOutput(GPIO_GRP_OLED_PIN_SCL_IOMUX);
DL_GPIO_initDigitalOutput(GPIO_GRP_OLED_PIN_SDA_IOMUX);
DL_GPIO_clearPins(GPIOA, GPIO_GRP_MOTOR_PIN_FRONT_RIGHT_A_PIN |
GPIO_GRP_MOTOR_PIN_FRONT_LEFT_A_PIN |
GPIO_GRP_MOTOR_PIN_FRONT_RIGHT_B_PIN |
GPIO_GRP_MOTOR_PIN_FRONT_LEFT_B_PIN |
GPIO_GRP_GRAY_PIN_SENSER_6_PIN |
GPIO_GRP_GRAY_PIN_SENSER_7_PIN |
GPIO_GRP_GRAY_PIN_SENSER_8_PIN |
GPIO_GRP_OLED_PIN_SCL_PIN |
GPIO_GRP_OLED_PIN_SDA_PIN);
DL_GPIO_enableOutput(GPIOA, GPIO_GRP_MOTOR_PIN_FRONT_RIGHT_A_PIN |
GPIO_GRP_MOTOR_PIN_FRONT_LEFT_A_PIN |
GPIO_GRP_MOTOR_PIN_FRONT_RIGHT_B_PIN |
GPIO_GRP_MOTOR_PIN_FRONT_LEFT_B_PIN |
GPIO_GRP_GRAY_PIN_SENSER_6_PIN |
GPIO_GRP_GRAY_PIN_SENSER_7_PIN |
GPIO_GRP_GRAY_PIN_SENSER_8_PIN |
GPIO_GRP_OLED_PIN_SCL_PIN |
GPIO_GRP_OLED_PIN_SDA_PIN);
DL_GPIO_clearPins(GPIOB, GPIO_GRP_MISC_PIN_BEEP_PIN);
DL_GPIO_setPins(GPIOB, GPIO_GRP_MISC_PIN_LED_PIN);
DL_GPIO_enableOutput(GPIOB, GPIO_GRP_MISC_PIN_BEEP_PIN |
GPIO_GRP_MISC_PIN_LED_PIN);
DL_GPIO_setUpperPinsPolarity(GPIOB, DL_GPIO_PIN_18_EDGE_RISE |
DL_GPIO_PIN_20_EDGE_RISE);
DL_GPIO_clearInterruptStatus(GPIOB, GPIO_GRP_ENCODER_PIN_E1A_PIN |
GPIO_GRP_ENCODER_PIN_E2A_PIN);
DL_GPIO_enableInterrupt(GPIOB, GPIO_GRP_ENCODER_PIN_E1A_PIN |
GPIO_GRP_ENCODER_PIN_E2A_PIN);
}
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_setSYSOSCFreq(DL_SYSCTL_SYSOSC_FREQ_BASE);
}
/*
* 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_TimerA_ClockConfig gPWM_FRONT_MOTORClockConfig = {
.clockSel = DL_TIMER_CLOCK_BUSCLK,
.divideRatio = DL_TIMER_CLOCK_DIVIDE_1,
.prescale = 0U
};
static const DL_TimerA_PWMConfig gPWM_FRONT_MOTORConfig = {
.pwmMode = DL_TIMER_PWM_MODE_EDGE_ALIGN_UP,
.period = 3200,
.isTimerWithFourCC = false,
.startTimer = DL_TIMER_STOP,
};
SYSCONFIG_WEAK void SYSCFG_DL_PWM_FRONT_MOTOR_init(void) {
DL_TimerA_setClockConfig(
PWM_FRONT_MOTOR_INST, (DL_TimerA_ClockConfig *) &gPWM_FRONT_MOTORClockConfig);
DL_TimerA_initPWMMode(
PWM_FRONT_MOTOR_INST, (DL_TimerA_PWMConfig *) &gPWM_FRONT_MOTORConfig);
DL_TimerA_setCaptureCompareOutCtl(PWM_FRONT_MOTOR_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_FRONT_MOTOR_INST, DL_TIMER_CC_UPDATE_METHOD_IMMEDIATE, DL_TIMERA_CAPTURE_COMPARE_0_INDEX);
DL_TimerA_setCaptureCompareValue(PWM_FRONT_MOTOR_INST, 0, DL_TIMER_CC_0_INDEX);
DL_TimerA_setCaptureCompareOutCtl(PWM_FRONT_MOTOR_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_FRONT_MOTOR_INST, DL_TIMER_CC_UPDATE_METHOD_IMMEDIATE, DL_TIMERA_CAPTURE_COMPARE_1_INDEX);
DL_TimerA_setCaptureCompareValue(PWM_FRONT_MOTOR_INST, 0, DL_TIMER_CC_1_INDEX);
DL_TimerA_enableClock(PWM_FRONT_MOTOR_INST);
DL_TimerA_setCCPDirection(PWM_FRONT_MOTOR_INST , DL_TIMER_CC0_OUTPUT | DL_TIMER_CC1_OUTPUT );
}
/*
* Timer clock configuration to be sourced by BUSCLK / (16000000 Hz)
* timerClkFreq = (timerClkSrc / (timerClkDivRatio * (timerClkPrescale + 1)))
* 1000000 Hz = 16000000 Hz / (2 * (15 + 1))
*/
static const DL_TimerA_ClockConfig gTIMER_0ClockConfig = {
.clockSel = DL_TIMER_CLOCK_BUSCLK,
.divideRatio = DL_TIMER_CLOCK_DIVIDE_2,
.prescale = 15U,
};
/*
* Timer load value (where the counter starts from) is calculated as (timerPeriod * timerClockFreq) - 1
* TIMER_0_INST_LOAD_VALUE = (10 ms * 1000000 Hz) - 1
*/
static const DL_TimerA_TimerConfig gTIMER_0TimerConfig = {
.period = TIMER_0_INST_LOAD_VALUE,
.timerMode = DL_TIMER_TIMER_MODE_PERIODIC,
.startTimer = DL_TIMER_STOP,
};
SYSCONFIG_WEAK void SYSCFG_DL_TIMER_0_init(void) {
DL_TimerA_setClockConfig(TIMER_0_INST,
(DL_TimerA_ClockConfig *) &gTIMER_0ClockConfig);
DL_TimerA_initTimerMode(TIMER_0_INST,
(DL_TimerA_TimerConfig *) &gTIMER_0TimerConfig);
DL_TimerA_enableInterrupt(TIMER_0_INST , DL_TIMERA_INTERRUPT_ZERO_EVENT);
DL_TimerA_enableClock(TIMER_0_INST);
}
static const DL_UART_Main_ClockConfig gUART_DEBUGClockConfig = {
.clockSel = DL_UART_MAIN_CLOCK_BUSCLK,
.divideRatio = DL_UART_MAIN_CLOCK_DIVIDE_RATIO_1
};
static const DL_UART_Main_Config gUART_DEBUGConfig = {
.mode = DL_UART_MAIN_MODE_NORMAL,
.direction = DL_UART_MAIN_DIRECTION_TX_RX,
.flowControl = DL_UART_MAIN_FLOW_CONTROL_NONE,
.parity = DL_UART_MAIN_PARITY_NONE,
.wordLength = DL_UART_MAIN_WORD_LENGTH_8_BITS,
.stopBits = DL_UART_MAIN_STOP_BITS_ONE
};
SYSCONFIG_WEAK void SYSCFG_DL_UART_DEBUG_init(void)
{
DL_UART_Main_setClockConfig(UART_DEBUG_INST, (DL_UART_Main_ClockConfig *) &gUART_DEBUGClockConfig);
DL_UART_Main_init(UART_DEBUG_INST, (DL_UART_Main_Config *) &gUART_DEBUGConfig);
/*
* Configure baud rate by setting oversampling and baud rate divisors.
* Target baud rate: 115200
* Actual baud rate: 115211.52
*/
DL_UART_Main_setOversampling(UART_DEBUG_INST, DL_UART_OVERSAMPLING_RATE_16X);
DL_UART_Main_setBaudRateDivisor(UART_DEBUG_INST, UART_DEBUG_IBRD_32_MHZ_115200_BAUD, UART_DEBUG_FBRD_32_MHZ_115200_BAUD);
/* Configure Interrupts */
DL_UART_Main_enableInterrupt(UART_DEBUG_INST,
DL_UART_MAIN_INTERRUPT_RX);
DL_UART_Main_enable(UART_DEBUG_INST);
}
static const DL_UART_Main_ClockConfig gUART_JY61PClockConfig = {
.clockSel = DL_UART_MAIN_CLOCK_BUSCLK,
.divideRatio = DL_UART_MAIN_CLOCK_DIVIDE_RATIO_1
};
static const DL_UART_Main_Config gUART_JY61PConfig = {
.mode = DL_UART_MAIN_MODE_NORMAL,
.direction = DL_UART_MAIN_DIRECTION_TX_RX,
.flowControl = DL_UART_MAIN_FLOW_CONTROL_NONE,
.parity = DL_UART_MAIN_PARITY_NONE,
.wordLength = DL_UART_MAIN_WORD_LENGTH_8_BITS,
.stopBits = DL_UART_MAIN_STOP_BITS_ONE
};
SYSCONFIG_WEAK void SYSCFG_DL_UART_JY61P_init(void)
{
DL_UART_Main_setClockConfig(UART_JY61P_INST, (DL_UART_Main_ClockConfig *) &gUART_JY61PClockConfig);
DL_UART_Main_init(UART_JY61P_INST, (DL_UART_Main_Config *) &gUART_JY61PConfig);
/*
* Configure baud rate by setting oversampling and baud rate divisors.
* Target baud rate: 9600
* Actual baud rate: 9600.24
*/
DL_UART_Main_setOversampling(UART_JY61P_INST, DL_UART_OVERSAMPLING_RATE_16X);
DL_UART_Main_setBaudRateDivisor(UART_JY61P_INST, UART_JY61P_IBRD_32_MHZ_9600_BAUD, UART_JY61P_FBRD_32_MHZ_9600_BAUD);
/* Configure Interrupts */
DL_UART_Main_enableInterrupt(UART_JY61P_INST,
DL_UART_MAIN_INTERRUPT_RX);
DL_UART_Main_enable(UART_JY61P_INST);
}
SYSCONFIG_WEAK void SYSCFG_DL_SYSTICK_init(void)
{
/* Initialize the period to 1.00 ms */
DL_SYSTICK_init(32000);
DL_SYSTICK_enableInterrupt();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。