From ae9f390667c69dc87187cfa9eb08ac057280e992 Mon Sep 17 00:00:00 2001 From: 4x-tech Date: Mon, 10 Nov 2025 18:05:11 +0800 Subject: [PATCH] mt6701 uart_redirect --- .gitignore | 245 ++++++++++ 3rd/delay.c | 9 + 3rd/delay.h | 7 + 3rd/mt6701.c | 114 +++++ 3rd/mt6701.h | 25 + 3rd/uart_redircet.c | 53 +++ 3rd/uart_redircet.h | 7 + Event.dot | 30 ++ README.html | 115 +++++ README.md | 41 ++ empty.c | 58 +++ empty.syscfg | 79 ++++ keil/empty_LP_MSPM0G3507_nortos_keil.uvprojx | 463 +++++++++++++++++++ keil/mspm0g3507.sct | 61 +++ keil/startup_mspm0g350x_uvision.s | 252 ++++++++++ ti_msp_dl_config.c | 202 ++++++++ ti_msp_dl_config.h | 148 ++++++ 17 files changed, 1909 insertions(+) create mode 100644 .gitignore create mode 100644 3rd/delay.c create mode 100644 3rd/delay.h create mode 100644 3rd/mt6701.c create mode 100644 3rd/mt6701.h create mode 100644 3rd/uart_redircet.c create mode 100644 3rd/uart_redircet.h create mode 100644 Event.dot create mode 100644 README.html create mode 100644 README.md create mode 100644 empty.c create mode 100644 empty.syscfg create mode 100644 keil/empty_LP_MSPM0G3507_nortos_keil.uvprojx create mode 100644 keil/mspm0g3507.sct create mode 100644 keil/startup_mspm0g350x_uvision.s create mode 100644 ti_msp_dl_config.c create mode 100644 ti_msp_dl_config.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..edbca82 --- /dev/null +++ b/.gitignore @@ -0,0 +1,245 @@ +# 2025/9/11 15:36 更新 +# ================================ +# 通用 .gitignore 模板(Keil 与 Renesas 工程适用) +# 适用于 Keil MDK-ARM 以及 Renesas e² studio / CS+ 工程 +# 文件中部分忽略规则为自定义,可根据项目实际需求进行调整 +# ================================ + + +# ================================ +# 构建目录 +# ================================ +# Keil 默认构建输出目录(包含中间文件) +MDK-ARM/ +# 自定义目标文件目录(如有) +Objects/ +# 自定义列表文件目录(如有) +Listings/ +binHEBING +# VS Code Local History插件生成目录 +.history/ +.lh/ +**.settings +*.launch + +# ================================ +# Keil MDK 工程专用忽略规则 +# ================================ + +# ================================ +# 工程文件与配置 +# ================================ +# 用户工程选项文件(包含本地调试配置,建议忽略) +*.uvoptx +# 用户界面布局文件(如窗口位置等,需忽略) +*.uvguix.* +# # 工程配置文件(建议提交时酌情考虑) +# *.uvprojx +# 备份文件(如工程文件自动备份) +*.bak +# 交叉引用文件(编译生成) +*.crf +# 依赖文件(编译生成) +*.d +# 调试配置文件 +*.scvd +# Run Time Environment 生成文件 +*.rte +# Vim 临时文件 +*.swp +# Vim 临时文件 +*.swo + +#================================ +# 编译输出文件 +# ================================ +# 目标文件(编译生成) +*.o +# 目标文件(Windows 风格) +*.obj +# ELF 格式可执行文件(含调试信息) +*.axf +# HEX 烧录文件 +*.hex +# 二进制镜像文件 +*.bin +# 内存映射文件(链接生成) +*.map +# 汇编列表文件(编译生成) +*.lst +# GCC 生成的可执行文件 +*.elf +# 通用输出文件 +*.out +# 依赖文件(自动生成) +*.d +*.dep + +# ================================ +# 调试与临时文件 +# ================================ +# 调试脚本(可能包含本地硬件配置) +*.ini +# 编译日志文件 +*.log +# 调试信息临时文件 +*.dbg +# 调试配置数据库 +*.cdb +# Trace 调试配置文件 +*.tracespec +# 数据库缓存 +*.db +# Batch 脚本文件(本地配置) Keil/ARMCC 自动生成的编译批处理脚本 +*.BAT + +# ================================ +# IDE 自动生成文件 +# ================================ +# 多项目工作区文件(如有) +*.uvmpw +# 旧版本依赖文件 +*.dep +# 编译过程日志文件 +*.plg +# J-Link 调试脚本(本地配置) +*.jlink + +# 其他临时文件 +# 编辑器临时文件(如 Keil 自动保存) +*.~* +# 临时文件 +*.tmp +# # 常见构建输出目录 +build/ +/EWARM/** +**/MDK/output/** +**/MDK/output/release/** +/output/ +/Debug/ +/dist/ + + +# ================================ +# 通用忽略规则(补充) +# ================================ +# 用户工具链配置(如 VS Code 等) +*.user +# VS Code 配置目录(如使用其他编辑器) +.vscode/ +# JetBrains IDE 配置目录 +.idea/ +# Eclipse 配置 +/.settings/ +# Eclipse C 项目配置 +/.cproject +# Eclipse 项目文件 +/.project +# macOS 系统文件 +.DS_Store +# Windows 缩略图缓存 +Thumbs.db +#这是 EIDE (Embedded IDE for VSCode) 自动生成的工程上下文配置文件。 +.eide.usr.ctx.json +# 这是 Clang 工具链的代码格式化配置文件。 +.clang-format +# 这是 Windows 自动生成的文件,主要存储文件夹显示属性(比如自定义图标、排序方式)。 +desktop.ini + +# ================================ +# IAR Embedded Workbench 工程文件 +# ================================ +# IAR 工具链文件 +/*.ewt +# IAR 调试配置文件 +/*.ewd +# IAR 工程文件(建议提交时酌情考虑) +/*.ewp +# IAR 工作区文件 +/*.eww +# IAR 编译输出 +/Obj/ +# IAR 汇编清单 +/Lst/ +# IAR 工程局部设置 +/settings/ + +# ================================ +# CMSIS Pack / 芯片支持包 +# ================================ +# IDE 自动下载的芯片支持包,无需提交 +/.pack/** + + +# ================================ +# Renesas 瑞萨工程专用忽略规则 +# ================================ +# e² studio (Eclipse-based) IDE 配置(本地环境相关,忽略) + +# Eclipse 项目本地设置 +/.settings/ +# Eclipse 工作区元数据 +/.metadata/ +# 启动/调试配置文件(本地生成) +/*.launch +# 远程调试临时文件 +/RemoteSystemsTempFiles/ + +# CS+ (CubeSuite+) IDE 文件(自动生成或本地相关,忽略) +# 绝对路径文件 +*.abs +# 编译中间文件 +*.poc +# 自动生成的 include 文件 +*.inc +# 工程信息文件(本地环境相关) +*.ipr +# 旧备份文件 +*.org +# 系统文件 +*.sys +# 构建日志 +*.log +# Motorola S-Record 固件文件 +*.mot +# CS+ 自动生成的编译中间文件 / 增量编译缓存 +*.mtud + +# Renesas Pack / Device 文件(自动下载,无需提交) +# MCU Pack 文件 +*.pack +# 调试配置文件(本地机器相关) +.rlaunch +# 系统视图描述文件(自动生成) +*.scvd + +# 临时 / 备份文件 +# 编辑器临时文件 +*~ +# 备份文件 +*.bak +# Vim 临时文件 +*.swp +# Vim 临时文件 +*.swo +# 临时文件 +*.tmp +# 用户本地配置 +*.user +# 数据库缓存 +*.db + + +# 操作系统相关 +# macOS Finder 缓存 +.DS_Store +# Windows 缩略图缓存 +Thumbs.db +# Windows 文件夹属性 +desktop.ini + +# 汇编源文件、源码文件和必要工程文件除外,其他产物均忽略 + +gcc/ +iar/ +ticlang/ \ No newline at end of file diff --git a/3rd/delay.c b/3rd/delay.c new file mode 100644 index 0000000..9ae742a --- /dev/null +++ b/3rd/delay.c @@ -0,0 +1,9 @@ +#include "Delay.h" +#include "ti_msp_dl_config.h" +void delay_ms(uint16_t ms) +{ + while(ms--) + { + delay_cycles(CPUCLK_FREQ / 1000); + } +} diff --git a/3rd/delay.h b/3rd/delay.h new file mode 100644 index 0000000..1cd521f --- /dev/null +++ b/3rd/delay.h @@ -0,0 +1,7 @@ +#ifndef delay_h +#define delay_h +#include + +void delay_ms(uint16_t ms); + +#endif /* ti_msp_dl_config_h */ \ No newline at end of file diff --git a/3rd/mt6701.c b/3rd/mt6701.c new file mode 100644 index 0000000..93f796c --- /dev/null +++ b/3rd/mt6701.c @@ -0,0 +1,114 @@ +#include "MT6701.h" +#include "ti_msp_dl_config.h" + +volatile int16_t angle; +volatile float angle_f; + +/* Data sent to the Target */ +uint8_t gTxPacket[I2C_TX_PACKET_SIZE] = +{ + 0x03 +}; + +/* Data received from Target */ +volatile uint8_t gRxPacket[I2C_RX_PACKET_SIZE]; + +/* I2C clock configuration */ +DL_I2C_ClockConfig gI2CclockConfig; +/* Frequency of selected I2C clock*/ +volatile uint32_t gClockSelFreq; + +/* Cycles to delay after controller transfer initiated */ +volatile uint32_t gDelayCycles; + +/* I2C Target address */ +#define I2C_TARGET_ADDRESS (0x06) + +void MT6701_iic_read_angel(void) +{ + /* Get I2C clock source and clock divider to use for delay cycle calculation */ + DL_I2C_getClockConfig(I2C_1_INST, &gI2CclockConfig); + switch(gI2CclockConfig.clockSel) + { + case DL_I2C_CLOCK_BUSCLK: + gClockSelFreq = 32000000; + break; + case DL_I2C_CLOCK_MFCLK: + gClockSelFreq = 4000000; + break; + default: + break; + } + /* + * Calculate number of clock cycles to delay after controller transfer initiated + * gDelayCycles = 3 I2C functional clock cycles + * gDelayCycles = 3 * I2C clock divider * (CPU clock freq / I2C clock freq) + */ + gDelayCycles = (3 * (gI2CclockConfig.divideRatio + 1)) * + (CPUCLK_FREQ / gClockSelFreq); + + /* + * Fill FIFO with data. This example will send a MAX of 8 bytes since it + * doesn't handle the case where FIFO is full + */ + DL_I2C_fillControllerTXFIFO(I2C_1_INST, &gTxPacket[0], I2C_TX_PACKET_SIZE); + + /* Wait for I2C to be Idle */ + while(!( + DL_I2C_getControllerStatus(I2C_1_INST) & DL_I2C_CONTROLLER_STATUS_IDLE)) + ; + + /* Send the packet to the controller. + * This function will send Start + Stop automatically. + */ + DL_I2C_startControllerTransfer(I2C_1_INST, I2C_TARGET_ADDRESS, + DL_I2C_CONTROLLER_DIRECTION_TX, I2C_TX_PACKET_SIZE); + + /* Workaround for errata I2C_ERR_13 */ + delay_cycles(gDelayCycles); + + /* Poll until the Controller writes all bytes */ + while( + DL_I2C_getControllerStatus(I2C_1_INST) & DL_I2C_CONTROLLER_STATUS_BUSY) + ; + + /* Trap if there was an error */ + if(DL_I2C_getControllerStatus(I2C_1_INST) & + DL_I2C_CONTROLLER_STATUS_ERROR) + { + /* LED will remain high if there is an error */ + __BKPT(0); + } + + /* Wait for I2C to be Idle */ + while(!( + DL_I2C_getControllerStatus(I2C_1_INST) & DL_I2C_CONTROLLER_STATUS_IDLE)) + ; + + /* Add delay between transfers */ + delay_cycles(1000); + + /* Send a read request to Target */ + DL_I2C_startControllerTransfer(I2C_1_INST, I2C_TARGET_ADDRESS, + DL_I2C_CONTROLLER_DIRECTION_RX, I2C_RX_PACKET_SIZE); + + /* + * Receive all bytes from target. LED will remain high if not all bytes + * are received + */ + for(uint8_t i = 0; i < I2C_RX_PACKET_SIZE; i++) + { + while(DL_I2C_isControllerRXFIFOEmpty(I2C_1_INST)) + ; + gRxPacket[i] = DL_I2C_receiveControllerData(I2C_1_INST); + } +} + + + +void MT6701_get_angle_degree(void) +{ + MT6701_iic_read_angel(); + angle = ((int16_t)gRxPacket[0] << 6) | (gRxPacket[1] >> 2); + angle_f = (float)angle * 360 / 16384; +} diff --git a/3rd/mt6701.h b/3rd/mt6701.h new file mode 100644 index 0000000..05620bc --- /dev/null +++ b/3rd/mt6701.h @@ -0,0 +1,25 @@ +#ifndef MT6701_H +#define MT6701_H + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif +#define I2C_TX_PACKET_SIZE (1) + +/* + * Number of bytes to received from target. + * This example uses FIFO with polling, and the maximum FIFO size is 8. + * Refer to interrupt examples to handle larger packets + */ +#define I2C_RX_PACKET_SIZE (2) +void MT6701_iic_read_angel(void); +void MT6701_get_angle_degree(void); + +#ifdef __cplusplus +} +#endif + +#endif /* MT6701_H */ diff --git a/3rd/uart_redircet.c b/3rd/uart_redircet.c new file mode 100644 index 0000000..817fc92 --- /dev/null +++ b/3rd/uart_redircet.c @@ -0,0 +1,53 @@ +#include "ti_msp_dl_config.h" +#include +#include + + +/* ARM Compiler 6 半主机模式禁用声明 */ +#if (__ARMCC_VERSION >= 6010050) +__asm(".global __use_no_semihosting\n\t"); +__asm(".global __ARM_use_no_argv \n\t"); +#else +#pragma import(__use_no_semihosting) +#endif + +FILE __stdout; + +/* 系统退出函数实现 */ +void _sys_exit(int x) +{ + x = x; + while (1) + ; /* 死循环防止程序异常退出 */ +} + +/* ARM Compiler 6 printf重定向实现 */ +int fputc(int c, FILE *stream) +{ + /* 等待UART发送缓冲区就绪 */ + while (DL_UART_Main_isBusy(UART_0_INST)) + ; + + /* 发送字符 */ + DL_UART_Main_transmitData(UART_0_INST, (uint8_t)c); + return c; +} + +int fputs(const char *restrict s, FILE *restrict stream) +{ + uint16_t i, len; + len = strlen(s); + for (i = 0; i < len; i++) + { + fputc(s[i], stream); + } + return len; +} + +int puts(const char *_ptr) +{ + int count = fputs(_ptr, stdout); + count += fputc('\n', stdout); /* 自动添加换行 */ + return count; +} + diff --git a/3rd/uart_redircet.h b/3rd/uart_redircet.h new file mode 100644 index 0000000..a64f228 --- /dev/null +++ b/3rd/uart_redircet.h @@ -0,0 +1,7 @@ +#ifndef Uart_h +#define Uart_h +#include + +void UART_Console_write(const uint8_t *data, uint16_t size); + +#endif /* ti_msp_dl_config_h */ \ No newline at end of file diff --git a/Event.dot b/Event.dot new file mode 100644 index 0000000..498c9f0 --- /dev/null +++ b/Event.dot @@ -0,0 +1,30 @@ + + +digraph H { + + parent [ + shape=plaintext + label=< + + + + + + + + + + + + + + + + + + +
Channel 1Channel 2Channel 3Channel 4Channel 5Channel 6Channel 7Channel 8Channel 9Channel 10Channel 11Channel 12Channel 13Channel 14Channel 15
+ >]; + + +} diff --git a/README.html b/README.html new file mode 100644 index 0000000..4180f14 --- /dev/null +++ b/README.html @@ -0,0 +1,115 @@ + + + + + + + Readme + + + + + + + +
+
+ +
+ +
+
+

Readme

+

Example Summary

+

Empty project using DriverLib. This example shows a basic empty project using DriverLib with just main file and SysConfig initialization.

+

Peripherals & Pin Assignments

+ + + + + + + + + + + + + + + + + + + + + + + + + +
PeripheralPinFunction
SYSCTL
DEBUGSSPA20Debug Clock
DEBUGSSPA19Debug Data In Out
+

BoosterPacks, Board Resources & Jumper Settings

+

Visit LP_MSPM0G3507 for LaunchPad information, including user guide and hardware files.

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
PinPeripheralFunctionLaunchPad PinLaunchPad Settings
PA20DEBUGSSSWCLKN/A
  • PA20 is used by SWD during debugging
    • J101 15:16 ON Connect to XDS-110 SWCLK while debugging
    • J101 15:16 OFF Disconnect from XDS-110 SWCLK if using pin in application
PA19DEBUGSSSWDION/A
  • PA19 is used by SWD during debugging
    • J101 13:14 ON Connect to XDS-110 SWDIO while debugging
    • J101 13:14 OFF Disconnect from XDS-110 SWDIO if using pin in application
+

Device Migration Recommendations

+

This project was developed for a superset device included in the LP_MSPM0G3507 LaunchPad. Please visit the CCS User’s Guide for information about migrating to other MSPM0 devices.

+

Low-Power Recommendations

+

TI recommends to terminate unused pins by setting the corresponding functions to GPIO and configure the pins to output low or input with internal pullup/pulldown resistor.

+

SysConfig allows developers to easily configure unused pins by selecting BoardConfigure Unused Pins.

+

For more information about jumper configuration to achieve low-power using the MSPM0 LaunchPad, please visit the LP-MSPM0G3507 User’s Guide.

+

Example Usage

+

Compile, load and run the example.

+ +
+ + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..ce86fb3 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +## Example Summary + +Empty project using DriverLib. +This example shows a basic empty project using DriverLib with just main file +and SysConfig initialization. + +## Peripherals & Pin Assignments + +| Peripheral | Pin | Function | +| --- | --- | --- | +| SYSCTL | | | +| DEBUGSS | PA20 | Debug Clock | +| DEBUGSS | PA19 | Debug Data In Out | + +## BoosterPacks, Board Resources & Jumper Settings + +Visit [LP_MSPM0G3507](https://www.ti.com/tool/LP-MSPM0G3507) for LaunchPad information, including user guide and hardware files. + +| Pin | Peripheral | Function | LaunchPad Pin | LaunchPad Settings | +| --- | --- | --- | --- | --- | +| PA20 | DEBUGSS | SWCLK | N/A |
  • PA20 is used by SWD during debugging
    • `J101 15:16 ON` Connect to XDS-110 SWCLK while debugging
    • `J101 15:16 OFF` Disconnect from XDS-110 SWCLK if using pin in application
| +| PA19 | DEBUGSS | SWDIO | N/A |
  • PA19 is used by SWD during debugging
    • `J101 13:14 ON` Connect to XDS-110 SWDIO while debugging
    • `J101 13:14 OFF` Disconnect from XDS-110 SWDIO if using pin in application
| + +### Device Migration Recommendations +This project was developed for a superset device included in the LP_MSPM0G3507 LaunchPad. Please +visit the [CCS User's Guide](https://software-dl.ti.com/msp430/esd/MSPM0-SDK/latest/docs/english/tools/ccs_ide_guide/doc_guide/doc_guide-srcs/ccs_ide_guide.html#sysconfig-project-migration) +for information about migrating to other MSPM0 devices. + +### Low-Power Recommendations +TI recommends to terminate unused pins by setting the corresponding functions to +GPIO and configure the pins to output low or input with internal +pullup/pulldown resistor. + +SysConfig allows developers to easily configure unused pins by selecting **Board**→**Configure Unused Pins**. + +For more information about jumper configuration to achieve low-power using the +MSPM0 LaunchPad, please visit the [LP-MSPM0G3507 User's Guide](https://www.ti.com/lit/slau873). + +## Example Usage + +Compile, load and run the example. diff --git a/empty.c b/empty.c new file mode 100644 index 0000000..0640f58 --- /dev/null +++ b/empty.c @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2021, 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. + */ + +#include "ti_msp_dl_config.h" +#include "Delay.h" +#include "MT6701.h" + +#include +#include + + +extern float angle_f; + +const float num_f = 0.123456f; + +int main(void) +{ + SYSCFG_DL_init(); + NVIC_EnableIRQ(UART_0_INST_INT_IRQN); + while (1) { + DL_GPIO_togglePins(LED_PORT,LED_PA0_PIN); + MT6701_get_angle_degree(); + delay_ms(20); + //printf("test \n"); + printf("angle %.5f \n" , angle_f); + } +} + + diff --git a/empty.syscfg b/empty.syscfg new file mode 100644 index 0000000..f51c5f8 --- /dev/null +++ b/empty.syscfg @@ -0,0 +1,79 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "MSPM0G350X" --part "Default" --package "LQFP-48(PT)" --product "mspm0_sdk@2.07.00.05" + * @v2CliArgs --device "MSPM0G3507" --package "LQFP-48(PT)" --product "mspm0_sdk@2.07.00.05" + * @versions {"tool":"1.25.0+4268"} + */ + +/** + * Import the modules used in this configuration. + */ +const GPIO = scripting.addModule("/ti/driverlib/GPIO", {}, false); +const GPIO1 = GPIO.addInstance(); +const I2C = scripting.addModule("/ti/driverlib/I2C", {}, false); +const I2C1 = I2C.addInstance(); +const SYSCTL = scripting.addModule("/ti/driverlib/SYSCTL"); +const UART = scripting.addModule("/ti/driverlib/UART", {}, false); +const UART1 = UART.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ +const gate7 = system.clockTree["MFCLKGATE"]; +gate7.enable = true; + +GPIO1.$name = "LED"; +GPIO1.associatedPins[0].$name = "PA0"; +GPIO1.associatedPins[0].pin.$assign = "PA0"; + +const Board = scripting.addModule("/ti/driverlib/Board", {}, false); +Board.peripheral.$assign = "DEBUGSS"; +Board.peripheral.swclkPin.$assign = "PA20"; +Board.peripheral.swdioPin.$assign = "PA19"; + +I2C1.$name = "I2C_1"; +I2C1.advAnalogGlitchFilter = "DISABLED"; +I2C1.basicEnableController = true; +I2C1.basicControllerStandardBusSpeed = "Fast"; +I2C1.peripheral.sdaPin.$assign = "PB3"; +I2C1.peripheral.sclPin.$assign = "PB2"; +I2C1.sdaPinConfig.hideOutputInversion = scripting.forceWrite(false); +I2C1.sdaPinConfig.onlyInternalResistor = scripting.forceWrite(false); +I2C1.sdaPinConfig.passedPeripheralType = scripting.forceWrite("Digital"); +I2C1.sdaPinConfig.$name = "ti_driverlib_gpio_GPIOPinGeneric2"; +I2C1.sclPinConfig.hideOutputInversion = scripting.forceWrite(false); +I2C1.sclPinConfig.onlyInternalResistor = scripting.forceWrite(false); +I2C1.sclPinConfig.passedPeripheralType = scripting.forceWrite("Digital"); +I2C1.sclPinConfig.$name = "ti_driverlib_gpio_GPIOPinGeneric3"; + +SYSCTL.forceDefaultClkConfig = true; +SYSCTL.peripheral.$assign = "SYSCTL"; + +UART1.$name = "UART_0"; +UART1.rxFifoThreshold = "DL_UART_RX_FIFO_LEVEL_ONE_ENTRY"; +UART1.targetBaudRate = 115200; +UART1.uartClkDiv = "8"; +UART1.enableFIFO = true; +UART1.txFifoThreshold = "DL_UART_TX_FIFO_LEVEL_ONE_ENTRY"; +UART1.enabledDMATXTriggers = "DL_UART_DMA_INTERRUPT_TX"; +UART1.peripheral.$assign = "UART0"; +UART1.peripheral.rxPin.$assign = "PA11"; +UART1.peripheral.txPin.$assign = "PA10"; +UART1.txPinConfig.$name = "ti_driverlib_gpio_GPIOPinGeneric0"; +UART1.rxPinConfig.$name = "ti_driverlib_gpio_GPIOPinGeneric1"; +UART1.DMA_CHANNEL_TX.$name = "DMA_CH0"; +UART1.DMA_CHANNEL_TX.addressMode = "b2f"; +UART1.DMA_CHANNEL_TX.srcLength = "BYTE"; +UART1.DMA_CHANNEL_TX.dstLength = "BYTE"; +UART1.DMA_CHANNEL_TX.peripheral.$assign = "DMA_CH0"; + +const ProjectConfig = scripting.addModule("/ti/project_config/ProjectConfig", {}, false); +ProjectConfig.migrationCondition = true; + +/** + * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future + * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to + * re-solve from scratch. + */ +I2C1.peripheral.$suggestSolution = "I2C1"; diff --git a/keil/empty_LP_MSPM0G3507_nortos_keil.uvprojx b/keil/empty_LP_MSPM0G3507_nortos_keil.uvprojx new file mode 100644 index 0000000..cba4b4a --- /dev/null +++ b/keil/empty_LP_MSPM0G3507_nortos_keil.uvprojx @@ -0,0 +1,463 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + empty_LP_MSPM0G3507_nortos_keil + 0x4 + ARM-ADS + 6220000::V6.22::ARMCLANG + 1 + + + MSPM0G3507 + Texas Instruments + TexasInstruments.MSPM0G1X0X_G3X0X_DFP.1.3.1 + https://software-dl.ti.com/msp430/esd/MSPM0-CMSIS/MSPM0G1X0X_G3X0X/latest/exports/ + IRAM(0x20000000,0x00008000) IRAM2(0x20100000,0x00008000) IROM(0x00000000,0x00020000) IROM2(0x00400000,0x00020000) XRAM(0x20200000,0x00008000) XRAM2(0x20300000,0x00008000) CPUTYPE("Cortex-M0+") CLOCK(12000000) ELITTLE + + + + + + + + + + + + + + + $$Device:MSPM0G3507$03_SVD\MSPM0G350X.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\Objects\ + empty_LP_MSPM0G3507_nortos_keil + 1 + 0 + 1 + 1 + 1 + .\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 1 + 0 + cmd.exe /C "$P../../../../../../tools/keil/syscfg.bat '$P' empty.syscfg" + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + -MPU + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + -MPU + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 0 + + 1 + + + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x8000 + + + 1 + 0x0 + 0x20000 + + + 1 + 0x20200000 + 0x8000 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x20000 + + + 1 + 0x400000 + 0x20000 + + + 0 + 0x20200000 + 0x8000 + + + 0 + 0x20300000 + 0x8000 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x8000 + + + 0 + 0x20100000 + 0x8000 + + + + + + 1 + 3 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 4 + 0 + 0 + 1 + 0 + 0 + 3 + 3 + 1 + 1 + 0 + 0 + 0 + + + __MSPM0G3507__ + + ../;../../../../../../source/third_party/CMSIS/Core/Include;../../../../../../source;..\3rd + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + + + + + + + + + 0 + 0 + 0 + 0 + 1 + 0 + + + + ./mspm0g3507.sct + + + ../../../../../../source/ti/driverlib/lib/keil/m0p/mspm0g1x0x_g3x0x/driverlib.a + + + + + + + + Source + + + empty.c + 1 + ../empty.c + + + empty.syscfg + 5 + ../empty.syscfg + + + startup_mspm0g350x_uvision.s + 2 + startup_mspm0g350x_uvision.s + + + ti_msp_dl_config.h + 5 + ../ti_msp_dl_config.h + + + ti_msp_dl_config.c + 1 + ../ti_msp_dl_config.c + + + delay.c + 1 + ..\3rd\delay.c + + + delay.h + 5 + ..\3rd\delay.h + + + mt6701.c + 1 + ..\3rd\mt6701.c + + + mt6701.h + 5 + ..\3rd\mt6701.h + + + uart_redircet.c + 1 + ..\3rd\uart_redircet.c + + + uart_redircet.h + 5 + ..\3rd\uart_redircet.h + + + + + + + + + + + + + + + + + empty_LP_MSPM0G3507_nortos_keil + 1 + + + + +
diff --git a/keil/mspm0g3507.sct b/keil/mspm0g3507.sct new file mode 100644 index 0000000..548cb33 --- /dev/null +++ b/keil/mspm0g3507.sct @@ -0,0 +1,61 @@ +/***************************************************************************** + + Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com/ + + 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. + +*****************************************************************************/ +; ************************************************************* +; *** Scatter-Loading Description File generated by uVision *** +; ************************************************************* + +LR_IROM1 0x00000000 0x00020000 { ; load region size_region + ER_IROM1 0x00000000 ALIGNALL 8 0x00020000 { ; load address = execution address + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + .ANY (+XO) + } + RW_IRAM2 0x20200000 0x00008000 { ; RW data + .ANY (+RW +ZI) + .ANY (.ramfunc) + } +} + +LR_BCR 0x41C00000 0x00000100 { ; load region size_region + BCR_CONFIG 0x41C00000 0x000000FF{ + .ANY (.BCRConfig) + } +} + +LR_BSL 0x41C00100 0x00000100 { ; load region size_region + BSL_CONFIG 0x41C00100 0x00000080{ + .ANY (.BSLConfig) + } +} diff --git a/keil/startup_mspm0g350x_uvision.s b/keil/startup_mspm0g350x_uvision.s new file mode 100644 index 0000000..31ccbf2 --- /dev/null +++ b/keil/startup_mspm0g350x_uvision.s @@ -0,0 +1,252 @@ +;//***************************************************************************** +;// +;// Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/ +;// +;// 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. +;// +;// MSPM0G3507 startup file +;// +;//**************************************************************************** +;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +;*/ + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Stack_Size EQU 0x00000100 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Heap_Size EQU 0x00000000 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV Handler + DCD SysTick_Handler ; SysTick Handler + + ; External Interrupts + DCD GROUP0_IRQHandler ; 1: GROUP0 interrupt handler + DCD GROUP1_IRQHandler ; 2: GROUP1 interrupt handler + DCD TIMG8_IRQHandler ; 3: TIMG8 interrupt handler + DCD UART3_IRQHandler ; 4: UART3 interrupt handler + DCD ADC0_IRQHandler ; 5: ADC0 interrupt handler + DCD ADC1_IRQHandler ; 6: ADC1 interrupt handler + DCD CANFD0_IRQHandler ; 7: CANFD0 interrupt handler + DCD DAC0_IRQHandler ; 8: DAC0 interrupt handler + DCD 0 ; 9: Reserved + DCD SPI0_IRQHandler ; 10: SPI0 interrupt handler + DCD SPI1_IRQHandler ; 11: SPI1 interrupt handler + DCD 0 ; 12: Reserved + DCD 0 ; 13: Reserved + DCD UART1_IRQHandler ; 14: UART1 interrupt handler + DCD UART2_IRQHandler ; 15: UART2 interrupt handler + DCD UART0_IRQHandler ; 16: UART0 interrupt handler + DCD TIMG0_IRQHandler ; 17: TIMG0 interrupt handler + DCD TIMG6_IRQHandler ; 18: TIMG6 interrupt handler + DCD TIMA0_IRQHandler ; 19: TIMA0 interrupt handler + DCD TIMA1_IRQHandler ; 20: TIMA1 interrupt handler + DCD TIMG7_IRQHandler ; 21: TIMG7 interrupt handler + DCD TIMG12_IRQHandler ; 22: TIMG12 interrupt handler + DCD 0 ; 23: Reserved + DCD 0 ; 24: Reserved + DCD I2C0_IRQHandler ; 25: I2C0 interrupt handler + DCD I2C1_IRQHandler ; 26: I2C1 interrupt handler + DCD 0 ; 27: Reserved + DCD 0 ; 28: Reserved + DCD AES_IRQHandler ; 29: AES interrupt handler + DCD 0 ; 30: Reserved + DCD RTC_IRQHandler ; 31: RTC interrupt handler + DCD DMA_IRQHandler ; 32: DMA interrupt handler + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + ;IMPORT SystemInit + IMPORT __main + ; SystemInit can be called here, but not necessary for MSPM0 + ;LDR R0, =SystemInit + ;BLX R0 + LDR R0, =__main + BX R0 + ENDP + + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT Default_Handler [WEAK] + EXPORT GROUP0_IRQHandler [WEAK] + EXPORT GROUP1_IRQHandler [WEAK] + EXPORT TIMG8_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT ADC0_IRQHandler [WEAK] + EXPORT ADC1_IRQHandler [WEAK] + EXPORT CANFD0_IRQHandler [WEAK] + EXPORT DAC0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT TIMG0_IRQHandler [WEAK] + EXPORT TIMG6_IRQHandler [WEAK] + EXPORT TIMA0_IRQHandler [WEAK] + EXPORT TIMA1_IRQHandler [WEAK] + EXPORT TIMG7_IRQHandler [WEAK] + EXPORT TIMG12_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT DMA_IRQHandler [WEAK] + +GROUP0_IRQHandler +GROUP1_IRQHandler +TIMG8_IRQHandler +UART3_IRQHandler +ADC0_IRQHandler +ADC1_IRQHandler +CANFD0_IRQHandler +DAC0_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART0_IRQHandler +TIMG0_IRQHandler +TIMG6_IRQHandler +TIMA0_IRQHandler +TIMA1_IRQHandler +TIMG7_IRQHandler +TIMG12_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +AES_IRQHandler +RTC_IRQHandler +DMA_IRQHandler + B . + ENDP + + ALIGN + + +; User Initial Stack & Heap + + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap + +__user_initial_stackheap PROC + LDR R0, = Heap_Mem + LDR R1, =(Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + ENDP + + ALIGN + + ENDIF + + + END diff --git a/ti_msp_dl_config.c b/ti_msp_dl_config.c new file mode 100644 index 0000000..329922c --- /dev/null +++ b/ti_msp_dl_config.c @@ -0,0 +1,202 @@ +/* + * 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" + +/* + * ======== 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_I2C_1_init(); + SYSCFG_DL_UART_0_init(); + SYSCFG_DL_DMA_init(); +} + + + +SYSCONFIG_WEAK void SYSCFG_DL_initPower(void) +{ + DL_GPIO_reset(GPIOA); + DL_GPIO_reset(GPIOB); + DL_I2C_reset(I2C_1_INST); + DL_UART_Main_reset(UART_0_INST); + + + DL_GPIO_enablePower(GPIOA); + DL_GPIO_enablePower(GPIOB); + DL_I2C_enablePower(I2C_1_INST); + DL_UART_Main_enablePower(UART_0_INST); + + delay_cycles(POWER_STARTUP_DELAY); +} + +SYSCONFIG_WEAK void SYSCFG_DL_GPIO_init(void) +{ + + 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, + DL_GPIO_WAKEUP_DISABLE); + DL_GPIO_initPeripheralInputFunctionFeatures(GPIO_I2C_1_IOMUX_SCL, + GPIO_I2C_1_IOMUX_SCL_FUNC, DL_GPIO_INVERSION_DISABLE, + DL_GPIO_RESISTOR_NONE, DL_GPIO_HYSTERESIS_DISABLE, + DL_GPIO_WAKEUP_DISABLE); + DL_GPIO_enableHiZ(GPIO_I2C_1_IOMUX_SDA); + DL_GPIO_enableHiZ(GPIO_I2C_1_IOMUX_SCL); + + DL_GPIO_initPeripheralOutputFunction( + GPIO_UART_0_IOMUX_TX, GPIO_UART_0_IOMUX_TX_FUNC); + DL_GPIO_initPeripheralInputFunction( + GPIO_UART_0_IOMUX_RX, GPIO_UART_0_IOMUX_RX_FUNC); + + DL_GPIO_initDigitalOutput(LED_PA0_IOMUX); + + DL_GPIO_clearPins(LED_PORT, LED_PA0_PIN); + DL_GPIO_enableOutput(LED_PORT, LED_PA0_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); + /* Set default configuration */ + DL_SYSCTL_disableHFXT(); + DL_SYSCTL_disableSYSPLL(); + DL_SYSCTL_setULPCLKDivider(DL_SYSCTL_ULPCLK_DIV_1); + DL_SYSCTL_setMCLKDivider(DL_SYSCTL_MCLK_DIVIDER_DISABLE); + +} + + +static const DL_I2C_ClockConfig gI2C_1ClockConfig = { + .clockSel = DL_I2C_CLOCK_BUSCLK, + .divideRatio = DL_I2C_CLOCK_DIVIDE_1, +}; + +SYSCONFIG_WEAK void SYSCFG_DL_I2C_1_init(void) { + + DL_I2C_setClockConfig(I2C_1_INST, + (DL_I2C_ClockConfig *) &gI2C_1ClockConfig); + DL_I2C_disableAnalogGlitchFilter(I2C_1_INST); + + /* Configure Controller Mode */ + DL_I2C_resetControllerTransfer(I2C_1_INST); + /* Set frequency to 400000 Hz*/ + DL_I2C_setTimerPeriod(I2C_1_INST, 7); + DL_I2C_setControllerTXFIFOThreshold(I2C_1_INST, DL_I2C_TX_FIFO_LEVEL_EMPTY); + DL_I2C_setControllerRXFIFOThreshold(I2C_1_INST, DL_I2C_RX_FIFO_LEVEL_BYTES_1); + DL_I2C_enableControllerClockStretching(I2C_1_INST); + + + /* Enable module */ + DL_I2C_enableController(I2C_1_INST); + + +} + +static const DL_UART_Main_ClockConfig gUART_0ClockConfig = { + .clockSel = DL_UART_MAIN_CLOCK_BUSCLK, + .divideRatio = DL_UART_MAIN_CLOCK_DIVIDE_RATIO_8 +}; + +static const DL_UART_Main_Config gUART_0Config = { + .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_0_init(void) +{ + DL_UART_Main_setClockConfig(UART_0_INST, (DL_UART_Main_ClockConfig *) &gUART_0ClockConfig); + + DL_UART_Main_init(UART_0_INST, (DL_UART_Main_Config *) &gUART_0Config); + /* + * Configure baud rate by setting oversampling and baud rate divisors. + * Target baud rate: 115200 + * Actual baud rate: 115107.91 + */ + DL_UART_Main_setOversampling(UART_0_INST, DL_UART_OVERSAMPLING_RATE_16X); + DL_UART_Main_setBaudRateDivisor(UART_0_INST, UART_0_IBRD_4_MHZ_115200_BAUD, UART_0_FBRD_4_MHZ_115200_BAUD); + + + /* Configure DMA Transmit Event */ + DL_UART_Main_enableDMATransmitEvent(UART_0_INST); + /* Configure FIFOs */ + DL_UART_Main_enableFIFOs(UART_0_INST); + DL_UART_Main_setRXFIFOThreshold(UART_0_INST, DL_UART_RX_FIFO_LEVEL_ONE_ENTRY); + DL_UART_Main_setTXFIFOThreshold(UART_0_INST, DL_UART_TX_FIFO_LEVEL_ONE_ENTRY); + + DL_UART_Main_enable(UART_0_INST); +} + +static const DL_DMA_Config gDMA_CH0Config = { + .transferMode = DL_DMA_SINGLE_TRANSFER_MODE, + .extendedMode = DL_DMA_NORMAL_MODE, + .destIncrement = DL_DMA_ADDR_UNCHANGED, + .srcIncrement = DL_DMA_ADDR_INCREMENT, + .destWidth = DL_DMA_WIDTH_BYTE, + .srcWidth = DL_DMA_WIDTH_BYTE, + .trigger = UART_0_INST_DMA_TRIGGER, + .triggerType = DL_DMA_TRIGGER_TYPE_EXTERNAL, +}; + +SYSCONFIG_WEAK void SYSCFG_DL_DMA_CH0_init(void) +{ + DL_DMA_initChannel(DMA, DMA_CH0_CHAN_ID , (DL_DMA_Config *) &gDMA_CH0Config); +} +SYSCONFIG_WEAK void SYSCFG_DL_DMA_init(void){ + SYSCFG_DL_DMA_CH0_init(); +} + + diff --git a/ti_msp_dl_config.h b/ti_msp_dl_config.h new file mode 100644 index 0000000..4a8fea5 --- /dev/null +++ b/ti_msp_dl_config.h @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2023, Texas Instruments Incorporated - http://www.ti.com + * 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.h ============= + * Configured MSPM0 DriverLib module declarations + * + * DO NOT EDIT - This file is generated for the MSPM0G350X + * by the SysConfig tool. + */ +#ifndef ti_msp_dl_config_h +#define ti_msp_dl_config_h + +#define CONFIG_MSPM0G350X +#define CONFIG_MSPM0G3507 + +#if defined(__ti_version__) || defined(__TI_COMPILER_VERSION__) +#define SYSCONFIG_WEAK __attribute__((weak)) +#elif defined(__IAR_SYSTEMS_ICC__) +#define SYSCONFIG_WEAK __weak +#elif defined(__GNUC__) +#define SYSCONFIG_WEAK __attribute__((weak)) +#endif + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * ======== SYSCFG_DL_init ======== + * Perform all required MSP DL initialization + * + * This function should be called once at a point before any use of + * MSP DL. + */ + + +/* clang-format off */ + +#define POWER_STARTUP_DELAY (16) + + +#define CPUCLK_FREQ 32000000 + + + + +/* Defines for I2C_1 */ +#define I2C_1_INST I2C1 +#define I2C_1_INST_IRQHandler I2C1_IRQHandler +#define I2C_1_INST_INT_IRQN I2C1_INT_IRQn +#define I2C_1_BUS_SPEED_HZ 400000 +#define GPIO_I2C_1_SDA_PORT GPIOB +#define GPIO_I2C_1_SDA_PIN DL_GPIO_PIN_3 +#define GPIO_I2C_1_IOMUX_SDA (IOMUX_PINCM16) +#define GPIO_I2C_1_IOMUX_SDA_FUNC IOMUX_PINCM16_PF_I2C1_SDA +#define GPIO_I2C_1_SCL_PORT GPIOB +#define GPIO_I2C_1_SCL_PIN DL_GPIO_PIN_2 +#define GPIO_I2C_1_IOMUX_SCL (IOMUX_PINCM15) +#define GPIO_I2C_1_IOMUX_SCL_FUNC IOMUX_PINCM15_PF_I2C1_SCL + + +/* Defines for UART_0 */ +#define UART_0_INST UART0 +#define UART_0_INST_FREQUENCY 4000000 +#define UART_0_INST_IRQHandler UART0_IRQHandler +#define UART_0_INST_INT_IRQN UART0_INT_IRQn +#define GPIO_UART_0_RX_PORT GPIOA +#define GPIO_UART_0_TX_PORT GPIOA +#define GPIO_UART_0_RX_PIN DL_GPIO_PIN_11 +#define GPIO_UART_0_TX_PIN DL_GPIO_PIN_10 +#define GPIO_UART_0_IOMUX_RX (IOMUX_PINCM22) +#define GPIO_UART_0_IOMUX_TX (IOMUX_PINCM21) +#define GPIO_UART_0_IOMUX_RX_FUNC IOMUX_PINCM22_PF_UART0_RX +#define GPIO_UART_0_IOMUX_TX_FUNC IOMUX_PINCM21_PF_UART0_TX +#define UART_0_BAUD_RATE (115200) +#define UART_0_IBRD_4_MHZ_115200_BAUD (2) +#define UART_0_FBRD_4_MHZ_115200_BAUD (11) + + + + + +/* Defines for DMA_CH0 */ +#define DMA_CH0_CHAN_ID (0) +#define UART_0_INST_DMA_TRIGGER (DMA_UART0_TX_TRIG) + + +/* Port definition for Pin Group LED */ +#define LED_PORT (GPIOA) + +/* Defines for PA0: GPIOA.0 with pinCMx 1 on package pin 1 */ +#define LED_PA0_PIN (DL_GPIO_PIN_0) +#define LED_PA0_IOMUX (IOMUX_PINCM1) + + +/* clang-format on */ + +void SYSCFG_DL_init(void); +void SYSCFG_DL_initPower(void); +void SYSCFG_DL_GPIO_init(void); +void SYSCFG_DL_SYSCTL_init(void); +void SYSCFG_DL_I2C_1_init(void); +void SYSCFG_DL_UART_0_init(void); +void SYSCFG_DL_DMA_init(void); + + +bool SYSCFG_DL_saveConfiguration(void); +bool SYSCFG_DL_restoreConfiguration(void); + +#ifdef __cplusplus +} +#endif + +#endif /* ti_msp_dl_config_h */