Mac osX下STM32F10x的快速开发(2)
- UID
- 1029342
- 性别
- 男
|
Mac osX下STM32F10x的快速开发(2)
LIBSTM32_OBJS = $(addprefix $(OBJ_DIR)/, $(notdir $(LIBSTM32_SRCS:.c=.o)))
USR_OBJS = $(addprefix $(OBJ_DIR)/, $(notdir $(USR_SRCS:.c=.o)))
ASM_SRCS = $(LIBSTM32_ASM_SRCS)
ASM_OBJS = $(addprefix $(OBJ_DIR)/, $(notdir $(LIBSTM32_ASM_SRCS:.s=.o)))
TCHAIN = arm-none-eabi
INCLUDE_DIRS = -I $(PRJDIR) -I $(SRCDIR) $(LIBSTM32_INCS) $(USR_INCS) $(USR_LIBS)
COMPILE_OPTS = -mcpu=cortex-m3 -mthumb -mfpu=vfp
COMPILE_OPTS+= -nostartfiles -fno-common -fomit-frame-pointer -Wall -g -O$(OPT)
LIBRARY_DIRS = -L $(STM32_LIB_DIR)/Libraries
PREDEFINES = $(LIBSTM32_DEFS) $(USR_DEFS)
CC = $(TCHAIN)-gcc
CFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) $(PREDEFINES)
CXX = $(TCHAIN)-g++
CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) $(PREDEFINES)
AS = $(TCHAIN)-gcc
ASFLAGS = $(COMPILE_OPTS) -c
LD = $(TCHAIN)-gcc
LDFLAGS = -Wl,--gc-sections,-Map=$(PROJECT).map,-cref,-u,Reset_Handler $(INCLUDE_DIRS) $(LIBRARY_DIRS) -T $(LD_FILE)
OBJCP = $(TCHAIN)-objcopy
AR = $(TCHAIN)-ar
ARFLAGS = cr
MAIN_OUT = $(PROJECT)_GCC
MAIN_OUT_ELF = $(MAIN_OUT).elf
MAIN_OUT_BIN = $(MAIN_OUT).bin
MAIN_OUT_HEX = $(MAIN_OUT).hex
MAIN_OUT_PROG = $(MAIN_OUT_HEX)
STR_DIV = ------------------------------------------------------------
# all
all: start gcc-info $(MAIN_OUT_ELF) $(MAIN_OUT_PROG) size flash end
# misc
start:
@echo Start Compiling Project $(PROJECT)
@echo User Files:
@echo $(USR_OBJS)
@echo STM32 Library Files:
@echo $(LIBSTM32_OBJS)
end:
@echo $(STR_DIV)
@echo bye!!
gcc-info:
@echo $(STR_DIV)
@echo gcc version is
@$(CC) --version
@echo $(STR_DIV)
# main
$(MAIN_OUT_ELF): $(ASM_OBJS) $(USR_OBJS) $(LIBSTM32_OBJS)
$(LD) $(LDFLAGS) $(ASM_OBJS) $(LIBSTM32_OBJS) $(USR_OBJS) --output $@
$(MAIN_OUT_BIN): $(MAIN_OUT_ELF)
$(OBJCP) -O binary $< $@
$(MAIN_OUT_HEX): $(MAIN_OUT_ELF)
$(OBJCP) -O ihex $< $@
size: $(MAIN_OUT_ELF)
@echo $(STR_DIV)
$(TCHAIN)-size $(MAIN_OUT_ELF)
flash: $(MAIN_OUT_PROG)
# @echo $(STR_DIV)
# vsprog -sstm32 -G -mj -I $(MAIN_OUT_HEX) -oe -owf -ovf
$(ASM_OBJS): $(ASM_SRCS)
$(CC) -c $(CFLAGS) $^
$(LIBSTM32_OBJS): $(LIBSTM32_SRCS)
$(CC) -c $(CFLAGS) $^
$(USR_OBJS): $(USR_SRCS)
$(CC) -c $(CFLAGS) $^
clean:
-rm $(USR_OBJS) $(PROJECT).map $(ASM_OBJS) $(LIBSTM32_OBJS) $(MAIN_OUT_ELF) $(MAIN_OUT_PROG)
5、修改Dfuse/src/main.c文件,使用自己定义的按键或者别的进入DFUse状态的条件,我的代码如下:
int main(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
/* Configure Button pin as input floating */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_ResetBits(GPIOB, GPIO_Pin_1);
// DFU_Button_Config();
/* Check if the Key push-button on STM3210x-EVAL Board is pressed */
if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1) == 0x00)
{ /* Test if user code is programmed starting from address 0x8003000 */
if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000)
{ /* Jump to user application */
JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) ApplicationAddress);
Jump_To_Application();
}
} /* Otherwise enters DFU mode to allow user to program his application */
// GPIO_SetBits(GPIOB, GPIO_Pin_0);
/* Enter DFU mode */
DeviceState = STATE_dfuERROR;
DeviceStatus[0] = STATUS_ERRFIRMWARE;
DeviceStatus[4] = DeviceState;
Set_System();
Set_USBClock();
USB_Init();
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_SetBits(GPIOB, GPIO_Pin_0);
/* Main loop */
while (1)
{}
}
|
|
|
|
|
|
|