diff --git a/myapps/blinky-OLD/Makefile b/myapps/blinky-OLD/Makefile new file mode 100644 index 0000000..ec1e803 --- /dev/null +++ b/myapps/blinky-OLD/Makefile @@ -0,0 +1,107 @@ +# For Linux +RM = rm -f +RMDIR = rm -rf +DEVNULL = /dev/null +ECHOBLANKLINE = echo + +#---------------- + +SYSCONFIG_TOOL ?= /home/ajit/ti/sysconfig_1.26.2/sysconfig_cli.sh +MSPM0_SDK_INSTALL_DIR ?= $(abspath ../../mspm0-sdk) + +CC = "arm-none-eabi-gcc" +LNK = "arm-none-eabi-gcc" + +SYSCONFIG_GUI_TOOL = $(dir $(SYSCONFIG_TOOL))sysconfig_gui$(suffix $(SYSCONFIG_TOOL)) +SYSCFG_CMD_STUB = $(SYSCONFIG_TOOL) --compiler gcc --product $(MSPM0_SDK_INSTALL_DIR)/.metadata/product.json +SYSCFG_GUI_CMD_STUB = $(SYSCONFIG_GUI_TOOL) --compiler gcc --product $(MSPM0_SDK_INSTALL_DIR)/.metadata/product.json +SYSCFG_FILES := $(shell $(SYSCFG_CMD_STUB) --listGeneratedFiles --listReferencedFiles --output . empty.syscfg) + +SYSCFG_C_FILES = $(filter %.c,$(SYSCFG_FILES)) +SYSCFG_H_FILES = $(filter %.h,$(SYSCFG_FILES)) +SYSCFG_OPT_FILES = $(filter %.opt,$(SYSCFG_FILES)) + +OBJECTS = empty.obj $(patsubst %.c,%.obj,$(notdir $(SYSCFG_C_FILES))) +NAME = empty + +CFLAGS += -I. \ + $(addprefix @,$(SYSCFG_OPT_FILES)) \ + -O2 \ + @device.opt \ + "-I$(MSPM0_SDK_INSTALL_DIR)/source/third_party/CMSIS/Core/Include" \ + "-I$(MSPM0_SDK_INSTALL_DIR)/source" \ + -mcpu=cortex-m0plus \ + -march=armv6-m \ + -mthumb \ + -std=c99 \ + -mfloat-abi=soft \ + -ffunction-sections \ + -fdata-sections \ + -g \ + -gstrict-dwarf \ + -Wall \ + --specs=nano.specs + +LFLAGS += "-L$(MSPM0_SDK_INSTALL_DIR)/source/ti/driverlib/lib/gcc/m0p/mspm0g1x0x_g3x0x" \ + -nostartfiles \ + -Tdevice.lds.genlibs \ + -l:driverlib.a \ + -Wl,-T,device_linker.lds \ + "-Wl,-Map,$(NAME).map" \ + "-L$(MSPM0_SDK_INSTALL_DIR)/source" \ + -L.. \ + -march=armv6-m \ + -mthumb \ + -static \ + -Wl,--gc-sections \ + "-L/usr/lib/gcc/arm-none-eabi/14.2.1/thumb/nofp" \ + -lgcc \ + -lc \ + -lm \ + --specs=nano.specs \ + --specs=nosys.specs + +all: $(NAME).out + +.INTERMEDIATE: syscfg +$(SYSCFG_FILES): syscfg + @ echo generation complete + +syscfg: empty.syscfg + @ echo Generating configuration files... + @ $(SYSCFG_CMD_STUB) --output $(@D) $< + + +# Helpful hint that the user needs to use a standalone SysConfig installation +$(SYSCONFIG_GUI_TOOL): + $(error $(dir $(SYSCONFIG_TOOL)) does not contain the GUI framework \ + necessary to launch the SysConfig GUI. Please set SYSCONFIG_TOOL \ + (in your SDK's imports.mak) to a standalone SysConfig installation \ + rather than one inside CCS) + +syscfg-gui: empty.syscfg $(SYSCONFIG_GUI_TOOL) + @ echo Opening SysConfig GUI + @ $(SYSCFG_GUI_CMD_STUB) $< + +define C_RULE +$(basename $(notdir $(1))).obj: $(1) $(SYSCFG_H_FILES) + @ echo Building $$@ + @ $(CC) $(CFLAGS) $$< -c -o $$@ +endef + +$(foreach c_file,$(SYSCFG_C_FILES),$(eval $(call C_RULE,$(c_file)))) + +empty.obj: src/main.c $(SYSCFG_H_FILES) + @ echo Building $@ + @ $(CC) $(CFLAGS) $< -c -o $@ + +$(NAME).out: $(OBJECTS) + @ echo linking $@ + @ $(LNK) $(OBJECTS) $(LFLAGS) -o $(NAME).out + +clean: + @ echo Cleaning... + @ $(RM) $(OBJECTS) > $(DEVNULL) 2>&1 + @ $(RM) $(NAME).out > $(DEVNULL) 2>&1 + @ $(RM) $(NAME).map > $(DEVNULL) 2>&1 + @ $(RM) $(SYSCFG_FILES)> $(DEVNULL) 2>&1 diff --git a/myapps/blinky/device.lds.genlibs b/myapps/blinky-OLD/device.lds.genlibs similarity index 100% rename from myapps/blinky/device.lds.genlibs rename to myapps/blinky-OLD/device.lds.genlibs diff --git a/myapps/blinky/device.opt b/myapps/blinky-OLD/device.opt similarity index 100% rename from myapps/blinky/device.opt rename to myapps/blinky-OLD/device.opt diff --git a/myapps/blinky-OLD/device_linker.lds b/myapps/blinky-OLD/device_linker.lds new file mode 100644 index 0000000..f280511 --- /dev/null +++ b/myapps/blinky-OLD/device_linker.lds @@ -0,0 +1,201 @@ +/***************************************************************************** + + 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. + +*****************************************************************************/ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0; /* required amount of heap */ +_Min_Stack_Size = 0x80; /* required amount of stack */ + + +/* Specify the memory areas */ +MEMORY +{ + FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x00020000 + SRAM (RWX) : ORIGIN = 0x20200000, LENGTH = 0x00008000 + BCR_CONFIG (R) : ORIGIN = 0x41C00000, LENGTH = 0x000000FF + BSL_CONFIG (R) : ORIGIN = 0x41C00100, LENGTH = 0x00000080 +} + +/* Note: SRAM length must match MPPC/MEMSS config! Please edit it manually. */ + +REGION_ALIAS("REGION_TEXT", FLASH); +REGION_ALIAS("REGION_PREINIT_ARRAY", FLASH); +REGION_ALIAS("REGION_INIT_ARRAY", FLASH); +REGION_ALIAS("REGION_FINI_ARRAY", FLASH); +REGION_ALIAS("REGION_BSS", SRAM); +REGION_ALIAS("REGION_NOINIT", SRAM); +REGION_ALIAS("REGION_DATA", SRAM); +REGION_ALIAS("REGION_STACK", SRAM); +REGION_ALIAS("REGION_HEAP", SRAM); +REGION_ALIAS("REGION_TEXT_RAM", SRAM); +REGION_ALIAS("REGION_ARM_EXIDX", FLASH); +REGION_ALIAS("REGION_ARM_EXTAB", FLASH); + +/* Define output sections */ +SECTIONS +{ + /* section for the interrupt vector area */ + PROVIDE (_intvecs_base_address = + DEFINED(_intvecs_base_address) ? _intvecs_base_address : 0x00000000); + + .intvecs (_intvecs_base_address) : AT (_intvecs_base_address) { + KEEP (*(.intvecs)) + } > REGION_TEXT + + PROVIDE (_vtable_base_address = + DEFINED(_vtable_base_address) ? _vtable_base_address : 0x20200000); + + .vtable (_vtable_base_address) (NOLOAD) : AT (_vtable_base_address) { + KEEP (*(.vtable)) + } > REGION_DATA + + .text : { + CREATE_OBJECT_SYMBOLS + KEEP (*(.text)) + . = ALIGN(0x8); + *(.text.*) + . = ALIGN(0x8); + KEEP (*(.ctors)) + . = ALIGN(0x8); + KEEP (*(.dtors)) + . = ALIGN(0x8); + KEEP (*(.init)) + . = ALIGN(0x8); + KEEP (*(.fini*)) + . = ALIGN(0x8); + } > REGION_TEXT AT> REGION_TEXT + + .ramfunc : { + __ramfunct_load__ = LOADADDR (.ramfunc); + __ramfunct_start__ = .; + *(.ramfunc) + . = ALIGN(0x8); + __ramfunct_end__ = .; + } > REGION_TEXT_RAM AT> REGION_TEXT + + .rodata : { + *(.rodata) + . = ALIGN(0x8); + *(.rodata.*) + . = ALIGN(0x8); + } > REGION_TEXT AT> REGION_TEXT + + .preinit_array : { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)); + PROVIDE_HIDDEN (__preinit_array_end = .); + } > REGION_PREINIT_ARRAY AT> REGION_TEXT + + .init_array : { + . = ALIGN(0x8); + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } > REGION_INIT_ARRAY AT> REGION_TEXT + + .fini_array : { + . = ALIGN(0x8); + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(0x8); + } > REGION_FINI_ARRAY AT> REGION_TEXT + + .ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + __exidx_end = .; + } > REGION_ARM_EXIDX AT> REGION_ARM_EXIDX + + .ARM.extab : { + . = ALIGN(0x8); + KEEP (*(.ARM.extab* .gnu.linkonce.armextab.*)) + . = ALIGN(0x8); + } > REGION_ARM_EXTAB AT> REGION_ARM_EXTAB + + __etext = .; + + .data : { + __data_load__ = LOADADDR (.data); + __data_start__ = .; + KEEP (*(.data)) + KEEP (*(.data*)) + . = ALIGN (8); + __data_end__ = .; + } > REGION_DATA AT> REGION_TEXT + + .bss : { + __bss_start__ = .; + *(.shbss) + KEEP (*(.bss)) + *(.bss.*) + *(COMMON) + . = ALIGN (8); + __bss_end__ = .; + } > REGION_BSS AT> REGION_BSS + + .noinit : { + /* place all symbols in input sections that start with .noinit */ + KEEP(*(*.noinit*)) + . = ALIGN (8); + } > REGION_NOINIT AT> REGION_NOINIT + + .heap : { + __heap_start__ = .; + end = __heap_start__; + _end = end; + __end = end; + KEEP (*(.heap)) + __heap_end__ = .; + __HeapLimit = __heap_end__; + } > REGION_HEAP AT> REGION_HEAP + + .stack (NOLOAD) : ALIGN(0x8) { + _stack = .; + KEEP(*(.stack)) + } > REGION_STACK AT> REGION_STACK + + .BCRConfig : + { + KEEP(*(.BCRConfig)) + } > BCR_CONFIG + + .BSLConfig : + { + KEEP(*(.BSLConfig)) + } > BSL_CONFIG + + __StackTop = ORIGIN(REGION_STACK) + LENGTH(REGION_STACK); + PROVIDE(__stack = __StackTop); +} diff --git a/myapps/blinky/empty.map b/myapps/blinky-OLD/empty.map similarity index 100% rename from myapps/blinky/empty.map rename to myapps/blinky-OLD/empty.map diff --git a/myapps/blinky/empty.obj b/myapps/blinky-OLD/empty.obj similarity index 100% rename from myapps/blinky/empty.obj rename to myapps/blinky-OLD/empty.obj diff --git a/myapps/blinky/empty.out b/myapps/blinky-OLD/empty.out similarity index 100% rename from myapps/blinky/empty.out rename to myapps/blinky-OLD/empty.out diff --git a/myapps/blinky/empty.syscfg b/myapps/blinky-OLD/empty.syscfg similarity index 100% rename from myapps/blinky/empty.syscfg rename to myapps/blinky-OLD/empty.syscfg diff --git a/myapps/blinky-OLD/src/main.c b/myapps/blinky-OLD/src/main.c new file mode 100644 index 0000000..21140a9 --- /dev/null +++ b/myapps/blinky-OLD/src/main.c @@ -0,0 +1,10 @@ + +#include "ti_msp_dl_config.h" + +int main(void) +{ + SYSCFG_DL_init(); + + while (1) { + } +} diff --git a/myapps/blinky/startup_mspm0g350x_gcc.c b/myapps/blinky-OLD/startup_mspm0g350x_gcc.c similarity index 100% rename from myapps/blinky/startup_mspm0g350x_gcc.c rename to myapps/blinky-OLD/startup_mspm0g350x_gcc.c diff --git a/myapps/blinky/startup_mspm0g350x_gcc.obj b/myapps/blinky-OLD/startup_mspm0g350x_gcc.obj similarity index 100% rename from myapps/blinky/startup_mspm0g350x_gcc.obj rename to myapps/blinky-OLD/startup_mspm0g350x_gcc.obj diff --git a/myapps/blinky-OLD/ti_msp_dl_config.c b/myapps/blinky-OLD/ti_msp_dl_config.c new file mode 100644 index 0000000..eda8bc6 --- /dev/null +++ b/myapps/blinky-OLD/ti_msp_dl_config.c @@ -0,0 +1,86 @@ +/* + * 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(); +} + +SYSCONFIG_WEAK void SYSCFG_DL_initPower(void) +{ + DL_GPIO_reset(GPIOA); + DL_GPIO_reset(GPIOB); + + DL_GPIO_enablePower(GPIOA); + DL_GPIO_enablePower(GPIOB); + delay_cycles(POWER_STARTUP_DELAY); +} + +SYSCONFIG_WEAK void SYSCFG_DL_GPIO_init(void) +{ + +} + + +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); + +} + + diff --git a/myapps/blinky-OLD/ti_msp_dl_config.h b/myapps/blinky-OLD/ti_msp_dl_config.h new file mode 100644 index 0000000..b6f0d1f --- /dev/null +++ b/myapps/blinky-OLD/ti_msp_dl_config.h @@ -0,0 +1,92 @@ +/* + * 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 + + + +/* 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); + + +#ifdef __cplusplus +} +#endif + +#endif /* ti_msp_dl_config_h */ diff --git a/myapps/blinky/ti_msp_dl_config.obj b/myapps/blinky-OLD/ti_msp_dl_config.obj similarity index 100% rename from myapps/blinky/ti_msp_dl_config.obj rename to myapps/blinky-OLD/ti_msp_dl_config.obj diff --git a/myapps/blinky/Makefile b/myapps/blinky/Makefile index ec1e803..caffc19 100644 --- a/myapps/blinky/Makefile +++ b/myapps/blinky/Makefile @@ -1,107 +1,160 @@ -# For Linux -RM = rm -f -RMDIR = rm -rf -DEVNULL = /dev/null -ECHOBLANKLINE = echo - -#---------------- - -SYSCONFIG_TOOL ?= /home/ajit/ti/sysconfig_1.26.2/sysconfig_cli.sh -MSPM0_SDK_INSTALL_DIR ?= $(abspath ../../mspm0-sdk) - -CC = "arm-none-eabi-gcc" -LNK = "arm-none-eabi-gcc" - -SYSCONFIG_GUI_TOOL = $(dir $(SYSCONFIG_TOOL))sysconfig_gui$(suffix $(SYSCONFIG_TOOL)) -SYSCFG_CMD_STUB = $(SYSCONFIG_TOOL) --compiler gcc --product $(MSPM0_SDK_INSTALL_DIR)/.metadata/product.json -SYSCFG_GUI_CMD_STUB = $(SYSCONFIG_GUI_TOOL) --compiler gcc --product $(MSPM0_SDK_INSTALL_DIR)/.metadata/product.json -SYSCFG_FILES := $(shell $(SYSCFG_CMD_STUB) --listGeneratedFiles --listReferencedFiles --output . empty.syscfg) - -SYSCFG_C_FILES = $(filter %.c,$(SYSCFG_FILES)) -SYSCFG_H_FILES = $(filter %.h,$(SYSCFG_FILES)) -SYSCFG_OPT_FILES = $(filter %.opt,$(SYSCFG_FILES)) - -OBJECTS = empty.obj $(patsubst %.c,%.obj,$(notdir $(SYSCFG_C_FILES))) -NAME = empty - -CFLAGS += -I. \ - $(addprefix @,$(SYSCFG_OPT_FILES)) \ - -O2 \ - @device.opt \ - "-I$(MSPM0_SDK_INSTALL_DIR)/source/third_party/CMSIS/Core/Include" \ - "-I$(MSPM0_SDK_INSTALL_DIR)/source" \ - -mcpu=cortex-m0plus \ - -march=armv6-m \ - -mthumb \ - -std=c99 \ - -mfloat-abi=soft \ - -ffunction-sections \ - -fdata-sections \ - -g \ - -gstrict-dwarf \ - -Wall \ - --specs=nano.specs - -LFLAGS += "-L$(MSPM0_SDK_INSTALL_DIR)/source/ti/driverlib/lib/gcc/m0p/mspm0g1x0x_g3x0x" \ - -nostartfiles \ - -Tdevice.lds.genlibs \ - -l:driverlib.a \ - -Wl,-T,device_linker.lds \ - "-Wl,-Map,$(NAME).map" \ - "-L$(MSPM0_SDK_INSTALL_DIR)/source" \ - -L.. \ - -march=armv6-m \ - -mthumb \ - -static \ - -Wl,--gc-sections \ - "-L/usr/lib/gcc/arm-none-eabi/14.2.1/thumb/nofp" \ - -lgcc \ - -lc \ - -lm \ - --specs=nano.specs \ - --specs=nosys.specs - -all: $(NAME).out - -.INTERMEDIATE: syscfg -$(SYSCFG_FILES): syscfg - @ echo generation complete - -syscfg: empty.syscfg - @ echo Generating configuration files... - @ $(SYSCFG_CMD_STUB) --output $(@D) $< +###################################### +# target +###################################### +TARGET = mspm0_blinky +#PART = STM32G030xx +#PYOCD_TARGET = stm32g030f6px -# Helpful hint that the user needs to use a standalone SysConfig installation -$(SYSCONFIG_GUI_TOOL): - $(error $(dir $(SYSCONFIG_TOOL)) does not contain the GUI framework \ - necessary to launch the SysConfig GUI. Please set SYSCONFIG_TOOL \ - (in your SDK's imports.mak) to a standalone SysConfig installation \ - rather than one inside CCS) +###################################### +# building variables +###################################### +# debug build? +DEBUG = 1 +# optimization for size +OPT = -Os -syscfg-gui: empty.syscfg $(SYSCONFIG_GUI_TOOL) - @ echo Opening SysConfig GUI - @ $(SYSCFG_GUI_CMD_STUB) $< -define C_RULE -$(basename $(notdir $(1))).obj: $(1) $(SYSCFG_H_FILES) - @ echo Building $$@ - @ $(CC) $(CFLAGS) $$< -c -o $$@ -endef +####################################### +# paths +####################################### +# Build path +BUILD_DIR = build +VND_DIR = ../../mspm0-sdk -$(foreach c_file,$(SYSCFG_C_FILES),$(eval $(call C_RULE,$(c_file)))) +###################################### +# source +###################################### +# C sources +C_SOURCES += \ + $(VND_DIR)/source/ti/devices/msp/m0p/startup_system_files/gcc/startup_mspm0g350x_gcc.c \ + ti_msp_dl_config.c \ + src/main.c -empty.obj: src/main.c $(SYSCFG_H_FILES) - @ echo Building $@ - @ $(CC) $(CFLAGS) $< -c -o $@ -$(NAME).out: $(OBJECTS) - @ echo linking $@ - @ $(LNK) $(OBJECTS) $(LFLAGS) -o $(NAME).out +# ASM sources +#ASM_SOURCES = + +####################################### +# binaries +####################################### +PREFIX = arm-none-eabi- + +CC = $(PREFIX)gcc +CP = $(PREFIX)objcopy +#SZ = $(PREFIX)size + +BIN = $(CP) -O binary -S + +####################################### +# CFLAGS +####################################### + +ifeq ($(DEBUG), 1) +#DEBUG_FLAGS = -gdwarf-3 +DEBUG_FLAGS = -g -gstrict-dwarf +endif + +# cpu +CPU = \ + -mcpu=cortex-m0plus \ + -march=armv6-m \ + -mthumb \ + -std=c99 \ + -mfloat-abi=soft \ + +DEFINES = -D__MSPM0G3507__ + +# fpu +FPU = + +# float-abi +FLOAT-ABI = + +# mcu +MCU = $(CPU) $(FPU) $(FLOAT-ABI) + +# C includes +C_INCLUDES += \ + -I. \ + -Isrc/inc \ + -I$(VND_DIR)/source/third_party/CMSIS/Core/Include \ + -I$(VND_DIR)/source + +# compile gcc flags +ADDN_CFLAGS = \ + -Wall \ + -fdata-sections \ + -ffunction-sections + +CFLAGS = $(MCU) $(ADDN_CFLAGS) $(C_INCLUDES) $(DEBUG_FLAGS) $(OPT) $(DEFINES) + + +# Generate dependency information +#CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" + + +#ASFLAGS = $(MCU) $(DEBUG_FLAGS) $(OPT) -Wa,--warn + +####################################### +# LDFLAGS +####################################### +# link script +LDSCRIPT = device_linker.lds + +LIBDIR = +LDFLAGS = \ + $(MCU) \ + "-L$(VND_DIR)/source/ti/driverlib/lib/gcc/m0p/mspm0g1x0x_g3x0x" \ + -l:driverlib.a \ + -T $(LDSCRIPT) \ + -nostartfiles \ + -Wl,-Map=$(BUILD_DIR)/$(TARGET).map \ + -static \ + -Wl,--gc-sections \ + "-L/usr/lib/gcc/arm-none-eabi/14.2.1/thumb/nofp" \ + -lgcc -lc -lm \ + --specs=nano.specs \ + --specs=nosys.specs \ + -Wl,--print-memory-usage \ + -Wl,--no-warn-rwx-segments + +# default action: build all +all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).bin + + +####################################### +# build the application +####################################### +# list of objects +OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) +vpath %.c $(sort $(dir $(C_SOURCES))) + +# list of ASM program objects +#OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) +#vpath %.s $(sort $(dir $(ASM_SOURCES))) + +$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) + $(CC) -c $(CFLAGS) $< -o $@ + +#$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) +# $(CC) -c $(ASFLAGS) $< -o $@ + +#$(LUAOBJECTS) $(OBJECTS) +$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile + $(CC) $(OBJECTS) $(LDFLAGS) -o $@ + +$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) + $(BIN) $< $@ + +$(BUILD_DIR): + mkdir $@ + +####################################### +# clean up +####################################### clean: - @ echo Cleaning... - @ $(RM) $(OBJECTS) > $(DEVNULL) 2>&1 - @ $(RM) $(NAME).out > $(DEVNULL) 2>&1 - @ $(RM) $(NAME).map > $(DEVNULL) 2>&1 - @ $(RM) $(SYSCFG_FILES)> $(DEVNULL) 2>&1 + -rm -fR $(BUILD_DIR) + +# *** EOF *** diff --git a/myapps/blinky/src/main.c b/myapps/blinky/src/main.c index 21140a9..af3b213 100644 --- a/myapps/blinky/src/main.c +++ b/myapps/blinky/src/main.c @@ -1,10 +1,20 @@ #include "ti_msp_dl_config.h" +/* This results in approximately 0.5s of delay assuming 32MHz CPU_CLK */ +#define DELAY (16000000) + int main(void) { + /* Power on GPIO, initialize pins as digital outputs */ SYSCFG_DL_init(); + /* Default: LED1 and LED3 ON, LED2 OFF */ + DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN); + while (1) { + delay_cycles(DELAY); + DL_GPIO_togglePins(GPIO_LEDS_PORT, + GPIO_LEDS_USER_LED_1_PIN); } } diff --git a/myapps/blinky/ti_msp_dl_config.c b/myapps/blinky/ti_msp_dl_config.c index eda8bc6..588548c 100644 --- a/myapps/blinky/ti_msp_dl_config.c +++ b/myapps/blinky/ti_msp_dl_config.c @@ -65,6 +65,11 @@ SYSCONFIG_WEAK void SYSCFG_DL_initPower(void) SYSCONFIG_WEAK void SYSCFG_DL_GPIO_init(void) { + DL_GPIO_initDigitalOutput(GPIO_LEDS_USER_LED_1_IOMUX); + + DL_GPIO_clearPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN); + DL_GPIO_enableOutput(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN); + } @@ -74,12 +79,11 @@ 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); + + DL_SYSCTL_setSYSOSCFreq(DL_SYSCTL_SYSOSC_FREQ_BASE); + /* Set default configuration */ + DL_SYSCTL_disableHFXT(); + DL_SYSCTL_disableSYSPLL(); } diff --git a/myapps/blinky/ti_msp_dl_config.h b/myapps/blinky/ti_msp_dl_config.h index b6f0d1f..5bd9075 100644 --- a/myapps/blinky/ti_msp_dl_config.h +++ b/myapps/blinky/ti_msp_dl_config.h @@ -34,13 +34,13 @@ * ============ ti_msp_dl_config.h ============= * Configured MSPM0 DriverLib module declarations * - * DO NOT EDIT - This file is generated for the MSPM0G350X + * DO NOT EDIT - This file is generated for the LP_MSPM0G3507 * by the SysConfig tool. */ #ifndef ti_msp_dl_config_h #define ti_msp_dl_config_h -#define CONFIG_MSPM0G350X +#define CONFIG_LP_MSPM0G3507 #define CONFIG_MSPM0G3507 #if defined(__ti_version__) || defined(__TI_COMPILER_VERSION__) @@ -73,10 +73,20 @@ extern "C" { #define POWER_STARTUP_DELAY (16) + #define CPUCLK_FREQ 32000000 + +/* Port definition for Pin Group GPIO_LEDS */ +#define GPIO_LEDS_PORT (GPIOB) + +/* Defines for USER_LED_1: GPIOB.22 with pinCMx 50 on package pin 21 */ +#define GPIO_LEDS_USER_LED_1_PIN (DL_GPIO_PIN_22) +#define GPIO_LEDS_USER_LED_1_IOMUX (IOMUX_PINCM50) + + /* clang-format on */ void SYSCFG_DL_init(void); @@ -85,6 +95,7 @@ void SYSCFG_DL_GPIO_init(void); void SYSCFG_DL_SYSCTL_init(void); + #ifdef __cplusplus } #endif