Hi,
I'm trying to compile a basic program that uses I2C for a TM4C123GH6PM without using any IDE (running Linux Mint 17 x64). So I found a Makefile that should be able to do this:
# Tiva Makefile # ##################################### # # Part of the uCtools project # uctools.github.com # ####################################### # user configuration: ####################################### # TARGET: name of the output file TARGET = main # MCU: part number to build for MCU = TM4C123GH6PM # SOURCES: list of input source sources SOURCES = main.c startup_gcc.c # INCLUDES: list of includes, by default, use Includes directory INCLUDES = -IInclude # OUTDIR: directory to use for output OUTDIR = build # TIVAWARE_PATH: path to tivaware folder #TIVAWARE_PATH = /home/eric/code/tivaware #TIVAWARE_PATH gets set by an environment variable # LD_SCRIPT: linker script LD_SCRIPT = $(MCU).ld # define flags CFLAGS = -g -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp CFLAGS +=-Os -ffunction-sections -fdata-sections -MD -std=c99 -Wall CFLAGS += -pedantic -DPART_$(MCU) -c -I$(TIVAWARE_PATH) CFLAGS += -DTARGET_IS_BLIZZARD_RA1 -Dgcc LDFLAGS = -T $(LD_SCRIPT) --entry ResetISR --gc-sections ####################################### # end of user configuration ####################################### # ####################################### # binaries ####################################### CC = arm-none-eabi-gcc LD = arm-none-eabi-ld OBJCOPY = arm-none-eabi-objcopy RM = rm -f MKDIR = mkdir -p ####################################### # list of object files, placed in the build directory regardless of source path OBJECTS = $(addprefix $(OUTDIR)/,$(notdir $(SOURCES:.c=.o))) # default: build bin all: $(OUTDIR)/$(TARGET).bin $(OUTDIR)/%.o: src/%.c | $(OUTDIR) $(CC) -o $@ $^ $(CFLAGS) $(OUTDIR)/a.out: $(OBJECTS) $(LD) -o $@ $^ $(LDFLAGS) $(OUTDIR)/main.bin: $(OUTDIR)/a.out $(OBJCOPY) -O binary $< $@ # create the output directory $(OUTDIR): $(MKDIR) $(OUTDIR) clean: -$(RM) $(OUTDIR)/* .PHONY: all clean
The problem is I get `undefined reference to `GPIOPinTypeI2CSCL'` and `undefined reference to `GPIOPinTypeI2C'` when trying to compile. The two lines that cause the error are:
GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
If I comment these lines out, I can compile and run the program on the device, but I2C obviously doesn't work.
These are the relevant include statements in my source code:
#include "inc/hw_types.h" #include "inc/hw_gpio.h" #include "inc/hw_memmap.h" #include "inc/hw_sysctl.h" #include "inc/hw_i2c.h" #include "driverlib/gpio.h" #include "driverlib/rom.h" #include "driverlib/sysctl.h" #include "driverlib/pin_map.h" #include "driverlib/i2c.h"
Is there anything wrong with my Makefile or am I missing an include?