diff --git a/Bootloader/main.c b/Bootloader/main.c index 9f3a45d..a02d53b 100644 --- a/Bootloader/main.c +++ b/Bootloader/main.c @@ -31,9 +31,13 @@ ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ -#include "boot_conf.h" +#include "mks_conf.h" #include "stm32f1xx_hal.h" +#include "stm32f1xx_hal_conf.h" +#include "stm32f1xx_hal_spi.h" +#include "stm32f1xx_hal_tim.h" +#include "boot_conf.h" #include "fatfs.h" #if defined(STM32F107xC) && defined(MKS_TFT) @@ -65,11 +69,6 @@ void Error_Handler(void); static void MX_GPIO_Init(void); void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); -void osDelay(__IO uint32_t Delay) -{ - HAL_Delay(Delay); -} - inline void moveVectorTable(uint32_t Offset) { // __disable_irq(); diff --git a/Inc/Buzzer.h b/Inc/Buzzer.h index 16becca..608671c 100644 --- a/Inc/Buzzer.h +++ b/Inc/Buzzer.h @@ -9,6 +9,9 @@ #ifndef BUZZER_H_ #define BUZZER_H_ +#include "mks_conf.h" +#include "stm32f1xx_hal_tim.h" + #ifdef __cplusplus namespace Buzzer diff --git a/Inc/PanelDue.h b/Inc/PanelDue.h index d71bb23..bdce3f2 100644 --- a/Inc/PanelDue.h +++ b/Inc/PanelDue.h @@ -13,6 +13,7 @@ #include "RequestTimer.h" #include "PrinterStatus.h" #include "UserInterface.h" +#include "eeprom.h" // Functions called from the serial I/O module extern void ProcessReceivedValue(const char id[], const char val[], int index); diff --git a/Inc/bsp_driver_sd.h b/Inc/bsp_driver_sd.h index 6c5a350..0bb6bda 100644 --- a/Inc/bsp_driver_sd.h +++ b/Inc/bsp_driver_sd.h @@ -36,12 +36,15 @@ #ifndef __STM32F1XX_SD_H #define __STM32F1XX_SD_H + #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal.h" +#include "stm32f1xx_hal_conf.h" +#include "stm32f1xx_hal_sd.h" /* Exported constants --------------------------------------------------------*/ diff --git a/Inc/eeprom.h b/Inc/eeprom.h index 3248585..afbc6dd 100644 --- a/Inc/eeprom.h +++ b/Inc/eeprom.h @@ -35,6 +35,7 @@ #define __EEPROM_H #include "stm32f1xx_hal.h" +#include "stm32f1xx_hal_i2c.h" #include "cmsis_os.h" #define EEPROM_ADDRESS 0xA0 // A0 = A1 = A2 = 0 diff --git a/Inc/mks_conf.h b/Inc/mks_conf.h index 7acf87c..a96dd86 100644 --- a/Inc/mks_conf.h +++ b/Inc/mks_conf.h @@ -36,9 +36,11 @@ #include "ecv.h" #include "stm32f1xx_hal.h" +#include "stm32f1xx_hal_spi.h" #include "cmsis_os.h" #include "fatfs.h" + #if defined(STM32F107xC) && defined(MKS_TFT) /** * Makerbase MKS-TFT32 diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..90688e3 --- /dev/null +++ b/Makefile @@ -0,0 +1,144 @@ +TARGET=main.hex +EXECUTABLE=main.elf +BINARY=main.bin + +CC=arm-none-eabi-gcc +LD=arm-none-eabi-gcc +AR=arm-none-eabi-ar +AS=arm-none-eabi-as +CP=arm-none-eabi-objcopy +OD=arm-none-eabi-objdump + +BIN=$(CP) -O ihex + +DEFS = -D__HEAP_SIZE=0x200 -D__STACK_SIZE=0x100 -DSTM32F107VC -DSTM32F10X_CL -DSTM32F107xC -DMKS_TFT -DILI9328 -MMD +STARTUP = Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f107xc.s + +MCU = cortex-m3 +MCFLAGS = -mcpu=$(MCU) -mthumb + +STM32_INCLUDES = -IDrivers/STM32F1xx_HAL_Driver/Inc/ \ + -IDrivers/CMSIS/Device/ST/STM32F1xx/Include/ \ + -IDrivers/CMSIS/Include/ \ + -IIcons \ + -IInc \ + -IBootloader \ + -IMiddlewares/Third_Party/FreeRTOS/Source/include \ + -IMiddlewares/Third_Party/FatFs/src/ \ + -IMiddlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc \ + -IMiddlewares/ST/STM32_USB_Host_Library/Core/Inc \ + -IMiddlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3 \ + -IMiddlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS + +OPTIMIZE = -Os + +CFLAGS = $(MCFLAGS) $(OPTIMIZE) $(DEFS) -fno-exceptions -funroll-loops -fdata-sections -ffunction-sections -g3 $(STM32_INCLUDES) -Wl,-T,STM32F107VC_FLASH.ld +AFLAGS = $(MCFLAGS) + +SRC = Src/main.c \ + Src/stm32f1xx_hal_msp.c \ + Src/stm32f1xx_hal_timebase_TIM.c \ + Src/stm32f1xx_it.c \ + Src/usb_host.c \ + Src/usbh_conf.c \ + Src/usbh_diskio.c \ + Src/fatfs.c \ + Src/spiflash_w25q16dv.c \ + Src/spisd_diskio.c \ + Src/Buzzer.cpp \ + Src/PanelDue.cpp \ + Src/Display.cpp \ + Src/FileManager.cpp \ + Src/SerialIo.cpp \ + Src/UserInterface.cpp \ + Src/UTFT.cpp \ + Src/UTouch.cpp \ + Src/eeprom.c \ + Src/Mem.cpp \ + Src/MessageLog.cpp \ + Src/Print.cpp \ + Src/Misc.cpp \ + Src/RequestTimer.cpp + +#SRC += Bootloader/flash.c \ +#Bootloader/main.c \ +#Bootloader/stm32f1xx_it.c \ + +SRC += Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_hcd.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usb.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \ +Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c +#Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_sd.c \ +#Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_fsmc.c \ +#Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_sdmmc.c \ +#Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_sram.c \ + +SRC += Fonts/glcd17x22.cpp \ +Icons/HomeIcons.cpp \ +Icons/KeyIcons.cpp \ +Icons/MiscIcons.cpp \ +Icons/NozzleIcons.cpp +#Fonts/glcd28x32.cpp \ + +SRC += Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc.c \ +Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_bot.c \ +Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_scsi.c \ +Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_core.c \ +Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c \ +Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ioreq.c \ +Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_pipes.c \ +Middlewares/Third_Party/FatFs/src/diskio.c \ +Middlewares/Third_Party/FatFs/src/ff.c \ +Middlewares/Third_Party/FatFs/src/ff_gen_drv.c \ +Middlewares/Third_Party/FatFs/src/option/ccsbcs.c \ +Middlewares/Third_Party/FatFs/src/option/syscall.c \ +Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c \ +Middlewares/Third_Party/FreeRTOS/Source/croutine.c \ +Middlewares/Third_Party/FreeRTOS/Source/event_groups.c \ +Middlewares/Third_Party/FreeRTOS/Source/list.c \ +Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c \ +Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c \ +Middlewares/Third_Party/FreeRTOS/Source/queue.c \ +Middlewares/Third_Party/FreeRTOS/Source/tasks.c \ +Middlewares/Third_Party/FreeRTOS/Source/timers.c \ + +OBJDIR = build +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) +OBJ += Startup.o + +all: $(BINARY) + +$(BINARY): $(EXECUTABLE) + $(CP) -O binary $(EXECUTABLE) $(BINARY) + +flash: $(BINARY) + st-flash write $(BINARY) 0x08000000 +# stm32flash -w $(BINARY) -v -g 0x0 /dev/ttyUSB0 + +$(EXECUTABLE): $(SRC) $(STARTUP) + $(CC) $(CFLAGS) $^ -lm -lstdc++ -lgcc -lc -lnosys -o $@ + +clean: + echo rm -f Startup.lst $(TARGET) $(TARGET).lst $(AUTOGEN) $(TARGET).out $(TARGET).hex $(TARGET).map \ + $(TARGET).dmp $(EXECUTABLE) +# $(OBJ) + +# Последнюю строчку лучше добавить в make, в секцию executable: +# $(EXECUTABLE): $(SRC) $(STARTUP) +# $(CC) $(CFLAGS) $^ -lm -lc -lnosys -o $@ +# $(CP) -O binary $(EXECUTABLE).elf $(EXECUTABLE).bin diff --git a/Src/Buzzer.cpp b/Src/Buzzer.cpp index 2fcbe46..9de4ee7 100644 --- a/Src/Buzzer.cpp +++ b/Src/Buzzer.cpp @@ -7,13 +7,13 @@ * The backlight control is included in this module because it also uses PWM. Output PWMH1 (aka PB1 peripheral A) drives the backlight pin. */ +#include "Buzzer.h" #include #include "ecv.h" #include "stm32f1xx_hal.h" #include "cmsis_os.h" -#include "Buzzer.h" TimerHandle_t xBuzzerTimer; extern TIM_HandleTypeDef htim2; diff --git a/Src/Mem.cpp b/Src/Mem.cpp index badc043..9aeddc6 100644 --- a/Src/Mem.cpp +++ b/Src/Mem.cpp @@ -5,10 +5,10 @@ * Author: David */ +#include "Mem.h" #include "ecv.h" #include "stm32f1xx_hal.h" #include "cmsis_os.h" -#include "Mem.h" //#include //void* operator new(size_t objsize, std::nothrow_t dummy) { diff --git a/Src/Misc.cpp b/Src/Misc.cpp index 2ec1ae3..3099395 100644 --- a/Src/Misc.cpp +++ b/Src/Misc.cpp @@ -8,7 +8,7 @@ #include "ecv.h" #include "Misc.h" -#include +//#include #include // Safe version of strncpy that ensures that the destination is always null-terminated on return diff --git a/Src/bsp_driver_sd.c b/Src/bsp_driver_sd.c index ad9e85d..44ff77a 100644 --- a/Src/bsp_driver_sd.c +++ b/Src/bsp_driver_sd.c @@ -36,7 +36,7 @@ #include "bsp_driver_sd.h" /* Extern variables ---------------------------------------------------------*/ - + extern SD_HandleTypeDef hsd; extern HAL_SD_CardInfoTypedef SDCardInfo; diff --git a/Src/fatfs.c b/Src/fatfs.c index 584527e..b90a6ba 100644 --- a/Src/fatfs.c +++ b/Src/fatfs.c @@ -31,8 +31,8 @@ ****************************************************************************** */ -#include "fatfs.h" #include "mks_conf.h" +#include "fatfs.h" #if defined(STM32F107xC) && defined(MKS_TFT) char SPISD_Path[4]; /* USER logical drive path */ diff --git a/Src/main.c b/Src/main.c index 96a13cd..a57903f 100644 --- a/Src/main.c +++ b/Src/main.c @@ -32,10 +32,10 @@ */ /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal.h" -#include "cmsis_os.h" -#include "fatfs.h" - +#include "stm32f1xx_hal_i2c.h" +#include "stm32f1xx_hal_uart.h" #include "mks_conf.h" +#include "cmsis_os.h" #if defined(STM32F107xC) && defined(MKS_TFT) # include "usb_host.h"