├── Readme.md
├── doc
└── img
│ ├── cdbridge_v6.1.jpg
│ ├── cdbridge_v6.1_case.jpg
│ └── cdgui.png
├── fw_bl
├── .gitignore
├── AT32F405xC_FLASH.ld
├── Makefile
├── cdbridge_bl.ATWP
├── flash.sh
├── libraries
│ ├── cmsis
│ │ └── cm4
│ │ │ ├── core_support
│ │ │ ├── arm_common_tables.h
│ │ │ ├── arm_common_tables_f16.h
│ │ │ ├── arm_const_structs.h
│ │ │ ├── arm_const_structs_f16.h
│ │ │ ├── arm_helium_utils.h
│ │ │ ├── arm_math.h
│ │ │ ├── arm_math_f16.h
│ │ │ ├── arm_math_memory.h
│ │ │ ├── arm_math_types.h
│ │ │ ├── arm_math_types_f16.h
│ │ │ ├── arm_mve_tables.h
│ │ │ ├── arm_mve_tables_f16.h
│ │ │ ├── arm_vec_math.h
│ │ │ ├── arm_vec_math_f16.h
│ │ │ ├── cmsis_armcc.h
│ │ │ ├── cmsis_armclang.h
│ │ │ ├── cmsis_armclang_ltm.h
│ │ │ ├── cmsis_compiler.h
│ │ │ ├── cmsis_gcc.h
│ │ │ ├── cmsis_iccarm.h
│ │ │ ├── cmsis_version.h
│ │ │ ├── core_cm4.h
│ │ │ ├── mpu_armv7.h
│ │ │ ├── mpu_armv8.h
│ │ │ └── pmu_armv8.h
│ │ │ └── device_support
│ │ │ ├── at32f402_405.h
│ │ │ ├── at32f402_405_conf_template.h
│ │ │ ├── startup
│ │ │ ├── gcc
│ │ │ │ ├── linker
│ │ │ │ │ ├── AT32F402xB_FLASH.ld
│ │ │ │ │ ├── AT32F402xC_FLASH.ld
│ │ │ │ │ ├── AT32F405xB_FLASH.ld
│ │ │ │ │ └── AT32F405xC_FLASH.ld
│ │ │ │ └── startup_at32f402_405.s
│ │ │ ├── iar
│ │ │ │ ├── linker
│ │ │ │ │ ├── AT32F402xB.icf
│ │ │ │ │ ├── AT32F402xC.icf
│ │ │ │ │ ├── AT32F405xB.icf
│ │ │ │ │ └── AT32F405xC.icf
│ │ │ │ └── startup_at32f402_405.s
│ │ │ └── mdk
│ │ │ │ └── startup_at32f402_405.s
│ │ │ ├── system_at32f402_405.c
│ │ │ └── system_at32f402_405.h
│ └── drivers
│ │ ├── inc
│ │ ├── at32f402_405_acc.h
│ │ ├── at32f402_405_adc.h
│ │ ├── at32f402_405_can.h
│ │ ├── at32f402_405_crc.h
│ │ ├── at32f402_405_crm.h
│ │ ├── at32f402_405_debug.h
│ │ ├── at32f402_405_def.h
│ │ ├── at32f402_405_dma.h
│ │ ├── at32f402_405_ertc.h
│ │ ├── at32f402_405_exint.h
│ │ ├── at32f402_405_flash.h
│ │ ├── at32f402_405_gpio.h
│ │ ├── at32f402_405_i2c.h
│ │ ├── at32f402_405_misc.h
│ │ ├── at32f402_405_pwc.h
│ │ ├── at32f402_405_qspi.h
│ │ ├── at32f402_405_scfg.h
│ │ ├── at32f402_405_spi.h
│ │ ├── at32f402_405_tmr.h
│ │ ├── at32f402_405_usart.h
│ │ ├── at32f402_405_usb.h
│ │ ├── at32f402_405_wdt.h
│ │ └── at32f402_405_wwdt.h
│ │ └── src
│ │ ├── at32f402_405_acc.c
│ │ ├── at32f402_405_adc.c
│ │ ├── at32f402_405_can.c
│ │ ├── at32f402_405_crc.c
│ │ ├── at32f402_405_crm.c
│ │ ├── at32f402_405_debug.c
│ │ ├── at32f402_405_dma.c
│ │ ├── at32f402_405_ertc.c
│ │ ├── at32f402_405_exint.c
│ │ ├── at32f402_405_flash.c
│ │ ├── at32f402_405_gpio.c
│ │ ├── at32f402_405_i2c.c
│ │ ├── at32f402_405_misc.c
│ │ ├── at32f402_405_pwc.c
│ │ ├── at32f402_405_qspi.c
│ │ ├── at32f402_405_scfg.c
│ │ ├── at32f402_405_spi.c
│ │ ├── at32f402_405_tmr.c
│ │ ├── at32f402_405_usart.c
│ │ ├── at32f402_405_usb.c
│ │ ├── at32f402_405_wdt.c
│ │ └── at32f402_405_wwdt.c
├── middlewares
│ ├── 3rd_party
│ │ └── fatfs
│ │ │ └── source
│ │ │ ├── diskio.c
│ │ │ ├── diskio.h
│ │ │ ├── ff.c
│ │ │ ├── ff.h
│ │ │ ├── ffconf_template.h
│ │ │ ├── ffsystem.c
│ │ │ └── ffunicode.c
│ ├── freertos
│ │ └── source
│ │ │ ├── croutine.c
│ │ │ ├── event_groups.c
│ │ │ ├── include
│ │ │ ├── FreeRTOS.h
│ │ │ ├── StackMacros.h
│ │ │ ├── atomic.h
│ │ │ ├── croutine.h
│ │ │ ├── deprecated_definitions.h
│ │ │ ├── event_groups.h
│ │ │ ├── list.h
│ │ │ ├── message_buffer.h
│ │ │ ├── mpu_prototypes.h
│ │ │ ├── mpu_wrappers.h
│ │ │ ├── portable.h
│ │ │ ├── projdefs.h
│ │ │ ├── queue.h
│ │ │ ├── semphr.h
│ │ │ ├── stack_macros.h
│ │ │ ├── stdint.readme
│ │ │ ├── stream_buffer.h
│ │ │ ├── task.h
│ │ │ └── timers.h
│ │ │ ├── list.c
│ │ │ ├── portable
│ │ │ ├── GCC
│ │ │ │ ├── ARM_CM3
│ │ │ │ │ ├── port.c
│ │ │ │ │ └── portmacro.h
│ │ │ │ └── ARM_CM4F
│ │ │ │ │ ├── port.c
│ │ │ │ │ └── portmacro.h
│ │ │ ├── IAR
│ │ │ │ ├── ARM_CM3
│ │ │ │ │ ├── port.c
│ │ │ │ │ ├── portasm.s
│ │ │ │ │ └── portmacro.h
│ │ │ │ └── ARM_CM4F
│ │ │ │ │ ├── port.c
│ │ │ │ │ ├── portasm.s
│ │ │ │ │ └── portmacro.h
│ │ │ ├── common
│ │ │ │ └── mpu_wrappers.c
│ │ │ ├── memmang
│ │ │ │ ├── ReadMe.url
│ │ │ │ ├── heap_1.c
│ │ │ │ ├── heap_2.c
│ │ │ │ ├── heap_3.c
│ │ │ │ ├── heap_4.c
│ │ │ │ └── heap_5.c
│ │ │ └── rvds
│ │ │ │ ├── ARM_CM3
│ │ │ │ ├── port.c
│ │ │ │ └── portmacro.h
│ │ │ │ └── ARM_CM4F
│ │ │ │ ├── port.c
│ │ │ │ └── portmacro.h
│ │ │ ├── queue.c
│ │ │ ├── stream_buffer.c
│ │ │ ├── tasks.c
│ │ │ └── timers.c
│ ├── i2c_application_library
│ │ ├── i2c_application.c
│ │ └── i2c_application.h
│ ├── usb_drivers
│ │ ├── inc
│ │ │ ├── usb_core.h
│ │ │ ├── usb_std.h
│ │ │ ├── usbd_core.h
│ │ │ ├── usbd_int.h
│ │ │ ├── usbd_sdr.h
│ │ │ ├── usbh_core.h
│ │ │ ├── usbh_ctrl.h
│ │ │ └── usbh_int.h
│ │ └── src
│ │ │ ├── usb_core.c
│ │ │ ├── usbd_core.c
│ │ │ ├── usbd_int.c
│ │ │ ├── usbd_sdr.c
│ │ │ ├── usbh_core.c
│ │ │ ├── usbh_ctrl.c
│ │ │ └── usbh_int.c
│ ├── usbd_class
│ │ ├── audio
│ │ │ ├── audio_class.c
│ │ │ ├── audio_class.h
│ │ │ ├── audio_conf.h
│ │ │ ├── audio_desc.c
│ │ │ └── audio_desc.h
│ │ ├── audio_hid
│ │ │ ├── audio_conf.h
│ │ │ ├── audio_hid_class.c
│ │ │ ├── audio_hid_class.h
│ │ │ ├── audio_hid_desc.c
│ │ │ └── audio_hid_desc.h
│ │ ├── cdc
│ │ │ ├── cdc_class.c
│ │ │ ├── cdc_class.h
│ │ │ ├── cdc_desc.c
│ │ │ └── cdc_desc.h
│ │ ├── composite_cdc_keyboard
│ │ │ ├── cdc_keyboard_class.c
│ │ │ ├── cdc_keyboard_class.h
│ │ │ ├── cdc_keyboard_desc.c
│ │ │ └── cdc_keyboard_desc.h
│ │ ├── composite_cdc_msc
│ │ │ ├── cdc_msc_class.c
│ │ │ ├── cdc_msc_class.h
│ │ │ ├── cdc_msc_desc.c
│ │ │ ├── cdc_msc_desc.h
│ │ │ └── msc_bot_scsi.c
│ │ ├── custom_hid
│ │ │ ├── custom_hid_class.c
│ │ │ ├── custom_hid_class.h
│ │ │ ├── custom_hid_desc.c
│ │ │ └── custom_hid_desc.h
│ │ ├── hid_iap
│ │ │ ├── hid_iap_class.c
│ │ │ ├── hid_iap_class.h
│ │ │ ├── hid_iap_desc.c
│ │ │ └── hid_iap_desc.h
│ │ ├── keyboard
│ │ │ ├── keyboard_class.c
│ │ │ ├── keyboard_class.h
│ │ │ ├── keyboard_desc.c
│ │ │ └── keyboard_desc.h
│ │ ├── mouse
│ │ │ ├── mouse_class.c
│ │ │ ├── mouse_class.h
│ │ │ ├── mouse_desc.c
│ │ │ └── mouse_desc.h
│ │ ├── msc
│ │ │ ├── msc_bot_scsi.c
│ │ │ ├── msc_bot_scsi.h
│ │ │ ├── msc_class.c
│ │ │ ├── msc_class.h
│ │ │ ├── msc_desc.c
│ │ │ └── msc_desc.h
│ │ ├── printer
│ │ │ ├── printer_class.c
│ │ │ ├── printer_class.h
│ │ │ ├── printer_desc.c
│ │ │ └── printer_desc.h
│ │ └── winusb
│ │ │ ├── winusb_class.c
│ │ │ ├── winusb_class.h
│ │ │ ├── winusb_desc.c
│ │ │ └── winusb_desc.h
│ └── usbh_class
│ │ ├── usbh_cdc
│ │ ├── usbh_cdc_class.c
│ │ └── usbh_cdc_class.h
│ │ ├── usbh_hid
│ │ ├── usbh_hid_class.c
│ │ ├── usbh_hid_class.h
│ │ ├── usbh_hid_keyboard.c
│ │ ├── usbh_hid_keyboard.h
│ │ ├── usbh_hid_mouse.c
│ │ └── usbh_hid_mouse.h
│ │ └── usbh_msc
│ │ ├── usbh_msc_bot_scsi.c
│ │ ├── usbh_msc_bot_scsi.h
│ │ ├── usbh_msc_class.c
│ │ └── usbh_msc_class.h
├── project
│ ├── Eclipse_gcc
│ │ ├── .cproject
│ │ ├── .project
│ │ ├── .settings
│ │ │ ├── language.settings.xml
│ │ │ └── org.eclipse.core.runtime.prefs
│ │ ├── AT32F405xC_FLASH.ld
│ │ └── startup_at32f402_405.s
│ ├── inc
│ │ ├── at32f402_405_conf.h
│ │ ├── at32f402_405_int.h
│ │ ├── at32f402_405_wk_config.h
│ │ ├── cdc_class.h
│ │ ├── cdc_desc.h
│ │ ├── usb_app.h
│ │ ├── usb_conf.h
│ │ └── wk_system.h
│ └── src
│ │ ├── at32f402_405_int.c
│ │ ├── at32f402_405_wk_config.c
│ │ ├── cdc_class.c
│ │ ├── cdc_desc.c
│ │ ├── main.c
│ │ ├── usb_app.c
│ │ └── wk_system.c
├── usr
│ ├── app_main.c
│ ├── app_main.h
│ ├── cd_config.h
│ ├── common_services.c
│ ├── config.c
│ └── debug_config.h
└── utils
│ ├── arch_wrapper.h
│ ├── cd_list.c
│ ├── cd_list.h
│ ├── cd_utils.h
│ ├── cdbus_uart.c
│ ├── cdbus_uart.h
│ ├── crc_hw.c
│ └── modbus_crc.h
├── fw_bridge
├── .gitignore
├── AT32F405xC_FLASH.ld
├── Makefile
├── cdbridge.ATWP
├── flash.sh
├── libraries
│ ├── cmsis
│ │ └── cm4
│ │ │ ├── core_support
│ │ │ ├── arm_common_tables.h
│ │ │ ├── arm_common_tables_f16.h
│ │ │ ├── arm_const_structs.h
│ │ │ ├── arm_const_structs_f16.h
│ │ │ ├── arm_helium_utils.h
│ │ │ ├── arm_math.h
│ │ │ ├── arm_math_f16.h
│ │ │ ├── arm_math_memory.h
│ │ │ ├── arm_math_types.h
│ │ │ ├── arm_math_types_f16.h
│ │ │ ├── arm_mve_tables.h
│ │ │ ├── arm_mve_tables_f16.h
│ │ │ ├── arm_vec_math.h
│ │ │ ├── arm_vec_math_f16.h
│ │ │ ├── cmsis_armcc.h
│ │ │ ├── cmsis_armclang.h
│ │ │ ├── cmsis_armclang_ltm.h
│ │ │ ├── cmsis_compiler.h
│ │ │ ├── cmsis_gcc.h
│ │ │ ├── cmsis_iccarm.h
│ │ │ ├── cmsis_version.h
│ │ │ ├── core_cm4.h
│ │ │ ├── mpu_armv7.h
│ │ │ ├── mpu_armv8.h
│ │ │ └── pmu_armv8.h
│ │ │ └── device_support
│ │ │ ├── at32f402_405.h
│ │ │ ├── at32f402_405_conf_template.h
│ │ │ ├── startup
│ │ │ ├── gcc
│ │ │ │ ├── linker
│ │ │ │ │ ├── AT32F402xB_FLASH.ld
│ │ │ │ │ ├── AT32F402xC_FLASH.ld
│ │ │ │ │ ├── AT32F405xB_FLASH.ld
│ │ │ │ │ └── AT32F405xC_FLASH.ld
│ │ │ │ └── startup_at32f402_405.s
│ │ │ ├── iar
│ │ │ │ ├── linker
│ │ │ │ │ ├── AT32F402xB.icf
│ │ │ │ │ ├── AT32F402xC.icf
│ │ │ │ │ ├── AT32F405xB.icf
│ │ │ │ │ └── AT32F405xC.icf
│ │ │ │ └── startup_at32f402_405.s
│ │ │ └── mdk
│ │ │ │ └── startup_at32f402_405.s
│ │ │ ├── system_at32f402_405.c
│ │ │ └── system_at32f402_405.h
│ └── drivers
│ │ ├── inc
│ │ ├── at32f402_405_acc.h
│ │ ├── at32f402_405_adc.h
│ │ ├── at32f402_405_can.h
│ │ ├── at32f402_405_crc.h
│ │ ├── at32f402_405_crm.h
│ │ ├── at32f402_405_debug.h
│ │ ├── at32f402_405_def.h
│ │ ├── at32f402_405_dma.h
│ │ ├── at32f402_405_ertc.h
│ │ ├── at32f402_405_exint.h
│ │ ├── at32f402_405_flash.h
│ │ ├── at32f402_405_gpio.h
│ │ ├── at32f402_405_i2c.h
│ │ ├── at32f402_405_misc.h
│ │ ├── at32f402_405_pwc.h
│ │ ├── at32f402_405_qspi.h
│ │ ├── at32f402_405_scfg.h
│ │ ├── at32f402_405_spi.h
│ │ ├── at32f402_405_tmr.h
│ │ ├── at32f402_405_usart.h
│ │ ├── at32f402_405_usb.h
│ │ ├── at32f402_405_wdt.h
│ │ └── at32f402_405_wwdt.h
│ │ └── src
│ │ ├── at32f402_405_acc.c
│ │ ├── at32f402_405_adc.c
│ │ ├── at32f402_405_can.c
│ │ ├── at32f402_405_crc.c
│ │ ├── at32f402_405_crm.c
│ │ ├── at32f402_405_debug.c
│ │ ├── at32f402_405_dma.c
│ │ ├── at32f402_405_ertc.c
│ │ ├── at32f402_405_exint.c
│ │ ├── at32f402_405_flash.c
│ │ ├── at32f402_405_gpio.c
│ │ ├── at32f402_405_i2c.c
│ │ ├── at32f402_405_misc.c
│ │ ├── at32f402_405_pwc.c
│ │ ├── at32f402_405_qspi.c
│ │ ├── at32f402_405_scfg.c
│ │ ├── at32f402_405_spi.c
│ │ ├── at32f402_405_tmr.c
│ │ ├── at32f402_405_usart.c
│ │ ├── at32f402_405_usb.c
│ │ ├── at32f402_405_wdt.c
│ │ └── at32f402_405_wwdt.c
├── middlewares
│ ├── 3rd_party
│ │ └── fatfs
│ │ │ └── source
│ │ │ ├── diskio.c
│ │ │ ├── diskio.h
│ │ │ ├── ff.c
│ │ │ ├── ff.h
│ │ │ ├── ffconf_template.h
│ │ │ ├── ffsystem.c
│ │ │ └── ffunicode.c
│ ├── freertos
│ │ └── source
│ │ │ ├── croutine.c
│ │ │ ├── event_groups.c
│ │ │ ├── include
│ │ │ ├── FreeRTOS.h
│ │ │ ├── StackMacros.h
│ │ │ ├── atomic.h
│ │ │ ├── croutine.h
│ │ │ ├── deprecated_definitions.h
│ │ │ ├── event_groups.h
│ │ │ ├── list.h
│ │ │ ├── message_buffer.h
│ │ │ ├── mpu_prototypes.h
│ │ │ ├── mpu_wrappers.h
│ │ │ ├── portable.h
│ │ │ ├── projdefs.h
│ │ │ ├── queue.h
│ │ │ ├── semphr.h
│ │ │ ├── stack_macros.h
│ │ │ ├── stdint.readme
│ │ │ ├── stream_buffer.h
│ │ │ ├── task.h
│ │ │ └── timers.h
│ │ │ ├── list.c
│ │ │ ├── portable
│ │ │ ├── GCC
│ │ │ │ ├── ARM_CM3
│ │ │ │ │ ├── port.c
│ │ │ │ │ └── portmacro.h
│ │ │ │ └── ARM_CM4F
│ │ │ │ │ ├── port.c
│ │ │ │ │ └── portmacro.h
│ │ │ ├── IAR
│ │ │ │ ├── ARM_CM3
│ │ │ │ │ ├── port.c
│ │ │ │ │ ├── portasm.s
│ │ │ │ │ └── portmacro.h
│ │ │ │ └── ARM_CM4F
│ │ │ │ │ ├── port.c
│ │ │ │ │ ├── portasm.s
│ │ │ │ │ └── portmacro.h
│ │ │ ├── common
│ │ │ │ └── mpu_wrappers.c
│ │ │ ├── memmang
│ │ │ │ ├── ReadMe.url
│ │ │ │ ├── heap_1.c
│ │ │ │ ├── heap_2.c
│ │ │ │ ├── heap_3.c
│ │ │ │ ├── heap_4.c
│ │ │ │ └── heap_5.c
│ │ │ └── rvds
│ │ │ │ ├── ARM_CM3
│ │ │ │ ├── port.c
│ │ │ │ └── portmacro.h
│ │ │ │ └── ARM_CM4F
│ │ │ │ ├── port.c
│ │ │ │ └── portmacro.h
│ │ │ ├── queue.c
│ │ │ ├── stream_buffer.c
│ │ │ ├── tasks.c
│ │ │ └── timers.c
│ ├── i2c_application_library
│ │ ├── i2c_application.c
│ │ └── i2c_application.h
│ ├── usb_drivers
│ │ ├── inc
│ │ │ ├── usb_core.h
│ │ │ ├── usb_std.h
│ │ │ ├── usbd_core.h
│ │ │ ├── usbd_int.h
│ │ │ ├── usbd_sdr.h
│ │ │ ├── usbh_core.h
│ │ │ ├── usbh_ctrl.h
│ │ │ └── usbh_int.h
│ │ └── src
│ │ │ ├── usb_core.c
│ │ │ ├── usbd_core.c
│ │ │ ├── usbd_int.c
│ │ │ ├── usbd_sdr.c
│ │ │ ├── usbh_core.c
│ │ │ ├── usbh_ctrl.c
│ │ │ └── usbh_int.c
│ ├── usbd_class
│ │ ├── audio
│ │ │ ├── audio_class.c
│ │ │ ├── audio_class.h
│ │ │ ├── audio_conf.h
│ │ │ ├── audio_desc.c
│ │ │ └── audio_desc.h
│ │ ├── audio_hid
│ │ │ ├── audio_conf.h
│ │ │ ├── audio_hid_class.c
│ │ │ ├── audio_hid_class.h
│ │ │ ├── audio_hid_desc.c
│ │ │ └── audio_hid_desc.h
│ │ ├── cdc
│ │ │ ├── cdc_class.c
│ │ │ ├── cdc_class.h
│ │ │ ├── cdc_desc.c
│ │ │ └── cdc_desc.h
│ │ ├── composite_cdc_keyboard
│ │ │ ├── cdc_keyboard_class.c
│ │ │ ├── cdc_keyboard_class.h
│ │ │ ├── cdc_keyboard_desc.c
│ │ │ └── cdc_keyboard_desc.h
│ │ ├── composite_cdc_msc
│ │ │ ├── cdc_msc_class.c
│ │ │ ├── cdc_msc_class.h
│ │ │ ├── cdc_msc_desc.c
│ │ │ ├── cdc_msc_desc.h
│ │ │ └── msc_bot_scsi.c
│ │ ├── custom_hid
│ │ │ ├── custom_hid_class.c
│ │ │ ├── custom_hid_class.h
│ │ │ ├── custom_hid_desc.c
│ │ │ └── custom_hid_desc.h
│ │ ├── hid_iap
│ │ │ ├── hid_iap_class.c
│ │ │ ├── hid_iap_class.h
│ │ │ ├── hid_iap_desc.c
│ │ │ └── hid_iap_desc.h
│ │ ├── keyboard
│ │ │ ├── keyboard_class.c
│ │ │ ├── keyboard_class.h
│ │ │ ├── keyboard_desc.c
│ │ │ └── keyboard_desc.h
│ │ ├── mouse
│ │ │ ├── mouse_class.c
│ │ │ ├── mouse_class.h
│ │ │ ├── mouse_desc.c
│ │ │ └── mouse_desc.h
│ │ ├── msc
│ │ │ ├── msc_bot_scsi.c
│ │ │ ├── msc_bot_scsi.h
│ │ │ ├── msc_class.c
│ │ │ ├── msc_class.h
│ │ │ ├── msc_desc.c
│ │ │ └── msc_desc.h
│ │ ├── printer
│ │ │ ├── printer_class.c
│ │ │ ├── printer_class.h
│ │ │ ├── printer_desc.c
│ │ │ └── printer_desc.h
│ │ └── winusb
│ │ │ ├── winusb_class.c
│ │ │ ├── winusb_class.h
│ │ │ ├── winusb_desc.c
│ │ │ └── winusb_desc.h
│ └── usbh_class
│ │ ├── usbh_cdc
│ │ ├── usbh_cdc_class.c
│ │ └── usbh_cdc_class.h
│ │ ├── usbh_hid
│ │ ├── usbh_hid_class.c
│ │ ├── usbh_hid_class.h
│ │ ├── usbh_hid_keyboard.c
│ │ ├── usbh_hid_keyboard.h
│ │ ├── usbh_hid_mouse.c
│ │ └── usbh_hid_mouse.h
│ │ └── usbh_msc
│ │ ├── usbh_msc_bot_scsi.c
│ │ ├── usbh_msc_bot_scsi.h
│ │ ├── usbh_msc_class.c
│ │ └── usbh_msc_class.h
├── project
│ ├── Eclipse_gcc
│ │ ├── .cproject
│ │ ├── .project
│ │ ├── .settings
│ │ │ ├── language.settings.xml
│ │ │ └── org.eclipse.core.runtime.prefs
│ │ ├── AT32F405xC_FLASH.ld
│ │ └── startup_at32f402_405.s
│ ├── inc
│ │ ├── at32f402_405_conf.h
│ │ ├── at32f402_405_int.h
│ │ ├── at32f402_405_wk_config.h
│ │ ├── cdc_class.h
│ │ ├── cdc_desc.h
│ │ ├── usb_app.h
│ │ ├── usb_conf.h
│ │ └── wk_system.h
│ └── src
│ │ ├── at32f402_405_int.c
│ │ ├── at32f402_405_wk_config.c
│ │ ├── cdc_class.c
│ │ ├── cdc_desc.c
│ │ ├── main.c
│ │ ├── usb_app.c
│ │ └── wk_system.c
├── usr
│ ├── app_main.c
│ ├── app_main.h
│ ├── cd_config.h
│ ├── cdctl_spi_wr.c
│ ├── cdctl_spi_wr.h
│ ├── common_services.c
│ ├── config.c
│ └── debug_config.h
└── utils
│ ├── arch_wrapper.h
│ ├── cd_frame.h
│ ├── cd_list.c
│ ├── cd_list.h
│ ├── cd_utils.h
│ ├── cdbus_uart.c
│ ├── cdbus_uart.h
│ ├── cdctl.c
│ ├── cdctl.h
│ ├── cdctl_it.c
│ ├── cdctl_it.h
│ ├── cdctl_pll_cal.c
│ ├── cdctl_pll_cal.h
│ ├── cdctl_regs.h
│ ├── crc_hw.c
│ └── modbus_crc.h
└── hw
├── cdbus_bridge_pcb_v6.1.png
└── cdbus_bridge_sch_v6.1.pdf
/Readme.md:
--------------------------------------------------------------------------------
1 | ## CDBUS Bridge
2 |
3 | The `CDBUS Bridge HS` is a USB-to-RS485 (CDBUS) adapter. The USB port supports `High-Speed`, and the RS485 interface supports up to 50 Mbps.
4 |
5 |
6 |
7 |
8 | - The two RS485 ports are internally straight-through, simplifying wiring.
9 |
10 | Switchs Defination:
11 | - S1.1: Force bootloader mode.
12 | - S1.2: In arbitration mode, the maximum limit of `baud_l`:
13 | OFF: Default 1 Mbps; ON: Default 2 Mbps. (modifiable)
14 | - S2.1: Enable pull-up resistor.
15 | - S2.2: Enable termination resistor.
16 | - S2.3: Enable pull-down resistor.
17 | - S2.4: Enable 5V output (disable when using external power supply ≤24V).
18 |
19 | ## Transparent Mode
20 |
21 | - The PC sends complete CDBUS packets (with CRC) via USB serial to the CDBUS Bridge, which forwards them unchanged to the RS-485 bus.
22 | - Data received from RS-485 is sent unchanged back to the PC via USB serial.
23 | - The baud rate set by the PC when opening the USB serial port is used for RS-485 (`baud_l` is automatically limited in arbitration mode).
24 | - The PC must enable the DTR option on the USB serial port.
25 | - The default RS-485 address of the Bridge is 0. To change it, see the next section.
26 |
27 | ## Configuration Mode
28 |
29 | CDBUS GUI Tool: https://github.com/dukelec/cdbus_gui
30 |
31 | When you open the serial port, specify the baud rate as `52685` (`0xcdcd`) to enter the configuration mode.
32 |
33 | The target address should be set to `00:00:ff`.
34 |
35 | After modifying the configuration, write 1 to `save_conf` to save the changes to flash.
36 |
37 | To restore the default configuration, change the value of `magic_code` to a different value, save it to flash, and then power cycle the device.
38 |
39 |
40 |
41 |
42 | ## Download Source Code
43 |
44 | ```
45 | git clone --recursive https://github.com/dukelec/cdbus_bridge
46 | ```
47 |
48 | For other hardware versions, please switch to the corresponding branch.
49 |
50 | ## Test
51 |
52 | ```
53 | git clone --recursive https://github.com/dukelec/cdbus_tools
54 | ```
55 |
56 | ```
57 | cd cdbus_tools/
58 | ./cdbus_terminal.py --help
59 | ```
60 |
61 | We can also use a generic serial debugging tool for loopback testing. For example, to simulate node 02 sending a packet to node 00 (with CRC):
62 | ```
63 | 02 00 01 cd c1 99
64 | ```
65 |
66 | If the hardware works properly, the same packet should be received.
67 |
68 |
--------------------------------------------------------------------------------
/doc/img/cdbridge_v6.1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dukelec/cdbus_bridge/826ad126b42fcb69d50684b164e60fb0b46d0a3f/doc/img/cdbridge_v6.1.jpg
--------------------------------------------------------------------------------
/doc/img/cdbridge_v6.1_case.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dukelec/cdbus_bridge/826ad126b42fcb69d50684b164e60fb0b46d0a3f/doc/img/cdbridge_v6.1_case.jpg
--------------------------------------------------------------------------------
/doc/img/cdgui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dukelec/cdbus_bridge/826ad126b42fcb69d50684b164e60fb0b46d0a3f/doc/img/cdgui.png
--------------------------------------------------------------------------------
/fw_bl/.gitignore:
--------------------------------------------------------------------------------
1 | #
2 | # NOTE! Don't add files that are generated in specific
3 | # subdirectories here. Add them in the ".gitignore" file
4 | # in that subdirectory instead.
5 | #
6 | # NOTE! Please use 'git ls-files -i --exclude-standard'
7 | # command after changing this file, to see if there are
8 | # any tracked files which get ignored after the change.
9 | #
10 | # Normal rules
11 | #
12 | .*
13 | *.log
14 |
15 | build/
16 |
17 | #
18 | # git files that we don't want to ignore even it they are dot-files
19 | #
20 | !.gitignore
21 | !.gitkeep
22 | !.mailmap
23 |
24 | *.orig
25 | *~
26 | \#*#
27 |
28 |
--------------------------------------------------------------------------------
/fw_bl/flash.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | pyocd flash -t at32f405kcu7_4 build/*.hex --pack=$AT32F405_DFP_PACK_FILE
4 |
--------------------------------------------------------------------------------
/fw_bl/libraries/cmsis/cm4/core_support/arm_math_f16.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * @file arm_math_f16.h
3 | * @brief Public header file for f16 function of the CMSIS DSP Library
4 | * @version V1.10.0
5 | * @date 08 July 2021
6 | * Target Processor: Cortex-M and Cortex-A cores
7 | ******************************************************************************/
8 | /*
9 | * Copyright (c) 2010-2021 Arm Limited or its affiliates. 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 _ARM_MATH_F16_H
27 | #define _ARM_MATH_F16_H
28 |
29 | #include "arm_math.h"
30 |
31 | #ifdef __cplusplus
32 | extern "C"
33 | {
34 | #endif
35 |
36 | #include "arm_math_types_f16.h"
37 | #include "dsp/none.h"
38 | #include "dsp/utils.h"
39 | #include "dsp/basic_math_functions_f16.h"
40 | #include "dsp/interpolation_functions_f16.h"
41 | #include "dsp/bayes_functions_f16.h"
42 | #include "dsp/matrix_functions_f16.h"
43 | #include "dsp/complex_math_functions_f16.h"
44 | #include "dsp/statistics_functions_f16.h"
45 | #include "dsp/controller_functions_f16.h"
46 | #include "dsp/support_functions_f16.h"
47 | #include "dsp/distance_functions_f16.h"
48 | #include "dsp/svm_functions_f16.h"
49 | #include "dsp/fast_math_functions_f16.h"
50 | #include "dsp/transform_functions_f16.h"
51 | #include "dsp/filtering_functions_f16.h"
52 |
53 | #ifdef __cplusplus
54 | }
55 | #endif
56 |
57 | #endif /* _ARM_MATH_F16_H */
58 |
59 |
60 |
--------------------------------------------------------------------------------
/fw_bl/libraries/cmsis/cm4/core_support/cmsis_version.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file cmsis_version.h
3 | * @brief CMSIS Core(M) Version definitions
4 | * @version V5.0.5
5 | * @date 02. February 2022
6 | ******************************************************************************/
7 | /*
8 | * Copyright (c) 2009-2022 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 (__clang__)
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 ( 6U) /*!< [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 |
--------------------------------------------------------------------------------
/fw_bl/libraries/cmsis/cm4/device_support/startup/iar/linker/AT32F402xB.icf:
--------------------------------------------------------------------------------
1 | /*###ICF### Section handled by ICF editor, don't touch! ****/
2 | /*-Editor annotation file-*/
3 | /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
4 | /*-Specials-*/
5 | define symbol __ICFEDIT_intvec_start__ = 0x08000000;
6 | /*-Memory Regions-*/
7 | define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
8 | define symbol __ICFEDIT_region_ROM_end__ = 0x0801FFFF;
9 | define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
10 | define symbol __ICFEDIT_region_RAM_end__ = 0x200117FF;
11 | /*-Sizes-*/
12 | define symbol __ICFEDIT_size_cstack__ = 0x1000;
13 | define symbol __ICFEDIT_size_heap__ = 0x1000;
14 | /**** End of ICF editor section. ###ICF###*/
15 |
16 | define memory mem with size = 4G;
17 | define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
18 | define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
19 |
20 | define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
21 | define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
22 |
23 | initialize by copy { readwrite };
24 | do not initialize { section .noinit };
25 |
26 | place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
27 |
28 | place in ROM_region { readonly };
29 | place in RAM_region { readwrite,
30 | block CSTACK, block HEAP };
--------------------------------------------------------------------------------
/fw_bl/libraries/cmsis/cm4/device_support/startup/iar/linker/AT32F402xC.icf:
--------------------------------------------------------------------------------
1 | /*###ICF### Section handled by ICF editor, don't touch! ****/
2 | /*-Editor annotation file-*/
3 | /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
4 | /*-Specials-*/
5 | define symbol __ICFEDIT_intvec_start__ = 0x08000000;
6 | /*-Memory Regions-*/
7 | define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
8 | define symbol __ICFEDIT_region_ROM_end__ = 0x0803FFFF;
9 | define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
10 | define symbol __ICFEDIT_region_RAM_end__ = 0x200197FF;
11 | /*-Sizes-*/
12 | define symbol __ICFEDIT_size_cstack__ = 0x1000;
13 | define symbol __ICFEDIT_size_heap__ = 0x1000;
14 | /**** End of ICF editor section. ###ICF###*/
15 |
16 | define memory mem with size = 4G;
17 | define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
18 | define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
19 |
20 | define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
21 | define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
22 |
23 | initialize by copy { readwrite };
24 | do not initialize { section .noinit };
25 |
26 | place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
27 |
28 | place in ROM_region { readonly };
29 | place in RAM_region { readwrite,
30 | block CSTACK, block HEAP };
--------------------------------------------------------------------------------
/fw_bl/libraries/cmsis/cm4/device_support/startup/iar/linker/AT32F405xB.icf:
--------------------------------------------------------------------------------
1 | /*###ICF### Section handled by ICF editor, don't touch! ****/
2 | /*-Editor annotation file-*/
3 | /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
4 | /*-Specials-*/
5 | define symbol __ICFEDIT_intvec_start__ = 0x08000000;
6 | /*-Memory Regions-*/
7 | define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
8 | define symbol __ICFEDIT_region_ROM_end__ = 0x0801FFFF;
9 | define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
10 | define symbol __ICFEDIT_region_RAM_end__ = 0x200117FF;
11 | /*-Sizes-*/
12 | define symbol __ICFEDIT_size_cstack__ = 0x1000;
13 | define symbol __ICFEDIT_size_heap__ = 0x1000;
14 | /**** End of ICF editor section. ###ICF###*/
15 |
16 | define memory mem with size = 4G;
17 | define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
18 | define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
19 |
20 | define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
21 | define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
22 |
23 | initialize by copy { readwrite };
24 | do not initialize { section .noinit };
25 |
26 | place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
27 |
28 | place in ROM_region { readonly };
29 | place in RAM_region { readwrite,
30 | block CSTACK, block HEAP };
--------------------------------------------------------------------------------
/fw_bl/libraries/cmsis/cm4/device_support/startup/iar/linker/AT32F405xC.icf:
--------------------------------------------------------------------------------
1 | /*###ICF### Section handled by ICF editor, don't touch! ****/
2 | /*-Editor annotation file-*/
3 | /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
4 | /*-Specials-*/
5 | define symbol __ICFEDIT_intvec_start__ = 0x08000000;
6 | /*-Memory Regions-*/
7 | define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
8 | define symbol __ICFEDIT_region_ROM_end__ = 0x0803FFFF;
9 | define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
10 | define symbol __ICFEDIT_region_RAM_end__ = 0x200197FF;
11 | /*-Sizes-*/
12 | define symbol __ICFEDIT_size_cstack__ = 0x1000;
13 | define symbol __ICFEDIT_size_heap__ = 0x1000;
14 | /**** End of ICF editor section. ###ICF###*/
15 |
16 | define memory mem with size = 4G;
17 | define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
18 | define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
19 |
20 | define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
21 | define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
22 |
23 | initialize by copy { readwrite };
24 | do not initialize { section .noinit };
25 |
26 | place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
27 |
28 | place in ROM_region { readonly };
29 | place in RAM_region { readwrite,
30 | block CSTACK, block HEAP };
--------------------------------------------------------------------------------
/fw_bl/libraries/cmsis/cm4/device_support/system_at32f402_405.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file system_at32f402_405.h
4 | * @brief cmsis cortex-m4 system header file.
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | #ifndef __SYSTEM_AT32F402_405_H
26 | #define __SYSTEM_AT32F402_405_H
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | /** @addtogroup CMSIS
33 | * @{
34 | */
35 |
36 | /** @addtogroup AT32F402_405_system
37 | * @{
38 | */
39 |
40 | /** @defgroup AT32F402_405_system_exported_variables
41 | * @{
42 | */
43 | extern unsigned int system_core_clock; /*!< system clock frequency (core clock) */
44 |
45 | /**
46 | * @}
47 | */
48 |
49 | /** @defgroup AT32F402_405_system_exported_functions
50 | * @{
51 | */
52 |
53 | extern void SystemInit(void);
54 | extern void system_core_clock_update(void);
55 | extern void reduce_power_consumption(void);
56 |
57 | /**
58 | * @}
59 | */
60 |
61 | /**
62 | * @}
63 | */
64 |
65 | /**
66 | * @}
67 | */
68 |
69 | #ifdef __cplusplus
70 | }
71 | #endif
72 |
73 | #endif
74 |
75 |
--------------------------------------------------------------------------------
/fw_bl/libraries/drivers/inc/at32f402_405_def.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file at32f402_405_def.h
4 | * @brief at32f402_405 macros header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* Define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __AT32F402_405_DEF_H
27 | #define __AT32F402_405_DEF_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | /* gnu compiler */
34 | #if defined (__GNUC__)
35 | #ifndef ALIGNED_HEAD
36 | #define ALIGNED_HEAD
37 | #endif
38 | #ifndef ALIGNED_TAIL
39 | #define ALIGNED_TAIL __attribute__ ((aligned (4)))
40 | #endif
41 | #endif
42 |
43 | /* arm compiler */
44 | #if defined (__CC_ARM)
45 | #ifndef ALIGNED_HEAD
46 | #define ALIGNED_HEAD __align(4)
47 | #endif
48 | #ifndef ALIGNED_TAIL
49 | #define ALIGNED_TAIL
50 | #endif
51 | #endif
52 |
53 | /* iar compiler */
54 | #if defined (__ICCARM__)
55 | #ifndef ALIGNED_HEAD
56 | #define ALIGNED_HEAD
57 | #endif
58 | #ifndef ALIGNED_TAIL
59 | #define ALIGNED_TAIL
60 | #endif
61 | #endif
62 |
63 | #define UNUSED(x) (void)x /* to avoid gcc/g++ warnings */
64 |
65 | #ifdef __cplusplus
66 | }
67 | #endif
68 |
69 | #endif
70 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/3rd_party/fatfs/source/diskio.h:
--------------------------------------------------------------------------------
1 | /*-----------------------------------------------------------------------/
2 | / Low level disk interface modlue include file (C)ChaN, 2019 /
3 | /-----------------------------------------------------------------------*/
4 |
5 | #ifndef _DISKIO_DEFINED
6 | #define _DISKIO_DEFINED
7 |
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif
11 |
12 | /* Status of Disk Functions */
13 | typedef BYTE DSTATUS;
14 |
15 | /* Results of Disk Functions */
16 | typedef enum {
17 | RES_OK = 0, /* 0: Successful */
18 | RES_ERROR, /* 1: R/W Error */
19 | RES_WRPRT, /* 2: Write Protected */
20 | RES_NOTRDY, /* 3: Not Ready */
21 | RES_PARERR /* 4: Invalid Parameter */
22 | } DRESULT;
23 |
24 |
25 | /*---------------------------------------*/
26 | /* Prototypes for disk control functions */
27 |
28 |
29 | DSTATUS disk_initialize (BYTE pdrv);
30 | DSTATUS disk_status (BYTE pdrv);
31 | DRESULT disk_read (BYTE pdrv, BYTE* buff, LBA_t sector, UINT count);
32 | DRESULT disk_write (BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count);
33 | DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
34 |
35 |
36 | /* Disk Status Bits (DSTATUS) */
37 |
38 | #define STA_NOINIT 0x01 /* Drive not initialized */
39 | #define STA_NODISK 0x02 /* No medium in the drive */
40 | #define STA_PROTECT 0x04 /* Write protected */
41 |
42 |
43 | /* Command code for disk_ioctrl fucntion */
44 |
45 | /* Generic command (Used by FatFs) */
46 | #define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */
47 | #define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */
48 | #define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
49 | #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */
50 | #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */
51 |
52 | /* Generic command (Not used by FatFs) */
53 | #define CTRL_POWER 5 /* Get/Set power status */
54 | #define CTRL_LOCK 6 /* Lock/Unlock media removal */
55 | #define CTRL_EJECT 7 /* Eject media */
56 | #define CTRL_FORMAT 8 /* Create physical format on the media */
57 |
58 | /* MMC/SDC specific ioctl command */
59 | #define MMC_GET_TYPE 10 /* Get card type */
60 | #define MMC_GET_CSD 11 /* Get CSD */
61 | #define MMC_GET_CID 12 /* Get CID */
62 | #define MMC_GET_OCR 13 /* Get OCR */
63 | #define MMC_GET_SDSTAT 14 /* Get SD status */
64 | #define ISDIO_READ 55 /* Read data form SD iSDIO register */
65 | #define ISDIO_WRITE 56 /* Write data to SD iSDIO register */
66 | #define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */
67 |
68 | /* ATA/CF specific ioctl command */
69 | #define ATA_GET_REV 20 /* Get F/W revision */
70 | #define ATA_GET_MODEL 21 /* Get model name */
71 | #define ATA_GET_SN 22 /* Get serial number */
72 |
73 | #ifdef __cplusplus
74 | }
75 | #endif
76 |
77 | #endif
78 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/freertos/source/include/StackMacros.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.4.3
3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * https://www.FreeRTOS.org
23 | * https://github.com/FreeRTOS
24 | *
25 | */
26 |
27 |
28 | #ifndef _MSC_VER /* Visual Studio doesn't support #warning. */
29 | #warning The name of this file has changed to stack_macros.h. Please update your code accordingly. This source file (which has the original name) will be removed in future released.
30 | #endif
31 |
32 | #include "stack_macros.h"
33 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/freertos/source/include/stdint.readme:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.4.3
3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * https://www.FreeRTOS.org
23 | * https://github.com/FreeRTOS
24 | *
25 | */
26 |
27 | #ifndef FREERTOS_STDINT
28 | #define FREERTOS_STDINT
29 |
30 | /*******************************************************************************
31 | * THIS IS NOT A FULL stdint.h IMPLEMENTATION - It only contains the definitions
32 | * necessary to build the FreeRTOS code. It is provided to allow FreeRTOS to be
33 | * built using compilers that do not provide their own stdint.h definition.
34 | *
35 | * To use this file:
36 | *
37 | * 1) Copy this file into the directory that contains your FreeRTOSConfig.h
38 | * header file, as that directory will already be in the compiler's include
39 | * path.
40 | *
41 | * 2) Rename the copied file stdint.h.
42 | *
43 | */
44 |
45 | typedef signed char int8_t;
46 | typedef unsigned char uint8_t;
47 | typedef short int16_t;
48 | typedef unsigned short uint16_t;
49 | typedef long int32_t;
50 | typedef unsigned long uint32_t;
51 |
52 | #endif /* FREERTOS_STDINT */
53 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/freertos/source/include/task.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dukelec/cdbus_bridge/826ad126b42fcb69d50684b164e60fb0b46d0a3f/fw_bl/middlewares/freertos/source/include/task.h
--------------------------------------------------------------------------------
/fw_bl/middlewares/freertos/source/portable/memmang/ReadMe.url:
--------------------------------------------------------------------------------
1 | [{000214A0-0000-0000-C000-000000000046}]
2 | Prop3=19,2
3 | [InternetShortcut]
4 | URL=https://www.FreeRTOS.org/a00111.html
5 | IDList=
6 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usb_drivers/inc/usbd_int.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file usbd_int.h
4 | * @brief usb interrupt header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __USBD_INT_H
27 | #define __USBD_INT_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | /** @addtogroup AT32F402_405_middlewares_usbd_drivers
34 | * @{
35 | */
36 |
37 | /** @addtogroup USBD_drivers_int
38 | * @{
39 | */
40 |
41 | /** @defgroup USBD_interrupt_exported_types
42 | * @{
43 | */
44 | /* includes ------------------------------------------------------------------*/
45 | #include "usbd_core.h"
46 | #include "usb_core.h"
47 |
48 | void usbd_irq_handler(otg_core_type *udev);
49 | void usbd_ept_handler(usbd_core_type *udev);
50 | void usbd_reset_handler(usbd_core_type *udev);
51 | void usbd_sof_handler(usbd_core_type *udev);
52 | void usbd_suspend_handler(usbd_core_type *udev);
53 | void usbd_wakeup_handler(usbd_core_type *udev);
54 | void usbd_inept_handler(usbd_core_type *udev);
55 | void usbd_outept_handler(usbd_core_type *udev);
56 | void usbd_ep1_in_handler(usbd_core_type *udev);
57 | void usbd_ep1_out_handler(usbd_core_type *udev);
58 | void usbd_enumdone_handler(usbd_core_type *udev);
59 | void usbd_rxflvl_handler(usbd_core_type *udev);
60 | void usbd_incomisioin_handler(usbd_core_type *udev);
61 | void usbd_discon_handler(usbd_core_type *udev);
62 | void usbd_incomisoout_handler(usbd_core_type *udev);
63 | void usb_write_empty_txfifo(usbd_core_type *udev, uint32_t ept_num);
64 |
65 | /**
66 | * @}
67 | */
68 |
69 | /**
70 | * @}
71 | */
72 |
73 | /**
74 | * @}
75 | */
76 |
77 | #ifdef __cplusplus
78 | }
79 | #endif
80 |
81 | #endif
82 |
83 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usb_drivers/inc/usbd_sdr.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file usb_sdr.h
4 | * @brief usb header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __USB_SDR_H
27 | #define __USB_SDR_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 |
34 | /* includes ------------------------------------------------------------------*/
35 | #include "usb_conf.h"
36 | #include "usb_core.h"
37 | /** @addtogroup AT32F402_405_middlewares_usbd_drivers
38 | * @{
39 | */
40 |
41 | /** @addtogroup USBD_drivers_standard_request
42 | * @{
43 | */
44 |
45 | /** @defgroup USBD_sdr_exported_functions
46 | * @{
47 | */
48 |
49 |
50 | void usbd_setup_request_parse(usb_setup_type *setup, uint8_t *buf);
51 | usb_sts_type usbd_device_request(usbd_core_type *udev);
52 | usb_sts_type usbd_interface_request(usbd_core_type *udev);
53 | usb_sts_type usbd_endpoint_request(usbd_core_type *udev);
54 |
55 |
56 | /**
57 | * @}
58 | */
59 |
60 | /**
61 | * @}
62 | */
63 |
64 | /**
65 | * @}
66 | */
67 | #ifdef __cplusplus
68 | }
69 | #endif
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usb_drivers/inc/usbh_int.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file usbh_int.h
4 | * @brief usb header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __USBH_INT_H
27 | #define __USBH_INT_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | /** @addtogroup AT32F402_405_middlewares_usbh_drivers
34 | * @{
35 | */
36 |
37 | /** @addtogroup USBH_drivers_int
38 | * @{
39 | */
40 |
41 | /** @defgroup USBH_interrupt_exported_types
42 | * @{
43 | */
44 |
45 | /* includes ------------------------------------------------------------------*/
46 | #include "usbh_core.h"
47 | #include "usb_core.h"
48 | void usbh_irq_handler(otg_core_type *hdev);
49 | void usbh_hch_handler(usbh_core_type *uhost);
50 | void usbh_port_handler(usbh_core_type *uhost);
51 | void usbh_disconnect_handler(usbh_core_type *uhost);
52 | void usbh_hch_in_handler(usbh_core_type *uhost, uint8_t chn);
53 | void usbh_hch_out_handler(usbh_core_type *uhost, uint8_t chn);
54 | void usbh_rx_qlvl_handler(usbh_core_type *uhost);
55 | void usbh_wakeup_handler(usbh_core_type *uhost);
56 | void usbh_sof_handler(usbh_core_type *uhost);
57 |
58 | /**
59 | * @}
60 | */
61 |
62 | /**
63 | * @}
64 | */
65 |
66 | /**
67 | * @}
68 | */
69 |
70 | #ifdef __cplusplus
71 | }
72 | #endif
73 |
74 | #endif
75 |
76 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usbd_class/audio/audio_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file audio_conf.h
4 | * @brief usb audio config
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __AUDIO_CONF_H
27 | #define __AUDIO_CONF_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 |
34 | /** @addtogroup AT32F402_405_middlewares_usbd_class
35 | * @{
36 | */
37 |
38 | /** @addtogroup USB_audio_class
39 | * @{
40 | */
41 |
42 | /** @defgroup USB_device_audio_config_definition
43 | * @{
44 | */
45 | #define AUDIO_SUPPORT_SPK 1
46 | #define AUDIO_SUPPORT_MIC 1
47 | #define AUDIO_SUPPORT_FEEDBACK 1
48 |
49 | #define AUDIO_SUPPORT_FREQ_16K 0
50 | #define AUDIO_SUPPORT_FREQ_48K 1
51 |
52 |
53 | #define AUDIO_SUPPORT_FREQ (AUDIO_SUPPORT_FREQ_16K + \
54 | AUDIO_SUPPORT_FREQ_48K \
55 | )
56 |
57 | #define AUDIO_FREQ_16K 16000
58 | #define AUDIO_FREQ_48K 48000
59 | #define AUDIO_BITW_16 16
60 |
61 | #define AUDIO_MIC_CHANEL_NUM 2
62 | #define AUDIO_MIC_DEFAULT_BITW AUDIO_BITW_16
63 |
64 | #define AUDIO_SPK_CHANEL_NUM 2
65 | #define AUDIO_SPK_DEFAULT_BITW AUDIO_BITW_16
66 |
67 |
68 | #define AUDIO_SUPPORT_MAX_FREQ 48
69 | #define AUDIO_DEFAULT_FREQ AUDIO_FREQ_48K
70 | #define AUDIO_DEFAULT_BITW AUDIO_BITW_16
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /**
77 | * @}
78 | */
79 |
80 | /**
81 | * @}
82 | */
83 | #ifdef __cplusplus
84 | }
85 | #endif
86 |
87 | #endif
88 |
89 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usbd_class/audio_hid/audio_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file audio_conf.h
4 | * @brief usb audio config
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __AUDIO_CONF_H
27 | #define __AUDIO_CONF_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 |
34 | /** @addtogroup AT32F402_405_middlewares_usbd_class
35 | * @{
36 | */
37 |
38 | /** @addtogroup USB_audio_hid_class
39 | * @{
40 | */
41 |
42 | /** @defgroup USB_device_audio_hid_config_definition
43 | * @{
44 | */
45 | #define AUDIO_SUPPORT_SPK 1
46 | #define AUDIO_SUPPORT_MIC 1
47 | #define AUDIO_SUPPORT_FEEDBACK 1
48 |
49 | #define AUDIO_SUPPORT_FREQ_16K 0
50 | #define AUDIO_SUPPORT_FREQ_48K 1
51 |
52 |
53 | #define AUDIO_SUPPORT_FREQ (AUDIO_SUPPORT_FREQ_16K + \
54 | AUDIO_SUPPORT_FREQ_48K \
55 | )
56 |
57 | #define AUDIO_FREQ_16K 16000
58 | #define AUDIO_FREQ_48K 48000
59 | #define AUDIO_BITW_16 16
60 |
61 | #define AUDIO_MIC_CHANEL_NUM 2
62 | #define AUDIO_MIC_DEFAULT_BITW AUDIO_BITW_16
63 |
64 | #define AUDIO_SPK_CHANEL_NUM 2
65 | #define AUDIO_SPK_DEFAULT_BITW AUDIO_BITW_16
66 |
67 |
68 | #define AUDIO_SUPPORT_MAX_FREQ 48
69 | #define AUDIO_DEFAULT_FREQ AUDIO_FREQ_48K
70 | #define AUDIO_DEFAULT_BITW AUDIO_BITW_16
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /**
77 | * @}
78 | */
79 |
80 | /**
81 | * @}
82 | */
83 | #ifdef __cplusplus
84 | }
85 | #endif
86 |
87 | #endif
88 |
89 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usbd_class/cdc/cdc_desc.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file cdc_desc.h
4 | * @brief usb cdc descriptor header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __CDC_DESC_H
27 | #define __CDC_DESC_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "cdc_class.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_cdc_desc
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_cdc_desc_definition
45 | * @{
46 | */
47 | /**
48 | * @brief usb bcd number define
49 | */
50 | #define CDC_BCD_NUM 0x0110
51 |
52 | /**
53 | * @brief usb vendor id and product id define
54 | */
55 | #define USBD_CDC_VENDOR_ID 0x2E3C
56 | #define USBD_CDC_PRODUCT_ID 0x5740
57 |
58 | /**
59 | * @brief usb descriptor size define
60 | */
61 | #define USBD_CDC_CONFIG_DESC_SIZE 67
62 | #define USBD_CDC_SIZ_STRING_LANGID 4
63 | #define USBD_CDC_SIZ_STRING_SERIAL 0x1A
64 |
65 | /**
66 | * @brief usb string define(vendor, product configuration, interface)
67 | */
68 | #define USBD_CDC_DESC_MANUFACTURER_STRING "Artery"
69 | #define USBD_CDC_DESC_PRODUCT_STRING "AT32 Virtual Com Port "
70 | #define USBD_CDC_DESC_CONFIGURATION_STRING "Virtual ComPort Config"
71 | #define USBD_CDC_DESC_INTERFACE_STRING "Virtual ComPort Interface"
72 |
73 | /**
74 | * @brief usb endpoint interval define
75 | */
76 | #define CDC_HID_BINTERVAL_TIME 0xFF
77 |
78 | /**
79 | * @brief usb mcu id address deine
80 | */
81 | #define MCU_ID1 (0x1FFFF7E8)
82 | #define MCU_ID2 (0x1FFFF7EC)
83 | #define MCU_ID3 (0x1FFFF7F0)
84 | /**
85 | * @}
86 | */
87 |
88 | extern usbd_desc_handler cdc_desc_handler;
89 |
90 |
91 | /**
92 | * @}
93 | */
94 |
95 | /**
96 | * @}
97 | */
98 | #ifdef __cplusplus
99 | }
100 | #endif
101 |
102 | #endif
103 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usbd_class/custom_hid/custom_hid_class.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file custom_hid_class.h
4 | * @brief usb hid header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __CUSTOM_HID_CLASS_H
27 | #define __CUSTOM_HID_CLASS_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "usb_std.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_custom_hid_class
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_custom_hid_class_endpoint_definition
45 | * @{
46 | */
47 |
48 | /**
49 | * @brief usb custom hid use endpoint define
50 | */
51 | #define USBD_CUSTOM_HID_IN_EPT 0x81
52 | #define USBD_CUSTOM_HID_OUT_EPT 0x01
53 |
54 | /**
55 | * @brief usb custom hid in and out max packet size define
56 | */
57 | #define USBD_CUSTOM_IN_MAXPACKET_SIZE 0x40
58 | #define USBD_CUSTOM_OUT_MAXPACKET_SIZE 0x40
59 |
60 | /**
61 | * @}
62 | */
63 |
64 | /** @defgroup USB_custom_hid_class_request_code_definition
65 | * @{
66 | */
67 |
68 | typedef struct
69 | {
70 | uint8_t g_rxhid_buff[USBD_CUSTOM_OUT_MAXPACKET_SIZE];
71 | uint8_t g_txhid_buff[USBD_CUSTOM_IN_MAXPACKET_SIZE];
72 |
73 | uint32_t hid_protocol;
74 | uint32_t hid_set_idle;
75 | uint32_t alt_setting;
76 |
77 | uint8_t hid_set_report[64];
78 | uint8_t hid_get_report[64];
79 | uint8_t hid_state;
80 | uint8_t send_state;
81 | }custom_hid_type;
82 |
83 | /**
84 | * @}
85 | */
86 |
87 | /** @defgroup USB_custom_hid_class_exported_functions
88 | * @{
89 | */
90 | extern usbd_class_handler custom_hid_class_handler;
91 | usb_sts_type custom_hid_class_send_report(void *udev, uint8_t *report, uint16_t len);
92 | /**
93 | * @}
94 | */
95 | /**
96 | * @}
97 | */
98 |
99 | /**
100 | * @}
101 | */
102 | #ifdef __cplusplus
103 | }
104 | #endif
105 |
106 | #endif
107 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usbd_class/hid_iap/hid_iap_desc.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file hid_iap_desc.h
4 | * @brief usb hid iap descriptor header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __HID_IAP_DESC_H
27 | #define __HID_IAP_DESC_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "hid_iap_class.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_hid_iap_desc
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_hid_iap_desc_definition
45 | * @{
46 | */
47 |
48 |
49 | #define HIDIAP_BCD_NUM 0x0110
50 |
51 | #define USBD_HIDIAP_VENDOR_ID 0x2E3C
52 | #define USBD_HIDIAP_PRODUCT_ID 0xAF01
53 |
54 | #define USBD_HIDIAP_CONFIG_DESC_SIZE 41
55 | #define USBD_HIDIAP_SIZ_REPORT_DESC 32
56 | #define USBD_HIDIAP_SIZ_STRING_LANGID 4
57 | #define USBD_HIDIAP_SIZ_STRING_SERIAL 0x1A
58 |
59 | #define USBD_HIDIAP_DESC_MANUFACTURER_STRING "Artery"
60 | #define USBD_HIDIAP_DESC_PRODUCT_STRING "HID IAP"
61 | #define USBD_HIDIAP_DESC_CONFIGURATION_STRING "HID IAP Config"
62 | #define USBD_HIDIAP_DESC_INTERFACE_STRING "HID IAP Interface"
63 |
64 | #define HIDIAP_BINTERVAL_TIME 0x01
65 |
66 | #define MCU_ID1 (0x1FFFF7E8)
67 | #define MCU_ID2 (0x1FFFF7EC)
68 | #define MCU_ID3 (0x1FFFF7F0)
69 | extern uint8_t g_usbd_hidiap_report[USBD_HIDIAP_SIZ_REPORT_DESC];
70 | extern uint8_t g_hidiap_usb_desc[9];
71 |
72 | extern usbd_desc_handler hid_iap_desc_handler;
73 |
74 |
75 | /**
76 | * @}
77 | */
78 |
79 | /**
80 | * @}
81 | */
82 |
83 |
84 | /**
85 | * @}
86 | */
87 | #ifdef __cplusplus
88 | }
89 | #endif
90 |
91 | #endif
92 |
93 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usbd_class/keyboard/keyboard_class.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file keyboard_class.h
4 | * @brief usb hid keyboard header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __KEYBOARD_CLASS_H
27 | #define __KEYBOARD_CLASS_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "usb_std.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_keyboard_class
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_keyboard_class_endpoint_definition
45 | * @{
46 | */
47 |
48 | /**
49 | * @brief usb hid use endpoint define
50 | */
51 | #define USBD_KEYBOARD_IN_EPT 0x81
52 |
53 | /**
54 | * @brief usb hid in and out max packet size define
55 | */
56 | #define USBD_KEYBOARD_IN_MAXPACKET_SIZE 0x40
57 | #define USBD_KEYBOARD_OUT_MAXPACKET_SIZE 0x40
58 |
59 | /**
60 | * @}
61 | */
62 |
63 |
64 | typedef struct
65 | {
66 | uint32_t hid_protocol;
67 | uint32_t hid_set_idle;
68 | uint32_t alt_setting;
69 | uint8_t hid_set_report[64];
70 | uint8_t keyboard_buf[8];
71 |
72 | __IO uint8_t hid_suspend_flag;
73 | __IO uint8_t g_u8tx_completed;
74 | uint8_t hid_state;
75 | uint8_t temp;
76 |
77 | }keyboard_type;
78 |
79 | /** @defgroup USB_hid_class_exported_functions
80 | * @{
81 | */
82 | extern usbd_class_handler keyboard_class_handler;
83 |
84 | usb_sts_type usb_keyboard_class_send_report(void *udev, uint8_t *report, uint16_t len);
85 | void usb_hid_keyboard_send_char(void *udev, uint8_t ascii_code);
86 | /**
87 | * @}
88 | */
89 |
90 | /**
91 | * @}
92 | */
93 |
94 | /**
95 | * @}
96 | */
97 | #ifdef __cplusplus
98 | }
99 | #endif
100 |
101 | #endif
102 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usbd_class/msc/msc_class.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file msc_class.h
4 | * @brief usb msc class file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 | /* define to prevent recursive inclusion -------------------------------------*/
25 | #ifndef __MSC_CLASS_H
26 | #define __MSC_CLASS_H
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | #include "usb_std.h"
33 | #include "usbd_core.h"
34 |
35 | /** @addtogroup AT32F402_405_middlewares_usbd_class
36 | * @{
37 | */
38 |
39 | /** @addtogroup USB_msc_class
40 | * @{
41 | */
42 |
43 | /** @defgroup USB_msc_class_definition
44 | * @{
45 | */
46 |
47 | #define USBD_MSC_BULK_IN_EPT 0x81
48 | #define USBD_MSC_BULK_OUT_EPT 0x01
49 |
50 | #define USBD_IN_MAXPACKET_SIZE 0x40
51 | #define USBD_OUT_MAXPACKET_SIZE 0x40
52 |
53 | #define USBD_HS_IN_MAXPACKET_SIZE 0x200
54 | #define USBD_HS_OUT_MAXPACKET_SIZE 0x200
55 |
56 |
57 | extern usbd_class_handler msc_class_handler;
58 | /**
59 | * @}
60 | */
61 |
62 | /**
63 | * @}
64 | */
65 |
66 | /**
67 | * @}
68 | */
69 | #ifdef __cplusplus
70 | }
71 | #endif
72 |
73 | #endif
74 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usbd_class/msc/msc_desc.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file msc_desc.h
4 | * @brief usb msc descriptor header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __MSC_DESC_H
27 | #define __MSC_DESC_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "msc_class.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_msc_desc
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_msc_desc_definition
45 | * @{
46 | */
47 |
48 | #define MSC_BCD_NUM 0x0110
49 |
50 | #define USBD_MSC_VENDOR_ID 0x2E3C
51 | #define USBD_MSC_PRODUCT_ID 0x5720
52 |
53 | #define USBD_MSC_CONFIG_DESC_SIZE 32
54 | #define USBD_MSC_SIZ_STRING_LANGID 4
55 | #define USBD_MSC_SIZ_STRING_SERIAL 0x1A
56 |
57 | #define USBD_MSC_DESC_MANUFACTURER_STRING "Artery"
58 | #define USBD_MSC_DESC_PRODUCT_STRING "AT32 Mass Storage"
59 | #define USBD_MSC_DESC_CONFIGURATION_STRING "Mass Storage Config"
60 | #define USBD_MSC_DESC_INTERFACE_STRING "Mass Storage Interface"
61 |
62 | #define MCU_ID1 (0x1FFFF7E8)
63 | #define MCU_ID2 (0x1FFFF7EC)
64 | #define MCU_ID3 (0x1FFFF7F0)
65 |
66 | extern usbd_desc_handler msc_desc_handler;
67 |
68 | /**
69 | * @}
70 | */
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /**
77 | * @}
78 | */
79 | #ifdef __cplusplus
80 | }
81 | #endif
82 |
83 | #endif
84 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usbd_class/printer/printer_class.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file printer_class.h
4 | * @brief usb cdc class file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __PRINTER_CLASS_H
27 | #define __PRINTER_CLASS_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "usb_std.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_printer_class
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_printer_class_definition
45 | * @{
46 | */
47 |
48 | #define USBD_PRINTER_BULK_IN_EPT 0x81
49 | #define USBD_PRINTER_BULK_OUT_EPT 0x01
50 |
51 | #define USBD_PRINTER_MAXPACKET_SIZE 0x40
52 | #define USBD_PRINTER_IN_MAXPACKET_SIZE USBD_PRINTER_MAXPACKET_SIZE
53 | #define USBD_PRINTER_OUT_MAXPACKET_SIZE USBD_PRINTER_MAXPACKET_SIZE
54 |
55 | #define USBD_HS_PRINTER_MAXPACKET_SIZE 0x100
56 | #define USBD_HS_PRINTER_IN_MAXPACKET_SIZE USBD_HS_PRINTER_MAXPACKET_SIZE
57 | #define USBD_HS_PRINTER_OUT_MAXPACKET_SIZE USBD_HS_PRINTER_MAXPACKET_SIZE
58 |
59 | #define PRINTER_DEVICE_ID_LEN 24
60 |
61 | typedef enum
62 | {
63 | PRINTER_REQ_GET_DEVICE_ID = 0x00,
64 | PRINTER_REQ_GET_PORT_STATUS = 0x01,
65 | PRINTER_REQ_GET_SOFT_RESET = 0x02
66 | }printer_req_type;
67 |
68 |
69 | typedef struct
70 | {
71 | uint32_t alt_setting;
72 | uint32_t g_printer_port_status;
73 | uint8_t *g_rx_buff;
74 | uint8_t *g_printer_data;
75 | uint32_t g_rxlen;
76 | __IO uint8_t g_tx_completed;
77 | __IO uint8_t g_rx_completed;
78 | uint32_t maxpacket;
79 | }printer_type;
80 |
81 | extern usbd_class_handler printer_class_handler;
82 | uint16_t usb_printer_get_rxdata(void *udev, uint8_t *recv_data);
83 | error_status usb_printer_send_data(void *udev, uint8_t *send_data, uint16_t len);
84 | /**
85 | * @}
86 | */
87 |
88 | /**
89 | * @}
90 | */
91 |
92 | /**
93 | * @}
94 | */
95 | #ifdef __cplusplus
96 | }
97 | #endif
98 |
99 | #endif
100 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usbd_class/printer/printer_desc.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file printer_desc.h
4 | * @brief usb printer descriptor header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __PRINTER_DESC_H
27 | #define __PRINTER_DESC_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "printer_class.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_printer_desc
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_printer_desc_definition
45 | * @{
46 | */
47 |
48 | #define PRINTER_BCD_NUM 0x0110
49 |
50 | #define USBD_PRINTER_VENDOR_ID 0x2E3C
51 | #define USBD_PRINTER_PRODUCT_ID 0x57FF
52 |
53 | #define USBD_PRINTER_CONFIG_DESC_SIZE 32
54 | #define USBD_PRINTER_SIZ_STRING_LANGID 4
55 | #define USBD_PRINTER_SIZ_STRING_SERIAL 0x1A
56 |
57 | #define USBD_PRINTER_DESC_MANUFACTURER_STRING "Artery"
58 | #define USBD_PRINTER_DESC_PRODUCT_STRING "AT32 Printer"
59 | #define USBD_PRINTER_DESC_CONFIGURATION_STRING "Printer Config"
60 | #define USBD_PRINTER_DESC_INTERFACE_STRING "Printer Interface"
61 |
62 | #define PRINTER_PROTOCOL_UNIDIRECTIONAL 0x01
63 | #define PRINTER_PROTOCOL_BI_DIRECTIONAL 0x02
64 | #define PRINTER_PROTOCOL_1284_4 0x03
65 | #define PRINTER_PROTOCOL_VENDOR_SPECIFIC 0xFF
66 |
67 |
68 | #define MCU_ID1 (0x1FFFF7E8)
69 | #define MCU_ID2 (0x1FFFF7EC)
70 | #define MCU_ID3 (0x1FFFF7F0)
71 |
72 |
73 | extern usbd_desc_handler printer_desc_handler;
74 |
75 | /**
76 | * @}
77 | */
78 |
79 | /**
80 | * @}
81 | */
82 |
83 | /**
84 | * @}
85 | */
86 | #ifdef __cplusplus
87 | }
88 | #endif
89 |
90 | #endif
91 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usbd_class/winusb/winusb_desc.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file winusb_desc.h
4 | * @brief usb winusb descriptor header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __WINUSB_DESC_H
27 | #define __WINUSB_DESC_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "winusb_class.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_winusb_desc
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_winusb_desc_definition
45 | * @{
46 | */
47 | /**
48 | * @brief usb vendor id and product id define
49 | */
50 | #define USBD_WINUSB_VENDOR_ID 0x2E3C
51 | #define USBD_WINUSB_PRODUCT_ID 0x5780
52 |
53 | /**
54 | * @brief usb descriptor size define
55 | */
56 | #define USBD_WINUSB_CONFIG_DESC_SIZE 32
57 | #define USBD_WINUSB_SIZ_STRING_LANGID 4
58 | #define USBD_WINUSB_SIZ_STRING_SERIAL 0x1A
59 |
60 | /**
61 | * @brief usb string define(vendor, product configuration, interface)
62 | */
63 | #define USBD_WINUSB_DESC_MANUFACTURER_STRING "Artery"
64 | #define USBD_WINUSB_DESC_PRODUCT_STRING "AT32 WinUSB"
65 | #define USBD_WINUSB_DESC_CONFIGURATION_STRING "WinUSB Config"
66 | #define USBD_WINUSB_DESC_INTERFACE_STRING "WinUSB Interface"
67 |
68 | /**
69 | * @brief usb mcu id address deine
70 | */
71 | #define MCU_ID1 (0x1FFFF7E8)
72 | #define MCU_ID2 (0x1FFFF7EC)
73 | #define MCU_ID3 (0x1FFFF7F0)
74 | /**
75 | * @}
76 | */
77 |
78 | extern usbd_desc_handler winusb_desc_handler;
79 |
80 |
81 | /**
82 | * @}
83 | */
84 |
85 | /**
86 | * @}
87 | */
88 | #ifdef __cplusplus
89 | }
90 | #endif
91 |
92 | #endif
93 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usbh_class/usbh_hid/usbh_hid_keyboard.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file usbh_hid_keyboard.h
4 | * @brief usb host hid keyboard header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 | /* Define to prevent recursive inclusion -------------------------------------*/
25 | #ifndef __USBH_HID_KEYBOARD_H
26 | #define __USBH_HID_KEYBOARD_H
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | #include "usb_conf.h"
33 |
34 | /** @addtogroup AT32F402_405_middlewares_usbh_class
35 | * @{
36 | */
37 |
38 | /** @addtogroup USBH_hid_class_keyboard
39 | * @{
40 | */
41 |
42 | /** @defgroup USBH_hid_class_keyboard_definition
43 | * @{
44 | */
45 |
46 | /**
47 | * @brief usb keyboard option code
48 | */
49 | #define KEYBOARD_LEFT_CTRL 0x01
50 | #define KEYBOARD_LEFT_SHIFT 0x02
51 | #define KEYBOARD_LEFT_ALT 0x04
52 | #define KEYBOARD_LEFT_GUI 0x08
53 | #define KEYBOARD_RIGHT_CTRL 0x10
54 | #define KEYBOARD_RIGHT_SHIFT 0x20
55 | #define KEYBOARD_RIGHT_ALT 0x40
56 | #define KEYBOARD_RIGHT_GUI 0x80
57 |
58 | #define KEYBOARD_MAX_NB_PRESSED 6
59 |
60 | #ifndef AZERTY_KEYBOARD
61 | #define QWERTY_KEYBOARD
62 | #endif
63 |
64 | void usbh_hid_keyboard_decode(uint8_t *data);
65 |
66 |
67 | /**
68 | * @}
69 | */
70 |
71 | /**
72 | * @}
73 | */
74 |
75 | /**
76 | * @}
77 | */
78 | #ifdef __cplusplus
79 | }
80 | #endif
81 |
82 | #endif
83 |
--------------------------------------------------------------------------------
/fw_bl/middlewares/usbh_class/usbh_hid/usbh_hid_mouse.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file usbh_hid_mouse.h
4 | * @brief usb host hid mouse header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 | /* Define to prevent recursive inclusion -------------------------------------*/
25 | #ifndef __USBH_HID_MOUSE_H
26 | #define __USBH_HID_MOUSE_H
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | #include "usb_conf.h"
33 |
34 | /** @addtogroup AT32F402_405_middlewares_usbh_class
35 | * @{
36 | */
37 |
38 | /** @addtogroup USBH_hid_class_mouse
39 | * @{
40 | */
41 |
42 | /** @defgroup USBH_hid_class_mouse_definition
43 | * @{
44 | */
45 |
46 | /**
47 | * @brief usb hid mouse x y
48 | */
49 | #define MOUSE_WINDOW_X 100
50 | #define MOUSE_WINDOW_Y 220
51 | #define MOUSE_WINDOW_HEIGHT 90
52 | #define MOUSE_WINDOW_WIDTH 128
53 |
54 | /**
55 | * @brief usb hid mouse button
56 | */
57 | #define MOUSE_BUTTON_LEFT 0x00
58 | #define MOUSE_BUTTON_RIGHT 0x01
59 | #define MOUSE_BUTTON_MIDDLE 0x02
60 |
61 | /**
62 | * @brief usb hid mouse type
63 | */
64 | typedef struct
65 | {
66 | uint8_t button;
67 | uint8_t x;
68 | uint8_t y;
69 | uint8_t z;
70 | }usb_hid_mouse_type;
71 |
72 | void usbh_hid_mouse_decode(uint8_t *mouse_data);
73 |
74 |
75 | /**
76 | * @}
77 | */
78 |
79 | /**
80 | * @}
81 | */
82 |
83 | /**
84 | * @}
85 | */
86 | #ifdef __cplusplus
87 | }
88 | #endif
89 |
90 | #endif
91 |
92 |
--------------------------------------------------------------------------------
/fw_bl/project/Eclipse_gcc/.settings/language.settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/fw_bl/project/Eclipse_gcc/.settings/org.eclipse.core.runtime.prefs:
--------------------------------------------------------------------------------
1 | content-types/enabled=true
2 | content-types/org.eclipse.cdt.core.asmSource/file-extensions=s
3 | eclipse.preferences.version=1
4 |
--------------------------------------------------------------------------------
/fw_bl/project/inc/at32f402_405_int.h:
--------------------------------------------------------------------------------
1 | /* add user code begin Header */
2 | /**
3 | **************************************************************************
4 | * @file at32f402_405_int.h
5 | * @brief header file of main interrupt service routines.
6 | **************************************************************************
7 | * Copyright notice & Disclaimer
8 | *
9 | * The software Board Support Package (BSP) that is made available to
10 | * download from Artery official website is the copyrighted work of Artery.
11 | * Artery authorizes customers to use, copy, and distribute the BSP
12 | * software and its related documentation for the purpose of design and
13 | * development in conjunction with Artery microcontrollers. Use of the
14 | * software is governed by this copyright notice and the following disclaimer.
15 | *
16 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
17 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
18 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
19 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
20 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
22 | *
23 | **************************************************************************
24 | */
25 | /* add user code end Header */
26 |
27 | /* define to prevent recursive inclusion -------------------------------------*/
28 | #ifndef __AT32F402_405_INT_H
29 | #define __AT32F402_405_INT_H
30 |
31 | #ifdef __cplusplus
32 | extern "C" {
33 | #endif
34 |
35 | /* includes ------------------------------------------------------------------*/
36 | #include "at32f402_405.h"
37 |
38 | /* private includes ----------------------------------------------------------*/
39 | /* add user code begin private includes */
40 |
41 | /* add user code end private includes */
42 |
43 | /* exported types ------------------------------------------------------------*/
44 | /* add user code begin exported types */
45 |
46 | /* add user code end exported types */
47 |
48 | /* exported constants --------------------------------------------------------*/
49 | /* add user code begin exported constants */
50 |
51 | /* add user code end exported constants */
52 |
53 | /* exported macro ------------------------------------------------------------*/
54 | /* add user code begin exported macro */
55 |
56 | /* add user code end exported macro */
57 |
58 | /* exported functions ------------------------------------------------------- */
59 | void NMI_Handler(void);
60 | void HardFault_Handler(void);
61 | void MemManage_Handler(void);
62 | void BusFault_Handler(void);
63 | void UsageFault_Handler(void);
64 | void SVC_Handler(void);
65 | void DebugMon_Handler(void);
66 | void PendSV_Handler(void);
67 |
68 | void SysTick_Handler(void);
69 |
70 | void OTGHS_IRQHandler(void);
71 | /* add user code begin exported functions */
72 |
73 | /* add user code end exported functions */
74 |
75 | #ifdef __cplusplus
76 | }
77 | #endif
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/fw_bl/project/inc/cdc_desc.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file cdc_desc.h
4 | * @brief usb cdc descriptor header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __CDC_DESC_H
27 | #define __CDC_DESC_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "cdc_class.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_cdc_desc
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_cdc_desc_definition
45 | * @{
46 | */
47 | /**
48 | * @brief usb bcd number define
49 | */
50 | #define CDC_BCD_NUM 0x0110
51 |
52 | /**
53 | * @brief usb vendor id and product id define
54 | */
55 | #define USBD_CDC_VENDOR_ID 0x2E3C
56 | #define USBD_CDC_PRODUCT_ID 0x5740
57 |
58 | /**
59 | * @brief usb descriptor size define
60 | */
61 | #define USBD_CDC_CONFIG_DESC_SIZE 67
62 | #define USBD_CDC_SIZ_STRING_LANGID 4
63 | #define USBD_CDC_SIZ_STRING_SERIAL 0x1A
64 |
65 | /**
66 | * @brief usb string define(vendor, product configuration, interface)
67 | */
68 | #define USBD_CDC_DESC_MANUFACTURER_STRING "DUKELEC"
69 | #define USBD_CDC_DESC_PRODUCT_STRING "CDBUS Bridge (BL)"
70 | #define USBD_CDC_DESC_CONFIGURATION_STRING "Virtual ComPort Config"
71 | #define USBD_CDC_DESC_INTERFACE_STRING "Virtual ComPort Interface"
72 |
73 | /**
74 | * @brief usb endpoint interval define
75 | */
76 | #define CDC_HID_BINTERVAL_TIME 0xFF
77 |
78 | /**
79 | * @brief usb mcu id address deine
80 | */
81 | #define MCU_ID1 (0x1FFFF7E8)
82 | #define MCU_ID2 (0x1FFFF7EC)
83 | #define MCU_ID3 (0x1FFFF7F0)
84 | /**
85 | * @}
86 | */
87 |
88 | extern usbd_desc_handler cdc_desc_handler;
89 |
90 |
91 | /**
92 | * @}
93 | */
94 |
95 | /**
96 | * @}
97 | */
98 | #ifdef __cplusplus
99 | }
100 | #endif
101 |
102 | #endif
103 |
--------------------------------------------------------------------------------
/fw_bl/project/inc/usb_app.h:
--------------------------------------------------------------------------------
1 | /* add user code begin Header */
2 | /**
3 | **************************************************************************
4 | * @file usb_app.h
5 | * @brief usb application config header file
6 | **************************************************************************
7 | * Copyright notice & Disclaimer
8 | *
9 | * The software Board Support Package (BSP) that is made available to
10 | * download from Artery official website is the copyrighted work of Artery.
11 | * Artery authorizes customers to use, copy, and distribute the BSP
12 | * software and its related documentation for the purpose of design and
13 | * development in conjunction with Artery microcontrollers. Use of the
14 | * software is governed by this copyright notice and the following disclaimer.
15 | *
16 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
17 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
18 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
19 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
20 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
22 | *
23 | **************************************************************************
24 | */
25 | /* add user code end Header */
26 |
27 | /* define to prevent recursive inclusion -------------------------------------*/
28 | #ifndef __USB_APP_H
29 | #define __USB_APP_H
30 |
31 | #ifdef __cplusplus
32 | extern "C" {
33 | #endif
34 |
35 | /* private includes -------------------------------------------------------------*/
36 | /* add user code begin private includes */
37 |
38 | /* add user code end private includes */
39 |
40 | /* private define ------------------------------------------------------------*/
41 | /* add user code begin private define */
42 |
43 | /* add user code end private define */
44 |
45 | /* exported types -------------------------------------------------------------*/
46 | /* add user code begin exported types */
47 |
48 | /* add user code end exported types */
49 |
50 | /* exported constants --------------------------------------------------------*/
51 | /* add user code begin exported constants */
52 |
53 | /* add user code end exported constants */
54 |
55 | /* exported macro ------------------------------------------------------------*/
56 | /* add user code begin exported macro */
57 |
58 | /* add user code end exported macro */
59 |
60 | void wk_usb_app_init(void);
61 |
62 | void wk_usb_app_task(void);
63 |
64 | void wk_otghs_irq_handler(void);
65 |
66 | /* add user code begin exported functions */
67 |
68 | /* add user code end exported functions */
69 |
70 | #ifdef __cplusplus
71 | }
72 | #endif
73 |
74 | #endif
75 |
--------------------------------------------------------------------------------
/fw_bl/project/inc/wk_system.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file wk_system.h
4 | * @brief workbench system header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 | /* define to prevent recursive inclusion -------------------------------------*/
25 | #ifndef __WK_SYSTEM_H
26 | #define __WK_SYSTEM_H
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | #include "at32f402_405.h"
33 |
34 | void wk_timebase_init(void);
35 | void wk_timebase_handler(void);
36 | void wk_delay_ms(uint32_t delay);
37 |
38 | #ifdef __cplusplus
39 | }
40 | #endif
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/fw_bl/usr/app_main.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __APP_MAIN_H__
11 | #define __APP_MAIN_H__
12 |
13 | #include "cd_utils.h"
14 | #include "cd_list.h"
15 | #include "cdbus_uart.h"
16 | #include "modbus_crc.h"
17 |
18 | #include "usb_conf.h"
19 | #include "usb_core.h"
20 | #include "wk_system.h"
21 | #include "usbd_int.h"
22 | #include "cdc_class.h"
23 | #include "cdc_desc.h"
24 |
25 | #define BL_ARGS 0x20000000 // first word
26 | #define APP_CONF_ADDR 0x0803F800 // last page
27 | #define APP_CONF_VER 0x0200
28 |
29 | #define FRAME_MAX 80
30 |
31 |
32 | typedef struct {
33 | uint16_t offset;
34 | uint16_t size;
35 | } regr_t; // reg range
36 |
37 |
38 | typedef struct {
39 | uint16_t magic_code; // 0xcdcd
40 | uint16_t conf_ver;
41 | uint8_t conf_from; // 0: default, 1: load from flash
42 | uint8_t do_reboot;
43 | bool _reserved;
44 | bool save_conf;
45 |
46 | bool dbg_en;
47 |
48 | uint8_t _keep[503]; // covers the areas in the app csa that need to be saved
49 |
50 | // end of flash
51 | #define _end_save usb_online // offset: 512
52 |
53 | bool usb_online;
54 |
55 | } csa_t; // config status area
56 |
57 | extern csa_t csa;
58 | extern const csa_t csa_dft;
59 |
60 |
61 | int flash_erase(uint32_t addr, uint32_t len);
62 | int flash_write(uint32_t addr, uint32_t len, const uint8_t *buf);
63 |
64 | extern gpio_t led_g;
65 | extern gpio_t sw1;
66 |
67 | extern list_head_t frame_free_head;
68 | extern cduart_dev_t d_dev; // uart / usb
69 | extern volatile uint8_t cdc_dtr;
70 | extern otg_core_type otg_core_struct_hs;
71 |
72 | extern uint32_t end; // end of bss
73 | extern uint32_t *bl_args;
74 |
75 | void common_service_init(void);
76 | void common_service_routine(void);
77 |
78 | void app_main(void);
79 | void load_conf(void);
80 | int save_conf(void);
81 | void try_jump_to_app(void);
82 |
83 | #endif
84 |
--------------------------------------------------------------------------------
/fw_bl/usr/cd_config.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __CD_CONFIG_H__
11 | #define __CD_CONFIG_H__
12 |
13 | //#define ARCH_SPI
14 | #define ARCH_CRC_HW
15 | #define CDUART_CRC crc16_hw
16 | #define CDUART_CRC_SUB crc16_hw_sub
17 |
18 | #define CD_FRAME_SIZE 258
19 | #define CDN_MAX_DAT 253
20 |
21 | #define DEBUG
22 | //#define VERBOSE
23 | //#define LIST_DEBUG
24 |
25 | #define CD_LIST_IT
26 | #define CD_IRQ_SAFE
27 |
28 | #define CDUART_IDLE_TIME (500000 / SYSTICK_US_DIV) // 500 ms
29 |
30 | #include "at32f402_405_wk_config.h"
31 | #include "debug_config.h"
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/fw_bl/usr/config.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #include "app_main.h"
11 |
12 | #define ONCE_PAGE_SIZE 2048
13 |
14 |
15 | const csa_t csa_dft = {
16 | .magic_code = 0xcdcd,
17 | .conf_ver = APP_CONF_VER,
18 | .dbg_en = false
19 | };
20 |
21 | csa_t csa;
22 |
23 |
24 | void load_conf(void)
25 | {
26 | uint16_t magic_code = *(uint16_t *)APP_CONF_ADDR;
27 | uint16_t conf_ver = *(uint16_t *)(APP_CONF_ADDR + 2);
28 | csa = csa_dft;
29 |
30 | //d_info("end_save: %d\n", offsetof(csa_t, _end_save)); // 512
31 | if (magic_code == 0xcdcd && (conf_ver >> 8) == (APP_CONF_VER >> 8)) {
32 | memcpy(&csa, (void *)APP_CONF_ADDR, offsetof(csa_t, _end_save));
33 | csa.conf_from = 1;
34 | memset(&csa.do_reboot, 0, 3);
35 | }
36 | }
37 |
38 | int save_conf(void)
39 | {
40 | int ret = flash_erase(APP_CONF_ADDR, 2048);
41 | if (ret)
42 | d_info("conf: failed to erase flash\n");
43 | ret = flash_write(APP_CONF_ADDR, offsetof(csa_t, _end_save), (uint8_t *)&csa);
44 |
45 | if (!ret) {
46 | d_info("conf: save to flash successed, size: %d\n", offsetof(csa_t, _end_save));
47 | return 0;
48 | } else {
49 | d_error("conf: save to flash error\n");
50 | return 1;
51 | }
52 | }
53 |
54 | int flash_erase(uint32_t addr, uint32_t len)
55 | {
56 | int ret = 0;
57 | uint32_t ofs = addr & ~0x08000000;
58 | uint32_t s_page = ofs / ONCE_PAGE_SIZE;
59 | int n_page = (ofs + len) / ONCE_PAGE_SIZE - s_page;
60 | if ((ofs + len) % ONCE_PAGE_SIZE)
61 | n_page++;
62 |
63 | flash_unlock();
64 | flash_flag_clear(FLASH_ODF_FLAG | FLASH_PRGMERR_FLAG | FLASH_EPPERR_FLAG);
65 | for (int i = 0; i < n_page; i++) {
66 | flash_status_type st = flash_sector_erase(0x08000000 + ONCE_PAGE_SIZE * (s_page + i));
67 | if (st != FLASH_OPERATE_DONE) {
68 | ret = -1;
69 | break;
70 | }
71 | }
72 | flash_lock();
73 | d_debug("flash erase: %08lx +%08lx (%ld %d), ret: %d\n", addr, len, s_page, n_page, ret);
74 | return ret;
75 | }
76 |
77 | int flash_write(uint32_t addr, uint32_t len, const uint8_t *buf)
78 | {
79 | int ret = 0;
80 | uint32_t write_cnt = (len + 3) / 4;
81 | uint32_t *src_addr = (uint32_t *) buf;
82 | uint32_t src_data;
83 |
84 | flash_unlock();
85 | flash_flag_clear(FLASH_ODF_FLAG | FLASH_PRGMERR_FLAG | FLASH_EPPERR_FLAG);
86 |
87 | for (uint32_t i = 0; i < write_cnt; i++) {
88 | src_data = get_unaligned32((uint8_t *)(src_addr + i));
89 | flash_status_type st = flash_word_program(addr + i * 4, src_data);
90 | if (st != FLASH_OPERATE_DONE) {
91 | ret = -1;
92 | break;
93 | }
94 | }
95 | flash_lock();
96 | d_verbose("flash write: %08lx %ld, ret: %d\n", addr, len, ret);
97 | return ret;
98 | }
99 |
--------------------------------------------------------------------------------
/fw_bl/usr/debug_config.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __DEBUG_CONFIG_H__
11 | #define __DEBUG_CONFIG_H__
12 |
13 | #include "arch_wrapper.h"
14 |
15 | static inline void dbg_transmit(const uint8_t *buf, uint16_t len)
16 | {
17 | for (uint16_t i = 0; i < len; i++) {
18 | while (!(UART7->sts & USART_TDBE_FLAG));
19 | UART7->dt = *(buf + i);
20 | }
21 | }
22 |
23 |
24 | #ifndef d_printf
25 | #define d_printf(fmt, ...) printf(fmt, ## __VA_ARGS__)
26 | #endif
27 |
28 | #define d_info(fmt, ...) d_printf("I: " fmt, ## __VA_ARGS__)
29 | #ifndef d_warn
30 | #define d_warn(fmt, ...) d_printf("W: " fmt, ## __VA_ARGS__)
31 | #endif
32 | #ifndef d_error
33 | #define d_error(fmt, ...) d_printf("E: " fmt, ## __VA_ARGS__)
34 | #endif
35 |
36 | #define dn_info(name, fmt, ...) d_info("%s: " fmt, name, ## __VA_ARGS__)
37 | #define dn_warn(name, fmt, ...) d_warn("%s: " fmt, name, ## __VA_ARGS__)
38 | #define dn_error(name, fmt, ...) d_error("%s: " fmt, name, ## __VA_ARGS__)
39 |
40 | #define df_info(fmt, ...) dn_info(__FUNCTION__, fmt, ## __VA_ARGS__)
41 | #define df_warn(fmt, ...) dn_warn(__FUNCTION__, fmt, ## __VA_ARGS__)
42 | #define df_error(fmt, ...) dn_error(__FUNCTION__, fmt, ## __VA_ARGS__)
43 |
44 | #define dnf_info(name, fmt, ...) d_info("%s: %s: " fmt, name, __FUNCTION__, ## __VA_ARGS__)
45 | #define dnf_warn(name, fmt, ...) d_warn("%s: %s: " fmt, name, __FUNCTION__, ## __VA_ARGS__)
46 | #define dnf_error(name, fmt, ...) d_error("%s: %s: " fmt, name, __FUNCTION__, ## __VA_ARGS__)
47 |
48 | #ifdef VERBOSE
49 | #define d_verbose_c(fmt, ...) d_printf(fmt, ## __VA_ARGS__)
50 | #define d_verbose(fmt, ...) d_printf("V: " fmt, ## __VA_ARGS__)
51 | #define dn_verbose(name, fmt, ...) d_verbose("%s: " fmt, name, ## __VA_ARGS__)
52 | #define df_verbose(fmt, ...) dn_verbose(__FUNCTION__, fmt, ## __VA_ARGS__)
53 | #define dnf_verbose(name, fmt, ...) d_verbose("%s: %s: " fmt, name, __FUNCTION__, ## __VA_ARGS__)
54 | #ifndef DEBUG
55 | #define DEBUG
56 | #endif // DEBUG
57 | #else
58 | #define d_verbose_c(fmt, ...) do {} while (0)
59 | #define d_verbose(fmt, ...) do {} while (0)
60 | #define dn_verbose(name, ...) do {} while (0)
61 | #define df_verbose(name, ...) do {} while (0)
62 | #define dnf_verbose(name, ...) do {} while (0)
63 | #endif
64 |
65 | #ifdef DEBUG
66 | #define d_debug_c(fmt, ...) d_printf(fmt, ## __VA_ARGS__)
67 | #define d_debug(fmt, ...) d_printf("D: " fmt, ## __VA_ARGS__)
68 | #define dn_debug(name, fmt, ...) d_debug("%s: " fmt, name, ## __VA_ARGS__)
69 | #define df_debug(fmt, ...) dn_debug(__FUNCTION__, fmt, ## __VA_ARGS__)
70 | #define dnf_debug(name, fmt, ...) d_debug("%s: %s: " fmt, name, __FUNCTION__, ## __VA_ARGS__)
71 | #else
72 | #define d_debug_c(fmt, ...) do {} while (0)
73 | #define d_debug(fmt, ...) do {} while (0)
74 | #define dn_debug(name, ...) do {} while (0)
75 | #define df_debug(name, ...) do {} while (0)
76 | #define dnf_debug(name, ...) do {} while (0)
77 | #endif
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/fw_bl/utils/cd_list.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __CD_LIST_H__
11 | #define __CD_LIST_H__
12 |
13 | typedef struct list_node {
14 | struct list_node *next;
15 | } list_node_t;
16 |
17 | typedef struct {
18 | list_node_t *first;
19 | list_node_t *last;
20 | uint32_t len;
21 | } list_head_t;
22 |
23 |
24 | list_node_t *list_get(list_head_t *head);
25 | void list_put(list_head_t *head, list_node_t *node);
26 |
27 | list_node_t *list_get_last(list_head_t *head);
28 | void list_put_begin(list_head_t *head, list_node_t *node);
29 | void list_pick(list_head_t *head, list_node_t *pre, list_node_t *node);
30 | void list_move_begin(list_head_t *head, list_node_t *pre, list_node_t *node);
31 |
32 |
33 | #define list_entry(ptr, type) \
34 | container_of(ptr, type, node)
35 |
36 | #define list_entry_safe(ptr, type) ({ \
37 | list_node_t *__ptr = (ptr); \
38 | __ptr ? container_of(__ptr, type, node) : NULL; \
39 | })
40 |
41 | #define list_get_entry(head, type) \
42 | list_entry_safe(list_get(head), type)
43 |
44 | #ifdef CD_LIST_IT
45 | #define list_get_entry_it(head, type) \
46 | list_entry_safe(list_get_it(head), type)
47 | #endif
48 |
49 | #define list_for_each(head, pre, pos) \
50 | for (pre = NULL, pos = (head)->first; pos != NULL; \
51 | pre = pos, pos = (pos ? (pos)->next : (head)->first))
52 | // you can remove a node during the loop:
53 | // list_pick(head, pre, pos);
54 | // pos = pre;
55 |
56 | // read only version:
57 | #define list_for_each_ro(head, pos) \
58 | for (pos = (head)->first; pos != NULL; \
59 | pos = (pos ? (pos)->next : (head)->first))
60 |
61 | #define list_head_init(head) \
62 | memset(head, 0, sizeof(list_head_t))
63 |
64 |
65 | #ifdef CD_LIST_IT
66 |
67 | static inline list_node_t *list_get_it(list_head_t *head)
68 | {
69 | uint32_t flags;
70 | list_node_t *node;
71 | local_irq_save(flags);
72 | node = list_get(head);
73 | local_irq_restore(flags);
74 | return node;
75 | }
76 |
77 | static inline void list_put_it(list_head_t *head, list_node_t *node)
78 | {
79 | uint32_t flags;
80 | local_irq_save(flags);
81 | list_put(head, node);
82 | local_irq_restore(flags);
83 | }
84 |
85 | static inline void list_put_begin_it(list_head_t *head, list_node_t *node)
86 | {
87 | uint32_t flags;
88 | local_irq_save(flags);
89 | list_put_begin(head, node);
90 | local_irq_restore(flags);
91 | }
92 |
93 | #endif // CD_LIST_IT
94 |
95 | #endif
96 |
--------------------------------------------------------------------------------
/fw_bl/utils/cdbus_uart.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #include "cd_utils.h"
11 | #include "cd_list.h"
12 | #include "cdbus_uart.h"
13 |
14 |
15 | void cduart_dev_init(cduart_dev_t *dev, list_head_t *free_head)
16 | {
17 | dev->rx_frame = cd_list_get(free_head);
18 | dev->free_head = free_head;
19 | dev->t_last = get_systick();
20 | dev->rx_crc = 0xffff;
21 |
22 | #ifdef USE_DYNAMIC_INIT
23 | list_head_init(&dev->rx_head);
24 | list_head_init(&dev->tx_head);
25 | dev->rx_byte_cnt = 0;
26 | dev->rx_drop = false;
27 | #endif
28 | }
29 |
30 |
31 | void cduart_rx_handle(cduart_dev_t *dev, const uint8_t *buf, unsigned len)
32 | {
33 | unsigned max_len;
34 | unsigned cpy_len;
35 | const uint8_t *rd = buf;
36 |
37 | while (true) {
38 | cd_frame_t *frame = dev->rx_frame;
39 |
40 | if (dev->rx_byte_cnt != 0 && get_systick() - dev->t_last > CDUART_IDLE_TIME) {
41 | printf("bus: timeout [%02x %02x %02x] %d, %d\n",
42 | frame->dat[0], frame->dat[1], frame->dat[2], dev->rx_byte_cnt, dev->rx_drop);
43 | for (int i = 0; i < dev->rx_byte_cnt; i++)
44 | printf("%02x ", frame->dat[i]);
45 | printf("\n");
46 | dev->rx_byte_cnt = 0;
47 | dev->rx_crc = 0xffff;
48 | dev->rx_drop = false;
49 | }
50 |
51 | if (!len || rd == buf + len)
52 | return;
53 | max_len = buf + len - rd;
54 | dev->t_last = get_systick();
55 |
56 | if (dev->rx_byte_cnt < 3)
57 | cpy_len = min(3 - dev->rx_byte_cnt, max_len);
58 | else
59 | cpy_len = min(frame->dat[2] + 5 - dev->rx_byte_cnt, max_len);
60 |
61 | if (!dev->rx_drop)
62 | memcpy(frame->dat + dev->rx_byte_cnt, rd, cpy_len);
63 | dev->rx_byte_cnt += cpy_len;
64 |
65 | if (dev->rx_byte_cnt == 3 &&
66 | (frame->dat[2] > CD_FRAME_SIZE - 5 ||
67 | (frame->dat[1] != 0xff && frame->dat[1] != dev->local_mac))) {
68 | printf("bus: drop [%x %x %x]\n", frame->dat[0], frame->dat[1], frame->dat[2]);
69 | dev->rx_drop = true;
70 | }
71 |
72 | if (!dev->rx_drop)
73 | dev->rx_crc = CDUART_CRC_SUB(rd, cpy_len, dev->rx_crc);
74 | rd += cpy_len;
75 |
76 | if (dev->rx_byte_cnt == frame->dat[2] + 5) {
77 | if (!dev->rx_drop) {
78 | if (dev->rx_crc != 0) {
79 | printf("bus: !crc [%x %x %x]\n", frame->dat[0], frame->dat[1], frame->dat[2]);
80 |
81 | } else {
82 | cd_frame_t *frm = cd_list_get(dev->free_head);
83 | if (frm) {
84 | cd_list_put(&dev->rx_head, dev->rx_frame);
85 | dev->rx_frame = frm;
86 | } else {
87 | printf("bus: rx lost\n");
88 | }
89 | }
90 | }
91 | dev->rx_byte_cnt = 0;
92 | dev->rx_crc = 0xffff;
93 | dev->rx_drop = false;
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/fw_bl/utils/cdbus_uart.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __CDBUS_UART_H__
11 | #define __CDBUS_UART_H__
12 |
13 | #include "modbus_crc.h"
14 |
15 | // 256 bytes are enough for the CDCTL controller (without CRC)
16 | // 258 bytes are enough for the UART controller (with CRC)
17 | // allow smaller sizes to save memory
18 | #ifndef CD_FRAME_SIZE
19 | #define CD_FRAME_SIZE 256
20 | #endif
21 |
22 | typedef struct {
23 | list_node_t node;
24 | uint8_t dat[CD_FRAME_SIZE];
25 | } cd_frame_t;
26 |
27 |
28 | #ifndef CDUART_IDLE_TIME
29 | #define CDUART_IDLE_TIME 5 // ms
30 | #endif
31 | #ifndef CDUART_CRC
32 | #define CDUART_CRC crc16
33 | #endif
34 | #ifndef CDUART_CRC_SUB
35 | #define CDUART_CRC_SUB crc16_sub
36 | #endif
37 |
38 | #ifdef CD_IRQ_SAFE
39 | #define cd_list_get(head) list_get_entry_it(head, cd_frame_t)
40 | #define cd_list_put(head, frm) list_put_it(head, &(frm)->node)
41 | #elif !defined(CD_USER_LIST)
42 | #define cd_list_get(head) list_get_entry(head, cd_frame_t)
43 | #define cd_list_put(head, frm) list_put(head, &(frm)->node)
44 | #endif
45 |
46 |
47 | typedef struct cduart_dev {
48 | list_head_t *free_head;
49 | list_head_t rx_head;
50 | list_head_t tx_head;
51 |
52 | cd_frame_t *rx_frame; // init: != NULL
53 | uint16_t rx_byte_cnt;
54 | uint16_t rx_crc;
55 | bool rx_drop;
56 | uint32_t t_last; // last receive time
57 |
58 | uint8_t local_mac;
59 | } cduart_dev_t;
60 |
61 |
62 | static inline cd_frame_t *cduart_get_rx_frame(cduart_dev_t *dev)
63 | {
64 | return cd_list_get(&dev->rx_head);
65 | }
66 |
67 | static inline void cduart_put_tx_frame(cduart_dev_t *dev, cd_frame_t *frame)
68 | {
69 | cd_list_put(&dev->tx_head, frame);
70 | }
71 |
72 |
73 | void cduart_dev_init(cduart_dev_t *dev, list_head_t *free_head);
74 | void cduart_rx_handle(cduart_dev_t *dev, const uint8_t *buf, unsigned len);
75 |
76 | static inline void cduart_fill_crc(uint8_t *dat)
77 | {
78 | uint16_t crc_val = CDUART_CRC(dat, dat[2] + 3);
79 | dat[dat[2] + 3] = crc_val & 0xff;
80 | dat[dat[2] + 4] = crc_val >> 8;
81 | }
82 |
83 | #endif
84 |
--------------------------------------------------------------------------------
/fw_bl/utils/crc_hw.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2024, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #include "modbus_crc.h"
11 |
12 | #define INIT idt
13 | #define CR ctrl
14 | #define DR dt
15 |
16 |
17 | uint16_t crc16_hw_sub(const uint8_t *data, uint32_t length, uint16_t crc_val)
18 | {
19 | uint16_t ret_val;
20 | #ifdef CRC_HW_IRQ_SAFE // not recommended, avoid large critical sections
21 | uint32_t flags;
22 | local_irq_save(flags);
23 | #endif
24 | CRC->INIT = crc_val;
25 | CRC->CR = 0xe9;
26 | CRC->INIT = CRC->DR; // bit-reverse crc_val
27 |
28 | while (((unsigned)data & 3) && length) {
29 | *(volatile uint8_t *)&CRC->DR = *data++;
30 | length--;
31 | }
32 |
33 | unsigned cnt = length >> 2;
34 | while (cnt--) {
35 | CRC->DR = *(uint32_t *)data;
36 | data += 4;
37 | }
38 |
39 | length &= 3;
40 | while (length--)
41 | *(volatile uint8_t *)&CRC->DR = *data++;
42 |
43 | ret_val = CRC->DR;
44 | #ifdef CRC_HW_IRQ_SAFE
45 | local_irq_restore(flags);
46 | #endif
47 | return ret_val;
48 | }
49 |
--------------------------------------------------------------------------------
/fw_bl/utils/modbus_crc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: http://www.modbustools.com/modbus_crc16.htm
8 | * Modified by: Duke Fong
9 | */
10 |
11 | #ifndef __MODBUS_CRC_H__
12 | #define __MODBUS_CRC_H__
13 |
14 | #include "cd_utils.h"
15 |
16 | uint16_t crc16_sub(const uint8_t *data, uint32_t length, uint16_t crc_val);
17 |
18 | static inline uint16_t crc16(const uint8_t *data, uint32_t length)
19 | {
20 | return crc16_sub(data, length, 0xffff);
21 | }
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/fw_bridge/.gitignore:
--------------------------------------------------------------------------------
1 | #
2 | # NOTE! Don't add files that are generated in specific
3 | # subdirectories here. Add them in the ".gitignore" file
4 | # in that subdirectory instead.
5 | #
6 | # NOTE! Please use 'git ls-files -i --exclude-standard'
7 | # command after changing this file, to see if there are
8 | # any tracked files which get ignored after the change.
9 | #
10 | # Normal rules
11 | #
12 | .*
13 | *.log
14 |
15 | build/
16 |
17 | #
18 | # git files that we don't want to ignore even it they are dot-files
19 | #
20 | !.gitignore
21 | !.gitkeep
22 | !.mailmap
23 |
24 | *.orig
25 | *~
26 | \#*#
27 |
28 |
--------------------------------------------------------------------------------
/fw_bridge/flash.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | pyocd flash -t at32f405kcu7_4 build/*.hex --pack=$AT32F405_DFP_PACK_FILE
4 |
--------------------------------------------------------------------------------
/fw_bridge/libraries/cmsis/cm4/core_support/arm_math_f16.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * @file arm_math_f16.h
3 | * @brief Public header file for f16 function of the CMSIS DSP Library
4 | * @version V1.10.0
5 | * @date 08 July 2021
6 | * Target Processor: Cortex-M and Cortex-A cores
7 | ******************************************************************************/
8 | /*
9 | * Copyright (c) 2010-2021 Arm Limited or its affiliates. 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 _ARM_MATH_F16_H
27 | #define _ARM_MATH_F16_H
28 |
29 | #include "arm_math.h"
30 |
31 | #ifdef __cplusplus
32 | extern "C"
33 | {
34 | #endif
35 |
36 | #include "arm_math_types_f16.h"
37 | #include "dsp/none.h"
38 | #include "dsp/utils.h"
39 | #include "dsp/basic_math_functions_f16.h"
40 | #include "dsp/interpolation_functions_f16.h"
41 | #include "dsp/bayes_functions_f16.h"
42 | #include "dsp/matrix_functions_f16.h"
43 | #include "dsp/complex_math_functions_f16.h"
44 | #include "dsp/statistics_functions_f16.h"
45 | #include "dsp/controller_functions_f16.h"
46 | #include "dsp/support_functions_f16.h"
47 | #include "dsp/distance_functions_f16.h"
48 | #include "dsp/svm_functions_f16.h"
49 | #include "dsp/fast_math_functions_f16.h"
50 | #include "dsp/transform_functions_f16.h"
51 | #include "dsp/filtering_functions_f16.h"
52 |
53 | #ifdef __cplusplus
54 | }
55 | #endif
56 |
57 | #endif /* _ARM_MATH_F16_H */
58 |
59 |
60 |
--------------------------------------------------------------------------------
/fw_bridge/libraries/cmsis/cm4/core_support/cmsis_version.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file cmsis_version.h
3 | * @brief CMSIS Core(M) Version definitions
4 | * @version V5.0.5
5 | * @date 02. February 2022
6 | ******************************************************************************/
7 | /*
8 | * Copyright (c) 2009-2022 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 (__clang__)
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 ( 6U) /*!< [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 |
--------------------------------------------------------------------------------
/fw_bridge/libraries/cmsis/cm4/device_support/startup/iar/linker/AT32F402xB.icf:
--------------------------------------------------------------------------------
1 | /*###ICF### Section handled by ICF editor, don't touch! ****/
2 | /*-Editor annotation file-*/
3 | /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
4 | /*-Specials-*/
5 | define symbol __ICFEDIT_intvec_start__ = 0x08000000;
6 | /*-Memory Regions-*/
7 | define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
8 | define symbol __ICFEDIT_region_ROM_end__ = 0x0801FFFF;
9 | define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
10 | define symbol __ICFEDIT_region_RAM_end__ = 0x200117FF;
11 | /*-Sizes-*/
12 | define symbol __ICFEDIT_size_cstack__ = 0x1000;
13 | define symbol __ICFEDIT_size_heap__ = 0x1000;
14 | /**** End of ICF editor section. ###ICF###*/
15 |
16 | define memory mem with size = 4G;
17 | define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
18 | define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
19 |
20 | define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
21 | define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
22 |
23 | initialize by copy { readwrite };
24 | do not initialize { section .noinit };
25 |
26 | place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
27 |
28 | place in ROM_region { readonly };
29 | place in RAM_region { readwrite,
30 | block CSTACK, block HEAP };
--------------------------------------------------------------------------------
/fw_bridge/libraries/cmsis/cm4/device_support/startup/iar/linker/AT32F402xC.icf:
--------------------------------------------------------------------------------
1 | /*###ICF### Section handled by ICF editor, don't touch! ****/
2 | /*-Editor annotation file-*/
3 | /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
4 | /*-Specials-*/
5 | define symbol __ICFEDIT_intvec_start__ = 0x08000000;
6 | /*-Memory Regions-*/
7 | define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
8 | define symbol __ICFEDIT_region_ROM_end__ = 0x0803FFFF;
9 | define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
10 | define symbol __ICFEDIT_region_RAM_end__ = 0x200197FF;
11 | /*-Sizes-*/
12 | define symbol __ICFEDIT_size_cstack__ = 0x1000;
13 | define symbol __ICFEDIT_size_heap__ = 0x1000;
14 | /**** End of ICF editor section. ###ICF###*/
15 |
16 | define memory mem with size = 4G;
17 | define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
18 | define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
19 |
20 | define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
21 | define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
22 |
23 | initialize by copy { readwrite };
24 | do not initialize { section .noinit };
25 |
26 | place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
27 |
28 | place in ROM_region { readonly };
29 | place in RAM_region { readwrite,
30 | block CSTACK, block HEAP };
--------------------------------------------------------------------------------
/fw_bridge/libraries/cmsis/cm4/device_support/startup/iar/linker/AT32F405xB.icf:
--------------------------------------------------------------------------------
1 | /*###ICF### Section handled by ICF editor, don't touch! ****/
2 | /*-Editor annotation file-*/
3 | /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
4 | /*-Specials-*/
5 | define symbol __ICFEDIT_intvec_start__ = 0x08000000;
6 | /*-Memory Regions-*/
7 | define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
8 | define symbol __ICFEDIT_region_ROM_end__ = 0x0801FFFF;
9 | define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
10 | define symbol __ICFEDIT_region_RAM_end__ = 0x200117FF;
11 | /*-Sizes-*/
12 | define symbol __ICFEDIT_size_cstack__ = 0x1000;
13 | define symbol __ICFEDIT_size_heap__ = 0x1000;
14 | /**** End of ICF editor section. ###ICF###*/
15 |
16 | define memory mem with size = 4G;
17 | define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
18 | define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
19 |
20 | define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
21 | define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
22 |
23 | initialize by copy { readwrite };
24 | do not initialize { section .noinit };
25 |
26 | place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
27 |
28 | place in ROM_region { readonly };
29 | place in RAM_region { readwrite,
30 | block CSTACK, block HEAP };
--------------------------------------------------------------------------------
/fw_bridge/libraries/cmsis/cm4/device_support/startup/iar/linker/AT32F405xC.icf:
--------------------------------------------------------------------------------
1 | /*###ICF### Section handled by ICF editor, don't touch! ****/
2 | /*-Editor annotation file-*/
3 | /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
4 | /*-Specials-*/
5 | define symbol __ICFEDIT_intvec_start__ = 0x08000000;
6 | /*-Memory Regions-*/
7 | define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
8 | define symbol __ICFEDIT_region_ROM_end__ = 0x0803FFFF;
9 | define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
10 | define symbol __ICFEDIT_region_RAM_end__ = 0x200197FF;
11 | /*-Sizes-*/
12 | define symbol __ICFEDIT_size_cstack__ = 0x1000;
13 | define symbol __ICFEDIT_size_heap__ = 0x1000;
14 | /**** End of ICF editor section. ###ICF###*/
15 |
16 | define memory mem with size = 4G;
17 | define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
18 | define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
19 |
20 | define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
21 | define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
22 |
23 | initialize by copy { readwrite };
24 | do not initialize { section .noinit };
25 |
26 | place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
27 |
28 | place in ROM_region { readonly };
29 | place in RAM_region { readwrite,
30 | block CSTACK, block HEAP };
--------------------------------------------------------------------------------
/fw_bridge/libraries/cmsis/cm4/device_support/system_at32f402_405.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file system_at32f402_405.h
4 | * @brief cmsis cortex-m4 system header file.
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | #ifndef __SYSTEM_AT32F402_405_H
26 | #define __SYSTEM_AT32F402_405_H
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | /** @addtogroup CMSIS
33 | * @{
34 | */
35 |
36 | /** @addtogroup AT32F402_405_system
37 | * @{
38 | */
39 |
40 | /** @defgroup AT32F402_405_system_exported_variables
41 | * @{
42 | */
43 | extern unsigned int system_core_clock; /*!< system clock frequency (core clock) */
44 |
45 | /**
46 | * @}
47 | */
48 |
49 | /** @defgroup AT32F402_405_system_exported_functions
50 | * @{
51 | */
52 |
53 | extern void SystemInit(void);
54 | extern void system_core_clock_update(void);
55 | extern void reduce_power_consumption(void);
56 |
57 | /**
58 | * @}
59 | */
60 |
61 | /**
62 | * @}
63 | */
64 |
65 | /**
66 | * @}
67 | */
68 |
69 | #ifdef __cplusplus
70 | }
71 | #endif
72 |
73 | #endif
74 |
75 |
--------------------------------------------------------------------------------
/fw_bridge/libraries/drivers/inc/at32f402_405_def.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file at32f402_405_def.h
4 | * @brief at32f402_405 macros header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* Define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __AT32F402_405_DEF_H
27 | #define __AT32F402_405_DEF_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | /* gnu compiler */
34 | #if defined (__GNUC__)
35 | #ifndef ALIGNED_HEAD
36 | #define ALIGNED_HEAD
37 | #endif
38 | #ifndef ALIGNED_TAIL
39 | #define ALIGNED_TAIL __attribute__ ((aligned (4)))
40 | #endif
41 | #endif
42 |
43 | /* arm compiler */
44 | #if defined (__CC_ARM)
45 | #ifndef ALIGNED_HEAD
46 | #define ALIGNED_HEAD __align(4)
47 | #endif
48 | #ifndef ALIGNED_TAIL
49 | #define ALIGNED_TAIL
50 | #endif
51 | #endif
52 |
53 | /* iar compiler */
54 | #if defined (__ICCARM__)
55 | #ifndef ALIGNED_HEAD
56 | #define ALIGNED_HEAD
57 | #endif
58 | #ifndef ALIGNED_TAIL
59 | #define ALIGNED_TAIL
60 | #endif
61 | #endif
62 |
63 | #define UNUSED(x) (void)x /* to avoid gcc/g++ warnings */
64 |
65 | #ifdef __cplusplus
66 | }
67 | #endif
68 |
69 | #endif
70 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/3rd_party/fatfs/source/diskio.h:
--------------------------------------------------------------------------------
1 | /*-----------------------------------------------------------------------/
2 | / Low level disk interface modlue include file (C)ChaN, 2019 /
3 | /-----------------------------------------------------------------------*/
4 |
5 | #ifndef _DISKIO_DEFINED
6 | #define _DISKIO_DEFINED
7 |
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif
11 |
12 | /* Status of Disk Functions */
13 | typedef BYTE DSTATUS;
14 |
15 | /* Results of Disk Functions */
16 | typedef enum {
17 | RES_OK = 0, /* 0: Successful */
18 | RES_ERROR, /* 1: R/W Error */
19 | RES_WRPRT, /* 2: Write Protected */
20 | RES_NOTRDY, /* 3: Not Ready */
21 | RES_PARERR /* 4: Invalid Parameter */
22 | } DRESULT;
23 |
24 |
25 | /*---------------------------------------*/
26 | /* Prototypes for disk control functions */
27 |
28 |
29 | DSTATUS disk_initialize (BYTE pdrv);
30 | DSTATUS disk_status (BYTE pdrv);
31 | DRESULT disk_read (BYTE pdrv, BYTE* buff, LBA_t sector, UINT count);
32 | DRESULT disk_write (BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count);
33 | DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
34 |
35 |
36 | /* Disk Status Bits (DSTATUS) */
37 |
38 | #define STA_NOINIT 0x01 /* Drive not initialized */
39 | #define STA_NODISK 0x02 /* No medium in the drive */
40 | #define STA_PROTECT 0x04 /* Write protected */
41 |
42 |
43 | /* Command code for disk_ioctrl fucntion */
44 |
45 | /* Generic command (Used by FatFs) */
46 | #define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */
47 | #define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */
48 | #define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
49 | #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */
50 | #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */
51 |
52 | /* Generic command (Not used by FatFs) */
53 | #define CTRL_POWER 5 /* Get/Set power status */
54 | #define CTRL_LOCK 6 /* Lock/Unlock media removal */
55 | #define CTRL_EJECT 7 /* Eject media */
56 | #define CTRL_FORMAT 8 /* Create physical format on the media */
57 |
58 | /* MMC/SDC specific ioctl command */
59 | #define MMC_GET_TYPE 10 /* Get card type */
60 | #define MMC_GET_CSD 11 /* Get CSD */
61 | #define MMC_GET_CID 12 /* Get CID */
62 | #define MMC_GET_OCR 13 /* Get OCR */
63 | #define MMC_GET_SDSTAT 14 /* Get SD status */
64 | #define ISDIO_READ 55 /* Read data form SD iSDIO register */
65 | #define ISDIO_WRITE 56 /* Write data to SD iSDIO register */
66 | #define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */
67 |
68 | /* ATA/CF specific ioctl command */
69 | #define ATA_GET_REV 20 /* Get F/W revision */
70 | #define ATA_GET_MODEL 21 /* Get model name */
71 | #define ATA_GET_SN 22 /* Get serial number */
72 |
73 | #ifdef __cplusplus
74 | }
75 | #endif
76 |
77 | #endif
78 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/freertos/source/include/StackMacros.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.4.3
3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * https://www.FreeRTOS.org
23 | * https://github.com/FreeRTOS
24 | *
25 | */
26 |
27 |
28 | #ifndef _MSC_VER /* Visual Studio doesn't support #warning. */
29 | #warning The name of this file has changed to stack_macros.h. Please update your code accordingly. This source file (which has the original name) will be removed in future released.
30 | #endif
31 |
32 | #include "stack_macros.h"
33 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/freertos/source/include/stdint.readme:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.4.3
3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * https://www.FreeRTOS.org
23 | * https://github.com/FreeRTOS
24 | *
25 | */
26 |
27 | #ifndef FREERTOS_STDINT
28 | #define FREERTOS_STDINT
29 |
30 | /*******************************************************************************
31 | * THIS IS NOT A FULL stdint.h IMPLEMENTATION - It only contains the definitions
32 | * necessary to build the FreeRTOS code. It is provided to allow FreeRTOS to be
33 | * built using compilers that do not provide their own stdint.h definition.
34 | *
35 | * To use this file:
36 | *
37 | * 1) Copy this file into the directory that contains your FreeRTOSConfig.h
38 | * header file, as that directory will already be in the compiler's include
39 | * path.
40 | *
41 | * 2) Rename the copied file stdint.h.
42 | *
43 | */
44 |
45 | typedef signed char int8_t;
46 | typedef unsigned char uint8_t;
47 | typedef short int16_t;
48 | typedef unsigned short uint16_t;
49 | typedef long int32_t;
50 | typedef unsigned long uint32_t;
51 |
52 | #endif /* FREERTOS_STDINT */
53 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/freertos/source/include/task.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dukelec/cdbus_bridge/826ad126b42fcb69d50684b164e60fb0b46d0a3f/fw_bridge/middlewares/freertos/source/include/task.h
--------------------------------------------------------------------------------
/fw_bridge/middlewares/freertos/source/portable/memmang/ReadMe.url:
--------------------------------------------------------------------------------
1 | [{000214A0-0000-0000-C000-000000000046}]
2 | Prop3=19,2
3 | [InternetShortcut]
4 | URL=https://www.FreeRTOS.org/a00111.html
5 | IDList=
6 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/usb_drivers/inc/usbd_int.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file usbd_int.h
4 | * @brief usb interrupt header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __USBD_INT_H
27 | #define __USBD_INT_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | /** @addtogroup AT32F402_405_middlewares_usbd_drivers
34 | * @{
35 | */
36 |
37 | /** @addtogroup USBD_drivers_int
38 | * @{
39 | */
40 |
41 | /** @defgroup USBD_interrupt_exported_types
42 | * @{
43 | */
44 | /* includes ------------------------------------------------------------------*/
45 | #include "usbd_core.h"
46 | #include "usb_core.h"
47 |
48 | void usbd_irq_handler(otg_core_type *udev);
49 | void usbd_ept_handler(usbd_core_type *udev);
50 | void usbd_reset_handler(usbd_core_type *udev);
51 | void usbd_sof_handler(usbd_core_type *udev);
52 | void usbd_suspend_handler(usbd_core_type *udev);
53 | void usbd_wakeup_handler(usbd_core_type *udev);
54 | void usbd_inept_handler(usbd_core_type *udev);
55 | void usbd_outept_handler(usbd_core_type *udev);
56 | void usbd_ep1_in_handler(usbd_core_type *udev);
57 | void usbd_ep1_out_handler(usbd_core_type *udev);
58 | void usbd_enumdone_handler(usbd_core_type *udev);
59 | void usbd_rxflvl_handler(usbd_core_type *udev);
60 | void usbd_incomisioin_handler(usbd_core_type *udev);
61 | void usbd_discon_handler(usbd_core_type *udev);
62 | void usbd_incomisoout_handler(usbd_core_type *udev);
63 | void usb_write_empty_txfifo(usbd_core_type *udev, uint32_t ept_num);
64 |
65 | /**
66 | * @}
67 | */
68 |
69 | /**
70 | * @}
71 | */
72 |
73 | /**
74 | * @}
75 | */
76 |
77 | #ifdef __cplusplus
78 | }
79 | #endif
80 |
81 | #endif
82 |
83 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/usb_drivers/inc/usbd_sdr.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file usb_sdr.h
4 | * @brief usb header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __USB_SDR_H
27 | #define __USB_SDR_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 |
34 | /* includes ------------------------------------------------------------------*/
35 | #include "usb_conf.h"
36 | #include "usb_core.h"
37 | /** @addtogroup AT32F402_405_middlewares_usbd_drivers
38 | * @{
39 | */
40 |
41 | /** @addtogroup USBD_drivers_standard_request
42 | * @{
43 | */
44 |
45 | /** @defgroup USBD_sdr_exported_functions
46 | * @{
47 | */
48 |
49 |
50 | void usbd_setup_request_parse(usb_setup_type *setup, uint8_t *buf);
51 | usb_sts_type usbd_device_request(usbd_core_type *udev);
52 | usb_sts_type usbd_interface_request(usbd_core_type *udev);
53 | usb_sts_type usbd_endpoint_request(usbd_core_type *udev);
54 |
55 |
56 | /**
57 | * @}
58 | */
59 |
60 | /**
61 | * @}
62 | */
63 |
64 | /**
65 | * @}
66 | */
67 | #ifdef __cplusplus
68 | }
69 | #endif
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/usb_drivers/inc/usbh_int.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file usbh_int.h
4 | * @brief usb header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __USBH_INT_H
27 | #define __USBH_INT_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | /** @addtogroup AT32F402_405_middlewares_usbh_drivers
34 | * @{
35 | */
36 |
37 | /** @addtogroup USBH_drivers_int
38 | * @{
39 | */
40 |
41 | /** @defgroup USBH_interrupt_exported_types
42 | * @{
43 | */
44 |
45 | /* includes ------------------------------------------------------------------*/
46 | #include "usbh_core.h"
47 | #include "usb_core.h"
48 | void usbh_irq_handler(otg_core_type *hdev);
49 | void usbh_hch_handler(usbh_core_type *uhost);
50 | void usbh_port_handler(usbh_core_type *uhost);
51 | void usbh_disconnect_handler(usbh_core_type *uhost);
52 | void usbh_hch_in_handler(usbh_core_type *uhost, uint8_t chn);
53 | void usbh_hch_out_handler(usbh_core_type *uhost, uint8_t chn);
54 | void usbh_rx_qlvl_handler(usbh_core_type *uhost);
55 | void usbh_wakeup_handler(usbh_core_type *uhost);
56 | void usbh_sof_handler(usbh_core_type *uhost);
57 |
58 | /**
59 | * @}
60 | */
61 |
62 | /**
63 | * @}
64 | */
65 |
66 | /**
67 | * @}
68 | */
69 |
70 | #ifdef __cplusplus
71 | }
72 | #endif
73 |
74 | #endif
75 |
76 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/usbd_class/audio/audio_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file audio_conf.h
4 | * @brief usb audio config
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __AUDIO_CONF_H
27 | #define __AUDIO_CONF_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 |
34 | /** @addtogroup AT32F402_405_middlewares_usbd_class
35 | * @{
36 | */
37 |
38 | /** @addtogroup USB_audio_class
39 | * @{
40 | */
41 |
42 | /** @defgroup USB_device_audio_config_definition
43 | * @{
44 | */
45 | #define AUDIO_SUPPORT_SPK 1
46 | #define AUDIO_SUPPORT_MIC 1
47 | #define AUDIO_SUPPORT_FEEDBACK 1
48 |
49 | #define AUDIO_SUPPORT_FREQ_16K 0
50 | #define AUDIO_SUPPORT_FREQ_48K 1
51 |
52 |
53 | #define AUDIO_SUPPORT_FREQ (AUDIO_SUPPORT_FREQ_16K + \
54 | AUDIO_SUPPORT_FREQ_48K \
55 | )
56 |
57 | #define AUDIO_FREQ_16K 16000
58 | #define AUDIO_FREQ_48K 48000
59 | #define AUDIO_BITW_16 16
60 |
61 | #define AUDIO_MIC_CHANEL_NUM 2
62 | #define AUDIO_MIC_DEFAULT_BITW AUDIO_BITW_16
63 |
64 | #define AUDIO_SPK_CHANEL_NUM 2
65 | #define AUDIO_SPK_DEFAULT_BITW AUDIO_BITW_16
66 |
67 |
68 | #define AUDIO_SUPPORT_MAX_FREQ 48
69 | #define AUDIO_DEFAULT_FREQ AUDIO_FREQ_48K
70 | #define AUDIO_DEFAULT_BITW AUDIO_BITW_16
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /**
77 | * @}
78 | */
79 |
80 | /**
81 | * @}
82 | */
83 | #ifdef __cplusplus
84 | }
85 | #endif
86 |
87 | #endif
88 |
89 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/usbd_class/audio_hid/audio_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file audio_conf.h
4 | * @brief usb audio config
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __AUDIO_CONF_H
27 | #define __AUDIO_CONF_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 |
34 | /** @addtogroup AT32F402_405_middlewares_usbd_class
35 | * @{
36 | */
37 |
38 | /** @addtogroup USB_audio_hid_class
39 | * @{
40 | */
41 |
42 | /** @defgroup USB_device_audio_hid_config_definition
43 | * @{
44 | */
45 | #define AUDIO_SUPPORT_SPK 1
46 | #define AUDIO_SUPPORT_MIC 1
47 | #define AUDIO_SUPPORT_FEEDBACK 1
48 |
49 | #define AUDIO_SUPPORT_FREQ_16K 0
50 | #define AUDIO_SUPPORT_FREQ_48K 1
51 |
52 |
53 | #define AUDIO_SUPPORT_FREQ (AUDIO_SUPPORT_FREQ_16K + \
54 | AUDIO_SUPPORT_FREQ_48K \
55 | )
56 |
57 | #define AUDIO_FREQ_16K 16000
58 | #define AUDIO_FREQ_48K 48000
59 | #define AUDIO_BITW_16 16
60 |
61 | #define AUDIO_MIC_CHANEL_NUM 2
62 | #define AUDIO_MIC_DEFAULT_BITW AUDIO_BITW_16
63 |
64 | #define AUDIO_SPK_CHANEL_NUM 2
65 | #define AUDIO_SPK_DEFAULT_BITW AUDIO_BITW_16
66 |
67 |
68 | #define AUDIO_SUPPORT_MAX_FREQ 48
69 | #define AUDIO_DEFAULT_FREQ AUDIO_FREQ_48K
70 | #define AUDIO_DEFAULT_BITW AUDIO_BITW_16
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /**
77 | * @}
78 | */
79 |
80 | /**
81 | * @}
82 | */
83 | #ifdef __cplusplus
84 | }
85 | #endif
86 |
87 | #endif
88 |
89 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/usbd_class/cdc/cdc_desc.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file cdc_desc.h
4 | * @brief usb cdc descriptor header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __CDC_DESC_H
27 | #define __CDC_DESC_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "cdc_class.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_cdc_desc
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_cdc_desc_definition
45 | * @{
46 | */
47 | /**
48 | * @brief usb bcd number define
49 | */
50 | #define CDC_BCD_NUM 0x0110
51 |
52 | /**
53 | * @brief usb vendor id and product id define
54 | */
55 | #define USBD_CDC_VENDOR_ID 0x2E3C
56 | #define USBD_CDC_PRODUCT_ID 0x5740
57 |
58 | /**
59 | * @brief usb descriptor size define
60 | */
61 | #define USBD_CDC_CONFIG_DESC_SIZE 67
62 | #define USBD_CDC_SIZ_STRING_LANGID 4
63 | #define USBD_CDC_SIZ_STRING_SERIAL 0x1A
64 |
65 | /**
66 | * @brief usb string define(vendor, product configuration, interface)
67 | */
68 | #define USBD_CDC_DESC_MANUFACTURER_STRING "Artery"
69 | #define USBD_CDC_DESC_PRODUCT_STRING "AT32 Virtual Com Port "
70 | #define USBD_CDC_DESC_CONFIGURATION_STRING "Virtual ComPort Config"
71 | #define USBD_CDC_DESC_INTERFACE_STRING "Virtual ComPort Interface"
72 |
73 | /**
74 | * @brief usb endpoint interval define
75 | */
76 | #define CDC_HID_BINTERVAL_TIME 0xFF
77 |
78 | /**
79 | * @brief usb mcu id address deine
80 | */
81 | #define MCU_ID1 (0x1FFFF7E8)
82 | #define MCU_ID2 (0x1FFFF7EC)
83 | #define MCU_ID3 (0x1FFFF7F0)
84 | /**
85 | * @}
86 | */
87 |
88 | extern usbd_desc_handler cdc_desc_handler;
89 |
90 |
91 | /**
92 | * @}
93 | */
94 |
95 | /**
96 | * @}
97 | */
98 | #ifdef __cplusplus
99 | }
100 | #endif
101 |
102 | #endif
103 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/usbd_class/custom_hid/custom_hid_class.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file custom_hid_class.h
4 | * @brief usb hid header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __CUSTOM_HID_CLASS_H
27 | #define __CUSTOM_HID_CLASS_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "usb_std.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_custom_hid_class
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_custom_hid_class_endpoint_definition
45 | * @{
46 | */
47 |
48 | /**
49 | * @brief usb custom hid use endpoint define
50 | */
51 | #define USBD_CUSTOM_HID_IN_EPT 0x81
52 | #define USBD_CUSTOM_HID_OUT_EPT 0x01
53 |
54 | /**
55 | * @brief usb custom hid in and out max packet size define
56 | */
57 | #define USBD_CUSTOM_IN_MAXPACKET_SIZE 0x40
58 | #define USBD_CUSTOM_OUT_MAXPACKET_SIZE 0x40
59 |
60 | /**
61 | * @}
62 | */
63 |
64 | /** @defgroup USB_custom_hid_class_request_code_definition
65 | * @{
66 | */
67 |
68 | typedef struct
69 | {
70 | uint8_t g_rxhid_buff[USBD_CUSTOM_OUT_MAXPACKET_SIZE];
71 | uint8_t g_txhid_buff[USBD_CUSTOM_IN_MAXPACKET_SIZE];
72 |
73 | uint32_t hid_protocol;
74 | uint32_t hid_set_idle;
75 | uint32_t alt_setting;
76 |
77 | uint8_t hid_set_report[64];
78 | uint8_t hid_get_report[64];
79 | uint8_t hid_state;
80 | uint8_t send_state;
81 | }custom_hid_type;
82 |
83 | /**
84 | * @}
85 | */
86 |
87 | /** @defgroup USB_custom_hid_class_exported_functions
88 | * @{
89 | */
90 | extern usbd_class_handler custom_hid_class_handler;
91 | usb_sts_type custom_hid_class_send_report(void *udev, uint8_t *report, uint16_t len);
92 | /**
93 | * @}
94 | */
95 | /**
96 | * @}
97 | */
98 |
99 | /**
100 | * @}
101 | */
102 | #ifdef __cplusplus
103 | }
104 | #endif
105 |
106 | #endif
107 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/usbd_class/hid_iap/hid_iap_desc.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file hid_iap_desc.h
4 | * @brief usb hid iap descriptor header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __HID_IAP_DESC_H
27 | #define __HID_IAP_DESC_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "hid_iap_class.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_hid_iap_desc
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_hid_iap_desc_definition
45 | * @{
46 | */
47 |
48 |
49 | #define HIDIAP_BCD_NUM 0x0110
50 |
51 | #define USBD_HIDIAP_VENDOR_ID 0x2E3C
52 | #define USBD_HIDIAP_PRODUCT_ID 0xAF01
53 |
54 | #define USBD_HIDIAP_CONFIG_DESC_SIZE 41
55 | #define USBD_HIDIAP_SIZ_REPORT_DESC 32
56 | #define USBD_HIDIAP_SIZ_STRING_LANGID 4
57 | #define USBD_HIDIAP_SIZ_STRING_SERIAL 0x1A
58 |
59 | #define USBD_HIDIAP_DESC_MANUFACTURER_STRING "Artery"
60 | #define USBD_HIDIAP_DESC_PRODUCT_STRING "HID IAP"
61 | #define USBD_HIDIAP_DESC_CONFIGURATION_STRING "HID IAP Config"
62 | #define USBD_HIDIAP_DESC_INTERFACE_STRING "HID IAP Interface"
63 |
64 | #define HIDIAP_BINTERVAL_TIME 0x01
65 |
66 | #define MCU_ID1 (0x1FFFF7E8)
67 | #define MCU_ID2 (0x1FFFF7EC)
68 | #define MCU_ID3 (0x1FFFF7F0)
69 | extern uint8_t g_usbd_hidiap_report[USBD_HIDIAP_SIZ_REPORT_DESC];
70 | extern uint8_t g_hidiap_usb_desc[9];
71 |
72 | extern usbd_desc_handler hid_iap_desc_handler;
73 |
74 |
75 | /**
76 | * @}
77 | */
78 |
79 | /**
80 | * @}
81 | */
82 |
83 |
84 | /**
85 | * @}
86 | */
87 | #ifdef __cplusplus
88 | }
89 | #endif
90 |
91 | #endif
92 |
93 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/usbd_class/keyboard/keyboard_class.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file keyboard_class.h
4 | * @brief usb hid keyboard header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __KEYBOARD_CLASS_H
27 | #define __KEYBOARD_CLASS_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "usb_std.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_keyboard_class
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_keyboard_class_endpoint_definition
45 | * @{
46 | */
47 |
48 | /**
49 | * @brief usb hid use endpoint define
50 | */
51 | #define USBD_KEYBOARD_IN_EPT 0x81
52 |
53 | /**
54 | * @brief usb hid in and out max packet size define
55 | */
56 | #define USBD_KEYBOARD_IN_MAXPACKET_SIZE 0x40
57 | #define USBD_KEYBOARD_OUT_MAXPACKET_SIZE 0x40
58 |
59 | /**
60 | * @}
61 | */
62 |
63 |
64 | typedef struct
65 | {
66 | uint32_t hid_protocol;
67 | uint32_t hid_set_idle;
68 | uint32_t alt_setting;
69 | uint8_t hid_set_report[64];
70 | uint8_t keyboard_buf[8];
71 |
72 | __IO uint8_t hid_suspend_flag;
73 | __IO uint8_t g_u8tx_completed;
74 | uint8_t hid_state;
75 | uint8_t temp;
76 |
77 | }keyboard_type;
78 |
79 | /** @defgroup USB_hid_class_exported_functions
80 | * @{
81 | */
82 | extern usbd_class_handler keyboard_class_handler;
83 |
84 | usb_sts_type usb_keyboard_class_send_report(void *udev, uint8_t *report, uint16_t len);
85 | void usb_hid_keyboard_send_char(void *udev, uint8_t ascii_code);
86 | /**
87 | * @}
88 | */
89 |
90 | /**
91 | * @}
92 | */
93 |
94 | /**
95 | * @}
96 | */
97 | #ifdef __cplusplus
98 | }
99 | #endif
100 |
101 | #endif
102 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/usbd_class/msc/msc_class.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file msc_class.h
4 | * @brief usb msc class file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 | /* define to prevent recursive inclusion -------------------------------------*/
25 | #ifndef __MSC_CLASS_H
26 | #define __MSC_CLASS_H
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | #include "usb_std.h"
33 | #include "usbd_core.h"
34 |
35 | /** @addtogroup AT32F402_405_middlewares_usbd_class
36 | * @{
37 | */
38 |
39 | /** @addtogroup USB_msc_class
40 | * @{
41 | */
42 |
43 | /** @defgroup USB_msc_class_definition
44 | * @{
45 | */
46 |
47 | #define USBD_MSC_BULK_IN_EPT 0x81
48 | #define USBD_MSC_BULK_OUT_EPT 0x01
49 |
50 | #define USBD_IN_MAXPACKET_SIZE 0x40
51 | #define USBD_OUT_MAXPACKET_SIZE 0x40
52 |
53 | #define USBD_HS_IN_MAXPACKET_SIZE 0x200
54 | #define USBD_HS_OUT_MAXPACKET_SIZE 0x200
55 |
56 |
57 | extern usbd_class_handler msc_class_handler;
58 | /**
59 | * @}
60 | */
61 |
62 | /**
63 | * @}
64 | */
65 |
66 | /**
67 | * @}
68 | */
69 | #ifdef __cplusplus
70 | }
71 | #endif
72 |
73 | #endif
74 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/usbd_class/msc/msc_desc.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file msc_desc.h
4 | * @brief usb msc descriptor header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __MSC_DESC_H
27 | #define __MSC_DESC_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "msc_class.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_msc_desc
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_msc_desc_definition
45 | * @{
46 | */
47 |
48 | #define MSC_BCD_NUM 0x0110
49 |
50 | #define USBD_MSC_VENDOR_ID 0x2E3C
51 | #define USBD_MSC_PRODUCT_ID 0x5720
52 |
53 | #define USBD_MSC_CONFIG_DESC_SIZE 32
54 | #define USBD_MSC_SIZ_STRING_LANGID 4
55 | #define USBD_MSC_SIZ_STRING_SERIAL 0x1A
56 |
57 | #define USBD_MSC_DESC_MANUFACTURER_STRING "Artery"
58 | #define USBD_MSC_DESC_PRODUCT_STRING "AT32 Mass Storage"
59 | #define USBD_MSC_DESC_CONFIGURATION_STRING "Mass Storage Config"
60 | #define USBD_MSC_DESC_INTERFACE_STRING "Mass Storage Interface"
61 |
62 | #define MCU_ID1 (0x1FFFF7E8)
63 | #define MCU_ID2 (0x1FFFF7EC)
64 | #define MCU_ID3 (0x1FFFF7F0)
65 |
66 | extern usbd_desc_handler msc_desc_handler;
67 |
68 | /**
69 | * @}
70 | */
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /**
77 | * @}
78 | */
79 | #ifdef __cplusplus
80 | }
81 | #endif
82 |
83 | #endif
84 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/usbd_class/printer/printer_desc.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file printer_desc.h
4 | * @brief usb printer descriptor header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __PRINTER_DESC_H
27 | #define __PRINTER_DESC_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "printer_class.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_printer_desc
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_printer_desc_definition
45 | * @{
46 | */
47 |
48 | #define PRINTER_BCD_NUM 0x0110
49 |
50 | #define USBD_PRINTER_VENDOR_ID 0x2E3C
51 | #define USBD_PRINTER_PRODUCT_ID 0x57FF
52 |
53 | #define USBD_PRINTER_CONFIG_DESC_SIZE 32
54 | #define USBD_PRINTER_SIZ_STRING_LANGID 4
55 | #define USBD_PRINTER_SIZ_STRING_SERIAL 0x1A
56 |
57 | #define USBD_PRINTER_DESC_MANUFACTURER_STRING "Artery"
58 | #define USBD_PRINTER_DESC_PRODUCT_STRING "AT32 Printer"
59 | #define USBD_PRINTER_DESC_CONFIGURATION_STRING "Printer Config"
60 | #define USBD_PRINTER_DESC_INTERFACE_STRING "Printer Interface"
61 |
62 | #define PRINTER_PROTOCOL_UNIDIRECTIONAL 0x01
63 | #define PRINTER_PROTOCOL_BI_DIRECTIONAL 0x02
64 | #define PRINTER_PROTOCOL_1284_4 0x03
65 | #define PRINTER_PROTOCOL_VENDOR_SPECIFIC 0xFF
66 |
67 |
68 | #define MCU_ID1 (0x1FFFF7E8)
69 | #define MCU_ID2 (0x1FFFF7EC)
70 | #define MCU_ID3 (0x1FFFF7F0)
71 |
72 |
73 | extern usbd_desc_handler printer_desc_handler;
74 |
75 | /**
76 | * @}
77 | */
78 |
79 | /**
80 | * @}
81 | */
82 |
83 | /**
84 | * @}
85 | */
86 | #ifdef __cplusplus
87 | }
88 | #endif
89 |
90 | #endif
91 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/usbd_class/winusb/winusb_desc.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file winusb_desc.h
4 | * @brief usb winusb descriptor header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __WINUSB_DESC_H
27 | #define __WINUSB_DESC_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "winusb_class.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_winusb_desc
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_winusb_desc_definition
45 | * @{
46 | */
47 | /**
48 | * @brief usb vendor id and product id define
49 | */
50 | #define USBD_WINUSB_VENDOR_ID 0x2E3C
51 | #define USBD_WINUSB_PRODUCT_ID 0x5780
52 |
53 | /**
54 | * @brief usb descriptor size define
55 | */
56 | #define USBD_WINUSB_CONFIG_DESC_SIZE 32
57 | #define USBD_WINUSB_SIZ_STRING_LANGID 4
58 | #define USBD_WINUSB_SIZ_STRING_SERIAL 0x1A
59 |
60 | /**
61 | * @brief usb string define(vendor, product configuration, interface)
62 | */
63 | #define USBD_WINUSB_DESC_MANUFACTURER_STRING "Artery"
64 | #define USBD_WINUSB_DESC_PRODUCT_STRING "AT32 WinUSB"
65 | #define USBD_WINUSB_DESC_CONFIGURATION_STRING "WinUSB Config"
66 | #define USBD_WINUSB_DESC_INTERFACE_STRING "WinUSB Interface"
67 |
68 | /**
69 | * @brief usb mcu id address deine
70 | */
71 | #define MCU_ID1 (0x1FFFF7E8)
72 | #define MCU_ID2 (0x1FFFF7EC)
73 | #define MCU_ID3 (0x1FFFF7F0)
74 | /**
75 | * @}
76 | */
77 |
78 | extern usbd_desc_handler winusb_desc_handler;
79 |
80 |
81 | /**
82 | * @}
83 | */
84 |
85 | /**
86 | * @}
87 | */
88 | #ifdef __cplusplus
89 | }
90 | #endif
91 |
92 | #endif
93 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/usbh_class/usbh_hid/usbh_hid_keyboard.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file usbh_hid_keyboard.h
4 | * @brief usb host hid keyboard header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 | /* Define to prevent recursive inclusion -------------------------------------*/
25 | #ifndef __USBH_HID_KEYBOARD_H
26 | #define __USBH_HID_KEYBOARD_H
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | #include "usb_conf.h"
33 |
34 | /** @addtogroup AT32F402_405_middlewares_usbh_class
35 | * @{
36 | */
37 |
38 | /** @addtogroup USBH_hid_class_keyboard
39 | * @{
40 | */
41 |
42 | /** @defgroup USBH_hid_class_keyboard_definition
43 | * @{
44 | */
45 |
46 | /**
47 | * @brief usb keyboard option code
48 | */
49 | #define KEYBOARD_LEFT_CTRL 0x01
50 | #define KEYBOARD_LEFT_SHIFT 0x02
51 | #define KEYBOARD_LEFT_ALT 0x04
52 | #define KEYBOARD_LEFT_GUI 0x08
53 | #define KEYBOARD_RIGHT_CTRL 0x10
54 | #define KEYBOARD_RIGHT_SHIFT 0x20
55 | #define KEYBOARD_RIGHT_ALT 0x40
56 | #define KEYBOARD_RIGHT_GUI 0x80
57 |
58 | #define KEYBOARD_MAX_NB_PRESSED 6
59 |
60 | #ifndef AZERTY_KEYBOARD
61 | #define QWERTY_KEYBOARD
62 | #endif
63 |
64 | void usbh_hid_keyboard_decode(uint8_t *data);
65 |
66 |
67 | /**
68 | * @}
69 | */
70 |
71 | /**
72 | * @}
73 | */
74 |
75 | /**
76 | * @}
77 | */
78 | #ifdef __cplusplus
79 | }
80 | #endif
81 |
82 | #endif
83 |
--------------------------------------------------------------------------------
/fw_bridge/middlewares/usbh_class/usbh_hid/usbh_hid_mouse.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file usbh_hid_mouse.h
4 | * @brief usb host hid mouse header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 | /* Define to prevent recursive inclusion -------------------------------------*/
25 | #ifndef __USBH_HID_MOUSE_H
26 | #define __USBH_HID_MOUSE_H
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | #include "usb_conf.h"
33 |
34 | /** @addtogroup AT32F402_405_middlewares_usbh_class
35 | * @{
36 | */
37 |
38 | /** @addtogroup USBH_hid_class_mouse
39 | * @{
40 | */
41 |
42 | /** @defgroup USBH_hid_class_mouse_definition
43 | * @{
44 | */
45 |
46 | /**
47 | * @brief usb hid mouse x y
48 | */
49 | #define MOUSE_WINDOW_X 100
50 | #define MOUSE_WINDOW_Y 220
51 | #define MOUSE_WINDOW_HEIGHT 90
52 | #define MOUSE_WINDOW_WIDTH 128
53 |
54 | /**
55 | * @brief usb hid mouse button
56 | */
57 | #define MOUSE_BUTTON_LEFT 0x00
58 | #define MOUSE_BUTTON_RIGHT 0x01
59 | #define MOUSE_BUTTON_MIDDLE 0x02
60 |
61 | /**
62 | * @brief usb hid mouse type
63 | */
64 | typedef struct
65 | {
66 | uint8_t button;
67 | uint8_t x;
68 | uint8_t y;
69 | uint8_t z;
70 | }usb_hid_mouse_type;
71 |
72 | void usbh_hid_mouse_decode(uint8_t *mouse_data);
73 |
74 |
75 | /**
76 | * @}
77 | */
78 |
79 | /**
80 | * @}
81 | */
82 |
83 | /**
84 | * @}
85 | */
86 | #ifdef __cplusplus
87 | }
88 | #endif
89 |
90 | #endif
91 |
92 |
--------------------------------------------------------------------------------
/fw_bridge/project/Eclipse_gcc/.settings/language.settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/fw_bridge/project/Eclipse_gcc/.settings/org.eclipse.core.runtime.prefs:
--------------------------------------------------------------------------------
1 | content-types/enabled=true
2 | content-types/org.eclipse.cdt.core.asmSource/file-extensions=s
3 | eclipse.preferences.version=1
4 |
--------------------------------------------------------------------------------
/fw_bridge/project/inc/at32f402_405_int.h:
--------------------------------------------------------------------------------
1 | /* add user code begin Header */
2 | /**
3 | **************************************************************************
4 | * @file at32f402_405_int.h
5 | * @brief header file of main interrupt service routines.
6 | **************************************************************************
7 | * Copyright notice & Disclaimer
8 | *
9 | * The software Board Support Package (BSP) that is made available to
10 | * download from Artery official website is the copyrighted work of Artery.
11 | * Artery authorizes customers to use, copy, and distribute the BSP
12 | * software and its related documentation for the purpose of design and
13 | * development in conjunction with Artery microcontrollers. Use of the
14 | * software is governed by this copyright notice and the following disclaimer.
15 | *
16 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
17 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
18 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
19 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
20 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
22 | *
23 | **************************************************************************
24 | */
25 | /* add user code end Header */
26 |
27 | /* define to prevent recursive inclusion -------------------------------------*/
28 | #ifndef __AT32F402_405_INT_H
29 | #define __AT32F402_405_INT_H
30 |
31 | #ifdef __cplusplus
32 | extern "C" {
33 | #endif
34 |
35 | /* includes ------------------------------------------------------------------*/
36 | #include "at32f402_405.h"
37 |
38 | /* private includes ----------------------------------------------------------*/
39 | /* add user code begin private includes */
40 |
41 | /* add user code end private includes */
42 |
43 | /* exported types ------------------------------------------------------------*/
44 | /* add user code begin exported types */
45 |
46 | /* add user code end exported types */
47 |
48 | /* exported constants --------------------------------------------------------*/
49 | /* add user code begin exported constants */
50 |
51 | /* add user code end exported constants */
52 |
53 | /* exported macro ------------------------------------------------------------*/
54 | /* add user code begin exported macro */
55 |
56 | /* add user code end exported macro */
57 |
58 | /* exported functions ------------------------------------------------------- */
59 | void NMI_Handler(void);
60 | void HardFault_Handler(void);
61 | void MemManage_Handler(void);
62 | void BusFault_Handler(void);
63 | void UsageFault_Handler(void);
64 | void SVC_Handler(void);
65 | void DebugMon_Handler(void);
66 | void PendSV_Handler(void);
67 |
68 | void SysTick_Handler(void);
69 |
70 | void OTGHS_IRQHandler(void);
71 | /* add user code begin exported functions */
72 |
73 | /* add user code end exported functions */
74 |
75 | #ifdef __cplusplus
76 | }
77 | #endif
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/fw_bridge/project/inc/cdc_desc.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file cdc_desc.h
4 | * @brief usb cdc descriptor header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 |
25 | /* define to prevent recursive inclusion -------------------------------------*/
26 | #ifndef __CDC_DESC_H
27 | #define __CDC_DESC_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #include "cdc_class.h"
34 | #include "usbd_core.h"
35 |
36 | /** @addtogroup AT32F402_405_middlewares_usbd_class
37 | * @{
38 | */
39 |
40 | /** @addtogroup USB_cdc_desc
41 | * @{
42 | */
43 |
44 | /** @defgroup USB_cdc_desc_definition
45 | * @{
46 | */
47 | /**
48 | * @brief usb bcd number define
49 | */
50 | #define CDC_BCD_NUM 0x0110
51 |
52 | /**
53 | * @brief usb vendor id and product id define
54 | */
55 | #define USBD_CDC_VENDOR_ID 0x2E3C
56 | #define USBD_CDC_PRODUCT_ID 0x5740
57 |
58 | /**
59 | * @brief usb descriptor size define
60 | */
61 | #define USBD_CDC_CONFIG_DESC_SIZE 67
62 | #define USBD_CDC_SIZ_STRING_LANGID 4
63 | #define USBD_CDC_SIZ_STRING_SERIAL 0x1A
64 |
65 | /**
66 | * @brief usb string define(vendor, product configuration, interface)
67 | */
68 | #define USBD_CDC_DESC_MANUFACTURER_STRING "DUKELEC"
69 | #define USBD_CDC_DESC_PRODUCT_STRING "CDBUS Bridge"
70 | #define USBD_CDC_DESC_CONFIGURATION_STRING "Virtual ComPort Config"
71 | #define USBD_CDC_DESC_INTERFACE_STRING "Virtual ComPort Interface"
72 |
73 | /**
74 | * @brief usb endpoint interval define
75 | */
76 | #define CDC_HID_BINTERVAL_TIME 0xFF
77 |
78 | /**
79 | * @brief usb mcu id address deine
80 | */
81 | #define MCU_ID1 (0x1FFFF7E8)
82 | #define MCU_ID2 (0x1FFFF7EC)
83 | #define MCU_ID3 (0x1FFFF7F0)
84 | /**
85 | * @}
86 | */
87 |
88 | extern usbd_desc_handler cdc_desc_handler;
89 |
90 |
91 | /**
92 | * @}
93 | */
94 |
95 | /**
96 | * @}
97 | */
98 | #ifdef __cplusplus
99 | }
100 | #endif
101 |
102 | #endif
103 |
--------------------------------------------------------------------------------
/fw_bridge/project/inc/usb_app.h:
--------------------------------------------------------------------------------
1 | /* add user code begin Header */
2 | /**
3 | **************************************************************************
4 | * @file usb_app.h
5 | * @brief usb application config header file
6 | **************************************************************************
7 | * Copyright notice & Disclaimer
8 | *
9 | * The software Board Support Package (BSP) that is made available to
10 | * download from Artery official website is the copyrighted work of Artery.
11 | * Artery authorizes customers to use, copy, and distribute the BSP
12 | * software and its related documentation for the purpose of design and
13 | * development in conjunction with Artery microcontrollers. Use of the
14 | * software is governed by this copyright notice and the following disclaimer.
15 | *
16 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
17 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
18 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
19 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
20 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
22 | *
23 | **************************************************************************
24 | */
25 | /* add user code end Header */
26 |
27 | /* define to prevent recursive inclusion -------------------------------------*/
28 | #ifndef __USB_APP_H
29 | #define __USB_APP_H
30 |
31 | #ifdef __cplusplus
32 | extern "C" {
33 | #endif
34 |
35 | /* private includes -------------------------------------------------------------*/
36 | /* add user code begin private includes */
37 |
38 | /* add user code end private includes */
39 |
40 | /* private define ------------------------------------------------------------*/
41 | /* add user code begin private define */
42 |
43 | /* add user code end private define */
44 |
45 | /* exported types -------------------------------------------------------------*/
46 | /* add user code begin exported types */
47 |
48 | /* add user code end exported types */
49 |
50 | /* exported constants --------------------------------------------------------*/
51 | /* add user code begin exported constants */
52 |
53 | /* add user code end exported constants */
54 |
55 | /* exported macro ------------------------------------------------------------*/
56 | /* add user code begin exported macro */
57 |
58 | /* add user code end exported macro */
59 |
60 | void wk_usb_app_init(void);
61 |
62 | void wk_usb_app_task(void);
63 |
64 | void wk_otghs_irq_handler(void);
65 |
66 | /* add user code begin exported functions */
67 |
68 | /* add user code end exported functions */
69 |
70 | #ifdef __cplusplus
71 | }
72 | #endif
73 |
74 | #endif
75 |
--------------------------------------------------------------------------------
/fw_bridge/project/inc/wk_system.h:
--------------------------------------------------------------------------------
1 | /**
2 | **************************************************************************
3 | * @file wk_system.h
4 | * @brief workbench system header file
5 | **************************************************************************
6 | * Copyright notice & Disclaimer
7 | *
8 | * The software Board Support Package (BSP) that is made available to
9 | * download from Artery official website is the copyrighted work of Artery.
10 | * Artery authorizes customers to use, copy, and distribute the BSP
11 | * software and its related documentation for the purpose of design and
12 | * development in conjunction with Artery microcontrollers. Use of the
13 | * software is governed by this copyright notice and the following disclaimer.
14 | *
15 | * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
16 | * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
17 | * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
18 | * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
19 | * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
21 | *
22 | **************************************************************************
23 | */
24 | /* define to prevent recursive inclusion -------------------------------------*/
25 | #ifndef __WK_SYSTEM_H
26 | #define __WK_SYSTEM_H
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | #include "at32f402_405.h"
33 |
34 | void wk_timebase_init(void);
35 | void wk_timebase_handler(void);
36 | void wk_delay_ms(uint32_t delay);
37 |
38 | #ifdef __cplusplus
39 | }
40 | #endif
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/fw_bridge/usr/app_main.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __APP_MAIN_H__
11 | #define __APP_MAIN_H__
12 |
13 | #include "cd_utils.h"
14 | #include "cd_list.h"
15 | #include "cdbus_uart.h"
16 | #include "cdctl_it.h"
17 | #include "modbus_crc.h"
18 |
19 | #include "usb_conf.h"
20 | #include "usb_core.h"
21 | #include "wk_system.h"
22 | #include "usbd_int.h"
23 | #include "cdc_class.h"
24 | #include "cdc_desc.h"
25 |
26 | #define BITS_SET(val, set) ((val) |= (set))
27 | #define BITS_CLR(val, clr) ((val) &= ~(clr))
28 | #define BITS_SET_CLR(val, set, clr) ((val) = ((val) | (set)) & ~(clr))
29 |
30 | #define BL_ARGS 0x20000000 // first word
31 | #define APP_CONF_ADDR 0x0803F800 // last page
32 | #define APP_CONF_VER 0x0201
33 |
34 | #define FRAME_MAX 80
35 |
36 |
37 | typedef struct {
38 | uint16_t offset;
39 | uint16_t size;
40 | } regr_t; // reg range
41 |
42 |
43 | typedef struct {
44 | uint16_t magic_code; // 0xcdcd
45 | uint16_t conf_ver;
46 | uint8_t conf_from; // 0: default, 1: all from flash, 2: partly from flash
47 | uint8_t do_reboot;
48 | bool _reserved0;
49 | bool save_conf;
50 |
51 | bool dbg_en;
52 | #define _end_common _reserved1
53 | uint8_t _reserved1[4];
54 |
55 | cdctl_cfg_t bus_cfg;
56 | uint32_t limit_baudrate0;
57 | uint32_t limit_baudrate1;
58 |
59 | // end of flash
60 | #define _end_save usb_online
61 |
62 | bool usb_online;
63 |
64 | } csa_t; // config status area
65 |
66 | extern csa_t csa;
67 | extern const csa_t csa_dft;
68 |
69 |
70 | int flash_erase(uint32_t addr, uint32_t len);
71 | int flash_write(uint32_t addr, uint32_t len, const uint8_t *buf);
72 |
73 | extern list_head_t frame_free_head;
74 | extern cduart_dev_t d_dev; // uart / usb
75 | extern volatile uint8_t cdc_dtr;
76 | extern otg_core_type otg_core_struct_hs;
77 |
78 | extern uint32_t end; // end of bss
79 |
80 | void common_service_init(void);
81 | void common_service_routine(void);
82 |
83 | void app_main(void);
84 | void load_conf(void);
85 | int save_conf(void);
86 | void csa_list_show(void);
87 |
88 | #endif
89 |
--------------------------------------------------------------------------------
/fw_bridge/usr/cd_config.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __CD_CONFIG_H__
11 | #define __CD_CONFIG_H__
12 |
13 | #define CDCTL_OSC_CLK 12000000UL // 12MHz
14 |
15 | //#define ARCH_SPI
16 | #define ARCH_CRC_HW
17 | #define CDUART_CRC crc16_hw
18 | #define CDUART_CRC_SUB crc16_hw_sub
19 |
20 | #define CD_FRAME_SIZE 258
21 | #define CDN_MAX_DAT 253
22 |
23 | #define DEBUG
24 | //#define VERBOSE
25 | //#define LIST_DEBUG
26 |
27 | #define CD_LIST_IT
28 | #define CD_IRQ_SAFE
29 |
30 | #define CDUART_IDLE_TIME (500000 / SYSTICK_US_DIV) // 500 ms
31 |
32 | #include "at32f402_405_wk_config.h"
33 | #include "debug_config.h"
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/fw_bridge/usr/cdctl_spi_wr.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #include "cdctl_spi_wr.h"
11 | #include "app_main.h"
12 |
13 | #define CCR ctrl
14 | #define CNDTR dtcnt
15 | #define CMAR maddr
16 | #define CPAR paddr
17 | #define ISR sts
18 | #define IFCR clr
19 | #define DMA_CCR_EN (1 << 0)
20 | #define DMA_CCR_TCIE (1 << 1)
21 |
22 | #define SR sts
23 | #define DR dt
24 | #define CR1 ctrl1
25 | #define CR2 ctrl2
26 | #define SPI_FLAG_BSY (1 << 7)
27 | #define SPI_CR1_SPE (1 << 6)
28 | #define SPI_CR2_RXDMAEN (1 << 0)
29 | #define SPI_CR2_TXDMAEN (1 << 1)
30 |
31 |
32 | uint8_t cdctl_buf[2];
33 |
34 |
35 | static void cdctl_spi_wr(const uint8_t *w_buf, uint8_t *r_buf, int len)
36 | {
37 | CD_DMA_R->CCR &= ~(DMA_CCR_EN | DMA_CCR_TCIE);
38 | CD_DMA_R->CNDTR = len;
39 | CD_DMA_R->CMAR = (uint32_t)r_buf;
40 | CD_DMA_R->CCR |= DMA_CCR_EN;
41 |
42 | CD_DMA_W->CCR &= ~DMA_CCR_EN;
43 | CD_DMA_W->CNDTR = len;
44 | CD_DMA_W->CMAR = (uint32_t)w_buf;
45 | CD_DMA_W->CCR |= DMA_CCR_EN;
46 |
47 | while (!(CD_DMA->ISR & CD_DMA_MASK));
48 | CD_DMA->IFCR = CD_DMA_MASK;
49 | }
50 |
51 | void cdctl_spi_wr_it(const uint8_t *w_buf, uint8_t *r_buf, int len)
52 | {
53 | CD_DMA_R->CCR &= ~DMA_CCR_EN;
54 | CD_DMA_R->CNDTR = len;
55 | CD_DMA_R->CMAR = (uint32_t)r_buf;
56 | CD_DMA_R->CCR |= DMA_CCR_TCIE | DMA_CCR_EN;
57 |
58 | CD_DMA_W->CCR &= ~DMA_CCR_EN;
59 | CD_DMA_W->CNDTR = len;
60 | CD_DMA_W->CMAR = (uint32_t)w_buf;
61 | CD_DMA_W->CCR |= DMA_CCR_EN;
62 | }
63 |
64 |
65 | void cdctl_spi_wr_isr(void)
66 | {
67 | //uint32_t flag_it = CD_DMA->ISR;
68 | //if (flag_it & CD_DMA_MASK) {
69 | CD_DMA->IFCR = CD_DMA_MASK;
70 | cdctl_spi_isr();
71 | //}
72 | }
73 |
74 |
75 | void cdctl_spi_wr_init(void)
76 | {
77 | BITS_SET(CD_SPI->CR1, SPI_CR1_SPE); // enable spi
78 | BITS_SET(CD_SPI->CR2, SPI_CR2_RXDMAEN);
79 | BITS_SET(CD_SPI->CR2, SPI_CR2_TXDMAEN);
80 | CD_DMA_R->CCR &= ~DMA_CCR_EN;
81 | CD_DMA_W->CCR &= ~DMA_CCR_EN;
82 | CD_DMA_W->CPAR = (uint32_t)&CD_SPI->DR;
83 | CD_DMA_R->CPAR = (uint32_t)&CD_SPI->DR;
84 | }
85 |
86 |
87 | uint8_t cdctl_reg_r(uint8_t reg)
88 | {
89 | volatile uint16_t dat = 0xffff;
90 | uint8_t tbuf[2] = {reg};
91 | irq_disable(CD_IRQ);
92 | while (cdctl_state > CDCTL_IDLE) {}
93 | CD_SS_LOW();
94 | cdctl_spi_wr(tbuf, (uint8_t *)&dat, 2);
95 | CD_SS_HIGH();
96 | irq_enable(CD_IRQ);
97 | return dat >> 8;
98 | }
99 |
100 | void cdctl_reg_w(uint8_t reg, uint8_t val)
101 | {
102 | uint8_t tbuf[2] = {reg | 0x80, val};
103 | irq_disable(CD_IRQ);
104 | while (cdctl_state > CDCTL_IDLE) {}
105 | CD_SS_LOW();
106 | cdctl_spi_wr(tbuf, tbuf, 2);
107 | CD_SS_HIGH();
108 | irq_enable(CD_IRQ);
109 | }
110 |
--------------------------------------------------------------------------------
/fw_bridge/usr/cdctl_spi_wr.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __CDCTL_SPI_WR_H__
11 | #define __CDCTL_SPI_WR_H__
12 |
13 | #include "cd_utils.h"
14 | #include "cd_list.h"
15 |
16 | #define CD_SPI SPI1
17 | #define CD_DMA_R DMA1_CHANNEL1
18 | #define CD_DMA_W DMA1_CHANNEL2
19 | #define CD_DMA DMA1
20 | #define CD_DMA_MASK (2 << 0) // DMA_ISR.TCIF1
21 |
22 | #define CD_SS_HIGH() {CD_SS_GPIO_PORT->scr = CD_SS_PIN;}
23 | #define CD_SS_LOW() {CD_SS_GPIO_PORT->clr = CD_SS_PIN;}
24 | #define CD_INT_RD() (CD_INT_GPIO_PORT->idt & CD_INT_PIN)
25 | #define CD_IRQ EXINT0_IRQn
26 |
27 | extern uint8_t cdctl_buf[];
28 |
29 | void cdctl_spi_wr_it(const uint8_t *w_buf, uint8_t *r_buf, int len);
30 | void cdctl_spi_wr_isr(void);
31 | void cdctl_spi_wr_init(void);
32 |
33 | uint8_t cdctl_reg_r(uint8_t reg);
34 | void cdctl_reg_w(uint8_t reg, uint8_t val);
35 |
36 |
37 | static inline void cdctl_reg_r_it(uint8_t reg)
38 | {
39 | cdctl_buf[0] = reg;
40 | CD_SS_LOW();
41 | cdctl_spi_wr_it(cdctl_buf, cdctl_buf, 2);
42 | }
43 |
44 | static inline void cdctl_reg_w_it(uint8_t reg, uint8_t val)
45 | {
46 | cdctl_buf[0] = reg | 0x80;
47 | cdctl_buf[1] = val;
48 | CD_SS_LOW();
49 | cdctl_spi_wr_it(cdctl_buf, cdctl_buf, 2);
50 | }
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/fw_bridge/usr/debug_config.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __DEBUG_CONFIG_H__
11 | #define __DEBUG_CONFIG_H__
12 |
13 | #include "arch_wrapper.h"
14 |
15 | static inline void dbg_transmit(const uint8_t *buf, uint16_t len)
16 | {
17 | for (uint16_t i = 0; i < len; i++) {
18 | while (!(UART7->sts & USART_TDBE_FLAG));
19 | UART7->dt = *(buf + i);
20 | }
21 | }
22 |
23 |
24 | #ifndef d_printf
25 | #define d_printf(fmt, ...) printf(fmt, ## __VA_ARGS__)
26 | #endif
27 |
28 | #define d_info(fmt, ...) d_printf("I: " fmt, ## __VA_ARGS__)
29 | #ifndef d_warn
30 | #define d_warn(fmt, ...) d_printf("W: " fmt, ## __VA_ARGS__)
31 | #endif
32 | #ifndef d_error
33 | #define d_error(fmt, ...) d_printf("E: " fmt, ## __VA_ARGS__)
34 | #endif
35 |
36 | #define dn_info(name, fmt, ...) d_info("%s: " fmt, name, ## __VA_ARGS__)
37 | #define dn_warn(name, fmt, ...) d_warn("%s: " fmt, name, ## __VA_ARGS__)
38 | #define dn_error(name, fmt, ...) d_error("%s: " fmt, name, ## __VA_ARGS__)
39 |
40 | #define df_info(fmt, ...) dn_info(__FUNCTION__, fmt, ## __VA_ARGS__)
41 | #define df_warn(fmt, ...) dn_warn(__FUNCTION__, fmt, ## __VA_ARGS__)
42 | #define df_error(fmt, ...) dn_error(__FUNCTION__, fmt, ## __VA_ARGS__)
43 |
44 | #define dnf_info(name, fmt, ...) d_info("%s: %s: " fmt, name, __FUNCTION__, ## __VA_ARGS__)
45 | #define dnf_warn(name, fmt, ...) d_warn("%s: %s: " fmt, name, __FUNCTION__, ## __VA_ARGS__)
46 | #define dnf_error(name, fmt, ...) d_error("%s: %s: " fmt, name, __FUNCTION__, ## __VA_ARGS__)
47 |
48 | #ifdef VERBOSE
49 | #define d_verbose_c(fmt, ...) d_printf(fmt, ## __VA_ARGS__)
50 | #define d_verbose(fmt, ...) d_printf("V: " fmt, ## __VA_ARGS__)
51 | #define dn_verbose(name, fmt, ...) d_verbose("%s: " fmt, name, ## __VA_ARGS__)
52 | #define df_verbose(fmt, ...) dn_verbose(__FUNCTION__, fmt, ## __VA_ARGS__)
53 | #define dnf_verbose(name, fmt, ...) d_verbose("%s: %s: " fmt, name, __FUNCTION__, ## __VA_ARGS__)
54 | #ifndef DEBUG
55 | #define DEBUG
56 | #endif // DEBUG
57 | #else
58 | #define d_verbose_c(fmt, ...) do {} while (0)
59 | #define d_verbose(fmt, ...) do {} while (0)
60 | #define dn_verbose(name, ...) do {} while (0)
61 | #define df_verbose(name, ...) do {} while (0)
62 | #define dnf_verbose(name, ...) do {} while (0)
63 | #endif
64 |
65 | #ifdef DEBUG
66 | #define d_debug_c(fmt, ...) d_printf(fmt, ## __VA_ARGS__)
67 | #define d_debug(fmt, ...) d_printf("D: " fmt, ## __VA_ARGS__)
68 | #define dn_debug(name, fmt, ...) d_debug("%s: " fmt, name, ## __VA_ARGS__)
69 | #define df_debug(fmt, ...) dn_debug(__FUNCTION__, fmt, ## __VA_ARGS__)
70 | #define dnf_debug(name, fmt, ...) d_debug("%s: %s: " fmt, name, __FUNCTION__, ## __VA_ARGS__)
71 | #else
72 | #define d_debug_c(fmt, ...) do {} while (0)
73 | #define d_debug(fmt, ...) do {} while (0)
74 | #define dn_debug(name, ...) do {} while (0)
75 | #define df_debug(name, ...) do {} while (0)
76 | #define dnf_debug(name, ...) do {} while (0)
77 | #endif
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/fw_bridge/utils/cd_frame.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __CD_FRAME_H__
11 | #define __CD_FRAME_H__
12 |
13 | #include "cd_list.h"
14 |
15 | // 256 bytes are enough for the CDCTL controller (without CRC)
16 | // 258 bytes are enough for the UART controller (with CRC)
17 | // allow smaller sizes to save memory
18 | #ifndef CD_FRAME_SIZE
19 | #define CD_FRAME_SIZE 256
20 | #endif
21 |
22 | typedef struct {
23 | list_node_t node;
24 | uint8_t dat[CD_FRAME_SIZE];
25 | } cd_frame_t;
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/fw_bridge/utils/cd_list.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __CD_LIST_H__
11 | #define __CD_LIST_H__
12 |
13 | typedef struct list_node {
14 | struct list_node *next;
15 | } list_node_t;
16 |
17 | typedef struct {
18 | list_node_t *first;
19 | list_node_t *last;
20 | uint32_t len;
21 | } list_head_t;
22 |
23 |
24 | list_node_t *list_get(list_head_t *head);
25 | void list_put(list_head_t *head, list_node_t *node);
26 |
27 | list_node_t *list_get_last(list_head_t *head);
28 | void list_put_begin(list_head_t *head, list_node_t *node);
29 | void list_pick(list_head_t *head, list_node_t *pre, list_node_t *node);
30 | void list_move_begin(list_head_t *head, list_node_t *pre, list_node_t *node);
31 |
32 |
33 | #define list_entry(ptr, type) \
34 | container_of(ptr, type, node)
35 |
36 | #define list_entry_safe(ptr, type) ({ \
37 | list_node_t *__ptr = (ptr); \
38 | __ptr ? container_of(__ptr, type, node) : NULL; \
39 | })
40 |
41 | #define list_get_entry(head, type) \
42 | list_entry_safe(list_get(head), type)
43 |
44 | #ifdef CD_LIST_IT
45 | #define list_get_entry_it(head, type) \
46 | list_entry_safe(list_get_it(head), type)
47 | #endif
48 |
49 | #define list_for_each(head, pre, pos) \
50 | for (pre = NULL, pos = (head)->first; pos != NULL; \
51 | pre = pos, pos = (pos ? (pos)->next : (head)->first))
52 | // you can remove a node during the loop:
53 | // list_pick(head, pre, pos);
54 | // pos = pre;
55 |
56 | // read only version:
57 | #define list_for_each_ro(head, pos) \
58 | for (pos = (head)->first; pos != NULL; \
59 | pos = (pos ? (pos)->next : (head)->first))
60 |
61 | #define list_head_init(head) \
62 | memset(head, 0, sizeof(list_head_t))
63 |
64 |
65 | #ifdef CD_LIST_IT
66 |
67 | static inline list_node_t *list_get_it(list_head_t *head)
68 | {
69 | uint32_t flags;
70 | list_node_t *node;
71 | local_irq_save(flags);
72 | node = list_get(head);
73 | local_irq_restore(flags);
74 | return node;
75 | }
76 |
77 | static inline void list_put_it(list_head_t *head, list_node_t *node)
78 | {
79 | uint32_t flags;
80 | local_irq_save(flags);
81 | list_put(head, node);
82 | local_irq_restore(flags);
83 | }
84 |
85 | static inline void list_put_begin_it(list_head_t *head, list_node_t *node)
86 | {
87 | uint32_t flags;
88 | local_irq_save(flags);
89 | list_put_begin(head, node);
90 | local_irq_restore(flags);
91 | }
92 |
93 | #endif // CD_LIST_IT
94 |
95 | #endif
96 |
--------------------------------------------------------------------------------
/fw_bridge/utils/cdbus_uart.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #include "cd_utils.h"
11 | #include "cd_list.h"
12 | #include "cdbus_uart.h"
13 |
14 |
15 | void cduart_dev_init(cduart_dev_t *dev, list_head_t *free_head)
16 | {
17 | dev->rx_frame = cd_list_get(free_head);
18 | dev->free_head = free_head;
19 | dev->t_last = get_systick();
20 | dev->rx_crc = 0xffff;
21 |
22 | #ifdef USE_DYNAMIC_INIT
23 | list_head_init(&dev->rx_head);
24 | list_head_init(&dev->tx_head);
25 | dev->rx_byte_cnt = 0;
26 | dev->rx_drop = false;
27 | #endif
28 | }
29 |
30 |
31 | void cduart_rx_handle(cduart_dev_t *dev, const uint8_t *buf, unsigned len)
32 | {
33 | unsigned max_len;
34 | unsigned cpy_len;
35 | const uint8_t *rd = buf;
36 |
37 | while (true) {
38 | cd_frame_t *frame = dev->rx_frame;
39 |
40 | if (dev->rx_byte_cnt != 0 && get_systick() - dev->t_last > CDUART_IDLE_TIME) {
41 | printf("bus: timeout [%02x %02x %02x] %d, %d\n",
42 | frame->dat[0], frame->dat[1], frame->dat[2], dev->rx_byte_cnt, dev->rx_drop);
43 | for (int i = 0; i < dev->rx_byte_cnt; i++)
44 | printf("%02x ", frame->dat[i]);
45 | printf("\n");
46 | dev->rx_byte_cnt = 0;
47 | dev->rx_crc = 0xffff;
48 | dev->rx_drop = false;
49 | }
50 |
51 | if (!len || rd == buf + len)
52 | return;
53 | max_len = buf + len - rd;
54 | dev->t_last = get_systick();
55 |
56 | if (dev->rx_byte_cnt < 3)
57 | cpy_len = min(3 - dev->rx_byte_cnt, max_len);
58 | else
59 | cpy_len = min(frame->dat[2] + 5 - dev->rx_byte_cnt, max_len);
60 |
61 | if (!dev->rx_drop)
62 | memcpy(frame->dat + dev->rx_byte_cnt, rd, cpy_len);
63 | dev->rx_byte_cnt += cpy_len;
64 |
65 | if (dev->rx_byte_cnt == 3 &&
66 | frame->dat[2] > CD_FRAME_SIZE - 5) {
67 | // (frame->dat[2] > CD_FRAME_SIZE - 5 || (frame->dat[1] != 0xff && frame->dat[1] != dev->local_mac))) {
68 | printf("bus: drop [%x %x %x]\n", frame->dat[0], frame->dat[1], frame->dat[2]);
69 | dev->rx_drop = true;
70 | }
71 |
72 | if (!dev->rx_drop)
73 | dev->rx_crc = CDUART_CRC_SUB(rd, cpy_len, dev->rx_crc);
74 | rd += cpy_len;
75 |
76 | if (dev->rx_byte_cnt == frame->dat[2] + 5) {
77 | if (!dev->rx_drop) {
78 | if (dev->rx_crc != 0) {
79 | printf("bus: !crc [%x %x %x]\n", frame->dat[0], frame->dat[1], frame->dat[2]);
80 |
81 | } else {
82 | cd_frame_t *frm = cd_list_get(dev->free_head);
83 | if (frm) {
84 | cd_list_put(&dev->rx_head, dev->rx_frame);
85 | dev->rx_frame = frm;
86 | } else {
87 | printf("bus: rx lost\n");
88 | }
89 | }
90 | }
91 | dev->rx_byte_cnt = 0;
92 | dev->rx_crc = 0xffff;
93 | dev->rx_drop = false;
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/fw_bridge/utils/cdbus_uart.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __CDBUS_UART_H__
11 | #define __CDBUS_UART_H__
12 |
13 | #include "modbus_crc.h"
14 | #include "cd_frame.h"
15 |
16 | #ifndef CDUART_IDLE_TIME
17 | #define CDUART_IDLE_TIME 5 // ms
18 | #endif
19 | #ifndef CDUART_CRC
20 | #define CDUART_CRC crc16
21 | #endif
22 | #ifndef CDUART_CRC_SUB
23 | #define CDUART_CRC_SUB crc16_sub
24 | #endif
25 |
26 | #ifdef CD_IRQ_SAFE
27 | #define cd_list_get(head) list_get_entry_it(head, cd_frame_t)
28 | #define cd_list_put(head, frm) list_put_it(head, &(frm)->node)
29 | #elif !defined(CD_USER_LIST)
30 | #define cd_list_get(head) list_get_entry(head, cd_frame_t)
31 | #define cd_list_put(head, frm) list_put(head, &(frm)->node)
32 | #endif
33 |
34 |
35 | typedef struct cduart_dev {
36 | list_head_t *free_head;
37 | list_head_t rx_head;
38 | list_head_t tx_head;
39 |
40 | cd_frame_t *rx_frame; // init: != NULL
41 | uint16_t rx_byte_cnt;
42 | uint16_t rx_crc;
43 | bool rx_drop;
44 | uint32_t t_last; // last receive time
45 |
46 | uint8_t local_mac;
47 | } cduart_dev_t;
48 |
49 |
50 | static inline cd_frame_t *cduart_get_rx_frame(cduart_dev_t *dev)
51 | {
52 | return cd_list_get(&dev->rx_head);
53 | }
54 |
55 | static inline void cduart_put_tx_frame(cduart_dev_t *dev, cd_frame_t *frame)
56 | {
57 | cd_list_put(&dev->tx_head, frame);
58 | }
59 |
60 |
61 | void cduart_dev_init(cduart_dev_t *dev, list_head_t *free_head);
62 | void cduart_rx_handle(cduart_dev_t *dev, const uint8_t *buf, unsigned len);
63 |
64 | static inline void cduart_fill_crc(uint8_t *dat)
65 | {
66 | uint16_t crc_val = CDUART_CRC(dat, dat[2] + 3);
67 | dat[dat[2] + 3] = crc_val & 0xff;
68 | dat[dat[2] + 4] = crc_val >> 8;
69 | }
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/fw_bridge/utils/cdctl.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __CDCTL_H__
11 | #define __CDCTL_H__
12 |
13 | #include "cd_utils.h"
14 | #include "cd_list.h"
15 | #include "cdctl_regs.h"
16 | #include "cd_frame.h"
17 |
18 |
19 | typedef struct {
20 | uint8_t mac;
21 | uint32_t baud_l;
22 | uint32_t baud_h;
23 | uint8_t filter_m[2];
24 |
25 | uint8_t mode; // 0: Arbitration, 1: Break Sync
26 | uint16_t tx_permit_len;
27 | uint16_t max_idle_len;
28 | uint8_t tx_pre_len;
29 | } cdctl_cfg_t;
30 |
31 | #define CDCTL_CFG_DFT(_mac) { \
32 | .mac = _mac, \
33 | .baud_l = 115200, \
34 | .baud_h = 115200, \
35 | .filter_m = { 0xff, 0xff }, \
36 | .mode = 0, \
37 | .tx_permit_len = 0x14, \
38 | .max_idle_len = 0xc8, \
39 | .tx_pre_len = 0x01 \
40 | }
41 |
42 |
43 | uint8_t cdctl_reg_r(uint8_t reg);
44 | void cdctl_reg_w(uint8_t reg, uint8_t val);
45 | void cdctl_set_baud_rate(uint32_t low, uint32_t high);
46 | void cdctl_get_baud_rate(uint32_t *low, uint32_t *high);
47 |
48 | void cdctl_routine(void);
49 | void cdctl_dev_init(cdctl_cfg_t *init, spi_t *spi);
50 |
51 | static inline void cdctl_flush(void)
52 | {
53 | cdctl_reg_w(REG_RX_CTRL, BIT_RX_RST_ALL);
54 | }
55 |
56 | void cdctl_put_tx_frame(cd_frame_t *frame);
57 |
58 |
59 | #define cdctl_state 0
60 |
61 | extern list_head_t cdctl_rx_head;
62 | extern list_head_t cdctl_tx_head;
63 |
64 | extern uint32_t cdctl_rx_cnt;
65 | extern uint32_t cdctl_tx_cnt;
66 | extern uint32_t cdctl_rx_lost_cnt;
67 | extern uint32_t cdctl_rx_error_cnt;
68 | extern uint32_t cdctl_rx_break_cnt;
69 | extern uint32_t cdctl_tx_cd_cnt;
70 | extern uint32_t cdctl_tx_error_cnt;
71 | extern uint32_t cdctl_rx_no_free_node_cnt;
72 | extern uint32_t cdctl_rx_len_err_cnt;
73 |
74 | #endif
75 |
--------------------------------------------------------------------------------
/fw_bridge/utils/cdctl_it.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __CDCTL_IT_H__
11 | #define __CDCTL_IT_H__
12 |
13 | #include "cd_utils.h"
14 | #include "cd_list.h"
15 | #include "cdctl_regs.h"
16 | #include "cdctl_spi_wr.h"
17 | #include "cd_frame.h"
18 |
19 |
20 | typedef enum {
21 | CDCTL_RST = 0,
22 |
23 | CDCTL_IDLE,
24 | CDCTL_WAIT_TX_CLEAN,
25 | CDCTL_RD_FLAG,
26 | CDCTL_REG_W,
27 |
28 | CDCTL_RX_HEADER,
29 | CDCTL_RX_BODY,
30 | CDCTL_TX_FRAME
31 | } cdctl_state_t;
32 |
33 |
34 | typedef struct {
35 | uint8_t mac;
36 | uint32_t baud_l;
37 | uint32_t baud_h;
38 | uint8_t filter_m[2];
39 |
40 | uint8_t mode; // 0: Arbitration, 1: Break Sync
41 | uint16_t tx_permit_len;
42 | uint16_t max_idle_len;
43 | uint8_t tx_pre_len;
44 | } cdctl_cfg_t;
45 |
46 | #define CDCTL_CFG_DFT(_mac) { \
47 | .mac = _mac, \
48 | .baud_l = 115200, \
49 | .baud_h = 115200, \
50 | .filter_m = { 0xff, 0xff }, \
51 | .mode = 0, \
52 | .tx_permit_len = 0x14, \
53 | .max_idle_len = 0xc8, \
54 | .tx_pre_len = 0x01 \
55 | }
56 |
57 | void cdctl_dev_init(cdctl_cfg_t *init);
58 |
59 | void cdctl_set_clk(uint32_t target_baud);
60 | void cdctl_set_baud_rate(uint32_t low, uint32_t high);
61 | void cdctl_get_baud_rate(uint32_t *low, uint32_t *high);
62 |
63 | void cdctl_put_tx_frame(cd_frame_t *frame);
64 |
65 | static inline void cdctl_flush(void)
66 | {
67 | cdctl_reg_w(REG_RX_CTRL, BIT_RX_RST_ALL);
68 | }
69 |
70 | void cdctl_int_isr(void);
71 | void cdctl_spi_isr(void);
72 |
73 |
74 | extern volatile cdctl_state_t cdctl_state;
75 |
76 | extern list_head_t cdctl_rx_head;
77 | extern list_head_t cdctl_tx_head;
78 |
79 | extern volatile uint32_t cdctl_rx_cnt;
80 | extern volatile uint32_t cdctl_tx_cnt;
81 | extern volatile uint32_t cdctl_rx_lost_cnt;
82 | extern volatile uint32_t cdctl_rx_error_cnt;
83 | extern volatile uint32_t cdctl_rx_break_cnt;
84 | extern volatile uint32_t cdctl_tx_cd_cnt;
85 | extern volatile uint32_t cdctl_tx_error_cnt;
86 | extern volatile uint32_t cdctl_rx_no_free_node_cnt;
87 | extern volatile uint32_t cdctl_rx_len_err_cnt;
88 |
89 | #endif
90 |
--------------------------------------------------------------------------------
/fw_bridge/utils/cdctl_pll_cal.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #include "cd_utils.h"
11 | #include "cdctl_pll_cal.h"
12 |
13 |
14 | pllcfg_t cdctl_pll_cal(uint32_t input, uint32_t output) {
15 | pllcfg_t best = {0, 0, 0, 0xffffffff, 0xffffffff};
16 | uint32_t min_vco = 100e6L, max_vco = 500e6L, target_vco = 300e6L;
17 | uint32_t min_div_freq = 1e6L, max_div_freq = 15e6L, target_div_freq = 8e6L;
18 |
19 | for (int d = 0; d <= 2; d++) {
20 | uint32_t factor_d = 1 << d; // pow(2, d)
21 |
22 | for (int n = 31; n >= 0; n--) {
23 | uint32_t div_freq = DIV_ROUND_CLOSEST(input, n + 2);
24 | if (div_freq < min_div_freq)
25 | continue;
26 | if (div_freq > max_div_freq)
27 | break;
28 |
29 | for (int m = 0; m < 512; m++) {
30 | uint32_t vco_freq = div_freq * (m + 2);
31 | if (vco_freq < min_vco)
32 | continue;
33 | if (vco_freq > max_vco)
34 | break;
35 |
36 | uint32_t computed_output = DIV_ROUND_CLOSEST(vco_freq, factor_d);
37 | uint32_t error = abs((int32_t)(computed_output - output));
38 |
39 | // optimize div_freq and vco_freq
40 | uint32_t div_freq_deviation = abs((int32_t)(div_freq - target_div_freq));
41 | uint32_t vco_freq_deviation = abs((int32_t)(vco_freq - target_vco));
42 | uint32_t total_deviation = div_freq_deviation * 10 + vco_freq_deviation;
43 |
44 | if (error < best.error || (error == best.error && total_deviation < best.deviation)) {
45 | best.n = n;
46 | best.m = m;
47 | best.d = d;
48 | best.error = error;
49 | best.deviation = total_deviation;
50 | }
51 | }
52 | }
53 | }
54 |
55 | if (best.d == 2)
56 | best.d = 3;
57 | return best;
58 | }
59 |
60 |
61 | uint32_t cdctl_pll_get(uint32_t input, pllcfg_t cfg)
62 | {
63 | if (cfg.d == 3)
64 | cfg.d = 2;
65 | uint32_t div_freq = DIV_ROUND_CLOSEST(input, cfg.n + 2);
66 | uint32_t vco_freq = div_freq * (cfg.m + 2);
67 | return vco_freq / (1 << cfg.d);
68 | }
69 |
70 |
71 | uint32_t cdctl_sys_cal(uint32_t baud) {
72 | uint32_t best[2] = {0, 0xffffffff};
73 | uint32_t clk_max = 150e6L;
74 | uint32_t clk_min = 100e6L; // higher sysclk for higher spi clk
75 | uint32_t clk_step = 2e5L;
76 |
77 | for (uint32_t c = clk_max; c >= clk_min; c -= clk_step) {
78 | uint32_t div = min(65535, DIV_ROUND_CLOSEST(c, baud));
79 | uint32_t error = abs((int32_t)(DIV_ROUND_CLOSEST(c, div) - baud));
80 |
81 | if (error < best[1]) {
82 | best[0] = c;
83 | best[1] = error;
84 | if (error == 0)
85 | break;
86 | }
87 | }
88 |
89 | return best[0];
90 | }
91 |
--------------------------------------------------------------------------------
/fw_bridge/utils/cdctl_pll_cal.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __CDCTL_PLL_CAL_H__
11 | #define __CDCTL_PLL_CAL_H__
12 |
13 | typedef struct {
14 | uint8_t n;
15 | uint16_t m;
16 | uint8_t d;
17 | uint32_t error;
18 | uint32_t deviation;
19 | } pllcfg_t;
20 |
21 | pllcfg_t cdctl_pll_cal(uint32_t input, uint32_t output);
22 | uint32_t cdctl_pll_get(uint32_t input, pllcfg_t cfg);
23 |
24 | uint32_t cdctl_sys_cal(uint32_t baud);
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/fw_bridge/utils/cdctl_regs.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #ifndef __CDCTL_REGS_H__
11 | #define __CDCTL_REGS_H__
12 |
13 | #define REG_VERSION 0x00
14 | #define REG_SETTING 0x02
15 | #define REG_IDLE_WAIT_LEN 0x04
16 | #define REG_TX_PERMIT_LEN_L 0x05
17 | #define REG_TX_PERMIT_LEN_H 0x06
18 | #define REG_MAX_IDLE_LEN_L 0x07
19 | #define REG_MAX_IDLE_LEN_H 0x08
20 | #define REG_TX_PRE_LEN 0x09
21 | #define REG_FILTER 0x0b
22 | #define REG_DIV_LS_L 0x0c
23 | #define REG_DIV_LS_H 0x0d
24 | #define REG_DIV_HS_L 0x0e
25 | #define REG_DIV_HS_H 0x0f
26 | #define REG_INT_FLAG 0x10
27 | #define REG_INT_MASK 0x11
28 | #define REG_RX 0x14
29 | #define REG_TX 0x15
30 | #define REG_RX_CTRL 0x16
31 | #define REG_TX_CTRL 0x17
32 | #define REG_RX_ADDR 0x18
33 | #define REG_RX_PAGE_FLAG 0x19
34 | #define REG_FILTER_M0 0x1a // multicast filter
35 | #define REG_FILTER_M1 0x1b
36 |
37 | // CDCTL01A
38 | #define REG_CLK_CTRL 0x01
39 | #define REG_PLL_ML 0x30
40 | #define REG_PLL_OD_MH 0x31
41 | #define REG_PLL_N 0x32
42 | #define REG_PLL_CTRL 0x33
43 | #define REG_PIN_INT_CTRL 0x34
44 | #define REG_PIN_RE_CTRL 0x35
45 | #define REG_CLK_STATUS 0x36
46 |
47 | #define BIT_SETTING_TX_PUSH_PULL (1 << 0)
48 | #define BIT_SETTING_TX_INVERT (1 << 1)
49 | #define BIT_SETTING_USER_CRC (1 << 2)
50 | #define BIT_SETTING_NO_DROP (1 << 3)
51 | #define BIT_SETTING_ARBITRATE (1 << 4)
52 | #define BIT_SETTING_BREAK_SYNC (1 << 5)
53 | #define BIT_SETTING_FULL_DUPLEX (1 << 6)
54 |
55 | #define BIT_FLAG_BUS_IDLE (1 << 0)
56 | #define BIT_FLAG_RX_PENDING (1 << 1)
57 | #define BIT_FLAG_RX_BREAK (1 << 2)
58 | #define BIT_FLAG_RX_LOST (1 << 3)
59 | #define BIT_FLAG_RX_ERROR (1 << 4)
60 | #define BIT_FLAG_TX_BUF_CLEAN (1 << 5)
61 | #define BIT_FLAG_TX_CD (1 << 6)
62 | #define BIT_FLAG_TX_ERROR (1 << 7)
63 |
64 | #define BIT_RX_RST_POINTER (1 << 0)
65 | #define BIT_RX_CLR_PENDING (1 << 1)
66 | #define BIT_RX_CLR_LOST (1 << 2)
67 | #define BIT_RX_CLR_ERROR (1 << 3)
68 | #define BIT_RX_RST (1 << 4)
69 | #define BIT_RX_CLR_BREAK (1 << 5)
70 | #define BIT_RX_RST_ALL 0x3f
71 |
72 | #define BIT_TX_RST_POINTER (1 << 0)
73 | #define BIT_TX_START (1 << 1)
74 | #define BIT_TX_CLR_CD (1 << 2)
75 | #define BIT_TX_CLR_ERROR (1 << 3)
76 | #define BIT_TX_ABORT (1 << 4)
77 | #define BIT_TX_SEND_BREAK (1 << 5)
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/fw_bridge/utils/crc_hw.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2024, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: Duke Fong
8 | */
9 |
10 | #include "modbus_crc.h"
11 |
12 | #define INIT idt
13 | #define CR ctrl
14 | #define DR dt
15 |
16 |
17 | uint16_t crc16_hw_sub(const uint8_t *data, uint32_t length, uint16_t crc_val)
18 | {
19 | uint16_t ret_val;
20 | #ifdef CRC_HW_IRQ_SAFE // not recommended, avoid large critical sections
21 | uint32_t flags;
22 | local_irq_save(flags);
23 | #endif
24 | CRC->INIT = crc_val;
25 | CRC->CR = 0xe9;
26 | CRC->INIT = CRC->DR; // bit-reverse crc_val
27 |
28 | while (((unsigned)data & 3) && length) {
29 | *(volatile uint8_t *)&CRC->DR = *data++;
30 | length--;
31 | }
32 |
33 | unsigned cnt = length >> 2;
34 | while (cnt--) {
35 | CRC->DR = *(uint32_t *)data;
36 | data += 4;
37 | }
38 |
39 | length &= 3;
40 | while (length--)
41 | *(volatile uint8_t *)&CRC->DR = *data++;
42 |
43 | ret_val = CRC->DR;
44 | #ifdef CRC_HW_IRQ_SAFE
45 | local_irq_restore(flags);
46 | #endif
47 | return ret_val;
48 | }
49 |
--------------------------------------------------------------------------------
/fw_bridge/utils/modbus_crc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Software License Agreement (MIT License)
3 | *
4 | * Copyright (c) 2017, DUKELEC, Inc.
5 | * All rights reserved.
6 | *
7 | * Author: http://www.modbustools.com/modbus_crc16.htm
8 | * Modified by: Duke Fong
9 | */
10 |
11 | #ifndef __MODBUS_CRC_H__
12 | #define __MODBUS_CRC_H__
13 |
14 | #include "cd_utils.h"
15 |
16 | uint16_t crc16_sub(const uint8_t *data, uint32_t length, uint16_t crc_val);
17 |
18 | static inline uint16_t crc16(const uint8_t *data, uint32_t length)
19 | {
20 | return crc16_sub(data, length, 0xffff);
21 | }
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/hw/cdbus_bridge_pcb_v6.1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dukelec/cdbus_bridge/826ad126b42fcb69d50684b164e60fb0b46d0a3f/hw/cdbus_bridge_pcb_v6.1.png
--------------------------------------------------------------------------------
/hw/cdbus_bridge_sch_v6.1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dukelec/cdbus_bridge/826ad126b42fcb69d50684b164e60fb0b46d0a3f/hw/cdbus_bridge_sch_v6.1.pdf
--------------------------------------------------------------------------------