Changeset - 1900ee8afb4a
[Not reviewed]
cortex-f0
13 1 13
Ethan Zonca - 9 years ago 2015-11-28 12:19:52
ez@ethanzonca.com
Rorganize
14 files changed with 16 insertions and 8 deletions:
0 comments (0 inline, 0 general)
Makefile
Show inline comments
 
# STM32F0xx Makefile
 
# #####################################
 
#
 
# Part of the uCtools project
 
# uctools.github.com
 
#
 
#######################################
 
# user configuration:
 
#######################################
 

	
 

	
 
# SOURCES: list of sources in the user application
 
SOURCES = main.c usbd_conf.c usbd_cdc_if.c usb_device.c usbd_desc.c stm32f0xx_it.c system_stm32f0xx.c gpio.c spi.c ssd1306.c stringhelpers.c display.c syslib.c storage.c flash.c max31855.c max31865.c
 
SOURCES = main.c system/usbd_conf.c system/usbd_cdc_if.c system/usb_device.c system/usbd_desc.c system/interrupts.c system/system_stm32f0xx.c gpio.c spi.c ssd1306.c stringhelpers.c display.c system/syslib.c storage.c flash.c max31855.c max31865.c
 
#SRC = $(shell find . -name *.c)
 

	
 
# TARGET: name of the user application
 
TARGET = main
 

	
 
# BUILD_DIR: directory to place output files in
 
BUILD_DIR = build
 

	
 
# LD_SCRIPT: location of the linker script
 
LD_SCRIPT = stm32f042c6_flash.ld
 

	
 
# USER_DEFS user defined macros
 
USER_DEFS = -D HSI48_VALUE=48000000 -D HSE_VALUE=16000000
 
# USER_INCLUDES: user defined includes
 
USER_INCLUDES =
 
USER_INCLUDES = -Isystem
 

	
 
# USB_INCLUDES: includes for the usb library
 
USB_INCLUDES = -Imiddlewares/ST/STM32_USB_Device_Library/Core/Inc
 
USB_INCLUDES += -Imiddlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc
 

	
 
# USER_CFLAGS: user C flags (enable warnings, enable debug info)
 
USER_CFLAGS = -Wall -g -ffunction-sections -fno-exceptions -fdata-sections -Os
 
# USER_LDFLAGS:  user LD flags
 
USER_LDFLAGS = -fno-exceptions -ffunction-sections -fno-exceptions -fdata-sections -Wl,--gc-sections
 

	
 
# TARGET_DEVICE: device to compile for
 
TARGET_DEVICE = STM32F042x6
 

	
 
#######################################
 
# end of user configuration
 
#######################################
 
#
 
#######################################
 
# binaries
 
#######################################
 
CC = arm-none-eabi-gcc
 
AR = arm-none-eabi-ar
 
RANLIB = arm-none-eabi-ranlib
 
SIZE = arm-none-eabi-size
 
@@ -114,61 +115,68 @@ cubelib: $(CUBELIB)
 
# build the USB library
 
#######################################
 
USB_MIDDLEWARE_PATH = ./middlewares/ST/STM32_USB_Device_Library/
 
USB_BUILD_DIR = $(BUILD_DIR)/usb
 
USB_SOURCES += usbd_ctlreq.c usbd_ioreq.c usbd_core.c usbd_cdc.c
 
# list of usb library objects
 
USB_OBJECTS += $(addprefix $(USB_BUILD_DIR)/,$(notdir $(USB_SOURCES:.c=.o)))
 

	
 
usb: $(USB_OBJECTS)
 

	
 
$(USB_BUILD_DIR)/%.o: $(USB_MIDDLEWARE_PATH)/Core/Src/%.c | $(USB_BUILD_DIR)
 
	$(CC) -Os $(CFLAGS) -c -o $@ $^
 

	
 
$(USB_BUILD_DIR)/%.o: $(USB_MIDDLEWARE_PATH)/Class/CDC/Src/%.c | $(USB_BUILD_DIR)
 
	$(CC) -Os $(CFLAGS) -c -o $@ $^
 

	
 
$(USB_BUILD_DIR):
 
	@echo $(USB_BUILD_DIR)
 
	$(MKDIR) $@
 

	
 
#######################################
 
# build the user application
 
#######################################
 

	
 
SYSTEM_BUILD_DIR = $(BUILD_DIR)/system
 

	
 
# list of user program objects
 
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(SOURCES:.c=.o)))
 
#OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(SOURCES:.c=.o)))
 
OBJECTS = $(addprefix $(BUILD_DIR)/,$(SOURCES:.c=.o))
 
# add an object for the startup code
 
OBJECTS += $(BUILD_DIR)/startup_stm32f042x6.o
 

	
 
# use the periphlib core library, plus generic ones (libc, libm, libnosys)
 
LIBS = -lstm32cube -lc -lm -lnosys
 
LDFLAGS = -T $(LD_SCRIPT) -L $(CUBELIB_BUILD_DIR) $(LIBS) $(USER_LDFLAGS)
 

	
 
$(BUILD_DIR)/$(TARGET).hex: $(BUILD_DIR)/$(TARGET).elf
 
$(BUILD_DIR)/$(TARGET).hex: $(BUILD_DIR)/$(TARGET).elf | $(SYSTEM_BUILD_DIR)
 
	$(OBJCOPY) -O ihex $(BUILD_DIR)/$(TARGET).elf $@
 
	$(OBJCOPY) -O binary $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).bin
 

	
 
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) $(USB_OBJECTS) $(CUBELIB)
 
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) $(USB_OBJECTS) $(CUBELIB) | $(SYSTEM_BUILD_DIR)
 
	$(CC) -o $@ $(CFLAGS) $(USER_LDFLAGS) $(OBJECTS) $(USB_OBJECTS) \
 
		-L$(CUBELIB_BUILD_DIR) -static $(LIBS) -Xlinker \
 
		-Map=$(BUILD_DIR)/$(TARGET).map \
 
		-T $(LD_SCRIPT)
 
	$(SIZE) $@
 

	
 
$(BUILD_DIR)/%.o: %.c | $(BUILD_DIR)
 
$(SYSTEM_BUILD_DIR):
 
	@echo $(SYSTEM_BUILD_DIR)
 
	$(MKDIR) $@
 

	
 
$(BUILD_DIR)/%.o: %.c | $(BUILD_DIR) $(SYSTEM_BUILD_DIR)
 
	$(CC) $(CFLAGS) -Os -c -o $@ $^
 

	
 
$(BUILD_DIR)/%.o: %.s | $(BUILD_DIR)
 
$(BUILD_DIR)/%.o: %.s | $(BUILD_DIR) $(SYSTEM_BUILD_DIR)
 
	$(CC) $(CFLAGS) -c -o $@ $^
 

	
 
$(BUILD_DIR):
 
	$(MKDIR) $@
 

	
 
# delete all user application files, keep the libraries
 
clean:
 
		-rm $(BUILD_DIR)/*.o
 
		-rm $(BUILD_DIR)/*.elf
 
		-rm $(BUILD_DIR)/*.bin
 
		-rm $(BUILD_DIR)/*.map
 

	
 
.PHONY: clean all cubelib
system/interrupts.c
Show inline comments
 
file renamed from stm32f0xx_it.c to system/interrupts.c
 
@@ -13,49 +13,49 @@
 
  *      this list of conditions and the following disclaimer.
 
  *   2. 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.
 
  *   3. Neither the name of STMicroelectronics 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 HOLDER 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.
 
  *
 
  ******************************************************************************
 
  */
 
/* Includes ------------------------------------------------------------------*/
 
#include "stm32f0xx_hal.h"
 
#include "stm32f0xx.h"
 
#include "stm32f0xx_it.h"
 
#include "interrupts.h"
 
/* USER CODE BEGIN 0 */
 
 
/* USER CODE END 0 */
 
/* External variables --------------------------------------------------------*/
 
 
extern PCD_HandleTypeDef hpcd_USB_FS;
 
 
/******************************************************************************/
 
/*            Cortex-M0 Processor Interruption and Exception Handlers         */ 
 
/******************************************************************************/
 
 
/**
 
* @brief This function handles USB global Interrupt (combined with EXTI line 18).
 
*/
 
void USB_IRQHandler(void)
 
{
 
  /* USER CODE BEGIN USB_IRQn 0 */
 
 
  /* USER CODE END USB_IRQn 0 */
 
  HAL_PCD_IRQHandler(&hpcd_USB_FS);
 
  /* USER CODE BEGIN USB_IRQn 1 */
 
 
  /* USER CODE END USB_IRQn 1 */
 
}
system/interrupts.h
Show inline comments
 
file renamed from stm32f0xx_it.h to system/interrupts.h
system/startup_stm32f042x6.s
Show inline comments
 
file renamed from startup_stm32f042x6.s to system/startup_stm32f042x6.s
system/syslib.c
Show inline comments
 
file renamed from syslib.c to system/syslib.c
system/syslib.h
Show inline comments
 
file renamed from syslib.h to system/syslib.h
system/usb_device.c
Show inline comments
 
file renamed from usb_device.c to system/usb_device.c
system/usb_device.h
Show inline comments
 
file renamed from usb_device.h to system/usb_device.h
system/usbd_cdc_if.c
Show inline comments
 
file renamed from usbd_cdc_if.c to system/usbd_cdc_if.c
system/usbd_cdc_if.h
Show inline comments
 
file renamed from usbd_cdc_if.h to system/usbd_cdc_if.h
system/usbd_conf.c
Show inline comments
 
file renamed from usbd_conf.c to system/usbd_conf.c
system/usbd_conf.h
Show inline comments
 
file renamed from usbd_conf.h to system/usbd_conf.h
system/usbd_desc.c
Show inline comments
 
file renamed from usbd_desc.c to system/usbd_desc.c
system/usbd_desc.h
Show inline comments
 
file renamed from usbd_desc.h to system/usbd_desc.h
0 comments (0 inline, 0 general)