diff --git a/Build/arch_config/riscv_rv32.config b/Build/arch_config/riscv_rv32.config new file mode 100644 index 00000000..91adb6b4 --- /dev/null +++ b/Build/arch_config/riscv_rv32.config @@ -0,0 +1,54 @@ +include $(BUILD_DIR)/compiler_configs/riscv_embed_gcc/riscv_none_embed_gcc.config + +# c语言文件编译参数 +CFLAGS += -march=rv32imac +CFLAGS += -mabi=ilp32 +CFLAGS += -msmall-data-limit=8 +CFLAGS += -msave-restore +CFLAGS += -Os +CFLAGS += -fmessage-length=0 +CFLAGS += -fsigned-char +CFLAGS += -ffunction-sections +CFLAGS += -fdata-sections +CFLAGS += -fno-common +CFLAGS += -Wunused +CFLAGS += -Wuninitialized +CFLAGS += -std=gnu99 +# CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<" + +#汇编文件编译参数 +ASMFLAGS += -march=rv32imac +ASMFLAGS += -mabi=ilp32 +ASMFLAGS += -msmall-data-limit=8 +ASMFLAGS += -msave-restore +ASMFLAGS += -Os +ASMFLAGS += -fmessage-length=0 +ASMFLAGS += -fsigned-char +ASMFLAGS += -ffunction-sections +ASMFLAGS += -fdata-sections +ASMFLAGS += -fno-common +ASMFLAGS += -Wunused +ASMFLAGS += -Wuninitialized +ASMFLAGS += -x assembler-with-cpp +# ASMFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<" + +#链接参数 +CLINK_FLAGS += -march=rv32imac +CLINK_FLAGS += -mabi=ilp32 +CLINK_FLAGS += -msmall-data-limit=8 +CLINK_FLAGS += -msave-restore +CLINK_FLAGS += -Os +CLINK_FLAGS += -fmessage-length=0 +CLINK_FLAGS += -fsigned-char +CLINK_FLAGS += -ffunction-sections +CLINK_FLAGS += -fdata-sections +CLINK_FLAGS += -fno-common +CLINK_FLAGS += -Wunused +CLINK_FLAGS += -Wuninitialized +CLINK_FLAGS += -nostartfiles +CLINK_FLAGS += -Xlinker --gc-sections --specs=nano.specs --specs=nosys.specs + +#芯片架构(会用在硬件平台相关的编译控制上,如bsp) +CATOS_BOARD_ARCH = riscv-rv32 + +.EXPORT_ALL_VARIABLES: diff --git a/Build/compiler_configs/arm_none_gcc/rules.mk b/Build/compiler_configs/arm_none_gcc/rules.mk index 0158ee51..1be1cc16 100644 --- a/Build/compiler_configs/arm_none_gcc/rules.mk +++ b/Build/compiler_configs/arm_none_gcc/rules.mk @@ -41,7 +41,7 @@ ifdef obj-y #编译文件 $(OBJ_OUT_DIR)/%.o: $(CUR_DIR)/%.c ifeq ($(compile_enable_detail), n) - @echo "compile $<" + @echo "compile $(notdir $<)" @$(CC) $(CINCLUDE_FILE_FLAG) $(CFLAGS) -o $@ -c $< else $(CC) $(CINCLUDE_FILE_FLAG) $(CFLAGS) -o $@ -c $< diff --git a/Build/compiler_configs/riscv_embed_gcc/riscv_none_embed_gcc.config b/Build/compiler_configs/riscv_embed_gcc/riscv_none_embed_gcc.config new file mode 100644 index 00000000..7df545a7 --- /dev/null +++ b/Build/compiler_configs/riscv_embed_gcc/riscv_none_embed_gcc.config @@ -0,0 +1,24 @@ +#编译命令指定 +#TOOLCHAIN_DIR = $(shell pwd) +CROSS_COMPILE = $(BUILD_DIR)/../../../riscv_embed_gcc/bin/riscv-none-embed- + +CC = $(CROSS_COMPILE)gcc +AS = $(CROSS_COMPILE)gcc +AR = $(CROSS_COMPILE)ar +LD = $(CROSS_COMPILE)gcc +CP = $(CROSS_COMPILE)objcopy +SZ = $(CROSS_COMPILE)size + +#添加参数使LD输出.map文件:-Wl,-Map=xx.map +LIST_MAP_FILE = -Wl,-Map + +#规则目录指定 +RULE_DIR = $(BUILD_DIR)/compiler_configs/riscv_embed_gcc + +#最终目标文件名 +MAP_NAME := $(PROJECT).map +ELF_NAME := $(PROJECT).elf +BIN_NAME := $(PROJECT).bin +HEX_NAME := $(PROJECT).hex + +.EXPORT_ALL_VARIABLES: \ No newline at end of file diff --git a/Build/compiler_configs/riscv_embed_gcc/rules.mk b/Build/compiler_configs/riscv_embed_gcc/rules.mk new file mode 100644 index 00000000..3540c789 --- /dev/null +++ b/Build/compiler_configs/riscv_embed_gcc/rules.mk @@ -0,0 +1,80 @@ +#当前目录 +CUR_DIR = $(shell pwd) + +#目标名(当前目录的目录名(不带完整前缀)) +TARGET := $(lastword $(subst /, ,$(CUR_DIR))) +#输出目录 +#OBJ_OUT_DIR = $(CUR_DIR) +OBJ_OUT_DIR = $(subst $(TOP_DIR),$(RELATIVE_PATH)/$(OBJ_DIR),$(CUR_DIR)) +#给obj目标添加输出目录作为前缀 +OBJ_TARGET = $(patsubst %,$(OBJ_OUT_DIR)/%,$(obj-y)) +#要创建的输出目录,并排序 +OBJ_Y_DIR = $(sort $(dir $(OBJ_TARGET))) +#c文件编译包含目录 +CINCLUDE_FILE_FLAG := $(addprefix -I$(RELATIVE_PATH)/,$(CINCLUDE_FILE)) + +#设置为伪目标,否则检测到文件或目录存在就不会执行命令 +.PHONY: print_cat_compile_info $(subdir-y) $(TARGET) + +all: print_cat_compile_info $(OBJ_Y_DIR) $(TARGET) + +#在子makefile里声明编译前需要打印的信息,VERIFY_MSG = xxx +print_cat_compile_info: +ifdef CAT_COMPILE_INFO +#这里echo要先输出一个空格,换行才能对齐 + @echo " $(CAT_COMPILE_INFO)" +endif + +#创建输出目录 +$(OBJ_Y_DIR): + @echo "\n-->make$(OBJ_Y_DIR)" + @if [ ! -d "$@" ];then $(MK_DIR) $@ ;fi; + + +#让all目标间接依赖OBJ_TARGET,又由于OBJ_TARGET的.o没有给出, +#就会和$(OBJ_OUT_DIR)/%.o匹配 +#############!!note1:subdir-y必须在OBJ_TARGET之后,因为subdir-y的编译 +#需要增加RELATIVE_PATH的层数 +$(TARGET): $(OBJ_TARGET) $(subdir-y) + +ifdef obj-y +#编译文件 +$(OBJ_OUT_DIR)/%.o: $(CUR_DIR)/%.c +ifeq ($(compile_enable_detail), n) + @echo "compile $<" + @$(CC) $(CINCLUDE_FILE_FLAG) $(CFLAGS) -o $@ -c $< +else + $(CC) $(CINCLUDE_FILE_FLAG) $(CFLAGS) -o $@ -c $< +endif + +$(OBJ_OUT_DIR)/%.o: $(CUR_DIR)/%.s +ifeq ($(compile_enable_detail), n) + @echo "compile $<" + @$(AS) $(ASMINCLUDE_FILE_FLAG) $(ASMFLAGS) -o $@ -c $< +else + $(AS) $(ASMINCLUDE_FILE_FLAG) $(ASMFLAGS) -o $@ -c $< +endif + + +$(OBJ_OUT_DIR)/%.o: $(CUR_DIR)/%.S +ifeq ($(compile_enable_detail), n) + @echo "compile $<" + @$(AS) $(ASMINCLUDE_FILE_FLAG) $(ASMFLAGS) -o $@ -c $< +else + $(AS) $(ASMINCLUDE_FILE_FLAG) $(ASMFLAGS) -o $@ -c $< +endif + +endif #ifdef obj-y + +#更改相对路径,以便目录层级创建 +#############!!note2:添加../必须放在这里,放前面的话生成的obj会再往上一个目录... +#就不在目标的output目录了 +ifdef subdir-y +RELATIVE_PATH := $(addprefix ../,$(RELATIVE_PATH)) +endif + +#编译子目录 +$(subdir-y): + $(MAKE) -C $@ + +export CINCLUDE_FILE diff --git a/workspace/Makefile_content b/workspace/Makefile_content index 24e5faf7..98900fc9 100644 --- a/workspace/Makefile_content +++ b/workspace/Makefile_content @@ -5,6 +5,10 @@ CAT_COMPILE_INFO += OUT_ELF = $(TEXT_COLOR_GREEN)$(OUT_ELF)$(TEXT_COLOR_END)\n CAT_COMPILE_INFO += compile_enable_detail = $(TEXT_COLOR_GREEN)$(compile_enable_detail)$(TEXT_COLOR_END)\n +include projects/$(PROJECT)/include_paths.mk + +CINCLUDE_FILE += projects/$(PROJECT)/user + subdir-y += catOS subdir-y += projects diff --git a/workspace/catOS/Makefile b/workspace/catOS/Makefile index ebd6f99e..69896c92 100644 --- a/workspace/catOS/Makefile +++ b/workspace/catOS/Makefile @@ -1,23 +1,4 @@ -CINCLUDE_FILE += catOS/bsp/interface -CINCLUDE_FILE += catOS/bsp/interface/drivers -CINCLUDE_FILE += catOS/bsp/arch/$(CATOS_BOARD_ARCH)/$(CATOS_BOARD_BSP)/drivers - - -CINCLUDE_FILE += catOS/include - -CINCLUDE_FILE += catOS/src/component/cat_device -CINCLUDE_FILE += catOS/src/component/cat_shell -CINCLUDE_FILE += catOS/src/component/cat_stdio -CINCLUDE_FILE += catOS/src/component/cat_string - -CINCLUDE_FILE += catOS/src/core/idle_task -CINCLUDE_FILE += catOS/src/core/init -CINCLUDE_FILE += catOS/src/core/interrupt -CINCLUDE_FILE += catOS/src/core/schedule -CINCLUDE_FILE += catOS/src/core/support - -CINCLUDE_FILE += user subdir-y += bsp subdir-y += src diff --git a/workspace/catOS/bsp/Libraries/STM32F1xx_HAL_Driver/Makefile b/workspace/catOS/bsp/Libraries/STM32F1xx_HAL_Driver/Makefile index f85d2010..95abda1f 100644 --- a/workspace/catOS/bsp/Libraries/STM32F1xx_HAL_Driver/Makefile +++ b/workspace/catOS/bsp/Libraries/STM32F1xx_HAL_Driver/Makefile @@ -1,9 +1,4 @@ -CINCLUDE_FILE += catOS/bsp/Libraries/CMSIS/Include -CINCLUDE_FILE += catOS/bsp/Libraries/CMSIS/Device/ST/STM32F1xx/Include -CINCLUDE_FILE += catOS/bsp/Libraries/STM32F1xx_HAL_Driver/Inc -CINCLUDE_FILE += catOS/bsp/Libraries/STM32F1xx_HAL_Driver - subdir-y += Src obj-y += stm32f1xx_it.o diff --git a/workspace/catOS/bsp/Libraries/STM32F1xx_HAL_Driver/Src/Makefile b/workspace/catOS/bsp/Libraries/STM32F1xx_HAL_Driver/Src/Makefile index 96b4cf14..ee4b7803 100644 --- a/workspace/catOS/bsp/Libraries/STM32F1xx_HAL_Driver/Src/Makefile +++ b/workspace/catOS/bsp/Libraries/STM32F1xx_HAL_Driver/Src/Makefile @@ -1,10 +1,4 @@ -CINCLUDE_FILE += user - -CINCLUDE_FILE += catOS/bsp/$(CATOS_BOARD_BSP)/Libraries/CMSIS/Include -CINCLUDE_FILE += catOS/bsp/$(CATOS_BOARD_BSP)/Libraries/CMSIS/Device/ST/STM32F1xx/Include -CINCLUDE_FILE += catOS/bsp/$(CATOS_BOARD_BSP)/Libraries/STM32F1xx_HAL_Driver/Inc - #HAL_LIB_DRIVER obj-y += stm32f1xx_hal_adc.o diff --git a/workspace/catOS/bsp/Makefile b/workspace/catOS/bsp/Makefile index 1143af22..9a9d1779 100644 --- a/workspace/catOS/bsp/Makefile +++ b/workspace/catOS/bsp/Makefile @@ -1,7 +1,5 @@ #VERIFY_MSG = catOS/port:$(RELATIVE_PATH)***** making catOS port dir ***** -CINCLUDE_FILE += catOS/bsp/Libraries - subdir-y += arch subdir-y += Libraries diff --git a/workspace/catOS/bsp/arch/cortex_m3/Makefile b/workspace/catOS/bsp/arch/cortex_m3/Makefile index 97e8cc3b..b923bfda 100644 --- a/workspace/catOS/bsp/arch/cortex_m3/Makefile +++ b/workspace/catOS/bsp/arch/cortex_m3/Makefile @@ -1,5 +1,6 @@ #VERIFY_MSG = catOS/port:$(RELATIVE_PATH)***** making catOS port dir ***** -subdir-y += $(CATOS_BOARD_BSP) +subdir-y += board +subdir-y += libcpu include $(RULE_DIR)/rules.mk diff --git a/workspace/catOS/bsp/arch/cortex_m3/board/Makefile b/workspace/catOS/bsp/arch/cortex_m3/board/Makefile new file mode 100644 index 00000000..97e8cc3b --- /dev/null +++ b/workspace/catOS/bsp/arch/cortex_m3/board/Makefile @@ -0,0 +1,5 @@ +#VERIFY_MSG = catOS/port:$(RELATIVE_PATH)***** making catOS port dir ***** + +subdir-y += $(CATOS_BOARD_BSP) + +include $(RULE_DIR)/rules.mk diff --git a/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/Makefile b/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/Makefile index b1bcf8e6..525311e6 100644 --- a/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/Makefile +++ b/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/Makefile @@ -1,15 +1,5 @@ #INCLUDE DIR FOR "stm32f103vet6_min" -CINCLUDE_FILE += catOS/bsp/Libraries/CMSIS/Include -CINCLUDE_FILE += catOS/bsp/Libraries/CMSIS/Device/ST/STM32F1xx/Include -CINCLUDE_FILE += catOS/bsp/Libraries/STM32F1xx_HAL_Driver/Inc -CINCLUDE_FILE += catOS/bsp/Libraries/STM32F1xx_HAL_Driver - -CINCLUDE_FILE += catOS/bsp/arch/$(CATOS_BOARD_ARCH)/$(CATOS_BOARD_BSP)/drivers/uart -CINCLUDE_FILE += catOS/bsp/interface -CINCLUDE_FILE += catOS/include -CINCLUDE_FILE += catOS/src/core/interrupt -CINCLUDE_FILE += catOS/src/core/schedule #subdir subdir-y += drivers diff --git a/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/drivers/pin/cat_drv_pin.c b/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/drivers/pin/cat_drv_pin.c index 6a158ec3..5378bcf4 100644 --- a/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/drivers/pin/cat_drv_pin.c +++ b/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/drivers/pin/cat_drv_pin.c @@ -32,7 +32,7 @@ void cat_pin_device_init(void) #endif } -cat_uint8_t cat_pin_init(cat_uint32_t pin_num, cat_uint8_t mode) +cat_err_t cat_pin_init(cat_uint32_t pin_num, cat_uint8_t mode) { cat_uint8_t ret = CAT_ERROR; stm32f103vet6_fire_pin_t *p = &(pin_map[0]); @@ -82,15 +82,13 @@ cat_uint8_t cat_pin_init(cat_uint32_t pin_num, cat_uint8_t mode) return ret; } -cat_uint8_t cat_pin_set_mode(cat_uint32_t pin_num, cat_uint8_t mode) +void cat_pin_set_mode(cat_uint32_t pin_num, cat_uint8_t mode) { - cat_uint8_t ret = CAT_ERROR; CAT_KPRINTF("[pin] set mode now not support, abort!\r\n"); - return ret; } -cat_int8_t cat_pin_read(cat_uint32_t pin_num) +cat_uint8_t cat_pin_read(cat_uint32_t pin_num) { cat_int8_t ret = CAT_ERROR; CAT_KPRINTF("[pin] read func now not support, abort!\r\n"); @@ -98,9 +96,8 @@ cat_int8_t cat_pin_read(cat_uint32_t pin_num) } -cat_uint8_t cat_pin_write(cat_uint32_t pin_num, cat_uint8_t val) +void cat_pin_write(cat_uint32_t pin_num, cat_uint8_t val) { - cat_uint8_t ret = CAT_EINVAL; stm32f103vet6_fire_pin_t *p = &(pin_map[0]); /* 遍历pin_map数组 */ @@ -110,14 +107,11 @@ cat_uint8_t cat_pin_write(cat_uint32_t pin_num, cat_uint8_t val) { HAL_GPIO_WritePin(p->port, p->gpio_pin, (GPIO_PinState)val); - ret = CAT_EOK; /* 写入结束结束循环 */ break; } /* if */ } /* for */ - - return ret; } #if (CATOS_ENABLE_CAT_SHELL == 1) @@ -151,7 +145,7 @@ void *do_write_pin(void *arg) CAT_KPRINTF("[pin] pin=%d, val=%d\r\n", pin_num, val); /* 调用pin_write函数写入 */ - ret = cat_pin_write(pin_num, val); + cat_pin_write(pin_num, val); if(ret != CAT_EOK) { CAT_SYS_PRINTF("[pin] fail to write !!\r\n"); diff --git a/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/port/gcc/Makefile b/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/port/gcc/Makefile index c646e9e9..22598f9b 100644 --- a/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/port/gcc/Makefile +++ b/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/port/gcc/Makefile @@ -5,7 +5,7 @@ obj-y += catos_start.o -obj-y += port_asm.o +# obj-y += port_asm.o obj-y += port.o include $(RULE_DIR)/rules.mk diff --git a/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/port/gcc/catos_start.s b/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/port/gcc/catos_start.s index 03b7b0b2..e0cff176 100644 --- a/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/port/gcc/catos_start.s +++ b/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/port/gcc/catos_start.s @@ -114,7 +114,7 @@ LoopFillZerobss: /* bl __libc_init_array */ /* Call the application's entry point.*/ /* 调用catos入口函数,并在完成初始化后跳转至用户主函数 */ - bl catos_init + bl main bx lr .size Reset_Handler, .-Reset_Handler diff --git a/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/port/gcc/port.c b/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/port/gcc/port.c index 6fa7704d..d87c013a 100644 --- a/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/port/gcc/port.c +++ b/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/port/gcc/port.c @@ -64,7 +64,7 @@ void SysTick_Handler(void) /* 开始调度 */ void catos_start_sched(void) { - +#if 0 cat_sp_task_before_start_first(); /* 开启定时器中断 */ @@ -74,77 +74,28 @@ void catos_start_sched(void) MEM8(NVIC_SYSPRI2) = NVIC_PENDSV_PRI; MEM32(NVIC_INT_CTRL) = NVIC_PENDSVSET; -} +#else + struct _cat_task_t *first_task = NULL; -/* 栈初始化 */ -/**< 异常触发时自动保存的寄存器 */ -struct _exception_stack_frame -{ - cat_uint32_t r0; - cat_uint32_t r1; - cat_uint32_t r2; - cat_uint32_t r3; - cat_uint32_t r12; - cat_uint32_t lr; /**< r14 */ - cat_uint32_t pc; /**< r15 */ - cat_uint32_t psr; -}; - -struct _stack_frame -{ - /**< 需要自行保存的寄存器 */ - cat_uint32_t r4; - cat_uint32_t r5; - cat_uint32_t r6; - cat_uint32_t r7; - cat_uint32_t r8; - cat_uint32_t r9; - cat_uint32_t r10; - cat_uint32_t r11; - - struct _exception_stack_frame exeption_stack_frame; -}; + //cat_sp_task_before_start_first(); + /* 获取最高优先级任务 */ + first_task = cat_sp_task_highest_ready(); -/** - * @brief 栈初始化 - * - * @param task_entry 任务入口函数地址 - * @param parameter 参数 - * @param stack_addr 栈起始地址 - * @param exit 任务退出函数地址 - * @return cat_uint8_t* 初始化后的栈顶地址 - */ -cat_uint8_t *cat_hw_stack_init(void *task_entry, void *arg, cat_uint8_t *stack_addr, void *exit_func) -{ - struct _stack_frame *stack_frame; - cat_uint8_t *stack; - cat_uint32_t i; + /* 因为是第一个任务,不用像调度时判断是否和上一个任务一样,直接赋值给当前任务就行 */ + cat_sp_cur_task = first_task; - /* 先加上4字节再8字节向下取整对齐(相当于四舍五入) */ - stack = stack_addr += sizeof(cat_uint32_t); - stack = (cat_uint8_t *)CAT_ALIGN_DOWN((cat_uint32_t)stack, 8); + /* 允许调度(打开调度锁,并且不在该处进行调度) */ + cat_sp_task_sched_enable_without_sched(); - /* 栈向上生长 */ - stack -= sizeof(struct _stack_frame); - stack_frame = (struct _stack_frame *)stack; + /* 开启时钟中断 */ + SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; - /* 初始化栈帧中所有寄存器 */ - for(i = 0; i < (sizeof(struct _stack_frame) / sizeof(cat_uint32_t)); i++) - { - ((cat_uint32_t *)stack_frame)[i] = 0xdeadbeef; - } + /* 设置pendsv中断优先级 */ + MEM8(NVIC_SYSPRI2) = NVIC_PENDSV_PRI; - stack_frame->exeption_stack_frame.r0 = (cat_uint32_t)arg; - stack_frame->exeption_stack_frame.r1 = 0; - stack_frame->exeption_stack_frame.r2 = 0; - stack_frame->exeption_stack_frame.r3 = 0; - stack_frame->exeption_stack_frame.r12 = 0; - stack_frame->exeption_stack_frame.lr = (cat_uint32_t)exit_func; - stack_frame->exeption_stack_frame.pc = (cat_uint32_t)task_entry; - stack_frame->exeption_stack_frame.psr = (cat_uint32_t)(1 << 24); - - /* 返回当前栈指针 */ - return stack; + /* 切换到第一个任务 */ + cat_hw_context_switch_to_first((cat_uint32_t)&(first_task->sp)); +#endif } diff --git a/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103vet6_fire/Makefile b/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103vet6_fire/Makefile index a57df8f9..37be4e9b 100644 --- a/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103vet6_fire/Makefile +++ b/workspace/catOS/bsp/arch/cortex_m3/board/stm32f103vet6_fire/Makefile @@ -1,17 +1,4 @@ -#INCLUDE DIR FOR "stm32f103vet6_fire" -CINCLUDE_FILE += catOS/bsp/Libraries/CMSIS/Include -CINCLUDE_FILE += catOS/bsp/Libraries/CMSIS/Device/ST/STM32F1xx/Include -CINCLUDE_FILE += catOS/bsp/Libraries/STM32F1xx_HAL_Driver/Inc -CINCLUDE_FILE += catOS/bsp/Libraries/STM32F1xx_HAL_Driver - -CINCLUDE_FILE += catOS/bsp/interface -CINCLUDE_FILE += catOS/bsp/interface/drivers - -CINCLUDE_FILE += catOS/include -CINCLUDE_FILE += catOS/src/core/interrupt -CINCLUDE_FILE += catOS/src/core/schedule - #subdir subdir-y += drivers subdir-y += port diff --git a/workspace/catOS/bsp/arch/cortex_m3/libcpu/Makefile b/workspace/catOS/bsp/arch/cortex_m3/libcpu/Makefile new file mode 100644 index 00000000..213369a6 --- /dev/null +++ b/workspace/catOS/bsp/arch/cortex_m3/libcpu/Makefile @@ -0,0 +1,4 @@ +obj-y += contex.o +obj-y += cpu_port.o + +include $(RULE_DIR)/rules.mk diff --git a/workspace/catOS/bsp/interface/drivers/cat_pin.h b/workspace/catOS/bsp/interface/drivers/cat_pin.h index 2514e47b..1a8d5670 100644 --- a/workspace/catOS/bsp/interface/drivers/cat_pin.h +++ b/workspace/catOS/bsp/interface/drivers/cat_pin.h @@ -15,7 +15,7 @@ #include "catos_config.h" #include "catos_types.h" -#include "cat_drv_pin.h" +#include "pin/cat_drv_pin.h" #define PIN(_port_name, _pin) DRV_PIN_NUM(_port_name, _pin) diff --git a/workspace/catOS/src/component/cat_stdio/Makefile b/workspace/catOS/src/component/cat_stdio/Makefile index 5d3ff0c1..f7faf09c 100644 --- a/workspace/catOS/src/component/cat_stdio/Makefile +++ b/workspace/catOS/src/component/cat_stdio/Makefile @@ -1,6 +1,4 @@ -CINCLUDE_FILE += catOS/src/support -CINCLUDE_FILE += catOS/user/bsp/uart obj-y += cat_stdio.o diff --git a/workspace/catOS/src/component/mem_rw/Makefile b/workspace/catOS/src/component/mem_rw/Makefile index 6c75778e..3cfc18ed 100644 --- a/workspace/catOS/src/component/mem_rw/Makefile +++ b/workspace/catOS/src/component/mem_rw/Makefile @@ -1,13 +1,5 @@ -CINCLUDE_FILE += catOS/include - -CINCLUDE_FILE += catOS/src/components/cat_error -CINCLUDE_FILE += catOS/src/components/cat_stdio - -CINCLUDE_FILE += catOS/src/support - - obj-y += mem_rw.o include $(RULE_DIR)/rules.mk diff --git a/workspace/catOS/src/core/schedule/Makefile b/workspace/catOS/src/core/schedule/Makefile index 62f60c2c..1a90a553 100644 --- a/workspace/catOS/src/core/schedule/Makefile +++ b/workspace/catOS/src/core/schedule/Makefile @@ -2,4 +2,6 @@ subdir-y += basic_task subdir-y += static_prio_sched +obj-y += cat_task.o + include $(RULE_DIR)/rules.mk \ No newline at end of file diff --git a/workspace/projects/demo/Makefile b/workspace/projects/demo/Makefile index 6e1795eb..030ad376 100644 --- a/workspace/projects/demo/Makefile +++ b/workspace/projects/demo/Makefile @@ -1,5 +1,4 @@ -CINCLUDE_FILE += catOS/include subdir-y += user diff --git a/workspace/projects/demo/demo.config b/workspace/projects/demo/demo.config index f484fda1..927fdc6a 100644 --- a/workspace/projects/demo/demo.config +++ b/workspace/projects/demo/demo.config @@ -3,7 +3,7 @@ include $(COMMON_CONFIG_DIR)/common_configs.mk #2: 开发板 -CATOS_BOARD_BSP = stm32f103vet6_fire +CATOS_BOARD_BSP = stm32f103c8t6_min # 可选开发板: # 1). stm32f103vet6_fire 野火指南者开发板 (cortex-m3:stm32f103vet6) # 2). stm32f103c8t6_min c8t6最小系统板 (cortex-m3:stm32f103c8t6) diff --git a/workspace/projects/demo/include_paths.mk b/workspace/projects/demo/include_paths.mk new file mode 100644 index 00000000..ed2a86a6 --- /dev/null +++ b/workspace/projects/demo/include_paths.mk @@ -0,0 +1,28 @@ + +CINCLUDE_FILE += catOS/include + +CINCLUDE_FILE += catOS/src/component/cat_device +CINCLUDE_FILE += catOS/src/component/cat_shell +CINCLUDE_FILE += catOS/src/component/cat_stdio +CINCLUDE_FILE += catOS/src/component/cat_string + +CINCLUDE_FILE += catOS/src/core/idle_task +CINCLUDE_FILE += catOS/src/core/init +CINCLUDE_FILE += catOS/src/core/interrupt +CINCLUDE_FILE += catOS/src/core/schedule +CINCLUDE_FILE += catOS/src/core/support + +CINCLUDE_FILE += user + +CINCLUDE_FILE += catOS/bsp/interface +CINCLUDE_FILE += catOS/bsp/interface/drivers +CINCLUDE_FILE += catOS/bsp/interface/drivers/iic + +# CINCLUDE_FILE += catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/drivers/pin + +CINCLUDE_FILE += catOS/bsp/arch/$(CATOS_BOARD_ARCH)/board/$(CATOS_BOARD_BSP)/drivers + +CINCLUDE_FILE += catOS/bsp/Libraries/CMSIS/Include +CINCLUDE_FILE += catOS/bsp/Libraries/CMSIS/Device/ST/STM32F1xx/Include +CINCLUDE_FILE += catOS/bsp/Libraries/STM32F1xx_HAL_Driver/Inc +CINCLUDE_FILE += catOS/bsp/Libraries/STM32F1xx_HAL_Driver \ No newline at end of file diff --git a/workspace/projects/demo/user/Makefile b/workspace/projects/demo/user/Makefile index f39d1883..6270ec96 100644 --- a/workspace/projects/demo/user/Makefile +++ b/workspace/projects/demo/user/Makefile @@ -1,14 +1,4 @@ -# CINCLUDE_FILE += catOS/bsp/Libraries/CMSIS/Include -# CINCLUDE_FILE += catOS/bsp/Libraries/CMSIS/Device/ST/STM32F1xx/Include -# CINCLUDE_FILE += catOS/bsp/Libraries/STM32F1xx_HAL_Driver/Inc -# CINCLUDE_FILE += catOS/bsp/Libraries/STM32F1xx_HAL_Driver - -# CINCLUDE_FILE += catOS/bsp/$(CATOS_BOARD_BSP)/drivers/uart -CINCLUDE_FILE += catOS/include - -# CINCLUDE_FILE += projects/demo/user/bsp/board_led - # subdir-y += bsp diff --git a/workspace/projects/demo/user/bsp/Makefile b/workspace/projects/demo/user/bsp/Makefile index dbb302ab..428c3e6b 100644 --- a/workspace/projects/demo/user/bsp/Makefile +++ b/workspace/projects/demo/user/bsp/Makefile @@ -1,8 +1,4 @@ -CINCLUDE_FILE += catOS/bsp/Libraries/CMSIS/Include -CINCLUDE_FILE += catOS/bsp/Libraries/CMSIS/Device/ST/STM32F1xx/Include -CINCLUDE_FILE += catOS/bsp/Libraries/STM32F1xx_HAL_Driver/Inc -CINCLUDE_FILE += catOS/bsp/Libraries/STM32F1xx_HAL_Driver subdir-y += board_led # subdir-y += iic diff --git a/workspace/projects/demo/user/bsp/board_led/Makefile b/workspace/projects/demo/user/bsp/board_led/Makefile index dfc4d3e7..25afa879 100644 --- a/workspace/projects/demo/user/bsp/board_led/Makefile +++ b/workspace/projects/demo/user/bsp/board_led/Makefile @@ -1,5 +1,5 @@ -CINCLUDE_FILE += catOS/bsp/$(CATOS_BOARD_BSP)/Libraries/STM32F1xx_HAL_Driver + obj-y += bsp_board_led.o diff --git a/workspace/projects/demo/user/bsp/lcd/Makefile b/workspace/projects/demo/user/bsp/lcd/Makefile index 045bb22c..cd9d79fd 100644 --- a/workspace/projects/demo/user/bsp/lcd/Makefile +++ b/workspace/projects/demo/user/bsp/lcd/Makefile @@ -1,5 +1,4 @@ -CINCLUDE_FILE += user/bsp/iic obj-y += bsp_lcd.o obj-y += oled.o diff --git a/workspace/projects/demo/user/catos_config.h b/workspace/projects/demo/user/catos_config.h new file mode 100644 index 00000000..01626da1 --- /dev/null +++ b/workspace/projects/demo/user/catos_config.h @@ -0,0 +1,61 @@ +/** + * @file cat_config.h + * @brief the config MACROs + * @author amoigus (648137125@qq.com) + * @version 0.1 + * @date 2021-03-19 + * + * @copyright Copyright (c) 2021 + * + * @par 修改日志: + * Date Version Author Description + * 2021-03-19 1.0 amoigus 内容 + */ + +#ifndef CATOS_CONFIG_H +#define CATOS_CONFIG_H + +/** 版本和构建信息 **/ +/* catos版本 */ +#define CATOS_VERSION "v1.0.2" +/* 构建工具信息 */ +#if defined(__CC_ARM) + #define CATOS_BUILD_COMPILER "armcc under 6" +#elif (defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )) + #define CATOS_BUILD_COMPILER "armcc6(AC6)" +#elif defined(__GNUC__) + #define CATOS_BUILD_COMPILER "gcc(GNU)" +#endif + +/** 系统相关 **/ +#define CATOS_SYSTICK_FRQ (100) /**< 系统时钟频率,每秒的tick数(周期的倒数)*/ +#define CATOS_SYSTICK_MS ((1000 * 1) / CATOS_SYSTICK_FRQ) /**< 每个tick经过的毫秒数*/ + +/** 任务相关 **/ +#define CATOS_MAX_TASK_PRIO (32) /**< 任务最大优先级 */ +#define CATOS_MAX_SLICE (10) /**< 最大时间片 */ + +#define CATOS_IDLE_STACK_SIZE (1024) /**< 空闲任务栈大小*/ + +/** component **/ +/* cat_device */ +#define CATOS_ENABLE_DEVICE_MODEL 1 /**< 使用设备驱动框架 */ + +/* cat_shell */ +#define CATOS_ENABLE_CAT_SHELL 1 /**< 使用shell */ +#if (CATOS_ENABLE_CAT_SHELL == 1) + #define CATOS_SHELL_TASK_PRIO (CATOS_MAX_TASK_PRIO - 2) /**< 任务优先级*/ + #define CATOS_SHELL_STACK_SIZE (4096) /**< 任务栈空间大小*/ +#endif + +/* cat_stdio */ +#define CATOS_ENABLE_SYS_PRINTF 1 /**< 系统输出 */ +#if (CATOS_ENABLE_SYS_PRINTF == 1) + #define CATOS_ENABLE_DEBUG_PRINTF 1 /**< 调试打印功能 */ + #define CATOS_STDIO_DEVICE_NAME "debug_uart" /**< 标准输入输出使用设备 */ +#endif /* #if (CATOS_ENABLE_SYS_PRINTF == 1) */ + +/* third_party 三方代码 */ +#define CATOS_ENABLE_CMBACKTRACE 0 /**< 使用cm_backtrace追踪 */ + +#endif/* #ifndef CATOS_CONFIG_H */ diff --git a/workspace/projects/demo/user/main.c b/workspace/projects/demo/user/main.c index 8741acc7..4293be5c 100644 --- a/workspace/projects/demo/user/main.c +++ b/workspace/projects/demo/user/main.c @@ -37,9 +37,9 @@ void task1_entry(void *arg) for(;;) { sched_task1_times++; - // board_led_on(); + board_led_on(); cat_sp_task_delay(100); - // board_led_off(); + board_led_off(); cat_sp_task_delay(100); } } @@ -56,6 +56,9 @@ void task2_entry(void *arg) int main(void) { + /* 初始化操作系统 */ + catos_init(); + board_led_init(); // EXTI_Key_Config(); diff --git a/workspace/projects/demo_vet6_keil/user/Makefile b/workspace/projects/demo_vet6_keil/user/Makefile index 97713155..8f7e04f6 100644 --- a/workspace/projects/demo_vet6_keil/user/Makefile +++ b/workspace/projects/demo_vet6_keil/user/Makefile @@ -1,16 +1,4 @@ -CINCLUDE_FILE += catOS/bsp/$(CATOS_BOARD_BSP)/Libraries/CMSIS/Include -CINCLUDE_FILE += catOS/bsp/$(CATOS_BOARD_BSP)/Libraries/CMSIS/Device/ST/STM32F1xx/Include -CINCLUDE_FILE += catOS/bsp/$(CATOS_BOARD_BSP)/Libraries/STM32F1xx_HAL_Driver/Inc -CINCLUDE_FILE += catOS/bsp/$(CATOS_BOARD_BSP)/Libraries/STM32F1xx_HAL_Driver - -CINCLUDE_FILE += catOS/bsp/$(CATOS_BOARD_BSP)/drivers/uart -CINCLUDE_FILE += catOS/include - -CINCLUDE_FILE += user -CINCLUDE_FILE += user/bsp/board_led -CINCLUDE_FILE += user/bsp/key - subdir-y += bsp diff --git a/workspace/projects/demo_vet6_keil_gnu/user/Makefile b/workspace/projects/demo_vet6_keil_gnu/user/Makefile index 97713155..8f7e04f6 100644 --- a/workspace/projects/demo_vet6_keil_gnu/user/Makefile +++ b/workspace/projects/demo_vet6_keil_gnu/user/Makefile @@ -1,16 +1,4 @@ -CINCLUDE_FILE += catOS/bsp/$(CATOS_BOARD_BSP)/Libraries/CMSIS/Include -CINCLUDE_FILE += catOS/bsp/$(CATOS_BOARD_BSP)/Libraries/CMSIS/Device/ST/STM32F1xx/Include -CINCLUDE_FILE += catOS/bsp/$(CATOS_BOARD_BSP)/Libraries/STM32F1xx_HAL_Driver/Inc -CINCLUDE_FILE += catOS/bsp/$(CATOS_BOARD_BSP)/Libraries/STM32F1xx_HAL_Driver - -CINCLUDE_FILE += catOS/bsp/$(CATOS_BOARD_BSP)/drivers/uart -CINCLUDE_FILE += catOS/include - -CINCLUDE_FILE += user -CINCLUDE_FILE += user/bsp/board_led -CINCLUDE_FILE += user/bsp/key - subdir-y += bsp