├── README.md ├── app ├── app_ccu │ ├── alarmTask │ │ ├── alarm_task.c │ │ └── alarm_task.h │ ├── bmsTask │ │ ├── bms_canhandle.c │ │ ├── bms_canhandle.h │ │ ├── bms_com.c │ │ ├── bms_com.h │ │ ├── bms_device.c │ │ ├── bms_device.h │ │ ├── bms_internal_handle.c │ │ ├── bms_internal_handle.h │ │ ├── bms_task.c │ │ └── bms_task.h │ ├── chargeTask │ │ ├── charge_task.c │ │ └── charge_task.h │ ├── modTask │ │ ├── modINFY │ │ │ ├── modyfy.c │ │ │ └── modyfy.h │ │ └── modSys │ │ │ ├── modSysManage.c │ │ │ └── modSysManage.h │ ├── sys │ │ ├── IO_megg.c │ │ ├── IO_megg.h │ │ ├── base_type.h │ │ ├── can_tx_rx_list.h │ │ ├── dcharger_version.h │ │ ├── fun.c │ │ ├── fun.h │ │ ├── log.c │ │ ├── log.h │ │ ├── os_thread.c │ │ ├── os_thread.h │ │ ├── sys_config.c │ │ ├── sys_config.h │ │ ├── tick_handle.c │ │ ├── tick_handle.h │ │ ├── time_cur.c │ │ └── time_cur.h │ ├── systype │ │ ├── sys_type.c │ │ ├── sys_type.h │ │ └── sys_type_contactor_group.h │ └── tcuCanTask │ │ ├── can.h │ │ ├── cantcu.c │ │ ├── cantcu.h │ │ ├── mid_delay.c │ │ ├── mid_delay.h │ │ ├── mutual_data.c │ │ ├── mutual_data.h │ │ ├── sgcan.c │ │ └── sgcan.h ├── app_hmi │ ├── inc │ │ ├── cmd_ctrl.h │ │ ├── cmd_param_req.h │ │ ├── cmd_param_set.h │ │ ├── hmi_param_tab0.h │ │ ├── hmi_param_tab_type.h │ │ ├── hmi_protocol.h │ │ └── hmi_task.h │ └── src │ │ ├── cmd_ctrl.c │ │ ├── cmd_param_req.c │ │ ├── cmd_param_set.c │ │ ├── hmi_param_tab0.c │ │ ├── hmi_protocol.c │ │ └── hmi_task.c ├── app_test │ ├── inc │ │ ├── com_protocol.h │ │ ├── test_protocol.h │ │ └── test_task.h │ └── src │ │ ├── com_protocol.c │ │ ├── test_protocol.c │ │ └── test_task.c └── readme.txt ├── arch ├── inc │ └── stm32f4xx │ │ ├── drv │ │ ├── drv_adc_cfg.h │ │ ├── drv_can_cfg.h │ │ ├── drv_dma_cfg.h │ │ ├── drv_irq_cfg.h │ │ ├── drv_pwm_cfg.h │ │ ├── drv_spi_cfg.h │ │ ├── drv_timer_cfg.h │ │ └── drv_uart_cfg.h │ │ ├── hal │ │ ├── misc.h │ │ ├── stm32f4xx_adc.h │ │ ├── stm32f4xx_can.h │ │ ├── stm32f4xx_cec.h │ │ ├── stm32f4xx_crc.h │ │ ├── stm32f4xx_cryp.h │ │ ├── stm32f4xx_dac.h │ │ ├── stm32f4xx_dbgmcu.h │ │ ├── stm32f4xx_dcmi.h │ │ ├── stm32f4xx_dma.h │ │ ├── stm32f4xx_dma2d.h │ │ ├── stm32f4xx_exti.h │ │ ├── stm32f4xx_flash.h │ │ ├── stm32f4xx_flash_ramfunc.h │ │ ├── stm32f4xx_fmc.h │ │ ├── stm32f4xx_fmpi2c.h │ │ ├── stm32f4xx_fsmc.h │ │ ├── stm32f4xx_gpio.h │ │ ├── stm32f4xx_hash.h │ │ ├── stm32f4xx_i2c.h │ │ ├── stm32f4xx_iwdg.h │ │ ├── stm32f4xx_ltdc.h │ │ ├── stm32f4xx_pwr.h │ │ ├── stm32f4xx_qspi.h │ │ ├── stm32f4xx_rcc.h │ │ ├── stm32f4xx_rng.h │ │ ├── stm32f4xx_rtc.h │ │ ├── stm32f4xx_sai.h │ │ ├── stm32f4xx_sdio.h │ │ ├── stm32f4xx_spdifrx.h │ │ ├── stm32f4xx_spi.h │ │ ├── stm32f4xx_syscfg.h │ │ ├── stm32f4xx_tim.h │ │ ├── stm32f4xx_usart.h │ │ ├── stm32f4xx_wwdg.h │ │ └── usb │ │ │ ├── core │ │ │ ├── usb_bsp.h │ │ │ ├── usb_conf.h │ │ │ ├── usb_core.h │ │ │ ├── usb_defines.h │ │ │ └── usb_regs.h │ │ │ ├── usb_device │ │ │ ├── config │ │ │ │ ├── usbd_conf.h │ │ │ │ └── usbd_desc.h │ │ │ ├── core │ │ │ │ ├── usbd_conf_template.h │ │ │ │ ├── usbd_core.h │ │ │ │ ├── usbd_def.h │ │ │ │ ├── usbd_ioreq.h │ │ │ │ ├── usbd_req.h │ │ │ │ └── usbd_usr.h │ │ │ ├── device │ │ │ │ ├── usb_dcd.h │ │ │ │ └── usb_dcd_int.h │ │ │ └── msc │ │ │ │ ├── usbd_msc_bot.h │ │ │ │ ├── usbd_msc_core.h │ │ │ │ ├── usbd_msc_data.h │ │ │ │ ├── usbd_msc_mem.h │ │ │ │ └── usbd_msc_scsi.h │ │ │ └── usb_host │ │ │ ├── config │ │ │ ├── usbh_conf.h │ │ │ └── usbh_usr.h │ │ │ ├── core │ │ │ ├── usb_hcd.h │ │ │ └── usb_hcd_int.h │ │ │ ├── host │ │ │ ├── usbh_conf_template.h │ │ │ ├── usbh_core.h │ │ │ ├── usbh_def.h │ │ │ ├── usbh_hcs.h │ │ │ ├── usbh_ioreq.h │ │ │ └── usbh_stdreq.h │ │ │ └── msc │ │ │ ├── usbh_msc_bot.h │ │ │ ├── usbh_msc_core.h │ │ │ └── usbh_msc_scsi.h │ │ └── platform │ │ ├── stm32f4xx.h │ │ ├── stm32f4xx_conf.h │ │ └── stm32f4xx_usb_regs.h └── src │ └── stm32f4xx │ ├── cfg │ ├── drv_adc_cfg.c │ ├── drv_can_cfg.c │ ├── drv_dma_cfg.c │ ├── drv_pwm_cfg.c │ ├── drv_spi_cfg.c │ ├── drv_timer_cfg.c │ └── drv_uart_cfg.c │ ├── drv │ ├── drv_adc.c │ ├── drv_can.c │ ├── drv_clock.c │ ├── drv_dma.c │ ├── drv_ext_int.c │ ├── drv_flash.c │ ├── drv_int.c │ ├── drv_pmu.c │ ├── drv_port.c │ ├── drv_pwm.c │ ├── drv_spi.c │ ├── drv_timer.c │ ├── drv_uart.c │ ├── drv_usb.c │ ├── drv_usb_master.c │ ├── drv_usb_slave.c │ └── drv_wdog.c │ └── hal │ ├── misc.c │ ├── stm32f4xx_adc.c │ ├── stm32f4xx_can.c │ ├── stm32f4xx_cec.c │ ├── stm32f4xx_crc.c │ ├── stm32f4xx_cryp.c │ ├── stm32f4xx_cryp_aes.c │ ├── stm32f4xx_cryp_des.c │ ├── stm32f4xx_cryp_tdes.c │ ├── stm32f4xx_dac.c │ ├── stm32f4xx_dbgmcu.c │ ├── stm32f4xx_dcmi.c │ ├── stm32f4xx_dma.c │ ├── stm32f4xx_dma2d.c │ ├── stm32f4xx_exti.c │ ├── stm32f4xx_flash.c │ ├── stm32f4xx_flash_ramfunc.c │ ├── stm32f4xx_fmc.c │ ├── stm32f4xx_fmpi2c.c │ ├── stm32f4xx_fsmc.c │ ├── stm32f4xx_gpio.c │ ├── stm32f4xx_hash.c │ ├── stm32f4xx_hash_md5.c │ ├── stm32f4xx_hash_sha1.c │ ├── stm32f4xx_i2c.c │ ├── stm32f4xx_iwdg.c │ ├── stm32f4xx_ltdc.c │ ├── stm32f4xx_pwr.c │ ├── stm32f4xx_qspi.c │ ├── stm32f4xx_rcc.c │ ├── stm32f4xx_rng.c │ ├── stm32f4xx_rtc.c │ ├── stm32f4xx_sai.c │ ├── stm32f4xx_sdio.c │ ├── stm32f4xx_spdifrx.c │ ├── stm32f4xx_spi.c │ ├── stm32f4xx_syscfg.c │ ├── stm32f4xx_tim.c │ ├── stm32f4xx_usart.c │ ├── stm32f4xx_wwdg.c │ └── usb │ ├── core │ └── usb_core.c │ ├── usb_device │ ├── config │ │ └── usbd_desc.c │ ├── core │ │ ├── usbd_core.c │ │ ├── usbd_ioreq.c │ │ └── usbd_req.c │ ├── device │ │ ├── usb_dcd.c │ │ └── usb_dcd_int.c │ └── msc │ │ ├── usbd_msc_bot.c │ │ ├── usbd_msc_core.c │ │ ├── usbd_msc_data.c │ │ └── usbd_msc_scsi.c │ └── usb_host │ ├── core │ ├── usb_hcd.c │ └── usb_hcd_int.c │ ├── host │ ├── usbh_core.c │ ├── usbh_hcs.c │ ├── usbh_ioreq.c │ └── usbh_stdreq.c │ └── msc │ ├── usbh_msc_bot.c │ ├── usbh_msc_core.c │ └── usbh_msc_scsi.c ├── bootldr ├── inc │ └── upgrade │ │ └── upgrade.h └── src │ ├── link │ └── ld │ │ ├── STM32F407IGTx_FLASH.ld │ │ ├── STM32F413ZGTx_FLASH.ld │ │ └── stm32_flash.ld │ ├── main.c │ ├── startup │ ├── armcc │ │ ├── startup_stm32f10x_hd.s │ │ ├── startup_stm32f407xx.s │ │ └── startup_stm32f413xx.s │ └── gcc │ │ ├── startup_stm32f10x_hd.s │ │ ├── startup_stm32f407xx.S │ │ ├── startup_stm32f407xx.o │ │ └── startup_stm32f413xx.S │ ├── upgrade │ └── upgrade.c │ └── version │ └── version.c ├── doc ├── usal_mcu说明文档.chm └── 整体框图.pdf ├── kernel ├── inc │ ├── dev │ │ ├── dev_adc.h │ │ ├── dev_can.h │ │ ├── dev_flash.h │ │ ├── dev_log.h │ │ ├── dev_pmu.h │ │ ├── dev_power.h │ │ ├── dev_pwm.h │ │ ├── dev_rs485.h │ │ ├── dev_switch.h │ │ └── dev_wdog.h │ ├── fatfs │ │ ├── diskio.h │ │ ├── ff.h │ │ └── ffconf.h │ ├── mem │ │ └── memory.h │ ├── per_can_mcp2515 │ │ └── per_can_mcp2515.h │ ├── per_ext_flash │ │ └── per_ext_flash.h │ ├── rtos │ │ ├── rtos_api.h │ │ └── rtx │ │ │ ├── rtx_compiler │ │ │ └── EventRecorder.h │ │ │ ├── rtx_config │ │ │ └── RTX_Config.h │ │ │ ├── rtx_inc │ │ │ ├── rtx_core_c.h │ │ │ ├── rtx_core_ca.h │ │ │ ├── rtx_core_cm.h │ │ │ ├── rtx_evr.h │ │ │ ├── rtx_lib.h │ │ │ └── rtx_os.h │ │ │ ├── rtx_include │ │ │ ├── cmsis_os2.h │ │ │ └── os_tick.h │ │ │ └── rtx_rte │ │ │ ├── arm_cm3 │ │ │ ├── ARMCM3.h │ │ │ ├── RTE_Components.h │ │ │ └── system_ARMCM3.h │ │ │ └── arm_cm4 │ │ │ ├── ARMCM4.h │ │ │ ├── ARMCM4_FP.h │ │ │ ├── RTE_Components.h │ │ │ └── system_ARMCM4.h │ ├── srt │ │ └── srt.h │ ├── thread │ │ ├── thread.h │ │ └── thread_event.h │ └── vfs │ │ └── vfs.h └── src │ ├── cfg │ ├── dev_adc_cfg.c │ ├── dev_can_cfg.c │ ├── dev_ext_flash_cfg.c │ ├── dev_flash_cfg.c │ ├── dev_init_cfg.c │ ├── dev_power_cfg.c │ ├── dev_pwm_cfg.c │ ├── dev_rs485_cfg.c │ ├── dev_switch_cfg.c │ └── per_ext_flash_cfg.c │ ├── dev │ ├── dev_adc.c │ ├── dev_can.c │ ├── dev_flash.c │ ├── dev_log.c │ ├── dev_pmu.c │ ├── dev_power.c │ ├── dev_pwm.c │ ├── dev_rs485.c │ ├── dev_switch.c │ └── dev_wdog.c │ ├── fatfs │ ├── diskio.c │ ├── ff.c │ ├── ffsystem.c │ └── ffunicode.c │ ├── kernel_init.c │ ├── kfc │ ├── kfc_dev.c │ ├── kfc_event.c │ ├── kfc_file.c │ ├── kfc_memory.c │ ├── kfc_mutex.c │ ├── kfc_srt.c │ ├── kfc_system.c │ ├── kfc_task.c │ └── kfc_timer.c │ ├── mem │ ├── memory.c │ └── memory.o │ ├── per_can_mcp2515 │ └── per_can_mcp2515.c │ ├── per_ext_flash │ └── per_ext_flash.c │ ├── rtos │ └── rtx │ │ ├── cmsis_version5.3.0.txt │ │ ├── rtos_api.c │ │ ├── rtx_config │ │ ├── RTX_Config.c │ │ └── RTX_Config.o │ │ ├── rtx_core │ │ ├── ARM │ │ │ ├── irq_armv8mbl.s │ │ │ ├── irq_armv8mbl_ns.s │ │ │ ├── irq_armv8mml.s │ │ │ ├── irq_armv8mml_ns.s │ │ │ ├── irq_ca.s │ │ │ ├── irq_cm0.s │ │ │ ├── irq_cm3.s │ │ │ └── irq_cm4f.s │ │ ├── GCC │ │ │ ├── irq_armv8mbl.S │ │ │ ├── irq_armv8mbl_ns.S │ │ │ ├── irq_armv8mml.S │ │ │ ├── irq_armv8mml_fp.S │ │ │ ├── irq_armv8mml_fp_ns.S │ │ │ ├── irq_armv8mml_ns.S │ │ │ ├── irq_ca.S │ │ │ ├── irq_cm0.S │ │ │ ├── irq_cm3.S │ │ │ ├── irq_cm4f.S │ │ │ ├── irq_cm4f.o │ │ │ └── irq_cm4f_keil.S │ │ └── IAR │ │ │ ├── irq_armv8mbl.s │ │ │ ├── irq_armv8mbl_common.s │ │ │ ├── irq_armv8mbl_ns.s │ │ │ ├── irq_armv8mml.s │ │ │ ├── irq_armv8mml_common.s │ │ │ ├── irq_armv8mml_ns.s │ │ │ ├── irq_ca.s │ │ │ ├── irq_cm0.s │ │ │ ├── irq_cm3.s │ │ │ └── irq_cm4f.s │ │ └── rtx_source │ │ ├── os_systick.c │ │ ├── os_systick.o │ │ ├── rtx_delay.c │ │ ├── rtx_delay.o │ │ ├── rtx_evflags.c │ │ ├── rtx_evflags.o │ │ ├── rtx_evr.c │ │ ├── rtx_evr.o │ │ ├── rtx_kernel.c │ │ ├── rtx_kernel.o │ │ ├── rtx_lib.c │ │ ├── rtx_lib.o │ │ ├── rtx_memory.c │ │ ├── rtx_memory.o │ │ ├── rtx_mempool.c │ │ ├── rtx_mempool.o │ │ ├── rtx_msgqueue.c │ │ ├── rtx_msgqueue.o │ │ ├── rtx_mutex.c │ │ ├── rtx_mutex.o │ │ ├── rtx_semaphore.c │ │ ├── rtx_semaphore.o │ │ ├── rtx_system.c │ │ ├── rtx_system.o │ │ ├── rtx_thread.c │ │ ├── rtx_thread.o │ │ ├── rtx_timer.c │ │ └── rtx_timer.o │ ├── srt │ ├── srt.c │ └── srt.o │ ├── thread │ ├── thread.c │ └── thread_event.c │ └── vfs │ ├── vfs.c │ └── vfs.o ├── lib └── src │ ├── mfc │ └── mfc_memory.c │ ├── ofc │ ├── ofc_chain.c │ ├── ofc_crc16.c │ ├── ofc_crc32.c │ ├── ofc_list.c │ ├── ofc_object.c │ └── ofc_ring_buf.c │ └── pfc │ ├── pfc_irq_buf.c │ └── pfc_sync_objs.c ├── public └── inc │ ├── app │ └── cfg │ │ └── ccu │ │ └── srt_table.h │ ├── arch │ ├── CMSIS │ │ └── Include │ │ │ ├── arm_common_tables.h │ │ │ ├── arm_const_structs.h │ │ │ ├── arm_math.h │ │ │ ├── cmsis_armcc.h │ │ │ ├── cmsis_armclang.h │ │ │ ├── cmsis_compiler.h │ │ │ ├── cmsis_gcc.h │ │ │ ├── cmsis_version.h │ │ │ ├── core_armv8mbl.h │ │ │ ├── core_armv8mml.h │ │ │ ├── core_cm0.h │ │ │ ├── core_cm0plus.h │ │ │ ├── core_cm23.h │ │ │ ├── core_cm3.h │ │ │ ├── core_cm33.h │ │ │ ├── core_cm4.h │ │ │ ├── core_cm7.h │ │ │ ├── core_sc000.h │ │ │ ├── core_sc300.h │ │ │ ├── mpu_armv7.h │ │ │ └── tz_context.h │ └── drv │ │ ├── drv_adc.h │ │ ├── drv_can.h │ │ ├── drv_clock.h │ │ ├── drv_dma.h │ │ ├── drv_ext_int.h │ │ ├── drv_flash.h │ │ ├── drv_int.h │ │ ├── drv_pmu.h │ │ ├── drv_port.h │ │ ├── drv_pwm.h │ │ ├── drv_spi.h │ │ ├── drv_timer.h │ │ ├── drv_uart.h │ │ ├── drv_usb.h │ │ ├── drv_usb_master.h │ │ ├── drv_usb_slave.h │ │ └── drv_wdog.h │ ├── def │ └── can_def.h │ ├── kernel │ ├── config │ │ ├── dev_config.h │ │ ├── mem_config.h │ │ └── srt_config.h │ ├── kernel_init.h │ └── kfc │ │ ├── kfc_dev.h │ │ ├── kfc_event.h │ │ ├── kfc_file.h │ │ ├── kfc_memory.h │ │ ├── kfc_mutex.h │ │ ├── kfc_srt.h │ │ ├── kfc_system.h │ │ ├── kfc_task.h │ │ └── kfc_timer.h │ └── lib │ ├── mfc │ └── mfc_memory.h │ ├── ofc │ ├── ofc_chain.h │ ├── ofc_crc16.h │ ├── ofc_crc32.h │ ├── ofc_list.h │ ├── ofc_object.h │ ├── ofc_ring_buf.h │ ├── ofc_string.h │ └── ofc_types.h │ └── pfc │ ├── pfc_irq_buf.h │ └── pfc_sync_objs.h ├── sln └── sln_test │ ├── app_test │ └── app_test.uvprojx │ ├── arch │ └── arch.uvprojx │ ├── bootldr │ └── bootldr.uvprojx │ ├── kernel │ └── kernel.uvprojx │ ├── lib │ └── lib.uvprojx │ ├── out │ ├── README.txt │ ├── USAL_APP.bin │ ├── USAL_BOOT.bin │ ├── app_hmi.lib │ ├── app_test.lib │ ├── arch.lib │ ├── kernel.lib │ └── lib.lib │ ├── sln.uvmpw │ └── usr │ └── usr.uvprojx └── usr ├── src ├── link │ └── ld │ │ ├── STM32F407IGTx_FLASH.ld │ │ ├── STM32F413ZGTx_FLASH.ld │ │ └── stm32_flash.ld └── startup │ ├── armcc │ ├── startup_stm32f10x_hd.s │ ├── startup_stm32f407xx.s │ └── startup_stm32f413xx.s │ └── gcc │ ├── startup_stm32f10x_hd.s │ ├── startup_stm32f407xx.S │ └── startup_stm32f413xx.S └── usr_test ├── main.c └── version └── version.c /README.md: -------------------------------------------------------------------------------- 1 | # usal_mcu 2 | =========================== 3 | usal_mcu 4 | ###########简单说明 5 | 6 | 实现仿linux分层架构实现mcu通用系统,方便芯片级切换以及多产品线开发 7 | 8 | 主要特点: 9 | 1.代码风格采用c语言的面向对象写法,支持跨平台 10 | 2.分层架构,驱动层,系统层,应用层,三者清晰独立,且均采用库模块形式支持加载剪裁 11 | 3.驱动和内核独立出简单配置文件,切换外设只需要修改对应配置文件即可 12 | 4.所有设备均为注册挂载式,方便剪裁,并且模仿linux vfs接口统一为open,close,write,read等接口 13 | 5.接口统一,应用使用接口为kfc头文件,简单清晰 14 | 6.整体结构清晰,预留多产品线应用支持 15 | 16 | 注:整体代码风格采用c语言面向对象写法参照鸿泉沈工和陆工并引用其个别文件,内存分配引用鸿泉叶工,其他整体架构和代码为个人完成 17 | 18 | ###########部署步骤 19 | keil 20 | mcu:stm32f4 21 | ###########目录结构描述 22 | ├── doc ///< 说明文档 23 | ├── public ///< 公共头文件 24 | ├── lib ///< 通用库 25 | ├── arch ///< 芯片层接口 26 | │ └── stm32f4 ///< stm32f4芯片支持 27 | │ - - - ├── cfg ///< 驱动配置文件 28 | │ - - - ├── drv ///< drv驱动程序 29 | │ - - - └── hal ///< 芯片厂家程序 30 | ├── bootldr ///< bootldr引导启动文件 31 | ├── kernel ///< 内核层 32 | │ ├── kfc ///< 应用使用所有内核接口 33 | │ ├── cfg ///< 内核配置 34 | │ ├── dev ///< 内核设备注册 35 | │ ├── mem ///< 内核内存管理 36 | │ ├── rtos ///< 内核操作系统(cmsis-rtx) 37 | │ ├── vfs ///< 内核虚拟文件系统 38 | │ ├── srt ///< 内核共享内存 39 | │ ├── fatfs ///< 内核文件系统 40 | │ ├── thread ///< 内核线程实现 41 | │ ├── per_can_mcp2515 ///< 内核外设spican 42 | │ └── per_ext_flash ///< 内核外设外部flash存储 43 | ├── app ///< 应用目录 44 | │ └── app_test ///< 接口使用测试程序 45 | └── usr ///< app启动文件 46 | └── sln ///< 工程文件 47 | 48 | 49 | ###########V1.0.0 版本内容更新 50 | 1. 新功能 基本内核功能 51 | 52 | -------------------------------------------------------------------------------- /app/app_ccu/alarmTask/alarm_task.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/alarmTask/alarm_task.c -------------------------------------------------------------------------------- /app/app_ccu/alarmTask/alarm_task.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/alarmTask/alarm_task.h -------------------------------------------------------------------------------- /app/app_ccu/bmsTask/bms_canhandle.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/bmsTask/bms_canhandle.c -------------------------------------------------------------------------------- /app/app_ccu/bmsTask/bms_canhandle.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/bmsTask/bms_canhandle.h -------------------------------------------------------------------------------- /app/app_ccu/bmsTask/bms_com.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/bmsTask/bms_com.c -------------------------------------------------------------------------------- /app/app_ccu/bmsTask/bms_com.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/bmsTask/bms_com.h -------------------------------------------------------------------------------- /app/app_ccu/bmsTask/bms_device.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/bmsTask/bms_device.c -------------------------------------------------------------------------------- /app/app_ccu/bmsTask/bms_device.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/bmsTask/bms_device.h -------------------------------------------------------------------------------- /app/app_ccu/bmsTask/bms_internal_handle.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/bmsTask/bms_internal_handle.c -------------------------------------------------------------------------------- /app/app_ccu/bmsTask/bms_internal_handle.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/bmsTask/bms_internal_handle.h -------------------------------------------------------------------------------- /app/app_ccu/bmsTask/bms_task.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/bmsTask/bms_task.c -------------------------------------------------------------------------------- /app/app_ccu/bmsTask/bms_task.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/bmsTask/bms_task.h -------------------------------------------------------------------------------- /app/app_ccu/chargeTask/charge_task.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/chargeTask/charge_task.c -------------------------------------------------------------------------------- /app/app_ccu/chargeTask/charge_task.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/chargeTask/charge_task.h -------------------------------------------------------------------------------- /app/app_ccu/modTask/modSys/modSysManage.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/modTask/modSys/modSysManage.c -------------------------------------------------------------------------------- /app/app_ccu/modTask/modSys/modSysManage.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/modTask/modSys/modSysManage.h -------------------------------------------------------------------------------- /app/app_ccu/sys/IO_megg.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/IO_megg.c -------------------------------------------------------------------------------- /app/app_ccu/sys/IO_megg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/IO_megg.h -------------------------------------------------------------------------------- /app/app_ccu/sys/base_type.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/base_type.h -------------------------------------------------------------------------------- /app/app_ccu/sys/can_tx_rx_list.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/can_tx_rx_list.h -------------------------------------------------------------------------------- /app/app_ccu/sys/dcharger_version.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/dcharger_version.h -------------------------------------------------------------------------------- /app/app_ccu/sys/fun.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/fun.c -------------------------------------------------------------------------------- /app/app_ccu/sys/fun.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/fun.h -------------------------------------------------------------------------------- /app/app_ccu/sys/log.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/log.c -------------------------------------------------------------------------------- /app/app_ccu/sys/log.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/log.h -------------------------------------------------------------------------------- /app/app_ccu/sys/os_thread.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/os_thread.c -------------------------------------------------------------------------------- /app/app_ccu/sys/os_thread.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/os_thread.h -------------------------------------------------------------------------------- /app/app_ccu/sys/sys_config.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/sys_config.c -------------------------------------------------------------------------------- /app/app_ccu/sys/sys_config.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/sys_config.h -------------------------------------------------------------------------------- /app/app_ccu/sys/tick_handle.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/tick_handle.c -------------------------------------------------------------------------------- /app/app_ccu/sys/tick_handle.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/tick_handle.h -------------------------------------------------------------------------------- /app/app_ccu/sys/time_cur.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/time_cur.c -------------------------------------------------------------------------------- /app/app_ccu/sys/time_cur.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/sys/time_cur.h -------------------------------------------------------------------------------- /app/app_ccu/systype/sys_type.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/systype/sys_type.c -------------------------------------------------------------------------------- /app/app_ccu/systype/sys_type.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/systype/sys_type.h -------------------------------------------------------------------------------- /app/app_ccu/systype/sys_type_contactor_group.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/systype/sys_type_contactor_group.h -------------------------------------------------------------------------------- /app/app_ccu/tcuCanTask/can.h: -------------------------------------------------------------------------------- 1 | /* 2 | * can.h 3 | * 4 | * Created on: Oct 10, 2021 5 | * Author: player 6 | */ 7 | 8 | #ifndef CAN_H_ 9 | #define CAN_H_ 10 | 11 | #include "fun.h" 12 | 13 | #define PF_CAN 29 14 | #define AF_CAN PF_CAN 15 | 16 | 17 | #define CAN_TX_MSG_LIST_MAX 64 18 | #define CAN_RX_MSG_LIST_MAX 128 19 | 20 | #define CAN_TX_INTERVAL 10 21 | 22 | 23 | typedef enum 24 | { 25 | CAN_BUAD_10K = 0, 26 | CAN_BUAD_20K, 27 | CAN_BUAD_50K, 28 | CAN_BUAD_100K, 29 | CAN_BUAD_125K, 30 | CAN_BUAD_250K, 31 | } CAN_BAUD_E; 32 | 33 | 34 | typedef struct 35 | { 36 | uint32_t id; 37 | uint8_t data[8]; 38 | uint8_t len; 39 | uint8_t ch; 40 | uint8_t format; 41 | uint8_t type; 42 | } CAN_MSG_T; 43 | 44 | int32_t s32_can_init(uint8_t can_index,uint32_t baud); 45 | 46 | #endif /* CAN_H_ */ 47 | -------------------------------------------------------------------------------- /app/app_ccu/tcuCanTask/mid_delay.c: -------------------------------------------------------------------------------- 1 | /****************************** 2 | > File Name: mid_delay.c 3 | > Author:Zhx 4 | > Mail: 862145496@qq.com 5 | > Created Time: Sat 18 Sep 2021 02:15:35 AM PDT 6 | *****************************/ 7 | 8 | #include "mid_delay.h" 9 | //#include "delay.h" 10 | #include 11 | 12 | 13 | uint32_t u32_time_get(void) 14 | { 15 | return 0; 16 | } 17 | 18 | //uint32_t uint32_time_get(void) 19 | //{ 20 | //// return u32_delay_get_time(); 21 | //} 22 | 23 | uint32_t u32_time_past(uint32_t u32_start) 24 | { 25 | // return u32_delay_past_time(u32_start); 26 | uint32_t ret=0; 27 | uint32_t tick=u32_time_get(); 28 | ret=0xFFFFFFFF- u32_start; 29 | ret+= 1 +tick; 30 | return (ret % 0xFFFFFFFF); 31 | } 32 | 33 | uint32_t u32_time_elapse(uint32_t u32_start,uint32_t u32_end) 34 | { 35 | // return u32_delay_elapse(u32_start,u32_end); 36 | return 0; 37 | } 38 | 39 | int32_t s32_time_mdelay(uint32_t u32_ms) 40 | { 41 | // return s32_delay_mdelay(u32_ms); 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /app/app_ccu/tcuCanTask/mid_delay.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | */ 4 | 5 | #ifndef MID_DELAY_H_ 6 | #define MID_DELAY_H_ 7 | 8 | #include "fun.h" 9 | 10 | #define TIME_1MS (1) 11 | #define TIME_50MS (50*TIME_1MS) 12 | #define TIME_100MS (100*TIME_1MS) 13 | #define TIME_250MS (250*TIME_1MS) 14 | #define TIME_500MS (500*TIME_1MS) 15 | #define TIME_1S (1000*TIME_1MS) 16 | 17 | 18 | 19 | uint32_t u32_time_get(void); 20 | uint32_t u32_time_past(uint32_t u32_start); 21 | uint32_t u32_time_elapse(uint32_t u32_start,uint32_t u32_end); 22 | int32_t s32_time_mdelay(uint32_t u32_ms); 23 | 24 | #endif /* MID_DELAY_H_ */ 25 | -------------------------------------------------------------------------------- /app/app_ccu/tcuCanTask/mutual_data.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/tcuCanTask/mutual_data.c -------------------------------------------------------------------------------- /app/app_ccu/tcuCanTask/mutual_data.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/app/app_ccu/tcuCanTask/mutual_data.h -------------------------------------------------------------------------------- /app/app_ccu/tcuCanTask/sgcan.h: -------------------------------------------------------------------------------- 1 | /****************************** 2 | > File Name: sgcan.h 3 | > Author:Zhx 4 | > Mail: 862145496@qq.com 5 | > Created Time: Sat 18 Sep 2021 02:15:35 AM PDT 6 | *****************************/ 7 | 8 | #ifndef SGCAN_H_ 9 | #define SGCAN_H_ 10 | 11 | #include "can.h" 12 | 13 | 14 | #define CAN_UP 0 15 | #define CAN_DOWN 1 16 | #define CAN_RECT 2 17 | 18 | 19 | 20 | #define SG_CAN_BUF_SIZE (1024+20) 21 | #define SG_CAN_MAX_PACK_NUM 64 22 | 23 | 24 | 25 | typedef struct 26 | { 27 | uint32_t id; 28 | uint16_t len; 29 | uint16_t first_len; 30 | uint16_t check_sum; 31 | uint8_t pack_num; 32 | uint8_t next_pack; 33 | uint8_t recv_complete; 34 | uint8_t crc_error; 35 | uint8_t restart; 36 | uint8_t data[SG_CAN_BUF_SIZE]; 37 | } T_CAN_SG_DATA; 38 | 39 | typedef struct 40 | { 41 | uint32_t pgn; 42 | uint32_t id; 43 | uint16_t len; 44 | uint8_t src_addr; 45 | uint8_t dest_addr; 46 | uint8_t pri; 47 | uint8_t data[8]; 48 | } T_CAN_SING_DATA; 49 | 50 | typedef struct{ 51 | T_CAN_SG_DATA t_tx_data; 52 | T_CAN_SG_DATA t_rx_data; 53 | T_CAN_SING_DATA t_sing_data; 54 | }T_SG_DATA; 55 | 56 | extern CAN_MSG_T tcu_can_data; 57 | 58 | uint32_t u32_sg_forward_tx(uint32_t port,uint8_t src_addr,uint8_t dst_addr,T_CAN_SG_DATA *pt_can_data); 59 | //int32_t s32_sgcan_set_driver(uint32_t port,S32_CAN_RXTX can_rx,S32_CAN_RXTX can_tx); 60 | uint32_t u32_simpcan_rx(uint32_t port,T_CAN_SG_DATA *can_multi, T_CAN_SING_DATA *single_can); 61 | uint32_t u32_sg_can_tx(uint32_t port,T_CAN_SG_DATA *pt_can_data); 62 | 63 | #endif /* SGCAN_H_ */ 64 | -------------------------------------------------------------------------------- /app/app_hmi/inc/cmd_ctrl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cmd_ctrl.h 3 | * @brief 命令-控制类 4 | * @note 5 | * @author 6 | * @date 2021-7-2 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-7-2 1.0 创建初始版本 13 | * @copyright 14 | */ 15 | #ifndef _CMD_CTRL_H_ 16 | #define _CMD_CTRL_H_ 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | 25 | /** 26 | * 消息发送函数 27 | * @param receiver: 接口所有者 28 | * @param host_source: 主机数据源 29 | * @param ser_num: 流水号 30 | * @param cmd: 收到的命令 31 | * @param data: 命令数据指针 32 | * @param data_len: 命令数据长度 33 | * @return True:成功 False:失败 34 | */ 35 | typedef Bool (*TCmdCtrlProcessSendMsg)(void *receiver, UInt8 host_source, UInt8 ser_num, UInt8 cmd, UInt8* data, UInt32 data_len); 36 | 37 | typedef struct TCmdCtrlProcessTag TCmdCtrlProcess; 38 | struct TCmdCtrlProcessTag 39 | { 40 | PROTECTED 41 | TOfObject parent_; ///< 继承的父类 42 | TOfVirtualMethod Destroy_; ///< 析构函数 43 | PUBLIC 44 | TCmdCtrlProcessSendMsg method_msg_send_; ///< 发送消息方法(调用者实现) 45 | void *receiver_; ///< 接收者 46 | PRIVATE 47 | 48 | }; 49 | 50 | /** 51 | * 对象创建 52 | * @param self: 对象实例指针 53 | * @return 如果创建成功返回True,否则返回False 54 | */ 55 | void TCmdCtrlProcessCreate(TCmdCtrlProcess *self); 56 | 57 | /** 58 | * 通知控制消息 59 | * @param self: 对象实例指针 60 | * @return 61 | */ 62 | Bool TCmdCtrlProcessNotifyMsg(TCmdCtrlProcess *self, UInt8 host_source, UInt8 ser_num, UInt8 cmd, UInt8* data, UInt32 data_len); 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #endif 68 | -------------------------------------------------------------------------------- /app/app_hmi/inc/cmd_param_req.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cmd_param_req.h 3 | * @brief 命令-参数查询 4 | * @note 5 | * @author 6 | * @date 2021-7-2 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-7-2 1.0 创建初始版本 13 | * @copyright 14 | */ 15 | #ifndef _CMD_PARAM_REQ_H_ 16 | #define _CMD_PARAM_REQ_H_ 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /** 25 | * 消息发送函数 26 | * @param receiver: 接口所有者 27 | * @param host_source: 主机数据源 28 | * @param ser_num: 流水号 29 | * @param cmd: 收到的命令 30 | * @param data: 命令数据指针 31 | * @param data_len: 命令数据长度 32 | * @return True:成功 False:失败 33 | */ 34 | typedef Bool (*TCmdParamReqProcessSendMsg)(void *receiver, UInt8 host_source, UInt8 ser_num, UInt8 cmd, UInt8* data, UInt32 data_len); 35 | 36 | typedef struct TCmdParamReqProcessTag TCmdParamReqProcess; 37 | struct TCmdParamReqProcessTag 38 | { 39 | PROTECTED 40 | TOfObject parent_; ///< 继承的父类 41 | TOfVirtualMethod Destroy_; ///< 析构函数 42 | PUBLIC 43 | TCmdParamReqProcessSendMsg method_msg_send_; ///< 发送消息方法(调用者实现) 44 | void *receiver_; ///< 接收者 45 | PRIVATE 46 | 47 | }; 48 | 49 | /** 50 | * 对象创建 51 | * @param self: 对象实例指针 52 | * @return 如果创建成功返回True,否则返回False 53 | */ 54 | void TCmdParamReqProcessCreate(TCmdParamReqProcess *self); 55 | 56 | /** 57 | * 通知参数查询消息 58 | * @param self: 对象实例指针 59 | * @return 如果成功返回True,否则返回False 60 | */ 61 | Bool TCmdParamReqProcessNotifyMsg(TCmdParamReqProcess *self, UInt8 host_source, UInt8 ser_num, UInt8 cmd, UInt8* data, UInt32 data_len); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | #endif 67 | -------------------------------------------------------------------------------- /app/app_hmi/inc/cmd_param_set.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cmd_param_set.h 3 | * @brief 命令-参数设置 4 | * @note 5 | * @author 6 | * @date 2021-7-2 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-7-2 1.0 创建初始版本 13 | * @copyright 14 | */ 15 | #ifndef _CMD_PARAM_SET_H_ 16 | #define _CMD_PARAM_SET_H_ 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /** 25 | * 消息发送函数 26 | * @param receiver: 接口所有者 27 | * @param host_source: 主机数据源 28 | * @param ser_num: 流水号 29 | * @param cmd: 收到的命令 30 | * @param data: 命令数据指针 31 | * @param data_len: 命令数据长度 32 | * @return True:成功 False:失败 33 | */ 34 | typedef Bool (*TCmdParamSetProcessSendMsg)(void *receiver, UInt8 host_source, UInt8 ser_num, UInt8 cmd, UInt8* data, UInt32 data_len); 35 | 36 | typedef struct TCmdParamSetProcessTag TCmdParamSetProcess; 37 | struct TCmdParamSetProcessTag 38 | { 39 | PROTECTED 40 | TOfObject parent_; ///< 继承的父类 41 | TOfVirtualMethod Destroy_; ///< 析构函数 42 | PUBLIC 43 | TCmdParamSetProcessSendMsg method_msg_send_; ///< 发送消息方法(调用者实现) 44 | void *receiver_; ///< 接收者 45 | PRIVATE 46 | 47 | }; 48 | 49 | /** 50 | * 对象创建 51 | * @param self: 对象实例指针 52 | * @return 如果创建成功返回True,否则返回False 53 | */ 54 | void TCmdParamSetProcessCreate(TCmdParamSetProcess *self); 55 | 56 | /** 57 | * 通知参数设置消息 58 | * @param self: 对象实例指针 59 | * @return 如果成功返回True,否则返回False 60 | */ 61 | Bool TCmdParamSetProcessNotifyMsg(TCmdParamSetProcess *self, UInt8 host_source, UInt8 ser_num, UInt8 cmd, UInt8* data, UInt32 data_len); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | #endif 67 | -------------------------------------------------------------------------------- /app/app_hmi/inc/hmi_param_tab0.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hmi_param_tab0.h 3 | * @brief 交互参数表0 4 | * @note 5 | * @author 6 | * @date 2021-7-2 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-7-2 1.0 创建初始版本 13 | * @copyright 14 | */ 15 | #ifndef _HMI_PARAM_TAB0_H_ 16 | #define _HMI_PARAM_TAB0_H_ 17 | 18 | #include 19 | #include "hmi_param_tab_type.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | /** 25 | * 参数表0 26 | */ 27 | extern TParamItem g_param_tab0[15]; 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | #endif 33 | -------------------------------------------------------------------------------- /app/app_hmi/inc/hmi_param_tab_type.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hmi_param_tab_type.h 3 | * @brief 交互参数表类型 4 | * @note 5 | * @author 6 | * @date 2021-7-2 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-7-2 1.0 创建初始版本 13 | * @copyright 14 | */ 15 | #ifndef _HMI_PARAM_TAB_TYPE_H_ 16 | #define _HMI_PARAM_TAB_TYPE_H_ 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | enum THmiParamCmdResultTag 25 | { 26 | kHmiParamCmdResultOk = 0, ///< 应答结果成功 27 | kHmiParamCmdResultIdErr, ///< 应答结果参数id错误 28 | kHmiParamCmdResultParamErr, ///< 应答结果内容错误 29 | kHmiParamCmdResultPermissionErr, ///< 应答结果权限错误 30 | kHmiParamCmdResultDoErr, ///< 应答结果执行失败 31 | }; 32 | typedef enum THmiParamCmdResultTag THmiParamCmdResult; 33 | 34 | /** 35 | * 定义参数项具体回调接口 36 | * @param is_set: False:读取 True:设置 37 | * @param data: 读取或者设置地址 38 | * @param len: 读取或者设置长度 39 | * @return THmiParamCmdResult结果 40 | */ 41 | typedef THmiParamCmdResult (*TCmdParamCallback)(Bool is_set, UInt8 *data, UInt32 len); 42 | typedef struct TParamItemTag TParamItem; 43 | struct TParamItemTag 44 | { 45 | UInt8 param_id; ///< 参数id 46 | UInt8 param_len; ///< 参数长度 47 | TCmdParamCallback call_back; ///< 参数回调 48 | }; 49 | 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | #endif 55 | -------------------------------------------------------------------------------- /app/app_hmi/inc/hmi_task.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hmi_task.h 3 | * @brief 交互主任务 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _APP_HMI_TASK_H_ 17 | #define _APP_HMI_TASK_H_ 18 | 19 | #include 20 | #include 21 | #include "hmi_protocol.h" 22 | #include "cmd_ctrl.h" 23 | #include "cmd_param_set.h" 24 | #include "cmd_param_req.h" 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /** 31 | * 主任务类 32 | * @par 示例 33 | * @code 34 | THmiTask test; 35 | 36 | THmiTaskCreate(&test); 37 | OfDestroyObject((TOfObject *)&test); 38 | * @endcode 39 | */ 40 | typedef struct THmiTaskTag THmiTask; 41 | struct THmiTaskTag 42 | { 43 | PROTECTED 44 | TKfcTask parent_; ///< 继承的父类 45 | TOfVirtualMethod Destroy_; ///< 析构函数 46 | 47 | PRIVATE 48 | 49 | THmiProtocol hmi_protocol_; ///< 协议处理 50 | UInt8 protocol_buffer_[512]; ///< 协议解析缓存buffer 51 | UInt8 protocol_send_buffer_[200]; ///< 协议发送缓存 52 | UInt8 com_read_buf_[512]; 53 | 54 | TCmdCtrlProcess cmd_ctrl_process_; 55 | TCmdParamSetProcess cmd_param_set_process_; 56 | TCmdParamReqProcess cmd_param_req_process_; 57 | }; 58 | /// 主任务对象 59 | extern THmiTask g_hmi_task; 60 | 61 | /** 62 | * 主任务创建 63 | * @param self: 对象实例指针 64 | * @return 65 | */ 66 | void THmiTaskCreate(THmiTask *self); 67 | 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif //_APP_UART_TASK_H_ 74 | -------------------------------------------------------------------------------- /app/app_hmi/src/cmd_ctrl.c: -------------------------------------------------------------------------------- 1 | #include "cmd_ctrl.h" 2 | #include "hmi_protocol.h" 3 | 4 | enum 5 | { 6 | kHmiProtocolCtrlCmdHmiCtl = 0, ///< hmi交互使能 7 | }; 8 | 9 | enum 10 | { 11 | kHmiProtocolCtrlCmdResultOk = 0, ///< 应答结果成功 12 | kHmiProtocolCtrlCmdResultIdErr, ///< 应答结果参数id错误 13 | kHmiProtocolCtrlCmdResultParamErr, ///< 应答结果内容错误 14 | }; 15 | 16 | #pragma pack(1) 17 | /// 主机控制命令消息体 18 | typedef struct THmiProtocolHostCtrlMsgTag THmiProtocolHostCtrlMsg; 19 | struct THmiProtocolHostCtrlMsgTag 20 | { 21 | UInt8 ctrl_cmd; ///< 控制命令 22 | UInt8 reserved[3]; ///< 保留3字节 23 | UInt16 param1; ///< 参数1 24 | UInt16 param2; ///< 参数2 25 | }; 26 | /// 从机控制应答消息体 27 | typedef struct THmiProtocolSlaveCtrlRespMsgTag THmiProtocolSlaveCtrlRespMsg; 28 | struct THmiProtocolSlaveCtrlRespMsgTag 29 | { 30 | UInt8 ctrl_cmd; ///< 控制命令 31 | UInt8 result; ///< 控制结果0:成功 1:命令不支持 2:参数错误 其他:失败 32 | UInt8 reserved[2]; ///< 保留2字节 33 | }; 34 | #pragma pack() 35 | 36 | /** 37 | * 控制命令-交互命令 38 | * @param self: 对象实例 39 | * @param param1: 参数1 40 | * @param param2: 参数2 41 | * @return 42 | */ 43 | static UInt8 TCmdCtrlProcessHmiCtrl(TCmdCtrlProcess *self, UInt16 param1, UInt16 param2) 44 | { 45 | return 0; 46 | } 47 | 48 | /** 49 | * 类的析构函数 50 | * @param object: 对象实例 51 | * @return 52 | */ 53 | static void TCmdCtrlProcessDestroy(TOfObject *object) 54 | { 55 | TCmdCtrlProcess *self = (TCmdCtrlProcess *)object; 56 | self->Destroy_(object); 57 | } 58 | 59 | void TCmdCtrlProcessCreate(TCmdCtrlProcess *self) 60 | { 61 | /// 构建基类 62 | TOfObjectCreate((TOfObject *)self); 63 | OVERRIDE_METHOD(TOfObject, Destroy, TCmdCtrlProcessDestroy); 64 | self->method_msg_send_ = NULL; 65 | self->receiver_ = NULL; 66 | } 67 | 68 | Bool TCmdCtrlProcessNotifyMsg(TCmdCtrlProcess *self, UInt8 host_source, UInt8 ser_num, UInt8 cmd, UInt8* data, UInt32 data_len) 69 | { 70 | THmiProtocolSlaveCtrlRespMsg resp_msg; 71 | resp_msg.ctrl_cmd = cmd; 72 | resp_msg.reserved[0] = 0; 73 | resp_msg.reserved[1] = 0; 74 | resp_msg.result = 1; 75 | if (data != NULL && data_len >= sizeof(THmiProtocolHostCtrlMsg)) 76 | { 77 | THmiProtocolHostCtrlMsg *ctrl_msg = (THmiProtocolHostCtrlMsg *)data; 78 | 79 | if (ctrl_msg->ctrl_cmd == kHmiProtocolCtrlCmdHmiCtl) 80 | { 81 | resp_msg.result = TCmdCtrlProcessHmiCtrl(self, ctrl_msg->param1, ctrl_msg->param2); 82 | } 83 | } 84 | 85 | if (self->method_msg_send_ != NULL) 86 | { 87 | self->method_msg_send_(self->receiver_, host_source, ser_num, kHmiProtocolCmdSlaveCtrlResp, (UInt8 *)&resp_msg, sizeof(resp_msg)); 88 | } 89 | 90 | return True; 91 | } 92 | -------------------------------------------------------------------------------- /app/app_test/inc/test_protocol.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file test_procol.h 3 | * @brief RS485测试协议 4 | * @note 5 | * @author 6 | * @date 2021-7-2 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-7-2 1.0 创建初始版本 13 | * @copyright 14 | */ 15 | #ifndef _TEST_PROTOCOL_H_ 16 | #define _TEST_PROTOCOL_H_ 17 | 18 | #include "stdint.h" 19 | #include "stdbool.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef struct TTestProtocolTag TTestProtocol; 26 | /** 27 | * 命令通知函数 28 | * @param receiver: 接口所有者 29 | * @param serial: 流水号 30 | * @param data: 命令数据指针 31 | * @param data_len: 命令数据长度 32 | * @return 33 | */ 34 | typedef void (*TTestProtocolMsgNotify)(void *receiver, uint8_t serial, uint8_t* data, uint32_t data_len); 35 | 36 | /** 37 | * 消息实际发送函数 38 | * @param receiver: 接口所有者 39 | * @param data: 发送数据地址 40 | * @param len: 发送数据长度 41 | * @return 0:失败 >0:发送成功个数 42 | */ 43 | typedef uint32_t (*TTestProtocolDataSend)(void *receiver, uint8_t *data, uint32_t len); 44 | 45 | struct TTestProtocolTag 46 | { 47 | ///PUBLIC 48 | TTestProtocolMsgNotify method_notify_; ///< 状态通知方法(调用者实现) 49 | TTestProtocolDataSend method_send_; ///< 发送消息方法(调用者实现) 50 | void *receiver_; ///< 接收者 51 | ///PRIVATE 52 | uint8_t *buffer_; ///< buffer缓冲区指针 53 | uint8_t *send_buffer_; ///< 发送缓冲区指针 54 | uint32_t buffer_size_; ///< buffer缓冲区大小 55 | uint32_t send_buffer_size_; ///< 发送缓冲区大小 56 | uint32_t now_size_; ///< 当前数据长度 57 | }; 58 | 59 | /** 60 | * 对象创建 61 | * @param self: 对象实例指针 62 | * @param buffer: 数据缓存区 63 | * @param buffer_size: 数据缓存区大小 64 | * @param send_buffer: 发送数据缓存区 65 | * @param send_buffer_size: 发送数据缓存区大小 66 | * @return 如果创建成功返回True,否则返回False 67 | */ 68 | bool TTestProtocolCreate(TTestProtocol *self, uint8_t* buffer, uint32_t buffer_size, uint8_t* send_buffer, uint32_t send_buffer_size); 69 | /** 70 | * 析构函数 71 | * @param self: 对象实例指针 72 | * @return 73 | */ 74 | void TTestProtocolDestroy(TTestProtocol *self); 75 | 76 | /** 77 | * 传入数据(解析后会调用通知函数) 78 | * @param self: 对象实例指针 79 | * @param data: 获取到的数据 80 | * @param data_len: 获取到的数据长度 81 | * @return 无 82 | */ 83 | void TTestProtocolTransfer(TTestProtocol *self, uint8_t *data, uint32_t data_len); 84 | 85 | /** 86 | * 发送数据 87 | * @param self: 对象实例指针 88 | * @param serial_num: 流水号 89 | * @param data: 数据 90 | * @param len: 数据长度 91 | * @return True:成功 False:失败 92 | */ 93 | bool TTestProtocolSendData(TTestProtocol *self, uint8_t serial_num, uint8_t *data, uint8_t len); 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | #endif 99 | -------------------------------------------------------------------------------- /app/readme.txt: -------------------------------------------------------------------------------- 1 | abc 2 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/drv/drv_adc_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_adc_cfg.h 3 | * @brief ADC驱动配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _DRV_ADC_CFG_H_ 17 | #define _DRV_ADC_CFG_H_ 18 | 19 | #include "drv_port.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef struct TDrvAdcCfgTag TDrvAdcCfg; 26 | struct TDrvAdcCfgTag 27 | { 28 | void *base; ///< 寄存器组基地址 29 | TDrvPort *adc_port; //< 接收引脚所在的端口 30 | Byte adc_pin; //< 接收引脚编号 31 | Byte adc_channel; ///< 通道号 32 | Byte adc_sample_tim; ///< 采样时间 33 | 34 | Byte use_channel; ///< 通道号 35 | // Int32 ref_val; ///< 参考电压 36 | // Int8 mode; ///< 转换模式 37 | // Int8 bits; ///< 转换位数 38 | // Int8 smplt; ///< 采样时间 39 | // Int8 pcc_idx; ///< PCC索引 40 | }; 41 | 42 | #ifdef __cplusplus 43 | } ///< extern "C" 44 | #endif 45 | 46 | #endif ///< _DRV_ADC_CFG_H_ 47 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/drv/drv_can_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_can_cfg.h 3 | * @brief CAN驱动配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _DRV_CAN_CFG_H_ 17 | #define _DRV_CAN_CFG_H_ 18 | 19 | #include "drv_port.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef struct TDrvCanCfgTag TDrvCanCfg; 26 | struct TDrvCanCfgTag 27 | { 28 | CAN_TypeDef *can_base; //< Uart寄存器组基地址 29 | TDrvPort *can_rx_port; //< 接收引脚所在的端口 30 | TDrvPort *can_tx_port; //< 发送引脚所在的端口 31 | Byte can_rx_pin; //< 接收引脚编号 32 | Byte can_tx_pin; //< 发送引脚编号 33 | TPortMux pin_mux; //< 引脚复用功能 34 | Byte interrupt_irqn; //< 35 | }; 36 | 37 | #ifdef __cplusplus 38 | } // extern "C" 39 | #endif 40 | 41 | #endif // _DRV_UART_CFG_H_ 42 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/drv/drv_dma_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_dma_cfg.h 3 | * @brief DMA驱动配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _DRV_DMA_CFG_H_ 17 | #define _DRV_DMA_CFG_H_ 18 | 19 | #include "drv_port.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef struct TDrvDmaCfgTag TDrvDmaCfg; 26 | struct TDrvDmaCfgTag 27 | { 28 | UInt32 dma_idx; ///< DMA选择(0~1) 29 | UInt32 chn; ///< 通道号(0~7) 30 | UInt32 chn_item; ///< 功能项(0~7) 31 | }; 32 | 33 | #ifdef __cplusplus 34 | } ///< extern "C" 35 | #endif 36 | 37 | #endif ///< _DRV_DMA_CFG_H_ 38 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/drv/drv_irq_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_irq_cfg.h 3 | * @brief 中断优先级配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _DRV_IRQ_CFG_H_ 17 | #define _DRV_IRQ_CFG_H_ 18 | 19 | #include "drv_port.h" 20 | #include "drv_int.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /// 抢占优先级组0 27 | enum 28 | { 29 | kDrvIrqCfgPreeCanRx0 = kSysIrqPreePriority0, ///< can0Rx 30 | kDrvIrqCfgPreeCanRx1 = kSysIrqPreePriority0, ///< can1Rx 31 | kDrvIrqCfgPreeCanRx2 = kSysIrqPreePriority0, ///< can2Rx 32 | kDrvIrqCfgPreeCanTx0 = kSysIrqPreePriority0, ///< can0Tx 33 | kDrvIrqCfgPreeCanTx1 = kSysIrqPreePriority0, ///< can1Tx 34 | kDrvIrqCfgPreeCanTx2 = kSysIrqPreePriority0, ///< can2Tx 35 | kDrvIrqCfgPreeRs485 = kSysIrqPreePriority0, ///< Rs485中断 36 | }; 37 | /// 响应优先级组0 38 | enum 39 | { 40 | kDrvIrqCfgSubCanRx0 = kSysIrqSubPriority0, ///< can0Rx 41 | kDrvIrqCfgSubCanRx1 = kSysIrqSubPriority1, ///< can1Rx 42 | kDrvIrqCfgSubCanRx2 = kSysIrqSubPriority2, ///< can2Rx 43 | kDrvIrqCfgSubCanTx0 = kSysIrqSubPriority3, ///< can0Tx 44 | kDrvIrqCfgSubCanTx1 = kSysIrqSubPriority4, ///< can1Tx 45 | kDrvIrqCfgSubCanTx2 = kSysIrqSubPriority5, ///< can2Tx 46 | kDrvIrqCfgSubRs485 = kSysIrqSubPriority6, ///< Rs458中断 47 | }; 48 | 49 | 50 | 51 | /// 抢占优先级组1 52 | enum 53 | { 54 | kDrvIrqCfgPreeExitInt = kSysIrqPreePriority1, ///< io口中断 55 | kDrvIrqCfgPreeTimer = kSysIrqPreePriority1, ///< 定时器中断 56 | kDrvIrqCfgPreeUsb = kSysIrqPreePriority1, ///< usb中断 57 | kDrvIrqCfgPreeUart = kSysIrqPreePriority1, ///< 串口中断 58 | }; 59 | 60 | /// 响应优先级组1 61 | enum 62 | { 63 | kDrvIrqCfgSubExitInt = kSysIrqSubPriority0, ///< io口中断 64 | kDrvIrqCfgSubTimer = kSysIrqSubPriority1, ///< 定时器中断 65 | kDrvIrqCfgSubUsb = kSysIrqSubPriority2, ///< usb中断 66 | kDrvIrqCfgSubUart = kSysIrqSubPriority3, ///< 串口中断 67 | }; 68 | 69 | 70 | 71 | #ifdef __cplusplus 72 | } ///< extern "C" 73 | #endif 74 | 75 | #endif ///< _DRV_IRQ_CFG_H_ 76 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/drv/drv_pwm_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_pwm_cfg.h 3 | * @brief pwm配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _DRV_PWM_CFG_H_ 17 | #define _DRV_PWM_CFG_H_ 18 | 19 | #include "drv_port.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | ///< 定时器配置 25 | typedef struct TDrvPwmTimerCfgTag TDrvPwmTimerCfg; 26 | struct TDrvPwmTimerCfgTag 27 | { 28 | UInt8 tim_index; ///< 定时器序列号 29 | UInt32 pwm_frequence; ///< pwm输出频率 30 | Bool time_is_open; ///< 定时器是否打开 31 | UInt32 pwm_period; ///< pwm周期值(自动计算) 32 | }; 33 | ///< 定时器通道配置 34 | typedef struct TDrvPwmCfgTag TDrvPwmCfg; 35 | struct TDrvPwmCfgTag 36 | { 37 | UInt8 pwm_tim_index_; ///< TDrvPwmTimerCfg序列号 38 | UInt8 tim_chn_; ///< 定时器通道 39 | TDrvPort *pwm_port; //< 接收引脚所在的端口 40 | Byte pwm_pin; //< 接收引脚编号 41 | TPortMux gpio_mux; //< 引脚复用功能 42 | }; 43 | 44 | extern const TDrvPwmCfg g_drv_pwm_cfgs[3]; 45 | 46 | #ifdef __cplusplus 47 | } // extern "C" 48 | #endif 49 | 50 | #endif // _DRV_PWM_CFG_H_ 51 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/drv/drv_spi_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_spi_cfg.h 3 | * @brief SPI驱动配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _DRV_SPI_CFG_H_ 17 | #define _DRV_SPI_CFG_H_ 18 | 19 | #include "drv_port.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef struct TDrvSpiCfgTag TDrvSpiCfg; 26 | struct TDrvSpiCfgTag 27 | { 28 | UInt8 spi_index; ///< spi序列号 29 | TDrvPort *sck_port; ///< spi_sck端口 30 | Byte sck_pin; ///< spi_sck引脚编号 31 | TDrvPort *mosi_port; ///< spi_mosi端口 32 | Byte mosi_pin; ///< spi_mosi引脚编号 33 | TDrvPort *miso_port; ///< spi_miso端口 34 | Byte miso_pin; ///< spi_miso引脚编号 35 | TPortMux spi_mux; ///< 引脚复用功能 36 | UInt32 baud_div; ///< 波特率分频设置(0: /2 1:/4 2: /8 3: /16 ....7: / 256) 37 | Byte cpol; ///< 时钟极性 0:空闲SCK低电平 1:空闲SCK高电平 38 | Byte cpha; ///< 时钟相位 0:从第一个时钟边沿采样 1:从第二个时钟边沿采样 39 | }; 40 | 41 | extern const TDrvSpiCfg g_drv_spi_cfgs[2]; 42 | 43 | #ifdef __cplusplus 44 | } // extern "C" 45 | #endif 46 | 47 | #endif // _DRV_SPI_CFG_H_ 48 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/drv/drv_timer_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_timer_cfg.h 3 | * @brief 定时器驱动配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _DRV_TIMER_CFG_H_ 17 | #define _DRV_TIMER_CFG_H_ 18 | 19 | #include "drv_port.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef struct TDrvTimerCfgTag TDrvTimerCfg; 26 | struct TDrvTimerCfgTag 27 | { 28 | Int32 timer_index; ///< 定时器序列(0起始) 29 | }; 30 | 31 | extern TDrvTimerCfg g_drv_timer_cfgs; 32 | 33 | #ifdef __cplusplus 34 | } ///< extern "C" 35 | #endif 36 | 37 | #endif ///< _DRV_TIMER_CFG_H_ 38 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/drv/drv_uart_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_uart_cfg.h 3 | * @brief 串口驱动配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _DRV_UART_CFG_H_ 17 | #define _DRV_UART_CFG_H_ 18 | 19 | #include "drv_port.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef struct TDrvUartCfgTag TDrvUartCfg; 26 | struct TDrvUartCfgTag 27 | { 28 | USART_TypeDef *uart_base; //< Uart寄存器组基地址 29 | TDrvPort *tx_port; //< 发送引脚所在的端口 30 | TDrvPort *rx_port; //< 接收引脚所在的端口 31 | TDrvPort *rts_port; //< 485.rts引脚所在的端口 32 | Byte tx_pin; //< 发送引脚编号 33 | Byte rx_pin; //< 接收引脚编号 34 | Byte rts_pin; //< rts引脚编号 35 | TPortMux pin_mux; //< 引脚复用功能 36 | TPortMux pin_rts_mux; //< rts的引脚复用功能 37 | Byte interrupt_irqn; //< 38 | }; 39 | 40 | #ifdef __cplusplus 41 | } // extern "C" 42 | #endif 43 | 44 | #endif // _DRV_UART_CFG_H_ 45 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/hal/stm32f4xx_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_crc.h 4 | * @author MCD Application Team 5 | * @version V1.5.0 6 | * @date 06-March-2015 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2015 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_CRC_H 31 | #define __STM32F4xx_CRC_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup CRC 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup CRC_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /* Exported macro ------------------------------------------------------------*/ 60 | /* Exported functions --------------------------------------------------------*/ 61 | 62 | void CRC_ResetDR(void); 63 | uint32_t CRC_CalcCRC(uint32_t Data); 64 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 65 | uint32_t CRC_GetCRC(void); 66 | void CRC_SetIDRegister(uint8_t IDValue); 67 | uint8_t CRC_GetIDRegister(void); 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* __STM32F4xx_CRC_H */ 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 84 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/hal/usb/core/usb_bsp.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_bsp.h 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief Specific api's relative to the used hardware platform 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USB_BSP__H__ 30 | #define __USB_BSP__H__ 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "usb_core.h" 34 | #include "usb_conf.h" 35 | 36 | /** @addtogroup USB_OTG_DRIVER 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USB_BSP 41 | * @brief This file is the 42 | * @{ 43 | */ 44 | 45 | 46 | /** @defgroup USB_BSP_Exported_Defines 47 | * @{ 48 | */ 49 | /** 50 | * @} 51 | */ 52 | 53 | 54 | /** @defgroup USB_BSP_Exported_Types 55 | * @{ 56 | */ 57 | /** 58 | * @} 59 | */ 60 | 61 | 62 | /** @defgroup USB_BSP_Exported_Macros 63 | * @{ 64 | */ 65 | /** 66 | * @} 67 | */ 68 | 69 | /** @defgroup USB_BSP_Exported_Variables 70 | * @{ 71 | */ 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USB_BSP_Exported_FunctionsPrototype 77 | * @{ 78 | */ 79 | void BSP_Init(void); 80 | 81 | void USB_OTG_BSP_Init (USB_OTG_CORE_HANDLE *pdev); 82 | void USB_OTG_BSP_uDelay (const uint32_t usec); 83 | void USB_OTG_BSP_mDelay (const uint32_t msec); 84 | void USB_OTG_BSP_EnableInterrupt (USB_OTG_CORE_HANDLE *pdev); 85 | //#ifdef USE_HOST_MODE 86 | void USB_OTG_BSP_ConfigVBUS(USB_OTG_CORE_HANDLE *pdev); 87 | void USB_OTG_BSP_DriveVBUS(USB_OTG_CORE_HANDLE *pdev,uint8_t state); 88 | //#endif 89 | /** 90 | * @} 91 | */ 92 | 93 | #endif //__USB_BSP__H__ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** 100 | * @} 101 | */ 102 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 103 | 104 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/hal/usb/usb_device/config/usbd_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_conf.h 4 | * @author MCD Application Team 5 | * @version V1.1.0 6 | * @date 19-March-2012 7 | * @brief USB Device configuration file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_CONF__H__ 30 | #define __USBD_CONF__H__ 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "usb_conf.h" 34 | 35 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 36 | * @{ 37 | */ 38 | 39 | /** @defgroup USBD_CONF 40 | * @brief This file is the device library configuration file 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_CONF_Exported_Defines 45 | * @{ 46 | */ 47 | 48 | 49 | #define USBD_CFG_MAX_NUM 1 50 | #define USBD_ITF_MAX_NUM 1 51 | #define USB_MAX_STR_DESC_SIZ 64 52 | 53 | #define USBD_SELF_POWERED 54 | 55 | /* Class Layer Parameter */ 56 | 57 | #define MSC_IN_EP 0x81 58 | #define MSC_OUT_EP 0x01 59 | #ifdef USE_USB_OTG_HS 60 | #ifdef USE_ULPI_PHY 61 | #define MSC_MAX_PACKET 512 62 | #else 63 | #define MSC_MAX_PACKET 64 64 | #endif 65 | #else /*USE_USB_OTG_FS*/ 66 | #define MSC_MAX_PACKET 64 67 | #endif 68 | 69 | 70 | #define MSC_MEDIA_PACKET 4096 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | 77 | /** @defgroup USB_CONF_Exported_TypesDefinitions 78 | * @{ 79 | */ 80 | /** 81 | * @} 82 | */ 83 | 84 | 85 | /** @defgroup USB_CONF_Exported_Macros 86 | * @{ 87 | */ 88 | /** 89 | * @} 90 | */ 91 | 92 | /** @defgroup USB_CONF_Exported_Variables 93 | * @{ 94 | */ 95 | /** 96 | * @} 97 | */ 98 | 99 | /** @defgroup USB_CONF_Exported_FunctionsPrototype 100 | * @{ 101 | */ 102 | /** 103 | * @} 104 | */ 105 | 106 | #endif //__USBD_CONF__H__ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 117 | 118 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/hal/usb/usb_device/core/usbd_conf_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_conf_template.h 4 | * @author MCD Application Team 5 | * @version V1.1.0 6 | * @date 19-March-2012 7 | * @brief usb device configuration template file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_CONF__H__ 30 | #define __USBD_CONF__H__ 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "usb_conf.h" 34 | 35 | /** @defgroup USB_CONF_Exported_Defines 36 | * @{ 37 | */ 38 | #define USE_USB_OTG_HS 39 | 40 | #define USBD_CFG_MAX_NUM 1 41 | #define USB_MAX_STR_DESC_SIZ 64 42 | #define USBD_EP0_MAX_PACKET_SIZE 64 43 | 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @defgroup USB_CONF_Exported_Types 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USB_CONF_Exported_Macros 58 | * @{ 59 | */ 60 | /** 61 | * @} 62 | */ 63 | 64 | /** @defgroup USB_CONF_Exported_Variables 65 | * @{ 66 | */ 67 | /** 68 | * @} 69 | */ 70 | 71 | /** @defgroup USB_CONF_Exported_FunctionsPrototype 72 | * @{ 73 | */ 74 | /** 75 | * @} 76 | */ 77 | 78 | 79 | #endif //__USBD_CONF__H__ 80 | 81 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 82 | 83 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/hal/usb/usb_device/core/usbd_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_core.h 4 | * @author MCD Application Team 5 | * @version V1.1.0 6 | * @date 19-March-2012 7 | * @brief Header file for usbd_core.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_CORE_H 30 | #define __USBD_CORE_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "usb_dcd.h" 34 | #include "usbd_def.h" 35 | #include "usbd_conf.h" 36 | 37 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 38 | * @{ 39 | */ 40 | 41 | /** @defgroup USBD_CORE 42 | * @brief This file is the Header file for usbd_core.c file 43 | * @{ 44 | */ 45 | 46 | 47 | /** @defgroup USBD_CORE_Exported_Defines 48 | * @{ 49 | */ 50 | 51 | typedef enum { 52 | USBD_OK = 0, 53 | USBD_BUSY, 54 | USBD_FAIL, 55 | }USBD_Status; 56 | /** 57 | * @} 58 | */ 59 | 60 | 61 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 62 | * @{ 63 | */ 64 | 65 | 66 | /** 67 | * @} 68 | */ 69 | 70 | 71 | 72 | /** @defgroup USBD_CORE_Exported_Macros 73 | * @{ 74 | */ 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup USBD_CORE_Exported_Variables 81 | * @{ 82 | */ 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup USBD_CORE_Exported_FunctionsPrototype 89 | * @{ 90 | */ 91 | void USBD_Init(USB_OTG_CORE_HANDLE *pdev, 92 | USB_OTG_CORE_ID_TypeDef coreID, 93 | USBD_DEVICE *pDevice, 94 | USBD_Class_cb_TypeDef *class_cb, 95 | USBD_Usr_cb_TypeDef *usr_cb); 96 | 97 | USBD_Status USBD_DeInit(USB_OTG_CORE_HANDLE *pdev); 98 | 99 | USBD_Status USBD_ClrCfg(USB_OTG_CORE_HANDLE *pdev, uint8_t cfgidx); 100 | 101 | USBD_Status USBD_SetCfg(USB_OTG_CORE_HANDLE *pdev, uint8_t cfgidx); 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | #endif /* __USBD_CORE_H */ 108 | 109 | /** 110 | * @} 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/hal/usb/usb_device/core/usbd_req.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_req.h 4 | * @author MCD Application Team 5 | * @version V1.1.0 6 | * @date 19-March-2012 7 | * @brief header file for the usbd_req.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | 30 | #ifndef __USB_REQUEST_H_ 31 | #define __USB_REQUEST_H_ 32 | 33 | /* Includes ------------------------------------------------------------------*/ 34 | #include "usbd_def.h" 35 | #include "usbd_core.h" 36 | #include "usbd_conf.h" 37 | 38 | 39 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 40 | * @{ 41 | */ 42 | 43 | /** @defgroup USBD_REQ 44 | * @brief header file for the usbd_ioreq.c file 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USBD_REQ_Exported_Defines 49 | * @{ 50 | */ 51 | /** 52 | * @} 53 | */ 54 | 55 | 56 | /** @defgroup USBD_REQ_Exported_Types 57 | * @{ 58 | */ 59 | /** 60 | * @} 61 | */ 62 | 63 | 64 | 65 | /** @defgroup USBD_REQ_Exported_Macros 66 | * @{ 67 | */ 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup USBD_REQ_Exported_Variables 73 | * @{ 74 | */ 75 | /** 76 | * @} 77 | */ 78 | 79 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 80 | * @{ 81 | */ 82 | 83 | USBD_Status USBD_StdDevReq (USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req); 84 | USBD_Status USBD_StdItfReq (USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req); 85 | USBD_Status USBD_StdEPReq (USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req); 86 | void USBD_ParseSetupRequest( USB_OTG_CORE_HANDLE *pdev, 87 | USB_SETUP_REQ *req); 88 | 89 | void USBD_CtlError( USB_OTG_CORE_HANDLE *pdev, 90 | USB_SETUP_REQ *req); 91 | 92 | void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len); 93 | /** 94 | * @} 95 | */ 96 | 97 | #endif /* __USB_REQUEST_H_ */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | 108 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 109 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/hal/usb/usb_device/msc/usbd_msc_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_msc_core.h 4 | * @author MCD Application Team 5 | * @version V1.1.0 6 | * @date 19-March-2012 7 | * @brief header for the usbd_msc_core.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef _USB_MSC_CORE_H_ 30 | #define _USB_MSC_CORE_H_ 31 | 32 | #include "usbd_ioreq.h" 33 | 34 | /** @addtogroup USBD_MSC_BOT 35 | * @{ 36 | */ 37 | 38 | /** @defgroup USBD_MSC 39 | * @brief This file is the Header file for USBD_msc.c 40 | * @{ 41 | */ 42 | 43 | 44 | /** @defgroup USBD_BOT_Exported_Defines 45 | * @{ 46 | */ 47 | 48 | 49 | #define BOT_GET_MAX_LUN 0xFE 50 | #define BOT_RESET 0xFF 51 | #define USB_MSC_CONFIG_DESC_SIZ 32 52 | 53 | #define MSC_EPIN_SIZE MSC_MAX_PACKET 54 | #define MSC_EPOUT_SIZE MSC_MAX_PACKET 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | /** @defgroup USB_CORE_Exported_Types 61 | * @{ 62 | */ 63 | 64 | extern USBD_Class_cb_TypeDef USBD_MSC_cb; 65 | /** 66 | * @} 67 | */ 68 | 69 | /** 70 | * @} 71 | */ 72 | #endif // _USB_MSC_CORE_H_ 73 | /** 74 | * @} 75 | */ 76 | 77 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/hal/usb/usb_device/msc/usbd_msc_data.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_msc_data.h 4 | * @author MCD Application Team 5 | * @version V1.1.0 6 | * @date 19-March-2012 7 | * @brief header for the usbd_msc_data.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | 30 | #ifndef _USBD_MSC_DATA_H_ 31 | #define _USBD_MSC_DATA_H_ 32 | 33 | /* Includes ------------------------------------------------------------------*/ 34 | #include "usbd_conf.h" 35 | 36 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USB_INFO 41 | * @brief general defines for the usb device library file 42 | * @{ 43 | */ 44 | 45 | /** @defgroup USB_INFO_Exported_Defines 46 | * @{ 47 | */ 48 | #define MODE_SENSE6_LEN 8 49 | #define MODE_SENSE10_LEN 8 50 | #define LENGTH_INQUIRY_PAGE00 7 51 | #define LENGTH_FORMAT_CAPACITIES 20 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | 58 | /** @defgroup USBD_INFO_Exported_TypesDefinitions 59 | * @{ 60 | */ 61 | /** 62 | * @} 63 | */ 64 | 65 | 66 | 67 | /** @defgroup USBD_INFO_Exported_Macros 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBD_INFO_Exported_Variables 76 | * @{ 77 | */ 78 | extern const uint8_t MSC_Page00_Inquiry_Data[]; 79 | extern const uint8_t MSC_Mode_Sense6_data[]; 80 | extern const uint8_t MSC_Mode_Sense10_data[] ; 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup USBD_INFO_Exported_FunctionsPrototype 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | #endif /* _USBD_MSC_DATA_H_ */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 105 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/hal/usb/usb_device/msc/usbd_msc_mem.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_msc_mem.h 4 | * @author MCD Application Team 5 | * @version V1.1.0 6 | * @date 19-March-2012 7 | * @brief header for the STORAGE DISK file file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | 30 | #ifndef __USBD_MEM_H 31 | #define __USBD_MEM_H 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "usbd_def.h" 34 | 35 | 36 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USBD_MEM 41 | * @brief header file for the storage disk file 42 | * @{ 43 | */ 44 | 45 | /** @defgroup USBD_MEM_Exported_Defines 46 | * @{ 47 | */ 48 | #define USBD_STD_INQUIRY_LENGTH 36 49 | /** 50 | * @} 51 | */ 52 | 53 | 54 | /** @defgroup USBD_MEM_Exported_TypesDefinitions 55 | * @{ 56 | */ 57 | 58 | typedef struct _USBD_STORAGE 59 | { 60 | int8_t (* Init) (uint8_t lun); 61 | int8_t (* GetCapacity) (uint8_t lun, uint32_t *block_num, uint32_t *block_size); 62 | int8_t (* IsReady) (uint8_t lun); 63 | int8_t (* IsWriteProtected) (uint8_t lun); 64 | int8_t (* Read) (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len); 65 | int8_t (* Write)(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len); 66 | int8_t (* GetMaxLun)(void); 67 | int8_t *pInquiry; 68 | 69 | }USBD_STORAGE_cb_TypeDef; 70 | /** 71 | * @} 72 | */ 73 | 74 | 75 | 76 | /** @defgroup USBD_MEM_Exported_Macros 77 | * @{ 78 | */ 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup USBD_MEM_Exported_Variables 85 | * @{ 86 | */ 87 | 88 | /** 89 | * @} 90 | */ 91 | 92 | /** @defgroup USBD_MEM_Exported_FunctionsPrototype 93 | * @{ 94 | */ 95 | extern USBD_STORAGE_cb_TypeDef *USBD_STORAGE_fops; 96 | /** 97 | * @} 98 | */ 99 | 100 | #endif /* __USBD_MEM_H */ 101 | /** 102 | * @} 103 | */ 104 | 105 | /** 106 | * @} 107 | */ 108 | 109 | /** 110 | * @} 111 | */ 112 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 113 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/hal/usb/usb_host/config/usbh_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USBH_conf.h 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief General low level driver configuration 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBH_CONF__H__ 30 | #define __USBH_CONF__H__ 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | 34 | /** @addtogroup USBH_OTG_DRIVER 35 | * @{ 36 | */ 37 | 38 | /** @defgroup USBH_CONF 39 | * @brief usb otg low level driver configuration file 40 | * @{ 41 | */ 42 | 43 | /** @defgroup USBH_CONF_Exported_Defines 44 | * @{ 45 | */ 46 | 47 | #define USBH_MAX_NUM_ENDPOINTS 2 48 | #define USBH_MAX_NUM_INTERFACES 2 49 | #ifdef USE_USB_OTG_FS 50 | #define USBH_MSC_MPS_SIZE 0x40 51 | #else 52 | #define USBH_MSC_MPS_SIZE 0x200 53 | #endif 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | 60 | /** @defgroup USBH_CONF_Exported_Types 61 | * @{ 62 | */ 63 | /** 64 | * @} 65 | */ 66 | 67 | 68 | /** @defgroup USBH_CONF_Exported_Macros 69 | * @{ 70 | */ 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBH_CONF_Exported_Variables 76 | * @{ 77 | */ 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @defgroup USBH_CONF_Exported_FunctionsPrototype 83 | * @{ 84 | */ 85 | /** 86 | * @} 87 | */ 88 | 89 | 90 | #endif //__USBH_CONF__H__ 91 | 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | /** 98 | * @} 99 | */ 100 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 101 | 102 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/hal/usb/usb_host/host/usbh_conf_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_conf_template 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief General USB Host library configuration 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBH_CONF__H__ 30 | #define __USBH_CONF__H__ 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | 34 | /** @addtogroup USBH_OTG_DRIVER 35 | * @{ 36 | */ 37 | 38 | /** @defgroup USBH_CONF 39 | * @brief usb otg low level driver configuration file 40 | * @{ 41 | */ 42 | 43 | /** @defgroup USBH_CONF_Exported_Defines 44 | * @{ 45 | */ 46 | 47 | #define USBH_MAX_NUM_ENDPOINTS 2 48 | #define USBH_MAX_NUM_INTERFACES 2 49 | #ifdef USE_USB_OTG_FS 50 | #define USBH_MSC_MPS_SIZE 0x40 51 | #else 52 | #define USBH_MSC_MPS_SIZE 0x200 53 | #endif 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | 60 | /** @defgroup USBH_CONF_Exported_Types 61 | * @{ 62 | */ 63 | /** 64 | * @} 65 | */ 66 | 67 | 68 | /** @defgroup USBH_CONF_Exported_Macros 69 | * @{ 70 | */ 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBH_CONF_Exported_Variables 76 | * @{ 77 | */ 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @defgroup USBH_CONF_Exported_FunctionsPrototype 83 | * @{ 84 | */ 85 | /** 86 | * @} 87 | */ 88 | 89 | 90 | #endif //__USBH_CONF__H__ 91 | 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | /** 98 | * @} 99 | */ 100 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 101 | 102 | -------------------------------------------------------------------------------- /arch/inc/stm32f4xx/platform/stm32f4xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/arch/inc/stm32f4xx/platform/stm32f4xx.h -------------------------------------------------------------------------------- /arch/src/stm32f4xx/cfg/drv_can_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_can_cfg.c 3 | * @brief 用于can配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | const TDrvCanCfg g_drv_can_cfgs[] = 16 | { 17 | [0] = { 18 | .can_base = CAN1, 19 | .can_rx_port = &g_drv_port[kDrvPortNumG], 20 | .can_tx_port = &g_drv_port[kDrvPortNumG], 21 | .can_rx_pin = 0, 22 | .can_tx_pin = 1, 23 | .pin_mux = kPortMuxAlt9, 24 | .interrupt_irqn = CAN1_RX0_IRQn, 25 | }, 26 | [1] = { 27 | .can_base = CAN2, 28 | .can_rx_port = &g_drv_port[kDrvPortNumG], 29 | .can_tx_port = &g_drv_port[kDrvPortNumG], 30 | .can_rx_pin = 11, 31 | .can_tx_pin = 12, 32 | .pin_mux = kPortMuxAlt9, 33 | .interrupt_irqn = CAN2_RX1_IRQn, 34 | }, 35 | [2] = { 36 | .can_base = CAN3, 37 | .can_rx_port = &g_drv_port[kDrvPortNumA], 38 | .can_tx_port = &g_drv_port[kDrvPortNumA], 39 | .can_rx_pin = 8, 40 | .can_tx_pin = 15, 41 | .pin_mux = kPortMuxAlt11, 42 | .interrupt_irqn = OTG_HS_EP1_IN_CAN3_RX0_IRQn, 43 | }, 44 | }; 45 | //const TDrvCanCfg g_drv_can_cfgs[] = 46 | //{ 47 | // [0] = { 48 | // .can_base = CAN1, 49 | // .can_rx_port = &g_drv_port[kDrvPortNumD], 50 | // .can_tx_port = &g_drv_port[kDrvPortNumD], 51 | // .can_rx_pin = 0, 52 | // .can_tx_pin = 1, 53 | // .pin_mux = kPortMuxAlt9, 54 | // .interrupt_irqn = CAN1_RX0_IRQn, 55 | // }, 56 | // [1] = { 57 | // .can_base = CAN2, 58 | // .can_rx_port = &g_drv_port[kDrvPortNumB], 59 | // .can_tx_port = &g_drv_port[kDrvPortNumB], 60 | // .can_rx_pin = 12, 61 | // .can_tx_pin = 13, 62 | // .pin_mux = kPortMuxAlt9, 63 | // .interrupt_irqn = CAN2_RX1_IRQn, 64 | // }, 65 | //}; 66 | -------------------------------------------------------------------------------- /arch/src/stm32f4xx/cfg/drv_dma_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_dma_cfg.c 3 | * @brief 用于dma配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | const TDrvDmaCfg g_drv_dma_cfgs[] = 16 | { 17 | [0] = { 18 | .dma_idx = 1, 19 | .chn = 0, 20 | .chn_item = 0, ///< ADC1功能 21 | }, 22 | [1] = { 23 | .dma_idx = 1, 24 | .chn = 2, 25 | .chn_item = 1, ///< ADC2功能 26 | }, 27 | [2] = { 28 | .dma_idx = 1, 29 | .chn = 1, 30 | .chn_item = 2, ///< ADC3功能 31 | }, 32 | }; 33 | -------------------------------------------------------------------------------- /arch/src/stm32f4xx/cfg/drv_pwm_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_pwm_cfg.c 3 | * @brief 用于pwm配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | TDrvPwmTimerCfg g_drv_pwm_timer_cfgs[] = 17 | { 18 | [0] = { 19 | .tim_index = 0, ///< 定时器1 20 | .pwm_frequence = 20000, ///< pwm频率 21 | .time_is_open = False, ///< 未打开 22 | }, 23 | }; 24 | 25 | const TDrvPwmCfg g_drv_pwm_cfgs[] = 26 | { 27 | [0] = { 28 | .pwm_tim_index_ = 0, ///< 使用g_drv_pwm_timer_cfgs[0] 29 | .tim_chn_ = 0, ///< 定时器通道1 30 | .pwm_port = &g_drv_port[kDrvPortNumE], 31 | .pwm_pin = 9, 32 | .gpio_mux = kPortMuxAlt1, 33 | }, 34 | }; 35 | -------------------------------------------------------------------------------- /arch/src/stm32f4xx/cfg/drv_spi_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_spi_cfg.c 3 | * @brief 用于spi配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | const TDrvSpiCfg g_drv_spi_cfgs[2] = 17 | { 18 | [0] = { 19 | .spi_index = 0, ///< spi1 20 | .sck_port = &g_drv_port[kDrvPortNumB], 21 | .sck_pin = 3, 22 | .mosi_port = &g_drv_port[kDrvPortNumB], 23 | .mosi_pin = 5, 24 | .miso_port = &g_drv_port[kDrvPortNumB], 25 | .miso_pin = 4, 26 | .spi_mux = kPortMuxAlt5, 27 | .baud_div = 1, 28 | .cpol = 1, 29 | .cpha = 1, 30 | }, 31 | [1] = { 32 | .spi_index = 1, ///< spi2 33 | .sck_port = &g_drv_port[kDrvPortNumB], 34 | .sck_pin = 13, 35 | .mosi_port = &g_drv_port[kDrvPortNumB], 36 | .mosi_pin = 15, 37 | .miso_port = &g_drv_port[kDrvPortNumB], 38 | .miso_pin = 14, 39 | .spi_mux = kPortMuxAlt5, 40 | .baud_div = 1, 41 | .cpol = 0, 42 | .cpha = 0, 43 | }, 44 | }; 45 | -------------------------------------------------------------------------------- /arch/src/stm32f4xx/cfg/drv_timer_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_timer_cfg.c 3 | * @brief 用于定时器配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | TDrvTimerCfg g_drv_timer_cfgs = 16 | { 17 | 2, ///< 使用定时器3 18 | }; 19 | -------------------------------------------------------------------------------- /arch/src/stm32f4xx/cfg/drv_uart_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_uart_cfg.c 3 | * @brief 用于uart配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | const TDrvUartCfg g_drv_uart_cfgs[] = 16 | { 17 | [0] = { 18 | .uart_base = UART8, 19 | .tx_port = &g_drv_port[kDrvPortNumF], 20 | .rx_port = &g_drv_port[kDrvPortNumF], 21 | .pin_mux = kPortMuxAlt8, 22 | .tx_pin = 9, 23 | .rx_pin = 8, 24 | .interrupt_irqn = UART8_IRQn, 25 | }, 26 | [1] = { 27 | .uart_base = UART7, 28 | .tx_port = &g_drv_port[kDrvPortNumF], 29 | .rx_port = &g_drv_port[kDrvPortNumF], 30 | .pin_mux = kPortMuxAlt8, 31 | .tx_pin = 7, 32 | .rx_pin = 6, 33 | .interrupt_irqn = UART7_IRQn, 34 | }, 35 | [2] = { 36 | .uart_base = USART3, 37 | .tx_port = &g_drv_port[kDrvPortNumD], 38 | .rx_port = &g_drv_port[kDrvPortNumD], 39 | .rts_port = &g_drv_port[kDrvPortNumD], 40 | .pin_mux = kPortMuxAlt7, 41 | .pin_rts_mux = kPortMuxDisabled, 42 | .tx_pin = 8, 43 | .rx_pin = 9, 44 | .rts_pin = 12, 45 | .interrupt_irqn = USART3_IRQn, 46 | }, 47 | [3] = { 48 | .uart_base = USART6, 49 | .tx_port = &g_drv_port[kDrvPortNumC], 50 | .rx_port = &g_drv_port[kDrvPortNumC], 51 | .rts_port = &g_drv_port[kDrvPortNumG], 52 | .pin_mux = kPortMuxAlt8, 53 | .pin_rts_mux = kPortMuxDisabled, 54 | .tx_pin = 6, 55 | .rx_pin = 7, 56 | .rts_pin = 8, 57 | .interrupt_irqn = USART6_IRQn, 58 | }, 59 | }; 60 | -------------------------------------------------------------------------------- /arch/src/stm32f4xx/drv/drv_int.c: -------------------------------------------------------------------------------- 1 | #include "drv_int.h" 2 | #include "stm32f4xx.h" 3 | 4 | #define AIRCR_VECTKEY_MASK ((UInt32)0x05FA0000) 5 | 6 | 7 | ///优先级组配置0 - 0抢占优先级 16个响应优先级 8 | ///优先级组配置1 - 2抢占优先级 8个响应优先级 9 | ///优先级组配置2 - 4抢占优先级 4个响应优先级 10 | ///优先级组配置3 - 8抢占优先级 2个响应优先级 11 | ///优先级组配置4 - 16抢占优先级 0个响应优先级 12 | enum 13 | { 14 | kNvicPriorityGroup0 = 0x700, 15 | kNvicPriorityGroup1 = 0x600, 16 | kNvicPriorityGroup2 = 0x500, 17 | kNvicPriorityGroup3 = 0x400, 18 | kNvicPriorityGroup4 = 0x300, 19 | }; 20 | void SysIRQInit() 21 | { 22 | /// 设置中断优先级组为1, 2抢占优先级 8个响应优先级 23 | UInt32 group = kNvicPriorityGroup1; 24 | SCB->AIRCR = AIRCR_VECTKEY_MASK | group; 25 | } 26 | 27 | void SysEnableIRQ(UInt32 irq_number, TSysIrqPreePriority preemption_priority, TSysIrqSubPriority sub_priority) 28 | { 29 | UInt8 tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F; 30 | 31 | tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08; 32 | tmppre = (0x4 - tmppriority); 33 | tmpsub = tmpsub >> tmppriority; 34 | 35 | tmppriority = preemption_priority << tmppre; 36 | tmppriority |= (UInt8)(sub_priority & tmpsub); 37 | 38 | tmppriority = tmppriority << 0x04; 39 | 40 | NVIC->IP[irq_number] = tmppriority; 41 | 42 | NVIC->ISER[(UInt32)(irq_number) >> 5] = 1 << ((UInt32)irq_number & 0x1F); 43 | } 44 | 45 | void SysDisableIRQ(UInt32 irq_number) 46 | { 47 | NVIC->ICER[(UInt32)(irq_number) >> 5] = 1 << ((UInt32)irq_number & 0x1F); 48 | 49 | /// 清除PENDING标志 50 | NVIC->ICPR[(UInt32)(irq_number) >> 5] = 1 << ((UInt32)irq_number & 0x1F); 51 | } 52 | 53 | -------------------------------------------------------------------------------- /arch/src/stm32f4xx/drv/drv_pmu.c: -------------------------------------------------------------------------------- 1 | #include "drv_pmu.h" 2 | #include "stm32f4xx.h" 3 | 4 | 5 | void DrvPmuWork(void) 6 | { 7 | //RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; 8 | } 9 | 10 | 11 | void DrvPmuSleep(void) 12 | { 13 | // uint32_t tmpreg = 0; 14 | // 15 | // RCC->APB2ENR &= ~RCC_APB2ENR_AFIOEN; 16 | // 17 | // 18 | // tmpreg = PWR->CR; 19 | // tmpreg &= 0xFFFFFFFC; 20 | // PWR->CR = tmpreg; 21 | // SCB->SCR |= SCB_SCR_SLEEPDEEP; 22 | // __WFI(); 23 | // SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP); 24 | } 25 | 26 | void DrvPmuSoftReset(void) 27 | { 28 | __set_FAULTMASK(1); 29 | NVIC_SystemReset(); 30 | } 31 | -------------------------------------------------------------------------------- /arch/src/stm32f4xx/drv/drv_wdog.c: -------------------------------------------------------------------------------- 1 | #include "drv_wdog.h" 2 | //#include "stm32f413xx.h" 3 | #include "stm32f4xx.h" 4 | 5 | TDrvWdog g_drv_wdog; 6 | 7 | enum 8 | { 9 | kDrvDogCmdStart = 0xCCCC, ///< 看门狗打开命令 10 | kDrvDogCmdSetEnable = 0x5555, ///< 看门狗设置使能命令(配置前需设置) 11 | kDrvDogCmdFeedDog = 0xAAAA, ///< 看门狗喂狗命令 12 | }; 13 | 14 | /** 15 | * 看门狗分频因子枚举 16 | */ 17 | typedef enum TDrvWdogPrescalerTag TDrvWdogPrescaler; 18 | enum TDrvWdogPrescalerTag 19 | { 20 | kDrvWdogPrescaler4 = 0, ///< 预分频因子=4(默认) 21 | kDrvWdogPrescaler8 = 1, ///< 预分频因子=8 22 | kDrvWdogPrescaler16 = 2, ///< 预分频因子=16 23 | kDrvWdogPrescaler32 = 3, ///< 预分频因子=32 24 | kDrvWdogPrescaler64 = 4, ///< 预分频因子=64 25 | kDrvWdogPrescaler128 = 5, ///< 预分频因子=128 26 | kDrvWdogPrescaler256 = 6, ///< 预分频因子=256(设置为7也是256) 27 | }; 28 | /** 29 | * 设置分频因子 30 | * @param self: 对象实例指针 31 | * @return 32 | */ 33 | static void TDrvWdogSetPrescaler(TDrvWdog *self, TDrvWdogPrescaler pre) 34 | { 35 | IWDG->KR = kDrvDogCmdSetEnable; 36 | while(IWDG->SR & 0x01); 37 | IWDG->PR = pre; 38 | } 39 | /** 40 | * 设置重置值 41 | * @param self: 对象实例指针 42 | * @param reload: 重置值(0~0xfff) 43 | * @return 44 | */ 45 | static void TDrvWdogSetReload(TDrvWdog *self, UInt16 reload) 46 | { 47 | IWDG->KR = kDrvDogCmdSetEnable; 48 | while(IWDG->SR & 0x02); 49 | IWDG->RLR = reload & 0xfff; 50 | } 51 | 52 | /** 53 | * 销毁看门狗 54 | * @param self: 对象实例指针 55 | * @return 56 | */ 57 | static void TDrvWdogDestroy(TOfObject *self) 58 | { 59 | ((TDrvWdog *)self)->Destroy_(self); 60 | } 61 | 62 | void TDrvWdogCreate(TDrvWdog *self) 63 | { 64 | TOfObjectCreate((TOfObject *)self); 65 | OVERRIDE_METHOD(TOfObject, Destroy, TDrvWdogDestroy); 66 | } 67 | 68 | void TDrvWdogOpen(TDrvWdog *self) 69 | { 70 | TDrvWdogSetPrescaler(&g_drv_wdog, kDrvWdogPrescaler64); 71 | TDrvWdogSetReload(&g_drv_wdog,1000); 72 | 73 | IWDG->KR = kDrvDogCmdStart; 74 | } 75 | 76 | void TDrvWdogClose(TDrvWdog *self) 77 | { 78 | 79 | } 80 | 81 | void TDrvWdogFeedDog(TDrvWdog *self) 82 | { 83 | IWDG->KR = kDrvDogCmdFeedDog; 84 | } 85 | 86 | 87 | -------------------------------------------------------------------------------- /arch/src/stm32f4xx/hal/stm32f4xx_qspi.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/arch/src/stm32f4xx/hal/stm32f4xx_qspi.c -------------------------------------------------------------------------------- /arch/src/stm32f4xx/hal/usb/usb_device/msc/usbd_msc_data.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_msc_data.c 4 | * @author MCD Application Team 5 | * @version V1.1.0 6 | * @date 19-March-2012 7 | * @brief This file provides all the vital inquiry pages and sense data. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_msc_data.h" 30 | 31 | 32 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 33 | * @{ 34 | */ 35 | 36 | 37 | /** @defgroup MSC_DATA 38 | * @brief Mass storage info/data module 39 | * @{ 40 | */ 41 | 42 | /** @defgroup MSC_DATA_Private_TypesDefinitions 43 | * @{ 44 | */ 45 | /** 46 | * @} 47 | */ 48 | 49 | 50 | /** @defgroup MSC_DATA_Private_Defines 51 | * @{ 52 | */ 53 | /** 54 | * @} 55 | */ 56 | 57 | 58 | /** @defgroup MSC_DATA_Private_Macros 59 | * @{ 60 | */ 61 | /** 62 | * @} 63 | */ 64 | 65 | 66 | /** @defgroup MSC_DATA_Private_Variables 67 | * @{ 68 | */ 69 | 70 | 71 | /* USB Mass storage Page 0 Inquiry Data */ 72 | const uint8_t MSC_Page00_Inquiry_Data[] = {//7 73 | 0x00, 74 | 0x00, 75 | 0x00, 76 | (LENGTH_INQUIRY_PAGE00 - 4), 77 | 0x00, 78 | 0x80, 79 | 0x83 80 | }; 81 | /* USB Mass storage sense 6 Data */ 82 | const uint8_t MSC_Mode_Sense6_data[] = { 83 | 0x00, 84 | 0x00, 85 | 0x00, 86 | 0x00, 87 | 0x00, 88 | 0x00, 89 | 0x00, 90 | 0x00 91 | }; 92 | /* USB Mass storage sense 10 Data */ 93 | const uint8_t MSC_Mode_Sense10_data[] = { 94 | 0x00, 95 | 0x06, 96 | 0x00, 97 | 0x00, 98 | 0x00, 99 | 0x00, 100 | 0x00, 101 | 0x00 102 | }; 103 | /** 104 | * @} 105 | */ 106 | 107 | 108 | /** @defgroup MSC_DATA_Private_FunctionPrototypes 109 | * @{ 110 | */ 111 | /** 112 | * @} 113 | */ 114 | 115 | 116 | /** @defgroup MSC_DATA_Private_Functions 117 | * @{ 118 | */ 119 | 120 | /** 121 | * @} 122 | */ 123 | 124 | 125 | /** 126 | * @} 127 | */ 128 | 129 | 130 | /** 131 | * @} 132 | */ 133 | 134 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 135 | -------------------------------------------------------------------------------- /bootldr/inc/upgrade/upgrade.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file upgrade.h 3 | * @brief 升级相关处理 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _BOOTLDR_UPGRADE_H_ 17 | #define _BOOTLDR_UPGRADE_H_ 18 | 19 | #include "ofc_types.h" 20 | #include "ofc_object.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /** 27 | * 升级类 28 | * @par 示例 29 | * @code 30 | * @endcode 31 | */ 32 | typedef struct TBootldrUpgradeTag TBootldrUpgrade; 33 | 34 | struct TBootldrUpgradeTag 35 | { 36 | PROTECTED 37 | TOfObject parent_; ///< 继承的父类 38 | TOfVirtualMethod Destroy_; ///< 析构函数 39 | 40 | PRIVATE 41 | 42 | }; 43 | 44 | 45 | extern TBootldrUpgrade g_upgrade; ///< 内存单例模式对象 46 | 47 | /** 48 | * 构造函数 49 | * @param self: 对象实例指针 50 | * @return 51 | */ 52 | void TBootldrUpgradeCreate(TBootldrUpgrade *self); 53 | 54 | /** 55 | * 检查是否有更新 56 | * @param self: 对象实例指针 57 | * @return True:有更新 False:无更新 58 | */ 59 | Bool TBootldrUpgradeCheckIsUpdate(TBootldrUpgrade *self); 60 | 61 | /** 62 | * 从备份区拷贝app 63 | * @param self: 对象实例指针 64 | * @return True:更新成功 False:更新失败 65 | */ 66 | Bool TBootldrUpgradeCopyApp(TBootldrUpgrade *self); 67 | 68 | 69 | #ifdef __cplusplus 70 | } // extern "C" 71 | #endif 72 | 73 | #endif // _BOOTLDR_UPGRADE_H_ 74 | -------------------------------------------------------------------------------- /bootldr/src/link/ld/stm32_flash.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/bootldr/src/link/ld/stm32_flash.ld -------------------------------------------------------------------------------- /bootldr/src/main.c: -------------------------------------------------------------------------------- 1 | #include "ofc_types.h" 2 | #include "drv_clock.h" 3 | #include "drv_flash.h" 4 | #include "drv_pmu.h" 5 | #include "stm32f4xx.h" 6 | #include "upgrade.h" 7 | 8 | enum 9 | { 10 | kAppStartAddress = 0x08020000, ///< 应用程序启动地址 11 | }; 12 | 13 | #if defined (__CC_ARM) 14 | __asm static void JumpTo(unsigned int address) 15 | { 16 | LDR SP, [R0] ///< Load new stack pointer address 17 | LDR PC, [R0, #4] ///< Load new program counter address 18 | } 19 | #elif defined (__GNUC__) 20 | static void JumpTo(unsigned int address) 21 | { 22 | asm( 23 | "LDR SP, [R0]\n\t" ///< Load new stack pointer address 24 | "LDR PC, [R0, #4]\n\t" ///< Load new program counter address 25 | ); 26 | } 27 | #endif 28 | /** 29 | * 用不上,只是ofc_object.c中需要用到 30 | * @param 31 | * @return 32 | */ 33 | void *OfMalloc(Int32 size) 34 | { 35 | return NULL; 36 | } 37 | 38 | /** 39 | * 用不上,只是ofc_object.c中需要用到 40 | * @param 41 | * @return 42 | */ 43 | void OfFree(void *ptr) 44 | { 45 | } 46 | 47 | /** 48 | * 系统初始化 49 | * @note 50 | */ 51 | static void SysInit(void) 52 | { 53 | /// 初始化时钟 54 | TDrvClockCreate(&g_drv_clock); 55 | TDrvClockInitClock(&g_drv_clock); 56 | TDrvFlashCreate(&g_drv_flash); 57 | TDrvFlashOpen(&g_drv_flash); 58 | } 59 | int a = 0; 60 | int main() 61 | { 62 | SysInit(); 63 | // TBootldrUpgradeCreate(&g_upgrade); 64 | // 65 | // if (TBootldrUpgradeCheckIsUpdate(&g_upgrade)) 66 | // { 67 | // TBootldrUpgradeCopyApp(&g_upgrade); 68 | // DrvPmuSoftReset(); 69 | // } 70 | 71 | 72 | /// 引导进入Application 73 | SCB->VTOR = (kAppStartAddress); 74 | JumpTo(kAppStartAddress); 75 | while(1) 76 | { 77 | if (a == 1) 78 | { 79 | a = 0; 80 | } 81 | 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /bootldr/src/startup/gcc/startup_stm32f407xx.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/bootldr/src/startup/gcc/startup_stm32f407xx.o -------------------------------------------------------------------------------- /bootldr/src/version/version.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file version.c 3 | * @brief 版本号 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | enum 21 | { 22 | kVersionAddress = 0xCFF8, 23 | }; 24 | 25 | typedef struct 26 | { 27 | unsigned char major; 28 | unsigned char minor; 29 | unsigned char test; 30 | unsigned char compile; 31 | unsigned int compile_time; 32 | }TVersion; 33 | 34 | const TVersion bootloader_version __attribute__((at(kVersionAddress))) = 35 | { 36 | .major = 0x02, 37 | .minor = 0x05, 38 | .test = 0x00, 39 | .compile = 0x00, 40 | .compile_time = 1573000888, 41 | }; 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | -------------------------------------------------------------------------------- /doc/usal_mcu说明文档.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/doc/usal_mcu说明文档.chm -------------------------------------------------------------------------------- /doc/整体框图.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/doc/整体框图.pdf -------------------------------------------------------------------------------- /kernel/inc/dev/dev_adc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_adc.h 3 | * @brief AD设备层 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KERNEL_DEV_ADC_H_ 17 | #define _KERNEL_DEV_ADC_H_ 18 | 19 | #include "ofc_types.h" 20 | #include "ofc_object.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | 27 | 28 | /** 29 | * 开关量设备初始化 30 | */ 31 | void DevAdcInit(void); 32 | 33 | #ifdef __cplusplus 34 | } // extern "C" 35 | #endif 36 | 37 | #endif // _KERNEL_DEV_SWITCH_H_ 38 | 39 | -------------------------------------------------------------------------------- /kernel/inc/dev/dev_can.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_can.h 3 | * @brief can设备层 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KERNEL_DEV_CAN_H_ 17 | #define _KERNEL_DEV_CAN_H_ 18 | 19 | #include "ofc_types.h" 20 | #include "ofc_object.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | 27 | /** 28 | * can设备初始化 29 | */ 30 | void DevCanInit(void); 31 | 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | #endif 35 | 36 | #endif // _KERNEL_DEV_CAN_H_ 37 | 38 | -------------------------------------------------------------------------------- /kernel/inc/dev/dev_flash.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_flash.h 3 | * @brief flash设备层 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KERNEL_DEV_FLASH_H_ 17 | #define _KERNEL_DEV_FLASH_H_ 18 | 19 | #include "ofc_types.h" 20 | #include "ofc_object.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | 27 | /** 28 | * flash设备初始化 29 | */ 30 | void DevFlashInit(void); 31 | 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | #endif 35 | 36 | #endif // _KERNEL_DEV_FLASH_H_ 37 | 38 | -------------------------------------------------------------------------------- /kernel/inc/dev/dev_log.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_log.h 3 | * @brief 串口日志层 4 | * @note 5 | * @author zgq 6 | * @date 2020-08-04 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2020-08-04 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KERNEL_DEV_LOG_H_ 17 | #define _KERNEL_DEV_LOG_H_ 18 | 19 | #include "ofc_types.h" 20 | #include "ofc_object.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | 27 | /** 28 | * can设备初始化 29 | */ 30 | void DevLogInit(void); 31 | 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | #endif 35 | 36 | #endif // _KERNEL_DEV_LOG_H_ 37 | 38 | -------------------------------------------------------------------------------- /kernel/inc/dev/dev_pmu.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_pmu.h 3 | * @brief 电源管理设备层 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KERNEL_DEV_PMU_H_ 17 | #define _KERNEL_DEV_PMU_H_ 18 | 19 | #include "ofc_types.h" 20 | #include "ofc_object.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | 27 | /** 28 | * can设备初始化 29 | */ 30 | void DevPmuInit(void); 31 | 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | #endif 35 | 36 | #endif // _KERNEL_DEV_PMU_H_ 37 | 38 | -------------------------------------------------------------------------------- /kernel/inc/dev/dev_power.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_power.h 3 | * @brief 电源控制设备层 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KERNEL_DEV_POWER_H_ 17 | #define _KERNEL_DEV_POWER_H_ 18 | 19 | #include "ofc_types.h" 20 | #include "ofc_object.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | 27 | 28 | /** 29 | * 电源控制设备初始化 30 | */ 31 | void DevPowerInit(void); 32 | 33 | #ifdef __cplusplus 34 | } // extern "C" 35 | #endif 36 | 37 | #endif // _KERNEL_DEV_POWER_H_ 38 | 39 | -------------------------------------------------------------------------------- /kernel/inc/dev/dev_pwm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_pwm.h 3 | * @brief PWM输出设备层 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KERNEL_DEV_PWM_H_ 17 | #define _KERNEL_DEV_PWM_H_ 18 | 19 | #include "ofc_types.h" 20 | #include "ofc_object.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | 27 | 28 | /** 29 | * Pwm输出设备初始化 30 | */ 31 | void DevPwmInit(void); 32 | 33 | #ifdef __cplusplus 34 | } // extern "C" 35 | #endif 36 | 37 | #endif // _KERNEL_DEV_PWM_H_ 38 | 39 | -------------------------------------------------------------------------------- /kernel/inc/dev/dev_rs485.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_rs485.h 3 | * @brief RS485设备 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KERNEL_DEV_RS485_H_ 17 | #define _KERNEL_DEV_RS485_H_ 18 | 19 | #include "ofc_types.h" 20 | #include "ofc_object.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | 27 | /** 28 | * can设备初始化 29 | */ 30 | void DevRs485Init(void); 31 | 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | #endif 35 | 36 | #endif // _KERNEL_DEV_RS485_H_ 37 | 38 | -------------------------------------------------------------------------------- /kernel/inc/dev/dev_switch.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_switch.h 3 | * @brief 开关量设备层 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KERNEL_DEV_SWITCH_H_ 17 | #define _KERNEL_DEV_SWITCH_H_ 18 | 19 | #include "ofc_types.h" 20 | #include "ofc_object.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | 27 | 28 | /** 29 | * 开关量设备初始化 30 | */ 31 | void DevSwitchInit(void); 32 | 33 | #ifdef __cplusplus 34 | } // extern "C" 35 | #endif 36 | 37 | #endif // _KERNEL_DEV_SWITCH_H_ 38 | 39 | -------------------------------------------------------------------------------- /kernel/inc/dev/dev_wdog.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_wdog.h 3 | * @brief 看门狗设备层 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KERNEL_DEV_WDOG_H_ 17 | #define _KERNEL_DEV_WDOG_H_ 18 | 19 | #include "ofc_types.h" 20 | #include "ofc_object.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | 27 | /** 28 | * 看门狗设备初始化 29 | */ 30 | void DevWdogInit(void); 31 | 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | #endif 35 | 36 | #endif // _KERNEL_DEV_WDOG_H_ 37 | 38 | -------------------------------------------------------------------------------- /kernel/inc/mem/memory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file memory.h 3 | * @brief 内存分配 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KERNEL_MEMORY_H_ 17 | #define _KERNEL_MEMORY_H_ 18 | 19 | #include "ofc_types.h" 20 | #include "ofc_object.h" 21 | #include "mfc_memory.h" 22 | #include "mem_config.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /** 29 | * 内存类 30 | * @par 示例 31 | * @code 32 | TMemMemoryCreate(&g_memory); 33 | OfDestroyObject((TOfObject *)&g_memory); 34 | * @endcode 35 | */ 36 | typedef struct TMemMemoryTag TMemMemory; 37 | 38 | struct TMemMemoryTag 39 | { 40 | PROTECTED 41 | TOfObject parent_; ///< 继承的父类 42 | TOfVirtualMethod Destroy_; ///< 析构函数 43 | 44 | PRIVATE 45 | T1KBIndex indexs_[kMemMemory1kCnt]; ///< 索引项的全局占用空间 46 | T1KBItem items_[kMemMemory1kCnt]; ///< 内存项的全局占用空间 47 | TMemBlock block_; ///< 内存块列表 48 | }; 49 | 50 | extern TMemMemory g_memory; ///< 内存单例模式对象 51 | 52 | /** 53 | * 内存类的构造函数 54 | * @param self: 对象实例指针 55 | * @return 56 | */ 57 | void TMemMemoryCreate(TMemMemory *self); 58 | 59 | 60 | #ifdef __cplusplus 61 | } // extern "C" 62 | #endif 63 | 64 | #endif // _KERNEL_MEMORY_H_ 65 | -------------------------------------------------------------------------------- /kernel/inc/rtos/rtx/rtx_inc/rtx_core_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2018 Arm Limited. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ----------------------------------------------------------------------------- 19 | * 20 | * Project: CMSIS-RTOS RTX 21 | * Title: Cortex Core definitions 22 | * 23 | * ----------------------------------------------------------------------------- 24 | */ 25 | 26 | #ifndef RTX_CORE_C_H_ 27 | #define RTX_CORE_C_H_ 28 | 29 | //lint -emacro((923,9078),SCB) "cast from unsigned long to pointer" [MISRA Note 9] 30 | #include "RTE_Components.h" 31 | #include CMSIS_device_header 32 | 33 | #if ((!defined(__ARM_ARCH_6M__)) && \ 34 | (!defined(__ARM_ARCH_7A__)) && \ 35 | (!defined(__ARM_ARCH_7M__)) && \ 36 | (!defined(__ARM_ARCH_7EM__)) && \ 37 | (!defined(__ARM_ARCH_8M_BASE__)) && \ 38 | (!defined(__ARM_ARCH_8M_MAIN__))) 39 | #error "Unknown Arm Architecture!" 40 | #endif 41 | 42 | #if (defined(__ARM_ARCH_7A__) && (__ARM_ARCH_7A__ != 0)) 43 | #include "rtx_core_ca.h" 44 | #else 45 | #include "rtx_core_cm.h" 46 | #endif 47 | 48 | #endif // RTX_CORE_C_H_ 49 | -------------------------------------------------------------------------------- /kernel/inc/rtos/rtx/rtx_include/os_tick.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file os_tick.h 3 | * @brief CMSIS OS Tick header file 4 | * @version V1.0.1 5 | * @date 24. November 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2017 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #ifndef OS_TICK_H 26 | #define OS_TICK_H 27 | 28 | #include 29 | 30 | /// IRQ Handler. 31 | #ifndef IRQHANDLER_T 32 | #define IRQHANDLER_T 33 | typedef void (*IRQHandler_t) (void); 34 | #endif 35 | 36 | /// Setup OS Tick. 37 | /// \param[in] freq tick frequency in Hz 38 | /// \param[in] handler tick IRQ handler 39 | /// \return 0 on success, -1 on error. 40 | int32_t OS_Tick_Setup (uint32_t freq, IRQHandler_t handler); 41 | 42 | /// Enable OS Tick. 43 | void OS_Tick_Enable (void); 44 | 45 | /// Disable OS Tick. 46 | void OS_Tick_Disable (void); 47 | 48 | /// Acknowledge OS Tick IRQ. 49 | void OS_Tick_AcknowledgeIRQ (void); 50 | 51 | /// Get OS Tick IRQ number. 52 | /// \return OS Tick IRQ number. 53 | int32_t OS_Tick_GetIRQn (void); 54 | 55 | /// Get OS Tick clock. 56 | /// \return OS Tick clock in Hz. 57 | uint32_t OS_Tick_GetClock (void); 58 | 59 | /// Get OS Tick interval. 60 | /// \return OS Tick interval. 61 | uint32_t OS_Tick_GetInterval (void); 62 | 63 | /// Get OS Tick count value. 64 | /// \return OS Tick count value. 65 | uint32_t OS_Tick_GetCount (void); 66 | 67 | /// Get OS Tick overflow status. 68 | /// \return OS Tick overflow status (1 - overflow, 0 - no overflow). 69 | uint32_t OS_Tick_GetOverflow (void); 70 | 71 | #endif /* OS_TICK_H */ 72 | -------------------------------------------------------------------------------- /kernel/inc/rtos/rtx/rtx_rte/arm_cm3/RTE_Components.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Auto generated Run-Time-Environment Component Configuration File 4 | * *** Do not modify ! *** 5 | * 6 | * Project: 'MyComponent' 7 | * Target: 'CM3_Simulation' 8 | */ 9 | 10 | #ifndef RTE_COMPONENTS_H 11 | #define RTE_COMPONENTS_H 12 | 13 | 14 | /* 15 | * Define the Device Header File: 16 | */ 17 | #define CMSIS_device_header "ARMCM3.h" 18 | 19 | //#define RTE_CMSIS_RTOS2 /* CMSIS-RTOS2 */ 20 | // #define RTE_CMSIS_RTOS2_RTX5 /* CMSIS-RTOS2 Keil RTX5 */ 21 | //#define RTE_Compiler_EventRecorder 22 | // #define RTE_Compiler_EventRecorder_DAP 23 | 24 | #endif /* RTE_COMPONENTS_H */ 25 | -------------------------------------------------------------------------------- /kernel/inc/rtos/rtx/rtx_rte/arm_cm3/system_ARMCM3.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file system_ARMCM3.h 3 | * @brief CMSIS Device System Header File for 4 | * ARMCM3 Device Series 5 | * @version V5.00 6 | * @date 10. January 2018 7 | ******************************************************************************/ 8 | /* 9 | * Copyright (c) 2009-2018 Arm Limited. All rights reserved. 10 | * 11 | * SPDX-License-Identifier: Apache-2.0 12 | * 13 | * Licensed under the Apache License, Version 2.0 (the License); you may 14 | * not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at 16 | * 17 | * www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 21 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | */ 25 | 26 | #ifndef SYSTEM_ARMCM3_H 27 | #define SYSTEM_ARMCM3_H 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 34 | 35 | 36 | /** 37 | \brief Setup the microcontroller system. 38 | 39 | Initialize the System and update the SystemCoreClock variable. 40 | */ 41 | extern void SystemInit (void); 42 | 43 | 44 | /** 45 | \brief Update SystemCoreClock variable. 46 | 47 | Updates the SystemCoreClock with current core Clock retrieved from cpu registers. 48 | */ 49 | extern void SystemCoreClockUpdate (void); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* SYSTEM_ARMCM3_H */ 56 | -------------------------------------------------------------------------------- /kernel/inc/rtos/rtx/rtx_rte/arm_cm4/ARMCM4.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/inc/rtos/rtx/rtx_rte/arm_cm4/ARMCM4.h -------------------------------------------------------------------------------- /kernel/inc/rtos/rtx/rtx_rte/arm_cm4/RTE_Components.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Auto generated Run-Time-Environment Component Configuration File 4 | * *** Do not modify ! *** 5 | * 6 | * Project: 'MyComponent' 7 | * Target: 'CM3_Simulation' 8 | */ 9 | 10 | #ifndef RTE_COMPONENTS_H 11 | #define RTE_COMPONENTS_H 12 | 13 | 14 | /* 15 | * Define the Device Header File: 16 | */ 17 | #define CMSIS_device_header "ARMCM4.h" 18 | 19 | //#define RTE_CMSIS_RTOS2 /* CMSIS-RTOS2 */ 20 | // #define RTE_CMSIS_RTOS2_RTX5 /* CMSIS-RTOS2 Keil RTX5 */ 21 | //#define RTE_Compiler_EventRecorder 22 | // #define RTE_Compiler_EventRecorder_DAP 23 | 24 | #endif /* RTE_COMPONENTS_H */ 25 | -------------------------------------------------------------------------------- /kernel/inc/rtos/rtx/rtx_rte/arm_cm4/system_ARMCM4.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file system_ARMCM4.h 3 | * @brief CMSIS Device System Header File for 4 | * ARMCM4 Device Series 5 | * @version V5.00 6 | * @date 10. January 2018 7 | ******************************************************************************/ 8 | /* 9 | * Copyright (c) 2009-2018 Arm Limited. All rights reserved. 10 | * 11 | * SPDX-License-Identifier: Apache-2.0 12 | * 13 | * Licensed under the Apache License, Version 2.0 (the License); you may 14 | * not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at 16 | * 17 | * www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 21 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | */ 25 | 26 | #ifndef SYSTEM_ARMCM4_H 27 | #define SYSTEM_ARMCM4_H 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 34 | 35 | 36 | /** 37 | \brief Setup the microcontroller system. 38 | 39 | Initialize the System and update the SystemCoreClock variable. 40 | */ 41 | extern void SystemInit (void); 42 | 43 | 44 | /** 45 | \brief Update SystemCoreClock variable. 46 | 47 | Updates the SystemCoreClock with current core Clock retrieved from cpu registers. 48 | */ 49 | extern void SystemCoreClockUpdate (void); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* SYSTEM_ARMCM4_H */ 56 | -------------------------------------------------------------------------------- /kernel/inc/thread/thread_event.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file thread_event.h 3 | * @brief 定义TThreadEvent类 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KERNEL_THREAD_EVENT_H_ 17 | #define _KERNEL_THREAD_EVENT_H_ 18 | 19 | #include 20 | #include "thread.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /** 27 | * 构造TThreadEvent类 28 | * 线程事件类仅构造时指定的线程可以拥有该对象,并且可调用该对象的所有方法. 29 | * 其它线程和中断中不得调用这些方法,仅TThreadEventSet方法可在其它线程和中断中调用. 30 | * 31 | * 线程事件机制: 32 | * 线程事件相当于线程有一个且仅有一个标记集合(设为F),F包含31个标记(由一个32bit的整型来存放). 33 | * F的每个bit为一个flag,从bit0到bit30,共计31个flag. 34 | * 35 | * 当其它线程或者中断调用TThreadEventSet时,该函数的参数flag用于指示标记集合中的哪个标记被置位. 36 | * flag的取值范围为0到30. 这里的flag实际上为F中的位的索引 37 | * 例如: 38 | * F = 0x00000000 39 | * TThreadEventSet(xx, 0); F: 0x00 -> 0x01 40 | * TThreadEventSet(xx, 1); F: 0x01 -> 0x03 41 | * TThreadEventSet(xx, 4); F: 0x03 -> 0x13 42 | * 43 | * TSfThreadEventWait函数用于等待事件.该函数的flags用于指示需要等待哪些标志置位. 44 | * @par 示例 45 | * @code 46 | Thread A: 47 | TThreadEvent event; 48 | TThreadEventCreate(&event, self); 49 | ... 50 | if (TThreadEventWait(event, 3, False, 100) ... // 等到flag为0或者1的事件产生,最多等到100ms 51 | 52 | Thread B: 53 | TThreadEventSet(&event, 0); // flag 0表示B中设置 54 | 55 | 中断中: 56 | TThreadEventSet(&event, 1); // flag 1表示中断中设置 57 | 58 | OfDestroyObject((TOfObject *)event); 59 | * @endcode 60 | */ 61 | typedef struct TThreadEventTag TThreadEvent; 62 | struct TThreadEventTag 63 | { 64 | PROTECTED 65 | TOfObject parent_; 66 | TOfVirtualMethod Destroy_; 67 | 68 | PRIVATE 69 | DRtosThreadHandle handle_; 70 | }; 71 | 72 | /** 73 | * 线程事件类的构造函数 74 | * @param self: 对象实例指针 75 | * @param thread: 拥有该事件的线程 76 | * @return 77 | */ 78 | void TThreadEventCreate(TThreadEvent *self, TThread *thread); 79 | 80 | /** 81 | * 设置事件标记 82 | * 注: 这个函数可以在任何地方调用,包括在中断中调用 83 | * @param self: 对象实例 84 | * @param flag: 需要设置的事件标记索引.flag的取值范围为: 0-30 85 | * @return 返回true表示设置该标记值时,等待函数正在等这个标记.否则表示等待函数没有在等待该标记 86 | */ 87 | Bool TThreadEventSet(TThreadEvent *self, Int32 flag); 88 | 89 | /** 90 | * 等待flags指定的一个或者多个事件. 91 | * @param self: 对象实例 92 | * @param flags: 需要等待的事件集合,仅bit0-bit30有效,bit31不得设置为1.比如flags=9(=1001B),表示等待flag=0和(或)3的事件 93 | * @param all: 是否需要等到flags指定的所有标记都置位才返回. 94 | * true: 表示flags指定的所有事件都等到才返回; false: 表示只需要等到flags指定的任意一个事件置位就返回 95 | * @param timeout: 等待的时长,单位: ms. 0: 表示不等待,立即返回, -1: 表示永久等待,直到事件产生 96 | * @return 返回true表示等到要求的事件, false表示超时或者出错 97 | */ 98 | Bool TThreadEventWait(TThreadEvent *self, Int32 flags, Bool all, Int32 timeout); 99 | 100 | #ifdef __cplusplus 101 | } // extern "C" 102 | #endif 103 | 104 | #endif // _SFC_THREAD_EVENT_H_ 105 | -------------------------------------------------------------------------------- /kernel/src/cfg/dev_adc_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_adc_cfg.c 3 | * @brief 用于adc设备配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | TDevAdcConfig g_dev_adc_cfg_[] = 17 | { 18 | [0] = {.drv_adc_chn = 0,}, ///< Adc设备-0 19 | [1] = {.drv_adc_chn = 1,}, ///< Adc设备-1 20 | [2] = {.drv_adc_chn = 2,}, ///< Adc设备-2 21 | [3] = {.drv_adc_chn = 3,}, ///< Adc设备-3 22 | [4] = {.drv_adc_chn = 4,}, ///< Adc设备-4 23 | [5] = {.drv_adc_chn = 5,}, ///< Adc设备-5 24 | }; 25 | 26 | -------------------------------------------------------------------------------- /kernel/src/cfg/dev_can_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_can_cfg.c 3 | * @brief 用于can设备配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | TDevCanConfig g_dev_can_cfg_[] = 17 | { 18 | [0] = {.drv_can_chn = 0, .defaut_baud = kCanBaudRate250k}, 19 | [1] = {.drv_can_chn = 1, .defaut_baud = kCanBaudRate250k}, 20 | }; 21 | 22 | TDevPerCanConfig g_dev_per_can_cfg_ = 23 | { 24 | .cs_port = &g_drv_port[kDrvPortNumB], 25 | .cs_pin = 12, 26 | .int_port = kDrvPortNumB, 27 | .int_pin = 11, 28 | .defaut_baud = kCanBaudRate250k, 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /kernel/src/cfg/dev_ext_flash_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_ext_flash_cfg.c 3 | * @brief 用于外部flash设备配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | TDevExtFlashConfig g_dev_ext_flash_cfg_[] = 17 | { 18 | [0] = {.addr = 0x0000, .size = 0x1000}, 19 | [1] = {.addr = 0x1000, .size = 0x1000}, 20 | }; 21 | 22 | TDevPerExtFlashConfig g_dev_per_ext_flash_cfg_ = 23 | { 24 | .cs_port = &g_drv_port[kDrvPortNumA], 25 | .cs_pin = 15, 26 | }; 27 | -------------------------------------------------------------------------------- /kernel/src/cfg/dev_flash_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_flash_cfg.c 3 | * @brief 用于flash设备配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | // /// 页大小 16 | // TDrvFlashPageSize g_flash_page_size[] = 17 | // { 18 | // {0x00000000, 0x4000}, ///< page 0 16K 19 | // {0x00004000, 0x4000}, ///< page 1 16K 20 | // {0x00008000, 0x4000}, ///< page 2 16K 21 | // {0x0000C000, 0x4000}, ///< page 3 16K 22 | // {0x00010000, 0x10000}, ///< page 4 64K 23 | // {0x00020000, 0x20000}, ///< page 5 128K 24 | // {0x00040000, 0x20000}, ///< page 6 128K 25 | // {0x00060000, 0x20000}, ///< page 7 128K 26 | // {0x00080000, 0x20000}, ///< page 8 128K 27 | // {0x000A0000, 0x20000}, ///< page 9 128K 28 | // {0x000C0000, 0x20000}, ///< page 10 128K 29 | // {0x000E0000, 0x20000}, ///< page 11 128K 30 | // }; 31 | 32 | TDevFlashConfig g_dev_flash_cfg_[] = 33 | { 34 | ///[0] = {.addr = 0x00020000, .size = 0x20000}, ///< app区(应用层不准操作) 35 | 36 | [0] = {.addr = 0x00008000, .size = 0x4000}, ///< app升级信息区 37 | [1] = {.addr = 0x00040000, .size = 0x20000}, ///< app备份区 38 | }; 39 | -------------------------------------------------------------------------------- /kernel/src/cfg/dev_init_cfg.c: -------------------------------------------------------------------------------- 1 | #include "dev_pmu.h" 2 | #include "dev_wdog.h" 3 | #include "dev_power.h" 4 | #include "dev_switch.h" 5 | #include "dev_adc.h" 6 | #include "dev_can.h" 7 | #include "dev_flash.h" 8 | #include "dev_log.h" 9 | #include "dev_rs485.h" 10 | #include "dev_pwm.h" 11 | 12 | /* 13 | * 设备初始化函数 14 | */ 15 | void DevInitCfg(void) 16 | { 17 | DevWdogInit(); 18 | DevPowerInit(); 19 | DevSwitchInit(); 20 | DevAdcInit(); 21 | DevFlashInit(); 22 | DevLogInit(); 23 | 24 | DevCanInit(); 25 | DevRs485Init(); 26 | DevPwmInit(); 27 | } 28 | -------------------------------------------------------------------------------- /kernel/src/cfg/dev_power_cfg.c: -------------------------------------------------------------------------------- 1 | #include "dev_can.h" 2 | 3 | TDevPowerConfig g_dev_power_cfg_[] = 4 | { 5 | {&g_drv_port[kDrvPortNumF], 0, False, False, False}, ///< 电源输出-0 6 | {&g_drv_port[kDrvPortNumF], 1, False, False, False}, ///< 电源输出-1 7 | {&g_drv_port[kDrvPortNumE], 11, False, False, False}, ///< 电源输出-2 8 | {&g_drv_port[kDrvPortNumF], 2, False, False, False}, ///< 电源输出-3 9 | {&g_drv_port[kDrvPortNumF], 3, False, False, False}, ///< 电源输出-4 10 | {&g_drv_port[kDrvPortNumD], 2, False, False, False}, ///< 电源输出-5 11 | 12 | }; 13 | 14 | 15 | -------------------------------------------------------------------------------- /kernel/src/cfg/dev_pwm_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_pwm_cfg.c 3 | * @brief 用于PWM设备配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | TDevPwmConfig g_dev_pwm_cfg_[] = 17 | { 18 | {0}, 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /kernel/src/cfg/dev_rs485_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_rs485_cfg.c 3 | * @brief 用于485设备配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | TDevRs485Config g_dev_rs485_cfg_[] = 17 | { 18 | [0] = {.drv_uart_chn = 2, .baud_default = 9600,}, 19 | [1] = {.drv_uart_chn = 3, .baud_default = 9600,}, 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /kernel/src/cfg/dev_switch_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dev_switch_cfg.c 3 | * @brief 用于开关量设备配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | TDevSwitchConfig g_dev_switch_cfg_[] = 17 | { 18 | {&g_drv_port[kDrvPortNumD], 5, kPortPullDisabled, False}, ///< 开关量设备-0 19 | {&g_drv_port[kDrvPortNumD], 4, kPortPullDisabled, False}, ///< 开关量设备-1 20 | {&g_drv_port[kDrvPortNumD], 7, kPortPullDisabled, False}, ///< 开关量设备-2 21 | {&g_drv_port[kDrvPortNumD], 6, kPortPullDisabled, False}, ///< 开关量设备-3 22 | {&g_drv_port[kDrvPortNumG], 10, kPortPullDisabled, False}, ///< 开关量设备-4 23 | {&g_drv_port[kDrvPortNumG], 9, kPortPullDisabled, False}, ///< 开关量设备-5 24 | }; 25 | -------------------------------------------------------------------------------- /kernel/src/cfg/per_ext_flash_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file per_ext_flash_cfg.c 3 | * @brief 用于外部flash设备配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | TPerExtFlashConfig g_per_ext_flash_cfg_ = 17 | { 18 | .drv_spi_chn = 0, 19 | .cs_port = &g_drv_port[kDrvPortNumA], 20 | .cs_pin = 15, 21 | }; 22 | -------------------------------------------------------------------------------- /kernel/src/dev/dev_log.c: -------------------------------------------------------------------------------- 1 | #include "dev_log.h" 2 | #include "vfs.h" 3 | #include "drv_uart.h" 4 | #include "kfc_system.h" 5 | 6 | /** 7 | * 设备基础对象 8 | */ 9 | typedef struct TDevLogTag TDevLog; 10 | struct TDevLogTag 11 | { 12 | TVfsDevBase parent_; ///< 继承的父类 13 | TOfVirtualMethod Destroy_; ///< 析构函数 14 | 15 | TDrvUart drv_uart_; ///< 驱动设备 16 | UInt8 rx_buffer_[100]; ///< 读取缓存 17 | PUBLIC 18 | }; 19 | 20 | static TDevLog g_dev_log_; ///< can0设备 21 | 22 | /** 23 | * 析构函数 24 | * @param object: 对象实例 25 | * @return 空 26 | */ 27 | static void TDevLogDestroy(TOfObject *object) 28 | { 29 | TDevLog *self = (TDevLog *)object; 30 | self->Destroy_(object); 31 | } 32 | 33 | static void TDevLogCreate(TDevLog *self) 34 | { 35 | TVfsDevBaseCreate((TVfsDevBase *)self); 36 | OVERRIDE_METHOD(TOfObject, Destroy, TDevLogDestroy); 37 | 38 | TDrvUartCreate(&self->drv_uart_, 0, self->rx_buffer_, sizeof(self->rx_buffer_), kDrvUartMode232); 39 | } 40 | /** 41 | * 开启设备 42 | * @param dev: 父类对象 43 | * @param sub_id: 子设备号 44 | * @return True:成功 False:失败 45 | */ 46 | static Bool TDevLogOpen(TVfsDevBase *dev, UInt8 sub_id) 47 | { 48 | TDevLog *self = (TDevLog *)dev; 49 | TDrvUartOpen(&self->drv_uart_, 115200, kDrvUartParityNone); 50 | return True; 51 | } 52 | /** 53 | * 关闭设备 54 | * @param dev: 父类对象 55 | * @param sub_id: 子设备号 56 | * @return True:成功 False:失败 57 | */ 58 | static Bool TDevLogClose(TVfsDevBase *dev, UInt8 sub_id) 59 | { 60 | TDevLog *self = (TDevLog *)dev; 61 | TDrvUartClose(&self->drv_uart_); 62 | return True; 63 | } 64 | /** 65 | * 读取设备 66 | * @param dev: 父类对象 67 | * @param sub_id: 子设备号 68 | * @param buf: 缓冲区 69 | * @param len: 缓冲区长度 70 | * @return >0 :成功读取到的数据长度 71 | */ 72 | Int32 TDevLogRead(TVfsDevBase *dev, UInt8 sub_id, void *buf, Int32 size) 73 | { 74 | TDevLog *self = (TDevLog *)dev; 75 | return TDrvUartRead(&self->drv_uart_, buf, size); 76 | } 77 | /** 78 | * 写入设备 79 | * @param dev: 父类对象 80 | * @param sub_id: 子设备号 81 | * @param buf: 缓冲区 82 | * @param len: 缓冲区长度 83 | * @return >0 :写入成功到的数据长度 84 | */ 85 | static Int32 TDevLogWrite(TVfsDevBase *dev, UInt8 sub_id, void *data, Int32 len) 86 | { 87 | Int32 result = 0; 88 | TDevLog *self = (TDevLog *)dev; 89 | result = TDrvUartWrite(&self->drv_uart_, data, len); 90 | KfcDelayMs(2); 91 | return result; 92 | } 93 | 94 | void DevLogInit(void) 95 | { 96 | TDevLogCreate(&g_dev_log_); 97 | g_dev_log_.parent_.open_ = TDevLogOpen; 98 | g_dev_log_.parent_.close_ = TDevLogClose; 99 | g_dev_log_.parent_.read_ = TDevLogRead; 100 | g_dev_log_.parent_.write_ = TDevLogWrite; 101 | TVfsDevMgrRegister(&g_dev_mgr, (kSfDevNumLog >> 8), (TVfsDevBase*)&g_dev_log_); 102 | } 103 | -------------------------------------------------------------------------------- /kernel/src/dev/dev_pmu.c: -------------------------------------------------------------------------------- 1 | #include "dev_pmu.h" 2 | #include "vfs.h" 3 | #include "drv_port.h" 4 | #include "drv_dma.h" 5 | /** 6 | * 设备基础对象 7 | */ 8 | typedef struct TDevPmuTag TDevPmu; 9 | struct TDevPmuTag 10 | { 11 | TVfsDevBase parent_; ///< 继承的父类 12 | TOfVirtualMethod Destroy_; ///< 析构函数 13 | 14 | PUBLIC 15 | }; 16 | 17 | 18 | static TDevPmu g_dev_pmu_; ///< Pmu0设备 19 | 20 | /** 21 | * 析构函数 22 | * @param object: 对象实例 23 | * @return 空 24 | */ 25 | static void TDevPmuDestroy(TOfObject *object) 26 | { 27 | TDevPmu *self = (TDevPmu *)object; 28 | self->Destroy_(object); 29 | } 30 | 31 | static void TDevPmuCreate(TDevPmu *self) 32 | { 33 | TVfsDevBaseCreate((TVfsDevBase *)self); 34 | OVERRIDE_METHOD(TOfObject, Destroy, TDevPmuDestroy); 35 | 36 | } 37 | 38 | static Bool TDevPmuOpen(TVfsDevBase *dev, UInt8 sub_id) 39 | { 40 | Bool result = False; 41 | //TDevPmu *self = (TDevPmu *)dev; 42 | 43 | return result; 44 | } 45 | 46 | void DevPmuInit(void) 47 | { 48 | UInt32 i; 49 | for (i = kDrvPortNumA; i < kDrvPortNumMax; i++) 50 | { 51 | TDrvPortCreate(&g_drv_port[i]); 52 | } 53 | 54 | /// 打开DMA 55 | TDrvDmaCreate(&g_drv_dma[0], 0); 56 | TDrvDmaCreate(&g_drv_dma[1], 1); 57 | TDrvDmaOpen(&g_drv_dma[0]); 58 | TDrvDmaOpen(&g_drv_dma[1]); 59 | 60 | TDevPmuCreate(&g_dev_pmu_); 61 | 62 | g_dev_pmu_.parent_.open_ = TDevPmuOpen; 63 | TVfsDevMgrRegister(&g_dev_mgr, (kSfDevNumPower >> 8), (TVfsDevBase*)&g_dev_pmu_); 64 | } 65 | -------------------------------------------------------------------------------- /kernel/src/dev/dev_wdog.c: -------------------------------------------------------------------------------- 1 | #include "dev_wdog.h" 2 | #include "vfs.h" 3 | #include "drv_wdog.h" 4 | /** 5 | * 设备基础对象 6 | */ 7 | typedef struct TDevWdogTag TDevWdog; 8 | struct TDevWdogTag 9 | { 10 | TVfsDevBase parent_; ///< 继承的父类 11 | TOfVirtualMethod Destroy_; ///< 析构函数 12 | 13 | PUBLIC 14 | }; 15 | 16 | 17 | static TDevWdog g_dev_wdog_; ///< 看门狗设备 18 | 19 | /** 20 | * 析构函数 21 | * @param object: 对象实例 22 | * @return 空 23 | */ 24 | static void TDevWdogDestroy(TOfObject *object) 25 | { 26 | TDevWdog *self = (TDevWdog *)object; 27 | self->Destroy_(object); 28 | } 29 | 30 | static void TDevWdogCreate(TDevWdog *self) 31 | { 32 | TVfsDevBaseCreate((TVfsDevBase *)self); 33 | OVERRIDE_METHOD(TOfObject, Destroy, TDevWdogDestroy); 34 | 35 | TDrvWdogCreate(&g_drv_wdog); 36 | } 37 | /** 38 | * 打开设备 39 | * @param dev: 父类对象 40 | * @param sub_id: 子设备号 41 | * @return True:成功 False:失败 42 | */ 43 | static Bool TDevWdogOpen(TVfsDevBase *dev, UInt8 sub_id) 44 | { 45 | TDrvWdogOpen(&g_drv_wdog); 46 | return True; 47 | } 48 | /** 49 | * 写入设备 50 | * @param dev: 父类对象 51 | * @param sub_id: 子设备号 52 | * @param buf: 缓冲区 53 | * @param len: 缓冲区长度 54 | * @return >0 :写入成功到的数据长度 55 | */ 56 | static Int32 TDevWdogWrite(TVfsDevBase *dev, UInt8 sub_id, void *buf, Int32 len) 57 | { 58 | TDrvWdogFeedDog(&g_drv_wdog); 59 | return 0; 60 | } 61 | 62 | void DevWdogInit(void) 63 | { 64 | TDevWdogCreate(&g_dev_wdog_); 65 | 66 | g_dev_wdog_.parent_.open_ = TDevWdogOpen; 67 | g_dev_wdog_.parent_.write_ = TDevWdogWrite; 68 | 69 | TVfsDevMgrRegister(&g_dev_mgr, (kSfDevNumWdog >> 8), (TVfsDevBase*)&g_dev_wdog_); 70 | 71 | } 72 | -------------------------------------------------------------------------------- /kernel/src/kernel_init.c: -------------------------------------------------------------------------------- 1 | #include "kernel_init.h" 2 | #include "rtos_api.h" 3 | #include "memory.h" 4 | #include "vfs.h" 5 | #include "srt.h" 6 | #include "drv_clock.h" 7 | #include "drv_int.h" 8 | #include "dev_init_cfg.c" 9 | #include "drv_ext_int.h" 10 | #include "kfc_timer.h" 11 | #include "drv_flash.h" 12 | #include "kfc_file.h" 13 | #include "drv_usb_master.h" 14 | #include "diskio.h" 15 | 16 | 17 | void KernelInit(void) 18 | { 19 | TDrvClockCreate(&g_drv_clock); 20 | TDrvClockInitClock(&g_drv_clock); 21 | SysIRQInit(); 22 | /// 内核初始化 23 | RtosKernelInit(); 24 | /// 内存管理初始化 25 | TMemMemoryCreate(&g_memory); 26 | /// 设备管理器初始化 27 | TVfsDevMgrCreate(&g_dev_mgr); 28 | /// 电源设备初始化(初始化GPIO) 29 | DevPmuInit(); 30 | /// 定时器打开 31 | TKfcTimerSrvCreate(&g_kfc_timer_srv); 32 | 33 | disk_create(kDiskTypeExtFlash); 34 | disk_create(kDiskTypeUsb); 35 | 36 | /// 文件系统初始化 37 | if (KfcFileMount(kKfcFileDiskTypeExtFlash) == kKfcFileResultNoFilesystem) 38 | { 39 | KfcFileMkfs(kKfcFileDiskTypeExtFlash); 40 | KfcFileMount(kKfcFileDiskTypeExtFlash); 41 | } 42 | /// srt配置表创建 43 | TSrtCreate(&g_srt); 44 | 45 | /// 驱动设备加载初始化(dev_init.c里) 46 | DevInitCfg(); 47 | 48 | } 49 | 50 | Bool KernelStart(void) 51 | { 52 | Bool result = False; 53 | if (RtosKernelReady()) 54 | { 55 | TKfcTimerSrvOpen(&g_kfc_timer_srv); ///< 定时器打开 56 | 57 | result = RtosKernelStart(); 58 | } 59 | return result; 60 | } 61 | 62 | void KernelRunOnce(void) 63 | { 64 | disk_run_once(kDiskTypeExtFlash); 65 | disk_run_once(kKfcFileDiskTypeUsb); 66 | } 67 | 68 | -------------------------------------------------------------------------------- /kernel/src/kfc/kfc_dev.c: -------------------------------------------------------------------------------- 1 | #include "kfc_dev.h" 2 | #include "vfs.h" 3 | 4 | 5 | Bool KfcDevOpen(UInt16 dev_num) 6 | { 7 | return TVfsDevMgrOpenDev(&g_dev_mgr, (dev_num >> 8), (dev_num & 0xff)); 8 | } 9 | 10 | Bool KfcDevClose(UInt16 dev_num) 11 | { 12 | return TVfsDevMgrCloseDev(&g_dev_mgr, (dev_num >> 8), (dev_num & 0xff)); 13 | } 14 | 15 | Bool KfcDevIoctl(UInt16 dev_num, UInt32 cmd, void *argv) 16 | { 17 | return TVfsDevMgrIoctlDev(&g_dev_mgr, (dev_num >> 8), (dev_num & 0xff), cmd, argv); 18 | } 19 | 20 | Int32 KfcDevRead(UInt16 dev_num, void *buf, UInt32 len) 21 | { 22 | return TVfsDevMgrReadDev(&g_dev_mgr, (dev_num >> 8), (dev_num & 0xff), buf, len); 23 | } 24 | 25 | 26 | Int32 KfcDevWrite(UInt16 dev_num, void *buf, UInt32 len) 27 | { 28 | return TVfsDevMgrWriteDev(&g_dev_mgr, (dev_num >> 8), (dev_num & 0xff), buf, len); 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /kernel/src/kfc/kfc_event.c: -------------------------------------------------------------------------------- 1 | #include "kfc_event.h" 2 | #include "rtos_api.h" 3 | 4 | 5 | static void TSfEventDestroy(TOfObject *sender) 6 | { 7 | TKfcEvent *self = (TKfcEvent *)sender; 8 | RtosEventFlagsDestroy((DRtosEventFlagsHandle)self->handle_); 9 | self->Destroy_(sender); 10 | } 11 | 12 | void TKfcEventCreate(TKfcEvent *self) 13 | { 14 | TOfObjectCreate((TOfObject *)self); 15 | OVERRIDE_METHOD(TOfObject, Destroy, TSfEventDestroy); 16 | 17 | self->handle_ = RtosEventFlagsCreate(); 18 | } 19 | 20 | Bool TKfcEventSetFlag(TKfcEvent *self, Int32 flag_bit_index ) 21 | { 22 | Int32 flags = 1 << flag_bit_index; 23 | Int32 r = RtosEventFlagsSet((DRtosEventFlagsHandle)self->handle_, flags); 24 | 25 | return r >= 0 ? (r & flags) == 0 : False; 26 | } 27 | 28 | Bool TKfcEventSetFlags(TKfcEvent *self, UInt32 flags) 29 | { 30 | Int32 r = RtosEventFlagsSet((DRtosEventFlagsHandle)self->handle_, flags); 31 | 32 | return r >= 0 ? ((UInt32)r & flags) == 0 : False; 33 | } 34 | 35 | Int32 TKfcEventWait(TKfcEvent *self, Int32 flags, Bool all, Int32 timeout) 36 | { 37 | return (Int32)RtosEventFlagsWait((DRtosEventFlagsHandle)self->handle_, flags, all ? kRtosEventFlagsOptionsWaitAll : kRtosEventFlagsOptionsWaitAny, timeout); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /kernel/src/kfc/kfc_memory.c: -------------------------------------------------------------------------------- 1 | #include "kfc_memory.h" 2 | void *KfcMalloc(Int32 size) 3 | { 4 | return OfMalloc(size); 5 | } 6 | 7 | void KfcFree(void *ptr) 8 | { 9 | OfFree(ptr); 10 | } 11 | 12 | 13 | -------------------------------------------------------------------------------- /kernel/src/kfc/kfc_mutex.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "rtos_api.h" 3 | 4 | static void TKfcMutexDestroy(TOfObject *sender) 5 | { 6 | TKfcMutex *self = (TKfcMutex *)sender; 7 | RtosMutexDestory((DRtosMutexHandle)self->handle_); 8 | self->Destroy_(sender); 9 | } 10 | 11 | Bool TKfcMutexCreate(TKfcMutex *self) 12 | { 13 | TOfObjectCreate((TOfObject *)self); 14 | OVERRIDE_METHOD(TOfObject, Destroy, TKfcMutexDestroy); 15 | 16 | self->handle_ = RtosMutexCreate(); 17 | 18 | return self->handle_ != NULL; 19 | } 20 | 21 | Bool TKfcMutexLock(TKfcMutex *self, Int32 timeout) 22 | { 23 | return RtosMutexLock((DRtosMutexHandle)self->handle_, timeout); 24 | } 25 | 26 | void TKfcMutexUnlock(TKfcMutex *self) 27 | { 28 | RtosMutexUnlock((DRtosMutexHandle)self->handle_); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /kernel/src/kfc/kfc_srt.c: -------------------------------------------------------------------------------- 1 | #include "kfc_srt.h" 2 | #include "srt.h" 3 | 4 | ///-----------------------plm掉电不存储接口------------------------/// 5 | 6 | Bool KfcSrtPlmSetBit(UInt32 addr, UInt32 bit, Bool value) 7 | { 8 | return TSrtPlmSetBit(&g_srt, addr, bit, value); 9 | } 10 | 11 | Bool KfcSrtPlmSetU08(UInt32 addr, UInt8 value) 12 | { 13 | return TSrtPlmSetU08(&g_srt, addr, value); 14 | } 15 | 16 | Bool KfcSrtPlmSetU16(UInt32 addr, UInt16 value) 17 | { 18 | return TSrtPlmSetU16(&g_srt, addr, value); 19 | } 20 | 21 | Bool KfcSrtPlmSetU32(UInt32 addr, UInt32 value) 22 | { 23 | return TSrtPlmSetU32(&g_srt, addr, value); 24 | } 25 | 26 | Bool KfcSrtPlmSetMem(UInt32 addr, UInt8 *data, UInt32 len) 27 | { 28 | return TSrtPlmSetMem(&g_srt, addr, data, len); 29 | } 30 | 31 | 32 | Bool KfcSrtPlmGetBit(UInt32 addr, UInt32 bit, Bool* value) 33 | { 34 | return TSrtPlmGetBit(&g_srt, addr, bit, value); 35 | } 36 | 37 | Bool KfcSrtPlmGetU08(UInt32 addr, UInt8* value) 38 | { 39 | return TSrtPlmGetU08(&g_srt, addr, value); 40 | } 41 | 42 | Bool KfcSrtPlmGetU16(UInt32 addr, UInt16* value) 43 | { 44 | return TSrtPlmGetU16(&g_srt, addr, value); 45 | } 46 | 47 | Bool KfcSrtPlmGetU32(UInt32 addr, UInt32* value) 48 | { 49 | return TSrtPlmGetU32(&g_srt, addr, value); 50 | } 51 | 52 | UInt32 KfcSrtPlmGetMem(UInt32 addr, UInt8 *buffer, UInt32 size) 53 | { 54 | return TSrtPlmGetMem(&g_srt, addr, buffer, size); 55 | } 56 | 57 | 58 | 59 | ///-----------------------phm掉电存储接口------------------------/// 60 | 61 | Bool KfcSrtPhmSetBit(UInt32 addr, UInt32 bit, Bool value) 62 | { 63 | return TSrtPhmSetBit(&g_srt, addr, bit, value); 64 | } 65 | 66 | Bool KfcSrtPhmSetU08(UInt32 addr, UInt8 value) 67 | { 68 | return TSrtPhmSetU08(&g_srt, addr, value); 69 | } 70 | 71 | Bool KfcSrtPhmSetU16(UInt32 addr, UInt16 value) 72 | { 73 | return TSrtPhmSetU16(&g_srt, addr, value); 74 | } 75 | Bool KfcSrtPhmSetU32(UInt32 addr, UInt32 value) 76 | { 77 | return TSrtPhmSetU32(&g_srt, addr, value); 78 | } 79 | Bool KfcSrtPhmSetMem(UInt32 addr, UInt8 *data, UInt32 len) 80 | { 81 | return TSrtPhmSetMem(&g_srt, addr, data, len); 82 | } 83 | 84 | 85 | Bool KfcSrtPhmGetBit(UInt32 addr, UInt32 bit, Bool* value) 86 | { 87 | return TSrtPhmGetBit(&g_srt, addr, bit, value); 88 | } 89 | 90 | Bool KfcSrtPhmGetU08(UInt32 addr, UInt8* value) 91 | { 92 | return TSrtPhmGetU08(&g_srt, addr, value); 93 | } 94 | 95 | Bool KfcSrtPhmGetU16(UInt32 addr, UInt16* value) 96 | { 97 | return TSrtPhmGetU16(&g_srt, addr, value); 98 | } 99 | 100 | Bool KfcSrtPhmGetU32(UInt32 addr, UInt32* value) 101 | { 102 | return TSrtPhmGetU32(&g_srt, addr, value); 103 | } 104 | 105 | UInt32 KfcSrtPhmGetMem(UInt32 addr, UInt8 *buffer, UInt32 size) 106 | { 107 | return TSrtPhmGetMem(&g_srt, addr, buffer, size); 108 | } 109 | 110 | 111 | -------------------------------------------------------------------------------- /kernel/src/kfc/kfc_system.c: -------------------------------------------------------------------------------- 1 | #include "kfc_system.h" 2 | #include "drv_clock.h" 3 | #include "rtos_api.h" 4 | 5 | void KfcSleep(UInt32 ms) 6 | { 7 | RtosSleep(ms); 8 | } 9 | 10 | UInt32 KfcGetTickCount(void) 11 | { 12 | return RtosGetTickCount(); 13 | } 14 | 15 | void KfcDelayUs(UInt32 us) 16 | { 17 | TDrvClockDelayUs(&g_drv_clock, us); 18 | } 19 | 20 | void KfcDelayMs(UInt32 ms) 21 | { 22 | TDrvClockDelayMs(&g_drv_clock, ms); 23 | } -------------------------------------------------------------------------------- /kernel/src/mem/memory.c: -------------------------------------------------------------------------------- 1 | #include "memory.h" 2 | #include "cmsis_compiler.h" 3 | 4 | TMemMemory g_memory; ///< 内存单例模式对象 5 | 6 | /** 7 | * ofc_object.c中需要用到 8 | * @param 9 | * @return 10 | */ 11 | void *OfMalloc(Int32 size) 12 | { 13 | return Malloc(size); 14 | } 15 | 16 | /** 17 | * ofc_object.c中需要用到 18 | * @param 19 | * @return 20 | */ 21 | void OfFree(void *ptr) 22 | { 23 | Free(ptr); 24 | } 25 | 26 | /** 27 | * 内存管理的全局加锁 28 | * @note 静态方法 29 | * @param object: 对象实例 30 | * @return 31 | */ 32 | static void TMemoryLock(void) 33 | { 34 | /// 关闭总中断 35 | __disable_irq(); 36 | } 37 | 38 | /** 39 | * 内存管理的全局解锁 40 | * @note 静态方法 41 | * @param object: 对象实例 42 | * @return 43 | */ 44 | static void TMemoryUnlock(void) 45 | { 46 | /// 开启总中断 47 | __enable_irq(); 48 | } 49 | 50 | /** 51 | * 类的析构函数 52 | * @param object: 对象实例 53 | * @return 54 | */ 55 | static void TMemMemoryDestroy(TOfObject *object) 56 | { 57 | TMemMemory *self = (TMemMemory *)object; 58 | 59 | ///< 释放内存管理 60 | KYMemory_Fini(); 61 | 62 | self->Destroy_(object); 63 | } 64 | 65 | void TMemMemoryCreate(TMemMemory *self) 66 | { 67 | /// 构建基类 68 | TOfObjectCreate((TOfObject *)self); 69 | OVERRIDE_METHOD(TOfObject, Destroy, TMemMemoryDestroy); 70 | 71 | /// 初始化内存管理 72 | self->block_.Items = self->items_; 73 | self->block_.Indexs = self->indexs_; 74 | self->block_.Count = sizeof(self->indexs_) / sizeof(self->indexs_[0]); 75 | KYMemory_Init(TMemoryLock, TMemoryUnlock, NULL, NULL, &self->block_, sizeof(self->block_)/sizeof(self->block_)); 76 | } 77 | -------------------------------------------------------------------------------- /kernel/src/mem/memory.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/mem/memory.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/cmsis_version5.3.0.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/cmsis_version5.3.0.txt -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_config/RTX_Config.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2018 Arm Limited. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ----------------------------------------------------------------------------- 19 | * 20 | * $Revision: V5.1.0 21 | * 22 | * Project: CMSIS-RTOS RTX 23 | * Title: RTX Configuration 24 | * 25 | * ----------------------------------------------------------------------------- 26 | */ 27 | 28 | #include "cmsis_compiler.h" 29 | #include "rtx_os.h" 30 | 31 | // OS Idle Thread 32 | __WEAK __NO_RETURN void osRtxIdleThread (void *argument) { 33 | (void)argument; 34 | 35 | for (;;) {} 36 | } 37 | 38 | // OS Error Callback function 39 | __WEAK uint32_t osRtxErrorNotify (uint32_t code, void *object_id) { 40 | (void)object_id; 41 | 42 | switch (code) { 43 | case osRtxErrorStackUnderflow: 44 | // Stack overflow detected for thread (thread_id=object_id) 45 | break; 46 | case osRtxErrorISRQueueOverflow: 47 | // ISR Queue overflow detected when inserting object (object_id) 48 | break; 49 | case osRtxErrorTimerQueueOverflow: 50 | // User Timer Callback Queue overflow detected for timer (timer_id=object_id) 51 | break; 52 | case osRtxErrorClibSpace: 53 | // Standard C/C++ library libspace not available: increase OS_THREAD_LIBSPACE_NUM 54 | break; 55 | case osRtxErrorClibMutex: 56 | // Standard C/C++ library mutex initialization failed 57 | break; 58 | default: 59 | // Reserved 60 | break; 61 | } 62 | for (;;) {} 63 | //return 0U; 64 | } 65 | -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_config/RTX_Config.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_config/RTX_Config.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_core/ARM/irq_armv8mbl_ns.s: -------------------------------------------------------------------------------- 1 | DOMAIN_NS EQU 1 2 | INCLUDE irq_armv8mbl.s 3 | END 4 | -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_core/ARM/irq_armv8mml_ns.s: -------------------------------------------------------------------------------- 1 | DOMAIN_NS EQU 1 2 | INCLUDE irq_armv8mml.s 3 | END 4 | -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_core/GCC/irq_armv8mbl_ns.S: -------------------------------------------------------------------------------- 1 | .equ DOMAIN_NS, 1 2 | .include "../Source/GCC/irq_armv8mbl.S" 3 | .end 4 | -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_core/GCC/irq_armv8mml_fp.S: -------------------------------------------------------------------------------- 1 | .equ __FPU_USED, 1 2 | .include "../Source/GCC/irq_armv8mml.S" 3 | .end 4 | -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_core/GCC/irq_armv8mml_fp_ns.S: -------------------------------------------------------------------------------- 1 | .equ __FPU_USED, 1 2 | .equ DOMAIN_NS, 1 3 | .include "../Source/GCC/irq_armv8mml.S" 4 | .end 5 | -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_core/GCC/irq_armv8mml_ns.S: -------------------------------------------------------------------------------- 1 | .equ DOMAIN_NS, 1 2 | .include "../Source/GCC/irq_armv8mml.S" 3 | .end 4 | -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_core/GCC/irq_cm4f.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_core/GCC/irq_cm4f.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_core/IAR/irq_armv8mbl.s: -------------------------------------------------------------------------------- 1 | NAME irq_armv8mbl.s 2 | #define DOMAIN_NS 0 3 | INCLUDE irq_armv8mbl_common.s 4 | END 5 | -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_core/IAR/irq_armv8mbl_ns.s: -------------------------------------------------------------------------------- 1 | NAME irq_armv8mbl_ns.s 2 | #define DOMAIN_NS 1 3 | INCLUDE irq_armv8mbl_common.s 4 | END 5 | -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_core/IAR/irq_armv8mml.s: -------------------------------------------------------------------------------- 1 | NAME irq_armv8mml.s 2 | #define DOMAIN_NS 0 3 | INCLUDE irq_armv8mml_common.s 4 | END 5 | -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_core/IAR/irq_armv8mml_ns.s: -------------------------------------------------------------------------------- 1 | NAME irq_armv8mml_ns.s 2 | #define DOMAIN_NS 1 3 | INCLUDE irq_armv8mml_common.s 4 | END 5 | -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_source/os_systick.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_source/os_systick.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_source/rtx_delay.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2018 Arm Limited. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ----------------------------------------------------------------------------- 19 | * 20 | * Project: CMSIS-RTOS RTX 21 | * Title: Delay functions 22 | * 23 | * ----------------------------------------------------------------------------- 24 | */ 25 | 26 | #include "rtx_lib.h" 27 | 28 | 29 | // ==== Service Calls ==== 30 | 31 | /// Wait for Timeout (Time Delay). 32 | /// \note API identical to osDelay 33 | static osStatus_t svcRtxDelay (uint32_t ticks) { 34 | 35 | if (ticks != 0U) { 36 | if (!osRtxThreadWaitEnter(osRtxThreadWaitingDelay, ticks)) { 37 | EvrRtxThreadDelayCompleted(); 38 | } 39 | } 40 | 41 | return osOK; 42 | } 43 | 44 | /// Wait until specified time. 45 | /// \note API identical to osDelayUntil 46 | static osStatus_t svcRtxDelayUntil (uint32_t ticks) { 47 | 48 | ticks -= osRtxInfo.kernel.tick; 49 | if (ticks == 0xFFFFFFFFU) { 50 | EvrRtxThreadError(NULL, (int32_t)osErrorParameter); 51 | //lint -e{904} "Return statement before end of function" [MISRA Note 1] 52 | return osErrorParameter; 53 | } 54 | 55 | if (ticks != 0U) { 56 | if (!osRtxThreadWaitEnter(osRtxThreadWaitingDelay, ticks)) { 57 | EvrRtxThreadDelayCompleted(); 58 | } 59 | } 60 | 61 | return osOK; 62 | } 63 | 64 | // Service Calls definitions 65 | //lint ++flb "Library Begin" [MISRA Note 11] 66 | SVC0_1(Delay, osStatus_t, uint32_t) 67 | SVC0_1(DelayUntil, osStatus_t, uint32_t) 68 | //lint --flb "Library End" 69 | 70 | 71 | // ==== Public API ==== 72 | 73 | /// Wait for Timeout (Time Delay). 74 | osStatus_t osDelay (uint32_t ticks) { 75 | osStatus_t status; 76 | 77 | EvrRtxThreadDelay(ticks); 78 | if (IsIrqMode() || IsIrqMasked()) { 79 | EvrRtxThreadError(NULL, (int32_t)osErrorISR); 80 | status = osErrorISR; 81 | } else { 82 | status = __svcDelay(ticks); 83 | } 84 | return status; 85 | } 86 | 87 | /// Wait until specified time. 88 | osStatus_t osDelayUntil (uint32_t ticks) { 89 | osStatus_t status; 90 | 91 | EvrRtxThreadDelayUntil(ticks); 92 | if (IsIrqMode() || IsIrqMasked()) { 93 | EvrRtxThreadError(NULL, (int32_t)osErrorISR); 94 | status = osErrorISR; 95 | } else { 96 | status = __svcDelayUntil(ticks); 97 | } 98 | return status; 99 | } 100 | -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_source/rtx_delay.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_source/rtx_delay.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_source/rtx_evflags.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_source/rtx_evflags.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_source/rtx_evr.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_source/rtx_evr.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_source/rtx_kernel.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_source/rtx_kernel.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_source/rtx_lib.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_source/rtx_lib.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_source/rtx_memory.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_source/rtx_memory.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_source/rtx_mempool.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_source/rtx_mempool.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_source/rtx_msgqueue.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_source/rtx_msgqueue.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_source/rtx_mutex.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_source/rtx_mutex.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_source/rtx_semaphore.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_source/rtx_semaphore.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_source/rtx_system.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_source/rtx_system.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_source/rtx_thread.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_source/rtx_thread.o -------------------------------------------------------------------------------- /kernel/src/rtos/rtx/rtx_source/rtx_timer.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/rtos/rtx/rtx_source/rtx_timer.o -------------------------------------------------------------------------------- /kernel/src/srt/srt.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/srt/srt.o -------------------------------------------------------------------------------- /kernel/src/thread/thread_event.c: -------------------------------------------------------------------------------- 1 | #include "thread_event.h" 2 | 3 | static void TThreadEventDestroy(TOfObject *sender) 4 | { 5 | TThreadEvent *self = (TThreadEvent *)sender; 6 | self->Destroy_(sender); 7 | } 8 | 9 | void TSfThreadEventCreate( TThreadEvent *self, TThread *thread ) 10 | { 11 | TOfObjectCreate((TOfObject *)self); 12 | OVERRIDE_METHOD(TOfObject, Destroy, TThreadEventDestroy); 13 | 14 | self->handle_ = TThreadHandle(thread); 15 | } 16 | 17 | Bool TThreadEventSet(TThreadEvent *self, Int32 flag) 18 | { 19 | Int32 flags = 1 << flag; 20 | Int32 r = RtosThreadFlagsSet(self->handle_, flags); 21 | 22 | return r >= 0 ? (r & flags) == 0 : False; 23 | } 24 | 25 | Bool TThreadEventWait(TThreadEvent *self, Int32 flags, Bool all, Int32 timeout) 26 | { 27 | return (Int32)RtosThreadFlagsWait(flags, all ? kRtosEventFlagsOptionsWaitAll : kRtosEventFlagsOptionsWaitAny, timeout) > 0; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /kernel/src/vfs/vfs.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/kernel/src/vfs/vfs.o -------------------------------------------------------------------------------- /lib/src/ofc/ofc_object.c: -------------------------------------------------------------------------------- 1 | #include "ofc_object.h" 2 | 3 | static void TOfObjectDestroy(TOfObject *self) 4 | { 5 | 6 | } 7 | 8 | void TOfObjectCreate( TOfObject *self ) 9 | { 10 | ASSIGN_METHOD(Destroy, TOfObjectDestroy); 11 | } 12 | 13 | void OfDestroyObject( TOfObject *self ) 14 | { 15 | if (self != NULL && self->Destroy != NULL) 16 | self->Destroy(self); 17 | } 18 | 19 | void OfFreeObject( TOfObject *self ) 20 | { 21 | if (self != NULL) 22 | { 23 | OfDestroyObject(self); 24 | OfFree(self); 25 | } 26 | } 27 | 28 | TOfObject * OfCreateObject( Int32 object_size ) 29 | { 30 | return (TOfObject *)OfMalloc(object_size); 31 | } 32 | -------------------------------------------------------------------------------- /public/inc/app/cfg/ccu/srt_table.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file srt_table.h 3 | * @brief CCU 存储配置表配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _SRT_TABLE_H_ 17 | #define _SRT_TABLE_H_ 18 | 19 | #include 20 | #include "srt_config.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /* 27 | * 掉电不保存配置表 28 | */ 29 | typedef enum TSrtPlmItemTag TSrtPlmItem; 30 | enum TSrtPlmItemTag 31 | { 32 | kSrtPlmItemFlag = 0, ///< flag标记0x5A len = 1 33 | 34 | 35 | kSrtPlmItemMax = kSrtPlmSize, 36 | 37 | }; 38 | 39 | /* 40 | * 掉电保存配置表 41 | */ 42 | typedef enum TSrtPhmItemTag TSrtPhmItem; 43 | enum TSrtPhmItemTag 44 | { 45 | kSrtPhmItemFlag = 0, ///< flag标记0x5A len = 1 46 | 47 | 48 | kSrtPhmItemMax = kSrtPhmSize, 49 | 50 | }; 51 | 52 | #ifdef __cplusplus 53 | } // extern "C" 54 | #endif 55 | 56 | #endif // _SRT_TABLE_H_ 57 | -------------------------------------------------------------------------------- /public/inc/arch/CMSIS/Include/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Project: CMSIS DSP Library 3 | * Title: arm_const_structs.h 4 | * Description: Constant structs that are initialized for user convenience. 5 | * For example, some can be given as arguments to the arm_cfft_f32() function. 6 | * 7 | * $Date: 27. January 2017 8 | * $Revision: V.1.5.1 9 | * 10 | * Target Processor: Cortex-M cores 11 | * -------------------------------------------------------------------- */ 12 | /* 13 | * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved. 14 | * 15 | * SPDX-License-Identifier: Apache-2.0 16 | * 17 | * Licensed under the Apache License, Version 2.0 (the License); you may 18 | * not use this file except in compliance with the License. 19 | * You may obtain a copy of the License at 20 | * 21 | * www.apache.org/licenses/LICENSE-2.0 22 | * 23 | * Unless required by applicable law or agreed to in writing, software 24 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 25 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | * See the License for the specific language governing permissions and 27 | * limitations under the License. 28 | */ 29 | 30 | #ifndef _ARM_CONST_STRUCTS_H 31 | #define _ARM_CONST_STRUCTS_H 32 | 33 | #include "arm_math.h" 34 | #include "arm_common_tables.h" 35 | 36 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 37 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 38 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 39 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 40 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 41 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 42 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 43 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 44 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 45 | 46 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 47 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 48 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 49 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 50 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 51 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 52 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 53 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 54 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 55 | 56 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 57 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 58 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 59 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 60 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 61 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 62 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 63 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 64 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /public/inc/arch/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.2 5 | * @date 19. April 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 0U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /public/inc/arch/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016 ARM Limited. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ---------------------------------------------------------------------------- 19 | * 20 | * $Date: 21. September 2016 21 | * $Revision: V1.0 22 | * 23 | * Project: TrustZone for ARMv8-M 24 | * Title: Context Management for ARMv8-M TrustZone 25 | * 26 | * Version 1.0 27 | * Initial Release 28 | *---------------------------------------------------------------------------*/ 29 | 30 | #ifndef TZ_CONTEXT_H 31 | #define TZ_CONTEXT_H 32 | 33 | #include 34 | 35 | #ifndef TZ_MODULEID_T 36 | #define TZ_MODULEID_T 37 | /// \details Data type that identifies secure software modules called by a process. 38 | typedef uint32_t TZ_ModuleId_t; 39 | #endif 40 | 41 | /// \details TZ Memory ID identifies an allocated memory slot. 42 | typedef uint32_t TZ_MemoryId_t; 43 | 44 | /// Initialize secure context memory system 45 | /// \return execution status (1: success, 0: error) 46 | uint32_t TZ_InitContextSystem_S (void); 47 | 48 | /// Allocate context memory for calling secure software modules in TrustZone 49 | /// \param[in] module identifies software modules called from non-secure mode 50 | /// \return value != 0 id TrustZone memory slot identifier 51 | /// \return value 0 no memory available or internal error 52 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 53 | 54 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 55 | /// \param[in] id TrustZone memory slot identifier 56 | /// \return execution status (1: success, 0: error) 57 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 58 | 59 | /// Load secure context (called on RTOS thread context switch) 60 | /// \param[in] id TrustZone memory slot identifier 61 | /// \return execution status (1: success, 0: error) 62 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 63 | 64 | /// Store secure context (called on RTOS thread context switch) 65 | /// \param[in] id TrustZone memory slot identifier 66 | /// \return execution status (1: success, 0: error) 67 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 68 | 69 | #endif // TZ_CONTEXT_H 70 | -------------------------------------------------------------------------------- /public/inc/arch/drv/drv_adc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_adc.h 3 | * @brief 模拟数字转换驱动程序 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _DRV_ADC_H_ 17 | #define _DRV_ADC_H_ 18 | 19 | #include 20 | #include 21 | #include "drv_dma.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * ADC驱动类 29 | * @par 示例 30 | * @code 31 | * @endcode 32 | */ 33 | typedef struct TDrvAdcTag TDrvAdc; 34 | struct TDrvAdcTag 35 | { 36 | PROTECTED 37 | TOfObject parent_; 38 | TOfVirtualMethod Destroy_; 39 | 40 | PRIVATE 41 | void *cfg_; ///< 基础配置 42 | Byte index_; 43 | Byte adc_index_; 44 | Byte chn_index_; 45 | Bool is_open_; 46 | 47 | TDrvDmaCh dma_chn_; 48 | }; 49 | 50 | /** 51 | * 驱动类的构造函数 52 | * @param self: 对象实例指针 53 | * @param index: 索引0, 1 54 | * @return 55 | */ 56 | void TDrvAdcCreate(TDrvAdc *self, Int32 index); 57 | 58 | /** 59 | * 驱动类的打开 60 | * @param self: 对象实例指针 61 | * @return True:成功 False:失败 62 | */ 63 | Bool TDrvAdcOpen(TDrvAdc *self); 64 | 65 | /** 66 | * 驱动类的关闭 67 | * @param self: 对象实例指针 68 | * @return True:成功 False:失败 69 | */ 70 | Bool TDrvAdcClose(TDrvAdc *self); 71 | 72 | /** 73 | * 驱动类的读取数据 74 | * @param self: 对象实例指针 75 | * @return 返回转换后的电压值, 单位毫伏 76 | */ 77 | UInt16 TDrvAdcRead(TDrvAdc *self); 78 | 79 | #ifdef __cplusplus 80 | } ///< extern "C" 81 | #endif 82 | 83 | #endif ///< _DRV_ADC_H_ 84 | -------------------------------------------------------------------------------- /public/inc/arch/drv/drv_clock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_clock.h 3 | * @brief 时钟驱动层 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | #ifndef _DRV_CLOCK_H_ 16 | #define _DRV_CLOCK_H_ 17 | 18 | #include 19 | //#include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef struct TDrvClockFrequencyTag TDrvClockFrequency; 26 | struct TDrvClockFrequencyTag 27 | { 28 | UInt32 sysclk_frequency; 29 | UInt32 hclk_frequency; 30 | UInt32 pclk1_frequency; 31 | UInt32 pclk2_frequency; 32 | }; 33 | 34 | 35 | typedef struct TDrvClockTag TDrvClock; 36 | struct TDrvClockTag 37 | { 38 | PROTECTED 39 | TOfObject parent_; 40 | TOfVirtualMethod Destroy_; 41 | 42 | TDrvClockFrequency clock_frequency_; ///< 当前时钟频率 43 | }; 44 | 45 | extern TDrvClock g_drv_clock; 46 | 47 | /** 48 | * 创建一个时钟驱动 49 | * @param self: 对象实例指针 50 | * @return 51 | */ 52 | void TDrvClockCreate(TDrvClock *self); 53 | 54 | /** 55 | * 设置外部时钟 56 | * @param self: 对象实例指针 57 | * @return 58 | */ 59 | void TDrvClockInitClock(TDrvClock *self); 60 | 61 | /** 62 | * 获取时钟频率 63 | * @param self: 对象实例指针 64 | * @param clock_frequency: 时钟值 65 | * @return True:成功 False:失败 66 | */ 67 | Bool TDrvClockGetFrequency(TDrvClock *self, TDrvClockFrequency *clock_frequency); 68 | /** 69 | * 延时微秒(不休眠) 70 | * @param self: 对象实例指针 71 | * @param us: 微秒 72 | * @return 无 73 | */ 74 | void TDrvClockDelayUs(TDrvClock *self, UInt32 us); 75 | /** 76 | * 延时毫秒(不休眠) 77 | * @param self: 对象实例指针 78 | * @param us: 毫秒 79 | * @return 无 80 | */ 81 | void TDrvClockDelayMs(TDrvClock *self, UInt32 ms); 82 | 83 | /// 给初始化库调用 84 | extern void SystemInit(void); 85 | /// 系统时钟值,给rtos使用 86 | extern UInt32 SystemCoreClock; 87 | 88 | #ifdef __cplusplus 89 | } // extern "C" 90 | #endif 91 | 92 | #endif //_DRV_CLOCK_H_ 93 | -------------------------------------------------------------------------------- /public/inc/arch/drv/drv_ext_int.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_ext_int.h 3 | * @brief 外部引脚中断驱动 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _DRV_EXT_INT_H_ 17 | #define _DRV_EXT_INT_H_ 18 | 19 | #include 20 | #include "drv_port.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /** 27 | * 引脚中断触发模式 28 | */ 29 | typedef enum TDrvExtIntTriggerModeTag TDrvExtIntTriggerMode; 30 | enum TDrvExtIntTriggerModeTag 31 | { 32 | kDrvExtIntDisable, ///< 禁用中断 33 | kDrvExtIntRising, ///< 上升沿有效 34 | kDrvExtIntFalling, ///< 下降沿有效 35 | kDrvExtIntBoth, ///< 上升沿和下降沿都有效 36 | 37 | ///----------------如下stm32不支持---------------------// 38 | kDrvExtIntLow, ///< 低电平有效 39 | kDrvExtIntHigh, ///< 高电平有效 40 | }; 41 | 42 | 43 | 44 | typedef struct TDrvExtIntTag TDrvExtInt; 45 | /** 46 | * 中断事件函数 47 | * @note: 由中断中调用 48 | * @param recevier: 事件的产生者 49 | * @return 50 | */ 51 | typedef void (*TDrvExtIntIrqEvent)(void *recevier); 52 | 53 | 54 | struct TDrvExtIntTag 55 | { 56 | PROTECTED 57 | TOfObject parent_; ///< 继承的父类 58 | TOfVirtualMethod Destroy_; ///< 析构函数 59 | 60 | PUBLIC 61 | void *recevier; ///< 事件接收者 62 | TDrvExtIntIrqEvent MethodOnIrq; ///< 中断事件; 注: 电平触发的事件,在中断事件返回前需清除外设的中断电平 63 | 64 | PRIVATE 65 | UInt8 pin_; ///< 引脚 66 | TDrvPortNum port_; ///< 端口号 67 | TDrvExtInt *next_; ///< 下一个对象 68 | }; 69 | 70 | /** 71 | * 构造函数 72 | * @note: 构造后必须先设置OnIrq,再调用TDrvExtIntSetTrigerMode来使能中断 73 | * @param self: 对象实例指针 74 | * @return 75 | */ 76 | void TDrvExtIntCreate(TDrvExtInt *self, TDrvPortNum port, UInt8 pin); 77 | 78 | 79 | /** 80 | * 设置中断触发模式 81 | * @note: 如果引脚配置为电平模式,建议使能该引脚的上下拉功能,否则外设芯片不焊接的话会一直产生中断 82 | * @param self: 对象实例指针 83 | * @param mode: 触发模式 84 | * @return 85 | */ 86 | void TDrvExtIntSetTrigerMode(TDrvExtInt *self, TDrvExtIntTriggerMode mode); 87 | 88 | 89 | #ifdef __cplusplus 90 | } // extern "C" 91 | #endif 92 | 93 | #endif // _DRV_EXT_INT_H_ 94 | -------------------------------------------------------------------------------- /public/inc/arch/drv/drv_int.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_int.h 3 | * @brief 中断相关的支持 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | #ifndef _DRV_INT_H_ 16 | #define _DRV_INT_H_ 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /// 抢占优先级 25 | typedef enum TSysIrqPreePriorityTag TSysIrqPreePriority; 26 | enum TSysIrqPreePriorityTag 27 | { 28 | kSysIrqPreePriority0 = 0, ///< 抢占优先级0 29 | kSysIrqPreePriority1, ///< 抢占优先级1 30 | }; 31 | 32 | /// 响应优先级 33 | typedef enum TSysIrqSubPriorityTag TSysIrqSubPriority; 34 | enum TSysIrqSubPriorityTag 35 | { 36 | kSysIrqSubPriority0 = 0, ///< 响应优先级0 37 | kSysIrqSubPriority1, ///< 响应优先级1 38 | kSysIrqSubPriority2, ///< 响应优先级2 39 | kSysIrqSubPriority3, ///< 响应优先级3 40 | kSysIrqSubPriority4, ///< 响应优先级4 41 | kSysIrqSubPriority5, ///< 响应优先级5 42 | kSysIrqSubPriority6, ///< 响应优先级6 43 | kSysIrqSubPriority7, ///< 响应优先级7 44 | }; 45 | /** 46 | * 中断初始化 47 | * @param 48 | * @return 49 | */ 50 | void SysIRQInit(void); 51 | /** 52 | * 使能中断 53 | * @param irq_number: 中断号 54 | * @param preemption_priority: 抢断优先级(0~1) 数字越低优先级越高 55 | * @param sub_priority: 响应优先级(0~7) 数字越低优先级越高 56 | * @return 57 | */ 58 | void SysEnableIRQ(UInt32 irq_number, TSysIrqPreePriority preemption_priority, TSysIrqSubPriority sub_priority); 59 | 60 | /** 61 | * 禁用中断(irq_number) 62 | * @param irq_number: 中断号 63 | * @return 64 | */ 65 | void SysDisableIRQ(UInt32 irq_number); 66 | 67 | 68 | #ifdef __cplusplus 69 | } // extern "C" 70 | #endif 71 | 72 | #endif // _DRV_INT_H_ 73 | -------------------------------------------------------------------------------- /public/inc/arch/drv/drv_pmu.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_pmu.h 3 | * @brief 电源管理驱动层 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | #ifndef _DRV_PMU_H_ 16 | #define _DRV_PMU_H_ 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | 25 | /** 26 | * 系统进入工作(刚启动调用一次) 27 | * @param 28 | * @return 29 | */ 30 | void DrvPmuWork(void); 31 | 32 | /** 33 | * 系统进入休眠模式 34 | * @param 35 | * @return 36 | */ 37 | void DrvPmuSleep(void); 38 | 39 | /** 40 | * 系统软件复位 41 | * @param 42 | * @return 43 | */ 44 | void DrvPmuSoftReset(void); 45 | 46 | #ifdef __cplusplus 47 | } // extern "C" 48 | #endif 49 | 50 | #endif //_DRV_PMU_H_ 51 | -------------------------------------------------------------------------------- /public/inc/arch/drv/drv_pwm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_pwm.h 3 | * @brief PWM输出 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | #ifndef _DRV_PWM_H_ 16 | #define _DRV_PWM_H_ 17 | 18 | #include 19 | #include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | 26 | typedef struct TDrvPwmTag TDrvPwm; 27 | 28 | 29 | /** 30 | * 中断事件函数 31 | * @note: 由中断中调用 32 | * @param sender: 事件的产生者 33 | * @return 34 | */ 35 | typedef void (*TDrvPwmIrq)(void *sender); 36 | 37 | struct TDrvPwmTag 38 | { 39 | PROTECTED 40 | TOfObject parent_; 41 | TOfVirtualMethod Destroy_; 42 | 43 | PUBLIC 44 | void *recevier; ///< 事件接收者 45 | TDrvPwmIrq MethodOnIrq; ///< 中断事件; 46 | 47 | PRIVATE 48 | 49 | Bool is_open_; ///< 是否已经打开 50 | UInt8 cfg_index_; ///< 配置序列 51 | Int32 pwm_timer_index_; ///< pwm使用定时器结构体序列 52 | }; 53 | 54 | /** 55 | * 构造函数 56 | * @param self: 对象实例指针 57 | * @param index: 项索引: 0..2 58 | * @return True:成功 False:失败 59 | */ 60 | Bool TDrvPwmCreate(TDrvPwm *self, UInt8 index); 61 | 62 | /** 63 | * 驱动打开 64 | * @param self: 对象实例指针 65 | * @return True:成功 False:失败 66 | */ 67 | Bool TDrvPwmOpen(TDrvPwm *self); 68 | 69 | /** 70 | * 驱动关闭 71 | * @param self: 对象实例指针 72 | * @return True:成功 False:失败 73 | */ 74 | Bool TDrvPwmClose(TDrvPwm *self); 75 | 76 | /** 77 | * 驱动关闭 78 | * @param self: 对象实例指针 79 | * @param value: 占空比值(高电平有效时间比)(0~100%) 80 | * @return True:成功 False:失败 81 | */ 82 | Bool TDrvPwmSetVaule(TDrvPwm *self, UInt32 value); 83 | 84 | 85 | #ifdef __cplusplus 86 | } // extern "C" 87 | #endif 88 | 89 | #endif // _DRV_PWM_H_ 90 | -------------------------------------------------------------------------------- /public/inc/arch/drv/drv_spi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_spi.h 3 | * @brief SPI主驱动 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _DRV_SPI_H_ 17 | #define _DRV_SPI_H_ 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef struct TDrvSpiTag TDrvSpi; 25 | 26 | struct TDrvSpiTag 27 | { 28 | PROTECTED 29 | TOfObject parent_; 30 | TOfVirtualMethod Destroy_; 31 | 32 | PRIVATE 33 | Bool is_open_; 34 | Int32 index_; ///< 配置索引 35 | Int32 spi_index_; ///< spi索引 36 | 37 | }; 38 | 39 | 40 | /** 41 | * 驱动创建 42 | * @param self: 对象实例指针 43 | * @param cfg: SPI模块配置信息 44 | * @return 创建成功返回True,否则返回False,参数错误 45 | */ 46 | Bool TDrvSpiCreate(TDrvSpi *self, UInt8 index); 47 | 48 | /** 49 | * 驱动打开 50 | * @param self: 对象实例指针 51 | * @return 52 | */ 53 | void TDrvSpiOpen(TDrvSpi *self); 54 | 55 | /** 56 | * 驱动关闭 57 | * @param self: 对象实例指针 58 | * @return 59 | */ 60 | void TDrvSpiClose(TDrvSpi *self); 61 | 62 | /** 63 | * 驱动是否已经打开 64 | * @param 65 | * @return 已经打开返回True,否则返回False 66 | */ 67 | Bool TDrvSpiIsOpen(TDrvSpi *self); 68 | /** 69 | * spi发送和读取数据 70 | * @param value:发送数据:读取一字节发送0xff 71 | * @return 返回读取到的数据 72 | */ 73 | Byte TDrvSpiWriteAndRead(TDrvSpi *self, Byte value); 74 | 75 | #ifdef __cplusplus 76 | } // extern "C" 77 | #endif 78 | 79 | #endif // _DRV_SPI_H_ 80 | -------------------------------------------------------------------------------- /public/inc/arch/drv/drv_usb_master.h: -------------------------------------------------------------------------------- 1 | ///** 2 | // * @file drv_usb_master.h 3 | // * @brief usb主机驱动 4 | // * @note 5 | // * @author zgq 6 | // * @date 2021-10-24 7 | // * @version 1.0 8 | 9 | // * @par 修改日志 10 | // * 11 | // *
Date Version Author Description 12 | // *
2021-10-24 1.0 zgq 创建初始版本 13 | // * @copyright 14 | // */ 15 | //#ifndef _DRV_USB_MASTER_H_ 16 | //#define _DRV_USB_MASTER_H_ 17 | //#include 18 | //#include 19 | 20 | //#ifdef __cplusplus 21 | //extern "C" { 22 | //#endif 23 | 24 | 25 | ///** 26 | // * 连接通知函数 27 | // * @note: 由中断中调用 28 | // * @param sender: 事件的产生者 29 | // * @param is_connected: False:断开 True:连接 30 | // * @return 31 | // */ 32 | //typedef void (*TDrvUsbMasterIsConnected)(void *sender, Bool is_connected); 33 | 34 | 35 | //typedef struct TDrvUsbMasterTag TDrvUsbMaster; 36 | 37 | //struct TDrvUsbMasterTag 38 | //{ 39 | //PROTECTED 40 | // TOfObject parent_; 41 | // TOfVirtualMethod Destroy_; 42 | // 43 | //PUBLIC 44 | // void *recevier; ///< 事件接收者 45 | // TDrvUsbMasterIsConnected MethodIsConnected; ///< 中断事件; 46 | // 47 | //PRIVATE 48 | // UInt8 usb_index_; ///< usb项 49 | // Bool is_connected_; ///< 是否有连接 50 | //}; 51 | 52 | //extern TDrvUsbMaster g_drv_usb_master; 53 | 54 | ///** 55 | // * 构造函数 56 | // * @param self: 对象实例指针 57 | // * @param usb_index: usb编号 0:fs 1:hs 58 | // * @return 59 | // */ 60 | //void TDrvUsbMasterCreate(TDrvUsbMaster *self, UInt8 usb_index); 61 | 62 | ///** 63 | // * 打开驱动 64 | // * @note: 65 | // * @param self: 对象实例指针 66 | // * @return 打开成功返回true,否则为false 67 | // */ 68 | //Bool TDrvUsbMasterOpen(TDrvUsbMaster *self); 69 | 70 | ///** 71 | // * 驱动关闭 72 | // * @param self: 对象实例指针 73 | // * @return 74 | // */ 75 | //void TDrvUsbMasterClose(TDrvUsbMaster *self); 76 | ///** 77 | // * u盘读取 78 | // * @param self: 对象实例指针 79 | // * @param addr: 地址 80 | // * @param buffer: 读取缓存 81 | // * @param read_len: 读取长度 82 | // * @return 0:失败 >=0:成功长度 83 | // */ 84 | //UInt32 TDrvUsbMasterRead(TDrvUsbMaster *self, UInt32 addr, UInt8 *buffer, UInt32 read_len); 85 | ///** 86 | // * u盘写入 87 | // * @param self: 对象实例指针 88 | // * @param addr: 地址 89 | // * @param data: 数据缓存 90 | // * @param write_len: 写入长度 91 | // * @return 0:失败 >=0:成功长度 92 | // */ 93 | //UInt32 TDrvUsbMasterWrite(TDrvUsbMaster *self, UInt32 addr, const UInt8 *data, UInt32 write_len); 94 | ///** 95 | // * 驱动循环处理 96 | // * @param self: 对象实例指针 97 | // * @return 98 | // */ 99 | //void TDrvUsbMasterRunOnce(TDrvUsbMaster *self); 100 | ///** 101 | // * 获取u盘容量(u盘连接时有效) 102 | // * @param self: 对象实例指针 103 | // * @return 104 | // */ 105 | //UInt32 TDrvUsbMasterGetCapacity(TDrvUsbMaster *self); 106 | 107 | //#ifdef __cplusplus 108 | //} // extern "C" 109 | //#endif 110 | 111 | //#endif /// _DRV_USB_Master_H_ 112 | -------------------------------------------------------------------------------- /public/inc/arch/drv/drv_usb_slave.h: -------------------------------------------------------------------------------- 1 | ///** 2 | // * @file drv_usb_slave.h 3 | // * @brief usb从机驱动 4 | // * @note 5 | // * @author zgq 6 | // * @date 2021-10-24 7 | // * @version 1.0 8 | 9 | // * @par 修改日志 10 | // * 11 | // *
Date Version Author Description 12 | // *
2021-10-24 1.0 zgq 创建初始版本 13 | // * @copyright 14 | // */ 15 | //#ifndef _DRV_USB_SLAVE_H_ 16 | //#define _DRV_USB_SLAVE_H_ 17 | //#include 18 | //#include 19 | 20 | //#ifdef __cplusplus 21 | //extern "C" { 22 | //#endif 23 | 24 | ///** 25 | // * 连接通知函数 26 | // * @note: 由中断中调用 27 | // * @param sender: 事件的产生者 28 | // * @param is_connected: False:断开 True:连接 29 | // * @return 30 | // */ 31 | //typedef void (*TDrvUsbSlaveIsConnected)(void *sender, Bool is_connected); 32 | 33 | 34 | //typedef struct TDrvUsbSlaveTag TDrvUsbSlave; 35 | 36 | //struct TDrvUsbSlaveTag 37 | //{ 38 | //PROTECTED 39 | // TOfObject parent_; 40 | // TOfVirtualMethod Destroy_; 41 | // 42 | //PUBLIC 43 | // void *recevier; ///< 事件接收者 44 | // TDrvUsbSlaveIsConnected MethodIsConnected; ///< 中断事件; 45 | // 46 | //PRIVATE 47 | // UInt8 usb_index_; ///< usb项 48 | // Bool is_connected_; ///< 是否有连接 49 | //}; 50 | 51 | //extern TDrvUsbSlave g_drv_usb_master; 52 | 53 | ///** 54 | // * 构造函数 55 | // * @param self: 对象实例指针 56 | // * @param usb_index: usb编号 0:fs 1:hs 57 | // * @return 58 | // */ 59 | //void TDrvUsbSlaveCreate(TDrvUsbSlave *self, UInt8 usb_index); 60 | 61 | ///** 62 | // * 打开驱动 63 | // * @note: 64 | // * @param self: 对象实例指针 65 | // * @return 打开成功返回true,否则为false 66 | // */ 67 | //Bool TDrvUsbSlaveOpen(TDrvUsbSlave *self); 68 | 69 | ///** 70 | // * 驱动关闭 71 | // * @param self: 对象实例指针 72 | // * @return 73 | // */ 74 | //void TDrvUsbSlaveClose(TDrvUsbSlave *self); 75 | 76 | //#ifdef __cplusplus 77 | //} // extern "C" 78 | //#endif 79 | 80 | //#endif /// _DRV_USB_SLAVE_H_ 81 | -------------------------------------------------------------------------------- /public/inc/arch/drv/drv_wdog.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drv_wdog.h 3 | * @brief 看门狗驱动层 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | #ifndef _DRV_WDOG_H_ 16 | #define _DRV_WDOG_H_ 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /** 25 | * 使用看门狗操作 26 | * @par 示例 27 | * @code 28 | TDrvWdogCreate(&g_drv_wdog); 29 | TDrvWdogOpen(&g_drv_wdog); 30 | .... 31 | TDrvWdogFeedDog(&g_drv_wdog); 32 | * @endcode 33 | */ 34 | 35 | typedef struct TDrvWdogTag TDrvWdog; 36 | struct TDrvWdogTag 37 | { 38 | PROTECTED 39 | TOfObject parent_; 40 | TOfVirtualMethod Destroy_; 41 | }; 42 | 43 | extern TDrvWdog g_drv_wdog; 44 | 45 | /** 46 | * 创建一个看门狗设备驱动 47 | * @param self: 对象实例指针 48 | * @return 49 | */ 50 | void TDrvWdogCreate(TDrvWdog *self); 51 | 52 | /** 53 | * 打开看门狗 54 | * @param self: 对象实例指针 55 | * @return 56 | */ 57 | void TDrvWdogOpen(TDrvWdog *self); 58 | 59 | /** 60 | * 关闭看门狗(暂时为空,无法关闭) 61 | * @param self: 对象实例指针 62 | * @return 63 | */ 64 | void TDrvWdogClose(TDrvWdog *self); 65 | 66 | /** 67 | * 喂狗(默认2s内需要喂狗) 68 | * @param self: 对象实例指针 69 | * @return 70 | */ 71 | void TDrvWdogFeedDog(TDrvWdog *self); 72 | 73 | #ifdef __cplusplus 74 | } // extern "C" 75 | #endif 76 | 77 | #endif //_DRV_WDOG_H_ 78 | -------------------------------------------------------------------------------- /public/inc/def/can_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file can_def.h 3 | * @brief CAN通用数据定义 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | #ifndef _CAN_DEF_H_ 16 | #define _CAN_DEF_H_ 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /** 25 | * 帧Id类型的枚举 26 | */ 27 | typedef enum TCanIdTypeTag TCanIdType; 28 | enum TCanIdTypeTag 29 | { 30 | kCanIdTypeStd, ///< 标准ID 31 | kCanIdTypeExt, ///< 扩展ID 32 | }; 33 | 34 | /** 35 | * Can帧类型的枚举 36 | */ 37 | typedef enum TCanFrameTypeTag TCanFrameType; 38 | enum TCanFrameTypeTag 39 | { 40 | kCanFrameTypeData, ///< 数据帧 41 | kCanFrameTypeRemote, ///< 远程帧 42 | }; 43 | 44 | /** 45 | * 收发的CAN数据定义 46 | */ 47 | typedef struct TCanDataTag TCanData; 48 | struct TCanDataTag 49 | { 50 | union 51 | { 52 | UInt32 recv_tick; ///< 收到数据时的TICK值(仅接收时有效) 53 | UInt32 data_id; ///< 数据发送完成或者失败时是否需要调用回调事件来告知.=0为不需要告知;否则为需要告知,data_id唯一标识一个报文 54 | } param; 55 | 56 | unsigned char bus_index; ///< CAN设备索引 57 | unsigned char length; ///< 数据长度 58 | unsigned char id_type; ///< TCanIdType, 0: 标准帧, 1: 扩展ID 59 | unsigned char frame_type; ///< TCanFrameType, 0: 数据帧, 1: 远程帧 60 | UInt32 id; ///< CANID; 扩展帧ID: Bit28-Bit0; 标准帧: Bit10-Bit0 61 | unsigned char data[8]; ///< CAN数据 62 | }; 63 | 64 | #ifdef __cplusplus 65 | } // extern "C" 66 | #endif 67 | 68 | #endif // _CAN_DEF_H_ 69 | -------------------------------------------------------------------------------- /public/inc/kernel/config/mem_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file mem_config.h 3 | * @brief 内存管理配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _SFC_MEM_CONFIG_H_ 17 | #define _SFC_MEM_CONFIG_H_ 18 | 19 | #include 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | /* 24 | * 枚举配置 25 | */ 26 | enum 27 | { 28 | kMemMemory1kCnt = 40, ///< 内存分配占用几个1K空间 29 | }; 30 | #ifdef __cplusplus 31 | } // extern "C" 32 | #endif 33 | 34 | #endif // _SFC_MEM_CONFIG_H_ 35 | -------------------------------------------------------------------------------- /public/inc/kernel/config/srt_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file srt_config.h 3 | * @brief 存储配置表配置 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _SFC_SRT_CONFIG_H_ 17 | #define _SFC_SRT_CONFIG_H_ 18 | 19 | #include 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | /* 24 | * 枚举配置 25 | */ 26 | enum 27 | { 28 | kSrtPlmSize = 4096, ///< 掉电不存储表大小 4k 29 | kSrtPhmSize = 4096, ///< 掉电存储表大小 4k 30 | }; 31 | /* 32 | * 掉电不存储表 33 | */ 34 | enum 35 | { 36 | kSrtPlmItemFlag = 0, ///< 存储标记(应用勿动) length = 1 37 | 38 | 39 | kSrtPlmItemMaxSize = kSrtPlmSize, ///< 最大值不能超过 40 | }; 41 | 42 | /* 43 | * 掉电存储表 44 | */ 45 | enum 46 | { 47 | kSrtPhmItemFlag = 0, ///< 存储标记(应用勿动) length = 1 48 | kSrtPhmReserved = 1, ///< length = 1 49 | kSrtPhmAppVersion = 2, ///< 程序版本高字节大版本号低字节小版本号 length = 2 50 | kSrtPhmDevNum = 4, ///< 10进制设备编号(2112019999) length = 4 51 | kSrtPhmSerialNumStr = 8, ///< 20字节序列号 length = 20 52 | kSrtPhmParamTabVersion = 28, ///< 参数表版本号高字节大版本号低字节小版本号 length = 2 53 | kSrtPhmCan0Baud = 30, ///< CAN0波特率 length = 4 54 | kSrtPhmCan1Baud = 34, ///< CAN1波特率 length = 4 55 | kSrtPhmCan2Baud = 38, ///< CAN2波特率 length = 4 56 | ///< 预留 57 | kSrtPhmProjectType = 60, ///< 项目类型 length = 1 58 | kSrtPhmModuleType = 61, ///< 模块类型 length = 1 59 | kSrtPhmModuleCnt = 62, ///< 模块数量 length = 1 60 | kSrtPhmContGroupType = 62, ///< 接触器群充类型 length = 1 61 | kSrtPhmChargeGunCnt = 62, ///< 充电枪数量 length = 1 62 | kSrtPhmChargeGunType = 62, ///< 充电枪类型 length = 1 63 | kSrtPhmBmsType = 62, ///< BMS类型 length = 1 64 | 65 | 66 | kSrtPhmItemMaxSize = kSrtPhmSize, ///< 最大值不能超过 67 | }; 68 | 69 | 70 | #ifdef __cplusplus 71 | } // extern "C" 72 | #endif 73 | 74 | #endif // _SFC_SRT_CONFIG_H_ 75 | -------------------------------------------------------------------------------- /public/inc/kernel/kernel_init.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file kernel_init.h 3 | * @brief 内核系统初始化 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KERNEL_INIT_H_ 17 | #define _KERNEL_INIT_H_ 18 | 19 | #include "ofc_types.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /** 26 | * 内核初始化 27 | * @param 28 | * @return 29 | */ 30 | void KernelInit(void); 31 | 32 | /** 33 | * 内核调度开始 34 | * @param 35 | * @return True:成功 False:失败 36 | */ 37 | Bool KernelStart(void); 38 | 39 | /** 40 | * 内核循环执行 41 | * @param 42 | * @return True:成功 False:失败 43 | */ 44 | void KernelRunOnce(void); 45 | 46 | #ifdef __cplusplus 47 | } // extern "C" 48 | #endif 49 | 50 | #endif // _APP_BASE_H_ 51 | -------------------------------------------------------------------------------- /public/inc/kernel/kfc/kfc_dev.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Kfc_dev.h 3 | * @brief 操作设备接口 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KFC_DEV_H_ 17 | #define _KFC_DEV_H_ 18 | 19 | #include 20 | #include "dev_config.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /** 27 | * 打开设备 28 | * @param dev_num: 设备号 29 | * @return True:成功 False:失败 30 | */ 31 | Bool KfcDevOpen(UInt16 dev_num); 32 | 33 | /** 34 | * 关闭设备 35 | * @param dev_num: 设备号 36 | * @return True: 成功 False:失败 37 | */ 38 | Bool KfcDevClose(UInt16 dev_num); 39 | 40 | /** 41 | * 设备ioctl 42 | * @param dev_num: 设备号 43 | * @param cmd: 命令字 44 | * @param argv: 命令参数 45 | * @return True: 成功 False:失败 46 | */ 47 | Bool KfcDevIoctl(UInt16 dev_num, UInt32 cmd, void *argv); 48 | 49 | /** 50 | * 设备读取函数 51 | * @param dev_num: 设备号 52 | * @param buf: 数据存放地址 53 | * @param len: 数据长度 54 | * @return <= 0: 失败 >0: 成功字节数 55 | */ 56 | Int32 KfcDevRead(UInt16 dev_num, void *buf, UInt32 len); 57 | 58 | /** 59 | * 设备写函数 60 | * @param dev_num: 设备号 61 | * @param buf: 数据存放地址 62 | * @param len: 数据长度 63 | * @return <= 0: 失败 >0: 成功字节数 64 | */ 65 | Int32 KfcDevWrite(UInt16 dev_num, void *buf, UInt32 len); 66 | 67 | #ifdef __cplusplus 68 | } // extern "C" 69 | #endif 70 | 71 | #endif // _KFC_DEV_H_ 72 | -------------------------------------------------------------------------------- /public/inc/kernel/kfc/kfc_event.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file kfc_event.h 3 | * @brief 定义TKfcEvent类 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | #ifndef _KFC_EVENT_H_ 16 | #define _KFC_EVENT_H_ 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | enum 25 | { 26 | kSfEventAllFlags = 0x7FFFFFFF, ///< 事件所有有效位的值 27 | }; 28 | 29 | /** 30 | * 构造TKfcEvent类,类似于TThreadEvent.跟TThreadEvent的区别在于: 31 | * TSfEvent可在一个线程中创建多个,而一个线程只能创建一个ThreadEven 32 | * @par 示例 33 | * @code 34 | Thread A: 35 | TKfcEvent event; 36 | TKfcEventCreate(&event); 37 | ... 38 | if (TKfcEventWait(&event, 3, False, 100) > 0) ... // 等到flag为0或者1的事件产生,最多等到100ms 39 | 40 | Thread B: 41 | TKfcEventSetFlag(&event, 0); // flag 0表示B中设置 42 | 43 | 中断中: 44 | TKfcEventSetFlag(&event, 1); // flag 1表示中断中设置 45 | 46 | OfDestroyObject((TOfObject *)event); 47 | * @endcode 48 | */ 49 | typedef struct TKfcEventTag TKfcEvent; 50 | struct TKfcEventTag 51 | { 52 | PROTECTED 53 | TOfObject parent_; 54 | TOfVirtualMethod Destroy_; 55 | 56 | PRIVATE 57 | //DRtosEventFlagsHandle handle_; 58 | void* handle_; 59 | }; 60 | 61 | /** 62 | * 事件类的构造函数 63 | * @param self: 对象实例指针 64 | * @return 65 | */ 66 | void TKfcEventCreate(TKfcEvent *self); 67 | 68 | /** 69 | * 设置事件标记 70 | * 注: 这个函数可以在任何地方调用,包括在中断中调用 71 | * @param self: 对象实例 72 | * @param flag_bit_index: 需要设置的事件标记索引.取值范围为: 0-30 73 | * @return 返回true表示设置该标记值时,等待函数正在等这个标记.否则表示等待函数没有在等待该标记 74 | */ 75 | Bool TKfcEventSetFlag(TKfcEvent *self, Int32 flag_bit_index); 76 | 77 | /** 78 | * 设置事件的多个标记 79 | * 注: 这个函数可以在任何地方调用,包括在中断中调用 80 | * @param self: 对象实例 81 | * @param flags: 需要设置的事件标记集合; 每个bit为一个事件标记.Bit31不允许设置; 82 | * @return 返回true表示设置该标记值时,等待函数正在等这个标记.否则表示等待函数没有在等待该标记 83 | */ 84 | Bool TKfcEventSetFlags(TKfcEvent *self, UInt32 flags); 85 | 86 | /** 87 | * 等待flags指定的一个或者多个事件. 88 | * 注: !!!!!!!!!!!!!!!!!!!!!!!!!!! 89 | * 如果event的flags为1011(二进制), 如果参数flags为1001(二进制),则返回值为1011, 之后event的flags变成0010 90 | * 注意,这里bit1的1没有被清除.之后如果有设置了flags为1100, 则event的flags=1110, 然后等待的参数flags为1000 91 | * 则函数返回值为1110,event的flags为0110; 切记,参数flags不设置为1的bit,如果event的falgs对应bit为1,则该bit会一直为1 92 | * @param self: 对象实例 93 | * @param flags: 需要等待的事件集合,仅bit0-bit30有效,bit31不得设置为1.比如flags=9(=1001B),表示等待flag=0和(或)3的事件 94 | * @param all: 是否需要等到flags指定的所有标记都置位才返回. 95 | * true: 表示flags指定的所有事件都等到才返回; false: 表示只需要等到flags指定的任意一个事件置位就返回 96 | * @param timeout: 等待的时长,单位: ms. 0: 表示不等待,立即返回, -1: 表示永久等待,直到事件产生 97 | * @return 返回等到要求时的事件集合, <0表示超时或者出错 98 | */ 99 | Int32 TKfcEventWait(TKfcEvent *self, Int32 flags, Bool all, Int32 timeout); 100 | 101 | #ifdef __cplusplus 102 | } // extern "C" 103 | #endif 104 | 105 | #endif // _KFC_EVENT_H_ 106 | -------------------------------------------------------------------------------- /public/inc/kernel/kfc/kfc_memory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file kfc_memory.h 3 | * @brief 动态内存分配接口 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KFC_MEMORY_H_ 17 | #define _KFC_MEMORY_H_ 18 | 19 | #include 20 | #include 21 | #include "dev_config.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * 系统内存分配函数 29 | * @param size: 分配内存的大小 30 | * @return 内存分配成功,返回分配的内存指针,否则返回NULL 31 | */ 32 | void *KfcMalloc(Int32 size); 33 | 34 | /** 35 | * 系统内存释放函数 36 | * @param ptr: 释放内存的指针 37 | * @return 38 | */ 39 | void KfcFree(void *ptr); 40 | 41 | 42 | #ifdef __cplusplus 43 | } // extern "C" 44 | #endif 45 | 46 | #endif // _KFC_MEMORY_H_ 47 | -------------------------------------------------------------------------------- /public/inc/kernel/kfc/kfc_mutex.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file kfc_mutex.h 3 | * @brief 定义互斥锁类 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KFC_MUTEX_H_ 17 | #define _KFC_MUTEX_H_ 18 | 19 | #include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /** 26 | * 构造加锁类 27 | * @par 示例 28 | * @code 29 | Thread A: 30 | TKfcMutex Mutex; 31 | TKfcMutexCreate(&Mutex); 32 | ... 33 | TKfcMutexLock(&Mutex, 100) ... // 申请锁最多等待100ms 34 | 35 | TKfcMutexUnlock(&Mutex); 36 | 37 | OfDestroyObject((TOfObject *)Mutex); 38 | * @endcode 39 | */ 40 | typedef struct TKfcMutexTag TKfcMutex; 41 | struct TKfcMutexTag 42 | { 43 | PROTECTED 44 | TOfObject parent_; 45 | TOfVirtualMethod Destroy_; 46 | 47 | PRIVATE 48 | void *handle_; 49 | }; 50 | 51 | /** 52 | * 临界区类的构造函数 53 | * @param self: 对象实例指针 54 | * @return True: 成功; False: 失败 55 | */ 56 | Bool TKfcMutexCreate(TKfcMutex *self); 57 | 58 | /** 59 | * 获得临界区.当前线程如果获得临界区,则当前线程就是临界区的所有者,直到当前线程调用TMutexRelease释放临界区 60 | * @param self: 对象实例 61 | * @param timeout: 等待的时长,单位: ms. 0: 表示不等待,立即返回, -1: 表示永久等待,直到得到这个临界区 62 | * @return 返回true表示获得临界区成功.否则表示获得临界区失败或者超时 63 | */ 64 | Bool TKfcMutexLock(TKfcMutex *self, Int32 timeout); 65 | 66 | /** 67 | * 释放临界区 68 | * @param self: 对象实例 69 | * @return 70 | */ 71 | void TKfcMutexUnlock(TKfcMutex *self); 72 | 73 | #ifdef __cplusplus 74 | } // extern "C" 75 | #endif 76 | 77 | #endif // _KFC_MUTEX_H_ 78 | -------------------------------------------------------------------------------- /public/inc/kernel/kfc/kfc_system.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file kfc_system.h 3 | * @brief 内核系统接口 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _KFC_SYSTEM_H_ 17 | #define _KFC_SYSTEM_H_ 18 | 19 | #include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /** 26 | * 线程休眠函数 27 | * @param ms: 休眠时长,单位: ms 28 | * @return 29 | */ 30 | void KfcSleep(UInt32 ms); 31 | 32 | /** 33 | * 得到当前的tick数,单位: 毫秒 34 | * @return tick数 35 | */ 36 | UInt32 KfcGetTickCount(void); 37 | /** 38 | * 微秒软件延迟(不休眠) 39 | * @return us:微秒 40 | */ 41 | void KfcDelayUs(UInt32 us); 42 | /** 43 | * 毫秒软件延迟(不休眠) 44 | * @return ms:毫秒 45 | */ 46 | void KfcDelayMs(UInt32 ms); 47 | #ifdef __cplusplus 48 | } // extern "C" 49 | #endif 50 | 51 | #endif // _KFC_SYSTEM_H_ 52 | -------------------------------------------------------------------------------- /public/inc/lib/ofc/ofc_crc16.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ofc_crc16.h 3 | * @brief CRC16相关的函数. 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | #ifndef _OFC_CRC16_H_ 16 | #define _OFC_CRC16_H_ 17 | 18 | #include "ofc_types.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /** 25 | * 计算CRC16值(CRC-16/MODBUS算法, 多项式: 0x8005, 初始值0xFFFF) 26 | * @param data: 需要计算CRC的数据 27 | * @param size: 数据大小 28 | * @note 本函数计算结果与原RFC库中的结果高低字节相反 29 | * @return 计算出来的crc值 30 | */ 31 | UInt16 OfCalcCrc16(UInt8 *data, Int32 size); 32 | 33 | /** 34 | * 计算CRC16值(CRC-16算法/MODBUS算法, 多项式: 0x8005) 35 | * @param data: 需要计算CRC的数据 36 | * @param size: 数据大小 37 | * @param seed: 种子,即计算的起始值 38 | * @return 计算出来的crc值 39 | */ 40 | UInt16 OfCalcCrc16s(UInt8 *data, Int32 size, UInt16 seed); 41 | 42 | #ifdef __cplusplus 43 | } // extern "C" 44 | #endif 45 | 46 | #endif // _OFC_CRC16_H_ 47 | -------------------------------------------------------------------------------- /public/inc/lib/ofc/ofc_crc32.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ofc_crc32.h 3 | * @brief CRC32相关的函数. 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _OFC_CRC32_H_ 17 | #define _OFC_CRC32_H_ 18 | 19 | #include "ofc_types.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /** 26 | * CRC32计算函数.初始值为0xFFFFFFFF 27 | * @param src: 需要计算crc的数据起始地址 28 | * @param size: 字节数 29 | * @note 此接口获取的非标准的CRC码,取反后=标准的CRC32码 30 | * @return 计算的crc结果码 31 | */ 32 | UInt32 OfCalcCrc32(UInt8 *src, Int32 size); 33 | 34 | /** 35 | * CRC32计算函数.初始值由crc输入,结果输出到crc 36 | * @param src: 需要计算crc的数据起始地址 37 | * @param size: 字节数 38 | * @param seed: 输入crc的起始值,输出最终的crc值 39 | * @note 此接口获取的非标准的CRC码,取反后=标准的CRC32码 40 | * @return 计算的crc结果码 41 | */ 42 | UInt32 OfCalcCrc32s(UInt8 *src, Int32 size, UInt32 seed); 43 | 44 | 45 | #ifdef __cplusplus 46 | } // extern "C" 47 | #endif 48 | #endif // _OFC_CRC32_H_ 49 | -------------------------------------------------------------------------------- /public/inc/lib/ofc/ofc_object.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ofc_object.h 3 | * @brief 基础类定义 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | #ifndef _OFC_OBJECT_H_ 16 | #define _OFC_OBJECT_H_ 17 | 18 | #include "ofc_types.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define ASSIGN_METHOD(name, method) \ 25 | self->name = method; 26 | 27 | #define OVERRIDE_METHOD(ancestor_class, name, method)\ 28 | self->name##_ = ((ancestor_class *)self)->name;\ 29 | ((ancestor_class *)self)->name = method; 30 | 31 | typedef struct TOfObjectTag TOfObject; 32 | typedef void (*TOfVirtualMethod)(TOfObject *self); 33 | 34 | /** 35 | * TOfNotifyEvent事件 36 | * @param sender: 调用者对象指针 37 | * @return 38 | */ 39 | typedef void (*TOfNotifyEvent)(TOfObject *sender); 40 | 41 | /** 42 | * TOfDoNotify事件 43 | * @param sender: 调用者对象指针 44 | * @return 45 | */ 46 | typedef void (*TOfDoNotify)(void *sender); 47 | 48 | /** 49 | * TOfOnNotify事件 50 | */ 51 | typedef struct TOfOnNotifyTag TOfOnNotify; 52 | struct TOfOnNotifyTag 53 | { 54 | void *object; 55 | TOfDoNotify Method; 56 | }; 57 | 58 | #define PRIVATE 59 | #define PROTECTED 60 | #define PUBLIC 61 | 62 | #define VIRTUAL 63 | 64 | /** 65 | * Ofc内存分配函数 66 | * @param size: 分配内存的大小 67 | * @return 内存分配成功,返回分配的内存指针,否则返回NULL 68 | */ 69 | void *OfMalloc(Int32 size); 70 | 71 | /** 72 | * Ofc内存释放函数 73 | * @param ptr: 释放内存的指针 74 | * @return 75 | */ 76 | void OfFree(void *ptr); 77 | 78 | /** 79 | * 所有对象的基类 80 | */ 81 | struct TOfObjectTag 82 | { 83 | PUBLIC 84 | TOfVirtualMethod Destroy; 85 | }; 86 | 87 | /** 88 | * TOfObject的构造函数 89 | * @param self: 对象实例指针 90 | * @return 91 | */ 92 | void TOfObjectCreate(TOfObject *self); 93 | 94 | /** 95 | * 所有的对象销毁,需要调用该函数. 96 | * @note 该函数只负责销毁对象,而不会释放self的内存.如果需要销毁并释放内存的话用FreeObject函数 97 | * 如果self不是malloc出来的可以调用这个函数 98 | * @param self: 对象实例指针 99 | * @return 100 | */ 101 | void OfDestroyObject(TOfObject *self); 102 | 103 | /** 104 | * 创建对象实例的函数.该函数仅仅是分配了对象占用的内存. 105 | * @param object_size: 对象实例的大小 106 | * @return 返回创建的对象(注: 该对象为调用任何构造函数) 107 | */ 108 | TOfObject *OfCreateObject(Int32 object_size); 109 | 110 | /** 111 | * 调用对象的析构函数,并释放self指向的内存. 112 | * 仅动态分配出来的对象用这个函数,否则用DestroyObject函数 113 | * @param self: 对象实例指针 114 | * @return 115 | */ 116 | void OfFreeObject(TOfObject *self); 117 | 118 | #ifdef __cplusplus 119 | } // extern "C" 120 | #endif 121 | 122 | #endif // _OFC_OBJECT_H_ 123 | -------------------------------------------------------------------------------- /public/inc/lib/ofc/ofc_string.h: -------------------------------------------------------------------------------- 1 | /** 2 | *@file ofc_string.h 3 | *@brief 定义标准库常用的跟字符串处理,内存复制等相关函数. 4 | *@note ofc库并没有实现这些函数的功能. 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _OFC_STRING_H_ 17 | #define _OFC_STRING_H_ 18 | 19 | #include "ofc_types.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | void *memcpy(void *dst, const void *src, TSize size); 26 | void *memmove(void *dst, const void *src, TSize size); 27 | char *strcpy(char *dst, const char *src); 28 | char *strncpy(char *dst, const char *src, TSize size); 29 | char *strcat(char *dst, const char *src); 30 | char *strncat(char *dst, const char *src, TSize size); 31 | int memcmp(const void *dst, const void *src, TSize size); 32 | int strcmp(const char *dst, const char *src); 33 | int strncmp(const char *dst, const char *src, TSize size); 34 | int strcoll(const char *dst, const char *src); 35 | TSize strxfrm(char *dst, const char *src, TSize size); 36 | void *memchr(const void *s, int c, TSize size); 37 | char *strchr(const char *s, int c); 38 | TSize strcspn(const char *dst, const char *src); 39 | char *strpbrk(const char *dst, const char *src); 40 | char *strrchr(const char *s, int c); 41 | TSize strspn(const char *dst, const char *src); 42 | char *strstr(const char *dst, const char *src); 43 | char *strtok(char *dst, const char *src); 44 | void *memset(void *s, int c, TSize size); 45 | char *strerror(int errnum); 46 | TSize strlen(const char *s); 47 | TSize memicmp(const void *buf1, const void *buf2, TSize count); 48 | 49 | #ifdef __cplusplus 50 | } // extern "C" 51 | #endif 52 | 53 | #endif // _OFC_STRING_H_ 54 | -------------------------------------------------------------------------------- /public/inc/lib/ofc/ofc_types.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ofc_types.h 3 | * @brief 基础定义(在陆凯锋的基础上修改) 4 | * @note 5 | * @author zgq 6 | * @date 2021-10-24 7 | * @version 1.0 8 | 9 | * @par 修改日志 10 | * 11 | *
Date Version Author Description 12 | *
2021-10-24 1.0 zgq 创建初始版本 13 | * @copyright 14 | */ 15 | 16 | #ifndef _OFC_TYPES_H_ 17 | #define _OFC_TYPES_H_ 18 | 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | 24 | /* 常量列表 */ 25 | 26 | /// 空指针值 27 | #ifndef NULL 28 | #define NULL ((void *)0) 29 | #endif 30 | 31 | /// 常量值 32 | #ifndef True 33 | /// 布尔值假 34 | #define False 0 35 | /// 布尔值真 36 | #define True 1 37 | #endif 38 | 39 | #ifndef TRUE 40 | /// 布尔值假 41 | #define FALSE 0 42 | /// 布尔值真 43 | #define TRUE 1 44 | #endif 45 | 46 | #ifndef OFFSET_OF 47 | #define OFFSET_OF(T, I) ((long)&((T*)0)->I) 48 | #endif 49 | 50 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 51 | 52 | /// 用于表示数据大小的类型 53 | // armcc: 32位4字节,64位8字节 54 | // gcc: 32位4字节,64位8字节 55 | #if defined(__CC_ARM) 56 | #if (__sizeof_ptr == 8) 57 | typedef unsigned long TSize; 58 | #else 59 | typedef unsigned int TSize; 60 | #endif 61 | #else 62 | #if (__SIZEOF_LONG__ == 8) 63 | typedef long unsigned int TSize; 64 | #else 65 | typedef unsigned int TSize; 66 | #endif 67 | #endif 68 | 69 | /* 类型定义 */ 70 | #if defined(_WIN32) || defined(_WIN64) || defined(_WINDOWS) || defined(WINCE) 71 | typedef unsigned __int64 ___uint64_t; 72 | typedef __int64 ___int64_t; 73 | #elif defined(__linux) 74 | typedef long long ___int64_t; 75 | typedef unsigned long long ___uint64_t; 76 | #else 77 | typedef long long ___int64_t; 78 | typedef unsigned long long ___uint64_t; 79 | #endif 80 | 81 | /// 有符号整型 82 | typedef ___int64_t Int64; 83 | typedef signed int Int32; 84 | typedef signed short Int16; 85 | typedef signed char Int8; 86 | 87 | /// 无符号整型 88 | typedef ___uint64_t UInt64; 89 | typedef unsigned int UInt32; 90 | typedef unsigned short UInt16; 91 | typedef unsigned char UInt8; 92 | 93 | /// 无符号整型 94 | typedef ___uint64_t QWord; 95 | typedef unsigned int DWord; 96 | typedef unsigned short Word; 97 | typedef unsigned char Byte; 98 | 99 | /// 布尔类型 100 | typedef unsigned char Bool; 101 | 102 | /// 用于表示时间的类型(同time_t) 103 | typedef long TTime; 104 | 105 | #ifdef __cplusplus 106 | } // extern "C" 107 | #endif 108 | 109 | #endif //_OFC_TYPES_H_ 110 | -------------------------------------------------------------------------------- /sln/sln_test/out/README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/sln/sln_test/out/README.txt -------------------------------------------------------------------------------- /sln/sln_test/out/USAL_APP.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/sln/sln_test/out/USAL_APP.bin -------------------------------------------------------------------------------- /sln/sln_test/out/USAL_BOOT.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/sln/sln_test/out/USAL_BOOT.bin -------------------------------------------------------------------------------- /sln/sln_test/out/app_hmi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/sln/sln_test/out/app_hmi.lib -------------------------------------------------------------------------------- /sln/sln_test/out/app_test.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/sln/sln_test/out/app_test.lib -------------------------------------------------------------------------------- /sln/sln_test/out/arch.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/sln/sln_test/out/arch.lib -------------------------------------------------------------------------------- /sln/sln_test/out/kernel.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/sln/sln_test/out/kernel.lib -------------------------------------------------------------------------------- /sln/sln_test/out/lib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/sln/sln_test/out/lib.lib -------------------------------------------------------------------------------- /sln/sln_test/sln.uvmpw: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1.0 5 | 6 |
### uVision Project, (C) Keil Software
7 | 8 | WorkSpace 9 | 10 | 11 | .\lib\lib.uvprojx 12 | 13 | 14 | 15 | .\arch\arch.uvprojx 16 | 17 | 18 | 19 | .\bootldr\bootldr.uvprojx 20 | 21 | 22 | 23 | .\kernel\kernel.uvprojx 24 | 25 | 26 | 27 | .\app_test\app_test.uvprojx 28 | 29 | 30 | 31 | .\usr\usr.uvprojx 32 | 1 33 | 34 | 35 |
36 | -------------------------------------------------------------------------------- /usr/src/link/ld/stm32_flash.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hu198021688500/usal_mcu/18028cbdfb42519f26367bd0dc2235bae0e08b50/usr/src/link/ld/stm32_flash.ld -------------------------------------------------------------------------------- /usr/usr_test/main.c: -------------------------------------------------------------------------------- 1 | #include "kernel_init.h" 2 | #include 3 | #include 4 | #include "test_task.h" 5 | #include "kfc_system.h" 6 | 7 | /** 8 | * 主任务 9 | */ 10 | typedef struct TMainTaskTag TMainTask; 11 | struct TMainTaskTag 12 | { 13 | PROTECTED 14 | TKfcTask parent_; ///< 继承的父类 15 | TOfVirtualMethod Destroy_; ///< 析构函数 16 | 17 | PRIVATE 18 | TTestTask *test_task_; 19 | }; 20 | 21 | /// 主任务对象 22 | TMainTask g_main_task; 23 | 24 | /** 25 | * 创建对象 26 | * @param object: 对象实例 27 | * @return 28 | */ 29 | static void TMainTaskOnTaskCreate(TOfObject *object) 30 | { 31 | TMainTask *self = (TMainTask *)object; 32 | self->test_task_ = &g_test_task; 33 | 34 | TTestTaskCreate(self->test_task_); ///< 测试任务创建 35 | } 36 | 37 | /** 38 | * 任务开始 39 | * @param object: 对象实例 40 | * @return 41 | */ 42 | static void TMainTaskOnTaskStart(TOfObject *object) 43 | { 44 | TMainTask *self = (TMainTask *)object; 45 | 46 | TKfcTaskStart((TKfcTask *)self->test_task_); ///< 测试任务启动 47 | } 48 | 49 | /** 50 | * 服务执行函数 51 | * @param object: 对象实例 52 | * @return 53 | */ 54 | static void TMainTaskOnTaskExecute(TOfObject *object) 55 | { 56 | TMainTask *self = (TMainTask *)object; 57 | 58 | while (!TKfcTaskTerminated((TKfcTask *)self)) 59 | { 60 | KernelRunOnce(); 61 | KfcSleep(2); 62 | } 63 | } 64 | 65 | /** 66 | * 析构函数 67 | * @param object: 对象实例 68 | * @return 69 | */ 70 | static void TMainTaskDestroy(TOfObject *object) 71 | { 72 | TMainTask *self = (TMainTask *)object; 73 | 74 | self->Destroy_(object); 75 | } 76 | 77 | void TMainTaskCreate(TMainTask *self) 78 | { 79 | #if defined (__GNUC__) 80 | static char stack[512] __attribute__ ((aligned (8))); 81 | #else 82 | __align(8) static char stack[512]; 83 | #endif 84 | 85 | TKfcTaskCreate(&self->parent_, kKfcTaskPriority6, stack, sizeof(stack)); 86 | OVERRIDE_METHOD(TOfObject, Destroy, TMainTaskDestroy); 87 | self->parent_.OnCreate = TMainTaskOnTaskCreate; 88 | self->parent_.OnStart = TMainTaskOnTaskStart; 89 | self->parent_.OnExecute = TMainTaskOnTaskExecute; 90 | 91 | TKfcTaskResume(&self->parent_); 92 | } 93 | 94 | int main() 95 | { 96 | /// 内核初始化 97 | KernelInit(); 98 | /// 主任务创建和启动 99 | TMainTaskCreate(&g_main_task); 100 | TKfcTaskStart((TKfcTask *)&g_main_task); 101 | 102 | KernelStart(); 103 | /// TODO:不应该走到这,需要加异常处理 104 | while(1); 105 | } 106 | -------------------------------------------------------------------------------- /usr/usr_test/version/version.c: -------------------------------------------------------------------------------- 1 | /** 2 | * version.c 3 | * 4 | * 概述:Bootloader 版本 5 | * 作者:lukf 6 | * 版本: 7 | * 修订记录 8 | * 2018-03-09 lukf 创建文件 9 | * 10 | */ 11 | 12 | /// #include "types.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | enum 19 | { 20 | kVersionAddress = 0xCFF8, 21 | }; 22 | 23 | typedef struct 24 | { 25 | unsigned char major; 26 | unsigned char minor; 27 | unsigned char test; 28 | unsigned char compile; 29 | unsigned int compile_time; 30 | }TVersion; 31 | 32 | const TVersion bootloader_version __attribute__((at(kVersionAddress))) = 33 | { 34 | .major = 0x02, 35 | .minor = 0x05, 36 | .test = 0x00, 37 | .compile = 0x00, 38 | .compile_time = 1573000888, 39 | }; 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | --------------------------------------------------------------------------------