summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/action.yml1
-rw-r--r--bsp/gd32/README.md2
-rw-r--r--bsp/gd32/arm/README.md1
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/.config714
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/Kconfig21
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/README.md116
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/SConscript15
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/SConstruct60
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/applications/SConscript15
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/applications/main.c36
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/board/Kconfig241
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/board/SConscript28
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/board/board.c85
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/board/board.h47
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/board/gd32f4xx_libopt.h45
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/board/linker_scripts/link.icf40
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/board/linker_scripts/link.ld142
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/board/linker_scripts/link.sct15
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/figures/board.pngbin0 -> 405988 bytes
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/project.ewd3056
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/project.ewp2321
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/project.eww10
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/project.uvoptx917
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/project.uvproj838
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/project.uvprojx732
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/rtconfig.h201
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/rtconfig.py150
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/template.ewp1892
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/template.uvoptx185
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/template.uvproj628
-rw-r--r--bsp/gd32/arm/gd32470z-lckfb/template.uvprojx412
-rw-r--r--bsp/gd32/arm/libraries/.ignore_format.yml9
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Include/gd32f4xx.h74
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/ARM/startup_gd32f405_425.s423
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/ARM/startup_gd32f407_427.s429
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/ARM/startup_gd32f450_470.s454
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/IAR/startup_gd32f405_425.s602
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/IAR/startup_gd32f407_427.s617
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/IAR/startup_gd32f450_470.s666
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/system_gd32f4xx.c437
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/core_cm4.h6
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/core_cmFunc.h144
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/core_cmInstr.h494
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_adc.h605
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_can.h339
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_crc.h41
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_ctc.h45
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dac.h47
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dbg.h54
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dci.h45
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dma.h160
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_enet.h315
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_exmc.h91
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_exti.h115
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_fmc.h116
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_fwdgt.h42
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_gpio.h77
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_i2c.h431
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_ipa.h75
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_iref.h43
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_misc.h58
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_pmu.h243
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_rcu.h148
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_rtc.h47
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_sdio.h39
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_spi.h117
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_syscfg.h37
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_timer.h126
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_tli.h103
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_trng.h75
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_usart.h215
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_wwdgt.h46
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_adc.c919
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_can.c511
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_crc.c6
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_ctc.c86
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dac.c159
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dbg.c35
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dci.c67
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dma.c473
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_enet.c859
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_exmc.c395
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_exti.c64
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_fmc.c456
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_fwdgt.c129
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_gpio.c55
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_i2c.c241
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_ipa.c178
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_iref.c7
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_misc.c61
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_pmu.c267
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_rcu.c647
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_rtc.c275
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_sdio.c107
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_spi.c313
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_syscfg.c25
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_timer.c497
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_tli.c164
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_trng.c49
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_usart.c254
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_wwdgt.c97
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Include/audio_core.h226
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Include/audio_out_itf.h67
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Source/audio_core.c756
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Source/audio_out_itf.c218
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/cdc/Include/cdc_acm_core.h42
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/cdc/Source/cdc_acm_core.c250
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Include/dfu_core.h49
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Include/dfu_mem.h85
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Source/dfu_core.c292
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Source/dfu_mem.c245
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Include/custom_hid_core.h34
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Include/standard_hid_core.h36
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Source/custom_hid_core.c197
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Source/standard_hid_core.c208
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/iap/Include/usb_iap_core.h40
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/iap/Source/usb_iap_core.c208
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_bbb.h38
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_core.h34
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_mem.h36
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_scsi.h44
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Source/usbd_msc_bbb.c66
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Source/usbd_msc_core.c214
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Source/usbd_msc_scsi.c148
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/printer/Include/printer_core.h34
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/printer/Source/printer_core.c154
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Include/usbd_core.h38
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Include/usbd_enum.h38
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Include/usbd_transc.h34
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Source/usbd_core.c36
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Source/usbd_enum.c130
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Source/usbd_transc.c42
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_core.h63
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_dev.h36
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_host.h36
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_hw.h51
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_regs.h56
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usbd_int.h34
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usbh_int.h42
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usb_core.c79
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usb_dev.c60
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usb_host.c49
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usbd_int.c71
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usbh_int.c114
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Include/usbh_hid_core.h132
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Include/usbh_standard_hid.h101
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Source/usbh_hid_core.c169
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Source/usbh_standard_hid.c276
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Include/usbh_msc_bbb.h122
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Include/usbh_msc_core.h42
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Include/usbh_msc_scsi.h36
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_bbb.c228
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_core.c287
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_fatfs.c52
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_scsi.c272
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_core.h79
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_enum.h37
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_pipe.h46
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_transc.h35
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_core.c233
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_enum.c58
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_pipe.c59
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_transc.c67
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/cdc/usb_cdc.h34
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/hid/usb_hid.h36
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/msc/msc_bbb.h38
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/msc/msc_scsi.h34
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/msc/usb_msc.h34
-rw-r--r--bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/common/usb_ch9_std.h36
-rw-r--r--components/net/netdev/src/netdev.c2
170 files changed, 26675 insertions, 9212 deletions
diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml
index 77aee2fdb7..8c4940b131 100644
--- a/.github/workflows/action.yml
+++ b/.github/workflows/action.yml
@@ -82,6 +82,7 @@ jobs:
- {RTT_BSP: "gd32/arm/gd32307e-start", RTT_TOOL_CHAIN: "sourcery-arm"}
- {RTT_BSP: "gd32/arm/gd32407v-start", RTT_TOOL_CHAIN: "sourcery-arm"}
- {RTT_BSP: "gd32/arm/gd32450z-eval", RTT_TOOL_CHAIN: "sourcery-arm"}
+ - {RTT_BSP: "gd32/arm/gd32470z-lckfb", RTT_TOOL_CHAIN: "sourcery-arm"}
- {RTT_BSP: "gd32e230k-start", RTT_TOOL_CHAIN: "sourcery-arm"}
- {RTT_BSP: "gd32vf103v-eval", RTT_TOOL_CHAIN: "sourcery-riscv-none-embed"}
- {RTT_BSP: "gd32303e-eval", RTT_TOOL_CHAIN: "sourcery-arm"}
diff --git a/bsp/gd32/README.md b/bsp/gd32/README.md
index 2f9263244b..b7f94cc13b 100644
--- a/bsp/gd32/README.md
+++ b/bsp/gd32/README.md
@@ -21,7 +21,7 @@ GD32 系列 BSP 目前支持情况如下表所示:
| **F4 系列** | |
| [gd32407v-start](arm/gd32407v-start) | 兆易创新 官方 GD32407V-START 开发板 |
| [gd32450z-eval](arm/gd32450z-eval) | 兆易创新 官方 GD32450Z-EVAL 开发板 |
-| | |
+| [gd32470z-lckfb](arm/gd32470z-lckfb) | 立创梁山派 GD32F470ZGT6 开发板 |
| **RISC-V 系列** | |
| **VF1 系列** | |
| [gd32vf103v-eval](risc-v/gd32vf103v-eval) | 兆易创新 官方 GGD32VF103V-EVAL 开发板 |
diff --git a/bsp/gd32/arm/README.md b/bsp/gd32/arm/README.md
index abb9515a5e..383b7ae3e6 100644
--- a/bsp/gd32/arm/README.md
+++ b/bsp/gd32/arm/README.md
@@ -20,6 +20,7 @@ GD32 ARM 系列 BSP 目前支持情况如下表所示:
| **F4 系列** | |
| [gd32407v-start](gd32407v-start) | 兆易创新 官方 GD32407V-START 开发板 |
| [gd32450z-eval](gd32450z-eval) | 兆易创新 官方 GD32450Z-EVAL 开发板 |
+| [gd32470z-lckfb](gd32470z-lckfb) | 立创梁山派 GD32F470ZGT6 开发板 |
可以通过阅读相应 BSP 下的 README 来快速上手,如果想要使用 BSP 更多功能可参考 docs 文件夹下提供的说明文档,如下表所示:
diff --git a/bsp/gd32/arm/gd32470z-lckfb/.config b/bsp/gd32/arm/gd32470z-lckfb/.config
new file mode 100644
index 0000000000..8486dc4b9e
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/.config
@@ -0,0 +1,714 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# RT-Thread Configuration
+#
+
+#
+# RT-Thread Kernel
+#
+CONFIG_RT_NAME_MAX=8
+# CONFIG_RT_USING_ARCH_DATA_TYPE is not set
+# CONFIG_RT_USING_SMP is not set
+CONFIG_RT_ALIGN_SIZE=8
+# CONFIG_RT_THREAD_PRIORITY_8 is not set
+CONFIG_RT_THREAD_PRIORITY_32=y
+# CONFIG_RT_THREAD_PRIORITY_256 is not set
+CONFIG_RT_THREAD_PRIORITY_MAX=32
+CONFIG_RT_TICK_PER_SECOND=1000
+CONFIG_RT_USING_OVERFLOW_CHECK=y
+CONFIG_RT_USING_HOOK=y
+CONFIG_RT_HOOK_USING_FUNC_PTR=y
+CONFIG_RT_USING_IDLE_HOOK=y
+CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
+CONFIG_IDLE_THREAD_STACK_SIZE=256
+CONFIG_RT_USING_TIMER_SOFT=y
+CONFIG_RT_TIMER_THREAD_PRIO=4
+CONFIG_RT_TIMER_THREAD_STACK_SIZE=512
+
+#
+# kservice optimization
+#
+CONFIG_RT_KSERVICE_USING_STDLIB=y
+# CONFIG_RT_KSERVICE_USING_STDLIB_MEMORY is not set
+# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set
+# CONFIG_RT_USING_TINY_FFS is not set
+# CONFIG_RT_KPRINTF_USING_LONGLONG is not set
+CONFIG_RT_DEBUG=y
+# CONFIG_RT_DEBUG_COLOR is not set
+# CONFIG_RT_DEBUG_INIT_CONFIG is not set
+# CONFIG_RT_DEBUG_THREAD_CONFIG is not set
+# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set
+# CONFIG_RT_DEBUG_IPC_CONFIG is not set
+# CONFIG_RT_DEBUG_TIMER_CONFIG is not set
+# CONFIG_RT_DEBUG_IRQ_CONFIG is not set
+# CONFIG_RT_DEBUG_MEM_CONFIG is not set
+# CONFIG_RT_DEBUG_SLAB_CONFIG is not set
+# CONFIG_RT_DEBUG_MEMHEAP_CONFIG is not set
+# CONFIG_RT_DEBUG_MODULE_CONFIG is not set
+
+#
+# Inter-Thread communication
+#
+CONFIG_RT_USING_SEMAPHORE=y
+CONFIG_RT_USING_MUTEX=y
+CONFIG_RT_USING_EVENT=y
+CONFIG_RT_USING_MAILBOX=y
+CONFIG_RT_USING_MESSAGEQUEUE=y
+# CONFIG_RT_USING_SIGNALS is not set
+
+#
+# Memory Management
+#
+CONFIG_RT_PAGE_MAX_ORDER=11
+CONFIG_RT_USING_MEMPOOL=y
+CONFIG_RT_USING_SMALL_MEM=y
+# CONFIG_RT_USING_SLAB is not set
+# CONFIG_RT_USING_MEMHEAP is not set
+CONFIG_RT_USING_SMALL_MEM_AS_HEAP=y
+# CONFIG_RT_USING_MEMHEAP_AS_HEAP is not set
+# CONFIG_RT_USING_SLAB_AS_HEAP is not set
+# CONFIG_RT_USING_USERHEAP is not set
+# CONFIG_RT_USING_NOHEAP is not set
+# CONFIG_RT_USING_MEMTRACE is not set
+# CONFIG_RT_USING_HEAP_ISR is not set
+CONFIG_RT_USING_HEAP=y
+
+#
+# Kernel Device Object
+#
+CONFIG_RT_USING_DEVICE=y
+# CONFIG_RT_USING_DEVICE_OPS is not set
+# CONFIG_RT_USING_DM is not set
+# CONFIG_RT_USING_INTERRUPT_INFO is not set
+CONFIG_RT_USING_CONSOLE=y
+CONFIG_RT_CONSOLEBUF_SIZE=128
+CONFIG_RT_CONSOLE_DEVICE_NAME="uart0"
+CONFIG_RT_VER_NUM=0x50000
+# CONFIG_RT_USING_CACHE is not set
+# CONFIG_ARCH_ARM_BOOTWITH_FLUSH_CACHE is not set
+# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
+# CONFIG_RT_USING_CPU_FFS is not set
+
+#
+# RT-Thread Components
+#
+CONFIG_RT_USING_COMPONENTS_INIT=y
+CONFIG_RT_USING_USER_MAIN=y
+CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048
+CONFIG_RT_MAIN_THREAD_PRIORITY=10
+# CONFIG_RT_USING_LEGACY is not set
+CONFIG_RT_USING_MSH=y
+CONFIG_RT_USING_FINSH=y
+CONFIG_FINSH_USING_MSH=y
+CONFIG_FINSH_THREAD_NAME="tshell"
+CONFIG_FINSH_THREAD_PRIORITY=20
+CONFIG_FINSH_THREAD_STACK_SIZE=4096
+CONFIG_FINSH_USING_HISTORY=y
+CONFIG_FINSH_HISTORY_LINES=5
+CONFIG_FINSH_USING_SYMTAB=y
+CONFIG_FINSH_CMD_SIZE=80
+CONFIG_MSH_USING_BUILT_IN_COMMANDS=y
+CONFIG_FINSH_USING_DESCRIPTION=y
+# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
+# CONFIG_FINSH_USING_AUTH is not set
+CONFIG_FINSH_ARG_MAX=10
+CONFIG_RT_USING_DFS=y
+CONFIG_DFS_USING_POSIX=y
+CONFIG_DFS_USING_WORKDIR=y
+CONFIG_DFS_FILESYSTEMS_MAX=4
+CONFIG_DFS_FILESYSTEM_TYPES_MAX=4
+CONFIG_DFS_FD_MAX=16
+# CONFIG_RT_USING_DFS_MNTTABLE is not set
+# CONFIG_RT_USING_DFS_ELMFAT is not set
+# CONFIG_RT_USING_DFS_DEVFS is not set
+# CONFIG_RT_USING_DFS_ROMFS is not set
+# CONFIG_RT_USING_DFS_CROMFS is not set
+# CONFIG_RT_USING_DFS_RAMFS is not set
+# CONFIG_RT_USING_DFS_TMPFS is not set
+# CONFIG_RT_USING_FAL is not set
+
+#
+# Device Drivers
+#
+CONFIG_RT_USING_DEVICE_IPC=y
+CONFIG_RT_UNAMED_PIPE_NUMBER=64
+# CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set
+CONFIG_RT_USING_SERIAL=y
+CONFIG_RT_USING_SERIAL_V1=y
+# CONFIG_RT_USING_SERIAL_V2 is not set
+CONFIG_RT_SERIAL_USING_DMA=y
+CONFIG_RT_SERIAL_RB_BUFSZ=64
+# CONFIG_RT_USING_CAN is not set
+# CONFIG_RT_USING_HWTIMER is not set
+# CONFIG_RT_USING_CPUTIME is not set
+# CONFIG_RT_USING_I2C is not set
+# CONFIG_RT_USING_PHY is not set
+CONFIG_RT_USING_PIN=y
+# CONFIG_RT_USING_ADC is not set
+# CONFIG_RT_USING_DAC is not set
+# CONFIG_RT_USING_NULL is not set
+# CONFIG_RT_USING_ZERO is not set
+# CONFIG_RT_USING_RANDOM is not set
+# CONFIG_RT_USING_PWM is not set
+# CONFIG_RT_USING_MTD_NOR is not set
+# CONFIG_RT_USING_MTD_NAND is not set
+# CONFIG_RT_USING_PM is not set
+# CONFIG_RT_USING_FDT is not set
+# CONFIG_RT_USING_RTC is not set
+# CONFIG_RT_USING_SDIO is not set
+# CONFIG_RT_USING_SPI is not set
+# CONFIG_RT_USING_WDT is not set
+# CONFIG_RT_USING_AUDIO is not set
+# CONFIG_RT_USING_SENSOR is not set
+# CONFIG_RT_USING_TOUCH is not set
+# CONFIG_RT_USING_LCD is not set
+# CONFIG_RT_USING_HWCRYPTO is not set
+# CONFIG_RT_USING_PULSE_ENCODER is not set
+# CONFIG_RT_USING_INPUT_CAPTURE is not set
+# CONFIG_RT_USING_DEV_BUS is not set
+# CONFIG_RT_USING_WIFI is not set
+# CONFIG_RT_USING_VIRTIO is not set
+
+#
+# Using USB
+#
+# CONFIG_RT_USING_USB is not set
+# CONFIG_RT_USING_USB_HOST is not set
+# CONFIG_RT_USING_USB_DEVICE is not set
+
+#
+# C/C++ and POSIX layer
+#
+CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
+
+#
+# POSIX (Portable Operating System Interface) layer
+#
+# CONFIG_RT_USING_POSIX_FS is not set
+# CONFIG_RT_USING_POSIX_DELAY is not set
+# CONFIG_RT_USING_POSIX_CLOCK is not set
+# CONFIG_RT_USING_POSIX_TIMER is not set
+# CONFIG_RT_USING_PTHREADS is not set
+# CONFIG_RT_USING_MODULE is not set
+
+#
+# Interprocess Communication (IPC)
+#
+# CONFIG_RT_USING_POSIX_PIPE is not set
+# CONFIG_RT_USING_POSIX_MESSAGE_QUEUE is not set
+# CONFIG_RT_USING_POSIX_MESSAGE_SEMAPHORE is not set
+
+#
+# Socket is in the 'Network' category
+#
+# CONFIG_RT_USING_CPLUSPLUS is not set
+
+#
+# Network
+#
+# CONFIG_RT_USING_SAL is not set
+# CONFIG_RT_USING_NETDEV is not set
+# CONFIG_RT_USING_LWIP is not set
+# CONFIG_RT_USING_AT is not set
+
+#
+# Utilities
+#
+# CONFIG_RT_USING_RYM is not set
+# CONFIG_RT_USING_ULOG is not set
+# CONFIG_RT_USING_UTEST is not set
+# CONFIG_RT_USING_VAR_EXPORT is not set
+# CONFIG_RT_USING_ADT is not set
+# CONFIG_RT_USING_RT_LINK is not set
+# CONFIG_RT_USING_VBUS is not set
+
+#
+# RT-Thread Utestcases
+#
+# CONFIG_RT_USING_UTESTCASES is not set
+
+#
+# RT-Thread online packages
+#
+
+#
+# IoT - internet of things
+#
+# CONFIG_PKG_USING_LWIP is not set
+# CONFIG_PKG_USING_LORAWAN_DRIVER is not set
+# CONFIG_PKG_USING_PAHOMQTT is not set
+# CONFIG_PKG_USING_UMQTT is not set
+# CONFIG_PKG_USING_WEBCLIENT is not set
+# CONFIG_PKG_USING_WEBNET is not set
+# CONFIG_PKG_USING_MONGOOSE is not set
+# CONFIG_PKG_USING_MYMQTT is not set
+# CONFIG_PKG_USING_KAWAII_MQTT is not set
+# CONFIG_PKG_USING_BC28_MQTT is not set
+# CONFIG_PKG_USING_WEBTERMINAL is not set
+# CONFIG_PKG_USING_LIBMODBUS is not set
+# CONFIG_PKG_USING_FREEMODBUS is not set
+# CONFIG_PKG_USING_NANOPB is not set
+
+#
+# Wi-Fi
+#
+
+#
+# Marvell WiFi
+#
+# CONFIG_PKG_USING_WLANMARVELL is not set
+
+#
+# Wiced WiFi
+#
+# CONFIG_PKG_USING_WLAN_WICED is not set
+# CONFIG_PKG_USING_RW007 is not set
+# CONFIG_PKG_USING_COAP is not set
+# CONFIG_PKG_USING_NOPOLL is not set
+# CONFIG_PKG_USING_NETUTILS is not set
+# CONFIG_PKG_USING_CMUX is not set
+# CONFIG_PKG_USING_PPP_DEVICE is not set
+# CONFIG_PKG_USING_AT_DEVICE is not set
+# CONFIG_PKG_USING_ATSRV_SOCKET is not set
+# CONFIG_PKG_USING_WIZNET is not set
+# CONFIG_PKG_USING_ZB_COORDINATOR is not set
+
+#
+# IoT Cloud
+#
+# CONFIG_PKG_USING_ONENET is not set
+# CONFIG_PKG_USING_GAGENT_CLOUD is not set
+# CONFIG_PKG_USING_ALI_IOTKIT is not set
+# CONFIG_PKG_USING_AZURE is not set
+# CONFIG_PKG_USING_TENCENT_IOT_EXPLORER is not set
+# CONFIG_PKG_USING_JIOT-C-SDK is not set
+# CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set
+# CONFIG_PKG_USING_JOYLINK is not set
+# CONFIG_PKG_USING_EZ_IOT_OS is not set
+# CONFIG_PKG_USING_IOTSHARP_SDK is not set
+# CONFIG_PKG_USING_NIMBLE is not set
+# CONFIG_PKG_USING_LLSYNC_SDK_ADAPTER is not set
+# CONFIG_PKG_USING_OTA_DOWNLOADER is not set
+# CONFIG_PKG_USING_IPMSG is not set
+# CONFIG_PKG_USING_LSSDP is not set
+# CONFIG_PKG_USING_AIRKISS_OPEN is not set
+# CONFIG_PKG_USING_LIBRWS is not set
+# CONFIG_PKG_USING_TCPSERVER is not set
+# CONFIG_PKG_USING_PROTOBUF_C is not set
+# CONFIG_PKG_USING_DLT645 is not set
+# CONFIG_PKG_USING_QXWZ is not set
+# CONFIG_PKG_USING_SMTP_CLIENT is not set
+# CONFIG_PKG_USING_ABUP_FOTA is not set
+# CONFIG_PKG_USING_LIBCURL2RTT is not set
+# CONFIG_PKG_USING_CAPNP is not set
+# CONFIG_PKG_USING_AGILE_TELNET is not set
+# CONFIG_PKG_USING_NMEALIB is not set
+# CONFIG_PKG_USING_PDULIB is not set
+# CONFIG_PKG_USING_BTSTACK is not set
+# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set
+# CONFIG_PKG_USING_WAYZ_IOTKIT is not set
+# CONFIG_PKG_USING_MAVLINK is not set
+# CONFIG_PKG_USING_BSAL is not set
+# CONFIG_PKG_USING_AGILE_MODBUS is not set
+# CONFIG_PKG_USING_AGILE_FTP is not set
+# CONFIG_PKG_USING_EMBEDDEDPROTO is not set
+# CONFIG_PKG_USING_RT_LINK_HW is not set
+# CONFIG_PKG_USING_LORA_PKT_FWD is not set
+# CONFIG_PKG_USING_LORA_GW_DRIVER_LIB is not set
+# CONFIG_PKG_USING_LORA_PKT_SNIFFER is not set
+# CONFIG_PKG_USING_HM is not set
+# CONFIG_PKG_USING_SMALL_MODBUS is not set
+# CONFIG_PKG_USING_NET_SERVER is not set
+# CONFIG_PKG_USING_ZFTP is not set
+
+#
+# security packages
+#
+# CONFIG_PKG_USING_MBEDTLS is not set
+# CONFIG_PKG_USING_LIBSODIUM is not set
+# CONFIG_PKG_USING_LIBHYDROGEN is not set
+# CONFIG_PKG_USING_TINYCRYPT is not set
+# CONFIG_PKG_USING_TFM is not set
+# CONFIG_PKG_USING_YD_CRYPTO is not set
+
+#
+# language packages
+#
+
+#
+# JSON: JavaScript Object Notation, a lightweight data-interchange format
+#
+# CONFIG_PKG_USING_CJSON is not set
+# CONFIG_PKG_USING_LJSON is not set
+# CONFIG_PKG_USING_RT_CJSON_TOOLS is not set
+# CONFIG_PKG_USING_RAPIDJSON is not set
+# CONFIG_PKG_USING_JSMN is not set
+# CONFIG_PKG_USING_AGILE_JSMN is not set
+# CONFIG_PKG_USING_PARSON is not set
+
+#
+# XML: Extensible Markup Language
+#
+# CONFIG_PKG_USING_SIMPLE_XML is not set
+# CONFIG_PKG_USING_EZXML is not set
+# CONFIG_PKG_USING_LUATOS_SOC is not set
+# CONFIG_PKG_USING_LUA is not set
+# CONFIG_PKG_USING_JERRYSCRIPT is not set
+# CONFIG_PKG_USING_MICROPYTHON is not set
+# CONFIG_PKG_USING_PIKASCRIPT is not set
+# CONFIG_PKG_USING_RTT_RUST is not set
+
+#
+# multimedia packages
+#
+
+#
+# LVGL: powerful and easy-to-use embedded GUI library
+#
+# CONFIG_PKG_USING_LVGL is not set
+# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
+# CONFIG_PKG_USING_LV_MUSIC_DEMO is not set
+# CONFIG_PKG_USING_GUI_GUIDER_DEMO is not set
+
+#
+# u8g2: a monochrome graphic library
+#
+# CONFIG_PKG_USING_U8G2_OFFICIAL is not set
+# CONFIG_PKG_USING_U8G2 is not set
+# CONFIG_PKG_USING_OPENMV is not set
+# CONFIG_PKG_USING_MUPDF is not set
+# CONFIG_PKG_USING_STEMWIN is not set
+# CONFIG_PKG_USING_WAVPLAYER is not set
+# CONFIG_PKG_USING_TJPGD is not set
+# CONFIG_PKG_USING_PDFGEN is not set
+# CONFIG_PKG_USING_HELIX is not set
+# CONFIG_PKG_USING_AZUREGUIX is not set
+# CONFIG_PKG_USING_TOUCHGFX2RTT is not set
+# CONFIG_PKG_USING_NUEMWIN is not set
+# CONFIG_PKG_USING_MP3PLAYER is not set
+# CONFIG_PKG_USING_TINYJPEG is not set
+# CONFIG_PKG_USING_UGUI is not set
+
+#
+# PainterEngine: A cross-platform graphics application framework written in C language
+#
+# CONFIG_PKG_USING_PAINTERENGINE is not set
+# CONFIG_PKG_USING_PAINTERENGINE_AUX is not set
+# CONFIG_PKG_USING_MCURSES is not set
+# CONFIG_PKG_USING_TERMBOX is not set
+# CONFIG_PKG_USING_VT100 is not set
+# CONFIG_PKG_USING_QRCODE is not set
+# CONFIG_PKG_USING_GUIENGINE is not set
+
+#
+# tools packages
+#
+# CONFIG_PKG_USING_CMBACKTRACE is not set
+# CONFIG_PKG_USING_EASYFLASH is not set
+# CONFIG_PKG_USING_EASYLOGGER is not set
+# CONFIG_PKG_USING_SYSTEMVIEW is not set
+# CONFIG_PKG_USING_SEGGER_RTT is not set
+# CONFIG_PKG_USING_RDB is not set
+# CONFIG_PKG_USING_ULOG_EASYFLASH is not set
+# CONFIG_PKG_USING_ULOG_FILE is not set
+# CONFIG_PKG_USING_LOGMGR is not set
+# CONFIG_PKG_USING_ADBD is not set
+# CONFIG_PKG_USING_COREMARK is not set
+# CONFIG_PKG_USING_DHRYSTONE is not set
+# CONFIG_PKG_USING_MEMORYPERF is not set
+# CONFIG_PKG_USING_NR_MICRO_SHELL is not set
+# CONFIG_PKG_USING_CHINESE_FONT_LIBRARY is not set
+# CONFIG_PKG_USING_LUNAR_CALENDAR is not set
+# CONFIG_PKG_USING_BS8116A is not set
+# CONFIG_PKG_USING_GPS_RMC is not set
+# CONFIG_PKG_USING_URLENCODE is not set
+# CONFIG_PKG_USING_UMCN is not set
+# CONFIG_PKG_USING_LWRB2RTT is not set
+# CONFIG_PKG_USING_CPU_USAGE is not set
+# CONFIG_PKG_USING_GBK2UTF8 is not set
+# CONFIG_PKG_USING_VCONSOLE is not set
+# CONFIG_PKG_USING_KDB is not set
+# CONFIG_PKG_USING_WAMR is not set
+# CONFIG_PKG_USING_MICRO_XRCE_DDS_CLIENT is not set
+# CONFIG_PKG_USING_LWLOG is not set
+# CONFIG_PKG_USING_ANV_TRACE is not set
+# CONFIG_PKG_USING_ANV_MEMLEAK is not set
+# CONFIG_PKG_USING_ANV_TESTSUIT is not set
+# CONFIG_PKG_USING_ANV_BENCH is not set
+# CONFIG_PKG_USING_DEVMEM is not set
+# CONFIG_PKG_USING_REGEX is not set
+# CONFIG_PKG_USING_MEM_SANDBOX is not set
+# CONFIG_PKG_USING_SOLAR_TERMS is not set
+# CONFIG_PKG_USING_GAN_ZHI is not set
+# CONFIG_PKG_USING_FDT is not set
+# CONFIG_PKG_USING_CBOX is not set
+# CONFIG_PKG_USING_SNOWFLAKE is not set
+# CONFIG_PKG_USING_HASH_MATCH is not set
+# CONFIG_PKG_USING_FIRE_PID_CURVE is not set
+# CONFIG_PKG_USING_ARMV7M_DWT_TOOL is not set
+
+#
+# system packages
+#
+
+#
+# enhanced kernel services
+#
+# CONFIG_PKG_USING_RT_MEMCPY_CM is not set
+# CONFIG_PKG_USING_RT_KPRINTF_THREADSAFE is not set
+# CONFIG_PKG_USING_RT_VSNPRINTF_FULL is not set
+
+#
+# acceleration: Assembly language or algorithmic acceleration packages
+#
+# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set
+# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set
+# CONFIG_PKG_USING_QFPLIB_M3 is not set
+
+#
+# CMSIS: ARM Cortex-M Microcontroller Software Interface Standard
+#
+# CONFIG_PKG_USING_CMSIS_5 is not set
+# CONFIG_PKG_USING_CMSIS_RTOS1 is not set
+# CONFIG_PKG_USING_CMSIS_RTOS2 is not set
+
+#
+# Micrium: Micrium software products porting for RT-Thread
+#
+# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set
+# CONFIG_PKG_USING_UCOSII_WRAPPER is not set
+# CONFIG_PKG_USING_UC_CRC is not set
+# CONFIG_PKG_USING_UC_CLK is not set
+# CONFIG_PKG_USING_UC_COMMON is not set
+# CONFIG_PKG_USING_UC_MODBUS is not set
+# CONFIG_PKG_USING_RTDUINO is not set
+# CONFIG_PKG_USING_CAIRO is not set
+# CONFIG_PKG_USING_PIXMAN is not set
+# CONFIG_PKG_USING_PARTITION is not set
+# CONFIG_PKG_USING_PERF_COUNTER is not set
+# CONFIG_PKG_USING_FLASHDB is not set
+# CONFIG_PKG_USING_SQLITE is not set
+# CONFIG_PKG_USING_RTI is not set
+# CONFIG_PKG_USING_DFS_YAFFS is not set
+# CONFIG_PKG_USING_LITTLEFS is not set
+# CONFIG_PKG_USING_DFS_JFFS2 is not set
+# CONFIG_PKG_USING_DFS_UFFS is not set
+# CONFIG_PKG_USING_LWEXT4 is not set
+# CONFIG_PKG_USING_THREAD_POOL is not set
+# CONFIG_PKG_USING_ROBOTS is not set
+# CONFIG_PKG_USING_EV is not set
+# CONFIG_PKG_USING_SYSWATCH is not set
+# CONFIG_PKG_USING_SYS_LOAD_MONITOR is not set
+# CONFIG_PKG_USING_PLCCORE is not set
+# CONFIG_PKG_USING_RAMDISK is not set
+# CONFIG_PKG_USING_MININI is not set
+# CONFIG_PKG_USING_QBOOT is not set
+# CONFIG_PKG_USING_PPOOL is not set
+# CONFIG_PKG_USING_OPENAMP is not set
+# CONFIG_PKG_USING_LPM is not set
+# CONFIG_PKG_USING_TLSF is not set
+# CONFIG_PKG_USING_EVENT_RECORDER is not set
+# CONFIG_PKG_USING_ARM_2D is not set
+# CONFIG_PKG_USING_MCUBOOT is not set
+# CONFIG_PKG_USING_TINYUSB is not set
+# CONFIG_PKG_USING_CHERRYUSB is not set
+# CONFIG_PKG_USING_KMULTI_RTIMER is not set
+# CONFIG_PKG_USING_TFDB is not set
+# CONFIG_PKG_USING_QPC is not set
+
+#
+# peripheral libraries and drivers
+#
+# CONFIG_PKG_USING_SENSORS_DRIVERS is not set
+# CONFIG_PKG_USING_REALTEK_AMEBA is not set
+# CONFIG_PKG_USING_SHT2X is not set
+# CONFIG_PKG_USING_SHT3X is not set
+# CONFIG_PKG_USING_ADT74XX is not set
+# CONFIG_PKG_USING_AS7341 is not set
+# CONFIG_PKG_USING_STM32_SDIO is not set
+# CONFIG_PKG_USING_RTT_ESP_IDF is not set
+# CONFIG_PKG_USING_ICM20608 is not set
+# CONFIG_PKG_USING_BUTTON is not set
+# CONFIG_PKG_USING_PCF8574 is not set
+# CONFIG_PKG_USING_SX12XX is not set
+# CONFIG_PKG_USING_SIGNAL_LED is not set
+# CONFIG_PKG_USING_LEDBLINK is not set
+# CONFIG_PKG_USING_LITTLED is not set
+# CONFIG_PKG_USING_LKDGUI is not set
+# CONFIG_PKG_USING_NRF5X_SDK is not set
+# CONFIG_PKG_USING_NRFX is not set
+# CONFIG_PKG_USING_WM_LIBRARIES is not set
+# CONFIG_PKG_USING_KENDRYTE_SDK is not set
+# CONFIG_PKG_USING_INFRARED is not set
+# CONFIG_PKG_USING_MULTI_INFRARED is not set
+# CONFIG_PKG_USING_AGILE_BUTTON is not set
+# CONFIG_PKG_USING_AGILE_LED is not set
+# CONFIG_PKG_USING_AT24CXX is not set
+# CONFIG_PKG_USING_MOTIONDRIVER2RTT is not set
+# CONFIG_PKG_USING_AD7746 is not set
+# CONFIG_PKG_USING_PCA9685 is not set
+# CONFIG_PKG_USING_I2C_TOOLS is not set
+# CONFIG_PKG_USING_NRF24L01 is not set
+# CONFIG_PKG_USING_TOUCH_DRIVERS is not set
+# CONFIG_PKG_USING_MAX17048 is not set
+# CONFIG_PKG_USING_RPLIDAR is not set
+# CONFIG_PKG_USING_AS608 is not set
+# CONFIG_PKG_USING_RC522 is not set
+# CONFIG_PKG_USING_WS2812B is not set
+# CONFIG_PKG_USING_EMBARC_BSP is not set
+# CONFIG_PKG_USING_EXTERN_RTC_DRIVERS is not set
+# CONFIG_PKG_USING_MULTI_RTIMER is not set
+# CONFIG_PKG_USING_MAX7219 is not set
+# CONFIG_PKG_USING_BEEP is not set
+# CONFIG_PKG_USING_EASYBLINK is not set
+# CONFIG_PKG_USING_PMS_SERIES is not set
+# CONFIG_PKG_USING_CAN_YMODEM is not set
+# CONFIG_PKG_USING_LORA_RADIO_DRIVER is not set
+# CONFIG_PKG_USING_QLED is not set
+# CONFIG_PKG_USING_PAJ7620 is not set
+# CONFIG_PKG_USING_AGILE_CONSOLE is not set
+# CONFIG_PKG_USING_LD3320 is not set
+# CONFIG_PKG_USING_WK2124 is not set
+# CONFIG_PKG_USING_LY68L6400 is not set
+# CONFIG_PKG_USING_DM9051 is not set
+# CONFIG_PKG_USING_SSD1306 is not set
+# CONFIG_PKG_USING_QKEY is not set
+# CONFIG_PKG_USING_RS485 is not set
+# CONFIG_PKG_USING_RS232 is not set
+# CONFIG_PKG_USING_NES is not set
+# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set
+# CONFIG_PKG_USING_VDEVICE is not set
+# CONFIG_PKG_USING_SGM706 is not set
+# CONFIG_PKG_USING_STM32WB55_SDK is not set
+# CONFIG_PKG_USING_RDA58XX is not set
+# CONFIG_PKG_USING_LIBNFC is not set
+# CONFIG_PKG_USING_MFOC is not set
+# CONFIG_PKG_USING_TMC51XX is not set
+# CONFIG_PKG_USING_TCA9534 is not set
+# CONFIG_PKG_USING_KOBUKI is not set
+# CONFIG_PKG_USING_ROSSERIAL is not set
+# CONFIG_PKG_USING_MICRO_ROS is not set
+# CONFIG_PKG_USING_MCP23008 is not set
+# CONFIG_PKG_USING_BLUETRUM_SDK is not set
+# CONFIG_PKG_USING_MISAKA_AT24CXX is not set
+# CONFIG_PKG_USING_MISAKA_RGB_BLING is not set
+# CONFIG_PKG_USING_LORA_MODEM_DRIVER is not set
+# CONFIG_PKG_USING_BL_MCU_SDK is not set
+# CONFIG_PKG_USING_SOFT_SERIAL is not set
+# CONFIG_PKG_USING_MB85RS16 is not set
+# CONFIG_PKG_USING_CW2015 is not set
+# CONFIG_PKG_USING_RFM300 is not set
+# CONFIG_PKG_USING_IO_INPUT_FILTER is not set
+
+#
+# AI packages
+#
+# CONFIG_PKG_USING_LIBANN is not set
+# CONFIG_PKG_USING_NNOM is not set
+# CONFIG_PKG_USING_ONNX_BACKEND is not set
+# CONFIG_PKG_USING_ONNX_PARSER is not set
+# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
+# CONFIG_PKG_USING_ELAPACK is not set
+# CONFIG_PKG_USING_ULAPACK is not set
+# CONFIG_PKG_USING_QUEST is not set
+# CONFIG_PKG_USING_NAXOS is not set
+
+#
+# miscellaneous packages
+#
+
+#
+# project laboratory
+#
+
+#
+# samples: kernel and components samples
+#
+# CONFIG_PKG_USING_KERNEL_SAMPLES is not set
+# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set
+# CONFIG_PKG_USING_NETWORK_SAMPLES is not set
+# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set
+
+#
+# entertainment: terminal games and other interesting software packages
+#
+# CONFIG_PKG_USING_CMATRIX is not set
+# CONFIG_PKG_USING_SL is not set
+# CONFIG_PKG_USING_CAL is not set
+# CONFIG_PKG_USING_ACLOCK is not set
+# CONFIG_PKG_USING_THREES is not set
+# CONFIG_PKG_USING_2048 is not set
+# CONFIG_PKG_USING_SNAKE is not set
+# CONFIG_PKG_USING_TETRIS is not set
+# CONFIG_PKG_USING_DONUT is not set
+# CONFIG_PKG_USING_COWSAY is not set
+# CONFIG_PKG_USING_LIBCSV is not set
+# CONFIG_PKG_USING_OPTPARSE is not set
+# CONFIG_PKG_USING_FASTLZ is not set
+# CONFIG_PKG_USING_MINILZO is not set
+# CONFIG_PKG_USING_QUICKLZ is not set
+# CONFIG_PKG_USING_LZMA is not set
+# CONFIG_PKG_USING_MULTIBUTTON is not set
+# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set
+# CONFIG_PKG_USING_CANFESTIVAL is not set
+# CONFIG_PKG_USING_ZLIB is not set
+# CONFIG_PKG_USING_MINIZIP is not set
+# CONFIG_PKG_USING_HEATSHRINK is not set
+# CONFIG_PKG_USING_DSTR is not set
+# CONFIG_PKG_USING_TINYFRAME is not set
+# CONFIG_PKG_USING_KENDRYTE_DEMO is not set
+# CONFIG_PKG_USING_DIGITALCTRL is not set
+# CONFIG_PKG_USING_UPACKER is not set
+# CONFIG_PKG_USING_UPARAM is not set
+# CONFIG_PKG_USING_HELLO is not set
+# CONFIG_PKG_USING_VI is not set
+# CONFIG_PKG_USING_KI is not set
+# CONFIG_PKG_USING_ARMv7M_DWT is not set
+# CONFIG_PKG_USING_UKAL is not set
+# CONFIG_PKG_USING_CRCLIB is not set
+# CONFIG_PKG_USING_LWGPS is not set
+# CONFIG_PKG_USING_STATE_MACHINE is not set
+# CONFIG_PKG_USING_DESIGN_PATTERN is not set
+# CONFIG_PKG_USING_CONTROLLER is not set
+# CONFIG_PKG_USING_PHASE_LOCKED_LOOP is not set
+# CONFIG_PKG_USING_MFBD is not set
+# CONFIG_PKG_USING_SLCAN2RTT is not set
+# CONFIG_PKG_USING_SOEM is not set
+
+#
+# Hardware Drivers Config
+#
+CONFIG_SOC_SERIES_GD32F4xx=y
+CONFIG_SOC_GD32470Z=y
+
+#
+# Onboard Peripheral Drivers
+#
+
+#
+# On-chip Peripheral Drivers
+#
+CONFIG_BSP_USING_GPIO=y
+CONFIG_BSP_USING_UART=y
+CONFIG_BSP_USING_UART0=y
+# CONFIG_BSP_UART0_RX_USING_DMA is not set
+# CONFIG_BSP_USING_UART1 is not set
+# CONFIG_BSP_USING_UART2 is not set
+# CONFIG_BSP_USING_UART3 is not set
+# CONFIG_BSP_USING_UART4 is not set
+# CONFIG_BSP_USING_UART5 is not set
+# CONFIG_BSP_USING_UART6 is not set
+# CONFIG_BSP_USING_UART7 is not set
+# CONFIG_BSP_USING_SPI is not set
+# CONFIG_BSP_USING_I2C1 is not set
+# CONFIG_BSP_USING_ADC is not set
+# CONFIG_BSP_USING_TIM is not set
+# CONFIG_BSP_USING_ONCHIP_RTC is not set
+# CONFIG_BSP_USING_WDT is not set
+# CONFIG_BSP_USING_SDIO is not set
+# CONFIG_BSP_USING_USBD is not set
+# CONFIG_BSP_USING_USBH is not set
+
+#
+# Board extended module Drivers
+#
diff --git a/bsp/gd32/arm/gd32470z-lckfb/Kconfig b/bsp/gd32/arm/gd32470z-lckfb/Kconfig
new file mode 100644
index 0000000000..609eb0745e
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/Kconfig
@@ -0,0 +1,21 @@
+mainmenu "RT-Thread Configuration"
+
+config BSP_DIR
+ string
+ option env="BSP_ROOT"
+ default "."
+
+config RTT_DIR
+ string
+ option env="RTT_ROOT"
+ default "../../../.."
+
+config PKGS_DIR
+ string
+ option env="PKGS_ROOT"
+ default "packages"
+
+source "$RTT_DIR/Kconfig"
+source "$PKGS_DIR/Kconfig"
+source "../libraries/Kconfig"
+source "board/Kconfig"
diff --git a/bsp/gd32/arm/gd32470z-lckfb/README.md b/bsp/gd32/arm/gd32470z-lckfb/README.md
new file mode 100644
index 0000000000..93c1e6f463
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/README.md
@@ -0,0 +1,116 @@
+# GD32470-LCKFB梁山派开发板BSP说明
+
+## 简介
+
+GD32470Z-LCKFB梁山派是立创开发板推出的一款GD32F470系列的开发板,最高主频高达240M,该开发板具有丰富的板载资源,是基于GD32F470ZGT6的全国产化开源开发板,图片如下:
+
+![board](figures/board.png)
+
+> 2022年12月05号后立创·梁山派开发板主控从GD32F450ZGT6升级到了GD32F470ZGT6 两款芯片兼容主要差别GD32F450ZGT6主频200、SDRAM 256K,GD32F470ZGT6主频240、SDRAM 512K。
+
+该开发板常用 **板载资源** 如下:
+
+- GD32F470ZGT6,主频 240MHz,CPU内核:ARM Cortex-M4,1024KB FLASH ,512KB RAM
+- 常用外设
+
+ - 用户LED :4个,LED1 (PE3),LED2(PD7),LED3(PG3),LED4(PA5)
+ - 电源指示灯:一个红色LED
+ - 按键:3个,KEY_UP(PA0),RESET(NRST),BOOT0(PB2)
+ - General TM * 10、Advanced TM * 2、Basic TM * 2
+ - SysTick * 1
+ - 看门狗 * 2
+ - RTC * 1
+ - USART * 4、UART * 4
+ - I2C * 3、I2S * 2
+ - SPI * 6
+ - SDIO * 1
+ - CAN * 2
+ - USBFS+HS
+ - 以太网 * 1
+ - TFT-LCD
+ - EXMC/SDRAM * 1
+ - ADC * 3
+ - DAC * 2
+ - 最多支持114GPIOs
+- 调试接口:CMSIS-DAP
+- 支持RGB接口和MCU屏幕接口
+- 一路SDIO-TF卡
+- SPI Flash:W25Q64
+- SDRAM:W9825G6KH-6I
+- 一路Type-C USB
+- 调试接口引出了SWD和UART
+- 双2*20PIN 2.54排针引出了68个可编程IO
+- 开发板更多信息请查看[立创开发板官网](https://lckfb.com/)
+
+## 外设支持
+
+本 BSP 目前对外设的支持情况如下:
+
+| **片上外设** | **支持情况** | **备注** |
+|:-------- |:--------:|:-------------------------------- |
+| GPIO | 支持 | PA0, PA1... ---> PIN: 0, 1...113 |
+| UART | 支持 | UART0 - UART7 |
+| **扩展模块** | **支持情况** | **备注** |
+| 暂无 | 暂不支持 | 暂不支持 |
+
+## 使用说明
+
+使用说明分为如下两个章节:
+
+- 快速上手
+
+ 本章节是为刚接触 RT-Thread 的新手准备的使用说明,遵循简单的步骤即可将 RT-Thread 操作系统运行在该开发板上,看到实验效果 。
+
+- 进阶使用
+
+ 本章节是为需要在 RT-Thread 操作系统上使用更多开发板资源的开发者准备的。通过使用 ENV 工具对 BSP 进行配置,可以开启更多板载资源,实现更多高级功能。
+
+### 快速上手
+
+本 BSP 为开发者提供 MDK5工程,支持 GCC 开发环境,也可使用RT-Thread Studio开发。下面以 MDK5 开发环境为例,介绍如何将系统运行起来。
+
+#### 硬件连接
+
+使用调试器连接开发板到 PC,使用USB2TTL连接USART0,并给开发板供电。
+
+#### 编译下载
+
+双击 project.uvprojx 文件,打开 MDK5 工程,编译并下载程序到开发板。
+
+> 工程默认配置使用 CMSIS-DAP 仿真器下载程序,在通过 CMSIS-DAP 连接开发板的基础上,点击下载按钮即可下载程序到开发板
+
+#### 运行结果
+
+下载程序成功之后,系统会自动运行,LED 闪烁。
+
+连接开发板对应串口到 PC , 在终端工具里打开相应的串口(115200-8-1-N),复位设备后,可以看到 RT-Thread 的输出信息:
+
+```bash
+ \ | /
+- RT - Thread Operating System
+ / | \ 5.0.0 build Mar 3 2023 00:43:44
+ 2006 - 2022 Copyright by RT-Thread team
+msh />
+```
+
+### 进阶使用
+
+此 BSP 默认只开启了 GPIO 和 串口1的功能,如果需使用高级功能,需要利用 ENV 工具对BSP 进行配置,步骤如下:
+
+1. 在 bsp 下打开 env 工具。
+
+2. 输入`menuconfig`命令配置工程,配置好之后保存退出。
+
+3. 输入`pkgs --update`命令更新软件包。
+
+4. 输入`scons --target=mdk4/mdk5/iar` 命令重新生成工程。
+
+## 注意事项
+
+暂无
+
+## 联系人信息
+
+维护人:
+
+- [yuanzihao](https://github.com/zihao-yuan/), 邮箱:<[email protected]>
diff --git a/bsp/gd32/arm/gd32470z-lckfb/SConscript b/bsp/gd32/arm/gd32470z-lckfb/SConscript
new file mode 100644
index 0000000000..20f7689c53
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/SConscript
@@ -0,0 +1,15 @@
+# for module compiling
+import os
+Import('RTT_ROOT')
+from building import *
+
+cwd = GetCurrentDir()
+objs = []
+list = os.listdir(cwd)
+
+for d in list:
+ path = os.path.join(cwd, d)
+ if os.path.isfile(os.path.join(path, 'SConscript')):
+ objs = objs + SConscript(os.path.join(d, 'SConscript'))
+
+Return('objs')
diff --git a/bsp/gd32/arm/gd32470z-lckfb/SConstruct b/bsp/gd32/arm/gd32470z-lckfb/SConstruct
new file mode 100644
index 0000000000..0701e74ed5
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/SConstruct
@@ -0,0 +1,60 @@
+import os
+import sys
+import rtconfig
+
+if os.getenv('RTT_ROOT'):
+ RTT_ROOT = os.getenv('RTT_ROOT')
+else:
+ RTT_ROOT = os.path.normpath(os.getcwd() + '/../../../..')
+
+sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
+try:
+ from building import *
+except:
+ print('Cannot found RT-Thread root directory, please check RTT_ROOT')
+ print(RTT_ROOT)
+ exit(-1)
+
+TARGET = 'rtthread.' + rtconfig.TARGET_EXT
+
+DefaultEnvironment(tools=[])
+env = Environment(tools = ['mingw'],
+ AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
+ CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
+ AR = rtconfig.AR, ARFLAGS = '-rc',
+ CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
+ LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
+env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
+
+if rtconfig.PLATFORM in ['iccarm']:
+ env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
+ env.Replace(ARFLAGS = [''])
+ env.Replace(LINKCOM = env["LINKCOM"] + ' --map rtthread.map')
+
+Export('RTT_ROOT')
+Export('rtconfig')
+
+SDK_ROOT = os.path.abspath('./')
+
+if os.path.exists(SDK_ROOT + '/libraries'):
+ libraries_path_prefix = SDK_ROOT + '/libraries'
+else:
+ libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
+
+SDK_LIB = libraries_path_prefix
+Export('SDK_LIB')
+
+# prepare building environment
+objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
+
+gd32_library = 'GD32F4xx_Firmware_Library'
+rtconfig.BSP_LIBRARY_TYPE = gd32_library
+
+# include libraries
+objs.extend(SConscript(os.path.join(libraries_path_prefix, gd32_library, 'SConscript')))
+
+# include drivers
+objs.extend(SConscript(os.path.join(libraries_path_prefix, 'gd32_drivers', 'SConscript')))
+
+# make a building
+DoBuilding(TARGET, objs)
diff --git a/bsp/gd32/arm/gd32470z-lckfb/applications/SConscript b/bsp/gd32/arm/gd32470z-lckfb/applications/SConscript
new file mode 100644
index 0000000000..9bb9abae89
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/applications/SConscript
@@ -0,0 +1,15 @@
+from building import *
+import os
+
+cwd = GetCurrentDir()
+src = Glob('*.c')
+CPPPATH = [cwd]
+
+group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
+
+list = os.listdir(cwd)
+for item in list:
+ if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
+ group = group + SConscript(os.path.join(item, 'SConscript'))
+
+Return('group')
diff --git a/bsp/gd32/arm/gd32470z-lckfb/applications/main.c b/bsp/gd32/arm/gd32470z-lckfb/applications/main.c
new file mode 100644
index 0000000000..dc801496bf
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/applications/main.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2006-2023, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2021-08-20 BruceOu first implementation
+ * 2023-03-05 yuanzihao change the LED pins
+ */
+
+#include <stdio.h>
+#include <rtthread.h>
+#include <rtdevice.h>
+#include <board.h>
+
+/* defined the LED1 pin: PE3 */
+#define LED1_PIN GET_PIN(E, 3)
+
+int main(void)
+{
+ int count = 1;
+
+ /* set LED1 pin mode to output */
+ rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT);
+
+ while (count++)
+ {
+ rt_pin_write(LED1_PIN, PIN_HIGH);
+ rt_thread_mdelay(500);
+ rt_pin_write(LED1_PIN, PIN_LOW);
+ rt_thread_mdelay(500);
+ }
+
+ return RT_EOK;
+}
diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/Kconfig b/bsp/gd32/arm/gd32470z-lckfb/board/Kconfig
new file mode 100644
index 0000000000..2b0c0ce10f
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/board/Kconfig
@@ -0,0 +1,241 @@
+menu "Hardware Drivers Config"
+
+config SOC_SERIES_GD32F4xx
+ bool
+ default y
+
+config SOC_GD32470Z
+ bool
+ select SOC_SERIES_GD32F4xx
+ select RT_USING_COMPONENTS_INIT
+ select RT_USING_USER_MAIN
+ default y
+
+menu "Onboard Peripheral Drivers"
+
+endmenu
+
+menu "On-chip Peripheral Drivers"
+
+ config BSP_USING_GPIO
+ bool "Enable GPIO"
+ select RT_USING_PIN
+ default y
+
+ menuconfig BSP_USING_UART
+ bool "Enable UART"
+ default y
+ select RT_USING_SERIAL
+ if BSP_USING_UART
+ config BSP_USING_UART0
+ bool "Enable UART0"
+ default y
+
+ config BSP_UART0_RX_USING_DMA
+ bool "Enable UART0 RX DMA"
+ depends on BSP_USING_UART0
+ select RT_SERIAL_USING_DMA
+ default n
+
+ config BSP_USING_UART1
+ bool "Enable UART1"
+ default n
+
+ config BSP_UART1_RX_USING_DMA
+ bool "Enable UART1 RX DMA"
+ depends on BSP_USING_UART1
+ select RT_SERIAL_USING_DMA
+ default n
+
+ config BSP_USING_UART2
+ bool "Enable UART2"
+ default n
+
+ config BSP_UART2_RX_USING_DMA
+ bool "Enable UART2 RX DMA"
+ depends on BSP_USING_UART2
+ select RT_SERIAL_USING_DMA
+ default n
+
+ config BSP_USING_UART3
+ bool "Enable UART3"
+ default n
+
+ config BSP_UART3_RX_USING_DMA
+ bool "Enable UART3 RX DMA"
+ depends on BSP_USING_UART3
+ select RT_SERIAL_USING_DMA
+ default n
+
+ config BSP_USING_UART4
+ bool "Enable UART4"
+ default n
+
+ config BSP_UART4_RX_USING_DMA
+ bool "Enable UART4 RX DMA"
+ depends on BSP_USING_UART4
+ select RT_SERIAL_USING_DMA
+ default n
+
+ config BSP_USING_UART5
+ bool "Enable UART5"
+ default n
+
+ config BSP_UART5_RX_USING_DMA
+ bool "Enable UART5 RX DMA"
+ depends on BSP_USING_UART5
+ select RT_SERIAL_USING_DMA
+ default n
+
+ config BSP_USING_UART6
+ bool "Enable UART6"
+ default n
+
+ config BSP_UART6_RX_USING_DMA
+ bool "Enable UART6 RX DMA"
+ depends on BSP_USING_UART6
+ select RT_SERIAL_USING_DMA
+ default n
+
+ config BSP_USING_UART7
+ bool "Enable UART7"
+ default n
+
+ config BSP_UART7_RX_USING_DMA
+ bool "Enable UART7 RX DMA"
+ depends on BSP_USING_UART7
+ select RT_SERIAL_USING_DMA
+ default n
+ endif
+
+ menuconfig BSP_USING_SPI
+ bool "Enable SPI BUS"
+ default n
+ select RT_USING_SPI
+ if BSP_USING_SPI
+ config BSP_USING_SPI1
+ bool "Enable SPI1 BUS"
+ default n
+
+ config BSP_SPI1_TX_USING_DMA
+ bool "Enable SPI1 TX DMA"
+ depends on BSP_USING_SPI1
+ default n
+
+ config BSP_SPI1_RX_USING_DMA
+ bool "Enable SPI1 RX DMA"
+ depends on BSP_USING_SPI1
+ select BSP_SPI1_TX_USING_DMA
+ default n
+ endif
+
+ menuconfig BSP_USING_I2C1
+ bool "Enable I2C1 BUS (software simulation)"
+ default n
+ select RT_USING_I2C
+ select RT_USING_I2C_BITOPS
+ select RT_USING_PIN
+ if BSP_USING_I2C1
+ config BSP_I2C1_SCL_PIN
+ int "i2c1 scl pin number"
+ range 1 216
+ default 24
+ config BSP_I2C1_SDA_PIN
+ int "I2C1 sda pin number"
+ range 1 216
+ default 25
+ endif
+
+ menuconfig BSP_USING_ADC
+ bool "Enable ADC"
+ default n
+ select RT_USING_ADC
+ if BSP_USING_ADC
+ config BSP_USING_ADC0
+ bool "Enable ADC0"
+ default n
+
+ config BSP_USING_ADC1
+ bool "Enable ADC1"
+ default n
+
+ config BSP_USING_ADC2
+ bool "Enable ADC2"
+ default n
+ endif
+
+ menuconfig BSP_USING_TIM
+ bool "Enable timer"
+ default n
+ select RT_USING_HWTIMER
+ if BSP_USING_TIM
+ config BSP_USING_TIM10
+ bool "Enable TIM10"
+ default n
+
+ config BSP_USING_TIM11
+ bool "Enable TIM11"
+ default n
+
+ config BSP_USING_TIM12
+ bool "Enable TIM13"
+ default n
+ endif
+
+ menuconfig BSP_USING_ONCHIP_RTC
+ bool "Enable RTC"
+ select RT_USING_RTC
+ default n
+ if BSP_USING_ONCHIP_RTC
+ choice
+ prompt "Select clock source"
+ default BSP_RTC_USING_LSE
+
+ config BSP_RTC_USING_LSE
+ bool "RTC USING LSE"
+
+ config BSP_RTC_USING_LSI
+ bool "RTC USING LSI"
+ endchoice
+ endif
+
+ config BSP_USING_WDT
+ bool "Enable Watchdog Timer"
+ select RT_USING_WDT
+ default n
+
+ config BSP_USING_SDIO
+ bool "Enable SDIO"
+ select RT_USING_SDIO
+ select RT_USING_DFS
+ default n
+
+ config BSP_USING_USBD
+ bool "Enable USB Device"
+ select RT_USING_USB_DEVICE
+ default n
+
+ menuconfig BSP_USING_USBH
+ bool "Enable USB Host"
+ select RT_USING_USB_HOST
+ default n
+ if BSP_USING_USBH
+ menuconfig RT_USBH_MSTORAGE
+ bool "Enable Udisk Drivers"
+ default n
+ if RT_USBH_MSTORAGE
+ config UDISK_MOUNTPOINT
+ string "Udisk mount dir"
+ default "/"
+ endif
+ endif
+
+ source "../libraries/gd32_drivers/Kconfig"
+
+endmenu
+
+menu "Board extended module Drivers"
+
+endmenu
+
+endmenu
diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/SConscript b/bsp/gd32/arm/gd32470z-lckfb/board/SConscript
new file mode 100644
index 0000000000..dd76970852
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/board/SConscript
@@ -0,0 +1,28 @@
+import os
+import rtconfig
+from building import *
+
+Import('SDK_LIB')
+
+cwd = GetCurrentDir()
+
+# add general drivers
+src = Split('''
+board.c
+''')
+
+path = [cwd]
+
+startup_path_prefix = SDK_LIB
+
+if rtconfig.PLATFORM in ['gcc']:
+ src += [startup_path_prefix + '/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/GCC/startup_gd32f4xx.s']
+elif rtconfig.PLATFORM in ['armcc', 'armclang']:
+ src += [startup_path_prefix + '/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/ARM/startup_gd32f4xx.s']
+elif rtconfig.PLATFORM in ['iccarm']:
+ src += [startup_path_prefix + '/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/IAR/startup_gd32f4xx.s']
+
+CPPDEFINES = ['GD32F470']
+group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
+
+Return('group')
diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/board.c b/bsp/gd32/arm/gd32470z-lckfb/board/board.c
new file mode 100644
index 0000000000..5f0ce9bc58
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/board/board.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2006-2023, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2021-08-20 BruceOu first implementation
+ */
+#include <stdint.h>
+#include <rthw.h>
+#include <rtthread.h>
+#include <board.h>
+
+/**
+ * @brief This function is executed in case of error occurrence.
+ * @param None
+ * @retval None
+ */
+void Error_Handler(void)
+{
+ /* USER CODE BEGIN Error_Handler */
+ /* User can add his own implementation to report the HAL error return state */
+ while (1)
+ {
+ }
+ /* USER CODE END Error_Handler */
+}
+
+/** System Clock Configuration
+*/
+void SystemClock_Config(void)
+{
+ SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
+ NVIC_SetPriority(SysTick_IRQn, 0);
+}
+
+/**
+ * This is the timer interrupt service routine.
+ *
+ */
+void SysTick_Handler(void)
+{
+ /* enter interrupt */
+ rt_interrupt_enter();
+
+ rt_tick_increase();
+
+ /* leave interrupt */
+ rt_interrupt_leave();
+}
+
+/**
+ * This function will initial GD32 board.
+ */
+void rt_hw_board_init()
+{
+ /* NVIC Configuration */
+#define NVIC_VTOR_MASK 0x3FFFFF80
+#ifdef VECT_TAB_RAM
+ /* Set the Vector Table base location at 0x10000000 */
+ SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
+#else /* VECT_TAB_FLASH */
+ /* Set the Vector Table base location at 0x08000000 */
+ SCB->VTOR = (0x08000000 & NVIC_VTOR_MASK);
+#endif
+
+ SystemClock_Config();
+
+#ifdef RT_USING_COMPONENTS_INIT
+ rt_components_board_init();
+#endif
+
+#ifdef RT_USING_CONSOLE
+ rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
+#endif
+
+#ifdef BSP_USING_SDRAM
+ rt_system_heap_init((void *)EXT_SDRAM_BEGIN, (void *)EXT_SDRAM_END);
+#else
+ rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
+#endif
+}
+
+/*@}*/
diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/board.h b/bsp/gd32/arm/gd32470z-lckfb/board/board.h
new file mode 100644
index 0000000000..3006da3290
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/board/board.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2006-2023, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2021-08-20 BruceOu first implementation
+ */
+#ifndef __BOARD_H__
+#define __BOARD_H__
+
+#include "gd32f4xx.h"
+#include "drv_usart.h"
+#include "drv_gpio.h"
+
+#include "gd32f4xx_exti.h"
+
+#define EXT_SDRAM_BEGIN (0xC0000000U) /* the begining address of external SDRAM */
+#define EXT_SDRAM_END (EXT_SDRAM_BEGIN + (32U * 1024 * 1024)) /* the end address of external SDRAM */
+
+// <o> Internal SRAM memory size[Kbytes] <8-512>
+// <i>Default: 448
+#ifdef __ICCARM__
+// Use *.icf ram symbal, to avoid hardcode.
+extern char __ICFEDIT_region_RAM_end__;
+#define GD32_SRAM_END &__ICFEDIT_region_RAM_end__
+#else
+#define GD32_SRAM_SIZE 448
+#define GD32_SRAM_END (0x20000000 + GD32_SRAM_SIZE * 1024)
+#endif
+
+#ifdef __ARMCC_VERSION
+extern int Image$$RW_IRAM1$$ZI$$Limit;
+#define HEAP_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit)
+#elif __ICCARM__
+#pragma section="HEAP"
+#define HEAP_BEGIN (__segment_end("HEAP"))
+#else
+extern int __bss_end;
+#define HEAP_BEGIN (&__bss_end)
+#endif
+
+#define HEAP_END GD32_SRAM_END
+
+#endif
+
diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/gd32f4xx_libopt.h b/bsp/gd32/arm/gd32470z-lckfb/board/gd32f4xx_libopt.h
new file mode 100644
index 0000000000..d26e3d15ec
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/board/gd32f4xx_libopt.h
@@ -0,0 +1,45 @@
+/*!
+ \file gd32f4xx_libopt.h
+ \brief library optional for gd32f4xx
+*/
+
+/*
+ Copyright (C) 2016 GigaDevice
+
+ 2016-10-19, V1.0.0, firmware for GD32F4xx
+*/
+
+#ifndef GD32F4XX_LIBOPT_H
+#define GD32F4XX_LIBOPT_H
+#include "gd32f4xx_rcu.h"
+#include "gd32f4xx_adc.h"
+#include "gd32f4xx_can.h"
+#include "gd32f4xx_crc.h"
+#include "gd32f4xx_ctc.h"
+#include "gd32f4xx_dac.h"
+#include "gd32f4xx_dbg.h"
+#include "gd32f4xx_dci.h"
+#include "gd32f4xx_dma.h"
+//#include "gd32f4xx_enet.h"
+#include "gd32f4xx_exmc.h"
+#include "gd32f4xx_exti.h"
+#include "gd32f4xx_fmc.h"
+#include "gd32f4xx_fwdgt.h"
+#include "gd32f4xx_gpio.h"
+#include "gd32f4xx_syscfg.h"
+#include "gd32f4xx_i2c.h"
+#include "gd32f4xx_ipa.h"
+#include "gd32f4xx_iref.h"
+#include "gd32f4xx_pmu.h"
+#include "gd32f4xx_rcu.h"
+#include "gd32f4xx_rtc.h"
+#include "gd32f4xx_sdio.h"
+#include "gd32f4xx_spi.h"
+#include "gd32f4xx_timer.h"
+#include "gd32f4xx_tli.h"
+#include "gd32f4xx_trng.h"
+#include "gd32f4xx_usart.h"
+#include "gd32f4xx_wwdgt.h"
+#include "gd32f4xx_misc.h"
+
+#endif /* GD32F4XX_LIBOPT_H */
diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/linker_scripts/link.icf b/bsp/gd32/arm/gd32470z-lckfb/board/linker_scripts/link.icf
new file mode 100644
index 0000000000..0c38c55897
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/board/linker_scripts/link.icf
@@ -0,0 +1,40 @@
+/*###ICF### Section handled by ICF editor, don't touch! ****/
+/*-Editor annotation file-*/
+/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
+/*-Specials-*/
+define symbol __ICFEDIT_intvec_start__ = 0x08000000;
+/*-Memory Regions-*/
+define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
+define symbol __ICFEDIT_region_ROM_end__ = 0x080FFFFF;
+define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
+define symbol __ICFEDIT_region_RAM_end__ = 0x2006FFFF;
+/*-Sizes-*/
+define symbol __ICFEDIT_size_cstack__ = 0x2000;
+define symbol __ICFEDIT_size_heap__ = 0x2000;
+/**** End of ICF editor section. ###ICF###*/
+
+export symbol __ICFEDIT_region_RAM_end__;
+
+define symbol __region_RAM1_start__ = 0x10000000;
+define symbol __region_RAM1_end__ = 0x1000FFFF;
+
+define memory mem with size = 4G;
+define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
+define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
+define region RAM1_region = mem:[from __region_RAM1_start__ to __region_RAM1_end__];
+
+define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
+define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
+
+initialize by copy { readwrite };
+do not initialize { section .noinit };
+
+keep { section FSymTab };
+keep { section VSymTab };
+keep { section .rti_fn* };
+place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
+
+place in ROM_region { readonly };
+place in RAM_region { readwrite,
+ block CSTACK, block HEAP };
+place in RAM1_region { section .sram };
diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/linker_scripts/link.ld b/bsp/gd32/arm/gd32470z-lckfb/board/linker_scripts/link.ld
new file mode 100644
index 0000000000..5bec095bfb
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/board/linker_scripts/link.ld
@@ -0,0 +1,142 @@
+/*
+ * linker script for GD32F4xx with GNU ld
+ * BruceOu 2021-12-14
+ */
+
+/* Program Entry, set to mark it as "used" and avoid gc */
+MEMORY
+{
+ CODE (rx) : ORIGIN = 0x08000000, LENGTH = 1024k /* 1024KB flash */
+ DATA (rw) : ORIGIN = 0x20000000, LENGTH = 448k /* 448KB sram */
+}
+ENTRY(Reset_Handler)
+_system_stack_size = 0x200;
+
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _stext = .;
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ *(.text) /* remaining code */
+ *(.text.*) /* remaining code */
+ *(.rodata) /* read-only data (constants) */
+ *(.rodata*)
+ *(.glue_7)
+ *(.glue_7t)
+ *(.gnu.linkonce.t*)
+
+ /* section information for finsh shell */
+ . = ALIGN(4);
+ __fsymtab_start = .;
+ KEEP(*(FSymTab))
+ __fsymtab_end = .;
+ . = ALIGN(4);
+ __vsymtab_start = .;
+ KEEP(*(VSymTab))
+ __vsymtab_end = .;
+ . = ALIGN(4);
+
+ /* section information for initial. */
+ . = ALIGN(4);
+ __rt_init_start = .;
+ KEEP(*(SORT(.rti_fn*)))
+ __rt_init_end = .;
+ . = ALIGN(4);
+
+ . = ALIGN(4);
+ _etext = .;
+ } > CODE = 0
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ __exidx_start = .;
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+
+ /* This is used by the startup in order to initialize the .data secion */
+ _sidata = .;
+ } > CODE
+ __exidx_end = .;
+
+ /* .data section which is used for initialized data */
+
+ .data : AT (_sidata)
+ {
+ . = ALIGN(4);
+ /* This is used by the startup in order to initialize the .data secion */
+ _sdata = . ;
+
+ *(.data)
+ *(.data.*)
+ *(.gnu.linkonce.d*)
+
+ . = ALIGN(4);
+ /* This is used by the startup in order to initialize the .data secion */
+ _edata = . ;
+ } >DATA
+
+ .stack :
+ {
+ . = . + _system_stack_size;
+ . = ALIGN(4);
+ _estack = .;
+ } >DATA
+
+ __bss_start = .;
+ .bss :
+ {
+ . = ALIGN(4);
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .;
+
+ *(.bss)
+ *(.bss.*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ /* This is used by the startup in order to initialize the .bss secion */
+ _ebss = . ;
+
+ *(.bss.init)
+ } > DATA
+ __bss_end = .;
+
+ _end = .;
+
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+ /* DWARF debug sections.
+ * Symbols in the DWARF debugging sections are relative to the beginning
+ * of the section so we begin them at 0. */
+ /* DWARF 1 */
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ /* GNU DWARF 1 extensions */
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ /* DWARF 1.1 and DWARF 2 */
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ /* SGI/MIPS DWARF 2 extensions */
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+}
diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/linker_scripts/link.sct b/bsp/gd32/arm/gd32470z-lckfb/board/linker_scripts/link.sct
new file mode 100644
index 0000000000..56a5b1213b
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/board/linker_scripts/link.sct
@@ -0,0 +1,15 @@
+; *************************************************************
+; *** Scatter-Loading Description File generated by uVision ***
+; *************************************************************
+
+LR_IROM1 0x08000000 0x00100000 { ; load region size_region
+ ER_IROM1 0x08000000 0x00100000 { ; load address = execution address
+ *.o (RESET, +First)
+ *(InRoot$$Sections)
+ .ANY (+RO)
+ }
+ RW_IRAM1 0x20000000 0x00070000 { ; RW data
+ .ANY (+RW +ZI)
+ }
+}
+
diff --git a/bsp/gd32/arm/gd32470z-lckfb/figures/board.png b/bsp/gd32/arm/gd32470z-lckfb/figures/board.png
new file mode 100644
index 0000000000..45f85c7db6
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/figures/board.png
Binary files differ
diff --git a/bsp/gd32/arm/gd32470z-lckfb/project.ewd b/bsp/gd32/arm/gd32470z-lckfb/project.ewd
new file mode 100644
index 0000000000..ff32f65ffb
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/project.ewd
@@ -0,0 +1,3056 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <fileVersion>3</fileVersion>
+ <configuration>
+ <name>Debug</name>
+ <toolchain>
+ <name>ARM</name>
+ </toolchain>
+ <debug>1</debug>
+ <settings>
+ <name>C-SPY</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>32</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>CInput</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CEndian</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCVariant</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>MemOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MemFile</name>
+ <state>$TOOLKIT_DIR$\CONFIG\debugger\GigaDevice\GD32F450xK.ddf</state>
+ </option>
+ <option>
+ <name>RunToEnable</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RunToName</name>
+ <state>main</state>
+ </option>
+ <option>
+ <name>CExtraOptionsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CExtraOptions</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CFpuProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCDDFArgumentProducer</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCDownloadSuppressDownload</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCDownloadVerifyAll</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCProductVersion</name>
+ <state>9.10.2.39304</state>
+ </option>
+ <option>
+ <name>OCDynDriverList</name>
+ <state>ARMSIM_ID</state>
+ </option>
+ <option>
+ <name>OCLastSavedByProductVersion</name>
+ <state>9.10.2.39304</state>
+ </option>
+ <option>
+ <name>UseFlashLoader</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CLowLevel</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCBE8Slave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>MacFile2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CDevice</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>FlashLoadersV3</name>
+ <state>$TOOLKIT_DIR$\config\flashloader\GigaDevice\FlashGD32F4xxxK.board</state>
+ </option>
+ <option>
+ <name>OCImagesSuppressCheck1</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCImagesPath1</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCImagesSuppressCheck2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCImagesPath2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCImagesSuppressCheck3</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCImagesPath3</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OverrideDefFlashBoard</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCImagesOffset1</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCImagesOffset2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCImagesOffset3</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCImagesUse1</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCImagesUse2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCImagesUse3</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCDeviceConfigMacroFile</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCDebuggerExtraOption</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCAllMTBOptions</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCMulticoreNrOfCores</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCMulticoreWorkspace</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCMulticoreSlaveProject</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCMulticoreSlaveConfiguration</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCDownloadExtraImage</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCAttachSlave</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MassEraseBeforeFlashing</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCMulticoreNrOfCoresSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCMulticoreAMPConfigType</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCMulticoreSessionFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCTpiuBaseOption</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>ARMSIM_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>1</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>OCSimDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCSimEnablePSP</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCSimPspOverrideConfig</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCSimPspConfigFile</name>
+ <state></state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>CADI_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>0</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>CCadiMemory</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>Fast Model</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCADILogFileCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCADILogFileEditB</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>CMSISDAP_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>4</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCIarProbeScriptFile</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CMSISDAPResetList</name>
+ <version>1</version>
+ <state>10</state>
+ </option>
+ <option>
+ <name>CMSISDAPHWResetDuration</name>
+ <state>300</state>
+ </option>
+ <option>
+ <name>CMSISDAPHWResetDelay</name>
+ <state>200</state>
+ </option>
+ <option>
+ <name>CMSISDAPDoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPLogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>CMSISDAPInterfaceRadio</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CMSISDAPInterfaceCmdLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPMultiTargetEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPMultiTarget</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPJtagSpeedList</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPBreakpointRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPRestoreBreakpointsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPUpdateBreakpointsEdit</name>
+ <state>_call_main</state>
+ </option>
+ <option>
+ <name>RDICatchReset</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>RDICatchUndef</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RDICatchSWI</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>RDICatchData</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RDICatchPrefetch</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RDICatchIRQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>RDICatchFIQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchCORERESET</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchMMERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchNOCPERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchCHKERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchSTATERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchBUSERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchINTERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchSFERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchHARDERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchDummy</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPMultiCPUEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPMultiCPUNumber</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCProbeCfgOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCProbeConfig</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CMSISDAPProbeConfigRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPSelectedCPUBehaviour</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ICpuName</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCJetEmuParams</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCCMSISDAPUsbSerialNo</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCCMSISDAPUsbSerialNoSelect</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>GDBSERVER_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>0</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>TCPIP</name>
+ <state>aaa.bbb.ccc.ddd</state>
+ </option>
+ <option>
+ <name>DoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>LogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>CCJTagBreakpointRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJTagDoUpdateBreakpoints</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJTagUpdateBreakpoints</name>
+ <state>_call_main</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>IJET_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>9</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCIarProbeScriptFile</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IjetResetList</name>
+ <version>1</version>
+ <state>10</state>
+ </option>
+ <option>
+ <name>IjetHWResetDuration</name>
+ <state>300</state>
+ </option>
+ <option>
+ <name>IjetHWResetDelay</name>
+ <state>200</state>
+ </option>
+ <option>
+ <name>IjetPowerFromProbe</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IjetPowerRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetDoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetLogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>IjetInterfaceRadio</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IjetInterfaceCmdLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetMultiTargetEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetMultiTarget</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetScanChainNonARMDevices</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetIRLength</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetJtagSpeedList</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetProtocolRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetSwoPin</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetCpuClockEdit</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IjetSwoPrescalerList</name>
+ <version>1</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetBreakpointRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetRestoreBreakpointsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetUpdateBreakpointsEdit</name>
+ <state>_call_main</state>
+ </option>
+ <option>
+ <name>RDICatchReset</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>RDICatchUndef</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RDICatchSWI</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>RDICatchData</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RDICatchPrefetch</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RDICatchIRQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>RDICatchFIQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchCORERESET</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchMMERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchNOCPERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchCHKERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchSTATERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchBUSERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchINTERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchSFERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchHARDERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchDummy</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCProbeCfgOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCProbeConfig</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IjetProbeConfigRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetMultiCPUEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetMultiCPUNumber</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetSelectedCPUBehaviour</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ICpuName</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCJetEmuParams</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IjetPreferETB</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IjetTraceSettingsList</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetTraceSizeList</name>
+ <version>0</version>
+ <state>4</state>
+ </option>
+ <option>
+ <name>FlashBoardPathSlave</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCIjetUsbSerialNo</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCIjetUsbSerialNoSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8ARReset</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREREL1NS</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREREL1S</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREREL2NS</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREREL3S</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREEL1NS</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8ARREL1NS</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREEL1S</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8ARREL1S</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREEL2NS</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8ARREL2NS</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREEL3S</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8ARREL3S</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>JLINK_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>16</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>JLinkSpeed</name>
+ <state>1000</state>
+ </option>
+ <option>
+ <name>CCJLinkDoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkLogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>CCJLinkHWResetDelay</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>JLinkInitialSpeed</name>
+ <state>1000</state>
+ </option>
+ <option>
+ <name>CCDoJlinkMultiTarget</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCScanChainNonARMDevices</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkMultiTarget</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkIRLength</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkCommRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkTCPIP</name>
+ <state>aaa.bbb.ccc.ddd</state>
+ </option>
+ <option>
+ <name>CCJLinkSpeedRadioV2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCUSBDevice</name>
+ <version>1</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCRDICatchReset</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCRDICatchUndef</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCRDICatchSWI</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCRDICatchData</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCRDICatchPrefetch</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCRDICatchIRQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCRDICatchFIQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkBreakpointRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkDoUpdateBreakpoints</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkUpdateBreakpoints</name>
+ <state>_call_main</state>
+ </option>
+ <option>
+ <name>CCJLinkInterfaceRadio</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCJLinkResetList</name>
+ <version>6</version>
+ <state>5</state>
+ </option>
+ <option>
+ <name>CCJLinkInterfaceCmdLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchCORERESET</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchMMERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchNOCPERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchCHRERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchSTATERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchBUSERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchINTERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchSFERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchHARDERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchDummy</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCJLinkScriptFile</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCJLinkUsbSerialNo</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCTcpIpAlt</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkTcpIpSerialNo</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCCpuClockEdit</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCSwoClockAuto</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSwoClockEdit</name>
+ <state>2000</state>
+ </option>
+ <option>
+ <name>OCJLinkTraceSource</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCJLinkTraceSourceDummy</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCJLinkDeviceName</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>LMIFTDI_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>3</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>LmiftdiSpeed</name>
+ <state>500</state>
+ </option>
+ <option>
+ <name>CCLmiftdiDoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCLmiftdiLogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>CCLmiFtdiInterfaceRadio</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCLmiFtdiInterfaceCmdLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCLmiftdiUsbSerialNo</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCLmiftdiUsbSerialNoSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCLmiftdiResetList</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>NULINK_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>0</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>DoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>LogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>PEMICRO_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>3</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCJPEMicroShowSettings</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>DoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>LogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>STLINK_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>7</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCSTLinkInterfaceRadio</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCSTLinkInterfaceCmdLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkResetList</name>
+ <version>3</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCpuClockEdit</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCSwoClockAuto</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCSwoClockEdit</name>
+ <state>2000</state>
+ </option>
+ <option>
+ <name>DoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>LogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>CCSTLinkDoUpdateBreakpoints</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkUpdateBreakpoints</name>
+ <state>_call_main</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchCORERESET</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchMMERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchNOCPERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchCHRERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchSTATERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchBUSERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchINTERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchSFERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchHARDERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchDummy</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkUsbSerialNo</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCSTLinkUsbSerialNoSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkJtagSpeedList</name>
+ <version>2</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkDAPNumber</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCSTLinkDebugAccessPortRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkUseServerSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkProbeList</name>
+ <version>1</version>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>THIRDPARTY_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>0</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>CThirdPartyDriverDll</name>
+ <state>###Uninitialized###</state>
+ </option>
+ <option>
+ <name>CThirdPartyLogFileCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CThirdPartyLogFileEditB</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>TIFET_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>1</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCMSPFetResetList</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetInterfaceRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetInterfaceCmdLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetTargetVccTypeDefault</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetTargetVoltage</name>
+ <state>###Uninitialized###</state>
+ </option>
+ <option>
+ <name>CCMSPFetVCCDefault</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCMSPFetTargetSettlingtime</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetRadioJtagSpeedType</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCMSPFetConnection</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetUsbComPort</name>
+ <state>Automatic</state>
+ </option>
+ <option>
+ <name>CCMSPFetAllowAccessToBSL</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetDoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetLogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>CCMSPFetRadioEraseFlash</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>XDS100_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>8</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>TIPackageOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>TIPackage</name>
+ <state></state>
+ </option>
+ <option>
+ <name>BoardFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>DoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>LogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>CCXds100BreakpointRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100DoUpdateBreakpoints</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100UpdateBreakpoints</name>
+ <state>_call_main</state>
+ </option>
+ <option>
+ <name>CCXds100CatchReset</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchUndef</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchSWI</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchData</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchPrefetch</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchIRQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchFIQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchCORERESET</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchMMERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchNOCPERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchCHRERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchSTATERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchBUSERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchINTERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchSFERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchHARDERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchDummy</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CpuClockEdit</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCXds100SwoClockAuto</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100SwoClockEdit</name>
+ <state>1000</state>
+ </option>
+ <option>
+ <name>CCXds100HWResetDelay</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100ResetList</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100UsbSerialNo</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCXds100UsbSerialNoSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100JtagSpeedList</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100InterfaceRadio</name>
+ <state>2</state>
+ </option>
+ <option>
+ <name>CCXds100InterfaceCmdLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100ProbeList</name>
+ <version>0</version>
+ <state>3</state>
+ </option>
+ <option>
+ <name>CCXds100SWOPortRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100SWOPort</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCXDSTargetVccEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXDSTargetVoltage</name>
+ <state>###Uninitialized###</state>
+ </option>
+ <option>
+ <name>OCXDSDigitalStatesConfigFile</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <debuggerPlugins>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\FreeRtos\FreeRtosArmPlugin.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin2.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9BE.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$EW_DIR$\common\plugins\TargetAccessServer\TargetAccessServer.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ </debuggerPlugins>
+ </configuration>
+ <configuration>
+ <name>Release</name>
+ <toolchain>
+ <name>ARM</name>
+ </toolchain>
+ <debug>0</debug>
+ <settings>
+ <name>C-SPY</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>32</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>CInput</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CEndian</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCVariant</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>MemOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MemFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>RunToEnable</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RunToName</name>
+ <state>main</state>
+ </option>
+ <option>
+ <name>CExtraOptionsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CExtraOptions</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CFpuProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCDDFArgumentProducer</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCDownloadSuppressDownload</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCDownloadVerifyAll</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCProductVersion</name>
+ <state>9.10.2.39304</state>
+ </option>
+ <option>
+ <name>OCDynDriverList</name>
+ <state>ARMSIM_ID</state>
+ </option>
+ <option>
+ <name>OCLastSavedByProductVersion</name>
+ <state></state>
+ </option>
+ <option>
+ <name>UseFlashLoader</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CLowLevel</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCBE8Slave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>MacFile2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CDevice</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>FlashLoadersV3</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCImagesSuppressCheck1</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCImagesPath1</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCImagesSuppressCheck2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCImagesPath2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCImagesSuppressCheck3</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCImagesPath3</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OverrideDefFlashBoard</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCImagesOffset1</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCImagesOffset2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCImagesOffset3</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCImagesUse1</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCImagesUse2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCImagesUse3</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCDeviceConfigMacroFile</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCDebuggerExtraOption</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCAllMTBOptions</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCMulticoreNrOfCores</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCMulticoreWorkspace</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCMulticoreSlaveProject</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCMulticoreSlaveConfiguration</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCDownloadExtraImage</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCAttachSlave</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MassEraseBeforeFlashing</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCMulticoreNrOfCoresSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCMulticoreAMPConfigType</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCMulticoreSessionFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCTpiuBaseOption</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>ARMSIM_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>1</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>OCSimDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCSimEnablePSP</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCSimPspOverrideConfig</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCSimPspConfigFile</name>
+ <state></state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>CADI_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>0</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>CCadiMemory</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>Fast Model</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCADILogFileCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCADILogFileEditB</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>CMSISDAP_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>4</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCIarProbeScriptFile</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CMSISDAPResetList</name>
+ <version>1</version>
+ <state>10</state>
+ </option>
+ <option>
+ <name>CMSISDAPHWResetDuration</name>
+ <state>300</state>
+ </option>
+ <option>
+ <name>CMSISDAPHWResetDelay</name>
+ <state>200</state>
+ </option>
+ <option>
+ <name>CMSISDAPDoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPLogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>CMSISDAPInterfaceRadio</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CMSISDAPInterfaceCmdLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPMultiTargetEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPMultiTarget</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPJtagSpeedList</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPBreakpointRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPRestoreBreakpointsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPUpdateBreakpointsEdit</name>
+ <state>_call_main</state>
+ </option>
+ <option>
+ <name>RDICatchReset</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>RDICatchUndef</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RDICatchSWI</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>RDICatchData</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RDICatchPrefetch</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RDICatchIRQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>RDICatchFIQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchCORERESET</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchMMERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchNOCPERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchCHKERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchSTATERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchBUSERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchINTERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchSFERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchHARDERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchDummy</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPMultiCPUEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPMultiCPUNumber</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCProbeCfgOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCProbeConfig</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CMSISDAPProbeConfigRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CMSISDAPSelectedCPUBehaviour</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ICpuName</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCJetEmuParams</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCCMSISDAPUsbSerialNo</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCCMSISDAPUsbSerialNoSelect</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>GDBSERVER_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>0</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>TCPIP</name>
+ <state>aaa.bbb.ccc.ddd</state>
+ </option>
+ <option>
+ <name>DoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>LogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>CCJTagBreakpointRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJTagDoUpdateBreakpoints</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJTagUpdateBreakpoints</name>
+ <state>_call_main</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>IJET_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>9</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OCIarProbeScriptFile</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IjetResetList</name>
+ <version>1</version>
+ <state>10</state>
+ </option>
+ <option>
+ <name>IjetHWResetDuration</name>
+ <state>300</state>
+ </option>
+ <option>
+ <name>IjetHWResetDelay</name>
+ <state>200</state>
+ </option>
+ <option>
+ <name>IjetPowerFromProbe</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IjetPowerRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetDoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetLogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>IjetInterfaceRadio</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IjetInterfaceCmdLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetMultiTargetEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetMultiTarget</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetScanChainNonARMDevices</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetIRLength</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetJtagSpeedList</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetProtocolRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetSwoPin</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetCpuClockEdit</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IjetSwoPrescalerList</name>
+ <version>1</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetBreakpointRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetRestoreBreakpointsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetUpdateBreakpointsEdit</name>
+ <state>_call_main</state>
+ </option>
+ <option>
+ <name>RDICatchReset</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>RDICatchUndef</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RDICatchSWI</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>RDICatchData</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RDICatchPrefetch</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RDICatchIRQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>RDICatchFIQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchCORERESET</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchMMERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchNOCPERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchCHKERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchSTATERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchBUSERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchINTERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchSFERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchHARDERR</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CatchDummy</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCProbeCfgOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCProbeConfig</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IjetProbeConfigRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetMultiCPUEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetMultiCPUNumber</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetSelectedCPUBehaviour</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ICpuName</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OCJetEmuParams</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IjetPreferETB</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IjetTraceSettingsList</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IjetTraceSizeList</name>
+ <version>0</version>
+ <state>4</state>
+ </option>
+ <option>
+ <name>FlashBoardPathSlave</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCIjetUsbSerialNo</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCIjetUsbSerialNoSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8ARReset</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREREL1NS</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREREL1S</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREREL2NS</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREREL3S</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREEL1NS</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8ARREL1NS</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREEL1S</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8ARREL1S</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREEL2NS</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8ARREL2NS</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8AREEL3S</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CatchV8ARREL3S</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>JLINK_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>16</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>JLinkSpeed</name>
+ <state>1000</state>
+ </option>
+ <option>
+ <name>CCJLinkDoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkLogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>CCJLinkHWResetDelay</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>JLinkInitialSpeed</name>
+ <state>1000</state>
+ </option>
+ <option>
+ <name>CCDoJlinkMultiTarget</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCScanChainNonARMDevices</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkMultiTarget</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkIRLength</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkCommRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkTCPIP</name>
+ <state>aaa.bbb.ccc.ddd</state>
+ </option>
+ <option>
+ <name>CCJLinkSpeedRadioV2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCUSBDevice</name>
+ <version>1</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCRDICatchReset</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCRDICatchUndef</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCRDICatchSWI</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCRDICatchData</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCRDICatchPrefetch</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCRDICatchIRQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCRDICatchFIQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkBreakpointRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkDoUpdateBreakpoints</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkUpdateBreakpoints</name>
+ <state>_call_main</state>
+ </option>
+ <option>
+ <name>CCJLinkInterfaceRadio</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCJLinkResetList</name>
+ <version>6</version>
+ <state>5</state>
+ </option>
+ <option>
+ <name>CCJLinkInterfaceCmdLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchCORERESET</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchMMERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchNOCPERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchCHRERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchSTATERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchBUSERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchINTERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchSFERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchHARDERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCatchDummy</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCJLinkScriptFile</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCJLinkUsbSerialNo</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCTcpIpAlt</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCJLinkTcpIpSerialNo</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCCpuClockEdit</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCSwoClockAuto</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSwoClockEdit</name>
+ <state>2000</state>
+ </option>
+ <option>
+ <name>OCJLinkTraceSource</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCJLinkTraceSourceDummy</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCJLinkDeviceName</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>LMIFTDI_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>3</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>LmiftdiSpeed</name>
+ <state>500</state>
+ </option>
+ <option>
+ <name>CCLmiftdiDoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCLmiftdiLogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>CCLmiFtdiInterfaceRadio</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCLmiFtdiInterfaceCmdLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCLmiftdiUsbSerialNo</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCLmiftdiUsbSerialNoSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCLmiftdiResetList</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>NULINK_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>0</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>DoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>LogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>PEMICRO_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>3</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCJPEMicroShowSettings</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>DoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>LogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>STLINK_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>7</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCSTLinkInterfaceRadio</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCSTLinkInterfaceCmdLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkResetList</name>
+ <version>3</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCpuClockEdit</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCSwoClockAuto</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCSwoClockEdit</name>
+ <state>2000</state>
+ </option>
+ <option>
+ <name>DoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>LogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>CCSTLinkDoUpdateBreakpoints</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkUpdateBreakpoints</name>
+ <state>_call_main</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchCORERESET</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchMMERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchNOCPERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchCHRERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchSTATERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchBUSERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchINTERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchSFERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchHARDERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkCatchDummy</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkUsbSerialNo</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCSTLinkUsbSerialNoSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkJtagSpeedList</name>
+ <version>2</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkDAPNumber</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCSTLinkDebugAccessPortRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkUseServerSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSTLinkProbeList</name>
+ <version>1</version>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>THIRDPARTY_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>0</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>CThirdPartyDriverDll</name>
+ <state>###Uninitialized###</state>
+ </option>
+ <option>
+ <name>CThirdPartyLogFileCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CThirdPartyLogFileEditB</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>TIFET_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>1</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCMSPFetResetList</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetInterfaceRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetInterfaceCmdLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetTargetVccTypeDefault</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetTargetVoltage</name>
+ <state>###Uninitialized###</state>
+ </option>
+ <option>
+ <name>CCMSPFetVCCDefault</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCMSPFetTargetSettlingtime</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetRadioJtagSpeedType</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCMSPFetConnection</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetUsbComPort</name>
+ <state>Automatic</state>
+ </option>
+ <option>
+ <name>CCMSPFetAllowAccessToBSL</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetDoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMSPFetLogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>CCMSPFetRadioEraseFlash</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>XDS100_ID</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>8</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>OCDriverInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>TIPackageOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>TIPackage</name>
+ <state></state>
+ </option>
+ <option>
+ <name>BoardFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>DoLogfile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>LogFile</name>
+ <state>$PROJ_DIR$\cspycomm.log</state>
+ </option>
+ <option>
+ <name>CCXds100BreakpointRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100DoUpdateBreakpoints</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100UpdateBreakpoints</name>
+ <state>_call_main</state>
+ </option>
+ <option>
+ <name>CCXds100CatchReset</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchUndef</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchSWI</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchData</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchPrefetch</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchIRQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchFIQ</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchCORERESET</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchMMERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchNOCPERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchCHRERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchSTATERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchBUSERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchINTERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchSFERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchHARDERR</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CatchDummy</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100CpuClockEdit</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCXds100SwoClockAuto</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100SwoClockEdit</name>
+ <state>1000</state>
+ </option>
+ <option>
+ <name>CCXds100HWResetDelay</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100ResetList</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100UsbSerialNo</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCXds100UsbSerialNoSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100JtagSpeedList</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100InterfaceRadio</name>
+ <state>2</state>
+ </option>
+ <option>
+ <name>CCXds100InterfaceCmdLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100ProbeList</name>
+ <version>0</version>
+ <state>3</state>
+ </option>
+ <option>
+ <name>CCXds100SWOPortRadio</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXds100SWOPort</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCXDSTargetVccEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCXDSTargetVoltage</name>
+ <state>###Uninitialized###</state>
+ </option>
+ <option>
+ <name>OCXDSDigitalStatesConfigFile</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <debuggerPlugins>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\FreeRtos\FreeRtosArmPlugin.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin2.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9BE.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$EW_DIR$\common\plugins\TargetAccessServer\TargetAccessServer.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ <plugin>
+ <file>$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin</file>
+ <loadFlag>0</loadFlag>
+ </plugin>
+ </debuggerPlugins>
+ </configuration>
+</project>
diff --git a/bsp/gd32/arm/gd32470z-lckfb/project.ewp b/bsp/gd32/arm/gd32470z-lckfb/project.ewp
new file mode 100644
index 0000000000..0b77ae33fc
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/project.ewp
@@ -0,0 +1,2321 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <fileVersion>3</fileVersion>
+ <configuration>
+ <name>Debug</name>
+ <toolchain>
+ <name>ARM</name>
+ </toolchain>
+ <debug>1</debug>
+ <settings>
+ <name>General</name>
+ <archiveVersion>3</archiveVersion>
+ <data>
+ <version>33</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>BrowseInfoPath</name>
+ <state>Debug\BrowseInfo</state>
+ </option>
+ <option>
+ <name>ExePath</name>
+ <state>build\Exe</state>
+ </option>
+ <option>
+ <name>ObjPath</name>
+ <state>build\Obj</state>
+ </option>
+ <option>
+ <name>ListPath</name>
+ <state>build\List</state>
+ </option>
+ <option>
+ <name>GEndianMode</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>Input description</name>
+ <state>Automatic choice of formatter, without multibyte support.</state>
+ </option>
+ <option>
+ <name>Output description</name>
+ <state>Automatic choice of formatter, without multibyte support.</state>
+ </option>
+ <option>
+ <name>GOutputBinary</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGCoreOrChip</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>GRuntimeLibSelect</name>
+ <version>0</version>
+ <state>2</state>
+ </option>
+ <option>
+ <name>GRuntimeLibSelectSlave</name>
+ <version>0</version>
+ <state>2</state>
+ </option>
+ <option>
+ <name>RTDescription</name>
+ <state>Use the full configuration of the C/C++ runtime library. Full locale interface, C locale, file descriptor support, multibytes in printf and scanf, and hex floats in strtod.</state>
+ </option>
+ <option>
+ <name>OGProductVersion</name>
+ <state>7.40.2.8567</state>
+ </option>
+ <option>
+ <name>OGLastSavedByProductVersion</name>
+ <state>9.10.2.39304</state>
+ </option>
+ <option>
+ <name>OGChipSelectEditMenu</name>
+ <state>GD32F450xK GD GD32F450xK</state>
+ </option>
+ <option>
+ <name>GenLowLevelInterface</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>GEndianModeBE</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OGBufferedTerminalOutput</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GenStdoutInterface</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>RTConfigPath2</name>
+ <state>$TOOLKIT_DIR$\inc\c\DLib_Config_Full.h</state>
+ </option>
+ <option>
+ <name>GBECoreSlave</name>
+ <version>30</version>
+ <state>39</state>
+ </option>
+ <option>
+ <name>OGUseCmsis</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OGUseCmsisDspLib</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>GRuntimeLibThreads</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CoreVariant</name>
+ <version>30</version>
+ <state>39</state>
+ </option>
+ <option>
+ <name>GFPUDeviceSlave</name>
+ <state>GD32F450xK GD GD32F450xK</state>
+ </option>
+ <option>
+ <name>FPU2</name>
+ <version>0</version>
+ <state>4</state>
+ </option>
+ <option>
+ <name>NrRegs</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>NEON</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GFPUCoreSlave2</name>
+ <version>30</version>
+ <state>39</state>
+ </option>
+ <option>
+ <name>OGCMSISPackSelectDevice</name>
+ </option>
+ <option>
+ <name>OgLibHeap</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGLibAdditionalLocale</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGPrintfVariant</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGPrintfMultibyteSupport</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGScanfVariant</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGScanfMultibyteSupport</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GenLocaleTags</name>
+ <state></state>
+ </option>
+ <option>
+ <name>GenLocaleDisplayOnly</name>
+ <state></state>
+ </option>
+ <option>
+ <name>DSPExtension</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>TrustZone</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>TrustZoneModes</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGAarch64Abi</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OG_32_64Device</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>ICCARM</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>37</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>CCDefines</name>
+ <state>USE_STDPERIPH_DRIVER</state>
+ <state>GD32F4XX</state>
+ <state>CLOCKS_PER_SEC=RT_TICK_PER_SECOND</state>
+ <state>RT_USING_DLIBC</state>
+ <state>RT_USING_LIBC</state>
+ <state>GD32F450</state>
+ <state>__RTTHREAD__</state>
+ <state>USE_STDPERIPH_DRIVER</state>
+ </option>
+ <option>
+ <name>CCPreprocFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPreprocComments</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPreprocLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCMnemonics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCMessages</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListAssFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListAssSource</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCEnableRemarks</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCDiagSuppress</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagRemark</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagWarning</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagError</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCObjPrefix</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCAllowList</name>
+ <version>1</version>
+ <state>00000000</state>
+ </option>
+ <option>
+ <name>CCDebugInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IEndianMode</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IExtraOptionsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IExtraOptions</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCLangConformance</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSignedPlainChar</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCRequirePrototypes</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCDiagWarnAreErr</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCompilerRuntimeInfo</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IFpuProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OutputFile</name>
+ <state>$FILE_BNAME$.o</state>
+ </option>
+ <option>
+ <name>CCLibConfigHeader</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>PreInclude</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCIncludePath2</name>
+ <state>$PROJ_DIR$\..\..\..\..\components\libc\compilers\common\extension</state>
+ <state>$PROJ_DIR$\..\..\..\..\components\libc\posix\io\poll</state>
+ <state>$PROJ_DIR$\..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Include</state>
+ <state>$PROJ_DIR$\..\libraries\GD32F4xx_Firmware_Library\CMSIS\GD\GD32F4xx\Include</state>
+ <state>$PROJ_DIR$\..\..\..\..\libcpu\arm\cortex-m4</state>
+ <state>$PROJ_DIR$\..\libraries\gd32_drivers</state>
+ <state>$PROJ_DIR$\..\..\..\..\components\libc\compilers\common\extension\fcntl\octal</state>
+ <state>$PROJ_DIR$\..\..\..\..\components\libc\compilers\common</state>
+ <state>$PROJ_DIR$\..\libraries\GD32F4xx_Firmware_Library\CMSIS</state>
+ <state>$PROJ_DIR$\.</state>
+ <state>$PROJ_DIR$\applications</state>
+ <state>$PROJ_DIR$\..\..\..\..\components\libc\posix\ipc</state>
+ <state>$PROJ_DIR$\..\..\..\..\libcpu\arm\common</state>
+ <state>$PROJ_DIR$\board</state>
+ <state>$PROJ_DIR$\..\..\..\..\components\finsh</state>
+ <state>$PROJ_DIR$\..\..\..\..\components\libc\posix\io\stdio</state>
+ <state>$PROJ_DIR$\..\..\..\..\include</state>
+ <state>$PROJ_DIR$\..\..\..\..\components\drivers\include</state>
+ </option>
+ <option>
+ <name>CCStdIncCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCodeSection</name>
+ <state>.text</state>
+ </option>
+ <option>
+ <name>IProcessorMode2</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCOptLevel</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCOptStrategy</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptLevelSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCPosIndRopi</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPosIndRwpi</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPosIndNoDynInit</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccLang</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCDialect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccAllowVLA</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccStaticDestr</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccCppInlineSemantics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCmsis</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccFloatSemantics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptimizationNoSizeConstraints</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCNoLiteralPool</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptStrategySlave</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCGuardCalls</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCEncSource</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCEncOutput</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCEncOutputBom</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCEncInput</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccExceptions2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccRTTI2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OICompilerExtraOption</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCStackProtection</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>AARM</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>11</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>AObjPrefix</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AEndian</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>ACaseSensitivity</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>MacroChars</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnWhat</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnOne</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AWarnRange1</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AWarnRange2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>ADebug</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AltRegisterNames</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ADefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AList</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AListHeader</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AListing</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>Includes</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacDefs</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacExps</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>MacExec</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OnlyAssed</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MultiLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>PageLengthCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>PageLength</name>
+ <state>80</state>
+ </option>
+ <option>
+ <name>TabSpacing</name>
+ <state>8</state>
+ </option>
+ <option>
+ <name>AXRef</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefDefines</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefInternal</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefDual</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AFpuProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AOutputFile</name>
+ <state>$FILE_BNAME$.o</state>
+ </option>
+ <option>
+ <name>ALimitErrorsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ALimitErrorsEdit</name>
+ <state>100</state>
+ </option>
+ <option>
+ <name>AIgnoreStdInclude</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AUserIncludes</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AExtraOptionsCheckV2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AExtraOptionsV2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AsmNoLiteralPool</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>PreInclude</name>
+ <state></state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>OBJCOPY</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>1</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>OOCOutputFormat</name>
+ <version>3</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCOutputOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OOCOutputFile</name>
+ <state>project.srec</state>
+ </option>
+ <option>
+ <name>OOCCommandLineProducer</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OOCObjCopyEnable</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>CUSTOM</name>
+ <archiveVersion>3</archiveVersion>
+ <data>
+ <extensions></extensions>
+ <cmdline></cmdline>
+ <hasPrio>64</hasPrio>
+ <buildSequence>inputOutputBased</buildSequence>
+ </data>
+ </settings>
+ <settings>
+ <name>BUILDACTION</name>
+ <archiveVersion>1</archiveVersion>
+ <data>
+ <prebuild></prebuild>
+ <postbuild></postbuild>
+ </data>
+ </settings>
+ <settings>
+ <name>ILINK</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>25</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>IlinkLibIOConfig</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkInputFileSlave</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkOutputFile</name>
+ <state>rtthread.out</state>
+ </option>
+ <option>
+ <name>IlinkDebugInfoEnable</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkKeepSymbols</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySymbol</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySegment</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryAlign</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkDefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkConfigDefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkMapFile</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogFile</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogInitialization</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogModule</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogSection</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogVeneer</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkIcfOverride</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkIcfFile</name>
+ <state>$PROJ_DIR$\board\linker_scripts\link.icf</state>
+ </option>
+ <option>
+ <name>IlinkIcfFileSlave</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkEnableRemarks</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkSuppressDiags</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsRem</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsWarn</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsErr</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkWarningsAreErrors</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkUseExtraOptions</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkExtraOptions</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkLowLevelInterfaceSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkAutoLibEnable</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkAdditionalLibs</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkOverrideProgramEntryLabel</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkProgramEntryLabelSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkProgramEntryLabel</name>
+ <state>__iar_program_start</state>
+ </option>
+ <option>
+ <name>DoFill</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>FillerByte</name>
+ <state>0xFF</state>
+ </option>
+ <option>
+ <name>FillerStart</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>FillerEnd</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>CrcSize</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcAlign</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcPoly</name>
+ <state>0x11021</state>
+ </option>
+ <option>
+ <name>CrcCompl</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CrcBitOrder</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CrcInitialValue</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>DoCrc</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkBE8Slave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkBufferedTerminalOutput</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkStdoutInterfaceSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcFullSize</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkIElfToolPostProcess</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogAutoLibSelect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogRedirSymbols</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogUnusedFragments</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkCrcReverseByteOrder</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCrcUseAsInput</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptInline</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkOptExceptionsAllow</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptExceptionsForce</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCmsis</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptMergeDuplSections</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkOptUseVfe</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptForceVfe</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkStackAnalysisEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkStackControlFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkStackCallGraphFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CrcAlgorithm</name>
+ <version>1</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcUnitSize</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkThreadsSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogCallGraph</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkIcfFile_AltDefault</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkEncInput</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkEncOutput</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkEncOutputBom</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkHeapSelect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLocaleSelect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkTrustzoneImportLibraryOut</name>
+ <state>project_import_lib.o</state>
+ </option>
+ <option>
+ <name>OILinkExtraOption</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryFile2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySymbol2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySegment2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryAlign2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkLogCrtRoutineSelection</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogFragmentInfo</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogInlining</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogMerging</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkDemangle</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>IARCHIVE</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>0</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>IarchiveInputs</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IarchiveOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IarchiveOutput</name>
+ <state>###Unitialized###</state>
+ </option>
+ </data>
+ </settings>
+ </configuration>
+ <configuration>
+ <name>Release</name>
+ <toolchain>
+ <name>ARM</name>
+ </toolchain>
+ <debug>0</debug>
+ <settings>
+ <name>General</name>
+ <archiveVersion>3</archiveVersion>
+ <data>
+ <version>33</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>BrowseInfoPath</name>
+ <state>Release\BrowseInfo</state>
+ </option>
+ <option>
+ <name>ExePath</name>
+ <state>Release\Exe</state>
+ </option>
+ <option>
+ <name>ObjPath</name>
+ <state>Release\Obj</state>
+ </option>
+ <option>
+ <name>ListPath</name>
+ <state>Release\List</state>
+ </option>
+ <option>
+ <name>GEndianMode</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>Input description</name>
+ <state></state>
+ </option>
+ <option>
+ <name>Output description</name>
+ <state></state>
+ </option>
+ <option>
+ <name>GOutputBinary</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGCoreOrChip</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GRuntimeLibSelect</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>GRuntimeLibSelectSlave</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RTDescription</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OGProductVersion</name>
+ <state>7.40.2.8567</state>
+ </option>
+ <option>
+ <name>OGLastSavedByProductVersion</name>
+ <state>9.10.2.39304</state>
+ </option>
+ <option>
+ <name>OGChipSelectEditMenu</name>
+ <state>Default None</state>
+ </option>
+ <option>
+ <name>GenLowLevelInterface</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GEndianModeBE</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGBufferedTerminalOutput</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GenStdoutInterface</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>RTConfigPath2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>GBECoreSlave</name>
+ <version>30</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OGUseCmsis</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGUseCmsisDspLib</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GRuntimeLibThreads</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CoreVariant</name>
+ <version>30</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GFPUDeviceSlave</name>
+ <state>Default None</state>
+ </option>
+ <option>
+ <name>FPU2</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>NrRegs</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>NEON</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GFPUCoreSlave2</name>
+ <version>30</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGCMSISPackSelectDevice</name>
+ </option>
+ <option>
+ <name>OgLibHeap</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGLibAdditionalLocale</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGPrintfVariant</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGPrintfMultibyteSupport</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGScanfVariant</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGScanfMultibyteSupport</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GenLocaleTags</name>
+ <state></state>
+ </option>
+ <option>
+ <name>GenLocaleDisplayOnly</name>
+ <state></state>
+ </option>
+ <option>
+ <name>DSPExtension</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>TrustZone</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>TrustZoneModes</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGAarch64Abi</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OG_32_64Device</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>ICCARM</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>37</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>CCDefines</name>
+ <state>NDEBUG</state>
+ <state>CLOCKS_PER_SEC=RT_TICK_PER_SECOND</state>
+ <state>RT_USING_DLIBC</state>
+ <state>RT_USING_LIBC</state>
+ <state>GD32F450</state>
+ <state>__RTTHREAD__</state>
+ <state>USE_STDPERIPH_DRIVER</state>
+ </option>
+ <option>
+ <name>CCPreprocFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPreprocComments</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPreprocLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCMnemonics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCMessages</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListAssFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListAssSource</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCEnableRemarks</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCDiagSuppress</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagRemark</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagWarning</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagError</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCObjPrefix</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCAllowList</name>
+ <version>1</version>
+ <state>11111110</state>
+ </option>
+ <option>
+ <name>CCDebugInfo</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IEndianMode</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IExtraOptionsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IExtraOptions</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCLangConformance</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSignedPlainChar</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCRequirePrototypes</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCDiagWarnAreErr</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCompilerRuntimeInfo</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IFpuProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OutputFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCLibConfigHeader</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>PreInclude</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCIncludePath2</name>
+ <state>$PROJ_DIR$\..\..\..\..\components\libc\compilers\common\extension</state>
+ <state>$PROJ_DIR$\..\..\..\..\components\libc\posix\io\poll</state>
+ <state>$PROJ_DIR$\..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Include</state>
+ <state>$PROJ_DIR$\..\libraries\GD32F4xx_Firmware_Library\CMSIS\GD\GD32F4xx\Include</state>
+ <state>$PROJ_DIR$\..\..\..\..\libcpu\arm\cortex-m4</state>
+ <state>$PROJ_DIR$\..\libraries\gd32_drivers</state>
+ <state>$PROJ_DIR$\..\..\..\..\components\libc\compilers\common\extension\fcntl\octal</state>
+ <state>$PROJ_DIR$\..\..\..\..\components\libc\compilers\common</state>
+ <state>$PROJ_DIR$\..\libraries\GD32F4xx_Firmware_Library\CMSIS</state>
+ <state>$PROJ_DIR$\.</state>
+ <state>$PROJ_DIR$\applications</state>
+ <state>$PROJ_DIR$\..\..\..\..\components\libc\posix\ipc</state>
+ <state>$PROJ_DIR$\..\..\..\..\libcpu\arm\common</state>
+ <state>$PROJ_DIR$\board</state>
+ <state>$PROJ_DIR$\..\..\..\..\components\finsh</state>
+ <state>$PROJ_DIR$\..\..\..\..\components\libc\posix\io\stdio</state>
+ <state>$PROJ_DIR$\..\..\..\..\include</state>
+ <state>$PROJ_DIR$\..\..\..\..\components\drivers\include</state>
+ </option>
+ <option>
+ <name>CCStdIncCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCodeSection</name>
+ <state>.text</state>
+ </option>
+ <option>
+ <name>IProcessorMode2</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCOptLevel</name>
+ <state>3</state>
+ </option>
+ <option>
+ <name>CCOptStrategy</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptLevelSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCPosIndRopi</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPosIndRwpi</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPosIndNoDynInit</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccLang</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCDialect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccAllowVLA</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccStaticDestr</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccCppInlineSemantics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCmsis</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccFloatSemantics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptimizationNoSizeConstraints</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCNoLiteralPool</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptStrategySlave</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCGuardCalls</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCEncSource</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCEncOutput</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCEncOutputBom</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCEncInput</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccExceptions2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccRTTI2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OICompilerExtraOption</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCStackProtection</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>AARM</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>11</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>AObjPrefix</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AEndian</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>ACaseSensitivity</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>MacroChars</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnWhat</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnOne</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AWarnRange1</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AWarnRange2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>ADebug</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AltRegisterNames</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ADefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AList</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AListHeader</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AListing</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>Includes</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacDefs</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacExps</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>MacExec</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OnlyAssed</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MultiLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>PageLengthCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>PageLength</name>
+ <state>80</state>
+ </option>
+ <option>
+ <name>TabSpacing</name>
+ <state>8</state>
+ </option>
+ <option>
+ <name>AXRef</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefDefines</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefInternal</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefDual</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AFpuProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AOutputFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>ALimitErrorsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ALimitErrorsEdit</name>
+ <state>100</state>
+ </option>
+ <option>
+ <name>AIgnoreStdInclude</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AUserIncludes</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AExtraOptionsCheckV2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AExtraOptionsV2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AsmNoLiteralPool</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>PreInclude</name>
+ <state></state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>OBJCOPY</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>1</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>OOCOutputFormat</name>
+ <version>3</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCOutputOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OOCOutputFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OOCCommandLineProducer</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OOCObjCopyEnable</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>CUSTOM</name>
+ <archiveVersion>3</archiveVersion>
+ <data>
+ <extensions></extensions>
+ <cmdline></cmdline>
+ <hasPrio>0</hasPrio>
+ <buildSequence>inputOutputBased</buildSequence>
+ </data>
+ </settings>
+ <settings>
+ <name>BUILDACTION</name>
+ <archiveVersion>1</archiveVersion>
+ <data>
+ <prebuild></prebuild>
+ <postbuild></postbuild>
+ </data>
+ </settings>
+ <settings>
+ <name>ILINK</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>25</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>IlinkLibIOConfig</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkInputFileSlave</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkOutputFile</name>
+ <state>###Unitialized###</state>
+ </option>
+ <option>
+ <name>IlinkDebugInfoEnable</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkKeepSymbols</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySymbol</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySegment</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryAlign</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkDefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkConfigDefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkMapFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogInitialization</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogModule</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogSection</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogVeneer</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkIcfOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkIcfFile</name>
+ <state>lnk0t.icf</state>
+ </option>
+ <option>
+ <name>IlinkIcfFileSlave</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkEnableRemarks</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkSuppressDiags</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsRem</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsWarn</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsErr</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkWarningsAreErrors</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkUseExtraOptions</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkExtraOptions</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkLowLevelInterfaceSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkAutoLibEnable</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkAdditionalLibs</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkOverrideProgramEntryLabel</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkProgramEntryLabelSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkProgramEntryLabel</name>
+ <state></state>
+ </option>
+ <option>
+ <name>DoFill</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>FillerByte</name>
+ <state>0xFF</state>
+ </option>
+ <option>
+ <name>FillerStart</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>FillerEnd</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>CrcSize</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcAlign</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcPoly</name>
+ <state>0x11021</state>
+ </option>
+ <option>
+ <name>CrcCompl</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CrcBitOrder</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CrcInitialValue</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>DoCrc</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkBE8Slave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkBufferedTerminalOutput</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkStdoutInterfaceSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcFullSize</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkIElfToolPostProcess</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogAutoLibSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogRedirSymbols</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogUnusedFragments</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCrcReverseByteOrder</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCrcUseAsInput</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptInline</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptExceptionsAllow</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptExceptionsForce</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCmsis</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptMergeDuplSections</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkOptUseVfe</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptForceVfe</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkStackAnalysisEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkStackControlFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkStackCallGraphFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CrcAlgorithm</name>
+ <version>1</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcUnitSize</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkThreadsSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogCallGraph</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkIcfFile_AltDefault</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkEncInput</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkEncOutput</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkEncOutputBom</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkHeapSelect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLocaleSelect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkTrustzoneImportLibraryOut</name>
+ <state>###Unitialized###</state>
+ </option>
+ <option>
+ <name>OILinkExtraOption</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryFile2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySymbol2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySegment2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryAlign2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkLogCrtRoutineSelection</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogFragmentInfo</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogInlining</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogMerging</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkDemangle</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>IARCHIVE</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>0</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>IarchiveInputs</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IarchiveOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IarchiveOutput</name>
+ <state>###Unitialized###</state>
+ </option>
+ </data>
+ </settings>
+ </configuration>
+ <group>
+ <name>Applications</name>
+ <file>
+ <name>$PROJ_DIR$\applications\main.c</name>
+ </file>
+ </group>
+ <group>
+ <name>Compiler</name>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\libc\compilers\dlib\environ.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\libc\compilers\common\stdlib.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\libc\compilers\dlib\syscall_close.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\libc\compilers\dlib\syscall_lseek.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\libc\compilers\dlib\syscall_mem.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\libc\compilers\dlib\syscall_open.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\libc\compilers\dlib\syscall_read.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\libc\compilers\dlib\syscall_remove.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\libc\compilers\dlib\syscall_write.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\libc\compilers\dlib\syscalls.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\libc\compilers\common\time.c</name>
+ </file>
+ </group>
+ <group>
+ <name>CPU</name>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\libcpu\arm\common\backtrace.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\libcpu\arm\cortex-m4\context_iar.S</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\libcpu\arm\cortex-m4\cpuport.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\libcpu\arm\common\div0.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\libcpu\arm\common\showmem.c</name>
+ </file>
+ </group>
+ <group>
+ <name>DeviceDrivers</name>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\drivers\ipc\completion.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\drivers\ipc\dataqueue.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\drivers\misc\pin.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\drivers\ipc\pipe.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\drivers\ipc\ringblk_buf.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\drivers\ipc\ringbuffer.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\drivers\serial\serial.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\drivers\ipc\waitqueue.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\drivers\ipc\workqueue.c</name>
+ </file>
+ </group>
+ <group>
+ <name>Drivers</name>
+ <file>
+ <name>$PROJ_DIR$\board\board.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\libraries\gd32_drivers\drv_gpio.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\libraries\gd32_drivers\drv_usart.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\libraries\GD32F4xx_Firmware_Library\CMSIS\GD\GD32F4xx\Source\IAR\startup_gd32f4xx.s</name>
+ </file>
+ </group>
+ <group>
+ <name>Finsh</name>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\finsh\cmd.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\finsh\msh.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\components\finsh\shell.c</name>
+ </file>
+ </group>
+ <group>
+ <name>Kernel</name>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\src\clock.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\src\components.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\src\device.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\src\idle.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\src\ipc.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\src\irq.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\src\kservice.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\src\mem.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\src\mempool.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\src\object.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\src\scheduler.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\src\thread.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\..\src\timer.c</name>
+ </file>
+ </group>
+ <group>
+ <name>Libraries</name>
+ <file>
+ <name>$PROJ_DIR$\..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_exti.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_gpio.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_misc.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_rcu.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_syscfg.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_usart.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\libraries\GD32F4xx_Firmware_Library\CMSIS\GD\GD32F4xx\Source\system_gd32f4xx.c</name>
+ </file>
+ </group>
+ <group>
+ <name>POSIX</name>
+ </group>
+</project>
diff --git a/bsp/gd32/arm/gd32470z-lckfb/project.eww b/bsp/gd32/arm/gd32470z-lckfb/project.eww
new file mode 100644
index 0000000000..c2cb02eb1e
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/project.eww
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+
+<workspace>
+ <project>
+ <path>$WS_DIR$\project.ewp</path>
+ </project>
+ <batchBuild/>
+</workspace>
+
+
diff --git a/bsp/gd32/arm/gd32470z-lckfb/project.uvoptx b/bsp/gd32/arm/gd32470z-lckfb/project.uvoptx
new file mode 100644
index 0000000000..05849dd0d1
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/project.uvoptx
@@ -0,0 +1,917 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
+
+ <SchemaVersion>1.0</SchemaVersion>
+
+ <Header>### uVision Project, (C) Keil Software</Header>
+
+ <Extensions>
+ <cExt>*.c</cExt>
+ <aExt>*.s*; *.src; *.a*</aExt>
+ <oExt>*.obj; *.o</oExt>
+ <lExt>*.lib</lExt>
+ <tExt>*.txt; *.h; *.inc; *.md</tExt>
+ <pExt>*.plm</pExt>
+ <CppX>*.cpp</CppX>
+ <nMigrate>0</nMigrate>
+ </Extensions>
+
+ <DaveTm>
+ <dwLowDateTime>0</dwLowDateTime>
+ <dwHighDateTime>0</dwHighDateTime>
+ </DaveTm>
+
+ <Target>
+ <TargetName>rt-thread</TargetName>
+ <ToolsetNumber>0x4</ToolsetNumber>
+ <ToolsetName>ARM-ADS</ToolsetName>
+ <TargetOption>
+ <CLKADS>12000000</CLKADS>
+ <OPTTT>
+ <gFlags>1</gFlags>
+ <BeepAtEnd>1</BeepAtEnd>
+ <RunSim>0</RunSim>
+ <RunTarget>1</RunTarget>
+ <RunAbUc>0</RunAbUc>
+ </OPTTT>
+ <OPTHX>
+ <HexSelection>1</HexSelection>
+ <FlashByte>65535</FlashByte>
+ <HexRangeLowAddress>0</HexRangeLowAddress>
+ <HexRangeHighAddress>0</HexRangeHighAddress>
+ <HexOffset>0</HexOffset>
+ </OPTHX>
+ <OPTLEX>
+ <PageWidth>79</PageWidth>
+ <PageLength>66</PageLength>
+ <TabStop>8</TabStop>
+ <ListingPath>.\build\</ListingPath>
+ </OPTLEX>
+ <ListingPage>
+ <CreateCListing>1</CreateCListing>
+ <CreateAListing>1</CreateAListing>
+ <CreateLListing>1</CreateLListing>
+ <CreateIListing>0</CreateIListing>
+ <AsmCond>1</AsmCond>
+ <AsmSymb>1</AsmSymb>
+ <AsmXref>0</AsmXref>
+ <CCond>1</CCond>
+ <CCode>0</CCode>
+ <CListInc>0</CListInc>
+ <CSymb>0</CSymb>
+ <LinkerCodeListing>0</LinkerCodeListing>
+ </ListingPage>
+ <OPTXL>
+ <LMap>1</LMap>
+ <LComments>1</LComments>
+ <LGenerateSymbols>1</LGenerateSymbols>
+ <LLibSym>1</LLibSym>
+ <LLines>1</LLines>
+ <LLocSym>1</LLocSym>
+ <LPubSym>1</LPubSym>
+ <LXref>0</LXref>
+ <LExpSel>0</LExpSel>
+ </OPTXL>
+ <OPTFL>
+ <tvExp>1</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <IsCurrentTarget>1</IsCurrentTarget>
+ </OPTFL>
+ <CpuCode>255</CpuCode>
+ <DebugOpt>
+ <uSim>0</uSim>
+ <uTrg>1</uTrg>
+ <sLdApp>1</sLdApp>
+ <sGomain>1</sGomain>
+ <sRbreak>1</sRbreak>
+ <sRwatch>1</sRwatch>
+ <sRmem>1</sRmem>
+ <sRfunc>1</sRfunc>
+ <sRbox>1</sRbox>
+ <tLdApp>1</tLdApp>
+ <tGomain>1</tGomain>
+ <tRbreak>1</tRbreak>
+ <tRwatch>1</tRwatch>
+ <tRmem>1</tRmem>
+ <tRfunc>0</tRfunc>
+ <tRbox>1</tRbox>
+ <tRtrace>1</tRtrace>
+ <sRSysVw>1</sRSysVw>
+ <tRSysVw>1</tRSysVw>
+ <sRunDeb>0</sRunDeb>
+ <sLrtime>0</sLrtime>
+ <bEvRecOn>1</bEvRecOn>
+ <bSchkAxf>0</bSchkAxf>
+ <bTchkAxf>0</bTchkAxf>
+ <nTsel>3</nTsel>
+ <sDll></sDll>
+ <sDllPa></sDllPa>
+ <sDlgDll></sDlgDll>
+ <sDlgPa></sDlgPa>
+ <sIfile></sIfile>
+ <tDll></tDll>
+ <tDllPa></tDllPa>
+ <tDlgDll></tDlgDll>
+ <tDlgPa></tDlgPa>
+ <tIfile></tIfile>
+ <pMon>BIN\CMSIS_AGDI.dll</pMon>
+ </DebugOpt>
+ <TargetDriverDllRegistry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>UL2CM3</Key>
+ <Name>UL2CM3(-S0 -C0 -P0 ) -FN1 -FC1000 -FD20000000 -FF0GD32F4xx_1MB -FL0100000 -FS08000000 -FP0($$Device:GD32F470ZG$Flash\GD32F4xx_1MB.FLM)</Name>
+ </SetRegEntry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>CMSIS_AGDI</Key>
+ <Name>-X"Any" -UAny -O206 -S0 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0GD32F4xx_1MB.FLM -FS08000000 -FL0100000 -FP0($$Device:GD32F470ZG$Flash\GD32F4xx_1MB.FLM)</Name>
+ </SetRegEntry>
+ </TargetDriverDllRegistry>
+ <Breakpoint/>
+ <Tracepoint>
+ <THDelay>0</THDelay>
+ </Tracepoint>
+ <DebugFlag>
+ <trace>0</trace>
+ <periodic>0</periodic>
+ <aLwin>0</aLwin>
+ <aCover>0</aCover>
+ <aSer1>0</aSer1>
+ <aSer2>0</aSer2>
+ <aPa>0</aPa>
+ <viewmode>0</viewmode>
+ <vrSel>0</vrSel>
+ <aSym>0</aSym>
+ <aTbox>0</aTbox>
+ <AscS1>0</AscS1>
+ <AscS2>0</AscS2>
+ <AscS3>0</AscS3>
+ <aSer3>0</aSer3>
+ <eProf>0</eProf>
+ <aLa>0</aLa>
+ <aPa1>0</aPa1>
+ <AscS4>0</AscS4>
+ <aSer4>0</aSer4>
+ <StkLoc>0</StkLoc>
+ <TrcWin>0</TrcWin>
+ <newCpu>0</newCpu>
+ <uProt>0</uProt>
+ </DebugFlag>
+ <LintExecutable></LintExecutable>
+ <LintConfigFile></LintConfigFile>
+ <bLintAuto>0</bLintAuto>
+ <bAutoGenD>0</bAutoGenD>
+ <LntExFlags>0</LntExFlags>
+ <pMisraName></pMisraName>
+ <pszMrule></pszMrule>
+ <pSingCmds></pSingCmds>
+ <pMultCmds></pMultCmds>
+ <pMisraNamep></pMisraNamep>
+ <pszMrulep></pszMrulep>
+ <pSingCmdsp></pSingCmdsp>
+ <pMultCmdsp></pMultCmdsp>
+ </TargetOption>
+ </Target>
+
+ <Group>
+ <GroupName>Applications</GroupName>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <RteFlg>0</RteFlg>
+ <File>
+ <GroupNumber>1</GroupNumber>
+ <FileNumber>1</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>applications\main.c</PathWithFileName>
+ <FilenameWithoutPath>main.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>Compiler</GroupName>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <RteFlg>0</RteFlg>
+ <File>
+ <GroupNumber>2</GroupNumber>
+ <FileNumber>2</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\libc\compilers\armlibc\syscall_mem.c</PathWithFileName>
+ <FilenameWithoutPath>syscall_mem.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>2</GroupNumber>
+ <FileNumber>3</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\libc\compilers\armlibc\syscalls.c</PathWithFileName>
+ <FilenameWithoutPath>syscalls.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>2</GroupNumber>
+ <FileNumber>4</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\libc\compilers\common\cctype.c</PathWithFileName>
+ <FilenameWithoutPath>cctype.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>2</GroupNumber>
+ <FileNumber>5</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\libc\compilers\common\cstdio.c</PathWithFileName>
+ <FilenameWithoutPath>cstdio.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>2</GroupNumber>
+ <FileNumber>6</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\libc\compilers\common\cstdlib.c</PathWithFileName>
+ <FilenameWithoutPath>cstdlib.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>2</GroupNumber>
+ <FileNumber>7</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\libc\compilers\common\cstring.c</PathWithFileName>
+ <FilenameWithoutPath>cstring.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>2</GroupNumber>
+ <FileNumber>8</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\libc\compilers\common\ctime.c</PathWithFileName>
+ <FilenameWithoutPath>ctime.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>2</GroupNumber>
+ <FileNumber>9</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\libc\compilers\common\cwchar.c</PathWithFileName>
+ <FilenameWithoutPath>cwchar.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>CPU</GroupName>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <RteFlg>0</RteFlg>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>10</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\libcpu\arm\common\div0.c</PathWithFileName>
+ <FilenameWithoutPath>div0.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>11</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\libcpu\arm\common\showmem.c</PathWithFileName>
+ <FilenameWithoutPath>showmem.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>12</FileNumber>
+ <FileType>2</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\libcpu\arm\cortex-m4\context_rvds.S</PathWithFileName>
+ <FilenameWithoutPath>context_rvds.S</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>13</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\libcpu\arm\cortex-m4\cpuport.c</PathWithFileName>
+ <FilenameWithoutPath>cpuport.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>DeviceDrivers</GroupName>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <RteFlg>0</RteFlg>
+ <File>
+ <GroupNumber>4</GroupNumber>
+ <FileNumber>14</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\drivers\ipc\completion.c</PathWithFileName>
+ <FilenameWithoutPath>completion.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>4</GroupNumber>
+ <FileNumber>15</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\drivers\ipc\dataqueue.c</PathWithFileName>
+ <FilenameWithoutPath>dataqueue.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>4</GroupNumber>
+ <FileNumber>16</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\drivers\ipc\pipe.c</PathWithFileName>
+ <FilenameWithoutPath>pipe.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>4</GroupNumber>
+ <FileNumber>17</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\drivers\ipc\ringblk_buf.c</PathWithFileName>
+ <FilenameWithoutPath>ringblk_buf.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>4</GroupNumber>
+ <FileNumber>18</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\drivers\ipc\ringbuffer.c</PathWithFileName>
+ <FilenameWithoutPath>ringbuffer.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>4</GroupNumber>
+ <FileNumber>19</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\drivers\ipc\waitqueue.c</PathWithFileName>
+ <FilenameWithoutPath>waitqueue.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>4</GroupNumber>
+ <FileNumber>20</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\drivers\ipc\workqueue.c</PathWithFileName>
+ <FilenameWithoutPath>workqueue.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>4</GroupNumber>
+ <FileNumber>21</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\drivers\misc\pin.c</PathWithFileName>
+ <FilenameWithoutPath>pin.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>4</GroupNumber>
+ <FileNumber>22</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\drivers\serial\serial.c</PathWithFileName>
+ <FilenameWithoutPath>serial.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>Drivers</GroupName>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <RteFlg>0</RteFlg>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>23</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>board\board.c</PathWithFileName>
+ <FilenameWithoutPath>board.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>24</FileNumber>
+ <FileType>2</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\libraries\GD32F4xx_Firmware_Library\CMSIS\GD\GD32F4xx\Source\ARM\startup_gd32f4xx.s</PathWithFileName>
+ <FilenameWithoutPath>startup_gd32f4xx.s</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>25</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\libraries\gd32_drivers\drv_gpio.c</PathWithFileName>
+ <FilenameWithoutPath>drv_gpio.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>26</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\libraries\gd32_drivers\drv_usart.c</PathWithFileName>
+ <FilenameWithoutPath>drv_usart.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>Filesystem</GroupName>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <RteFlg>0</RteFlg>
+ <File>
+ <GroupNumber>6</GroupNumber>
+ <FileNumber>27</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\dfs\src\dfs_posix.c</PathWithFileName>
+ <FilenameWithoutPath>dfs_posix.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>6</GroupNumber>
+ <FileNumber>28</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\dfs\src\dfs_fs.c</PathWithFileName>
+ <FilenameWithoutPath>dfs_fs.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>6</GroupNumber>
+ <FileNumber>29</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\dfs\src\dfs.c</PathWithFileName>
+ <FilenameWithoutPath>dfs.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>6</GroupNumber>
+ <FileNumber>30</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\dfs\src\dfs_file.c</PathWithFileName>
+ <FilenameWithoutPath>dfs_file.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>Finsh</GroupName>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <RteFlg>0</RteFlg>
+ <File>
+ <GroupNumber>7</GroupNumber>
+ <FileNumber>31</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\finsh\shell.c</PathWithFileName>
+ <FilenameWithoutPath>shell.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>7</GroupNumber>
+ <FileNumber>32</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\finsh\msh.c</PathWithFileName>
+ <FilenameWithoutPath>msh.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>7</GroupNumber>
+ <FileNumber>33</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\finsh\msh_parse.c</PathWithFileName>
+ <FilenameWithoutPath>msh_parse.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>7</GroupNumber>
+ <FileNumber>34</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\finsh\cmd.c</PathWithFileName>
+ <FilenameWithoutPath>cmd.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>7</GroupNumber>
+ <FileNumber>35</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\components\finsh\msh_file.c</PathWithFileName>
+ <FilenameWithoutPath>msh_file.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>Kernel</GroupName>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <RteFlg>0</RteFlg>
+ <File>
+ <GroupNumber>8</GroupNumber>
+ <FileNumber>36</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\src\clock.c</PathWithFileName>
+ <FilenameWithoutPath>clock.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>8</GroupNumber>
+ <FileNumber>37</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\src\components.c</PathWithFileName>
+ <FilenameWithoutPath>components.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>8</GroupNumber>
+ <FileNumber>38</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\src\device.c</PathWithFileName>
+ <FilenameWithoutPath>device.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>8</GroupNumber>
+ <FileNumber>39</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\src\idle.c</PathWithFileName>
+ <FilenameWithoutPath>idle.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>8</GroupNumber>
+ <FileNumber>40</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\src\ipc.c</PathWithFileName>
+ <FilenameWithoutPath>ipc.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>8</GroupNumber>
+ <FileNumber>41</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\src\irq.c</PathWithFileName>
+ <FilenameWithoutPath>irq.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>8</GroupNumber>
+ <FileNumber>42</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\src\kservice.c</PathWithFileName>
+ <FilenameWithoutPath>kservice.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>8</GroupNumber>
+ <FileNumber>43</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\src\mem.c</PathWithFileName>
+ <FilenameWithoutPath>mem.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>8</GroupNumber>
+ <FileNumber>44</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\src\mempool.c</PathWithFileName>
+ <FilenameWithoutPath>mempool.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>8</GroupNumber>
+ <FileNumber>45</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\src\object.c</PathWithFileName>
+ <FilenameWithoutPath>object.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>8</GroupNumber>
+ <FileNumber>46</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\src\scheduler.c</PathWithFileName>
+ <FilenameWithoutPath>scheduler.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>8</GroupNumber>
+ <FileNumber>47</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\src\thread.c</PathWithFileName>
+ <FilenameWithoutPath>thread.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>8</GroupNumber>
+ <FileNumber>48</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\..\..\src\timer.c</PathWithFileName>
+ <FilenameWithoutPath>timer.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>Libraries</GroupName>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <RteFlg>0</RteFlg>
+ <File>
+ <GroupNumber>9</GroupNumber>
+ <FileNumber>49</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_syscfg.c</PathWithFileName>
+ <FilenameWithoutPath>gd32f4xx_syscfg.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>9</GroupNumber>
+ <FileNumber>50</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_exti.c</PathWithFileName>
+ <FilenameWithoutPath>gd32f4xx_exti.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>9</GroupNumber>
+ <FileNumber>51</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_gpio.c</PathWithFileName>
+ <FilenameWithoutPath>gd32f4xx_gpio.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>9</GroupNumber>
+ <FileNumber>52</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_rcu.c</PathWithFileName>
+ <FilenameWithoutPath>gd32f4xx_rcu.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>9</GroupNumber>
+ <FileNumber>53</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_misc.c</PathWithFileName>
+ <FilenameWithoutPath>gd32f4xx_misc.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>9</GroupNumber>
+ <FileNumber>54</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_usart.c</PathWithFileName>
+ <FilenameWithoutPath>gd32f4xx_usart.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ <File>
+ <GroupNumber>9</GroupNumber>
+ <FileNumber>55</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\libraries\GD32F4xx_Firmware_Library\CMSIS\GD\GD32F4xx\Source\system_gd32f4xx.c</PathWithFileName>
+ <FilenameWithoutPath>system_gd32f4xx.c</FilenameWithoutPath>
+ <RteFlg>0</RteFlg>
+ <bShared>0</bShared>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>::CMSIS</GroupName>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <RteFlg>1</RteFlg>
+ </Group>
+
+</ProjectOpt>
diff --git a/bsp/gd32/arm/gd32470z-lckfb/project.uvproj b/bsp/gd32/arm/gd32470z-lckfb/project.uvproj
new file mode 100644
index 0000000000..c114f67f78
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/project.uvproj
@@ -0,0 +1,838 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_proj.xsd">
+ <SchemaVersion>1.1</SchemaVersion>
+ <Header>### uVision Project, (C) Keil Software</Header>
+ <Targets>
+ <Target>
+ <TargetName>rt-thread</TargetName>
+ <ToolsetNumber>0x4</ToolsetNumber>
+ <ToolsetName>ARM-ADS</ToolsetName>
+ <uAC6>0</uAC6>
+ <TargetOption>
+ <TargetCommonOption>
+ <Device>GD32F450ZK</Device>
+ <Vendor>GigaDevice</Vendor>
+ <Cpu>IRAM(0x20000000-0x20030000) IRAM2(0x10000000-0x10010000) IROM(0x08000000-0x08300000) CLOCK(25000000) CPUTYPE("Cortex-M4") FPU2</Cpu>
+ <FlashUtilSpec />
+ <StartupFile>"Startup\GD\GD32F4xx\startup_gd32f4xx.s" ("GD32F4xx Startup Code")</StartupFile>
+ <FlashDriverDll>UL2CM3(-O207 -S0 -C0 -FO7 -FD20000000 -FC800 -FN1 -FF0GD32F4xx_3MB -FS08000000 -FL0300000)</FlashDriverDll>
+ <DeviceId>0</DeviceId>
+ <RegisterFile>gd32f4xx0.h</RegisterFile>
+ <MemoryEnv />
+ <Cmp />
+ <Asm />
+ <Linker />
+ <OHString />
+ <InfinionOptionDll />
+ <SLE66CMisc />
+ <SLE66AMisc />
+ <SLE66LinkerMisc />
+ <SFDFile>SFD\GD\GD32F4xx\GD32F4xx.SFR</SFDFile>
+ <bCustSvd>0</bCustSvd>
+ <UseEnv>0</UseEnv>
+ <BinPath />
+ <IncludePath />
+ <LibPath />
+ <RegisterFilePath>GD\GD32F4xx\</RegisterFilePath>
+ <DBRegisterFilePath>GD\GD32F4xx\</DBRegisterFilePath>
+ <TargetStatus>
+ <Error>0</Error>
+ <ExitCodeStop>0</ExitCodeStop>
+ <ButtonStop>0</ButtonStop>
+ <NotGenerated>0</NotGenerated>
+ <InvalidFlash>1</InvalidFlash>
+ </TargetStatus>
+ <OutputDirectory>.\output\</OutputDirectory>
+ <OutputName>rtthread</OutputName>
+ <CreateExecutable>1</CreateExecutable>
+ <CreateLib>0</CreateLib>
+ <CreateHexFile>1</CreateHexFile>
+ <DebugInformation>1</DebugInformation>
+ <BrowseInformation>1</BrowseInformation>
+ <ListingPath>.\build\</ListingPath>
+ <HexFormatSelection>1</HexFormatSelection>
+ <Merge32K>0</Merge32K>
+ <CreateBatchFile>0</CreateBatchFile>
+ <BeforeCompile>
+ <RunUserProg1>0</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name />
+ <UserProg2Name />
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ <nStopU1X>0</nStopU1X>
+ <nStopU2X>0</nStopU2X>
+ </BeforeCompile>
+ <BeforeMake>
+ <RunUserProg1>0</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name />
+ <UserProg2Name />
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ <nStopB1X>0</nStopB1X>
+ <nStopB2X>0</nStopB2X>
+ </BeforeMake>
+ <AfterMake>
+ <RunUserProg1>0</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name />
+ <UserProg2Name />
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ <nStopA1X>0</nStopA1X>
+ <nStopA2X>0</nStopA2X>
+ </AfterMake>
+ <SelectedForBatchBuild>0</SelectedForBatchBuild>
+ <SVCSIdString />
+ </TargetCommonOption>
+ <CommonProperty>
+ <UseCPPCompiler>0</UseCPPCompiler>
+ <RVCTCodeConst>0</RVCTCodeConst>
+ <RVCTZI>0</RVCTZI>
+ <RVCTOtherData>0</RVCTOtherData>
+ <ModuleSelection>0</ModuleSelection>
+ <IncludeInBuild>1</IncludeInBuild>
+ <AlwaysBuild>0</AlwaysBuild>
+ <GenerateAssemblyFile>0</GenerateAssemblyFile>
+ <AssembleAssemblyFile>0</AssembleAssemblyFile>
+ <PublicsOnly>0</PublicsOnly>
+ <StopOnExitCode>3</StopOnExitCode>
+ <CustomArgument />
+ <IncludeLibraryModules />
+ <ComprImg>1</ComprImg>
+ </CommonProperty>
+ <DllOption>
+ <SimDllName>SARMCM3.DLL</SimDllName>
+ <SimDllArguments> -REMAP</SimDllArguments>
+ <SimDlgDll>DCM.DLL</SimDlgDll>
+ <SimDlgDllArguments>-pCM3</SimDlgDllArguments>
+ <TargetDllName>SARMCM3.DLL</TargetDllName>
+ <TargetDllArguments />
+ <TargetDlgDll>TCM.DLL</TargetDlgDll>
+ <TargetDlgDllArguments>-pCM3</TargetDlgDllArguments>
+ </DllOption>
+ <DebugOption>
+ <OPTHX>
+ <HexSelection>1</HexSelection>
+ <HexRangeLowAddress>0</HexRangeLowAddress>
+ <HexRangeHighAddress>0</HexRangeHighAddress>
+ <HexOffset>0</HexOffset>
+ <Oh166RecLen>16</Oh166RecLen>
+ </OPTHX>
+ <Simulator>
+ <UseSimulator>0</UseSimulator>
+ <LoadApplicationAtStartup>1</LoadApplicationAtStartup>
+ <RunToMain>1</RunToMain>
+ <RestoreBreakpoints>1</RestoreBreakpoints>
+ <RestoreWatchpoints>1</RestoreWatchpoints>
+ <RestoreMemoryDisplay>1</RestoreMemoryDisplay>
+ <RestoreFunctions>1</RestoreFunctions>
+ <RestoreToolbox>1</RestoreToolbox>
+ <LimitSpeedToRealTime>0</LimitSpeedToRealTime>
+ <RestoreSysVw>1</RestoreSysVw>
+ </Simulator>
+ <Target>
+ <UseTarget>1</UseTarget>
+ <LoadApplicationAtStartup>1</LoadApplicationAtStartup>
+ <RunToMain>1</RunToMain>
+ <RestoreBreakpoints>1</RestoreBreakpoints>
+ <RestoreWatchpoints>1</RestoreWatchpoints>
+ <RestoreMemoryDisplay>1</RestoreMemoryDisplay>
+ <RestoreFunctions>0</RestoreFunctions>
+ <RestoreToolbox>1</RestoreToolbox>
+ <RestoreTracepoints>0</RestoreTracepoints>
+ <RestoreSysVw>1</RestoreSysVw>
+ </Target>
+ <RunDebugAfterBuild>0</RunDebugAfterBuild>
+ <TargetSelection>3</TargetSelection>
+ <SimDlls>
+ <CpuDll />
+ <CpuDllArguments />
+ <PeripheralDll />
+ <PeripheralDllArguments />
+ <InitializationFile />
+ </SimDlls>
+ <TargetDlls>
+ <CpuDll />
+ <CpuDllArguments />
+ <PeripheralDll />
+ <PeripheralDllArguments />
+ <InitializationFile />
+ <Driver>BIN\CMSIS_AGDI.dll</Driver>
+ </TargetDlls>
+ </DebugOption>
+ <Utilities>
+ <Flash1>
+ <UseTargetDll>1</UseTargetDll>
+ <UseExternalTool>0</UseExternalTool>
+ <RunIndependent>0</RunIndependent>
+ <UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
+ <Capability>1</Capability>
+ <DriverSelection>4096</DriverSelection>
+ </Flash1>
+ <bUseTDR>1</bUseTDR>
+ <Flash2>BIN\UL2CM3.DLL</Flash2>
+ <Flash3>"" ()</Flash3>
+ <Flash4 />
+ <pFcarmOut />
+ <pFcarmGrp />
+ <pFcArmRoot />
+ <FcArmLst>0</FcArmLst>
+ </Utilities>
+ <TargetArmAds>
+ <ArmAdsMisc>
+ <GenerateListings>0</GenerateListings>
+ <asHll>1</asHll>
+ <asAsm>1</asAsm>
+ <asMacX>1</asMacX>
+ <asSyms>1</asSyms>
+ <asFals>1</asFals>
+ <asDbgD>1</asDbgD>
+ <asForm>1</asForm>
+ <ldLst>0</ldLst>
+ <ldmm>1</ldmm>
+ <ldXref>1</ldXref>
+ <BigEnd>0</BigEnd>
+ <AdsALst>1</AdsALst>
+ <AdsACrf>1</AdsACrf>
+ <AdsANop>0</AdsANop>
+ <AdsANot>0</AdsANot>
+ <AdsLLst>1</AdsLLst>
+ <AdsLmap>1</AdsLmap>
+ <AdsLcgr>1</AdsLcgr>
+ <AdsLsym>1</AdsLsym>
+ <AdsLszi>1</AdsLszi>
+ <AdsLtoi>1</AdsLtoi>
+ <AdsLsun>1</AdsLsun>
+ <AdsLven>1</AdsLven>
+ <AdsLsxf>1</AdsLsxf>
+ <RvctClst>0</RvctClst>
+ <GenPPlst>0</GenPPlst>
+ <AdsCpuType>"Cortex-M4"</AdsCpuType>
+ <RvctDeviceName />
+ <mOS>0</mOS>
+ <uocRom>0</uocRom>
+ <uocRam>0</uocRam>
+ <hadIROM>1</hadIROM>
+ <hadIRAM>1</hadIRAM>
+ <hadXRAM>0</hadXRAM>
+ <uocXRam>0</uocXRam>
+ <RvdsVP>2</RvdsVP>
+ <hadIRAM2>1</hadIRAM2>
+ <hadIROM2>0</hadIROM2>
+ <StupSel>8</StupSel>
+ <useUlib>1</useUlib>
+ <EndSel>0</EndSel>
+ <uLtcg>0</uLtcg>
+ <nSecure>0</nSecure>
+ <RoSelD>3</RoSelD>
+ <RwSelD>3</RwSelD>
+ <CodeSel>0</CodeSel>
+ <OptFeed>0</OptFeed>
+ <NoZi1>0</NoZi1>
+ <NoZi2>0</NoZi2>
+ <NoZi3>0</NoZi3>
+ <NoZi4>0</NoZi4>
+ <NoZi5>0</NoZi5>
+ <Ro1Chk>0</Ro1Chk>
+ <Ro2Chk>0</Ro2Chk>
+ <Ro3Chk>0</Ro3Chk>
+ <Ir1Chk>1</Ir1Chk>
+ <Ir2Chk>0</Ir2Chk>
+ <Ra1Chk>0</Ra1Chk>
+ <Ra2Chk>0</Ra2Chk>
+ <Ra3Chk>0</Ra3Chk>
+ <Im1Chk>1</Im1Chk>
+ <Im2Chk>0</Im2Chk>
+ <OnChipMemories>
+ <Ocm1>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm1>
+ <Ocm2>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm2>
+ <Ocm3>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm3>
+ <Ocm4>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm4>
+ <Ocm5>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm5>
+ <Ocm6>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm6>
+ <IRAM>
+ <Type>0</Type>
+ <StartAddress>0x20000000</StartAddress>
+ <Size>0x30000</Size>
+ </IRAM>
+ <IROM>
+ <Type>1</Type>
+ <StartAddress>0x8000000</StartAddress>
+ <Size>0x300000</Size>
+ </IROM>
+ <XRAM>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </XRAM>
+ <OCR_RVCT1>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT1>
+ <OCR_RVCT2>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT2>
+ <OCR_RVCT3>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT3>
+ <OCR_RVCT4>
+ <Type>1</Type>
+ <StartAddress>0x8000000</StartAddress>
+ <Size>0x300000</Size>
+ </OCR_RVCT4>
+ <OCR_RVCT5>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT5>
+ <OCR_RVCT6>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT6>
+ <OCR_RVCT7>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT7>
+ <OCR_RVCT8>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT8>
+ <OCR_RVCT9>
+ <Type>0</Type>
+ <StartAddress>0x20000000</StartAddress>
+ <Size>0x30000</Size>
+ </OCR_RVCT9>
+ <OCR_RVCT10>
+ <Type>0</Type>
+ <StartAddress>0x10000000</StartAddress>
+ <Size>0x10000</Size>
+ </OCR_RVCT10>
+ </OnChipMemories>
+ <RvctStartVector />
+ </ArmAdsMisc>
+ <Cads>
+ <interw>1</interw>
+ <Optim>1</Optim>
+ <oTime>0</oTime>
+ <SplitLS>0</SplitLS>
+ <OneElfS>1</OneElfS>
+ <Strict>0</Strict>
+ <EnumInt>0</EnumInt>
+ <PlainCh>0</PlainCh>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <wLevel>2</wLevel>
+ <uThumb>0</uThumb>
+ <uSurpInc>0</uSurpInc>
+ <uC99>1</uC99>
+ <uGnu>0</uGnu>
+ <useXO>0</useXO>
+ <v6Lang>1</v6Lang>
+ <v6LangP>1</v6LangP>
+ <vShortEn>1</vShortEn>
+ <vShortWch>1</vShortWch>
+ <v6Lto>0</v6Lto>
+ <v6WtE>0</v6WtE>
+ <v6Rtti>0</v6Rtti>
+ <VariousControls>
+ <MiscControls />
+ <Define>__STDC_LIMIT_MACROS, USE_STDPERIPH_DRIVER, RT_USING_LIBC, __CLK_TCK=RT_TICK_PER_SECOND, GD32F450, __RTTHREAD__, RT_USING_ARM_LIBC</Define>
+ <Undefine />
+ <IncludePath>applications;.;..\..\..\..\components\libc\compilers\common\include;..\..\..\..\components\libc\compilers\common\extension;..\..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\..\libcpu\arm\common;..\..\..\..\libcpu\arm\cortex-m4;..\..\..\..\components\drivers\include;..\..\..\..\components\drivers\include;..\..\..\..\components\drivers\include;board;..\libraries\gd32_drivers;..\..\..\..\components\dfs\include;..\..\..\..\components\finsh;.;..\..\..\..\include;..\libraries\GD32F4xx_Firmware_Library\CMSIS\GD\GD32F4xx\Include;..\libraries\GD32F4xx_Firmware_Library\CMSIS;..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Include;..\..\..\..\components\libc\posix\io\poll;..\..\..\..\components\libc\posix\io\stdio;..\..\..\..\components\libc\posix\ipc</IncludePath>
+ </VariousControls>
+ </Cads>
+ <Aads>
+ <interw>1</interw>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <thumb>0</thumb>
+ <SplitLS>0</SplitLS>
+ <SwStkChk>0</SwStkChk>
+ <NoWarn>0</NoWarn>
+ <uSurpInc>0</uSurpInc>
+ <useXO>0</useXO>
+ <uClangAs>0</uClangAs>
+ <VariousControls>
+ <MiscControls />
+ <Define />
+ <Undefine />
+ <IncludePath />
+ </VariousControls>
+ </Aads>
+ <LDads>
+ <umfTarg>1</umfTarg>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <noStLib>0</noStLib>
+ <RepFail>1</RepFail>
+ <useFile>0</useFile>
+ <TextAddressRange>0x08000000</TextAddressRange>
+ <DataAddressRange>0x20000000</DataAddressRange>
+ <pXoBase />
+ <ScatterFile />
+ <IncludeLibs />
+ <IncludeLibsPath />
+ <Misc />
+ <LinkerInputFile />
+ <DisabledWarnings />
+ </LDads>
+ </TargetArmAds>
+ </TargetOption>
+ <Groups>
+ <Group>
+ <GroupName>Applications</GroupName>
+ <Files>
+ <File>
+ <FileName>main.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>applications\main.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>Compiler</GroupName>
+ <Files>
+ <File>
+ <FileName>syscall_mem.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\armlibc\syscall_mem.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>syscalls.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\armlibc\syscalls.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>cctype.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\common\cctype.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>cstdio.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\common\cstdio.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>cstdlib.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\common\cstdlib.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>cstring.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\common\cstring.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>ctime.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\common\ctime.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>cwchar.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\common\cwchar.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>CPU</GroupName>
+ <Files>
+ <File>
+ <FileName>backtrace.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\libcpu\arm\common\backtrace.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>div0.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\libcpu\arm\common\div0.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>showmem.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\libcpu\arm\common\showmem.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>context_rvds.S</FileName>
+ <FileType>2</FileType>
+ <FilePath>..\..\..\..\libcpu\arm\cortex-m4\context_rvds.S</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>cpuport.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\libcpu\arm\cortex-m4\cpuport.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>DeviceDrivers</GroupName>
+ <Files>
+ <File>
+ <FileName>completion.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\ipc\completion.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>dataqueue.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\ipc\dataqueue.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>pipe.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\ipc\pipe.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>ringblk_buf.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\ipc\ringblk_buf.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>ringbuffer.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\ipc\ringbuffer.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>waitqueue.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\ipc\waitqueue.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>workqueue.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\ipc\workqueue.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>pin.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\misc\pin.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>serial.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\serial\serial.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>Drivers</GroupName>
+ <Files>
+ <File>
+ <FileName>board.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>board\board.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>startup_gd32f4xx.s</FileName>
+ <FileType>2</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\CMSIS\GD\GD32F4xx\Source\ARM\startup_gd32f4xx.s</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>drv_gpio.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\gd32_drivers\drv_gpio.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>drv_usart.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\gd32_drivers\drv_usart.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>Filesystem</GroupName>
+ <Files>
+ <File>
+ <FileName>dfs_posix.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\dfs\src\dfs_posix.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>dfs_fs.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\dfs\src\dfs_fs.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>dfs.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\dfs\src\dfs.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>dfs_file.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\dfs\src\dfs_file.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>Finsh</GroupName>
+ <Files>
+ <File>
+ <FileName>shell.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\finsh\shell.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>msh.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\finsh\msh.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>msh_parse.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\finsh\msh_parse.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>cmd.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\finsh\cmd.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>msh_file.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\finsh\msh_file.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>Kernel</GroupName>
+ <Files>
+ <File>
+ <FileName>clock.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\clock.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>components.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\components.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>device.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\device.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>idle.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\idle.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>ipc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\ipc.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>irq.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\irq.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>kservice.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\kservice.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>mem.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\mem.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>mempool.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\mempool.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>object.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\object.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>scheduler.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\scheduler.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>thread.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\thread.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>timer.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\timer.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>Libraries</GroupName>
+ <Files>
+ <File>
+ <FileName>gd32f4xx_syscfg.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_syscfg.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>gd32f4xx_exti.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_exti.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>gd32f4xx_gpio.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_gpio.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>gd32f4xx_rcu.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_rcu.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>gd32f4xx_misc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_misc.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>gd32f4xx_usart.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_usart.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
+ <FileName>system_gd32f4xx.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\CMSIS\GD\GD32F4xx\Source\system_gd32f4xx.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ </Groups>
+ </Target>
+ </Targets>
+</Project>
diff --git a/bsp/gd32/arm/gd32470z-lckfb/project.uvprojx b/bsp/gd32/arm/gd32470z-lckfb/project.uvprojx
new file mode 100644
index 0000000000..c76740ed61
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/project.uvprojx
@@ -0,0 +1,732 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
+
+ <SchemaVersion>2.1</SchemaVersion>
+
+ <Header>### uVision Project, (C) Keil Software</Header>
+
+ <Targets>
+ <Target>
+ <TargetName>rt-thread</TargetName>
+ <ToolsetNumber>0x4</ToolsetNumber>
+ <ToolsetName>ARM-ADS</ToolsetName>
+ <uAC6>0</uAC6>
+ <TargetOption>
+ <TargetCommonOption>
+ <Device>GD32F470ZG</Device>
+ <Vendor>GigaDevice</Vendor>
+ <PackID>GigaDevice.GD32F4xx_DFP.3.0.0</PackID>
+ <PackURL>http://gd32mcu.com/data/documents/pack/</PackURL>
+ <Cpu>IRAM(0x20000000,0x070000) IRAM2(0x10000000,0x010000) IROM(0x08000000,0x0100000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
+ <FlashUtilSpec></FlashUtilSpec>
+ <StartupFile></StartupFile>
+ <FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0GD32F4xx_1MB -FS08000000 -FL0100000 -FP0($$Device:GD32F470ZG$Flash\GD32F4xx_1MB.FLM))</FlashDriverDll>
+ <DeviceId>0</DeviceId>
+ <RegisterFile>$$Device:GD32F470ZG$Device\F4XX\Include\gd32f4xx.h</RegisterFile>
+ <MemoryEnv></MemoryEnv>
+ <Cmp></Cmp>
+ <Asm></Asm>
+ <Linker></Linker>
+ <OHString></OHString>
+ <InfinionOptionDll></InfinionOptionDll>
+ <SLE66CMisc></SLE66CMisc>
+ <SLE66AMisc></SLE66AMisc>
+ <SLE66LinkerMisc></SLE66LinkerMisc>
+ <SFDFile>$$Device:GD32F470ZG$SVD\GD32F4xx.svd</SFDFile>
+ <bCustSvd>0</bCustSvd>
+ <UseEnv>0</UseEnv>
+ <BinPath></BinPath>
+ <IncludePath></IncludePath>
+ <LibPath></LibPath>
+ <RegisterFilePath></RegisterFilePath>
+ <DBRegisterFilePath></DBRegisterFilePath>
+ <TargetStatus>
+ <Error>0</Error>
+ <ExitCodeStop>0</ExitCodeStop>
+ <ButtonStop>0</ButtonStop>
+ <NotGenerated>0</NotGenerated>
+ <InvalidFlash>1</InvalidFlash>
+ </TargetStatus>
+ <OutputDirectory>.\build\</OutputDirectory>
+ <OutputName>rtthread</OutputName>
+ <CreateExecutable>1</CreateExecutable>
+ <CreateLib>0</CreateLib>
+ <CreateHexFile>0</CreateHexFile>
+ <DebugInformation>1</DebugInformation>
+ <BrowseInformation>0</BrowseInformation>
+ <ListingPath>.\build\</ListingPath>
+ <HexFormatSelection>1</HexFormatSelection>
+ <Merge32K>0</Merge32K>
+ <CreateBatchFile>0</CreateBatchFile>
+ <BeforeCompile>
+ <RunUserProg1>0</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name></UserProg1Name>
+ <UserProg2Name></UserProg2Name>
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ <nStopU1X>0</nStopU1X>
+ <nStopU2X>0</nStopU2X>
+ </BeforeCompile>
+ <BeforeMake>
+ <RunUserProg1>0</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name></UserProg1Name>
+ <UserProg2Name></UserProg2Name>
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ <nStopB1X>0</nStopB1X>
+ <nStopB2X>0</nStopB2X>
+ </BeforeMake>
+ <AfterMake>
+ <RunUserProg1>1</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name>fromelf --bin !L --output rtthread.bin</UserProg1Name>
+ <UserProg2Name></UserProg2Name>
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ <nStopA1X>0</nStopA1X>
+ <nStopA2X>0</nStopA2X>
+ </AfterMake>
+ <SelectedForBatchBuild>0</SelectedForBatchBuild>
+ <SVCSIdString></SVCSIdString>
+ </TargetCommonOption>
+ <CommonProperty>
+ <UseCPPCompiler>0</UseCPPCompiler>
+ <RVCTCodeConst>0</RVCTCodeConst>
+ <RVCTZI>0</RVCTZI>
+ <RVCTOtherData>0</RVCTOtherData>
+ <ModuleSelection>0</ModuleSelection>
+ <IncludeInBuild>1</IncludeInBuild>
+ <AlwaysBuild>0</AlwaysBuild>
+ <GenerateAssemblyFile>0</GenerateAssemblyFile>
+ <AssembleAssemblyFile>0</AssembleAssemblyFile>
+ <PublicsOnly>0</PublicsOnly>
+ <StopOnExitCode>3</StopOnExitCode>
+ <CustomArgument></CustomArgument>
+ <IncludeLibraryModules></IncludeLibraryModules>
+ <ComprImg>1</ComprImg>
+ </CommonProperty>
+ <DllOption>
+ <SimDllName>SARMCM3.DLL</SimDllName>
+ <SimDllArguments> -REMAP -MPU</SimDllArguments>
+ <SimDlgDll>DCM.DLL</SimDlgDll>
+ <SimDlgDllArguments>-pCM4</SimDlgDllArguments>
+ <TargetDllName>SARMCM3.DLL</TargetDllName>
+ <TargetDllArguments> -MPU</TargetDllArguments>
+ <TargetDlgDll>TCM.DLL</TargetDlgDll>
+ <TargetDlgDllArguments>-pCM4</TargetDlgDllArguments>
+ </DllOption>
+ <DebugOption>
+ <OPTHX>
+ <HexSelection>1</HexSelection>
+ <HexRangeLowAddress>0</HexRangeLowAddress>
+ <HexRangeHighAddress>0</HexRangeHighAddress>
+ <HexOffset>0</HexOffset>
+ <Oh166RecLen>16</Oh166RecLen>
+ </OPTHX>
+ </DebugOption>
+ <Utilities>
+ <Flash1>
+ <UseTargetDll>1</UseTargetDll>
+ <UseExternalTool>0</UseExternalTool>
+ <RunIndependent>0</RunIndependent>
+ <UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
+ <Capability>1</Capability>
+ <DriverSelection>4096</DriverSelection>
+ </Flash1>
+ <bUseTDR>1</bUseTDR>
+ <Flash2>BIN\UL2CM3.DLL</Flash2>
+ <Flash3></Flash3>
+ <Flash4></Flash4>
+ <pFcarmOut></pFcarmOut>
+ <pFcarmGrp></pFcarmGrp>
+ <pFcArmRoot></pFcArmRoot>
+ <FcArmLst>0</FcArmLst>
+ </Utilities>
+ <TargetArmAds>
+ <ArmAdsMisc>
+ <GenerateListings>0</GenerateListings>
+ <asHll>1</asHll>
+ <asAsm>1</asAsm>
+ <asMacX>1</asMacX>
+ <asSyms>1</asSyms>
+ <asFals>1</asFals>
+ <asDbgD>1</asDbgD>
+ <asForm>1</asForm>
+ <ldLst>0</ldLst>
+ <ldmm>1</ldmm>
+ <ldXref>1</ldXref>
+ <BigEnd>0</BigEnd>
+ <AdsALst>1</AdsALst>
+ <AdsACrf>1</AdsACrf>
+ <AdsANop>0</AdsANop>
+ <AdsANot>0</AdsANot>
+ <AdsLLst>1</AdsLLst>
+ <AdsLmap>1</AdsLmap>
+ <AdsLcgr>1</AdsLcgr>
+ <AdsLsym>1</AdsLsym>
+ <AdsLszi>1</AdsLszi>
+ <AdsLtoi>1</AdsLtoi>
+ <AdsLsun>1</AdsLsun>
+ <AdsLven>1</AdsLven>
+ <AdsLsxf>1</AdsLsxf>
+ <RvctClst>0</RvctClst>
+ <GenPPlst>0</GenPPlst>
+ <AdsCpuType>"Cortex-M4"</AdsCpuType>
+ <RvctDeviceName></RvctDeviceName>
+ <mOS>0</mOS>
+ <uocRom>0</uocRom>
+ <uocRam>0</uocRam>
+ <hadIROM>1</hadIROM>
+ <hadIRAM>1</hadIRAM>
+ <hadXRAM>0</hadXRAM>
+ <uocXRam>0</uocXRam>
+ <RvdsVP>2</RvdsVP>
+ <RvdsMve>0</RvdsMve>
+ <RvdsCdeCp>0</RvdsCdeCp>
+ <hadIRAM2>1</hadIRAM2>
+ <hadIROM2>0</hadIROM2>
+ <StupSel>8</StupSel>
+ <useUlib>0</useUlib>
+ <EndSel>0</EndSel>
+ <uLtcg>0</uLtcg>
+ <nSecure>0</nSecure>
+ <RoSelD>3</RoSelD>
+ <RwSelD>4</RwSelD>
+ <CodeSel>0</CodeSel>
+ <OptFeed>0</OptFeed>
+ <NoZi1>0</NoZi1>
+ <NoZi2>0</NoZi2>
+ <NoZi3>0</NoZi3>
+ <NoZi4>0</NoZi4>
+ <NoZi5>0</NoZi5>
+ <Ro1Chk>0</Ro1Chk>
+ <Ro2Chk>0</Ro2Chk>
+ <Ro3Chk>0</Ro3Chk>
+ <Ir1Chk>1</Ir1Chk>
+ <Ir2Chk>0</Ir2Chk>
+ <Ra1Chk>0</Ra1Chk>
+ <Ra2Chk>0</Ra2Chk>
+ <Ra3Chk>0</Ra3Chk>
+ <Im1Chk>1</Im1Chk>
+ <Im2Chk>0</Im2Chk>
+ <OnChipMemories>
+ <Ocm1>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm1>
+ <Ocm2>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm2>
+ <Ocm3>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm3>
+ <Ocm4>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm4>
+ <Ocm5>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm5>
+ <Ocm6>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm6>
+ <IRAM>
+ <Type>0</Type>
+ <StartAddress>0x20000000</StartAddress>
+ <Size>0x70000</Size>
+ </IRAM>
+ <IROM>
+ <Type>1</Type>
+ <StartAddress>0x8000000</StartAddress>
+ <Size>0x100000</Size>
+ </IROM>
+ <XRAM>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </XRAM>
+ <OCR_RVCT1>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT1>
+ <OCR_RVCT2>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT2>
+ <OCR_RVCT3>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT3>
+ <OCR_RVCT4>
+ <Type>1</Type>
+ <StartAddress>0x8000000</StartAddress>
+ <Size>0x100000</Size>
+ </OCR_RVCT4>
+ <OCR_RVCT5>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT5>
+ <OCR_RVCT6>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT6>
+ <OCR_RVCT7>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT7>
+ <OCR_RVCT8>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT8>
+ <OCR_RVCT9>
+ <Type>0</Type>
+ <StartAddress>0x20000000</StartAddress>
+ <Size>0x70000</Size>
+ </OCR_RVCT9>
+ <OCR_RVCT10>
+ <Type>0</Type>
+ <StartAddress>0x10000000</StartAddress>
+ <Size>0x10000</Size>
+ </OCR_RVCT10>
+ </OnChipMemories>
+ <RvctStartVector></RvctStartVector>
+ </ArmAdsMisc>
+ <Cads>
+ <interw>1</interw>
+ <Optim>4</Optim>
+ <oTime>0</oTime>
+ <SplitLS>0</SplitLS>
+ <OneElfS>1</OneElfS>
+ <Strict>0</Strict>
+ <EnumInt>0</EnumInt>
+ <PlainCh>0</PlainCh>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <wLevel>0</wLevel>
+ <uThumb>0</uThumb>
+ <uSurpInc>0</uSurpInc>
+ <uC99>1</uC99>
+ <uGnu>0</uGnu>
+ <useXO>0</useXO>
+ <v6Lang>1</v6Lang>
+ <v6LangP>1</v6LangP>
+ <vShortEn>1</vShortEn>
+ <vShortWch>1</vShortWch>
+ <v6Lto>0</v6Lto>
+ <v6WtE>0</v6WtE>
+ <v6Rtti>0</v6Rtti>
+ <VariousControls>
+ <MiscControls></MiscControls>
+ <Define>__STDC_LIMIT_MACROS, RT_USING_ARMLIBC, USE_STDPERIPH_DRIVER, GD32F470, RT_USING_LIBC, __CLK_TCK=RT_TICK_PER_SECOND, __RTTHREAD__</Define>
+ <Undefine></Undefine>
+ <IncludePath>..\..\..\..\components\drivers\include;..\..\..\..\components\dfs\include;..\..\..\..\components\drivers\include;..\..\..\..\components\libc\posix\io\stdio;..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Include;..\..\..\..\components\finsh;..\..\..\..\libcpu\arm\cortex-m4;..\..\..\..\components\libc\compilers\common\include;..\..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\libraries\gd32_drivers;board;..\..\..\..\libcpu\arm\common;..\libraries\GD32F4xx_Firmware_Library\CMSIS;applications;..\libraries\GD32F4xx_Firmware_Library\CMSIS\GD\GD32F4xx\Include;..\..\..\..\components\drivers\include;..\..\..\..\components\libc\compilers\common\extension;..\..\..\..\components\libc\posix\io\poll;..\..\..\..\include;.;..\..\..\..\components\libc\posix\ipc</IncludePath>
+ </VariousControls>
+ </Cads>
+ <Aads>
+ <interw>1</interw>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <thumb>0</thumb>
+ <SplitLS>0</SplitLS>
+ <SwStkChk>0</SwStkChk>
+ <NoWarn>0</NoWarn>
+ <uSurpInc>0</uSurpInc>
+ <useXO>0</useXO>
+ <ClangAsOpt>4</ClangAsOpt>
+ <VariousControls>
+ <MiscControls></MiscControls>
+ <Define></Define>
+ <Undefine></Undefine>
+ <IncludePath></IncludePath>
+ </VariousControls>
+ </Aads>
+ <LDads>
+ <umfTarg>1</umfTarg>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <noStLib>0</noStLib>
+ <RepFail>1</RepFail>
+ <useFile>0</useFile>
+ <TextAddressRange>0x08000000</TextAddressRange>
+ <DataAddressRange>0x20000000</DataAddressRange>
+ <pXoBase></pXoBase>
+ <ScatterFile>.\gd32_rom.ld</ScatterFile>
+ <IncludeLibs></IncludeLibs>
+ <IncludeLibsPath></IncludeLibsPath>
+ <Misc></Misc>
+ <LinkerInputFile></LinkerInputFile>
+ <DisabledWarnings></DisabledWarnings>
+ </LDads>
+ </TargetArmAds>
+ </TargetOption>
+ <Groups>
+ <Group>
+ <GroupName>Applications</GroupName>
+ <Files>
+ <File>
+ <FileName>main.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>applications\main.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>Compiler</GroupName>
+ <Files>
+ <File>
+ <FileName>syscall_mem.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\armlibc\syscall_mem.c</FilePath>
+ </File>
+ <File>
+ <FileName>syscalls.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\armlibc\syscalls.c</FilePath>
+ </File>
+ <File>
+ <FileName>cctype.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\common\cctype.c</FilePath>
+ </File>
+ <File>
+ <FileName>cstdio.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\common\cstdio.c</FilePath>
+ </File>
+ <File>
+ <FileName>cstdlib.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\common\cstdlib.c</FilePath>
+ </File>
+ <File>
+ <FileName>cstring.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\common\cstring.c</FilePath>
+ </File>
+ <File>
+ <FileName>ctime.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\common\ctime.c</FilePath>
+ </File>
+ <File>
+ <FileName>cwchar.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\libc\compilers\common\cwchar.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>CPU</GroupName>
+ <Files>
+ <File>
+ <FileName>div0.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\libcpu\arm\common\div0.c</FilePath>
+ </File>
+ <File>
+ <FileName>showmem.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\libcpu\arm\common\showmem.c</FilePath>
+ </File>
+ <File>
+ <FileName>context_rvds.S</FileName>
+ <FileType>2</FileType>
+ <FilePath>..\..\..\..\libcpu\arm\cortex-m4\context_rvds.S</FilePath>
+ </File>
+ <File>
+ <FileName>cpuport.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\libcpu\arm\cortex-m4\cpuport.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>DeviceDrivers</GroupName>
+ <Files>
+ <File>
+ <FileName>completion.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\ipc\completion.c</FilePath>
+ </File>
+ <File>
+ <FileName>dataqueue.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\ipc\dataqueue.c</FilePath>
+ </File>
+ <File>
+ <FileName>pipe.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\ipc\pipe.c</FilePath>
+ </File>
+ <File>
+ <FileName>ringblk_buf.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\ipc\ringblk_buf.c</FilePath>
+ </File>
+ <File>
+ <FileName>ringbuffer.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\ipc\ringbuffer.c</FilePath>
+ </File>
+ <File>
+ <FileName>waitqueue.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\ipc\waitqueue.c</FilePath>
+ </File>
+ <File>
+ <FileName>workqueue.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\ipc\workqueue.c</FilePath>
+ </File>
+ <File>
+ <FileName>pin.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\misc\pin.c</FilePath>
+ </File>
+ <File>
+ <FileName>serial.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\drivers\serial\serial.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>Drivers</GroupName>
+ <Files>
+ <File>
+ <FileName>board.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>board\board.c</FilePath>
+ </File>
+ <File>
+ <FileName>startup_gd32f4xx.s</FileName>
+ <FileType>2</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\CMSIS\GD\GD32F4xx\Source\ARM\startup_gd32f4xx.s</FilePath>
+ </File>
+ <File>
+ <FileName>drv_gpio.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\gd32_drivers\drv_gpio.c</FilePath>
+ </File>
+ <File>
+ <FileName>drv_usart.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\gd32_drivers\drv_usart.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>Filesystem</GroupName>
+ <Files>
+ <File>
+ <FileName>dfs_posix.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\dfs\src\dfs_posix.c</FilePath>
+ </File>
+ <File>
+ <FileName>dfs_fs.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\dfs\src\dfs_fs.c</FilePath>
+ </File>
+ <File>
+ <FileName>dfs.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\dfs\src\dfs.c</FilePath>
+ </File>
+ <File>
+ <FileName>dfs_file.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\dfs\src\dfs_file.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>Finsh</GroupName>
+ <Files>
+ <File>
+ <FileName>shell.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\finsh\shell.c</FilePath>
+ </File>
+ <File>
+ <FileName>msh.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\finsh\msh.c</FilePath>
+ </File>
+ <File>
+ <FileName>msh_parse.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\finsh\msh_parse.c</FilePath>
+ </File>
+ <File>
+ <FileName>cmd.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\finsh\cmd.c</FilePath>
+ </File>
+ <File>
+ <FileName>msh_file.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\components\finsh\msh_file.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>Kernel</GroupName>
+ <Files>
+ <File>
+ <FileName>clock.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\clock.c</FilePath>
+ </File>
+ <File>
+ <FileName>components.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\components.c</FilePath>
+ </File>
+ <File>
+ <FileName>device.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\device.c</FilePath>
+ </File>
+ <File>
+ <FileName>idle.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\idle.c</FilePath>
+ </File>
+ <File>
+ <FileName>ipc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\ipc.c</FilePath>
+ </File>
+ <File>
+ <FileName>irq.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\irq.c</FilePath>
+ </File>
+ <File>
+ <FileName>kservice.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\kservice.c</FilePath>
+ </File>
+ <File>
+ <FileName>mem.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\mem.c</FilePath>
+ </File>
+ <File>
+ <FileName>mempool.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\mempool.c</FilePath>
+ </File>
+ <File>
+ <FileName>object.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\object.c</FilePath>
+ </File>
+ <File>
+ <FileName>scheduler.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\scheduler.c</FilePath>
+ </File>
+ <File>
+ <FileName>thread.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\thread.c</FilePath>
+ </File>
+ <File>
+ <FileName>timer.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\..\src\timer.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>Libraries</GroupName>
+ <Files>
+ <File>
+ <FileName>gd32f4xx_syscfg.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_syscfg.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_exti.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_exti.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_gpio.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_gpio.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_rcu.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_rcu.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_misc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_misc.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_usart.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\GD32F4xx_standard_peripheral\Source\gd32f4xx_usart.c</FilePath>
+ </File>
+ <File>
+ <FileName>system_gd32f4xx.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\libraries\GD32F4xx_Firmware_Library\CMSIS\GD\GD32F4xx\Source\system_gd32f4xx.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>::CMSIS</GroupName>
+ </Group>
+ </Groups>
+ </Target>
+ </Targets>
+
+ <RTE>
+ <apis/>
+ <components>
+ <component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.5.0" condition="ARMv6_7_8-M Device">
+ <package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/>
+ <targetInfos>
+ <targetInfo name="rt-thread"/>
+ </targetInfos>
+ </component>
+ </components>
+ <files/>
+ </RTE>
+
+ <LayerInfo>
+ <Layers>
+ <Layer>
+ <LayName>&lt;Project Info&gt;</LayName>
+ <LayTarg>0</LayTarg>
+ <LayPrjMark>1</LayPrjMark>
+ </Layer>
+ </Layers>
+ </LayerInfo>
+
+</Project>
diff --git a/bsp/gd32/arm/gd32470z-lckfb/rtconfig.h b/bsp/gd32/arm/gd32470z-lckfb/rtconfig.h
new file mode 100644
index 0000000000..ccdb397b6a
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/rtconfig.h
@@ -0,0 +1,201 @@
+#ifndef RT_CONFIG_H__
+#define RT_CONFIG_H__
+
+/* Automatically generated file; DO NOT EDIT. */
+/* RT-Thread Configuration */
+
+/* RT-Thread Kernel */
+
+#define RT_NAME_MAX 8
+#define RT_ALIGN_SIZE 8
+#define RT_THREAD_PRIORITY_32
+#define RT_THREAD_PRIORITY_MAX 32
+#define RT_TICK_PER_SECOND 1000
+#define RT_USING_OVERFLOW_CHECK
+#define RT_USING_HOOK
+#define RT_HOOK_USING_FUNC_PTR
+#define RT_USING_IDLE_HOOK
+#define RT_IDLE_HOOK_LIST_SIZE 4
+#define IDLE_THREAD_STACK_SIZE 256
+#define RT_USING_TIMER_SOFT
+#define RT_TIMER_THREAD_PRIO 4
+#define RT_TIMER_THREAD_STACK_SIZE 512
+
+/* kservice optimization */
+
+#define RT_KSERVICE_USING_STDLIB
+#define RT_DEBUG
+
+/* Inter-Thread communication */
+
+#define RT_USING_SEMAPHORE
+#define RT_USING_MUTEX
+#define RT_USING_EVENT
+#define RT_USING_MAILBOX
+#define RT_USING_MESSAGEQUEUE
+
+/* Memory Management */
+
+#define RT_PAGE_MAX_ORDER 11
+#define RT_USING_MEMPOOL
+#define RT_USING_SMALL_MEM
+#define RT_USING_SMALL_MEM_AS_HEAP
+#define RT_USING_HEAP
+
+/* Kernel Device Object */
+
+#define RT_USING_DEVICE
+#define RT_USING_CONSOLE
+#define RT_CONSOLEBUF_SIZE 128
+#define RT_CONSOLE_DEVICE_NAME "uart0"
+#define RT_VER_NUM 0x50000
+
+/* RT-Thread Components */
+
+#define RT_USING_COMPONENTS_INIT
+#define RT_USING_USER_MAIN
+#define RT_MAIN_THREAD_STACK_SIZE 2048
+#define RT_MAIN_THREAD_PRIORITY 10
+#define RT_USING_MSH
+#define RT_USING_FINSH
+#define FINSH_USING_MSH
+#define FINSH_THREAD_NAME "tshell"
+#define FINSH_THREAD_PRIORITY 20
+#define FINSH_THREAD_STACK_SIZE 4096
+#define FINSH_USING_HISTORY
+#define FINSH_HISTORY_LINES 5
+#define FINSH_USING_SYMTAB
+#define FINSH_CMD_SIZE 80
+#define MSH_USING_BUILT_IN_COMMANDS
+#define FINSH_USING_DESCRIPTION
+#define FINSH_ARG_MAX 10
+#define RT_USING_DFS
+#define DFS_USING_POSIX
+#define DFS_USING_WORKDIR
+#define DFS_FILESYSTEMS_MAX 4
+#define DFS_FILESYSTEM_TYPES_MAX 4
+#define DFS_FD_MAX 16
+
+/* Device Drivers */
+
+#define RT_USING_DEVICE_IPC
+#define RT_UNAMED_PIPE_NUMBER 64
+#define RT_USING_SERIAL
+#define RT_USING_SERIAL_V1
+#define RT_SERIAL_USING_DMA
+#define RT_SERIAL_RB_BUFSZ 64
+#define RT_USING_PIN
+
+/* Using USB */
+
+
+/* C/C++ and POSIX layer */
+
+#define RT_LIBC_DEFAULT_TIMEZONE 8
+
+/* POSIX (Portable Operating System Interface) layer */
+
+
+/* Interprocess Communication (IPC) */
+
+
+/* Socket is in the 'Network' category */
+
+
+/* Network */
+
+
+/* Utilities */
+
+
+/* RT-Thread Utestcases */
+
+
+/* RT-Thread online packages */
+
+/* IoT - internet of things */
+
+
+/* Wi-Fi */
+
+/* Marvell WiFi */
+
+
+/* Wiced WiFi */
+
+
+/* IoT Cloud */
+
+
+/* security packages */
+
+
+/* language packages */
+
+/* JSON: JavaScript Object Notation, a lightweight data-interchange format */
+
+
+/* XML: Extensible Markup Language */
+
+
+/* multimedia packages */
+
+/* LVGL: powerful and easy-to-use embedded GUI library */
+
+
+/* u8g2: a monochrome graphic library */
+
+
+/* PainterEngine: A cross-platform graphics application framework written in C language */
+
+
+/* tools packages */
+
+
+/* system packages */
+
+/* enhanced kernel services */
+
+
+/* acceleration: Assembly language or algorithmic acceleration packages */
+
+
+/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
+
+
+/* Micrium: Micrium software products porting for RT-Thread */
+
+
+/* peripheral libraries and drivers */
+
+
+/* AI packages */
+
+
+/* miscellaneous packages */
+
+/* project laboratory */
+
+/* samples: kernel and components samples */
+
+
+/* entertainment: terminal games and other interesting software packages */
+
+
+/* Hardware Drivers Config */
+
+#define SOC_SERIES_GD32F4xx
+#define SOC_GD32470Z
+
+/* Onboard Peripheral Drivers */
+
+/* On-chip Peripheral Drivers */
+
+#define BSP_USING_GPIO
+#define BSP_USING_UART
+#define BSP_USING_UART0
+
+/* Board extended module Drivers */
+
+
+#endif
diff --git a/bsp/gd32/arm/gd32470z-lckfb/rtconfig.py b/bsp/gd32/arm/gd32470z-lckfb/rtconfig.py
new file mode 100644
index 0000000000..81ad46ee79
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/rtconfig.py
@@ -0,0 +1,150 @@
+import os
+
+# toolchains options
+ARCH='arm'
+CPU='cortex-m4'
+CROSS_TOOL='keil'
+
+# bsp lib config
+BSP_LIBRARY_TYPE = None
+
+if os.getenv('RTT_CC'):
+ CROSS_TOOL = os.getenv('RTT_CC')
+if os.getenv('RTT_ROOT'):
+ RTT_ROOT = os.getenv('RTT_ROOT')
+
+# cross_tool provides the cross compiler
+# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
+if CROSS_TOOL == 'gcc':
+ PLATFORM = 'gcc'
+ EXEC_PATH = r'C:\Users\XXYYZZ'
+elif CROSS_TOOL == 'keil':
+ PLATFORM = 'armcc'
+ EXEC_PATH = r'C:/Keil_v5'
+elif CROSS_TOOL == 'iar':
+ PLATFORM = 'iccarm'
+ EXEC_PATH = r'C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.3'
+
+if os.getenv('RTT_EXEC_PATH'):
+ EXEC_PATH = os.getenv('RTT_EXEC_PATH')
+
+BUILD = 'debug'
+
+if PLATFORM == 'gcc':
+ # toolchains
+ PREFIX = 'arm-none-eabi-'
+ CC = PREFIX + 'gcc'
+ AS = PREFIX + 'gcc'
+ AR = PREFIX + 'ar'
+ CXX = PREFIX + 'g++'
+ LINK = PREFIX + 'gcc'
+ TARGET_EXT = 'elf'
+ SIZE = PREFIX + 'size'
+ OBJDUMP = PREFIX + 'objdump'
+ OBJCPY = PREFIX + 'objcopy'
+
+ DEVICE = ' -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -DGD32F450'
+ CFLAGS = DEVICE + ' -Dgcc'
+ AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb '
+ LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -T board/linker_scripts/link.ld'
+
+ CPATH = ''
+ LPATH = ''
+
+ if BUILD == 'debug':
+ CFLAGS += ' -O0 -gdwarf-2 -g'
+ AFLAGS += ' -gdwarf-2'
+ else:
+ CFLAGS += ' -O2'
+
+ CXXFLAGS = CFLAGS
+
+ POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
+
+elif PLATFORM == 'armcc':
+ # toolchains
+ CC = 'armcc'
+ CXX = 'armcc'
+ AS = 'armasm'
+ AR = 'armar'
+ LINK = 'armlink'
+ TARGET_EXT = 'axf'
+
+ DEVICE = ' --cpu Cortex-M4.fp '
+ CFLAGS = '-c ' + DEVICE + ' --apcs=interwork --c99'
+ AFLAGS = DEVICE + ' --apcs=interwork '
+ LFLAGS = DEVICE + ' --scatter "board\linker_scripts\link.sct" --info sizes --info totals --info unused --info veneers --list rtthread.map --strict'
+ CFLAGS += ' -I' + EXEC_PATH + '/ARM/ARMCC/include'
+ LFLAGS += ' --libpath=' + EXEC_PATH + '/ARM/ARMCC/lib'
+
+ CFLAGS += ' -D__MICROLIB '
+ AFLAGS += ' --pd "__MICROLIB SETA 1" '
+ LFLAGS += ' --library_type=microlib '
+ EXEC_PATH += '/ARM/ARMCC/bin/'
+
+ if BUILD == 'debug':
+ CFLAGS += ' -g -O0'
+ AFLAGS += ' -g'
+ else:
+ CFLAGS += ' -O2'
+
+ CXXFLAGS = CFLAGS
+ CFLAGS += ' -std=c99'
+
+ POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET'
+
+elif PLATFORM == 'iccarm':
+ # toolchains
+ CC = 'iccarm'
+ CXX = 'iccarm'
+ AS = 'iasmarm'
+ AR = 'iarchive'
+ LINK = 'ilinkarm'
+ TARGET_EXT = 'out'
+
+ DEVICE = '-Dewarm'
+
+ CFLAGS = DEVICE
+ CFLAGS += ' --diag_suppress Pa050'
+ CFLAGS += ' --no_cse'
+ CFLAGS += ' --no_unroll'
+ CFLAGS += ' --no_inline'
+ CFLAGS += ' --no_code_motion'
+ CFLAGS += ' --no_tbaa'
+ CFLAGS += ' --no_clustering'
+ CFLAGS += ' --no_scheduling'
+ CFLAGS += ' --endian=little'
+ CFLAGS += ' --cpu=Cortex-M4'
+ CFLAGS += ' -e'
+ CFLAGS += ' --fpu=VFPv4_sp'
+ CFLAGS += ' --dlib_config "' + EXEC_PATH + '/arm/INC/c/DLib_Config_Normal.h"'
+ CFLAGS += ' --silent'
+
+ AFLAGS = DEVICE
+ AFLAGS += ' -s+'
+ AFLAGS += ' -w+'
+ AFLAGS += ' -r'
+ AFLAGS += ' --cpu Cortex-M4'
+ AFLAGS += ' --fpu VFPv4_sp'
+ AFLAGS += ' -S'
+
+ if BUILD == 'debug':
+ CFLAGS += ' --debug'
+ CFLAGS += ' -On'
+ else:
+ CFLAGS += ' -Oh'
+
+ LFLAGS = ' --config "board/linker_scripts/link.icf"'
+ LFLAGS += ' --entry __iar_program_start'
+
+ CXXFLAGS = CFLAGS
+
+ EXEC_PATH = EXEC_PATH + '/arm/bin/'
+ POST_ACTION = 'ielftool --bin $TARGET rtthread.bin'
+
+def dist_handle(BSP_ROOT, dist_dir):
+ import sys
+ cwd_path = os.getcwd()
+ sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools'))
+ from sdk_dist import dist_do_building
+ dist_do_building(BSP_ROOT, dist_dir)
diff --git a/bsp/gd32/arm/gd32470z-lckfb/template.ewp b/bsp/gd32/arm/gd32470z-lckfb/template.ewp
new file mode 100644
index 0000000000..963857b281
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/template.ewp
@@ -0,0 +1,1892 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+
+<project>
+ <fileVersion>2</fileVersion>
+ <configuration>
+ <name>Debug</name>
+ <toolchain>
+ <name>ARM</name>
+ </toolchain>
+ <debug>1</debug>
+ <settings>
+ <name>General</name>
+ <archiveVersion>3</archiveVersion>
+ <data>
+ <version>22</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>ExePath</name>
+ <state>build\Exe</state>
+ </option>
+ <option>
+ <name>ObjPath</name>
+ <state>build\Obj</state>
+ </option>
+ <option>
+ <name>ListPath</name>
+ <state>build\List</state>
+ </option>
+ <option>
+ <name>Variant</name>
+ <version>21</version>
+ <state>39</state>
+ </option>
+ <option>
+ <name>GEndianMode</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>Input variant</name>
+ <version>3</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>Input description</name>
+ <state>Automatic choice of formatter.</state>
+ </option>
+ <option>
+ <name>Output variant</name>
+ <version>2</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>Output description</name>
+ <state>Automatic choice of formatter.</state>
+ </option>
+ <option>
+ <name>GOutputBinary</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>FPU</name>
+ <version>5</version>
+ <state>7</state>
+ </option>
+ <option>
+ <name>OGCoreOrChip</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>GRuntimeLibSelect</name>
+ <version>0</version>
+ <state>2</state>
+ </option>
+ <option>
+ <name>GRuntimeLibSelectSlave</name>
+ <version>0</version>
+ <state>2</state>
+ </option>
+ <option>
+ <name>RTDescription</name>
+ <state>Use the full configuration of the C/C++ runtime library. Full locale interface, C locale, file descriptor support, multibytes in printf and scanf, and hex floats in strtod.</state>
+ </option>
+ <option>
+ <name>OGProductVersion</name>
+ <state>7.40.2.8567</state>
+ </option>
+ <option>
+ <name>OGLastSavedByProductVersion</name>
+ <state>7.40.2.8567</state>
+ </option>
+ <option>
+ <name>GeneralEnableMisra</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GeneralMisraVerbose</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGChipSelectEditMenu</name>
+ <state>GD32F450xK GD GD32F450xK</state>
+ </option>
+ <option>
+ <name>GenLowLevelInterface</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>GEndianModeBE</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OGBufferedTerminalOutput</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GenStdoutInterface</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GeneralMisraRules98</name>
+ <version>0</version>
+ <state>1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111</state>
+ </option>
+ <option>
+ <name>GeneralMisraVer</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GeneralMisraRules04</name>
+ <version>0</version>
+ <state>111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111</state>
+ </option>
+ <option>
+ <name>RTConfigPath2</name>
+ <state>$TOOLKIT_DIR$\INC\c\DLib_Config_Full.h</state>
+ </option>
+ <option>
+ <name>GFPUCoreSlave</name>
+ <version>21</version>
+ <state>39</state>
+ </option>
+ <option>
+ <name>GBECoreSlave</name>
+ <version>21</version>
+ <state>39</state>
+ </option>
+ <option>
+ <name>OGUseCmsis</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OGUseCmsisDspLib</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>GRuntimeLibThreads</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>ICCARM</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>31</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>CCDefines</name>
+ <state>USE_STDPERIPH_DRIVER</state>
+ <state>GD32F4XX</state>
+ </option>
+ <option>
+ <name>CCPreprocFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPreprocComments</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPreprocLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCMnemonics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCMessages</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListAssFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListAssSource</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCEnableRemarks</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCDiagSuppress</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagRemark</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagWarning</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagError</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCObjPrefix</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCAllowList</name>
+ <version>1</version>
+ <state>00000000</state>
+ </option>
+ <option>
+ <name>CCDebugInfo</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IEndianMode</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IExtraOptionsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IExtraOptions</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCLangConformance</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSignedPlainChar</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCRequirePrototypes</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMultibyteSupport</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCDiagWarnAreErr</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCompilerRuntimeInfo</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IFpuProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OutputFile</name>
+ <state>$FILE_BNAME$.o</state>
+ </option>
+ <option>
+ <name>CCLibConfigHeader</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>PreInclude</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CompilerMisraOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCIncludePath2</name>
+
+ </option>
+ <option>
+ <name>CCStdIncCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCodeSection</name>
+ <state>.text</state>
+ </option>
+ <option>
+ <name>IInterwork2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IProcessorMode2</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCOptLevel</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCOptStrategy</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptLevelSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CompilerMisraRules98</name>
+ <version>0</version>
+ <state>1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111</state>
+ </option>
+ <option>
+ <name>CompilerMisraRules04</name>
+ <version>0</version>
+ <state>111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111</state>
+ </option>
+ <option>
+ <name>CCPosIndRopi</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPosIndRwpi</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPosIndNoDynInit</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccLang</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCDialect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccAllowVLA</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCppDialect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccExceptions</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccRTTI</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccStaticDestr</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccCppInlineSemantics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCmsis</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccFloatSemantics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptimizationNoSizeConstraints</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCNoLiteralPool</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptStrategySlave</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCGuardCalls</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>AARM</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>9</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>AObjPrefix</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AEndian</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>ACaseSensitivity</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>MacroChars</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnWhat</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnOne</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AWarnRange1</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AWarnRange2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>ADebug</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AltRegisterNames</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ADefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AList</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AListHeader</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AListing</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>Includes</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacDefs</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacExps</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>MacExec</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OnlyAssed</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MultiLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>PageLengthCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>PageLength</name>
+ <state>80</state>
+ </option>
+ <option>
+ <name>TabSpacing</name>
+ <state>8</state>
+ </option>
+ <option>
+ <name>AXRef</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefDefines</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefInternal</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefDual</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AFpuProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AOutputFile</name>
+ <state>$FILE_BNAME$.o</state>
+ </option>
+ <option>
+ <name>AMultibyteSupport</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ALimitErrorsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ALimitErrorsEdit</name>
+ <state>100</state>
+ </option>
+ <option>
+ <name>AIgnoreStdInclude</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AUserIncludes</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AExtraOptionsCheckV2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AExtraOptionsV2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AsmNoLiteralPool</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>OBJCOPY</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>1</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>OOCOutputFormat</name>
+ <version>3</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCOutputOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OOCOutputFile</name>
+ <state>project.srec</state>
+ </option>
+ <option>
+ <name>OOCCommandLineProducer</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OOCObjCopyEnable</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>CUSTOM</name>
+ <archiveVersion>3</archiveVersion>
+ <data>
+ <extensions></extensions>
+ <cmdline></cmdline>
+ <hasPrio>0</hasPrio>
+ </data>
+ </settings>
+ <settings>
+ <name>BICOMP</name>
+ <archiveVersion>0</archiveVersion>
+ <data/>
+ </settings>
+ <settings>
+ <name>BUILDACTION</name>
+ <archiveVersion>1</archiveVersion>
+ <data>
+ <prebuild></prebuild>
+ <postbuild></postbuild>
+ </data>
+ </settings>
+ <settings>
+ <name>ILINK</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>16</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>IlinkLibIOConfig</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>XLinkMisraHandler</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkInputFileSlave</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkOutputFile</name>
+ <state>rtthread.out</state>
+ </option>
+ <option>
+ <name>IlinkDebugInfoEnable</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkKeepSymbols</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySymbol</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySegment</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryAlign</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkDefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkConfigDefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkMapFile</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogFile</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogInitialization</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogModule</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogSection</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogVeneer</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkIcfOverride</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkIcfFile</name>
+ <state>$PROJ_DIR$\board\linker_scripts\link.icf</state>
+ </option>
+ <option>
+ <name>IlinkIcfFileSlave</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkEnableRemarks</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkSuppressDiags</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsRem</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsWarn</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsErr</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkWarningsAreErrors</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkUseExtraOptions</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkExtraOptions</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkLowLevelInterfaceSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkAutoLibEnable</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkAdditionalLibs</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkOverrideProgramEntryLabel</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkProgramEntryLabelSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkProgramEntryLabel</name>
+ <state>__iar_program_start</state>
+ </option>
+ <option>
+ <name>DoFill</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>FillerByte</name>
+ <state>0xFF</state>
+ </option>
+ <option>
+ <name>FillerStart</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>FillerEnd</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>CrcSize</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcAlign</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcPoly</name>
+ <state>0x11021</state>
+ </option>
+ <option>
+ <name>CrcCompl</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CrcBitOrder</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CrcInitialValue</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>DoCrc</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkBE8Slave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkBufferedTerminalOutput</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkStdoutInterfaceSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcFullSize</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkIElfToolPostProcess</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogAutoLibSelect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogRedirSymbols</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkLogUnusedFragments</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkCrcReverseByteOrder</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCrcUseAsInput</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptInline</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkOptExceptionsAllow</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptExceptionsForce</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCmsis</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptMergeDuplSections</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkOptUseVfe</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptForceVfe</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkStackAnalysisEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkStackControlFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkStackCallGraphFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CrcAlgorithm</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcUnitSize</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkThreadsSlave</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>IARCHIVE</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>0</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>1</debug>
+ <option>
+ <name>IarchiveInputs</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IarchiveOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IarchiveOutput</name>
+ <state>###Unitialized###</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>BILINK</name>
+ <archiveVersion>0</archiveVersion>
+ <data/>
+ </settings>
+ </configuration>
+ <configuration>
+ <name>Release</name>
+ <toolchain>
+ <name>ARM</name>
+ </toolchain>
+ <debug>0</debug>
+ <settings>
+ <name>General</name>
+ <archiveVersion>3</archiveVersion>
+ <data>
+ <version>22</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>ExePath</name>
+ <state>Release\Exe</state>
+ </option>
+ <option>
+ <name>ObjPath</name>
+ <state>Release\Obj</state>
+ </option>
+ <option>
+ <name>ListPath</name>
+ <state>Release\List</state>
+ </option>
+ <option>
+ <name>Variant</name>
+ <version>21</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GEndianMode</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>Input variant</name>
+ <version>3</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>Input description</name>
+ <state></state>
+ </option>
+ <option>
+ <name>Output variant</name>
+ <version>2</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>Output description</name>
+ <state></state>
+ </option>
+ <option>
+ <name>GOutputBinary</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>FPU</name>
+ <version>5</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGCoreOrChip</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GRuntimeLibSelect</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>GRuntimeLibSelectSlave</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>RTDescription</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OGProductVersion</name>
+ <state>7.40.2.8567</state>
+ </option>
+ <option>
+ <name>OGLastSavedByProductVersion</name>
+ <state></state>
+ </option>
+ <option>
+ <name>GeneralEnableMisra</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GeneralMisraVerbose</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGChipSelectEditMenu</name>
+ <state></state>
+ </option>
+ <option>
+ <name>GenLowLevelInterface</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GEndianModeBE</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGBufferedTerminalOutput</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GenStdoutInterface</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GeneralMisraRules98</name>
+ <version>0</version>
+ <state>1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111</state>
+ </option>
+ <option>
+ <name>GeneralMisraVer</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GeneralMisraRules04</name>
+ <version>0</version>
+ <state>111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111</state>
+ </option>
+ <option>
+ <name>RTConfigPath2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>GFPUCoreSlave</name>
+ <version>21</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>GBECoreSlave</name>
+ <version>21</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OGUseCmsis</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OGUseCmsisDspLib</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>GRuntimeLibThreads</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>ICCARM</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>31</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>CCDefines</name>
+ <state>NDEBUG</state>
+ </option>
+ <option>
+ <name>CCPreprocFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPreprocComments</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPreprocLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCMnemonics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListCMessages</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListAssFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCListAssSource</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCEnableRemarks</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCDiagSuppress</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagRemark</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagWarning</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCDiagError</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCObjPrefix</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCAllowList</name>
+ <version>1</version>
+ <state>11111110</state>
+ </option>
+ <option>
+ <name>CCDebugInfo</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IEndianMode</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IExtraOptionsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IExtraOptions</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCLangConformance</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCSignedPlainChar</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCRequirePrototypes</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCMultibyteSupport</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCDiagWarnAreErr</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCompilerRuntimeInfo</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IFpuProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OutputFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCLibConfigHeader</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>PreInclude</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CompilerMisraOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCIncludePath2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CCStdIncCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCCodeSection</name>
+ <state>.text</state>
+ </option>
+ <option>
+ <name>IInterwork2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IProcessorMode2</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CCOptLevel</name>
+ <state>3</state>
+ </option>
+ <option>
+ <name>CCOptStrategy</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptLevelSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CompilerMisraRules98</name>
+ <version>0</version>
+ <state>1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111</state>
+ </option>
+ <option>
+ <name>CompilerMisraRules04</name>
+ <version>0</version>
+ <state>111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111</state>
+ </option>
+ <option>
+ <name>CCPosIndRopi</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPosIndRwpi</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCPosIndNoDynInit</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccLang</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCDialect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccAllowVLA</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCppDialect</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccExceptions</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccRTTI</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccStaticDestr</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccCppInlineSemantics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IccCmsis</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IccFloatSemantics</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptimizationNoSizeConstraints</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCNoLiteralPool</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCOptStrategySlave</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CCGuardCalls</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>AARM</name>
+ <archiveVersion>2</archiveVersion>
+ <data>
+ <version>9</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>AObjPrefix</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AEndian</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>ACaseSensitivity</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>MacroChars</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnWhat</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AWarnOne</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AWarnRange1</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AWarnRange2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>ADebug</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AltRegisterNames</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ADefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AList</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AListHeader</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AListing</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>Includes</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacDefs</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MacExps</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>MacExec</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OnlyAssed</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>MultiLine</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>PageLengthCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>PageLength</name>
+ <state>80</state>
+ </option>
+ <option>
+ <name>TabSpacing</name>
+ <state>8</state>
+ </option>
+ <option>
+ <name>AXRef</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefDefines</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefInternal</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AXRefDual</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AFpuProcessor</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>AOutputFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AMultibyteSupport</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ALimitErrorsCheck</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>ALimitErrorsEdit</name>
+ <state>100</state>
+ </option>
+ <option>
+ <name>AIgnoreStdInclude</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AUserIncludes</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AExtraOptionsCheckV2</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>AExtraOptionsV2</name>
+ <state></state>
+ </option>
+ <option>
+ <name>AsmNoLiteralPool</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>OBJCOPY</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>1</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>OOCOutputFormat</name>
+ <version>3</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OCOutputOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>OOCOutputFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>OOCCommandLineProducer</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>OOCObjCopyEnable</name>
+ <state>0</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>CUSTOM</name>
+ <archiveVersion>3</archiveVersion>
+ <data>
+ <extensions></extensions>
+ <cmdline></cmdline>
+ <hasPrio>0</hasPrio>
+ </data>
+ </settings>
+ <settings>
+ <name>BICOMP</name>
+ <archiveVersion>0</archiveVersion>
+ <data/>
+ </settings>
+ <settings>
+ <name>BUILDACTION</name>
+ <archiveVersion>1</archiveVersion>
+ <data>
+ <prebuild></prebuild>
+ <postbuild></postbuild>
+ </data>
+ </settings>
+ <settings>
+ <name>ILINK</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>16</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>IlinkLibIOConfig</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>XLinkMisraHandler</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkInputFileSlave</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkOutputFile</name>
+ <state>###Unitialized###</state>
+ </option>
+ <option>
+ <name>IlinkDebugInfoEnable</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkKeepSymbols</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySymbol</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinarySegment</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkRawBinaryAlign</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkDefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkConfigDefines</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkMapFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogFile</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogInitialization</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogModule</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogSection</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogVeneer</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkIcfOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkIcfFile</name>
+ <state>lnk0t.icf</state>
+ </option>
+ <option>
+ <name>IlinkIcfFileSlave</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkEnableRemarks</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkSuppressDiags</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsRem</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsWarn</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkTreatAsErr</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkWarningsAreErrors</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkUseExtraOptions</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkExtraOptions</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkLowLevelInterfaceSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkAutoLibEnable</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkAdditionalLibs</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkOverrideProgramEntryLabel</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkProgramEntryLabelSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkProgramEntryLabel</name>
+ <state></state>
+ </option>
+ <option>
+ <name>DoFill</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>FillerByte</name>
+ <state>0xFF</state>
+ </option>
+ <option>
+ <name>FillerStart</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>FillerEnd</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>CrcSize</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcAlign</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcPoly</name>
+ <state>0x11021</state>
+ </option>
+ <option>
+ <name>CrcCompl</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CrcBitOrder</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>CrcInitialValue</name>
+ <state>0x0</state>
+ </option>
+ <option>
+ <name>DoCrc</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkBE8Slave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkBufferedTerminalOutput</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkStdoutInterfaceSlave</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcFullSize</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkIElfToolPostProcess</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogAutoLibSelect</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogRedirSymbols</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkLogUnusedFragments</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCrcReverseByteOrder</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCrcUseAsInput</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptInline</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptExceptionsAllow</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptExceptionsForce</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkCmsis</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptMergeDuplSections</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkOptUseVfe</name>
+ <state>1</state>
+ </option>
+ <option>
+ <name>IlinkOptForceVfe</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkStackAnalysisEnable</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkStackControlFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IlinkStackCallGraphFile</name>
+ <state></state>
+ </option>
+ <option>
+ <name>CrcAlgorithm</name>
+ <version>0</version>
+ <state>1</state>
+ </option>
+ <option>
+ <name>CrcUnitSize</name>
+ <version>0</version>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IlinkThreadsSlave</name>
+ <state>1</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>IARCHIVE</name>
+ <archiveVersion>0</archiveVersion>
+ <data>
+ <version>0</version>
+ <wantNonLocal>1</wantNonLocal>
+ <debug>0</debug>
+ <option>
+ <name>IarchiveInputs</name>
+ <state></state>
+ </option>
+ <option>
+ <name>IarchiveOverride</name>
+ <state>0</state>
+ </option>
+ <option>
+ <name>IarchiveOutput</name>
+ <state>###Unitialized###</state>
+ </option>
+ </data>
+ </settings>
+ <settings>
+ <name>BILINK</name>
+ <archiveVersion>0</archiveVersion>
+ <data/>
+ </settings>
+ </configuration>
+</project>
+
+
diff --git a/bsp/gd32/arm/gd32470z-lckfb/template.uvoptx b/bsp/gd32/arm/gd32470z-lckfb/template.uvoptx
new file mode 100644
index 0000000000..14dde5e4db
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/template.uvoptx
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
+
+ <SchemaVersion>1.0</SchemaVersion>
+
+ <Header>### uVision Project, (C) Keil Software</Header>
+
+ <Extensions>
+ <cExt>*.c</cExt>
+ <aExt>*.s*; *.src; *.a*</aExt>
+ <oExt>*.obj; *.o</oExt>
+ <lExt>*.lib</lExt>
+ <tExt>*.txt; *.h; *.inc; *.md</tExt>
+ <pExt>*.plm</pExt>
+ <CppX>*.cpp</CppX>
+ <nMigrate>0</nMigrate>
+ </Extensions>
+
+ <DaveTm>
+ <dwLowDateTime>0</dwLowDateTime>
+ <dwHighDateTime>0</dwHighDateTime>
+ </DaveTm>
+
+ <Target>
+ <TargetName>rt-thread</TargetName>
+ <ToolsetNumber>0x4</ToolsetNumber>
+ <ToolsetName>ARM-ADS</ToolsetName>
+ <TargetOption>
+ <CLKADS>12000000</CLKADS>
+ <OPTTT>
+ <gFlags>1</gFlags>
+ <BeepAtEnd>1</BeepAtEnd>
+ <RunSim>0</RunSim>
+ <RunTarget>1</RunTarget>
+ <RunAbUc>0</RunAbUc>
+ </OPTTT>
+ <OPTHX>
+ <HexSelection>1</HexSelection>
+ <FlashByte>65535</FlashByte>
+ <HexRangeLowAddress>0</HexRangeLowAddress>
+ <HexRangeHighAddress>0</HexRangeHighAddress>
+ <HexOffset>0</HexOffset>
+ </OPTHX>
+ <OPTLEX>
+ <PageWidth>79</PageWidth>
+ <PageLength>66</PageLength>
+ <TabStop>8</TabStop>
+ <ListingPath>.\build\</ListingPath>
+ </OPTLEX>
+ <ListingPage>
+ <CreateCListing>1</CreateCListing>
+ <CreateAListing>1</CreateAListing>
+ <CreateLListing>1</CreateLListing>
+ <CreateIListing>0</CreateIListing>
+ <AsmCond>1</AsmCond>
+ <AsmSymb>1</AsmSymb>
+ <AsmXref>0</AsmXref>
+ <CCond>1</CCond>
+ <CCode>0</CCode>
+ <CListInc>0</CListInc>
+ <CSymb>0</CSymb>
+ <LinkerCodeListing>0</LinkerCodeListing>
+ </ListingPage>
+ <OPTXL>
+ <LMap>1</LMap>
+ <LComments>1</LComments>
+ <LGenerateSymbols>1</LGenerateSymbols>
+ <LLibSym>1</LLibSym>
+ <LLines>1</LLines>
+ <LLocSym>1</LLocSym>
+ <LPubSym>1</LPubSym>
+ <LXref>0</LXref>
+ <LExpSel>0</LExpSel>
+ </OPTXL>
+ <OPTFL>
+ <tvExp>1</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <IsCurrentTarget>1</IsCurrentTarget>
+ </OPTFL>
+ <CpuCode>255</CpuCode>
+ <DebugOpt>
+ <uSim>0</uSim>
+ <uTrg>1</uTrg>
+ <sLdApp>1</sLdApp>
+ <sGomain>1</sGomain>
+ <sRbreak>1</sRbreak>
+ <sRwatch>1</sRwatch>
+ <sRmem>1</sRmem>
+ <sRfunc>1</sRfunc>
+ <sRbox>1</sRbox>
+ <tLdApp>1</tLdApp>
+ <tGomain>1</tGomain>
+ <tRbreak>1</tRbreak>
+ <tRwatch>1</tRwatch>
+ <tRmem>1</tRmem>
+ <tRfunc>0</tRfunc>
+ <tRbox>1</tRbox>
+ <tRtrace>1</tRtrace>
+ <sRSysVw>1</sRSysVw>
+ <tRSysVw>1</tRSysVw>
+ <sRunDeb>0</sRunDeb>
+ <sLrtime>0</sLrtime>
+ <bEvRecOn>1</bEvRecOn>
+ <bSchkAxf>0</bSchkAxf>
+ <bTchkAxf>0</bTchkAxf>
+ <nTsel>3</nTsel>
+ <sDll></sDll>
+ <sDllPa></sDllPa>
+ <sDlgDll></sDlgDll>
+ <sDlgPa></sDlgPa>
+ <sIfile></sIfile>
+ <tDll></tDll>
+ <tDllPa></tDllPa>
+ <tDlgDll></tDlgDll>
+ <tDlgPa></tDlgPa>
+ <tIfile></tIfile>
+ <pMon>BIN\CMSIS_AGDI.dll</pMon>
+ </DebugOpt>
+ <TargetDriverDllRegistry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>UL2CM3</Key>
+ <Name>UL2CM3(-S0 -C0 -P0 ) -FN1 -FC1000 -FD20000000 -FF0GD32F4xx_1MB -FL0100000 -FS08000000 -FP0($$Device:GD32F470ZG$Flash\GD32F4xx_1MB.FLM)</Name>
+ </SetRegEntry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>CMSIS_AGDI</Key>
+ <Name>-X"Any" -UAny -O206 -S0 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0GD32F4xx_1MB.FLM -FS08000000 -FL0100000 -FP0($$Device:GD32F470ZG$Flash\GD32F4xx_1MB.FLM)</Name>
+ </SetRegEntry>
+ </TargetDriverDllRegistry>
+ <Breakpoint/>
+ <Tracepoint>
+ <THDelay>0</THDelay>
+ </Tracepoint>
+ <DebugFlag>
+ <trace>0</trace>
+ <periodic>0</periodic>
+ <aLwin>0</aLwin>
+ <aCover>0</aCover>
+ <aSer1>0</aSer1>
+ <aSer2>0</aSer2>
+ <aPa>0</aPa>
+ <viewmode>0</viewmode>
+ <vrSel>0</vrSel>
+ <aSym>0</aSym>
+ <aTbox>0</aTbox>
+ <AscS1>0</AscS1>
+ <AscS2>0</AscS2>
+ <AscS3>0</AscS3>
+ <aSer3>0</aSer3>
+ <eProf>0</eProf>
+ <aLa>0</aLa>
+ <aPa1>0</aPa1>
+ <AscS4>0</AscS4>
+ <aSer4>0</aSer4>
+ <StkLoc>0</StkLoc>
+ <TrcWin>0</TrcWin>
+ <newCpu>0</newCpu>
+ <uProt>0</uProt>
+ </DebugFlag>
+ <LintExecutable></LintExecutable>
+ <LintConfigFile></LintConfigFile>
+ <bLintAuto>0</bLintAuto>
+ <bAutoGenD>0</bAutoGenD>
+ <LntExFlags>0</LntExFlags>
+ <pMisraName></pMisraName>
+ <pszMrule></pszMrule>
+ <pSingCmds></pSingCmds>
+ <pMultCmds></pMultCmds>
+ <pMisraNamep></pMisraNamep>
+ <pszMrulep></pszMrulep>
+ <pSingCmdsp></pSingCmdsp>
+ <pMultCmdsp></pMultCmdsp>
+ </TargetOption>
+ </Target>
+
+ <Group>
+ <GroupName>::CMSIS</GroupName>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <RteFlg>1</RteFlg>
+ </Group>
+
+</ProjectOpt>
diff --git a/bsp/gd32/arm/gd32470z-lckfb/template.uvproj b/bsp/gd32/arm/gd32470z-lckfb/template.uvproj
new file mode 100644
index 0000000000..d7a936eb29
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/template.uvproj
@@ -0,0 +1,628 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_proj.xsd">
+
+ <SchemaVersion>1.1</SchemaVersion>
+
+ <Header>### uVision Project, (C) Keil Software</Header>
+
+ <Targets>
+ <Target>
+ <TargetName>rt-thread</TargetName>
+ <ToolsetNumber>0x4</ToolsetNumber>
+ <ToolsetName>ARM-ADS</ToolsetName>
+ <uAC6>0</uAC6>
+ <TargetOption>
+ <TargetCommonOption>
+ <Device>GD32F450ZK</Device>
+ <Vendor>GigaDevice</Vendor>
+ <Cpu>IRAM(0x20000000-0x20030000) IRAM2(0x10000000-0x10010000) IROM(0x08000000-0x08300000) CLOCK(25000000) CPUTYPE("Cortex-M4") FPU2</Cpu>
+ <FlashUtilSpec></FlashUtilSpec>
+ <StartupFile>"Startup\GD\GD32F4xx\startup_gd32f4xx.s" ("GD32F4xx Startup Code")</StartupFile>
+ <FlashDriverDll>UL2CM3(-O207 -S0 -C0 -FO7 -FD20000000 -FC800 -FN1 -FF0GD32F4xx_3MB -FS08000000 -FL0300000)</FlashDriverDll>
+ <DeviceId>0</DeviceId>
+ <RegisterFile>gd32f4xx0.h</RegisterFile>
+ <MemoryEnv></MemoryEnv>
+ <Cmp></Cmp>
+ <Asm></Asm>
+ <Linker></Linker>
+ <OHString></OHString>
+ <InfinionOptionDll></InfinionOptionDll>
+ <SLE66CMisc></SLE66CMisc>
+ <SLE66AMisc></SLE66AMisc>
+ <SLE66LinkerMisc></SLE66LinkerMisc>
+ <SFDFile>SFD\GD\GD32F4xx\GD32F4xx.SFR</SFDFile>
+ <bCustSvd>0</bCustSvd>
+ <UseEnv>0</UseEnv>
+ <BinPath></BinPath>
+ <IncludePath></IncludePath>
+ <LibPath></LibPath>
+ <RegisterFilePath>GD\GD32F4xx\</RegisterFilePath>
+ <DBRegisterFilePath>GD\GD32F4xx\</DBRegisterFilePath>
+ <TargetStatus>
+ <Error>0</Error>
+ <ExitCodeStop>0</ExitCodeStop>
+ <ButtonStop>0</ButtonStop>
+ <NotGenerated>0</NotGenerated>
+ <InvalidFlash>1</InvalidFlash>
+ </TargetStatus>
+ <OutputDirectory>.\output\</OutputDirectory>
+ <OutputName>rtthread</OutputName>
+ <CreateExecutable>1</CreateExecutable>
+ <CreateLib>0</CreateLib>
+ <CreateHexFile>1</CreateHexFile>
+ <DebugInformation>1</DebugInformation>
+ <BrowseInformation>1</BrowseInformation>
+ <ListingPath>.\build\</ListingPath>
+ <HexFormatSelection>1</HexFormatSelection>
+ <Merge32K>0</Merge32K>
+ <CreateBatchFile>0</CreateBatchFile>
+ <BeforeCompile>
+ <RunUserProg1>0</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name></UserProg1Name>
+ <UserProg2Name></UserProg2Name>
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ <nStopU1X>0</nStopU1X>
+ <nStopU2X>0</nStopU2X>
+ </BeforeCompile>
+ <BeforeMake>
+ <RunUserProg1>0</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name></UserProg1Name>
+ <UserProg2Name></UserProg2Name>
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ <nStopB1X>0</nStopB1X>
+ <nStopB2X>0</nStopB2X>
+ </BeforeMake>
+ <AfterMake>
+ <RunUserProg1>0</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name></UserProg1Name>
+ <UserProg2Name></UserProg2Name>
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ <nStopA1X>0</nStopA1X>
+ <nStopA2X>0</nStopA2X>
+ </AfterMake>
+ <SelectedForBatchBuild>0</SelectedForBatchBuild>
+ <SVCSIdString></SVCSIdString>
+ </TargetCommonOption>
+ <CommonProperty>
+ <UseCPPCompiler>0</UseCPPCompiler>
+ <RVCTCodeConst>0</RVCTCodeConst>
+ <RVCTZI>0</RVCTZI>
+ <RVCTOtherData>0</RVCTOtherData>
+ <ModuleSelection>0</ModuleSelection>
+ <IncludeInBuild>1</IncludeInBuild>
+ <AlwaysBuild>0</AlwaysBuild>
+ <GenerateAssemblyFile>0</GenerateAssemblyFile>
+ <AssembleAssemblyFile>0</AssembleAssemblyFile>
+ <PublicsOnly>0</PublicsOnly>
+ <StopOnExitCode>3</StopOnExitCode>
+ <CustomArgument></CustomArgument>
+ <IncludeLibraryModules></IncludeLibraryModules>
+ <ComprImg>1</ComprImg>
+ </CommonProperty>
+ <DllOption>
+ <SimDllName>SARMCM3.DLL</SimDllName>
+ <SimDllArguments> -REMAP</SimDllArguments>
+ <SimDlgDll>DCM.DLL</SimDlgDll>
+ <SimDlgDllArguments>-pCM3</SimDlgDllArguments>
+ <TargetDllName>SARMCM3.DLL</TargetDllName>
+ <TargetDllArguments></TargetDllArguments>
+ <TargetDlgDll>TCM.DLL</TargetDlgDll>
+ <TargetDlgDllArguments>-pCM3</TargetDlgDllArguments>
+ </DllOption>
+ <DebugOption>
+ <OPTHX>
+ <HexSelection>1</HexSelection>
+ <HexRangeLowAddress>0</HexRangeLowAddress>
+ <HexRangeHighAddress>0</HexRangeHighAddress>
+ <HexOffset>0</HexOffset>
+ <Oh166RecLen>16</Oh166RecLen>
+ </OPTHX>
+ <Simulator>
+ <UseSimulator>0</UseSimulator>
+ <LoadApplicationAtStartup>1</LoadApplicationAtStartup>
+ <RunToMain>1</RunToMain>
+ <RestoreBreakpoints>1</RestoreBreakpoints>
+ <RestoreWatchpoints>1</RestoreWatchpoints>
+ <RestoreMemoryDisplay>1</RestoreMemoryDisplay>
+ <RestoreFunctions>1</RestoreFunctions>
+ <RestoreToolbox>1</RestoreToolbox>
+ <LimitSpeedToRealTime>0</LimitSpeedToRealTime>
+ <RestoreSysVw>1</RestoreSysVw>
+ </Simulator>
+ <Target>
+ <UseTarget>1</UseTarget>
+ <LoadApplicationAtStartup>1</LoadApplicationAtStartup>
+ <RunToMain>1</RunToMain>
+ <RestoreBreakpoints>1</RestoreBreakpoints>
+ <RestoreWatchpoints>1</RestoreWatchpoints>
+ <RestoreMemoryDisplay>1</RestoreMemoryDisplay>
+ <RestoreFunctions>0</RestoreFunctions>
+ <RestoreToolbox>1</RestoreToolbox>
+ <RestoreTracepoints>0</RestoreTracepoints>
+ <RestoreSysVw>1</RestoreSysVw>
+ </Target>
+ <RunDebugAfterBuild>0</RunDebugAfterBuild>
+ <TargetSelection>3</TargetSelection>
+ <SimDlls>
+ <CpuDll></CpuDll>
+ <CpuDllArguments></CpuDllArguments>
+ <PeripheralDll></PeripheralDll>
+ <PeripheralDllArguments></PeripheralDllArguments>
+ <InitializationFile></InitializationFile>
+ </SimDlls>
+ <TargetDlls>
+ <CpuDll></CpuDll>
+ <CpuDllArguments></CpuDllArguments>
+ <PeripheralDll></PeripheralDll>
+ <PeripheralDllArguments></PeripheralDllArguments>
+ <InitializationFile></InitializationFile>
+ <Driver>BIN\CMSIS_AGDI.dll</Driver>
+ </TargetDlls>
+ </DebugOption>
+ <Utilities>
+ <Flash1>
+ <UseTargetDll>1</UseTargetDll>
+ <UseExternalTool>0</UseExternalTool>
+ <RunIndependent>0</RunIndependent>
+ <UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
+ <Capability>1</Capability>
+ <DriverSelection>4096</DriverSelection>
+ </Flash1>
+ <bUseTDR>1</bUseTDR>
+ <Flash2>BIN\UL2CM3.DLL</Flash2>
+ <Flash3>"" ()</Flash3>
+ <Flash4></Flash4>
+ <pFcarmOut></pFcarmOut>
+ <pFcarmGrp></pFcarmGrp>
+ <pFcArmRoot></pFcArmRoot>
+ <FcArmLst>0</FcArmLst>
+ </Utilities>
+ <TargetArmAds>
+ <ArmAdsMisc>
+ <GenerateListings>0</GenerateListings>
+ <asHll>1</asHll>
+ <asAsm>1</asAsm>
+ <asMacX>1</asMacX>
+ <asSyms>1</asSyms>
+ <asFals>1</asFals>
+ <asDbgD>1</asDbgD>
+ <asForm>1</asForm>
+ <ldLst>0</ldLst>
+ <ldmm>1</ldmm>
+ <ldXref>1</ldXref>
+ <BigEnd>0</BigEnd>
+ <AdsALst>1</AdsALst>
+ <AdsACrf>1</AdsACrf>
+ <AdsANop>0</AdsANop>
+ <AdsANot>0</AdsANot>
+ <AdsLLst>1</AdsLLst>
+ <AdsLmap>1</AdsLmap>
+ <AdsLcgr>1</AdsLcgr>
+ <AdsLsym>1</AdsLsym>
+ <AdsLszi>1</AdsLszi>
+ <AdsLtoi>1</AdsLtoi>
+ <AdsLsun>1</AdsLsun>
+ <AdsLven>1</AdsLven>
+ <AdsLsxf>1</AdsLsxf>
+ <RvctClst>0</RvctClst>
+ <GenPPlst>0</GenPPlst>
+ <AdsCpuType>"Cortex-M4"</AdsCpuType>
+ <RvctDeviceName></RvctDeviceName>
+ <mOS>0</mOS>
+ <uocRom>0</uocRom>
+ <uocRam>0</uocRam>
+ <hadIROM>1</hadIROM>
+ <hadIRAM>1</hadIRAM>
+ <hadXRAM>0</hadXRAM>
+ <uocXRam>0</uocXRam>
+ <RvdsVP>2</RvdsVP>
+ <hadIRAM2>1</hadIRAM2>
+ <hadIROM2>0</hadIROM2>
+ <StupSel>8</StupSel>
+ <useUlib>1</useUlib>
+ <EndSel>0</EndSel>
+ <uLtcg>0</uLtcg>
+ <nSecure>0</nSecure>
+ <RoSelD>3</RoSelD>
+ <RwSelD>3</RwSelD>
+ <CodeSel>0</CodeSel>
+ <OptFeed>0</OptFeed>
+ <NoZi1>0</NoZi1>
+ <NoZi2>0</NoZi2>
+ <NoZi3>0</NoZi3>
+ <NoZi4>0</NoZi4>
+ <NoZi5>0</NoZi5>
+ <Ro1Chk>0</Ro1Chk>
+ <Ro2Chk>0</Ro2Chk>
+ <Ro3Chk>0</Ro3Chk>
+ <Ir1Chk>1</Ir1Chk>
+ <Ir2Chk>0</Ir2Chk>
+ <Ra1Chk>0</Ra1Chk>
+ <Ra2Chk>0</Ra2Chk>
+ <Ra3Chk>0</Ra3Chk>
+ <Im1Chk>1</Im1Chk>
+ <Im2Chk>0</Im2Chk>
+ <OnChipMemories>
+ <Ocm1>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm1>
+ <Ocm2>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm2>
+ <Ocm3>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm3>
+ <Ocm4>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm4>
+ <Ocm5>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm5>
+ <Ocm6>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm6>
+ <IRAM>
+ <Type>0</Type>
+ <StartAddress>0x20000000</StartAddress>
+ <Size>0x30000</Size>
+ </IRAM>
+ <IROM>
+ <Type>1</Type>
+ <StartAddress>0x8000000</StartAddress>
+ <Size>0x300000</Size>
+ </IROM>
+ <XRAM>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </XRAM>
+ <OCR_RVCT1>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT1>
+ <OCR_RVCT2>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT2>
+ <OCR_RVCT3>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT3>
+ <OCR_RVCT4>
+ <Type>1</Type>
+ <StartAddress>0x8000000</StartAddress>
+ <Size>0x300000</Size>
+ </OCR_RVCT4>
+ <OCR_RVCT5>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT5>
+ <OCR_RVCT6>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT6>
+ <OCR_RVCT7>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT7>
+ <OCR_RVCT8>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT8>
+ <OCR_RVCT9>
+ <Type>0</Type>
+ <StartAddress>0x20000000</StartAddress>
+ <Size>0x30000</Size>
+ </OCR_RVCT9>
+ <OCR_RVCT10>
+ <Type>0</Type>
+ <StartAddress>0x10000000</StartAddress>
+ <Size>0x10000</Size>
+ </OCR_RVCT10>
+ </OnChipMemories>
+ <RvctStartVector></RvctStartVector>
+ </ArmAdsMisc>
+ <Cads>
+ <interw>1</interw>
+ <Optim>1</Optim>
+ <oTime>0</oTime>
+ <SplitLS>0</SplitLS>
+ <OneElfS>1</OneElfS>
+ <Strict>0</Strict>
+ <EnumInt>0</EnumInt>
+ <PlainCh>0</PlainCh>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <wLevel>2</wLevel>
+ <uThumb>0</uThumb>
+ <uSurpInc>0</uSurpInc>
+ <uC99>1</uC99>
+ <uGnu>0</uGnu>
+ <useXO>0</useXO>
+ <v6Lang>1</v6Lang>
+ <v6LangP>1</v6LangP>
+ <vShortEn>1</vShortEn>
+ <vShortWch>1</vShortWch>
+ <v6Lto>0</v6Lto>
+ <v6WtE>0</v6WtE>
+ <v6Rtti>0</v6Rtti>
+ <VariousControls>
+ <MiscControls></MiscControls>
+ <Define></Define>
+ <Undefine></Undefine>
+ <IncludePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Include;..\..\..\Library\Firmware\CMSIS\GD\GD32F4xx\Include;..\..\..\Library\Utilities;..\</IncludePath>
+ </VariousControls>
+ </Cads>
+ <Aads>
+ <interw>1</interw>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <thumb>0</thumb>
+ <SplitLS>0</SplitLS>
+ <SwStkChk>0</SwStkChk>
+ <NoWarn>0</NoWarn>
+ <uSurpInc>0</uSurpInc>
+ <useXO>0</useXO>
+ <uClangAs>0</uClangAs>
+ <VariousControls>
+ <MiscControls></MiscControls>
+ <Define></Define>
+ <Undefine></Undefine>
+ <IncludePath></IncludePath>
+ </VariousControls>
+ </Aads>
+ <LDads>
+ <umfTarg>1</umfTarg>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <noStLib>0</noStLib>
+ <RepFail>1</RepFail>
+ <useFile>0</useFile>
+ <TextAddressRange>0x08000000</TextAddressRange>
+ <DataAddressRange>0x20000000</DataAddressRange>
+ <pXoBase></pXoBase>
+ <ScatterFile></ScatterFile>
+ <IncludeLibs></IncludeLibs>
+ <IncludeLibsPath></IncludeLibsPath>
+ <Misc></Misc>
+ <LinkerInputFile></LinkerInputFile>
+ <DisabledWarnings></DisabledWarnings>
+ </LDads>
+ </TargetArmAds>
+ </TargetOption>
+ <Groups>
+ <Group>
+ <GroupName>Application</GroupName>
+ <Files>
+ <File>
+ <FileName>main.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\main.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_it.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\gd32f4xx_it.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>CMSIS</GroupName>
+ <Files>
+ <File>
+ <FileName>system_gd32f4xx.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\CMSIS\GD\GD32F4xx\Source\system_gd32f4xx.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>GD32F4xx_Peripherals</GroupName>
+ <Files>
+ <File>
+ <FileName>gd32f4xx_adc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_adc.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_can.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_can.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_crc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_crc.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_ctc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_ctc.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_dac.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_dac.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_dbg.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_dbg.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_dci.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_dci.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_dma.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_dma.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_enet.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_enet.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_exmc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_exmc.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_exti.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_exti.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_fmc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_fmc.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_fwdgt.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_fwdgt.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_gpio.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_gpio.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_i2c.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_i2c.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_ipa.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_ipa.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_iref.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_iref.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_misc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_misc.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_pmu.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_pmu.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_rcu.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_rcu.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_rtc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_rtc.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_sdio.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_sdio.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_spi.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_spi.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_syscfg.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_syscfg.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_timer.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_timer.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_tli.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_tli.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_trng.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_trng.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_usart.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_usart.c</FilePath>
+ </File>
+ <File>
+ <FileName>gd32f4xx_wwdgt.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Firmware\GD32F4xx_standard_peripheral\Source\gd32f4xx_wwdgt.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>GD32F4xx_EVAL</GroupName>
+ <Files>
+ <File>
+ <FileName>gd32f450z_eval.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\..\Library\Utilities\gd32f450z_eval.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>Startup</GroupName>
+ <Files>
+ <File>
+ <FileName>startup_gd32f4xx.s</FileName>
+ <FileType>2</FileType>
+ <FilePath>..\..\..\Library\Firmware\CMSIS\GD\GD32F4xx\Source\ARM\startup_gd32f4xx.s</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>Doc</GroupName>
+ <Files>
+ <File>
+ <FileName>readme.txt</FileName>
+ <FileType>5</FileType>
+ <FilePath>..\readme.txt</FilePath>
+ </File>
+ </Files>
+ </Group>
+ </Groups>
+ </Target>
+ </Targets>
+
+</Project>
diff --git a/bsp/gd32/arm/gd32470z-lckfb/template.uvprojx b/bsp/gd32/arm/gd32470z-lckfb/template.uvprojx
new file mode 100644
index 0000000000..6b18f2e8f2
--- /dev/null
+++ b/bsp/gd32/arm/gd32470z-lckfb/template.uvprojx
@@ -0,0 +1,412 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
+
+ <SchemaVersion>2.1</SchemaVersion>
+
+ <Header>### uVision Project, (C) Keil Software</Header>
+
+ <Targets>
+ <Target>
+ <TargetName>rt-thread</TargetName>
+ <ToolsetNumber>0x4</ToolsetNumber>
+ <ToolsetName>ARM-ADS</ToolsetName>
+ <uAC6>0</uAC6>
+ <TargetOption>
+ <TargetCommonOption>
+ <Device>GD32F470ZG</Device>
+ <Vendor>GigaDevice</Vendor>
+ <PackID>GigaDevice.GD32F4xx_DFP.3.0.0</PackID>
+ <PackURL>http://gd32mcu.com/data/documents/pack/</PackURL>
+ <Cpu>IRAM(0x20000000,0x070000) IRAM2(0x10000000,0x010000) IROM(0x08000000,0x0100000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
+ <FlashUtilSpec></FlashUtilSpec>
+ <StartupFile></StartupFile>
+ <FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0GD32F4xx_1MB -FS08000000 -FL0100000 -FP0($$Device:GD32F470ZG$Flash\GD32F4xx_1MB.FLM))</FlashDriverDll>
+ <DeviceId>0</DeviceId>
+ <RegisterFile>$$Device:GD32F470ZG$Device\F4XX\Include\gd32f4xx.h</RegisterFile>
+ <MemoryEnv></MemoryEnv>
+ <Cmp></Cmp>
+ <Asm></Asm>
+ <Linker></Linker>
+ <OHString></OHString>
+ <InfinionOptionDll></InfinionOptionDll>
+ <SLE66CMisc></SLE66CMisc>
+ <SLE66AMisc></SLE66AMisc>
+ <SLE66LinkerMisc></SLE66LinkerMisc>
+ <SFDFile>$$Device:GD32F470ZG$SVD\GD32F4xx.svd</SFDFile>
+ <bCustSvd>0</bCustSvd>
+ <UseEnv>0</UseEnv>
+ <BinPath></BinPath>
+ <IncludePath></IncludePath>
+ <LibPath></LibPath>
+ <RegisterFilePath></RegisterFilePath>
+ <DBRegisterFilePath></DBRegisterFilePath>
+ <TargetStatus>
+ <Error>0</Error>
+ <ExitCodeStop>0</ExitCodeStop>
+ <ButtonStop>0</ButtonStop>
+ <NotGenerated>0</NotGenerated>
+ <InvalidFlash>1</InvalidFlash>
+ </TargetStatus>
+ <OutputDirectory>.\build\</OutputDirectory>
+ <OutputName>rtthread</OutputName>
+ <CreateExecutable>1</CreateExecutable>
+ <CreateLib>0</CreateLib>
+ <CreateHexFile>0</CreateHexFile>
+ <DebugInformation>1</DebugInformation>
+ <BrowseInformation>0</BrowseInformation>
+ <ListingPath>.\build\</ListingPath>
+ <HexFormatSelection>1</HexFormatSelection>
+ <Merge32K>0</Merge32K>
+ <CreateBatchFile>0</CreateBatchFile>
+ <BeforeCompile>
+ <RunUserProg1>0</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name></UserProg1Name>
+ <UserProg2Name></UserProg2Name>
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ <nStopU1X>0</nStopU1X>
+ <nStopU2X>0</nStopU2X>
+ </BeforeCompile>
+ <BeforeMake>
+ <RunUserProg1>0</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name></UserProg1Name>
+ <UserProg2Name></UserProg2Name>
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ <nStopB1X>0</nStopB1X>
+ <nStopB2X>0</nStopB2X>
+ </BeforeMake>
+ <AfterMake>
+ <RunUserProg1>1</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name>fromelf --bin !L --output rtthread.bin</UserProg1Name>
+ <UserProg2Name></UserProg2Name>
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ <nStopA1X>0</nStopA1X>
+ <nStopA2X>0</nStopA2X>
+ </AfterMake>
+ <SelectedForBatchBuild>0</SelectedForBatchBuild>
+ <SVCSIdString></SVCSIdString>
+ </TargetCommonOption>
+ <CommonProperty>
+ <UseCPPCompiler>0</UseCPPCompiler>
+ <RVCTCodeConst>0</RVCTCodeConst>
+ <RVCTZI>0</RVCTZI>
+ <RVCTOtherData>0</RVCTOtherData>
+ <ModuleSelection>0</ModuleSelection>
+ <IncludeInBuild>1</IncludeInBuild>
+ <AlwaysBuild>0</AlwaysBuild>
+ <GenerateAssemblyFile>0</GenerateAssemblyFile>
+ <AssembleAssemblyFile>0</AssembleAssemblyFile>
+ <PublicsOnly>0</PublicsOnly>
+ <StopOnExitCode>3</StopOnExitCode>
+ <CustomArgument></CustomArgument>
+ <IncludeLibraryModules></IncludeLibraryModules>
+ <ComprImg>1</ComprImg>
+ </CommonProperty>
+ <DllOption>
+ <SimDllName>SARMCM3.DLL</SimDllName>
+ <SimDllArguments> -REMAP -MPU</SimDllArguments>
+ <SimDlgDll>DCM.DLL</SimDlgDll>
+ <SimDlgDllArguments>-pCM4</SimDlgDllArguments>
+ <TargetDllName>SARMCM3.DLL</TargetDllName>
+ <TargetDllArguments> -MPU</TargetDllArguments>
+ <TargetDlgDll>TCM.DLL</TargetDlgDll>
+ <TargetDlgDllArguments>-pCM4</TargetDlgDllArguments>
+ </DllOption>
+ <DebugOption>
+ <OPTHX>
+ <HexSelection>1</HexSelection>
+ <HexRangeLowAddress>0</HexRangeLowAddress>
+ <HexRangeHighAddress>0</HexRangeHighAddress>
+ <HexOffset>0</HexOffset>
+ <Oh166RecLen>16</Oh166RecLen>
+ </OPTHX>
+ </DebugOption>
+ <Utilities>
+ <Flash1>
+ <UseTargetDll>1</UseTargetDll>
+ <UseExternalTool>0</UseExternalTool>
+ <RunIndependent>0</RunIndependent>
+ <UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
+ <Capability>1</Capability>
+ <DriverSelection>4096</DriverSelection>
+ </Flash1>
+ <bUseTDR>1</bUseTDR>
+ <Flash2>BIN\UL2CM3.DLL</Flash2>
+ <Flash3></Flash3>
+ <Flash4></Flash4>
+ <pFcarmOut></pFcarmOut>
+ <pFcarmGrp></pFcarmGrp>
+ <pFcArmRoot></pFcArmRoot>
+ <FcArmLst>0</FcArmLst>
+ </Utilities>
+ <TargetArmAds>
+ <ArmAdsMisc>
+ <GenerateListings>0</GenerateListings>
+ <asHll>1</asHll>
+ <asAsm>1</asAsm>
+ <asMacX>1</asMacX>
+ <asSyms>1</asSyms>
+ <asFals>1</asFals>
+ <asDbgD>1</asDbgD>
+ <asForm>1</asForm>
+ <ldLst>0</ldLst>
+ <ldmm>1</ldmm>
+ <ldXref>1</ldXref>
+ <BigEnd>0</BigEnd>
+ <AdsALst>1</AdsALst>
+ <AdsACrf>1</AdsACrf>
+ <AdsANop>0</AdsANop>
+ <AdsANot>0</AdsANot>
+ <AdsLLst>1</AdsLLst>
+ <AdsLmap>1</AdsLmap>
+ <AdsLcgr>1</AdsLcgr>
+ <AdsLsym>1</AdsLsym>
+ <AdsLszi>1</AdsLszi>
+ <AdsLtoi>1</AdsLtoi>
+ <AdsLsun>1</AdsLsun>
+ <AdsLven>1</AdsLven>
+ <AdsLsxf>1</AdsLsxf>
+ <RvctClst>0</RvctClst>
+ <GenPPlst>0</GenPPlst>
+ <AdsCpuType>"Cortex-M4"</AdsCpuType>
+ <RvctDeviceName></RvctDeviceName>
+ <mOS>0</mOS>
+ <uocRom>0</uocRom>
+ <uocRam>0</uocRam>
+ <hadIROM>1</hadIROM>
+ <hadIRAM>1</hadIRAM>
+ <hadXRAM>0</hadXRAM>
+ <uocXRam>0</uocXRam>
+ <RvdsVP>2</RvdsVP>
+ <RvdsMve>0</RvdsMve>
+ <RvdsCdeCp>0</RvdsCdeCp>
+ <hadIRAM2>1</hadIRAM2>
+ <hadIROM2>0</hadIROM2>
+ <StupSel>8</StupSel>
+ <useUlib>0</useUlib>
+ <EndSel>0</EndSel>
+ <uLtcg>0</uLtcg>
+ <nSecure>0</nSecure>
+ <RoSelD>3</RoSelD>
+ <RwSelD>4</RwSelD>
+ <CodeSel>0</CodeSel>
+ <OptFeed>0</OptFeed>
+ <NoZi1>0</NoZi1>
+ <NoZi2>0</NoZi2>
+ <NoZi3>0</NoZi3>
+ <NoZi4>0</NoZi4>
+ <NoZi5>0</NoZi5>
+ <Ro1Chk>0</Ro1Chk>
+ <Ro2Chk>0</Ro2Chk>
+ <Ro3Chk>0</Ro3Chk>
+ <Ir1Chk>1</Ir1Chk>
+ <Ir2Chk>0</Ir2Chk>
+ <Ra1Chk>0</Ra1Chk>
+ <Ra2Chk>0</Ra2Chk>
+ <Ra3Chk>0</Ra3Chk>
+ <Im1Chk>1</Im1Chk>
+ <Im2Chk>0</Im2Chk>
+ <OnChipMemories>
+ <Ocm1>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm1>
+ <Ocm2>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm2>
+ <Ocm3>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm3>
+ <Ocm4>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm4>
+ <Ocm5>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm5>
+ <Ocm6>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm6>
+ <IRAM>
+ <Type>0</Type>
+ <StartAddress>0x20000000</StartAddress>
+ <Size>0x70000</Size>
+ </IRAM>
+ <IROM>
+ <Type>1</Type>
+ <StartAddress>0x8000000</StartAddress>
+ <Size>0x100000</Size>
+ </IROM>
+ <XRAM>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </XRAM>
+ <OCR_RVCT1>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT1>
+ <OCR_RVCT2>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT2>
+ <OCR_RVCT3>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT3>
+ <OCR_RVCT4>
+ <Type>1</Type>
+ <StartAddress>0x8000000</StartAddress>
+ <Size>0x100000</Size>
+ </OCR_RVCT4>
+ <OCR_RVCT5>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT5>
+ <OCR_RVCT6>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT6>
+ <OCR_RVCT7>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT7>
+ <OCR_RVCT8>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT8>
+ <OCR_RVCT9>
+ <Type>0</Type>
+ <StartAddress>0x20000000</StartAddress>
+ <Size>0x70000</Size>
+ </OCR_RVCT9>
+ <OCR_RVCT10>
+ <Type>0</Type>
+ <StartAddress>0x10000000</StartAddress>
+ <Size>0x10000</Size>
+ </OCR_RVCT10>
+ </OnChipMemories>
+ <RvctStartVector></RvctStartVector>
+ </ArmAdsMisc>
+ <Cads>
+ <interw>1</interw>
+ <Optim>4</Optim>
+ <oTime>0</oTime>
+ <SplitLS>0</SplitLS>
+ <OneElfS>1</OneElfS>
+ <Strict>0</Strict>
+ <EnumInt>0</EnumInt>
+ <PlainCh>0</PlainCh>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <wLevel>0</wLevel>
+ <uThumb>0</uThumb>
+ <uSurpInc>0</uSurpInc>
+ <uC99>1</uC99>
+ <uGnu>0</uGnu>
+ <useXO>0</useXO>
+ <v6Lang>1</v6Lang>
+ <v6LangP>1</v6LangP>
+ <vShortEn>1</vShortEn>
+ <vShortWch>1</vShortWch>
+ <v6Lto>0</v6Lto>
+ <v6WtE>0</v6WtE>
+ <v6Rtti>0</v6Rtti>
+ <VariousControls>
+ <MiscControls></MiscControls>
+ <Define></Define>
+ <Undefine></Undefine>
+ <IncludePath></IncludePath>
+ </VariousControls>
+ </Cads>
+ <Aads>
+ <interw>1</interw>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <thumb>0</thumb>
+ <SplitLS>0</SplitLS>
+ <SwStkChk>0</SwStkChk>
+ <NoWarn>0</NoWarn>
+ <uSurpInc>0</uSurpInc>
+ <useXO>0</useXO>
+ <ClangAsOpt>4</ClangAsOpt>
+ <VariousControls>
+ <MiscControls></MiscControls>
+ <Define></Define>
+ <Undefine></Undefine>
+ <IncludePath></IncludePath>
+ </VariousControls>
+ </Aads>
+ <LDads>
+ <umfTarg>1</umfTarg>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <noStLib>0</noStLib>
+ <RepFail>1</RepFail>
+ <useFile>0</useFile>
+ <TextAddressRange>0x08000000</TextAddressRange>
+ <DataAddressRange>0x20000000</DataAddressRange>
+ <pXoBase></pXoBase>
+ <ScatterFile>.\gd32_rom.ld</ScatterFile>
+ <IncludeLibs></IncludeLibs>
+ <IncludeLibsPath></IncludeLibsPath>
+ <Misc></Misc>
+ <LinkerInputFile></LinkerInputFile>
+ <DisabledWarnings></DisabledWarnings>
+ </LDads>
+ </TargetArmAds>
+ </TargetOption>
+ <Groups>
+ <Group>
+ <GroupName>::CMSIS</GroupName>
+ </Group>
+ </Groups>
+ </Target>
+ </Targets>
+
+ <RTE>
+ <apis/>
+ <components>
+ <component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.5.0" condition="ARMv6_7_8-M Device">
+ <package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/>
+ <targetInfos>
+ <targetInfo name="rt-thread"/>
+ </targetInfos>
+ </component>
+ </components>
+ <files/>
+ </RTE>
+
+ <LayerInfo>
+ <Layers>
+ <Layer>
+ <LayName>&lt;Project Info&gt;</LayName>
+ <LayTarg>0</LayTarg>
+ <LayPrjMark>1</LayPrjMark>
+ </Layer>
+ </Layers>
+ </LayerInfo>
+
+</Project>
diff --git a/bsp/gd32/arm/libraries/.ignore_format.yml b/bsp/gd32/arm/libraries/.ignore_format.yml
new file mode 100644
index 0000000000..eecf5a711f
--- /dev/null
+++ b/bsp/gd32/arm/libraries/.ignore_format.yml
@@ -0,0 +1,9 @@
+# files format check exclude path, please follow the instructions below to modify;
+# If you need to exclude an entire folder, add the folder path in dir_path;
+# If you need to exclude a file, add the path to the file in file_path.
+
+dir_path:
+- GD32F10x_Firmware_Library
+- GD32F20x_Firmware_Library
+- GD32F30x_Firmware_Library
+- GD32F4xx_Firmware_Library
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Include/gd32f4xx.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Include/gd32f4xx.h
index a901975bbd..de1d1364f7 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Include/gd32f4xx.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Include/gd32f4xx.h
@@ -1,7 +1,7 @@
/*!
\file gd32f4xx.h
\brief general definitions for GD32F4xx
-
+
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
@@ -10,27 +10,27 @@
/*
Copyright (c) 2020, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -39,16 +39,19 @@ OF SUCH DAMAGE.
#ifdef __cplusplus
extern "C" {
-#endif
+#endif
/* define GD32F4xx */
-#if !defined (GD32F450) && !defined (GD32F405) && !defined (GD32F407)
+#if !defined (GD32F450) && !defined (GD32F405) && !defined (GD32F407) && !defined (GD32F470) && !defined (GD32F425) && !defined (GD32F427)
/* #define GD32F450 */
/* #define GD32F405 */
/* #define GD32F407 */
+ /* #define GD32F470 */
+ /* #define GD32F425 */
+ /* #define GD32F427 */
#endif /* define GD32F4xx */
-
-#if !defined (GD32F450) && !defined (GD32F405) && !defined (GD32F407)
+
+#if !defined (GD32F450) && !defined (GD32F405) && !defined (GD32F407) && !defined (GD32F470) && !defined (GD32F425) && !defined (GD32F427)
#error "Please select the target GD32F4xx device in gd32f4xx.h file"
#endif /* undefine GD32F4xx tip */
@@ -63,7 +66,7 @@ OF SUCH DAMAGE.
#endif /* high speed crystal oscillator startup timeout */
/* define value of internal 16MHz RC oscillator (IRC16M) in Hz */
-#if !defined (IRC16M_VALUE)
+#if !defined (IRC16M_VALUE)
#define IRC16M_VALUE ((uint32_t)16000000)
#endif /* internal 16MHz RC oscillator value */
@@ -73,12 +76,12 @@ OF SUCH DAMAGE.
#endif /* internal 16MHz RC oscillator startup timeout */
/* define value of internal 32KHz RC oscillator(IRC32K) in Hz */
-#if !defined (IRC32K_VALUE)
+#if !defined (IRC32K_VALUE)
#define IRC32K_VALUE ((uint32_t)32000)
#endif /* internal 32KHz RC oscillator value */
/* define value of low speed crystal oscillator (LXTAL)in Hz */
-#if !defined (LXTAL_VALUE)
+#if !defined (LXTAL_VALUE)
#define LXTAL_VALUE ((uint32_t)32768)
#endif /* low speed crystal oscillator value */
@@ -89,7 +92,7 @@ OF SUCH DAMAGE.
#define __GD32F4xx_STDPERIPH_VERSION_MAIN (0x03) /*!< [31:24] main version */
#define __GD32F4xx_STDPERIPH_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
#define __GD32F4xx_STDPERIPH_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
-#define __GD32F4xx_STDPERIPH_VERSION_RC (0x00) /*!< [7:0] release candidate */
+#define __GD32F4xx_STDPERIPH_VERSION_RC (0x00) /*!< [7:0] release candidate */
#define __GD32F4xx_STDPERIPH_VERSION ((__GD32F4xx_STDPERIPH_VERSION_MAIN << 24)\
|(__GD32F4xx_STDPERIPH_VERSION_SUB1 << 16)\
|(__GD32F4xx_STDPERIPH_VERSION_SUB2 << 8)\
@@ -162,8 +165,8 @@ typedef enum IRQn
TIMER7_TRG_CMT_TIMER13_IRQn = 45, /*!< TIMER7 trigger and commutation and TIMER13 interrupts */
TIMER7_Channel_IRQn = 46, /*!< TIMER7 channel capture compare interrupt */
DMA0_Channel7_IRQn = 47, /*!< DMA0 channel7 interrupt */
-
-#if defined (GD32F450)
+
+#if defined (GD32F450) || defined (GD32F470)
EXMC_IRQn = 48, /*!< EXMC interrupt */
SDIO_IRQn = 49, /*!< SDIO interrupt */
TIMER4_IRQn = 50, /*!< TIMER4 interrupt */
@@ -205,9 +208,9 @@ typedef enum IRQn
TLI_IRQn = 88, /*!< TLI interrupt */
TLI_ER_IRQn = 89, /*!< TLI error interrupt */
IPA_IRQn = 90, /*!< IPA interrupt */
-#endif /* GD32F450 */
+#endif /* GD32F450 and GD32F470 */
-#if defined (GD32F405)
+#if defined (GD32F405) || defined (GD32F425)
SDIO_IRQn = 49, /*!< SDIO interrupt */
TIMER4_IRQn = 50, /*!< TIMER4 interrupt */
SPI2_IRQn = 51, /*!< SPI2 interrupt */
@@ -238,9 +241,9 @@ typedef enum IRQn
DCI_IRQn = 78, /*!< DCI interrupt */
TRNG_IRQn = 80, /*!< TRNG interrupt */
FPU_IRQn = 81, /*!< FPU interrupt */
-#endif /* GD32F405 */
+#endif /* GD32F405 and GD32F425 */
-#if defined (GD32F407)
+#if defined (GD32F407) || defined (GD32F427)
EXMC_IRQn = 48, /*!< EXMC interrupt */
SDIO_IRQn = 49, /*!< SDIO interrupt */
TIMER4_IRQn = 50, /*!< TIMER4 interrupt */
@@ -274,7 +277,7 @@ typedef enum IRQn
DCI_IRQn = 78, /*!< DCI interrupt */
TRNG_IRQn = 80, /*!< TRNG interrupt */
FPU_IRQn = 81, /*!< FPU interrupt */
-#endif /* GD32F407 */
+#endif /* GD32F407 and GD32F427 */
} IRQn_Type;
@@ -285,7 +288,6 @@ typedef enum IRQn
/* enum definitions */
typedef enum {DISABLE = 0, ENABLE = !DISABLE} EventStatus, ControlStatus;
-typedef enum {FALSE = 0, TRUE = !FALSE} bool;
typedef enum {RESET = 0, SET = !RESET} FlagStatus;
typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrStatus;
@@ -294,7 +296,7 @@ typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrStatus;
#define REG16(addr) (*(volatile uint16_t *)(uint32_t)(addr))
#define REG8(addr) (*(volatile uint8_t *)(uint32_t)(addr))
#define BIT(x) ((uint32_t)((uint32_t)0x01U<<(x)))
-#define BITS(start, end) ((0xFFFFFFFFUL << (start)) & (0xFFFFFFFFUL >> (31U - (uint32_t)(end))))
+#define BITS(start, end) ((0xFFFFFFFFUL << (start)) & (0xFFFFFFFFUL >> (31U - (uint32_t)(end))))
#define GET_BITS(regval, start, end) (((regval) & BITS((start),(end))) >> (start))
/* main flash and SRAM memory map */
@@ -355,12 +357,12 @@ typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrStatus;
/* define marco USE_STDPERIPH_DRIVER */
#if !defined USE_STDPERIPH_DRIVER
#define USE_STDPERIPH_DRIVER
-#endif
+#endif
#ifdef USE_STDPERIPH_DRIVER
#include "gd32f4xx_libopt.h"
#endif /* USE_STDPERIPH_DRIVER */
-#ifdef cplusplus
+#ifdef __cplusplus
}
#endif
-#endif
+#endif
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/ARM/startup_gd32f405_425.s b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/ARM/startup_gd32f405_425.s
new file mode 100644
index 0000000000..2e5eba5f0d
--- /dev/null
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/ARM/startup_gd32f405_425.s
@@ -0,0 +1,423 @@
+;/*!
+; \file startup_gd32f405_425.s
+; \brief start up file
+;
+; \version 2016-08-15, V1.0.0, firmware for GD32F4xx
+; \version 2018-12-12, V2.0.0, firmware for GD32F4xx
+; \version 2020-09-30, V2.1.0, firmware for GD32F4xx
+; \version 2022-03-09, V3.0.0, firmware for GD32F4xx
+;*/
+;
+;/*
+; Copyright (c) 2022, GigaDevice Semiconductor Inc.
+;
+; Redistribution and use in source and binary forms, with or without modification,
+;are permitted provided that the following conditions are met:
+;
+; 1. Redistributions of source code must retain the above copyright notice, this
+; list of conditions and the following disclaimer.
+; 2. Redistributions in binary form must reproduce the above copyright notice,
+; this list of conditions and the following disclaimer in the documentation
+; and/or other materials provided with the distribution.
+; 3. Neither the name of the copyright holder nor the names of its contributors
+; may be used to endorse or promote products derived from this software without
+; specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+;AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+;IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+;INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+;NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+;PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+;WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+;ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+;OF SUCH DAMAGE.
+;*/
+
+; <h> Stack Configuration
+; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
+; </h>
+
+Stack_Size EQU 0x00000400
+
+ AREA STACK, NOINIT, READWRITE, ALIGN=3
+Stack_Mem SPACE Stack_Size
+__initial_sp
+
+
+; <h> Heap Configuration
+; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
+; </h>
+
+Heap_Size EQU 0x00000400
+
+ AREA HEAP, NOINIT, READWRITE, ALIGN=3
+__heap_base
+Heap_Mem SPACE Heap_Size
+__heap_limit
+
+ PRESERVE8
+ THUMB
+
+; /* reset Vector Mapped to at Address 0 */
+ AREA RESET, DATA, READONLY
+ EXPORT __Vectors
+ EXPORT __Vectors_End
+ EXPORT __Vectors_Size
+
+__Vectors DCD __initial_sp ; Top of Stack
+ DCD Reset_Handler ; Reset Handler
+ DCD NMI_Handler ; NMI Handler
+ DCD HardFault_Handler ; Hard Fault Handler
+ DCD MemManage_Handler ; MPU Fault Handler
+ DCD BusFault_Handler ; Bus Fault Handler
+ DCD UsageFault_Handler ; Usage Fault Handler
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD SVC_Handler ; SVCall Handler
+ DCD DebugMon_Handler ; Debug Monitor Handler
+ DCD 0 ; Reserved
+ DCD PendSV_Handler ; PendSV Handler
+ DCD SysTick_Handler ; SysTick Handler
+
+; /* external interrupts handler */
+ DCD WWDGT_IRQHandler ; 16:Window Watchdog Timer
+ DCD LVD_IRQHandler ; 17:LVD through EXTI Line detect
+ DCD TAMPER_STAMP_IRQHandler ; 18:Tamper and TimeStamp through EXTI Line detect
+ DCD RTC_WKUP_IRQHandler ; 19:RTC Wakeup through EXTI Line
+ DCD FMC_IRQHandler ; 20:FMC
+ DCD RCU_CTC_IRQHandler ; 21:RCU and CTC
+ DCD EXTI0_IRQHandler ; 22:EXTI Line 0
+ DCD EXTI1_IRQHandler ; 23:EXTI Line 1
+ DCD EXTI2_IRQHandler ; 24:EXTI Line 2
+ DCD EXTI3_IRQHandler ; 25:EXTI Line 3
+ DCD EXTI4_IRQHandler ; 26:EXTI Line 4
+ DCD DMA0_Channel0_IRQHandler ; 27:DMA0 Channel0
+ DCD DMA0_Channel1_IRQHandler ; 28:DMA0 Channel1
+ DCD DMA0_Channel2_IRQHandler ; 29:DMA0 Channel2
+ DCD DMA0_Channel3_IRQHandler ; 30:DMA0 Channel3
+ DCD DMA0_Channel4_IRQHandler ; 31:DMA0 Channel4
+ DCD DMA0_Channel5_IRQHandler ; 32:DMA0 Channel5
+ DCD DMA0_Channel6_IRQHandler ; 33:DMA0 Channel6
+ DCD ADC_IRQHandler ; 34:ADC
+ DCD CAN0_TX_IRQHandler ; 35:CAN0 TX
+ DCD CAN0_RX0_IRQHandler ; 36:CAN0 RX0
+ DCD CAN0_RX1_IRQHandler ; 37:CAN0 RX1
+ DCD CAN0_EWMC_IRQHandler ; 38:CAN0 EWMC
+ DCD EXTI5_9_IRQHandler ; 39:EXTI5 to EXTI9
+ DCD TIMER0_BRK_TIMER8_IRQHandler ; 40:TIMER0 Break and TIMER8
+ DCD TIMER0_UP_TIMER9_IRQHandler ; 41:TIMER0 Update and TIMER9
+ DCD TIMER0_TRG_CMT_TIMER10_IRQHandler ; 42:TIMER0 Trigger and Commutation and TIMER10
+ DCD TIMER0_Channel_IRQHandler ; 43:TIMER0 Channel Capture Compare
+ DCD TIMER1_IRQHandler ; 44:TIMER1
+ DCD TIMER2_IRQHandler ; 45:TIMER2
+ DCD TIMER3_IRQHandler ; 46:TIMER3
+ DCD I2C0_EV_IRQHandler ; 47:I2C0 Event
+ DCD I2C0_ER_IRQHandler ; 48:I2C0 Error
+ DCD I2C1_EV_IRQHandler ; 49:I2C1 Event
+ DCD I2C1_ER_IRQHandler ; 50:I2C1 Error
+ DCD SPI0_IRQHandler ; 51:SPI0
+ DCD SPI1_IRQHandler ; 52:SPI1
+ DCD USART0_IRQHandler ; 53:USART0
+ DCD USART1_IRQHandler ; 54:USART1
+ DCD USART2_IRQHandler ; 55:USART2
+ DCD EXTI10_15_IRQHandler ; 56:EXTI10 to EXTI15
+ DCD RTC_Alarm_IRQHandler ; 57:RTC Alarm
+ DCD USBFS_WKUP_IRQHandler ; 58:USBFS Wakeup
+ DCD TIMER7_BRK_TIMER11_IRQHandler ; 59:TIMER7 Break and TIMER11
+ DCD TIMER7_UP_TIMER12_IRQHandler ; 60:TIMER7 Update and TIMER12
+ DCD TIMER7_TRG_CMT_TIMER13_IRQHandler ; 61:TIMER7 Trigger and Commutation and TIMER13
+ DCD TIMER7_Channel_IRQHandler ; 62:TIMER7 Channel Capture Compare
+ DCD DMA0_Channel7_IRQHandler ; 63:DMA0 Channel7
+ DCD 0 ; 64:Reserved
+ DCD SDIO_IRQHandler ; 65:SDIO
+ DCD TIMER4_IRQHandler ; 66:TIMER4
+ DCD SPI2_IRQHandler ; 67:SPI2
+ DCD UART3_IRQHandler ; 68:UART3
+ DCD UART4_IRQHandler ; 69:UART4
+ DCD TIMER5_DAC_IRQHandler ; 70:TIMER5 and DAC0 DAC1 Underrun error
+ DCD TIMER6_IRQHandler ; 71:TIMER6
+ DCD DMA1_Channel0_IRQHandler ; 72:DMA1 Channel0
+ DCD DMA1_Channel1_IRQHandler ; 73:DMA1 Channel1
+ DCD DMA1_Channel2_IRQHandler ; 74:DMA1 Channel2
+ DCD DMA1_Channel3_IRQHandler ; 75:DMA1 Channel3
+ DCD DMA1_Channel4_IRQHandler ; 76:DMA1 Channel4
+ DCD 0 ; 77:Reserved
+ DCD 0 ; 78:Reserved
+ DCD CAN1_TX_IRQHandler ; 79:CAN1 TX
+ DCD CAN1_RX0_IRQHandler ; 80:CAN1 RX0
+ DCD CAN1_RX1_IRQHandler ; 81:CAN1 RX1
+ DCD CAN1_EWMC_IRQHandler ; 82:CAN1 EWMC
+ DCD USBFS_IRQHandler ; 83:USBFS
+ DCD DMA1_Channel5_IRQHandler ; 84:DMA1 Channel5
+ DCD DMA1_Channel6_IRQHandler ; 85:DMA1 Channel6
+ DCD DMA1_Channel7_IRQHandler ; 86:DMA1 Channel7
+ DCD USART5_IRQHandler ; 87:USART5
+ DCD I2C2_EV_IRQHandler ; 88:I2C2 Event
+ DCD I2C2_ER_IRQHandler ; 89:I2C2 Error
+ DCD USBHS_EP1_Out_IRQHandler ; 90:USBHS Endpoint 1 Out
+ DCD USBHS_EP1_In_IRQHandler ; 91:USBHS Endpoint 1 in
+ DCD USBHS_WKUP_IRQHandler ; 92:USBHS Wakeup through EXTI Line
+ DCD USBHS_IRQHandler ; 93:USBHS
+ DCD DCI_IRQHandler ; 94:DCI
+ DCD 0 ; 95:Reserved
+ DCD TRNG_IRQHandler ; 96:TRNG
+ DCD FPU_IRQHandler ; 97:FPU
+
+__Vectors_End
+
+__Vectors_Size EQU __Vectors_End - __Vectors
+
+ AREA |.text|, CODE, READONLY
+
+;/* reset Handler */
+Reset_Handler PROC
+ EXPORT Reset_Handler [WEAK]
+ IMPORT SystemInit
+ IMPORT __main
+ LDR R0, =SystemInit
+ BLX R0
+ LDR R0, =__main
+ BX R0
+ ENDP
+
+;/* dummy Exception Handlers */
+NMI_Handler PROC
+ EXPORT NMI_Handler [WEAK]
+ B .
+ ENDP
+HardFault_Handler\
+ PROC
+ EXPORT HardFault_Handler [WEAK]
+ B .
+ ENDP
+MemManage_Handler\
+ PROC
+ EXPORT MemManage_Handler [WEAK]
+ B .
+ ENDP
+BusFault_Handler\
+ PROC
+ EXPORT BusFault_Handler [WEAK]
+ B .
+ ENDP
+UsageFault_Handler\
+ PROC
+ EXPORT UsageFault_Handler [WEAK]
+ B .
+ ENDP
+SVC_Handler PROC
+ EXPORT SVC_Handler [WEAK]
+ B .
+ ENDP
+DebugMon_Handler\
+ PROC
+ EXPORT DebugMon_Handler [WEAK]
+ B .
+ ENDP
+PendSV_Handler\
+ PROC
+ EXPORT PendSV_Handler [WEAK]
+ B .
+ ENDP
+SysTick_Handler\
+ PROC
+ EXPORT SysTick_Handler [WEAK]
+ B .
+ ENDP
+
+Default_Handler PROC
+; /* external interrupts handler */
+ EXPORT WWDGT_IRQHandler [WEAK]
+ EXPORT LVD_IRQHandler [WEAK]
+ EXPORT TAMPER_STAMP_IRQHandler [WEAK]
+ EXPORT RTC_WKUP_IRQHandler [WEAK]
+ EXPORT FMC_IRQHandler [WEAK]
+ EXPORT RCU_CTC_IRQHandler [WEAK]
+ EXPORT EXTI0_IRQHandler [WEAK]
+ EXPORT EXTI1_IRQHandler [WEAK]
+ EXPORT EXTI2_IRQHandler [WEAK]
+ EXPORT EXTI3_IRQHandler [WEAK]
+ EXPORT EXTI4_IRQHandler [WEAK]
+ EXPORT DMA0_Channel0_IRQHandler [WEAK]
+ EXPORT DMA0_Channel1_IRQHandler [WEAK]
+ EXPORT DMA0_Channel2_IRQHandler [WEAK]
+ EXPORT DMA0_Channel3_IRQHandler [WEAK]
+ EXPORT DMA0_Channel4_IRQHandler [WEAK]
+ EXPORT DMA0_Channel5_IRQHandler [WEAK]
+ EXPORT DMA0_Channel6_IRQHandler [WEAK]
+ EXPORT ADC_IRQHandler [WEAK]
+ EXPORT CAN0_TX_IRQHandler [WEAK]
+ EXPORT CAN0_RX0_IRQHandler [WEAK]
+ EXPORT CAN0_RX1_IRQHandler [WEAK]
+ EXPORT CAN0_EWMC_IRQHandler [WEAK]
+ EXPORT EXTI5_9_IRQHandler [WEAK]
+ EXPORT TIMER0_BRK_TIMER8_IRQHandler [WEAK]
+ EXPORT TIMER0_UP_TIMER9_IRQHandler [WEAK]
+ EXPORT TIMER0_TRG_CMT_TIMER10_IRQHandler [WEAK]
+ EXPORT TIMER0_Channel_IRQHandler [WEAK]
+ EXPORT TIMER1_IRQHandler [WEAK]
+ EXPORT TIMER2_IRQHandler [WEAK]
+ EXPORT TIMER3_IRQHandler [WEAK]
+ EXPORT I2C0_EV_IRQHandler [WEAK]
+ EXPORT I2C0_ER_IRQHandler [WEAK]
+ EXPORT I2C1_EV_IRQHandler [WEAK]
+ EXPORT I2C1_ER_IRQHandler [WEAK]
+ EXPORT SPI0_IRQHandler [WEAK]
+ EXPORT SPI1_IRQHandler [WEAK]
+ EXPORT USART0_IRQHandler [WEAK]
+ EXPORT USART1_IRQHandler [WEAK]
+ EXPORT USART2_IRQHandler [WEAK]
+ EXPORT EXTI10_15_IRQHandler [WEAK]
+ EXPORT RTC_Alarm_IRQHandler [WEAK]
+ EXPORT USBFS_WKUP_IRQHandler [WEAK]
+ EXPORT TIMER7_BRK_TIMER11_IRQHandler [WEAK]
+ EXPORT TIMER7_UP_TIMER12_IRQHandler [WEAK]
+ EXPORT TIMER7_TRG_CMT_TIMER13_IRQHandler [WEAK]
+ EXPORT TIMER7_Channel_IRQHandler [WEAK]
+ EXPORT DMA0_Channel7_IRQHandler [WEAK]
+ EXPORT SDIO_IRQHandler [WEAK]
+ EXPORT TIMER4_IRQHandler [WEAK]
+ EXPORT SPI2_IRQHandler [WEAK]
+ EXPORT UART3_IRQHandler [WEAK]
+ EXPORT UART4_IRQHandler [WEAK]
+ EXPORT TIMER5_DAC_IRQHandler [WEAK]
+ EXPORT TIMER6_IRQHandler [WEAK]
+ EXPORT DMA1_Channel0_IRQHandler [WEAK]
+ EXPORT DMA1_Channel1_IRQHandler [WEAK]
+ EXPORT DMA1_Channel2_IRQHandler [WEAK]
+ EXPORT DMA1_Channel3_IRQHandler [WEAK]
+ EXPORT DMA1_Channel4_IRQHandler [WEAK]
+ EXPORT CAN1_TX_IRQHandler [WEAK]
+ EXPORT CAN1_RX0_IRQHandler [WEAK]
+ EXPORT CAN1_RX1_IRQHandler [WEAK]
+ EXPORT CAN1_EWMC_IRQHandler [WEAK]
+ EXPORT USBFS_IRQHandler [WEAK]
+ EXPORT DMA1_Channel5_IRQHandler [WEAK]
+ EXPORT DMA1_Channel6_IRQHandler [WEAK]
+ EXPORT DMA1_Channel7_IRQHandler [WEAK]
+ EXPORT USART5_IRQHandler [WEAK]
+ EXPORT I2C2_EV_IRQHandler [WEAK]
+ EXPORT I2C2_ER_IRQHandler [WEAK]
+ EXPORT USBHS_EP1_Out_IRQHandler [WEAK]
+ EXPORT USBHS_EP1_In_IRQHandler [WEAK]
+ EXPORT USBHS_WKUP_IRQHandler [WEAK]
+ EXPORT USBHS_IRQHandler [WEAK]
+ EXPORT DCI_IRQHandler [WEAK]
+ EXPORT TRNG_IRQHandler [WEAK]
+ EXPORT FPU_IRQHandler [WEAK]
+
+;/* external interrupts handler */
+WWDGT_IRQHandler
+LVD_IRQHandler
+TAMPER_STAMP_IRQHandler
+RTC_WKUP_IRQHandler
+FMC_IRQHandler
+RCU_CTC_IRQHandler
+EXTI0_IRQHandler
+EXTI1_IRQHandler
+EXTI2_IRQHandler
+EXTI3_IRQHandler
+EXTI4_IRQHandler
+DMA0_Channel0_IRQHandler
+DMA0_Channel1_IRQHandler
+DMA0_Channel2_IRQHandler
+DMA0_Channel3_IRQHandler
+DMA0_Channel4_IRQHandler
+DMA0_Channel5_IRQHandler
+DMA0_Channel6_IRQHandler
+ADC_IRQHandler
+CAN0_TX_IRQHandler
+CAN0_RX0_IRQHandler
+CAN0_RX1_IRQHandler
+CAN0_EWMC_IRQHandler
+EXTI5_9_IRQHandler
+TIMER0_BRK_TIMER8_IRQHandler
+TIMER0_UP_TIMER9_IRQHandler
+TIMER0_TRG_CMT_TIMER10_IRQHandler
+TIMER0_Channel_IRQHandler
+TIMER1_IRQHandler
+TIMER2_IRQHandler
+TIMER3_IRQHandler
+I2C0_EV_IRQHandler
+I2C0_ER_IRQHandler
+I2C1_EV_IRQHandler
+I2C1_ER_IRQHandler
+SPI0_IRQHandler
+SPI1_IRQHandler
+USART0_IRQHandler
+USART1_IRQHandler
+USART2_IRQHandler
+EXTI10_15_IRQHandler
+RTC_Alarm_IRQHandler
+USBFS_WKUP_IRQHandler
+TIMER7_BRK_TIMER11_IRQHandler
+TIMER7_UP_TIMER12_IRQHandler
+TIMER7_TRG_CMT_TIMER13_IRQHandler
+TIMER7_Channel_IRQHandler
+DMA0_Channel7_IRQHandler
+SDIO_IRQHandler
+TIMER4_IRQHandler
+SPI2_IRQHandler
+UART3_IRQHandler
+UART4_IRQHandler
+TIMER5_DAC_IRQHandler
+TIMER6_IRQHandler
+DMA1_Channel0_IRQHandler
+DMA1_Channel1_IRQHandler
+DMA1_Channel2_IRQHandler
+DMA1_Channel3_IRQHandler
+DMA1_Channel4_IRQHandler
+CAN1_TX_IRQHandler
+CAN1_RX0_IRQHandler
+CAN1_RX1_IRQHandler
+CAN1_EWMC_IRQHandler
+USBFS_IRQHandler
+DMA1_Channel5_IRQHandler
+DMA1_Channel6_IRQHandler
+DMA1_Channel7_IRQHandler
+USART5_IRQHandler
+I2C2_EV_IRQHandler
+I2C2_ER_IRQHandler
+USBHS_EP1_Out_IRQHandler
+USBHS_EP1_In_IRQHandler
+USBHS_WKUP_IRQHandler
+USBHS_IRQHandler
+DCI_IRQHandler
+TRNG_IRQHandler
+FPU_IRQHandler
+
+ B .
+ ENDP
+
+ ALIGN
+
+; user Initial Stack & Heap
+
+ IF :DEF:__MICROLIB
+
+ EXPORT __initial_sp
+ EXPORT __heap_base
+ EXPORT __heap_limit
+
+ ELSE
+
+ IMPORT __use_two_region_memory
+ EXPORT __user_initial_stackheap
+
+__user_initial_stackheap PROC
+ LDR R0, = Heap_Mem
+ LDR R1, =(Stack_Mem + Stack_Size)
+ LDR R2, = (Heap_Mem + Heap_Size)
+ LDR R3, = Stack_Mem
+ BX LR
+ ENDP
+
+ ALIGN
+
+ ENDIF
+
+ END
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/ARM/startup_gd32f407_427.s b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/ARM/startup_gd32f407_427.s
new file mode 100644
index 0000000000..4569d8adaa
--- /dev/null
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/ARM/startup_gd32f407_427.s
@@ -0,0 +1,429 @@
+;/*!
+; \file startup_gd32f407_427.s
+; \brief start up file
+;
+; \version 2016-08-15, V1.0.0, firmware for GD32F4xx
+; \version 2018-12-12, V2.0.0, firmware for GD32F4xx
+; \version 2020-09-30, V2.1.0, firmware for GD32F4xx
+; \version 2022-03-09, V3.0.0, firmware for GD32F4xx
+;*/
+;
+;/*
+; Copyright (c) 2022, GigaDevice Semiconductor Inc.
+;
+; Redistribution and use in source and binary forms, with or without modification,
+;are permitted provided that the following conditions are met:
+;
+; 1. Redistributions of source code must retain the above copyright notice, this
+; list of conditions and the following disclaimer.
+; 2. Redistributions in binary form must reproduce the above copyright notice,
+; this list of conditions and the following disclaimer in the documentation
+; and/or other materials provided with the distribution.
+; 3. Neither the name of the copyright holder nor the names of its contributors
+; may be used to endorse or promote products derived from this software without
+; specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+;AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+;IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+;INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+;NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+;PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+;WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+;ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+;OF SUCH DAMAGE.
+;*/
+
+; <h> Stack Configuration
+; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
+; </h>
+
+Stack_Size EQU 0x00000400
+
+ AREA STACK, NOINIT, READWRITE, ALIGN=3
+Stack_Mem SPACE Stack_Size
+__initial_sp
+
+
+; <h> Heap Configuration
+; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
+; </h>
+
+Heap_Size EQU 0x00000400
+
+ AREA HEAP, NOINIT, READWRITE, ALIGN=3
+__heap_base
+Heap_Mem SPACE Heap_Size
+__heap_limit
+
+ PRESERVE8
+ THUMB
+
+; /* reset Vector Mapped to at Address 0 */
+ AREA RESET, DATA, READONLY
+ EXPORT __Vectors
+ EXPORT __Vectors_End
+ EXPORT __Vectors_Size
+
+__Vectors DCD __initial_sp ; Top of Stack
+ DCD Reset_Handler ; Reset Handler
+ DCD NMI_Handler ; NMI Handler
+ DCD HardFault_Handler ; Hard Fault Handler
+ DCD MemManage_Handler ; MPU Fault Handler
+ DCD BusFault_Handler ; Bus Fault Handler
+ DCD UsageFault_Handler ; Usage Fault Handler
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD SVC_Handler ; SVCall Handler
+ DCD DebugMon_Handler ; Debug Monitor Handler
+ DCD 0 ; Reserved
+ DCD PendSV_Handler ; PendSV Handler
+ DCD SysTick_Handler ; SysTick Handler
+
+; /* external interrupts handler */
+ DCD WWDGT_IRQHandler ; 16:Window Watchdog Timer
+ DCD LVD_IRQHandler ; 17:LVD through EXTI Line detect
+ DCD TAMPER_STAMP_IRQHandler ; 18:Tamper and TimeStamp through EXTI Line detect
+ DCD RTC_WKUP_IRQHandler ; 19:RTC Wakeup through EXTI Line
+ DCD FMC_IRQHandler ; 20:FMC
+ DCD RCU_CTC_IRQHandler ; 21:RCU and CTC
+ DCD EXTI0_IRQHandler ; 22:EXTI Line 0
+ DCD EXTI1_IRQHandler ; 23:EXTI Line 1
+ DCD EXTI2_IRQHandler ; 24:EXTI Line 2
+ DCD EXTI3_IRQHandler ; 25:EXTI Line 3
+ DCD EXTI4_IRQHandler ; 26:EXTI Line 4
+ DCD DMA0_Channel0_IRQHandler ; 27:DMA0 Channel0
+ DCD DMA0_Channel1_IRQHandler ; 28:DMA0 Channel1
+ DCD DMA0_Channel2_IRQHandler ; 29:DMA0 Channel2
+ DCD DMA0_Channel3_IRQHandler ; 30:DMA0 Channel3
+ DCD DMA0_Channel4_IRQHandler ; 31:DMA0 Channel4
+ DCD DMA0_Channel5_IRQHandler ; 32:DMA0 Channel5
+ DCD DMA0_Channel6_IRQHandler ; 33:DMA0 Channel6
+ DCD ADC_IRQHandler ; 34:ADC
+ DCD CAN0_TX_IRQHandler ; 35:CAN0 TX
+ DCD CAN0_RX0_IRQHandler ; 36:CAN0 RX0
+ DCD CAN0_RX1_IRQHandler ; 37:CAN0 RX1
+ DCD CAN0_EWMC_IRQHandler ; 38:CAN0 EWMC
+ DCD EXTI5_9_IRQHandler ; 39:EXTI5 to EXTI9
+ DCD TIMER0_BRK_TIMER8_IRQHandler ; 40:TIMER0 Break and TIMER8
+ DCD TIMER0_UP_TIMER9_IRQHandler ; 41:TIMER0 Update and TIMER9
+ DCD TIMER0_TRG_CMT_TIMER10_IRQHandler ; 42:TIMER0 Trigger and Commutation and TIMER10
+ DCD TIMER0_Channel_IRQHandler ; 43:TIMER0 Channel Capture Compare
+ DCD TIMER1_IRQHandler ; 44:TIMER1
+ DCD TIMER2_IRQHandler ; 45:TIMER2
+ DCD TIMER3_IRQHandler ; 46:TIMER3
+ DCD I2C0_EV_IRQHandler ; 47:I2C0 Event
+ DCD I2C0_ER_IRQHandler ; 48:I2C0 Error
+ DCD I2C1_EV_IRQHandler ; 49:I2C1 Event
+ DCD I2C1_ER_IRQHandler ; 50:I2C1 Error
+ DCD SPI0_IRQHandler ; 51:SPI0
+ DCD SPI1_IRQHandler ; 52:SPI1
+ DCD USART0_IRQHandler ; 53:USART0
+ DCD USART1_IRQHandler ; 54:USART1
+ DCD USART2_IRQHandler ; 55:USART2
+ DCD EXTI10_15_IRQHandler ; 56:EXTI10 to EXTI15
+ DCD RTC_Alarm_IRQHandler ; 57:RTC Alarm
+ DCD USBFS_WKUP_IRQHandler ; 58:USBFS Wakeup
+ DCD TIMER7_BRK_TIMER11_IRQHandler ; 59:TIMER7 Break and TIMER11
+ DCD TIMER7_UP_TIMER12_IRQHandler ; 60:TIMER7 Update and TIMER12
+ DCD TIMER7_TRG_CMT_TIMER13_IRQHandler ; 61:TIMER7 Trigger and Commutation and TIMER13
+ DCD TIMER7_Channel_IRQHandler ; 62:TIMER7 Capture Compare
+ DCD DMA0_Channel7_IRQHandler ; 63:DMA0 Channel7
+ DCD EXMC_IRQHandler ; 64:EXMC
+ DCD SDIO_IRQHandler ; 65:SDIO
+ DCD TIMER4_IRQHandler ; 66:TIMER4
+ DCD SPI2_IRQHandler ; 67:SPI2
+ DCD UART3_IRQHandler ; 68:UART3
+ DCD UART4_IRQHandler ; 69:UART4
+ DCD TIMER5_DAC_IRQHandler ; 70:TIMER5 and DAC0 DAC1 Underrun error
+ DCD TIMER6_IRQHandler ; 71:TIMER6
+ DCD DMA1_Channel0_IRQHandler ; 72:DMA1 Channel0
+ DCD DMA1_Channel1_IRQHandler ; 73:DMA1 Channel1
+ DCD DMA1_Channel2_IRQHandler ; 74:DMA1 Channel2
+ DCD DMA1_Channel3_IRQHandler ; 75:DMA1 Channel3
+ DCD DMA1_Channel4_IRQHandler ; 76:DMA1 Channel4
+ DCD ENET_IRQHandler ; 77:Ethernet
+ DCD ENET_WKUP_IRQHandler ; 78:Ethernet Wakeup through EXTI Line
+ DCD CAN1_TX_IRQHandler ; 79:CAN1 TX
+ DCD CAN1_RX0_IRQHandler ; 80:CAN1 RX0
+ DCD CAN1_RX1_IRQHandler ; 81:CAN1 RX1
+ DCD CAN1_EWMC_IRQHandler ; 82:CAN1 EWMC
+ DCD USBFS_IRQHandler ; 83:USBFS
+ DCD DMA1_Channel5_IRQHandler ; 84:DMA1 Channel5
+ DCD DMA1_Channel6_IRQHandler ; 85:DMA1 Channel6
+ DCD DMA1_Channel7_IRQHandler ; 86:DMA1 Channel7
+ DCD USART5_IRQHandler ; 87:USART5
+ DCD I2C2_EV_IRQHandler ; 88:I2C2 Event
+ DCD I2C2_ER_IRQHandler ; 89:I2C2 Error
+ DCD USBHS_EP1_Out_IRQHandler ; 90:USBHS Endpoint 1 Out
+ DCD USBHS_EP1_In_IRQHandler ; 91:USBHS Endpoint 1 in
+ DCD USBHS_WKUP_IRQHandler ; 92:USBHS Wakeup through EXTI Line
+ DCD USBHS_IRQHandler ; 93:USBHS
+ DCD DCI_IRQHandler ; 94:DCI
+ DCD 0 ; 95:Reserved
+ DCD TRNG_IRQHandler ; 96:TRNG
+ DCD FPU_IRQHandler ; 97:FPU
+
+__Vectors_End
+
+__Vectors_Size EQU __Vectors_End - __Vectors
+
+ AREA |.text|, CODE, READONLY
+
+;/* reset Handler */
+Reset_Handler PROC
+ EXPORT Reset_Handler [WEAK]
+ IMPORT SystemInit
+ IMPORT __main
+ LDR R0, =SystemInit
+ BLX R0
+ LDR R0, =__main
+ BX R0
+ ENDP
+
+;/* dummy Exception Handlers */
+NMI_Handler PROC
+ EXPORT NMI_Handler [WEAK]
+ B .
+ ENDP
+HardFault_Handler\
+ PROC
+ EXPORT HardFault_Handler [WEAK]
+ B .
+ ENDP
+MemManage_Handler\
+ PROC
+ EXPORT MemManage_Handler [WEAK]
+ B .
+ ENDP
+BusFault_Handler\
+ PROC
+ EXPORT BusFault_Handler [WEAK]
+ B .
+ ENDP
+UsageFault_Handler\
+ PROC
+ EXPORT UsageFault_Handler [WEAK]
+ B .
+ ENDP
+SVC_Handler PROC
+ EXPORT SVC_Handler [WEAK]
+ B .
+ ENDP
+DebugMon_Handler\
+ PROC
+ EXPORT DebugMon_Handler [WEAK]
+ B .
+ ENDP
+PendSV_Handler\
+ PROC
+ EXPORT PendSV_Handler [WEAK]
+ B .
+ ENDP
+SysTick_Handler\
+ PROC
+ EXPORT SysTick_Handler [WEAK]
+ B .
+ ENDP
+
+Default_Handler PROC
+; /* external interrupts handler */
+ EXPORT WWDGT_IRQHandler [WEAK]
+ EXPORT LVD_IRQHandler [WEAK]
+ EXPORT TAMPER_STAMP_IRQHandler [WEAK]
+ EXPORT RTC_WKUP_IRQHandler [WEAK]
+ EXPORT FMC_IRQHandler [WEAK]
+ EXPORT RCU_CTC_IRQHandler [WEAK]
+ EXPORT EXTI0_IRQHandler [WEAK]
+ EXPORT EXTI1_IRQHandler [WEAK]
+ EXPORT EXTI2_IRQHandler [WEAK]
+ EXPORT EXTI3_IRQHandler [WEAK]
+ EXPORT EXTI4_IRQHandler [WEAK]
+ EXPORT DMA0_Channel0_IRQHandler [WEAK]
+ EXPORT DMA0_Channel1_IRQHandler [WEAK]
+ EXPORT DMA0_Channel2_IRQHandler [WEAK]
+ EXPORT DMA0_Channel3_IRQHandler [WEAK]
+ EXPORT DMA0_Channel4_IRQHandler [WEAK]
+ EXPORT DMA0_Channel5_IRQHandler [WEAK]
+ EXPORT DMA0_Channel6_IRQHandler [WEAK]
+ EXPORT ADC_IRQHandler [WEAK]
+ EXPORT CAN0_TX_IRQHandler [WEAK]
+ EXPORT CAN0_RX0_IRQHandler [WEAK]
+ EXPORT CAN0_RX1_IRQHandler [WEAK]
+ EXPORT CAN0_EWMC_IRQHandler [WEAK]
+ EXPORT EXTI5_9_IRQHandler [WEAK]
+ EXPORT TIMER0_BRK_TIMER8_IRQHandler [WEAK]
+ EXPORT TIMER0_UP_TIMER9_IRQHandler [WEAK]
+ EXPORT TIMER0_TRG_CMT_TIMER10_IRQHandler [WEAK]
+ EXPORT TIMER0_Channel_IRQHandler [WEAK]
+ EXPORT TIMER1_IRQHandler [WEAK]
+ EXPORT TIMER2_IRQHandler [WEAK]
+ EXPORT TIMER3_IRQHandler [WEAK]
+ EXPORT I2C0_EV_IRQHandler [WEAK]
+ EXPORT I2C0_ER_IRQHandler [WEAK]
+ EXPORT I2C1_EV_IRQHandler [WEAK]
+ EXPORT I2C1_ER_IRQHandler [WEAK]
+ EXPORT SPI0_IRQHandler [WEAK]
+ EXPORT SPI1_IRQHandler [WEAK]
+ EXPORT USART0_IRQHandler [WEAK]
+ EXPORT USART1_IRQHandler [WEAK]
+ EXPORT USART2_IRQHandler [WEAK]
+ EXPORT EXTI10_15_IRQHandler [WEAK]
+ EXPORT RTC_Alarm_IRQHandler [WEAK]
+ EXPORT USBFS_WKUP_IRQHandler [WEAK]
+ EXPORT TIMER7_BRK_TIMER11_IRQHandler [WEAK]
+ EXPORT TIMER7_UP_TIMER12_IRQHandler [WEAK]
+ EXPORT TIMER7_TRG_CMT_TIMER13_IRQHandler [WEAK]
+ EXPORT TIMER7_Channel_IRQHandler [WEAK]
+ EXPORT DMA0_Channel7_IRQHandler [WEAK]
+ EXPORT EXMC_IRQHandler [WEAK]
+ EXPORT SDIO_IRQHandler [WEAK]
+ EXPORT TIMER4_IRQHandler [WEAK]
+ EXPORT SPI2_IRQHandler [WEAK]
+ EXPORT UART3_IRQHandler [WEAK]
+ EXPORT UART4_IRQHandler [WEAK]
+ EXPORT TIMER5_DAC_IRQHandler [WEAK]
+ EXPORT TIMER6_IRQHandler [WEAK]
+ EXPORT DMA1_Channel0_IRQHandler [WEAK]
+ EXPORT DMA1_Channel1_IRQHandler [WEAK]
+ EXPORT DMA1_Channel2_IRQHandler [WEAK]
+ EXPORT DMA1_Channel3_IRQHandler [WEAK]
+ EXPORT DMA1_Channel4_IRQHandler [WEAK]
+ EXPORT ENET_IRQHandler [WEAK]
+ EXPORT ENET_WKUP_IRQHandler [WEAK]
+ EXPORT CAN1_TX_IRQHandler [WEAK]
+ EXPORT CAN1_RX0_IRQHandler [WEAK]
+ EXPORT CAN1_RX1_IRQHandler [WEAK]
+ EXPORT CAN1_EWMC_IRQHandler [WEAK]
+ EXPORT USBFS_IRQHandler [WEAK]
+ EXPORT DMA1_Channel5_IRQHandler [WEAK]
+ EXPORT DMA1_Channel6_IRQHandler [WEAK]
+ EXPORT DMA1_Channel7_IRQHandler [WEAK]
+ EXPORT USART5_IRQHandler [WEAK]
+ EXPORT I2C2_EV_IRQHandler [WEAK]
+ EXPORT I2C2_ER_IRQHandler [WEAK]
+ EXPORT USBHS_EP1_Out_IRQHandler [WEAK]
+ EXPORT USBHS_EP1_In_IRQHandler [WEAK]
+ EXPORT USBHS_WKUP_IRQHandler [WEAK]
+ EXPORT USBHS_IRQHandler [WEAK]
+ EXPORT DCI_IRQHandler [WEAK]
+ EXPORT TRNG_IRQHandler [WEAK]
+ EXPORT FPU_IRQHandler [WEAK]
+
+;/* external interrupts handler */
+WWDGT_IRQHandler
+LVD_IRQHandler
+TAMPER_STAMP_IRQHandler
+RTC_WKUP_IRQHandler
+FMC_IRQHandler
+RCU_CTC_IRQHandler
+EXTI0_IRQHandler
+EXTI1_IRQHandler
+EXTI2_IRQHandler
+EXTI3_IRQHandler
+EXTI4_IRQHandler
+DMA0_Channel0_IRQHandler
+DMA0_Channel1_IRQHandler
+DMA0_Channel2_IRQHandler
+DMA0_Channel3_IRQHandler
+DMA0_Channel4_IRQHandler
+DMA0_Channel5_IRQHandler
+DMA0_Channel6_IRQHandler
+ADC_IRQHandler
+CAN0_TX_IRQHandler
+CAN0_RX0_IRQHandler
+CAN0_RX1_IRQHandler
+CAN0_EWMC_IRQHandler
+EXTI5_9_IRQHandler
+TIMER0_BRK_TIMER8_IRQHandler
+TIMER0_UP_TIMER9_IRQHandler
+TIMER0_TRG_CMT_TIMER10_IRQHandler
+TIMER0_Channel_IRQHandler
+TIMER1_IRQHandler
+TIMER2_IRQHandler
+TIMER3_IRQHandler
+I2C0_EV_IRQHandler
+I2C0_ER_IRQHandler
+I2C1_EV_IRQHandler
+I2C1_ER_IRQHandler
+SPI0_IRQHandler
+SPI1_IRQHandler
+USART0_IRQHandler
+USART1_IRQHandler
+USART2_IRQHandler
+EXTI10_15_IRQHandler
+RTC_Alarm_IRQHandler
+USBFS_WKUP_IRQHandler
+TIMER7_BRK_TIMER11_IRQHandler
+TIMER7_UP_TIMER12_IRQHandler
+TIMER7_TRG_CMT_TIMER13_IRQHandler
+TIMER7_Channel_IRQHandler
+DMA0_Channel7_IRQHandler
+EXMC_IRQHandler
+SDIO_IRQHandler
+TIMER4_IRQHandler
+SPI2_IRQHandler
+UART3_IRQHandler
+UART4_IRQHandler
+TIMER5_DAC_IRQHandler
+TIMER6_IRQHandler
+DMA1_Channel0_IRQHandler
+DMA1_Channel1_IRQHandler
+DMA1_Channel2_IRQHandler
+DMA1_Channel3_IRQHandler
+DMA1_Channel4_IRQHandler
+ENET_IRQHandler
+ENET_WKUP_IRQHandler
+CAN1_TX_IRQHandler
+CAN1_RX0_IRQHandler
+CAN1_RX1_IRQHandler
+CAN1_EWMC_IRQHandler
+USBFS_IRQHandler
+DMA1_Channel5_IRQHandler
+DMA1_Channel6_IRQHandler
+DMA1_Channel7_IRQHandler
+USART5_IRQHandler
+I2C2_EV_IRQHandler
+I2C2_ER_IRQHandler
+USBHS_EP1_Out_IRQHandler
+USBHS_EP1_In_IRQHandler
+USBHS_WKUP_IRQHandler
+USBHS_IRQHandler
+DCI_IRQHandler
+TRNG_IRQHandler
+FPU_IRQHandler
+
+ B .
+ ENDP
+
+ ALIGN
+
+; user Initial Stack & Heap
+
+ IF :DEF:__MICROLIB
+
+ EXPORT __initial_sp
+ EXPORT __heap_base
+ EXPORT __heap_limit
+
+ ELSE
+
+ IMPORT __use_two_region_memory
+ EXPORT __user_initial_stackheap
+
+__user_initial_stackheap PROC
+ LDR R0, = Heap_Mem
+ LDR R1, =(Stack_Mem + Stack_Size)
+ LDR R2, = (Heap_Mem + Heap_Size)
+ LDR R3, = Stack_Mem
+ BX LR
+ ENDP
+
+ ALIGN
+
+ ENDIF
+
+ END
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/ARM/startup_gd32f450_470.s b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/ARM/startup_gd32f450_470.s
new file mode 100644
index 0000000000..85b978a681
--- /dev/null
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/ARM/startup_gd32f450_470.s
@@ -0,0 +1,454 @@
+;/*!
+; \file startup_gd32f450_470.s
+; \brief start up file
+;
+; \version 2016-08-15, V1.0.0, firmware for GD32F4xx
+; \version 2018-12-12, V2.0.0, firmware for GD32F4xx
+; \version 2020-09-30, V2.1.0, firmware for GD32F4xx
+; \version 2022-03-09, V3.0.0, firmware for GD32F4xx
+;*/
+;
+;/*
+; Copyright (c) 2022, GigaDevice Semiconductor Inc.
+;
+; Redistribution and use in source and binary forms, with or without modification,
+;are permitted provided that the following conditions are met:
+;
+; 1. Redistributions of source code must retain the above copyright notice, this
+; list of conditions and the following disclaimer.
+; 2. Redistributions in binary form must reproduce the above copyright notice,
+; this list of conditions and the following disclaimer in the documentation
+; and/or other materials provided with the distribution.
+; 3. Neither the name of the copyright holder nor the names of its contributors
+; may be used to endorse or promote products derived from this software without
+; specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+;AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+;IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+;INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+;NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+;PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+;WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+;ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+;OF SUCH DAMAGE.
+;*/
+
+; <h> Stack Configuration
+; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
+; </h>
+
+Stack_Size EQU 0x00000400
+
+ AREA STACK, NOINIT, READWRITE, ALIGN=3
+Stack_Mem SPACE Stack_Size
+__initial_sp
+
+
+; <h> Heap Configuration
+; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
+; </h>
+
+Heap_Size EQU 0x00000400
+
+ AREA HEAP, NOINIT, READWRITE, ALIGN=3
+__heap_base
+Heap_Mem SPACE Heap_Size
+__heap_limit
+
+ PRESERVE8
+ THUMB
+
+; /* reset Vector Mapped to at Address 0 */
+ AREA RESET, DATA, READONLY
+ EXPORT __Vectors
+ EXPORT __Vectors_End
+ EXPORT __Vectors_Size
+
+__Vectors DCD __initial_sp ; Top of Stack
+ DCD Reset_Handler ; Reset Handler
+ DCD NMI_Handler ; NMI Handler
+ DCD HardFault_Handler ; Hard Fault Handler
+ DCD MemManage_Handler ; MPU Fault Handler
+ DCD BusFault_Handler ; Bus Fault Handler
+ DCD UsageFault_Handler ; Usage Fault Handler
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD SVC_Handler ; SVCall Handler
+ DCD DebugMon_Handler ; Debug Monitor Handler
+ DCD 0 ; Reserved
+ DCD PendSV_Handler ; PendSV Handler
+ DCD SysTick_Handler ; SysTick Handler
+
+; /* external interrupts handler */
+ DCD WWDGT_IRQHandler ; 16:Window Watchdog Timer
+ DCD LVD_IRQHandler ; 17:LVD through EXTI Line detect
+ DCD TAMPER_STAMP_IRQHandler ; 18:Tamper and TimeStamp through EXTI Line detect
+ DCD RTC_WKUP_IRQHandler ; 19:RTC Wakeup through EXTI Line
+ DCD FMC_IRQHandler ; 20:FMC
+ DCD RCU_CTC_IRQHandler ; 21:RCU and CTC
+ DCD EXTI0_IRQHandler ; 22:EXTI Line 0
+ DCD EXTI1_IRQHandler ; 23:EXTI Line 1
+ DCD EXTI2_IRQHandler ; 24:EXTI Line 2
+ DCD EXTI3_IRQHandler ; 25:EXTI Line 3
+ DCD EXTI4_IRQHandler ; 26:EXTI Line 4
+ DCD DMA0_Channel0_IRQHandler ; 27:DMA0 Channel0
+ DCD DMA0_Channel1_IRQHandler ; 28:DMA0 Channel1
+ DCD DMA0_Channel2_IRQHandler ; 29:DMA0 Channel2
+ DCD DMA0_Channel3_IRQHandler ; 30:DMA0 Channel3
+ DCD DMA0_Channel4_IRQHandler ; 31:DMA0 Channel4
+ DCD DMA0_Channel5_IRQHandler ; 32:DMA0 Channel5
+ DCD DMA0_Channel6_IRQHandler ; 33:DMA0 Channel6
+ DCD ADC_IRQHandler ; 34:ADC
+ DCD CAN0_TX_IRQHandler ; 35:CAN0 TX
+ DCD CAN0_RX0_IRQHandler ; 36:CAN0 RX0
+ DCD CAN0_RX1_IRQHandler ; 37:CAN0 RX1
+ DCD CAN0_EWMC_IRQHandler ; 38:CAN0 EWMC
+ DCD EXTI5_9_IRQHandler ; 39:EXTI5 to EXTI9
+ DCD TIMER0_BRK_TIMER8_IRQHandler ; 40:TIMER0 Break and TIMER8
+ DCD TIMER0_UP_TIMER9_IRQHandler ; 41:TIMER0 Update and TIMER9
+ DCD TIMER0_TRG_CMT_TIMER10_IRQHandler ; 42:TIMER0 Trigger and Commutation and TIMER10
+ DCD TIMER0_Channel_IRQHandler ; 43:TIMER0 Capture Compare
+ DCD TIMER1_IRQHandler ; 44:TIMER1
+ DCD TIMER2_IRQHandler ; 45:TIMER2
+ DCD TIMER3_IRQHandler ; 46:TIMER3
+ DCD I2C0_EV_IRQHandler ; 47:I2C0 Event
+ DCD I2C0_ER_IRQHandler ; 48:I2C0 Error
+ DCD I2C1_EV_IRQHandler ; 49:I2C1 Event
+ DCD I2C1_ER_IRQHandler ; 50:I2C1 Error
+ DCD SPI0_IRQHandler ; 51:SPI0
+ DCD SPI1_IRQHandler ; 52:SPI1
+ DCD USART0_IRQHandler ; 53:USART0
+ DCD USART1_IRQHandler ; 54:USART1
+ DCD USART2_IRQHandler ; 55:USART2
+ DCD EXTI10_15_IRQHandler ; 56:EXTI10 to EXTI15
+ DCD RTC_Alarm_IRQHandler ; 57:RTC Alarm
+ DCD USBFS_WKUP_IRQHandler ; 58:USBFS Wakeup
+ DCD TIMER7_BRK_TIMER11_IRQHandler ; 59:TIMER7 Break and TIMER11
+ DCD TIMER7_UP_TIMER12_IRQHandler ; 60:TIMER7 Update and TIMER12
+ DCD TIMER7_TRG_CMT_TIMER13_IRQHandler ; 61:TIMER7 Trigger and Commutation and TIMER13
+ DCD TIMER7_Channel_IRQHandler ; 62:TIMER7 Channel Capture Compare
+ DCD DMA0_Channel7_IRQHandler ; 63:DMA0 Channel7
+ DCD EXMC_IRQHandler ; 64:EXMC
+ DCD SDIO_IRQHandler ; 65:SDIO
+ DCD TIMER4_IRQHandler ; 66:TIMER4
+ DCD SPI2_IRQHandler ; 67:SPI2
+ DCD UART3_IRQHandler ; 68:UART3
+ DCD UART4_IRQHandler ; 69:UART4
+ DCD TIMER5_DAC_IRQHandler ; 70:TIMER5 and DAC0 DAC1 Underrun error
+ DCD TIMER6_IRQHandler ; 71:TIMER6
+ DCD DMA1_Channel0_IRQHandler ; 72:DMA1 Channel0
+ DCD DMA1_Channel1_IRQHandler ; 73:DMA1 Channel1
+ DCD DMA1_Channel2_IRQHandler ; 74:DMA1 Channel2
+ DCD DMA1_Channel3_IRQHandler ; 75:DMA1 Channel3
+ DCD DMA1_Channel4_IRQHandler ; 76:DMA1 Channel4
+ DCD ENET_IRQHandler ; 77:Ethernet
+ DCD ENET_WKUP_IRQHandler ; 78:Ethernet Wakeup through EXTI Line
+ DCD CAN1_TX_IRQHandler ; 79:CAN1 TX
+ DCD CAN1_RX0_IRQHandler ; 80:CAN1 RX0
+ DCD CAN1_RX1_IRQHandler ; 81:CAN1 RX1
+ DCD CAN1_EWMC_IRQHandler ; 82:CAN1 EWMC
+ DCD USBFS_IRQHandler ; 83:USBFS
+ DCD DMA1_Channel5_IRQHandler ; 84:DMA1 Channel5
+ DCD DMA1_Channel6_IRQHandler ; 85:DMA1 Channel6
+ DCD DMA1_Channel7_IRQHandler ; 86:DMA1 Channel7
+ DCD USART5_IRQHandler ; 87:USART5
+ DCD I2C2_EV_IRQHandler ; 88:I2C2 Event
+ DCD I2C2_ER_IRQHandler ; 89:I2C2 Error
+ DCD USBHS_EP1_Out_IRQHandler ; 90:USBHS Endpoint 1 Out
+ DCD USBHS_EP1_In_IRQHandler ; 91:USBHS Endpoint 1 in
+ DCD USBHS_WKUP_IRQHandler ; 92:USBHS Wakeup through EXTI Line
+ DCD USBHS_IRQHandler ; 93:USBHS
+ DCD DCI_IRQHandler ; 94:DCI
+ DCD 0 ; 95:Reserved
+ DCD TRNG_IRQHandler ; 96:TRNG
+ DCD FPU_IRQHandler ; 97:FPU
+ DCD UART6_IRQHandler ; 98:UART6
+ DCD UART7_IRQHandler ; 99:UART7
+ DCD SPI3_IRQHandler ; 100:SPI3
+ DCD SPI4_IRQHandler ; 101:SPI4
+ DCD SPI5_IRQHandler ; 102:SPI5
+ DCD 0 ; 103:Reserved
+ DCD TLI_IRQHandler ; 104:TLI
+ DCD TLI_ER_IRQHandler ; 105:TLI Error
+ DCD IPA_IRQHandler ; 106:IPA
+
+__Vectors_End
+
+__Vectors_Size EQU __Vectors_End - __Vectors
+
+ AREA |.text|, CODE, READONLY
+
+;/* reset Handler */
+Reset_Handler PROC
+ EXPORT Reset_Handler [WEAK]
+ IMPORT SystemInit
+ IMPORT __main
+ LDR R0, =SystemInit
+ BLX R0
+ LDR R0, =__main
+ BX R0
+ ENDP
+
+;/* dummy Exception Handlers */
+NMI_Handler PROC
+ EXPORT NMI_Handler [WEAK]
+ B .
+ ENDP
+HardFault_Handler\
+ PROC
+ EXPORT HardFault_Handler [WEAK]
+ B .
+ ENDP
+MemManage_Handler\
+ PROC
+ EXPORT MemManage_Handler [WEAK]
+ B .
+ ENDP
+BusFault_Handler\
+ PROC
+ EXPORT BusFault_Handler [WEAK]
+ B .
+ ENDP
+UsageFault_Handler\
+ PROC
+ EXPORT UsageFault_Handler [WEAK]
+ B .
+ ENDP
+SVC_Handler PROC
+ EXPORT SVC_Handler [WEAK]
+ B .
+ ENDP
+DebugMon_Handler\
+ PROC
+ EXPORT DebugMon_Handler [WEAK]
+ B .
+ ENDP
+PendSV_Handler\
+ PROC
+ EXPORT PendSV_Handler [WEAK]
+ B .
+ ENDP
+SysTick_Handler\
+ PROC
+ EXPORT SysTick_Handler [WEAK]
+ B .
+ ENDP
+
+Default_Handler PROC
+; /* external interrupts handler */
+ EXPORT WWDGT_IRQHandler [WEAK]
+ EXPORT LVD_IRQHandler [WEAK]
+ EXPORT TAMPER_STAMP_IRQHandler [WEAK]
+ EXPORT RTC_WKUP_IRQHandler [WEAK]
+ EXPORT FMC_IRQHandler [WEAK]
+ EXPORT RCU_CTC_IRQHandler [WEAK]
+ EXPORT EXTI0_IRQHandler [WEAK]
+ EXPORT EXTI1_IRQHandler [WEAK]
+ EXPORT EXTI2_IRQHandler [WEAK]
+ EXPORT EXTI3_IRQHandler [WEAK]
+ EXPORT EXTI4_IRQHandler [WEAK]
+ EXPORT DMA0_Channel0_IRQHandler [WEAK]
+ EXPORT DMA0_Channel1_IRQHandler [WEAK]
+ EXPORT DMA0_Channel2_IRQHandler [WEAK]
+ EXPORT DMA0_Channel3_IRQHandler [WEAK]
+ EXPORT DMA0_Channel4_IRQHandler [WEAK]
+ EXPORT DMA0_Channel5_IRQHandler [WEAK]
+ EXPORT DMA0_Channel6_IRQHandler [WEAK]
+ EXPORT ADC_IRQHandler [WEAK]
+ EXPORT CAN0_TX_IRQHandler [WEAK]
+ EXPORT CAN0_RX0_IRQHandler [WEAK]
+ EXPORT CAN0_RX1_IRQHandler [WEAK]
+ EXPORT CAN0_EWMC_IRQHandler [WEAK]
+ EXPORT EXTI5_9_IRQHandler [WEAK]
+ EXPORT TIMER0_BRK_TIMER8_IRQHandler [WEAK]
+ EXPORT TIMER0_UP_TIMER9_IRQHandler [WEAK]
+ EXPORT TIMER0_TRG_CMT_TIMER10_IRQHandler [WEAK]
+ EXPORT TIMER0_Channel_IRQHandler [WEAK]
+ EXPORT TIMER1_IRQHandler [WEAK]
+ EXPORT TIMER2_IRQHandler [WEAK]
+ EXPORT TIMER3_IRQHandler [WEAK]
+ EXPORT I2C0_EV_IRQHandler [WEAK]
+ EXPORT I2C0_ER_IRQHandler [WEAK]
+ EXPORT I2C1_EV_IRQHandler [WEAK]
+ EXPORT I2C1_ER_IRQHandler [WEAK]
+ EXPORT SPI0_IRQHandler [WEAK]
+ EXPORT SPI1_IRQHandler [WEAK]
+ EXPORT USART0_IRQHandler [WEAK]
+ EXPORT USART1_IRQHandler [WEAK]
+ EXPORT USART2_IRQHandler [WEAK]
+ EXPORT EXTI10_15_IRQHandler [WEAK]
+ EXPORT RTC_Alarm_IRQHandler [WEAK]
+ EXPORT USBFS_WKUP_IRQHandler [WEAK]
+ EXPORT TIMER7_BRK_TIMER11_IRQHandler [WEAK]
+ EXPORT TIMER7_UP_TIMER12_IRQHandler [WEAK]
+ EXPORT TIMER7_TRG_CMT_TIMER13_IRQHandler [WEAK]
+ EXPORT TIMER7_Channel_IRQHandler [WEAK]
+ EXPORT DMA0_Channel7_IRQHandler [WEAK]
+ EXPORT EXMC_IRQHandler [WEAK]
+ EXPORT SDIO_IRQHandler [WEAK]
+ EXPORT TIMER4_IRQHandler [WEAK]
+ EXPORT SPI2_IRQHandler [WEAK]
+ EXPORT UART3_IRQHandler [WEAK]
+ EXPORT UART4_IRQHandler [WEAK]
+ EXPORT TIMER5_DAC_IRQHandler [WEAK]
+ EXPORT TIMER6_IRQHandler [WEAK]
+ EXPORT DMA1_Channel0_IRQHandler [WEAK]
+ EXPORT DMA1_Channel1_IRQHandler [WEAK]
+ EXPORT DMA1_Channel2_IRQHandler [WEAK]
+ EXPORT DMA1_Channel3_IRQHandler [WEAK]
+ EXPORT DMA1_Channel4_IRQHandler [WEAK]
+ EXPORT ENET_IRQHandler [WEAK]
+ EXPORT ENET_WKUP_IRQHandler [WEAK]
+ EXPORT CAN1_TX_IRQHandler [WEAK]
+ EXPORT CAN1_RX0_IRQHandler [WEAK]
+ EXPORT CAN1_RX1_IRQHandler [WEAK]
+ EXPORT CAN1_EWMC_IRQHandler [WEAK]
+ EXPORT USBFS_IRQHandler [WEAK]
+ EXPORT DMA1_Channel5_IRQHandler [WEAK]
+ EXPORT DMA1_Channel6_IRQHandler [WEAK]
+ EXPORT DMA1_Channel7_IRQHandler [WEAK]
+ EXPORT USART5_IRQHandler [WEAK]
+ EXPORT I2C2_EV_IRQHandler [WEAK]
+ EXPORT I2C2_ER_IRQHandler [WEAK]
+ EXPORT USBHS_EP1_Out_IRQHandler [WEAK]
+ EXPORT USBHS_EP1_In_IRQHandler [WEAK]
+ EXPORT USBHS_WKUP_IRQHandler [WEAK]
+ EXPORT USBHS_IRQHandler [WEAK]
+ EXPORT DCI_IRQHandler [WEAK]
+ EXPORT TRNG_IRQHandler [WEAK]
+ EXPORT FPU_IRQHandler [WEAK]
+ EXPORT UART6_IRQHandler [WEAK]
+ EXPORT UART7_IRQHandler [WEAK]
+ EXPORT SPI3_IRQHandler [WEAK]
+ EXPORT SPI4_IRQHandler [WEAK]
+ EXPORT SPI5_IRQHandler [WEAK]
+ EXPORT TLI_IRQHandler [WEAK]
+ EXPORT TLI_ER_IRQHandler [WEAK]
+ EXPORT IPA_IRQHandler [WEAK]
+
+;/* external interrupts handler */
+WWDGT_IRQHandler
+LVD_IRQHandler
+TAMPER_STAMP_IRQHandler
+RTC_WKUP_IRQHandler
+FMC_IRQHandler
+RCU_CTC_IRQHandler
+EXTI0_IRQHandler
+EXTI1_IRQHandler
+EXTI2_IRQHandler
+EXTI3_IRQHandler
+EXTI4_IRQHandler
+DMA0_Channel0_IRQHandler
+DMA0_Channel1_IRQHandler
+DMA0_Channel2_IRQHandler
+DMA0_Channel3_IRQHandler
+DMA0_Channel4_IRQHandler
+DMA0_Channel5_IRQHandler
+DMA0_Channel6_IRQHandler
+ADC_IRQHandler
+CAN0_TX_IRQHandler
+CAN0_RX0_IRQHandler
+CAN0_RX1_IRQHandler
+CAN0_EWMC_IRQHandler
+EXTI5_9_IRQHandler
+TIMER0_BRK_TIMER8_IRQHandler
+TIMER0_UP_TIMER9_IRQHandler
+TIMER0_TRG_CMT_TIMER10_IRQHandler
+TIMER0_Channel_IRQHandler
+TIMER1_IRQHandler
+TIMER2_IRQHandler
+TIMER3_IRQHandler
+I2C0_EV_IRQHandler
+I2C0_ER_IRQHandler
+I2C1_EV_IRQHandler
+I2C1_ER_IRQHandler
+SPI0_IRQHandler
+SPI1_IRQHandler
+USART0_IRQHandler
+USART1_IRQHandler
+USART2_IRQHandler
+EXTI10_15_IRQHandler
+RTC_Alarm_IRQHandler
+USBFS_WKUP_IRQHandler
+TIMER7_BRK_TIMER11_IRQHandler
+TIMER7_UP_TIMER12_IRQHandler
+TIMER7_TRG_CMT_TIMER13_IRQHandler
+TIMER7_Channel_IRQHandler
+DMA0_Channel7_IRQHandler
+EXMC_IRQHandler
+SDIO_IRQHandler
+TIMER4_IRQHandler
+SPI2_IRQHandler
+UART3_IRQHandler
+UART4_IRQHandler
+TIMER5_DAC_IRQHandler
+TIMER6_IRQHandler
+DMA1_Channel0_IRQHandler
+DMA1_Channel1_IRQHandler
+DMA1_Channel2_IRQHandler
+DMA1_Channel3_IRQHandler
+DMA1_Channel4_IRQHandler
+ENET_IRQHandler
+ENET_WKUP_IRQHandler
+CAN1_TX_IRQHandler
+CAN1_RX0_IRQHandler
+CAN1_RX1_IRQHandler
+CAN1_EWMC_IRQHandler
+USBFS_IRQHandler
+DMA1_Channel5_IRQHandler
+DMA1_Channel6_IRQHandler
+DMA1_Channel7_IRQHandler
+USART5_IRQHandler
+I2C2_EV_IRQHandler
+I2C2_ER_IRQHandler
+USBHS_EP1_Out_IRQHandler
+USBHS_EP1_In_IRQHandler
+USBHS_WKUP_IRQHandler
+USBHS_IRQHandler
+DCI_IRQHandler
+TRNG_IRQHandler
+FPU_IRQHandler
+UART6_IRQHandler
+UART7_IRQHandler
+SPI3_IRQHandler
+SPI4_IRQHandler
+SPI5_IRQHandler
+TLI_IRQHandler
+TLI_ER_IRQHandler
+IPA_IRQHandler
+
+ B .
+ ENDP
+
+ ALIGN
+
+; user Initial Stack & Heap
+
+ IF :DEF:__MICROLIB
+
+ EXPORT __initial_sp
+ EXPORT __heap_base
+ EXPORT __heap_limit
+
+ ELSE
+
+ IMPORT __use_two_region_memory
+ EXPORT __user_initial_stackheap
+
+__user_initial_stackheap PROC
+ LDR R0, = Heap_Mem
+ LDR R1, =(Stack_Mem + Stack_Size)
+ LDR R2, = (Heap_Mem + Heap_Size)
+ LDR R3, = Stack_Mem
+ BX LR
+ ENDP
+
+ ALIGN
+
+ ENDIF
+
+ END
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/IAR/startup_gd32f405_425.s b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/IAR/startup_gd32f405_425.s
new file mode 100644
index 0000000000..28eb812a71
--- /dev/null
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/IAR/startup_gd32f405_425.s
@@ -0,0 +1,602 @@
+;/*!
+; \file startup_gd32f405_425.s
+; \brief start up file
+;
+; \version 2016-08-15, V1.0.0, firmware for GD32F4xx
+; \version 2018-12-12, V2.0.0, firmware for GD32F4xx
+; \version 2020-09-30, V2.1.0, firmware for GD32F4xx
+; \version 2022-03-09, V3.0.0, firmware for GD32F4xx
+;*/
+;
+;/*
+; Copyright (c) 2022, GigaDevice Semiconductor Inc.
+;
+; Redistribution and use in source and binary forms, with or without modification,
+;are permitted provided that the following conditions are met:
+;
+; 1. Redistributions of source code must retain the above copyright notice, this
+; list of conditions and the following disclaimer.
+; 2. Redistributions in binary form must reproduce the above copyright notice,
+; this list of conditions and the following disclaimer in the documentation
+; and/or other materials provided with the distribution.
+; 3. Neither the name of the copyright holder nor the names of its contributors
+; may be used to endorse or promote products derived from this software without
+; specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+;AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+;IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+;INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+;NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+;PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+;WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+;ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+;OF SUCH DAMAGE.
+;*/
+
+ MODULE ?cstartup
+
+ ;; Forward declaration of sections.
+ SECTION CSTACK:DATA:NOROOT(3)
+
+ SECTION .intvec:CODE:NOROOT(2)
+
+ EXTERN __iar_program_start
+ EXTERN SystemInit
+ PUBLIC __vector_table
+
+ DATA
+__vector_table
+ DCD sfe(CSTACK) ; top of stack
+ DCD Reset_Handler ; Vector Number 1,Reset Handler
+
+ DCD NMI_Handler ; Vector Number 2,NMI Handler
+ DCD HardFault_Handler ; Vector Number 3,Hard Fault Handler
+ DCD MemManage_Handler ; Vector Number 4,MPU Fault Handler
+ DCD BusFault_Handler ; Vector Number 5,Bus Fault Handler
+ DCD UsageFault_Handler ; Vector Number 6,Usage Fault Handler
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD SVC_Handler ; Vector Number 11,SVCall Handler
+ DCD DebugMon_Handler ; Vector Number 12,Debug Monitor Handler
+ DCD 0 ; Reserved
+ DCD PendSV_Handler ; Vector Number 14,PendSV Handler
+ DCD SysTick_Handler ; Vector Number 15,SysTick Handler
+
+ ; External Interrupts
+ DCD WWDGT_IRQHandler ; 16:Window Watchdog Timer
+ DCD LVD_IRQHandler ; 17:LVD through EXTI Line detect
+ DCD TAMPER_STAMP_IRQHandler ; 18:Tamper and TimeStamp through EXTI Line detect
+ DCD RTC_WKUP_IRQHandler ; 19:RTC Wakeup through EXTI Line
+ DCD FMC_IRQHandler ; 20:FMC
+ DCD RCU_CTC_IRQHandler ; 21:RCU and CTC
+ DCD EXTI0_IRQHandler ; 22:EXTI Line 0
+ DCD EXTI1_IRQHandler ; 23:EXTI Line 1
+ DCD EXTI2_IRQHandler ; 24:EXTI Line 2
+ DCD EXTI3_IRQHandler ; 25:EXTI Line 3
+ DCD EXTI4_IRQHandler ; 26:EXTI Line 4
+ DCD DMA0_Channel0_IRQHandler ; 27:DMA0 Channel0
+ DCD DMA0_Channel1_IRQHandler ; 28:DMA0 Channel1
+ DCD DMA0_Channel2_IRQHandler ; 29:DMA0 Channel2
+ DCD DMA0_Channel3_IRQHandler ; 30:DMA0 Channel3
+ DCD DMA0_Channel4_IRQHandler ; 31:DMA0 Channel4
+ DCD DMA0_Channel5_IRQHandler ; 32:DMA0 Channel5
+ DCD DMA0_Channel6_IRQHandler ; 33:DMA0 Channel6
+ DCD ADC_IRQHandler ; 34:ADC
+ DCD CAN0_TX_IRQHandler ; 35:CAN0 TX
+ DCD CAN0_RX0_IRQHandler ; 36:CAN0 RX0
+ DCD CAN0_RX1_IRQHandler ; 37:CAN0 RX1
+ DCD CAN0_EWMC_IRQHandler ; 38:CAN0 EWMC
+ DCD EXTI5_9_IRQHandler ; 39:EXTI5 to EXTI9
+ DCD TIMER0_BRK_TIMER8_IRQHandler ; 40:TIMER0 Break and TIMER8
+ DCD TIMER0_UP_TIMER9_IRQHandler ; 41:TIMER0 Update and TIMER9
+ DCD TIMER0_TRG_CMT_TIMER10_IRQHandler ; 42:TIMER0 Trigger and Commucation and TIMER10
+ DCD TIMER0_Channel_IRQHandler ; 43:TIMER0 Capture Compare
+ DCD TIMER1_IRQHandler ; 44:TIMER1
+ DCD TIMER2_IRQHandler ; 45:TIMER2
+ DCD TIMER3_IRQHandler ; 46:TIMER3
+ DCD I2C0_EV_IRQHandler ; 47:I2C0 Event
+ DCD I2C0_ER_IRQHandler ; 48:I2C0 Error
+ DCD I2C1_EV_IRQHandler ; 49:I2C1 Event
+ DCD I2C1_ER_IRQHandler ; 50:I2C1 Error
+ DCD SPI0_IRQHandler ; 51:SPI0
+ DCD SPI1_IRQHandler ; 52:SPI1
+ DCD USART0_IRQHandler ; 53:USART0
+ DCD USART1_IRQHandler ; 54:USART1
+ DCD USART2_IRQHandler ; 55:USART2
+ DCD EXTI10_15_IRQHandler ; 56:EXTI10 to EXTI15
+ DCD RTC_Alarm_IRQHandler ; 57:RTC Alarm
+ DCD USBFS_WKUP_IRQHandler ; 58:USBFS Wakeup
+ DCD TIMER7_BRK_TIMER11_IRQHandler ; 59:TIMER7 Break and TIMER11
+ DCD TIMER7_UP_TIMER12_IRQHandler ; 60:TIMER7 Update and TIMER12
+ DCD TIMER7_TRG_CMT_TIMER13_IRQHandler ; 61:TIMER7 Trigger and Commucation and TIMER13
+ DCD TIMER7_Channel_IRQHandler ; 62:TIMER7 Capture Compare
+ DCD DMA0_Channel7_IRQHandler ; 63:DMA0 Channel7
+ DCD 0 ; 64:Reserved
+ DCD SDIO_IRQHandler ; 65:SDIO
+ DCD TIMER4_IRQHandler ; 66:TIMER4
+ DCD SPI2_IRQHandler ; 67:SPI2
+ DCD UART3_IRQHandler ; 68:UART3
+ DCD UART4_IRQHandler ; 69:UART4
+ DCD TIMER5_DAC_IRQHandler ; 70:TIMER5 and DAC0 DAC1 Underrun error
+ DCD TIMER6_IRQHandler ; 71:TIMER6
+ DCD DMA1_Channel0_IRQHandler ; 72:DMA1 Channel0
+ DCD DMA1_Channel1_IRQHandler ; 73:DMA1 Channel1
+ DCD DMA1_Channel2_IRQHandler ; 74:DMA1 Channel2
+ DCD DMA1_Channel3_IRQHandler ; 75:DMA1 Channel3
+ DCD DMA1_Channel4_IRQHandler ; 76:DMA1 Channel4
+ DCD 0 ; 77:Reserved
+ DCD 0 ; 78:Reserved
+ DCD CAN1_TX_IRQHandler ; 79:CAN1 TX
+ DCD CAN1_RX0_IRQHandler ; 80:CAN1 RX0
+ DCD CAN1_RX1_IRQHandler ; 81:CAN1 RX1
+ DCD CAN1_EWMC_IRQHandler ; 82:CAN1 EWMC
+ DCD USBFS_IRQHandler ; 83:USBFS
+ DCD DMA1_Channel5_IRQHandler ; 84:DMA1 Channel5
+ DCD DMA1_Channel6_IRQHandler ; 85:DMA1 Channel6
+ DCD DMA1_Channel7_IRQHandler ; 86:DMA1 Channel7
+ DCD USART5_IRQHandler ; 87:USART5
+ DCD I2C2_EV_IRQHandler ; 88:I2C2 Event
+ DCD I2C2_ER_IRQHandler ; 89:I2C2 Error
+ DCD USBHS_EP1_Out_IRQHandler ; 90:USBHS Endpoint 1 Out
+ DCD USBHS_EP1_In_IRQHandler ; 91:USBHS Endpoint 1 in
+ DCD USBHS_WKUP_IRQHandler ; 92:USBHS Wakeup through EXTI Line
+ DCD USBHS_IRQHandler ; 93:USBHS
+ DCD DCI_IRQHandler ; 94:DCI
+ DCD 0 ; 95:Reserved
+ DCD TRNG_IRQHandler ; 96:TRNG
+ DCD FPU_IRQHandler ; 97:FPU
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Default interrupt handlers.
+;;
+ THUMB
+
+ PUBWEAK Reset_Handler
+ SECTION .text:CODE:NOROOT:REORDER(2)
+Reset_Handler
+ LDR R0, =SystemInit
+ BLX R0
+ LDR R0, =__iar_program_start
+ BX R0
+
+ PUBWEAK NMI_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+NMI_Handler
+ B NMI_Handler
+
+ PUBWEAK HardFault_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+HardFault_Handler
+ B HardFault_Handler
+
+ PUBWEAK MemManage_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+MemManage_Handler
+ B MemManage_Handler
+
+ PUBWEAK BusFault_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+BusFault_Handler
+ B BusFault_Handler
+
+ PUBWEAK UsageFault_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+UsageFault_Handler
+ B UsageFault_Handler
+
+ PUBWEAK SVC_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SVC_Handler
+ B SVC_Handler
+
+ PUBWEAK DebugMon_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DebugMon_Handler
+ B DebugMon_Handler
+
+ PUBWEAK PendSV_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+PendSV_Handler
+ B PendSV_Handler
+
+ PUBWEAK SysTick_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SysTick_Handler
+ B SysTick_Handler
+
+ PUBWEAK WWDGT_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+WWDGT_IRQHandler
+ B WWDGT_IRQHandler
+
+ PUBWEAK LVD_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+LVD_IRQHandler
+ B LVD_IRQHandler
+
+ PUBWEAK TAMPER_STAMP_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TAMPER_STAMP_IRQHandler
+ B TAMPER_STAMP_IRQHandler
+
+ PUBWEAK RTC_WKUP_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+RTC_WKUP_IRQHandler
+ B RTC_WKUP_IRQHandler
+
+ PUBWEAK FMC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+FMC_IRQHandler
+ B FMC_IRQHandler
+
+ PUBWEAK RCU_CTC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+RCU_CTC_IRQHandler
+ B RCU_CTC_IRQHandler
+
+ PUBWEAK EXTI0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI0_IRQHandler
+ B EXTI0_IRQHandler
+
+ PUBWEAK EXTI1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI1_IRQHandler
+ B EXTI1_IRQHandler
+
+ PUBWEAK EXTI2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI2_IRQHandler
+ B EXTI2_IRQHandler
+
+ PUBWEAK EXTI3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI3_IRQHandler
+ B EXTI3_IRQHandler
+
+ PUBWEAK EXTI4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI4_IRQHandler
+ B EXTI4_IRQHandler
+
+ PUBWEAK DMA0_Channel0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel0_IRQHandler
+ B DMA0_Channel0_IRQHandler
+
+ PUBWEAK DMA0_Channel1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel1_IRQHandler
+ B DMA0_Channel1_IRQHandler
+
+ PUBWEAK DMA0_Channel2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel2_IRQHandler
+ B DMA0_Channel2_IRQHandler
+
+ PUBWEAK DMA0_Channel3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel3_IRQHandler
+ B DMA0_Channel3_IRQHandler
+
+ PUBWEAK DMA0_Channel4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel4_IRQHandler
+ B DMA0_Channel4_IRQHandler
+
+ PUBWEAK DMA0_Channel5_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel5_IRQHandler
+ B DMA0_Channel5_IRQHandler
+
+ PUBWEAK DMA0_Channel6_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel6_IRQHandler
+ B DMA0_Channel6_IRQHandler
+
+ PUBWEAK ADC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+ADC_IRQHandler
+ B ADC_IRQHandler
+
+ PUBWEAK CAN0_TX_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN0_TX_IRQHandler
+ B CAN0_TX_IRQHandler
+
+ PUBWEAK CAN0_RX0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN0_RX0_IRQHandler
+ B CAN0_RX0_IRQHandler
+
+ PUBWEAK CAN0_RX1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN0_RX1_IRQHandler
+ B CAN0_RX1_IRQHandler
+
+ PUBWEAK CAN0_EWMC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN0_EWMC_IRQHandler
+ B CAN0_EWMC_IRQHandler
+
+ PUBWEAK EXTI5_9_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI5_9_IRQHandler
+ B EXTI5_9_IRQHandler
+
+ PUBWEAK TIMER0_BRK_TIMER8_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER0_BRK_TIMER8_IRQHandler
+ B TIMER0_BRK_TIMER8_IRQHandler
+
+ PUBWEAK TIMER0_UP_TIMER9_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER0_UP_TIMER9_IRQHandler
+ B TIMER0_UP_TIMER9_IRQHandler
+
+ PUBWEAK TIMER0_TRG_CMT_TIMER10_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER0_TRG_CMT_TIMER10_IRQHandler
+ B TIMER0_TRG_CMT_TIMER10_IRQHandler
+
+ PUBWEAK TIMER0_Channel_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER0_Channel_IRQHandler
+ B TIMER0_Channel_IRQHandler
+
+ PUBWEAK TIMER1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER1_IRQHandler
+ B TIMER1_IRQHandler
+
+ PUBWEAK TIMER2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER2_IRQHandler
+ B TIMER2_IRQHandler
+
+ PUBWEAK TIMER3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER3_IRQHandler
+ B TIMER3_IRQHandler
+
+ PUBWEAK I2C0_EV_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C0_EV_IRQHandler
+ B I2C0_EV_IRQHandler
+
+ PUBWEAK I2C0_ER_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C0_ER_IRQHandler
+ B I2C0_ER_IRQHandler
+
+ PUBWEAK I2C1_EV_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C1_EV_IRQHandler
+ B I2C1_EV_IRQHandler
+
+ PUBWEAK I2C1_ER_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C1_ER_IRQHandler
+ B I2C1_ER_IRQHandler
+
+ PUBWEAK SPI0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SPI0_IRQHandler
+ B SPI0_IRQHandler
+
+ PUBWEAK SPI1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SPI1_IRQHandler
+ B SPI1_IRQHandler
+
+ PUBWEAK USART0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USART0_IRQHandler
+ B USART0_IRQHandler
+
+ PUBWEAK USART1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USART1_IRQHandler
+ B USART1_IRQHandler
+
+ PUBWEAK USART2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USART2_IRQHandler
+ B USART2_IRQHandler
+
+ PUBWEAK EXTI10_15_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI10_15_IRQHandler
+ B EXTI10_15_IRQHandler
+
+ PUBWEAK RTC_Alarm_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+RTC_Alarm_IRQHandler
+ B RTC_Alarm_IRQHandler
+
+ PUBWEAK USBFS_WKUP_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBFS_WKUP_IRQHandler
+ B USBFS_WKUP_IRQHandler
+
+ PUBWEAK TIMER7_BRK_TIMER11_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER7_BRK_TIMER11_IRQHandler
+ B TIMER7_BRK_TIMER11_IRQHandler
+
+ PUBWEAK TIMER7_UP_TIMER12_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER7_UP_TIMER12_IRQHandler
+ B TIMER7_UP_TIMER12_IRQHandler
+
+ PUBWEAK TIMER7_TRG_CMT_TIMER13_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER7_TRG_CMT_TIMER13_IRQHandler
+ B TIMER7_TRG_CMT_TIMER13_IRQHandler
+
+ PUBWEAK TIMER7_Channel_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER7_Channel_IRQHandler
+ B TIMER7_Channel_IRQHandler
+
+ PUBWEAK DMA0_Channel7_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel7_IRQHandler
+ B DMA0_Channel7_IRQHandler
+
+ PUBWEAK SDIO_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SDIO_IRQHandler
+ B SDIO_IRQHandler
+
+ PUBWEAK TIMER4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER4_IRQHandler
+ B TIMER4_IRQHandler
+
+ PUBWEAK SPI2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SPI2_IRQHandler
+ B SPI2_IRQHandler
+
+ PUBWEAK UART3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+UART3_IRQHandler
+ B UART3_IRQHandler
+
+ PUBWEAK UART4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+UART4_IRQHandler
+ B UART4_IRQHandler
+
+ PUBWEAK TIMER5_DAC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER5_DAC_IRQHandler
+ B TIMER5_DAC_IRQHandler
+
+ PUBWEAK TIMER6_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER6_IRQHandler
+ B TIMER6_IRQHandler
+
+ PUBWEAK DMA1_Channel0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel0_IRQHandler
+ B DMA1_Channel0_IRQHandler
+
+ PUBWEAK DMA1_Channel1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel1_IRQHandler
+ B DMA1_Channel1_IRQHandler
+
+ PUBWEAK DMA1_Channel2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel2_IRQHandler
+ B DMA1_Channel2_IRQHandler
+
+ PUBWEAK DMA1_Channel3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel3_IRQHandler
+ B DMA1_Channel3_IRQHandler
+
+ PUBWEAK DMA1_Channel4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel4_IRQHandler
+ B DMA1_Channel4_IRQHandler
+
+ PUBWEAK CAN1_TX_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN1_TX_IRQHandler
+ B CAN1_TX_IRQHandler
+
+ PUBWEAK CAN1_RX0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN1_RX0_IRQHandler
+ B CAN1_RX0_IRQHandler
+
+ PUBWEAK CAN1_RX1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN1_RX1_IRQHandler
+ B CAN1_RX1_IRQHandler
+
+ PUBWEAK CAN1_EWMC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN1_EWMC_IRQHandler
+ B CAN1_EWMC_IRQHandler
+
+ PUBWEAK USBFS_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBFS_IRQHandler
+ B USBFS_IRQHandler
+
+ PUBWEAK DMA1_Channel5_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel5_IRQHandler
+ B DMA1_Channel5_IRQHandler
+
+ PUBWEAK DMA1_Channel6_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel6_IRQHandler
+ B DMA1_Channel6_IRQHandler
+
+ PUBWEAK DMA1_Channel7_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel7_IRQHandler
+ B DMA1_Channel7_IRQHandler
+
+ PUBWEAK USART5_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USART5_IRQHandler
+ B USART5_IRQHandler
+
+ PUBWEAK I2C2_EV_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C2_EV_IRQHandler
+ B I2C2_EV_IRQHandler
+
+ PUBWEAK I2C2_ER_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C2_ER_IRQHandler
+ B I2C2_ER_IRQHandler
+
+ PUBWEAK USBHS_EP1_Out_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBHS_EP1_Out_IRQHandler
+ B USBHS_EP1_Out_IRQHandler
+
+ PUBWEAK USBHS_EP1_In_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBHS_EP1_In_IRQHandler
+ B USBHS_EP1_In_IRQHandler
+
+ PUBWEAK USBHS_WKUP_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBHS_WKUP_IRQHandler
+ B USBHS_WKUP_IRQHandler
+
+ PUBWEAK USBHS_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBHS_IRQHandler
+ B USBHS_IRQHandler
+
+ PUBWEAK DCI_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DCI_IRQHandler
+ B DCI_IRQHandler
+
+ PUBWEAK TRNG_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TRNG_IRQHandler
+ B TRNG_IRQHandler
+
+ PUBWEAK FPU_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+FPU_IRQHandler
+ B FPU_IRQHandler
+
+ END \ No newline at end of file
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/IAR/startup_gd32f407_427.s b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/IAR/startup_gd32f407_427.s
new file mode 100644
index 0000000000..c11f8e7851
--- /dev/null
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/IAR/startup_gd32f407_427.s
@@ -0,0 +1,617 @@
+;/*!
+; \file startup_gd32f407_427.s
+; \brief start up file
+;
+; \version 2016-08-15, V1.0.0, firmware for GD32F4xx
+; \version 2018-12-12, V2.0.0, firmware for GD32F4xx
+; \version 2020-09-30, V2.1.0, firmware for GD32F4xx
+; \version 2022-03-09, V3.0.0, firmware for GD32F4xx
+;*/
+;
+;/*
+; Copyright (c) 2022, GigaDevice Semiconductor Inc.
+;
+; Redistribution and use in source and binary forms, with or without modification,
+;are permitted provided that the following conditions are met:
+;
+; 1. Redistributions of source code must retain the above copyright notice, this
+; list of conditions and the following disclaimer.
+; 2. Redistributions in binary form must reproduce the above copyright notice,
+; this list of conditions and the following disclaimer in the documentation
+; and/or other materials provided with the distribution.
+; 3. Neither the name of the copyright holder nor the names of its contributors
+; may be used to endorse or promote products derived from this software without
+; specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+;AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+;IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+;INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+;NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+;PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+;WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+;ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+;OF SUCH DAMAGE.
+;*/
+
+ MODULE ?cstartup
+
+ ;; Forward declaration of sections.
+ SECTION CSTACK:DATA:NOROOT(3)
+
+ SECTION .intvec:CODE:NOROOT(2)
+
+ EXTERN __iar_program_start
+ EXTERN SystemInit
+ PUBLIC __vector_table
+
+ DATA
+__vector_table
+ DCD sfe(CSTACK) ; top of stack
+ DCD Reset_Handler ; Vector Number 1,Reset Handler
+
+ DCD NMI_Handler ; Vector Number 2,NMI Handler
+ DCD HardFault_Handler ; Vector Number 3,Hard Fault Handler
+ DCD MemManage_Handler ; Vector Number 4,MPU Fault Handler
+ DCD BusFault_Handler ; Vector Number 5,Bus Fault Handler
+ DCD UsageFault_Handler ; Vector Number 6,Usage Fault Handler
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD SVC_Handler ; Vector Number 11,SVCall Handler
+ DCD DebugMon_Handler ; Vector Number 12,Debug Monitor Handler
+ DCD 0 ; Reserved
+ DCD PendSV_Handler ; Vector Number 14,PendSV Handler
+ DCD SysTick_Handler ; Vector Number 15,SysTick Handler
+
+ ; External Interrupts
+ DCD WWDGT_IRQHandler ; 16:Window Watchdog Timer
+ DCD LVD_IRQHandler ; 17:LVD through EXTI Line detect
+ DCD TAMPER_STAMP_IRQHandler ; 18:Tamper and TimeStamp through EXTI Line detect
+ DCD RTC_WKUP_IRQHandler ; 19:RTC Wakeup through EXTI Line
+ DCD FMC_IRQHandler ; 20:FMC
+ DCD RCU_CTC_IRQHandler ; 21:RCU and CTC
+ DCD EXTI0_IRQHandler ; 22:EXTI Line 0
+ DCD EXTI1_IRQHandler ; 23:EXTI Line 1
+ DCD EXTI2_IRQHandler ; 24:EXTI Line 2
+ DCD EXTI3_IRQHandler ; 25:EXTI Line 3
+ DCD EXTI4_IRQHandler ; 26:EXTI Line 4
+ DCD DMA0_Channel0_IRQHandler ; 27:DMA0 Channel0
+ DCD DMA0_Channel1_IRQHandler ; 28:DMA0 Channel1
+ DCD DMA0_Channel2_IRQHandler ; 29:DMA0 Channel2
+ DCD DMA0_Channel3_IRQHandler ; 30:DMA0 Channel3
+ DCD DMA0_Channel4_IRQHandler ; 31:DMA0 Channel4
+ DCD DMA0_Channel5_IRQHandler ; 32:DMA0 Channel5
+ DCD DMA0_Channel6_IRQHandler ; 33:DMA0 Channel6
+ DCD ADC_IRQHandler ; 34:ADC
+ DCD CAN0_TX_IRQHandler ; 35:CAN0 TX
+ DCD CAN0_RX0_IRQHandler ; 36:CAN0 RX0
+ DCD CAN0_RX1_IRQHandler ; 37:CAN0 RX1
+ DCD CAN0_EWMC_IRQHandler ; 38:CAN0 EWMC
+ DCD EXTI5_9_IRQHandler ; 39:EXTI5 to EXTI9
+ DCD TIMER0_BRK_TIMER8_IRQHandler ; 40:TIMER0 Break and TIMER8
+ DCD TIMER0_UP_TIMER9_IRQHandler ; 41:TIMER0 Update and TIMER9
+ DCD TIMER0_TRG_CMT_TIMER10_IRQHandler ; 42:TIMER0 Trigger and Commucation and TIMER10
+ DCD TIMER0_Channel_IRQHandler ; 43:TIMER0 Capture Compare
+ DCD TIMER1_IRQHandler ; 44:TIMER1
+ DCD TIMER2_IRQHandler ; 45:TIMER2
+ DCD TIMER3_IRQHandler ; 46:TIMER3
+ DCD I2C0_EV_IRQHandler ; 47:I2C0 Event
+ DCD I2C0_ER_IRQHandler ; 48:I2C0 Error
+ DCD I2C1_EV_IRQHandler ; 49:I2C1 Event
+ DCD I2C1_ER_IRQHandler ; 50:I2C1 Error
+ DCD SPI0_IRQHandler ; 51:SPI0
+ DCD SPI1_IRQHandler ; 52:SPI1
+ DCD USART0_IRQHandler ; 53:USART0
+ DCD USART1_IRQHandler ; 54:USART1
+ DCD USART2_IRQHandler ; 55:USART2
+ DCD EXTI10_15_IRQHandler ; 56:EXTI10 to EXTI15
+ DCD RTC_Alarm_IRQHandler ; 57:RTC Alarm
+ DCD USBFS_WKUP_IRQHandler ; 58:USBFS Wakeup
+ DCD TIMER7_BRK_TIMER11_IRQHandler ; 59:TIMER7 Break and TIMER11
+ DCD TIMER7_UP_TIMER12_IRQHandler ; 60:TIMER7 Update and TIMER12
+ DCD TIMER7_TRG_CMT_TIMER13_IRQHandler ; 61:TIMER7 Trigger and Commucation and TIMER13
+ DCD TIMER7_Channel_IRQHandler ; 62:TIMER7 Channel Capture Compare
+ DCD DMA0_Channel7_IRQHandler ; 63:DMA0 Channel7
+ DCD EXMC_IRQHandler ; 64:EXMC
+ DCD SDIO_IRQHandler ; 65:SDIO
+ DCD TIMER4_IRQHandler ; 66:TIMER4
+ DCD SPI2_IRQHandler ; 67:SPI2
+ DCD UART3_IRQHandler ; 68:UART3
+ DCD UART4_IRQHandler ; 69:UART4
+ DCD TIMER5_DAC_IRQHandler ; 70:TIMER5 and DAC0 DAC1 Underrun error
+ DCD TIMER6_IRQHandler ; 71:TIMER6
+ DCD DMA1_Channel0_IRQHandler ; 72:DMA1 Channel0
+ DCD DMA1_Channel1_IRQHandler ; 73:DMA1 Channel1
+ DCD DMA1_Channel2_IRQHandler ; 74:DMA1 Channel2
+ DCD DMA1_Channel3_IRQHandler ; 75:DMA1 Channel3
+ DCD DMA1_Channel4_IRQHandler ; 76:DMA1 Channel4
+ DCD ENET_IRQHandler ; 77:Ethernet
+ DCD ENET_WKUP_IRQHandler ; 78:Ethernet Wakeup through EXTI Line
+ DCD CAN1_TX_IRQHandler ; 79:CAN1 TX
+ DCD CAN1_RX0_IRQHandler ; 80:CAN1 RX0
+ DCD CAN1_RX1_IRQHandler ; 81:CAN1 RX1
+ DCD CAN1_EWMC_IRQHandler ; 82:CAN1 EWMC
+ DCD USBFS_IRQHandler ; 83:USBFS
+ DCD DMA1_Channel5_IRQHandler ; 84:DMA1 Channel5
+ DCD DMA1_Channel6_IRQHandler ; 85:DMA1 Channel6
+ DCD DMA1_Channel7_IRQHandler ; 86:DMA1 Channel7
+ DCD USART5_IRQHandler ; 87:USART5
+ DCD I2C2_EV_IRQHandler ; 88:I2C2 Event
+ DCD I2C2_ER_IRQHandler ; 89:I2C2 Error
+ DCD USBHS_EP1_Out_IRQHandler ; 90:USBHS Endpoint 1 Out
+ DCD USBHS_EP1_In_IRQHandler ; 91:USBHS Endpoint 1 in
+ DCD USBHS_WKUP_IRQHandler ; 92:USBHS Wakeup through EXTI Line
+ DCD USBHS_IRQHandler ; 93:USBHS
+ DCD DCI_IRQHandler ; 94:DCI
+ DCD 0 ; 95:Reserved
+ DCD TRNG_IRQHandler ; 96:TRNG
+ DCD FPU_IRQHandler ; 97:FPU
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Default interrupt handlers.
+;;
+ THUMB
+
+ PUBWEAK Reset_Handler
+ SECTION .text:CODE:NOROOT:REORDER(2)
+Reset_Handler
+ LDR R0, =SystemInit
+ BLX R0
+ LDR R0, =__iar_program_start
+ BX R0
+
+ PUBWEAK NMI_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+NMI_Handler
+ B NMI_Handler
+
+ PUBWEAK HardFault_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+HardFault_Handler
+ B HardFault_Handler
+
+ PUBWEAK MemManage_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+MemManage_Handler
+ B MemManage_Handler
+
+ PUBWEAK BusFault_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+BusFault_Handler
+ B BusFault_Handler
+
+ PUBWEAK UsageFault_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+UsageFault_Handler
+ B UsageFault_Handler
+
+ PUBWEAK SVC_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SVC_Handler
+ B SVC_Handler
+
+ PUBWEAK DebugMon_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DebugMon_Handler
+ B DebugMon_Handler
+
+ PUBWEAK PendSV_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+PendSV_Handler
+ B PendSV_Handler
+
+ PUBWEAK SysTick_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SysTick_Handler
+ B SysTick_Handler
+
+ PUBWEAK WWDGT_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+WWDGT_IRQHandler
+ B WWDGT_IRQHandler
+
+ PUBWEAK LVD_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+LVD_IRQHandler
+ B LVD_IRQHandler
+
+ PUBWEAK TAMPER_STAMP_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TAMPER_STAMP_IRQHandler
+ B TAMPER_STAMP_IRQHandler
+
+ PUBWEAK RTC_WKUP_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+RTC_WKUP_IRQHandler
+ B RTC_WKUP_IRQHandler
+
+ PUBWEAK FMC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+FMC_IRQHandler
+ B FMC_IRQHandler
+
+ PUBWEAK RCU_CTC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+RCU_CTC_IRQHandler
+ B RCU_CTC_IRQHandler
+
+ PUBWEAK EXTI0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI0_IRQHandler
+ B EXTI0_IRQHandler
+
+ PUBWEAK EXTI1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI1_IRQHandler
+ B EXTI1_IRQHandler
+
+ PUBWEAK EXTI2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI2_IRQHandler
+ B EXTI2_IRQHandler
+
+ PUBWEAK EXTI3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI3_IRQHandler
+ B EXTI3_IRQHandler
+
+ PUBWEAK EXTI4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI4_IRQHandler
+ B EXTI4_IRQHandler
+
+ PUBWEAK DMA0_Channel0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel0_IRQHandler
+ B DMA0_Channel0_IRQHandler
+
+ PUBWEAK DMA0_Channel1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel1_IRQHandler
+ B DMA0_Channel1_IRQHandler
+
+ PUBWEAK DMA0_Channel2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel2_IRQHandler
+ B DMA0_Channel2_IRQHandler
+
+ PUBWEAK DMA0_Channel3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel3_IRQHandler
+ B DMA0_Channel3_IRQHandler
+
+ PUBWEAK DMA0_Channel4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel4_IRQHandler
+ B DMA0_Channel4_IRQHandler
+
+ PUBWEAK DMA0_Channel5_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel5_IRQHandler
+ B DMA0_Channel5_IRQHandler
+
+ PUBWEAK DMA0_Channel6_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel6_IRQHandler
+ B DMA0_Channel6_IRQHandler
+
+ PUBWEAK ADC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+ADC_IRQHandler
+ B ADC_IRQHandler
+
+ PUBWEAK CAN0_TX_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN0_TX_IRQHandler
+ B CAN0_TX_IRQHandler
+
+ PUBWEAK CAN0_RX0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN0_RX0_IRQHandler
+ B CAN0_RX0_IRQHandler
+
+ PUBWEAK CAN0_RX1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN0_RX1_IRQHandler
+ B CAN0_RX1_IRQHandler
+
+ PUBWEAK CAN0_EWMC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN0_EWMC_IRQHandler
+ B CAN0_EWMC_IRQHandler
+
+ PUBWEAK EXTI5_9_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI5_9_IRQHandler
+ B EXTI5_9_IRQHandler
+
+ PUBWEAK TIMER0_BRK_TIMER8_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER0_BRK_TIMER8_IRQHandler
+ B TIMER0_BRK_TIMER8_IRQHandler
+
+ PUBWEAK TIMER0_UP_TIMER9_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER0_UP_TIMER9_IRQHandler
+ B TIMER0_UP_TIMER9_IRQHandler
+
+ PUBWEAK TIMER0_TRG_CMT_TIMER10_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER0_TRG_CMT_TIMER10_IRQHandler
+ B TIMER0_TRG_CMT_TIMER10_IRQHandler
+
+ PUBWEAK TIMER0_Channel_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER0_Channel_IRQHandler
+ B TIMER0_Channel_IRQHandler
+
+ PUBWEAK TIMER1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER1_IRQHandler
+ B TIMER1_IRQHandler
+
+ PUBWEAK TIMER2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER2_IRQHandler
+ B TIMER2_IRQHandler
+
+ PUBWEAK TIMER3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER3_IRQHandler
+ B TIMER3_IRQHandler
+
+ PUBWEAK I2C0_EV_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C0_EV_IRQHandler
+ B I2C0_EV_IRQHandler
+
+ PUBWEAK I2C0_ER_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C0_ER_IRQHandler
+ B I2C0_ER_IRQHandler
+
+ PUBWEAK I2C1_EV_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C1_EV_IRQHandler
+ B I2C1_EV_IRQHandler
+
+ PUBWEAK I2C1_ER_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C1_ER_IRQHandler
+ B I2C1_ER_IRQHandler
+
+ PUBWEAK SPI0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SPI0_IRQHandler
+ B SPI0_IRQHandler
+
+ PUBWEAK SPI1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SPI1_IRQHandler
+ B SPI1_IRQHandler
+
+ PUBWEAK USART0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USART0_IRQHandler
+ B USART0_IRQHandler
+
+ PUBWEAK USART1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USART1_IRQHandler
+ B USART1_IRQHandler
+
+ PUBWEAK USART2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USART2_IRQHandler
+ B USART2_IRQHandler
+
+ PUBWEAK EXTI10_15_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI10_15_IRQHandler
+ B EXTI10_15_IRQHandler
+
+ PUBWEAK RTC_Alarm_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+RTC_Alarm_IRQHandler
+ B RTC_Alarm_IRQHandler
+
+ PUBWEAK USBFS_WKUP_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBFS_WKUP_IRQHandler
+ B USBFS_WKUP_IRQHandler
+
+ PUBWEAK TIMER7_BRK_TIMER11_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER7_BRK_TIMER11_IRQHandler
+ B TIMER7_BRK_TIMER11_IRQHandler
+
+ PUBWEAK TIMER7_UP_TIMER12_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER7_UP_TIMER12_IRQHandler
+ B TIMER7_UP_TIMER12_IRQHandler
+
+ PUBWEAK TIMER7_TRG_CMT_TIMER13_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER7_TRG_CMT_TIMER13_IRQHandler
+ B TIMER7_TRG_CMT_TIMER13_IRQHandler
+
+ PUBWEAK TIMER7_Channel_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER7_Channel_IRQHandler
+ B TIMER7_Channel_IRQHandler
+
+ PUBWEAK DMA0_Channel7_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel7_IRQHandler
+ B DMA0_Channel7_IRQHandler
+
+ PUBWEAK EXMC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXMC_IRQHandler
+ B EXMC_IRQHandler
+
+ PUBWEAK SDIO_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SDIO_IRQHandler
+ B SDIO_IRQHandler
+
+ PUBWEAK TIMER4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER4_IRQHandler
+ B TIMER4_IRQHandler
+
+ PUBWEAK SPI2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SPI2_IRQHandler
+ B SPI2_IRQHandler
+
+ PUBWEAK UART3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+UART3_IRQHandler
+ B UART3_IRQHandler
+
+ PUBWEAK UART4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+UART4_IRQHandler
+ B UART4_IRQHandler
+
+ PUBWEAK TIMER5_DAC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER5_DAC_IRQHandler
+ B TIMER5_DAC_IRQHandler
+
+ PUBWEAK TIMER6_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER6_IRQHandler
+ B TIMER6_IRQHandler
+
+ PUBWEAK DMA1_Channel0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel0_IRQHandler
+ B DMA1_Channel0_IRQHandler
+
+ PUBWEAK DMA1_Channel1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel1_IRQHandler
+ B DMA1_Channel1_IRQHandler
+
+ PUBWEAK DMA1_Channel2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel2_IRQHandler
+ B DMA1_Channel2_IRQHandler
+
+ PUBWEAK DMA1_Channel3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel3_IRQHandler
+ B DMA1_Channel3_IRQHandler
+
+ PUBWEAK DMA1_Channel4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel4_IRQHandler
+ B DMA1_Channel4_IRQHandler
+
+ PUBWEAK ENET_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+ENET_IRQHandler
+ B ENET_IRQHandler
+
+ PUBWEAK ENET_WKUP_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+ENET_WKUP_IRQHandler
+ B ENET_WKUP_IRQHandler
+
+ PUBWEAK CAN1_TX_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN1_TX_IRQHandler
+ B CAN1_TX_IRQHandler
+
+ PUBWEAK CAN1_RX0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN1_RX0_IRQHandler
+ B CAN1_RX0_IRQHandler
+
+ PUBWEAK CAN1_RX1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN1_RX1_IRQHandler
+ B CAN1_RX1_IRQHandler
+
+ PUBWEAK CAN1_EWMC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN1_EWMC_IRQHandler
+ B CAN1_EWMC_IRQHandler
+
+ PUBWEAK USBFS_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBFS_IRQHandler
+ B USBFS_IRQHandler
+
+ PUBWEAK DMA1_Channel5_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel5_IRQHandler
+ B DMA1_Channel5_IRQHandler
+
+ PUBWEAK DMA1_Channel6_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel6_IRQHandler
+ B DMA1_Channel6_IRQHandler
+
+ PUBWEAK DMA1_Channel7_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel7_IRQHandler
+ B DMA1_Channel7_IRQHandler
+
+ PUBWEAK USART5_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USART5_IRQHandler
+ B USART5_IRQHandler
+
+ PUBWEAK I2C2_EV_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C2_EV_IRQHandler
+ B I2C2_EV_IRQHandler
+
+ PUBWEAK I2C2_ER_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C2_ER_IRQHandler
+ B I2C2_ER_IRQHandler
+
+ PUBWEAK USBHS_EP1_Out_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBHS_EP1_Out_IRQHandler
+ B USBHS_EP1_Out_IRQHandler
+
+ PUBWEAK USBHS_EP1_In_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBHS_EP1_In_IRQHandler
+ B USBHS_EP1_In_IRQHandler
+
+ PUBWEAK USBHS_WKUP_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBHS_WKUP_IRQHandler
+ B USBHS_WKUP_IRQHandler
+
+ PUBWEAK USBHS_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBHS_IRQHandler
+ B USBHS_IRQHandler
+
+ PUBWEAK DCI_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DCI_IRQHandler
+ B DCI_IRQHandler
+
+ PUBWEAK TRNG_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TRNG_IRQHandler
+ B TRNG_IRQHandler
+
+ PUBWEAK FPU_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+FPU_IRQHandler
+ B FPU_IRQHandler
+
+ END \ No newline at end of file
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/IAR/startup_gd32f450_470.s b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/IAR/startup_gd32f450_470.s
new file mode 100644
index 0000000000..6727f0714e
--- /dev/null
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/IAR/startup_gd32f450_470.s
@@ -0,0 +1,666 @@
+;/*!
+; \file startup_gd32f450_470.s
+; \brief start up file
+;
+; \version 2016-08-15, V1.0.0, firmware for GD32F4xx
+; \version 2018-12-12, V2.0.0, firmware for GD32F4xx
+; \version 2020-09-30, V2.1.0, firmware for GD32F4xx
+; \version 2022-03-09, V3.0.0, firmware for GD32F4xx
+;*/
+;
+;/*
+; Copyright (c) 2022, GigaDevice Semiconductor Inc.
+;
+; Redistribution and use in source and binary forms, with or without modification,
+;are permitted provided that the following conditions are met:
+;
+; 1. Redistributions of source code must retain the above copyright notice, this
+; list of conditions and the following disclaimer.
+; 2. Redistributions in binary form must reproduce the above copyright notice,
+; this list of conditions and the following disclaimer in the documentation
+; and/or other materials provided with the distribution.
+; 3. Neither the name of the copyright holder nor the names of its contributors
+; may be used to endorse or promote products derived from this software without
+; specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+;AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+;IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+;INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+;NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+;PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+;WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+;ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+;OF SUCH DAMAGE.
+;*/
+
+ MODULE ?cstartup
+
+ ;; Forward declaration of sections.
+ SECTION CSTACK:DATA:NOROOT(3)
+
+ SECTION .intvec:CODE:NOROOT(2)
+
+ EXTERN __iar_program_start
+ EXTERN SystemInit
+ PUBLIC __vector_table
+
+ DATA
+__vector_table
+ DCD sfe(CSTACK) ; top of stack
+ DCD Reset_Handler ; Vector Number 1,Reset Handler
+
+ DCD NMI_Handler ; Vector Number 2,NMI Handler
+ DCD HardFault_Handler ; Vector Number 3,Hard Fault Handler
+ DCD MemManage_Handler ; Vector Number 4,MPU Fault Handler
+ DCD BusFault_Handler ; Vector Number 5,Bus Fault Handler
+ DCD UsageFault_Handler ; Vector Number 6,Usage Fault Handler
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD SVC_Handler ; Vector Number 11,SVCall Handler
+ DCD DebugMon_Handler ; Vector Number 12,Debug Monitor Handler
+ DCD 0 ; Reserved
+ DCD PendSV_Handler ; Vector Number 14,PendSV Handler
+ DCD SysTick_Handler ; Vector Number 15,SysTick Handler
+
+ ; External Interrupts
+ DCD WWDGT_IRQHandler ; 16:Window Watchdog Timer
+ DCD LVD_IRQHandler ; 17:LVD through EXTI Line detect
+ DCD TAMPER_STAMP_IRQHandler ; 18:Tamper and TimeStamp through EXTI Line detect
+ DCD RTC_WKUP_IRQHandler ; 19:RTC Wakeup through EXTI Line
+ DCD FMC_IRQHandler ; 20:FMC
+ DCD RCU_CTC_IRQHandler ; 21:RCU and CTC
+ DCD EXTI0_IRQHandler ; 22:EXTI Line 0
+ DCD EXTI1_IRQHandler ; 23:EXTI Line 1
+ DCD EXTI2_IRQHandler ; 24:EXTI Line 2
+ DCD EXTI3_IRQHandler ; 25:EXTI Line 3
+ DCD EXTI4_IRQHandler ; 26:EXTI Line 4
+ DCD DMA0_Channel0_IRQHandler ; 27:DMA0 Channel0
+ DCD DMA0_Channel1_IRQHandler ; 28:DMA0 Channel1
+ DCD DMA0_Channel2_IRQHandler ; 29:DMA0 Channel2
+ DCD DMA0_Channel3_IRQHandler ; 30:DMA0 Channel3
+ DCD DMA0_Channel4_IRQHandler ; 31:DMA0 Channel4
+ DCD DMA0_Channel5_IRQHandler ; 32:DMA0 Channel5
+ DCD DMA0_Channel6_IRQHandler ; 33:DMA0 Channel6
+ DCD ADC_IRQHandler ; 34:ADC
+ DCD CAN0_TX_IRQHandler ; 35:CAN0 TX
+ DCD CAN0_RX0_IRQHandler ; 36:CAN0 RX0
+ DCD CAN0_RX1_IRQHandler ; 37:CAN0 RX1
+ DCD CAN0_EWMC_IRQHandler ; 38:CAN0 EWMC
+ DCD EXTI5_9_IRQHandler ; 39:EXTI5 to EXTI9
+ DCD TIMER0_BRK_TIMER8_IRQHandler ; 40:TIMER0 Break and TIMER8
+ DCD TIMER0_UP_TIMER9_IRQHandler ; 41:TIMER0 Update and TIMER9
+ DCD TIMER0_TRG_CMT_TIMER10_IRQHandler ; 42:TIMER0 Trigger and Commucation and TIMER10
+ DCD TIMER0_Channel_IRQHandler ; 43:TIMER0 Channel Capture Compare
+ DCD TIMER1_IRQHandler ; 44:TIMER1
+ DCD TIMER2_IRQHandler ; 45:TIMER2
+ DCD TIMER3_IRQHandler ; 46:TIMER3
+ DCD I2C0_EV_IRQHandler ; 47:I2C0 Event
+ DCD I2C0_ER_IRQHandler ; 48:I2C0 Error
+ DCD I2C1_EV_IRQHandler ; 49:I2C1 Event
+ DCD I2C1_ER_IRQHandler ; 50:I2C1 Error
+ DCD SPI0_IRQHandler ; 51:SPI0
+ DCD SPI1_IRQHandler ; 52:SPI1
+ DCD USART0_IRQHandler ; 53:USART0
+ DCD USART1_IRQHandler ; 54:USART1
+ DCD USART2_IRQHandler ; 55:USART2
+ DCD EXTI10_15_IRQHandler ; 56:EXTI10 to EXTI15
+ DCD RTC_Alarm_IRQHandler ; 57:RTC Alarm
+ DCD USBFS_WKUP_IRQHandler ; 58:USBFS Wakeup
+ DCD TIMER7_BRK_TIMER11_IRQHandler ; 59:TIMER7 Break and TIMER11
+ DCD TIMER7_UP_TIMER12_IRQHandler ; 60:TIMER7 Update and TIMER12
+ DCD TIMER7_TRG_CMT_TIMER13_IRQHandler ; 61:TIMER7 Trigger and Commucation and TIMER13
+ DCD TIMER7_Channel_IRQHandler ; 62:TIMER7 Channel Capture Compare
+ DCD DMA0_Channel7_IRQHandler ; 63:DMA0 Channel7
+ DCD EXMC_IRQHandler ; 64:EXMC
+ DCD SDIO_IRQHandler ; 65:SDIO
+ DCD TIMER4_IRQHandler ; 66:TIMER4
+ DCD SPI2_IRQHandler ; 67:SPI2
+ DCD UART3_IRQHandler ; 68:UART3
+ DCD UART4_IRQHandler ; 69:UART4
+ DCD TIMER5_DAC_IRQHandler ; 70:TIMER5 and DAC0 DAC1 Underrun error
+ DCD TIMER6_IRQHandler ; 71:TIMER6
+ DCD DMA1_Channel0_IRQHandler ; 72:DMA1 Channel0
+ DCD DMA1_Channel1_IRQHandler ; 73:DMA1 Channel1
+ DCD DMA1_Channel2_IRQHandler ; 74:DMA1 Channel2
+ DCD DMA1_Channel3_IRQHandler ; 75:DMA1 Channel3
+ DCD DMA1_Channel4_IRQHandler ; 76:DMA1 Channel4
+ DCD ENET_IRQHandler ; 77:Ethernet
+ DCD ENET_WKUP_IRQHandler ; 78:Ethernet Wakeup through EXTI Line
+ DCD CAN1_TX_IRQHandler ; 79:CAN1 TX
+ DCD CAN1_RX0_IRQHandler ; 80:CAN1 RX0
+ DCD CAN1_RX1_IRQHandler ; 81:CAN1 RX1
+ DCD CAN1_EWMC_IRQHandler ; 82:CAN1 EWMC
+ DCD USBFS_IRQHandler ; 83:USBFS
+ DCD DMA1_Channel5_IRQHandler ; 84:DMA1 Channel5
+ DCD DMA1_Channel6_IRQHandler ; 85:DMA1 Channel6
+ DCD DMA1_Channel7_IRQHandler ; 86:DMA1 Channel7
+ DCD USART5_IRQHandler ; 87:USART5
+ DCD I2C2_EV_IRQHandler ; 88:I2C2 Event
+ DCD I2C2_ER_IRQHandler ; 89:I2C2 Error
+ DCD USBHS_EP1_Out_IRQHandler ; 90:USBHS Endpoint 1 Out
+ DCD USBHS_EP1_In_IRQHandler ; 91:USBHS Endpoint 1 in
+ DCD USBHS_WKUP_IRQHandler ; 92:USBHS Wakeup through EXTI Line
+ DCD USBHS_IRQHandler ; 93:USBHS
+ DCD DCI_IRQHandler ; 94:DCI
+ DCD 0 ; 95:Reserved
+ DCD TRNG_IRQHandler ; 96:TRNG
+ DCD FPU_IRQHandler ; 97:FPU
+ DCD UART6_IRQHandler ; 98:UART6
+ DCD UART7_IRQHandler ; 99:UART7
+ DCD SPI3_IRQHandler ; 100:SPI3
+ DCD SPI4_IRQHandler ; 101:SPI4
+ DCD SPI5_IRQHandler ; 102:SPI5
+ DCD 0 ; 103:Reserved
+ DCD TLI_IRQHandler ; 104:TLI
+ DCD TLI_ER_IRQHandler ; 105:TLI Error
+ DCD IPA_IRQHandler ; 106:IPA
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Default interrupt handlers.
+;;
+ THUMB
+
+ PUBWEAK Reset_Handler
+ SECTION .text:CODE:NOROOT:REORDER(2)
+Reset_Handler
+ LDR R0, =SystemInit
+ BLX R0
+ LDR R0, =__iar_program_start
+ BX R0
+
+ PUBWEAK NMI_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+NMI_Handler
+ B NMI_Handler
+
+ PUBWEAK HardFault_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+HardFault_Handler
+ B HardFault_Handler
+
+ PUBWEAK MemManage_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+MemManage_Handler
+ B MemManage_Handler
+
+ PUBWEAK BusFault_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+BusFault_Handler
+ B BusFault_Handler
+
+ PUBWEAK UsageFault_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+UsageFault_Handler
+ B UsageFault_Handler
+
+ PUBWEAK SVC_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SVC_Handler
+ B SVC_Handler
+
+ PUBWEAK DebugMon_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DebugMon_Handler
+ B DebugMon_Handler
+
+ PUBWEAK PendSV_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+PendSV_Handler
+ B PendSV_Handler
+
+ PUBWEAK SysTick_Handler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SysTick_Handler
+ B SysTick_Handler
+
+ PUBWEAK WWDGT_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+WWDGT_IRQHandler
+ B WWDGT_IRQHandler
+
+ PUBWEAK LVD_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+LVD_IRQHandler
+ B LVD_IRQHandler
+
+ PUBWEAK TAMPER_STAMP_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TAMPER_STAMP_IRQHandler
+ B TAMPER_STAMP_IRQHandler
+
+ PUBWEAK RTC_WKUP_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+RTC_WKUP_IRQHandler
+ B RTC_WKUP_IRQHandler
+
+ PUBWEAK FMC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+FMC_IRQHandler
+ B FMC_IRQHandler
+
+ PUBWEAK RCU_CTC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+RCU_CTC_IRQHandler
+ B RCU_CTC_IRQHandler
+
+ PUBWEAK EXTI0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI0_IRQHandler
+ B EXTI0_IRQHandler
+
+ PUBWEAK EXTI1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI1_IRQHandler
+ B EXTI1_IRQHandler
+
+ PUBWEAK EXTI2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI2_IRQHandler
+ B EXTI2_IRQHandler
+
+ PUBWEAK EXTI3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI3_IRQHandler
+ B EXTI3_IRQHandler
+
+ PUBWEAK EXTI4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI4_IRQHandler
+ B EXTI4_IRQHandler
+
+ PUBWEAK DMA0_Channel0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel0_IRQHandler
+ B DMA0_Channel0_IRQHandler
+
+ PUBWEAK DMA0_Channel1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel1_IRQHandler
+ B DMA0_Channel1_IRQHandler
+
+ PUBWEAK DMA0_Channel2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel2_IRQHandler
+ B DMA0_Channel2_IRQHandler
+
+ PUBWEAK DMA0_Channel3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel3_IRQHandler
+ B DMA0_Channel3_IRQHandler
+
+ PUBWEAK DMA0_Channel4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel4_IRQHandler
+ B DMA0_Channel4_IRQHandler
+
+ PUBWEAK DMA0_Channel5_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel5_IRQHandler
+ B DMA0_Channel5_IRQHandler
+
+ PUBWEAK DMA0_Channel6_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel6_IRQHandler
+ B DMA0_Channel6_IRQHandler
+
+ PUBWEAK ADC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+ADC_IRQHandler
+ B ADC_IRQHandler
+
+ PUBWEAK CAN0_TX_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN0_TX_IRQHandler
+ B CAN0_TX_IRQHandler
+
+ PUBWEAK CAN0_RX0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN0_RX0_IRQHandler
+ B CAN0_RX0_IRQHandler
+
+ PUBWEAK CAN0_RX1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN0_RX1_IRQHandler
+ B CAN0_RX1_IRQHandler
+
+ PUBWEAK CAN0_EWMC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN0_EWMC_IRQHandler
+ B CAN0_EWMC_IRQHandler
+
+ PUBWEAK EXTI5_9_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI5_9_IRQHandler
+ B EXTI5_9_IRQHandler
+
+ PUBWEAK TIMER0_BRK_TIMER8_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER0_BRK_TIMER8_IRQHandler
+ B TIMER0_BRK_TIMER8_IRQHandler
+
+ PUBWEAK TIMER0_UP_TIMER9_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER0_UP_TIMER9_IRQHandler
+ B TIMER0_UP_TIMER9_IRQHandler
+
+ PUBWEAK TIMER0_TRG_CMT_TIMER10_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER0_TRG_CMT_TIMER10_IRQHandler
+ B TIMER0_TRG_CMT_TIMER10_IRQHandler
+
+ PUBWEAK TIMER0_Channel_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER0_Channel_IRQHandler
+ B TIMER0_Channel_IRQHandler
+
+ PUBWEAK TIMER1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER1_IRQHandler
+ B TIMER1_IRQHandler
+
+ PUBWEAK TIMER2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER2_IRQHandler
+ B TIMER2_IRQHandler
+
+ PUBWEAK TIMER3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER3_IRQHandler
+ B TIMER3_IRQHandler
+
+ PUBWEAK I2C0_EV_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C0_EV_IRQHandler
+ B I2C0_EV_IRQHandler
+
+ PUBWEAK I2C0_ER_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C0_ER_IRQHandler
+ B I2C0_ER_IRQHandler
+
+ PUBWEAK I2C1_EV_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C1_EV_IRQHandler
+ B I2C1_EV_IRQHandler
+
+ PUBWEAK I2C1_ER_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C1_ER_IRQHandler
+ B I2C1_ER_IRQHandler
+
+ PUBWEAK SPI0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SPI0_IRQHandler
+ B SPI0_IRQHandler
+
+ PUBWEAK SPI1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SPI1_IRQHandler
+ B SPI1_IRQHandler
+
+ PUBWEAK USART0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USART0_IRQHandler
+ B USART0_IRQHandler
+
+ PUBWEAK USART1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USART1_IRQHandler
+ B USART1_IRQHandler
+
+ PUBWEAK USART2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USART2_IRQHandler
+ B USART2_IRQHandler
+
+ PUBWEAK EXTI10_15_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXTI10_15_IRQHandler
+ B EXTI10_15_IRQHandler
+
+ PUBWEAK RTC_Alarm_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+RTC_Alarm_IRQHandler
+ B RTC_Alarm_IRQHandler
+
+ PUBWEAK USBFS_WKUP_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBFS_WKUP_IRQHandler
+ B USBFS_WKUP_IRQHandler
+
+ PUBWEAK TIMER7_BRK_TIMER11_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER7_BRK_TIMER11_IRQHandler
+ B TIMER7_BRK_TIMER11_IRQHandler
+
+ PUBWEAK TIMER7_UP_TIMER12_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER7_UP_TIMER12_IRQHandler
+ B TIMER7_UP_TIMER12_IRQHandler
+
+ PUBWEAK TIMER7_TRG_CMT_TIMER13_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER7_TRG_CMT_TIMER13_IRQHandler
+ B TIMER7_TRG_CMT_TIMER13_IRQHandler
+
+ PUBWEAK TIMER7_Channel_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER7_Channel_IRQHandler
+ B TIMER7_Channel_IRQHandler
+
+ PUBWEAK DMA0_Channel7_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA0_Channel7_IRQHandler
+ B DMA0_Channel7_IRQHandler
+
+ PUBWEAK EXMC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+EXMC_IRQHandler
+ B EXMC_IRQHandler
+
+ PUBWEAK SDIO_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SDIO_IRQHandler
+ B SDIO_IRQHandler
+
+ PUBWEAK TIMER4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER4_IRQHandler
+ B TIMER4_IRQHandler
+
+ PUBWEAK SPI2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SPI2_IRQHandler
+ B SPI2_IRQHandler
+
+ PUBWEAK UART3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+UART3_IRQHandler
+ B UART3_IRQHandler
+
+ PUBWEAK UART4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+UART4_IRQHandler
+ B UART4_IRQHandler
+
+ PUBWEAK TIMER5_DAC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER5_DAC_IRQHandler
+ B TIMER5_DAC_IRQHandler
+
+ PUBWEAK TIMER6_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TIMER6_IRQHandler
+ B TIMER6_IRQHandler
+
+ PUBWEAK DMA1_Channel0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel0_IRQHandler
+ B DMA1_Channel0_IRQHandler
+
+ PUBWEAK DMA1_Channel1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel1_IRQHandler
+ B DMA1_Channel1_IRQHandler
+
+ PUBWEAK DMA1_Channel2_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel2_IRQHandler
+ B DMA1_Channel2_IRQHandler
+
+ PUBWEAK DMA1_Channel3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel3_IRQHandler
+ B DMA1_Channel3_IRQHandler
+
+ PUBWEAK DMA1_Channel4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel4_IRQHandler
+ B DMA1_Channel4_IRQHandler
+
+ PUBWEAK ENET_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+ENET_IRQHandler
+ B ENET_IRQHandler
+
+ PUBWEAK ENET_WKUP_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+ENET_WKUP_IRQHandler
+ B ENET_WKUP_IRQHandler
+
+ PUBWEAK CAN1_TX_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN1_TX_IRQHandler
+ B CAN1_TX_IRQHandler
+
+ PUBWEAK CAN1_RX0_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN1_RX0_IRQHandler
+ B CAN1_RX0_IRQHandler
+
+ PUBWEAK CAN1_RX1_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN1_RX1_IRQHandler
+ B CAN1_RX1_IRQHandler
+
+ PUBWEAK CAN1_EWMC_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+CAN1_EWMC_IRQHandler
+ B CAN1_EWMC_IRQHandler
+
+ PUBWEAK USBFS_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBFS_IRQHandler
+ B USBFS_IRQHandler
+
+ PUBWEAK DMA1_Channel5_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel5_IRQHandler
+ B DMA1_Channel5_IRQHandler
+
+ PUBWEAK DMA1_Channel6_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel6_IRQHandler
+ B DMA1_Channel6_IRQHandler
+
+ PUBWEAK DMA1_Channel7_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DMA1_Channel7_IRQHandler
+ B DMA1_Channel7_IRQHandler
+
+ PUBWEAK USART5_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USART5_IRQHandler
+ B USART5_IRQHandler
+
+ PUBWEAK I2C2_EV_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C2_EV_IRQHandler
+ B I2C2_EV_IRQHandler
+
+ PUBWEAK I2C2_ER_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+I2C2_ER_IRQHandler
+ B I2C2_ER_IRQHandler
+
+ PUBWEAK USBHS_EP1_Out_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBHS_EP1_Out_IRQHandler
+ B USBHS_EP1_Out_IRQHandler
+
+ PUBWEAK USBHS_EP1_In_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBHS_EP1_In_IRQHandler
+ B USBHS_EP1_In_IRQHandler
+
+ PUBWEAK USBHS_WKUP_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBHS_WKUP_IRQHandler
+ B USBHS_WKUP_IRQHandler
+
+ PUBWEAK USBHS_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+USBHS_IRQHandler
+ B USBHS_IRQHandler
+
+ PUBWEAK DCI_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+DCI_IRQHandler
+ B DCI_IRQHandler
+
+ PUBWEAK TRNG_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TRNG_IRQHandler
+ B TRNG_IRQHandler
+
+ PUBWEAK FPU_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+FPU_IRQHandler
+ B FPU_IRQHandler
+
+ PUBWEAK UART6_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+UART6_IRQHandler
+ B UART6_IRQHandler
+
+ PUBWEAK UART7_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+UART7_IRQHandler
+ B UART7_IRQHandler
+
+ PUBWEAK SPI3_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SPI3_IRQHandler
+ B SPI3_IRQHandler
+
+ PUBWEAK SPI4_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SPI4_IRQHandler
+ B SPI4_IRQHandler
+
+ PUBWEAK SPI5_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+SPI5_IRQHandler
+ B SPI5_IRQHandler
+
+ PUBWEAK TLI_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TLI_IRQHandler
+ B TLI_IRQHandler
+
+ PUBWEAK TLI_ER_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+TLI_ER_IRQHandler
+ B TLI_ER_IRQHandler
+
+ PUBWEAK IPA_IRQHandler
+ SECTION .text:CODE:NOROOT:REORDER(1)
+IPA_IRQHandler
+ B IPA_IRQHandler
+ END \ No newline at end of file
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/system_gd32f4xx.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/system_gd32f4xx.c
index 2ea97ae3f8..25020f2795 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/system_gd32f4xx.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/GD/GD32F4xx/Source/system_gd32f4xx.c
@@ -52,14 +52,26 @@
//#define __SYSTEM_CLOCK_200M_PLL_IRC16M (uint32_t)(200000000)
//#define __SYSTEM_CLOCK_200M_PLL_8M_HXTAL (uint32_t)(200000000)
#define __SYSTEM_CLOCK_200M_PLL_25M_HXTAL (uint32_t)(200000000)
+//#define __SYSTEM_CLOCK_240M_PLL_IRC16M (uint32_t)(240000000)
+//#define __SYSTEM_CLOCK_240M_PLL_8M_HXTAL (uint32_t)(240000000)
+//#define __SYSTEM_CLOCK_240M_PLL_25M_HXTAL (uint32_t)(240000000)
+
+#define RCU_MODIFY(__delay) do{ \
+ volatile uint32_t i; \
+ if(0 != __delay){ \
+ RCU_CFG0 |= RCU_AHB_CKSYS_DIV2; \
+ for(i=0; i<__delay; i++){ \
+ } \
+ RCU_CFG0 |= RCU_AHB_CKSYS_DIV4; \
+ for(i=0; i<__delay; i++){ \
+ } \
+ } \
+ }while(0)
#define SEL_IRC16M 0x00U
#define SEL_HXTAL 0x01U
#define SEL_PLLP 0x02U
-#define RCU_MODIFY {volatile uint32_t i; \
- RCU_CFG0 |= RCU_AHB_CKSYS_DIV2; \
- for(i=0;i<50000;i++);}
-
+
/* set the system clock frequency and declare the system clock configuration function */
#ifdef __SYSTEM_CLOCK_IRC16M
uint32_t SystemCoreClock = __SYSTEM_CLOCK_IRC16M;
@@ -94,6 +106,15 @@ static void system_clock_200m_8m_hxtal(void);
#elif defined (__SYSTEM_CLOCK_200M_PLL_25M_HXTAL)
uint32_t SystemCoreClock = __SYSTEM_CLOCK_200M_PLL_25M_HXTAL;
static void system_clock_200m_25m_hxtal(void);
+#elif defined (__SYSTEM_CLOCK_240M_PLL_IRC16M)
+uint32_t SystemCoreClock = __SYSTEM_CLOCK_240M_PLL_IRC16M;
+static void system_clock_240m_irc16m(void);
+#elif defined (__SYSTEM_CLOCK_240M_PLL_8M_HXTAL)
+uint32_t SystemCoreClock = __SYSTEM_CLOCK_240M_PLL_8M_HXTAL;
+static void system_clock_240m_8m_hxtal(void);
+#elif defined (__SYSTEM_CLOCK_240M_PLL_25M_HXTAL)
+uint32_t SystemCoreClock = __SYSTEM_CLOCK_240M_PLL_25M_HXTAL;
+static void system_clock_240m_25m_hxtal(void);
#endif /* __SYSTEM_CLOCK_IRC16M */
@@ -108,34 +129,41 @@ static void system_clock_config(void);
*/
void SystemInit (void)
{
- /* FPU settings ------------------------------------------------------------*/
- #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
+ /* FPU settings */
+#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
- #endif
- /* Reset the RCU clock configuration to the default reset state ------------*/
- /* Set IRC16MEN bit */
- RCU_CTL |= RCU_CTL_IRC16MEN;
-
- RCU_MODIFY
-
- /* Reset CFG0 register */
- RCU_CFG0 = 0x00000000U;
-
- /* Reset HXTALEN, CKMEN and PLLEN bits */
- RCU_CTL &= ~(RCU_CTL_PLLEN | RCU_CTL_CKMEN | RCU_CTL_HXTALEN);
+#endif
+ /* Reset the RCU clock configuration to the default reset state */
+ /* Set IRC16MEN bit */
+ RCU_CTL |= RCU_CTL_IRC16MEN;
+ while(0U == (RCU_CTL & RCU_CTL_IRC16MSTB)){
+ }
+ RCU_MODIFY(0x50);
+
+ RCU_CFG0 &= ~RCU_CFG0_SCS;
+
+ /* Reset HXTALEN, CKMEN and PLLEN bits */
+ RCU_CTL &= ~(RCU_CTL_PLLEN | RCU_CTL_CKMEN | RCU_CTL_HXTALEN);
- /* Reset PLLCFGR register */
- RCU_PLL = 0x24003010U;
+ /* Reset HSEBYP bit */
+ RCU_CTL &= ~(RCU_CTL_HXTALBPS);
+
+ /* Reset CFG0 register */
+ RCU_CFG0 = 0x00000000U;
- /* Reset HSEBYP bit */
- RCU_CTL &= ~(RCU_CTL_HXTALBPS);
+ /* wait until IRC16M is selected as system clock */
+ while(0 != (RCU_CFG0 & RCU_SCSS_IRC16M)){
+ }
- /* Disable all interrupts */
- RCU_INT = 0x00000000U;
+ /* Reset PLLCFGR register */
+ RCU_PLL = 0x24003010U;
- /* Configure the System clock source, PLL Multiplier and Divider factors,
- AHB/APBx prescalers and Flash settings ----------------------------------*/
- system_clock_config();
+ /* Disable all interrupts */
+ RCU_INT = 0x00000000U;
+
+ /* Configure the System clock source, PLL Multiplier and Divider factors,
+ AHB/APBx prescalers and Flash settings */
+ system_clock_config();
}
/*!
\brief configure the system clock
@@ -167,7 +195,13 @@ static void system_clock_config(void)
system_clock_200m_8m_hxtal();
#elif defined (__SYSTEM_CLOCK_200M_PLL_25M_HXTAL)
system_clock_200m_25m_hxtal();
-#endif /* __SYSTEM_CLOCK_IRC16M */
+#elif defined (__SYSTEM_CLOCK_240M_PLL_IRC16M)
+ system_clock_240m_irc16m();
+#elif defined (__SYSTEM_CLOCK_240M_PLL_8M_HXTAL)
+ system_clock_240m_8m_hxtal();
+#elif defined (__SYSTEM_CLOCK_240M_PLL_25M_HXTAL)
+ system_clock_240m_25m_hxtal();
+#endif /* __SYSTEM_CLOCK_IRC16M */
}
#ifdef __SYSTEM_CLOCK_IRC16M
@@ -181,33 +215,33 @@ static void system_clock_16m_irc16m(void)
{
uint32_t timeout = 0U;
uint32_t stab_flag = 0U;
-
+
/* enable IRC16M */
RCU_CTL |= RCU_CTL_IRC16MEN;
-
+
/* wait until IRC16M is stable or the startup time is longer than IRC16M_STARTUP_TIMEOUT */
do{
timeout++;
stab_flag = (RCU_CTL & RCU_CTL_IRC16MSTB);
}while((0U == stab_flag) && (IRC16M_STARTUP_TIMEOUT != timeout));
-
+
/* if fail */
if(0U == (RCU_CTL & RCU_CTL_IRC16MSTB)){
while(1){
}
}
-
+
/* AHB = SYSCLK */
RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
/* APB2 = AHB */
RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
/* APB1 = AHB */
RCU_CFG0 |= RCU_APB1_CKAHB_DIV1;
-
+
/* select IRC16M as system clock */
RCU_CFG0 &= ~RCU_CFG0_SCS;
RCU_CFG0 |= RCU_CKSYSSRC_IRC16M;
-
+
/* wait until IRC16M is selected as system clock */
while(0 != (RCU_CFG0 & RCU_SCSS_IRC16M)){
}
@@ -224,33 +258,33 @@ static void system_clock_hxtal(void)
{
uint32_t timeout = 0U;
uint32_t stab_flag = 0U;
-
+
/* enable HXTAL */
RCU_CTL |= RCU_CTL_HXTALEN;
-
+
/* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
do{
timeout++;
stab_flag = (RCU_CTL & RCU_CTL_HXTALSTB);
}while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
-
+
/* if fail */
if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
while(1){
}
}
-
+
/* AHB = SYSCLK */
RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
/* APB2 = AHB */
RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
/* APB1 = AHB */
RCU_CFG0 |= RCU_APB1_CKAHB_DIV1;
-
+
/* select HXTAL as system clock */
RCU_CFG0 &= ~RCU_CFG0_SCS;
RCU_CFG0 |= RCU_CKSYSSRC_HXTAL;
-
+
/* wait until HXTAL is selected as system clock */
while(0 == (RCU_CFG0 & RCU_SCSS_HXTAL)){
}
@@ -267,7 +301,7 @@ static void system_clock_120m_irc16m(void)
{
uint32_t timeout = 0U;
uint32_t stab_flag = 0U;
-
+
/* enable IRC16M */
RCU_CTL |= RCU_CTL_IRC16MEN;
@@ -282,7 +316,7 @@ static void system_clock_120m_irc16m(void)
while(1){
}
}
-
+
RCU_APB1EN |= RCU_APB1EN_PMUEN;
PMU_CTL |= PMU_CTL_LDOVS;
@@ -294,7 +328,7 @@ static void system_clock_120m_irc16m(void)
/* APB1 = AHB/4 */
RCU_CFG0 |= RCU_APB1_CKAHB_DIV4;
- /* Configure the main PLL, PSC = 16, PLL_N = 240, PLL_P = 2, PLL_Q = 5 */
+ /* Configure the main PLL, PSC = 16, PLL_N = 240, PLL_P = 2, PLL_Q = 5 */
RCU_PLL = (16U | (240U << 6U) | (((2U >> 1U) - 1U) << 16U) |
(RCU_PLLSRC_IRC16M) | (5U << 24U));
@@ -304,17 +338,17 @@ static void system_clock_120m_irc16m(void)
/* wait until PLL is stable */
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
}
-
+
/* Enable the high-drive to extend the clock frequency to 120 Mhz */
PMU_CTL |= PMU_CTL_HDEN;
while(0U == (PMU_CS & PMU_CS_HDRF)){
}
-
+
/* select the high-drive mode */
PMU_CTL |= PMU_CTL_HDS;
while(0U == (PMU_CS & PMU_CS_HDSRF)){
- }
-
+ }
+
/* select PLL as system clock */
RCU_CFG0 &= ~RCU_CFG0_SCS;
RCU_CFG0 |= RCU_CKSYSSRC_PLLP;
@@ -335,7 +369,7 @@ static void system_clock_120m_8m_hxtal(void)
{
uint32_t timeout = 0U;
uint32_t stab_flag = 0U;
-
+
/* enable HXTAL */
RCU_CTL |= RCU_CTL_HXTALEN;
@@ -350,7 +384,7 @@ static void system_clock_120m_8m_hxtal(void)
while(1){
}
}
-
+
RCU_APB1EN |= RCU_APB1EN_PMUEN;
PMU_CTL |= PMU_CTL_LDOVS;
@@ -362,7 +396,7 @@ static void system_clock_120m_8m_hxtal(void)
/* APB1 = AHB/4 */
RCU_CFG0 |= RCU_APB1_CKAHB_DIV4;
- /* Configure the main PLL, PSC = 8, PLL_N = 240, PLL_P = 2, PLL_Q = 5 */
+ /* Configure the main PLL, PSC = 8, PLL_N = 240, PLL_P = 2, PLL_Q = 5 */
RCU_PLL = (8U | (240U << 6U) | (((2U >> 1U) - 1U) << 16U) |
(RCU_PLLSRC_HXTAL) | (5U << 24U));
@@ -372,17 +406,17 @@ static void system_clock_120m_8m_hxtal(void)
/* wait until PLL is stable */
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
}
-
+
/* Enable the high-drive to extend the clock frequency to 120 Mhz */
PMU_CTL |= PMU_CTL_HDEN;
while(0U == (PMU_CS & PMU_CS_HDRF)){
}
-
+
/* select the high-drive mode */
PMU_CTL |= PMU_CTL_HDS;
while(0U == (PMU_CS & PMU_CS_HDSRF)){
- }
-
+ }
+
/* select PLL as system clock */
RCU_CFG0 &= ~RCU_CFG0_SCS;
RCU_CFG0 |= RCU_CKSYSSRC_PLLP;
@@ -403,7 +437,7 @@ static void system_clock_120m_25m_hxtal(void)
{
uint32_t timeout = 0U;
uint32_t stab_flag = 0U;
-
+
/* enable HXTAL */
RCU_CTL |= RCU_CTL_HXTALEN;
@@ -418,7 +452,7 @@ static void system_clock_120m_25m_hxtal(void)
while(1){
}
}
-
+
RCU_APB1EN |= RCU_APB1EN_PMUEN;
PMU_CTL |= PMU_CTL_LDOVS;
@@ -430,7 +464,7 @@ static void system_clock_120m_25m_hxtal(void)
/* APB1 = AHB/4 */
RCU_CFG0 |= RCU_APB1_CKAHB_DIV4;
- /* Configure the main PLL, PSC = 25, PLL_N = 240, PLL_P = 2, PLL_Q = 5 */
+ /* Configure the main PLL, PSC = 25, PLL_N = 240, PLL_P = 2, PLL_Q = 5 */
RCU_PLL = (25U | (240U << 6U) | (((2U >> 1U) - 1U) << 16U) |
(RCU_PLLSRC_HXTAL) | (5U << 24U));
@@ -440,17 +474,17 @@ static void system_clock_120m_25m_hxtal(void)
/* wait until PLL is stable */
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
}
-
+
/* Enable the high-drive to extend the clock frequency to 120 Mhz */
PMU_CTL |= PMU_CTL_HDEN;
while(0U == (PMU_CS & PMU_CS_HDRF)){
}
-
+
/* select the high-drive mode */
PMU_CTL |= PMU_CTL_HDS;
while(0U == (PMU_CS & PMU_CS_HDSRF)){
- }
-
+ }
+
/* select PLL as system clock */
RCU_CFG0 &= ~RCU_CFG0_SCS;
RCU_CFG0 |= RCU_CKSYSSRC_PLLP;
@@ -471,7 +505,7 @@ static void system_clock_168m_irc16m(void)
{
uint32_t timeout = 0U;
uint32_t stab_flag = 0U;
-
+
/* enable IRC16M */
RCU_CTL |= RCU_CTL_IRC16MEN;
@@ -486,7 +520,7 @@ static void system_clock_168m_irc16m(void)
while(1){
}
}
-
+
RCU_APB1EN |= RCU_APB1EN_PMUEN;
PMU_CTL |= PMU_CTL_LDOVS;
@@ -498,7 +532,7 @@ static void system_clock_168m_irc16m(void)
/* APB1 = AHB/4 */
RCU_CFG0 |= RCU_APB1_CKAHB_DIV4;
- /* Configure the main PLL, PSC = 16, PLL_N = 336, PLL_P = 2, PLL_Q = 7 */
+ /* Configure the main PLL, PSC = 16, PLL_N = 336, PLL_P = 2, PLL_Q = 7 */
RCU_PLL = (16U | (336U << 6U) | (((2U >> 1U) - 1U) << 16U) |
(RCU_PLLSRC_IRC16M) | (7U << 24U));
@@ -508,17 +542,17 @@ static void system_clock_168m_irc16m(void)
/* wait until PLL is stable */
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
}
-
+
/* Enable the high-drive to extend the clock frequency to 168 Mhz */
PMU_CTL |= PMU_CTL_HDEN;
while(0U == (PMU_CS & PMU_CS_HDRF)){
}
-
+
/* select the high-drive mode */
PMU_CTL |= PMU_CTL_HDS;
while(0U == (PMU_CS & PMU_CS_HDSRF)){
- }
-
+ }
+
/* select PLL as system clock */
RCU_CFG0 &= ~RCU_CFG0_SCS;
RCU_CFG0 |= RCU_CKSYSSRC_PLLP;
@@ -538,7 +572,7 @@ static void system_clock_168m_irc16m(void)
static void system_clock_168m_8m_hxtal(void)
{
uint32_t timeout = 0U;
-
+
/* enable HXTAL */
RCU_CTL |= RCU_CTL_HXTALEN;
@@ -562,7 +596,7 @@ static void system_clock_168m_8m_hxtal(void)
/* APB1 = AHB/4 */
RCU_CFG0 |= RCU_APB1_CKAHB_DIV4;
- /* Configure the main PLL, PSC = 8, PLL_N = 336, PLL_P = 2, PLL_Q = 7 */
+ /* Configure the main PLL, PSC = 8, PLL_N = 336, PLL_P = 2, PLL_Q = 7 */
RCU_PLL = (8U | (336 << 6U) | (((2 >> 1U) -1U) << 16U) |
(RCU_PLLSRC_HXTAL) | (7 << 24U));
@@ -572,12 +606,12 @@ static void system_clock_168m_8m_hxtal(void)
/* wait until PLL is stable */
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
}
-
+
/* Enable the high-drive to extend the clock frequency to 168 Mhz */
PMU_CTL |= PMU_CTL_HDEN;
while(0U == (PMU_CS & PMU_CS_HDRF)){
}
-
+
/* select the high-drive mode */
PMU_CTL |= PMU_CTL_HDS;
while(0U == (PMU_CS & PMU_CS_HDSRF)){
@@ -603,7 +637,7 @@ static void system_clock_168m_25m_hxtal(void)
{
uint32_t timeout = 0U;
uint32_t stab_flag = 0U;
-
+
/* enable HXTAL */
RCU_CTL |= RCU_CTL_HXTALEN;
@@ -618,7 +652,7 @@ static void system_clock_168m_25m_hxtal(void)
while(1){
}
}
-
+
RCU_APB1EN |= RCU_APB1EN_PMUEN;
PMU_CTL |= PMU_CTL_LDOVS;
@@ -630,7 +664,7 @@ static void system_clock_168m_25m_hxtal(void)
/* APB1 = AHB */
RCU_CFG0 |= RCU_APB1_CKAHB_DIV4;
- /* Configure the main PLL, PSC = 25, PLL_N = 336, PLL_P = 2, PLL_Q = 7 */
+ /* Configure the main PLL, PSC = 25, PLL_N = 336, PLL_P = 2, PLL_Q = 7 */
RCU_PLL = (25U | (336U << 6U) | (((2U >> 1U) - 1U) << 16U) |
(RCU_PLLSRC_HXTAL) | (7U << 24U));
@@ -640,17 +674,17 @@ static void system_clock_168m_25m_hxtal(void)
/* wait until PLL is stable */
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
}
-
+
/* Enable the high-drive to extend the clock frequency to 168 Mhz */
PMU_CTL |= PMU_CTL_HDEN;
while(0U == (PMU_CS & PMU_CS_HDRF)){
}
-
+
/* select the high-drive mode */
PMU_CTL |= PMU_CTL_HDS;
while(0U == (PMU_CS & PMU_CS_HDSRF)){
- }
-
+ }
+
/* select PLL as system clock */
RCU_CFG0 &= ~RCU_CFG0_SCS;
RCU_CFG0 |= RCU_CKSYSSRC_PLLP;
@@ -671,7 +705,7 @@ static void system_clock_200m_irc16m(void)
{
uint32_t timeout = 0U;
uint32_t stab_flag = 0U;
-
+
/* enable IRC16M */
RCU_CTL |= RCU_CTL_IRC16MEN;
@@ -686,7 +720,7 @@ static void system_clock_200m_irc16m(void)
while(1){
}
}
-
+
RCU_APB1EN |= RCU_APB1EN_PMUEN;
PMU_CTL |= PMU_CTL_LDOVS;
@@ -698,7 +732,7 @@ static void system_clock_200m_irc16m(void)
/* APB1 = AHB/4 */
RCU_CFG0 |= RCU_APB1_CKAHB_DIV4;
- /* Configure the main PLL, PSC = 16, PLL_N = 400, PLL_P = 2, PLL_Q = 9 */
+ /* Configure the main PLL, PSC = 16, PLL_N = 400, PLL_P = 2, PLL_Q = 9 */
RCU_PLL = (16U | (400U << 6U) | (((2U >> 1U) - 1U) << 16U) |
(RCU_PLLSRC_IRC16M) | (9U << 24U));
@@ -708,17 +742,17 @@ static void system_clock_200m_irc16m(void)
/* wait until PLL is stable */
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
}
-
+
/* Enable the high-drive to extend the clock frequency to 200 Mhz */
PMU_CTL |= PMU_CTL_HDEN;
while(0U == (PMU_CS & PMU_CS_HDRF)){
}
-
+
/* select the high-drive mode */
PMU_CTL |= PMU_CTL_HDS;
while(0U == (PMU_CS & PMU_CS_HDSRF)){
- }
-
+ }
+
/* select PLL as system clock */
RCU_CFG0 &= ~RCU_CFG0_SCS;
RCU_CFG0 |= RCU_CKSYSSRC_PLLP;
@@ -739,7 +773,7 @@ static void system_clock_200m_8m_hxtal(void)
{
uint32_t timeout = 0U;
uint32_t stab_flag = 0U;
-
+
/* enable HXTAL */
RCU_CTL |= RCU_CTL_HXTALEN;
@@ -754,7 +788,7 @@ static void system_clock_200m_8m_hxtal(void)
while(1){
}
}
-
+
RCU_APB1EN |= RCU_APB1EN_PMUEN;
PMU_CTL |= PMU_CTL_LDOVS;
@@ -766,7 +800,7 @@ static void system_clock_200m_8m_hxtal(void)
/* APB1 = AHB/4 */
RCU_CFG0 |= RCU_APB1_CKAHB_DIV4;
- /* Configure the main PLL, PSC = 8, PLL_N = 400, PLL_P = 2, PLL_Q = 9 */
+ /* Configure the main PLL, PSC = 8, PLL_N = 400, PLL_P = 2, PLL_Q = 9 */
RCU_PLL = (8U | (400U << 6U) | (((2U >> 1U) - 1U) << 16U) |
(RCU_PLLSRC_HXTAL) | (9U << 24U));
@@ -776,17 +810,17 @@ static void system_clock_200m_8m_hxtal(void)
/* wait until PLL is stable */
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
}
-
+
/* Enable the high-drive to extend the clock frequency to 200 Mhz */
PMU_CTL |= PMU_CTL_HDEN;
while(0U == (PMU_CS & PMU_CS_HDRF)){
}
-
+
/* select the high-drive mode */
PMU_CTL |= PMU_CTL_HDS;
while(0U == (PMU_CS & PMU_CS_HDSRF)){
- }
-
+ }
+
/* select PLL as system clock */
RCU_CFG0 &= ~RCU_CFG0_SCS;
RCU_CFG0 |= RCU_CKSYSSRC_PLLP;
@@ -807,7 +841,7 @@ static void system_clock_200m_25m_hxtal(void)
{
uint32_t timeout = 0U;
uint32_t stab_flag = 0U;
-
+
/* enable HXTAL */
RCU_CTL |= RCU_CTL_HXTALEN;
@@ -822,7 +856,7 @@ static void system_clock_200m_25m_hxtal(void)
while(1){
}
}
-
+
RCU_APB1EN |= RCU_APB1EN_PMUEN;
PMU_CTL |= PMU_CTL_LDOVS;
@@ -834,7 +868,7 @@ static void system_clock_200m_25m_hxtal(void)
/* APB1 = AHB/4 */
RCU_CFG0 |= RCU_APB1_CKAHB_DIV4;
- /* Configure the main PLL, PSC = 25, PLL_N = 400, PLL_P = 2, PLL_Q = 9 */
+ /* Configure the main PLL, PSC = 25, PLL_N = 400, PLL_P = 2, PLL_Q = 9 */
RCU_PLL = (25U | (400U << 6U) | (((2U >> 1U) - 1U) << 16U) |
(RCU_PLLSRC_HXTAL) | (9U << 24U));
@@ -844,17 +878,153 @@ static void system_clock_200m_25m_hxtal(void)
/* wait until PLL is stable */
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
}
-
+
/* Enable the high-drive to extend the clock frequency to 200 Mhz */
PMU_CTL |= PMU_CTL_HDEN;
while(0U == (PMU_CS & PMU_CS_HDRF)){
}
+
+ /* select the high-drive mode */
+ PMU_CTL |= PMU_CTL_HDS;
+ while(0U == (PMU_CS & PMU_CS_HDSRF)){
+ }
+
+ /* select PLL as system clock */
+ RCU_CFG0 &= ~RCU_CFG0_SCS;
+ RCU_CFG0 |= RCU_CKSYSSRC_PLLP;
+
+ /* wait until PLL is selected as system clock */
+ while(0U == (RCU_CFG0 & RCU_SCSS_PLLP)){
+ }
+}
+
+#elif defined (__SYSTEM_CLOCK_240M_PLL_IRC16M)
+/*!
+ \brief configure the system clock to 240M by PLL which selects IRC16M as its clock source
+ \param[in] none
+ \param[out] none
+ \retval none
+*/
+static void system_clock_240m_irc16m(void)
+{
+ uint32_t timeout = 0U;
+ uint32_t stab_flag = 0U;
+
+ /* enable IRC16M */
+ RCU_CTL |= RCU_CTL_IRC16MEN;
+
+ /* wait until IRC16M is stable or the startup time is longer than IRC16M_STARTUP_TIMEOUT */
+ do{
+ timeout++;
+ stab_flag = (RCU_CTL & RCU_CTL_IRC16MSTB);
+ }while((0U == stab_flag) && (IRC16M_STARTUP_TIMEOUT != timeout));
+
+ /* if fail */
+ if(0U == (RCU_CTL & RCU_CTL_IRC16MSTB)){
+ while(1){
+ }
+ }
+
+ RCU_APB1EN |= RCU_APB1EN_PMUEN;
+ PMU_CTL |= PMU_CTL_LDOVS;
+
+ /* IRC16M is stable */
+ /* AHB = SYSCLK */
+ RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
+ /* APB2 = AHB/2 */
+ RCU_CFG0 |= RCU_APB2_CKAHB_DIV2;
+ /* APB1 = AHB/4 */
+ RCU_CFG0 |= RCU_APB1_CKAHB_DIV4;
+
+ /* Configure the main PLL, PSC = 16, PLL_N = 480, PLL_P = 2, PLL_Q = 10 */
+ RCU_PLL = (16U | (480U << 6U) | (((2U >> 1U) - 1U) << 16U) |
+ (RCU_PLLSRC_IRC16M) | (10U << 24U));
+ /* enable PLL */
+ RCU_CTL |= RCU_CTL_PLLEN;
+
+ /* wait until PLL is stable */
+ while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
+ }
+
+ /* Enable the high-drive to extend the clock frequency to 240 Mhz */
+ PMU_CTL |= PMU_CTL_HDEN;
+ while(0U == (PMU_CS & PMU_CS_HDRF)){
+ }
+
/* select the high-drive mode */
PMU_CTL |= PMU_CTL_HDS;
while(0U == (PMU_CS & PMU_CS_HDSRF)){
+ }
+
+ /* select PLL as system clock */
+ RCU_CFG0 &= ~RCU_CFG0_SCS;
+ RCU_CFG0 |= RCU_CKSYSSRC_PLLP;
+
+ /* wait until PLL is selected as system clock */
+ while(0U == (RCU_CFG0 & RCU_SCSS_PLLP)){
}
+}
+#elif defined (__SYSTEM_CLOCK_240M_PLL_8M_HXTAL)
+/*!
+ \brief configure the system clock to 240M by PLL which selects HXTAL(8M) as its clock source
+ \param[in] none
+ \param[out] none
+ \retval none
+*/
+static void system_clock_240m_8m_hxtal(void)
+{
+ uint32_t timeout = 0U;
+ uint32_t stab_flag = 0U;
+
+ /* enable HXTAL */
+ RCU_CTL |= RCU_CTL_HXTALEN;
+
+ /* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
+ do{
+ timeout++;
+ stab_flag = (RCU_CTL & RCU_CTL_HXTALSTB);
+ }while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
+
+ /* if fail */
+ if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
+ while(1){
+ }
+ }
+
+ RCU_APB1EN |= RCU_APB1EN_PMUEN;
+ PMU_CTL |= PMU_CTL_LDOVS;
+
+ /* HXTAL is stable */
+ /* AHB = SYSCLK */
+ RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
+ /* APB2 = AHB/2 */
+ RCU_CFG0 |= RCU_APB2_CKAHB_DIV2;
+ /* APB1 = AHB/4 */
+ RCU_CFG0 |= RCU_APB1_CKAHB_DIV4;
+
+ /* Configure the main PLL, PSC = 8, PLL_N = 480, PLL_P = 2, PLL_Q = 10 */
+ RCU_PLL = (8U | (480U << 6U) | (((2U >> 1U) - 1U) << 16U) |
+ (RCU_PLLSRC_HXTAL) | (10U << 24U));
+
+ /* enable PLL */
+ RCU_CTL |= RCU_CTL_PLLEN;
+
+ /* wait until PLL is stable */
+ while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
+ }
+
+ /* Enable the high-drive to extend the clock frequency to 240 Mhz */
+ PMU_CTL |= PMU_CTL_HDEN;
+ while(0U == (PMU_CS & PMU_CS_HDRF)){
+ }
+
+ /* select the high-drive mode */
+ PMU_CTL |= PMU_CTL_HDS;
+ while(0U == (PMU_CS & PMU_CS_HDSRF)){
+ }
+
/* select PLL as system clock */
RCU_CFG0 &= ~RCU_CFG0_SCS;
RCU_CFG0 |= RCU_CKSYSSRC_PLLP;
@@ -864,6 +1034,73 @@ static void system_clock_200m_25m_hxtal(void)
}
}
+#elif defined (__SYSTEM_CLOCK_240M_PLL_25M_HXTAL)
+/*!
+ \brief configure the system clock to 240M by PLL which selects HXTAL(25M) as its clock source
+ \param[in] none
+ \param[out] none
+ \retval none
+*/
+static void system_clock_240m_25m_hxtal(void)
+{
+ uint32_t timeout = 0U;
+ uint32_t stab_flag = 0U;
+
+ /* enable HXTAL */
+ RCU_CTL |= RCU_CTL_HXTALEN;
+
+ /* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
+ do{
+ timeout++;
+ stab_flag = (RCU_CTL & RCU_CTL_HXTALSTB);
+ }while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
+
+ /* if fail */
+ if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
+ while(1){
+ }
+ }
+
+ RCU_APB1EN |= RCU_APB1EN_PMUEN;
+ PMU_CTL |= PMU_CTL_LDOVS;
+
+ /* HXTAL is stable */
+ /* AHB = SYSCLK */
+ RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
+ /* APB2 = AHB/2 */
+ RCU_CFG0 |= RCU_APB2_CKAHB_DIV2;
+ /* APB1 = AHB/4 */
+ RCU_CFG0 |= RCU_APB1_CKAHB_DIV4;
+
+ /* Configure the main PLL, PSC = 25, PLL_N = 480, PLL_P = 2, PLL_Q = 10 */
+ RCU_PLL = (25U | (480U << 6U) | (((2U >> 1U) - 1U) << 16U) |
+ (RCU_PLLSRC_HXTAL) | (10U << 24U));
+
+ /* enable PLL */
+ RCU_CTL |= RCU_CTL_PLLEN;
+
+ /* wait until PLL is stable */
+ while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
+ }
+
+ /* Enable the high-drive to extend the clock frequency to 240 Mhz */
+ PMU_CTL |= PMU_CTL_HDEN;
+ while(0U == (PMU_CS & PMU_CS_HDRF)){
+ }
+
+ /* select the high-drive mode */
+ PMU_CTL |= PMU_CTL_HDS;
+ while(0U == (PMU_CS & PMU_CS_HDSRF)){
+ }
+
+ /* select PLL as system clock */
+ RCU_CFG0 &= ~RCU_CFG0_SCS;
+ RCU_CFG0 |= RCU_CKSYSSRC_PLLP;
+
+ /* wait until PLL is selected as system clock */
+ while(0U == (RCU_CFG0 & RCU_SCSS_PLLP)){
+ }
+}
#endif /* __SYSTEM_CLOCK_IRC16M */
/*!
\brief update the SystemCoreClock with current core clock retrieved from cpu registers
@@ -871,11 +1108,11 @@ static void system_clock_200m_25m_hxtal(void)
\param[out] none
\retval none
*/
-void SystemCoreClockUpdate (void)
+void SystemCoreClockUpdate(void)
{
uint32_t sws;
uint32_t pllpsc, plln, pllsel, pllp, ck_src, idx, clk_exp;
-
+
/* exponent of AHB, APB1 and APB2 clock divider */
const uint8_t ahb_exp[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
@@ -902,7 +1139,7 @@ void SystemCoreClockUpdate (void)
} else {
ck_src = IRC16M_VALUE;
}
- SystemCoreClock = ((ck_src / pllpsc) * plln)/pllp;
+ SystemCoreClock = ((ck_src / pllpsc) * plln) / pllp;
break;
/* IRC16M is selected as CK_SYS */
default:
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/core_cm4.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/core_cm4.h
index e3cd89f728..d82841442c 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/core_cm4.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/core_cm4.h
@@ -100,7 +100,7 @@
#define __INLINE inline /*!< inline keyword for TASKING Compiler */
#define __STATIC_INLINE static inline
-#elif defined ( __CSMC__ ) /* Cosmic */
+#elif defined ( __CSMC__ ) /* Cosmic */
#define __packed
#define __ASM _asm /*!< asm keyword for COSMIC Compiler */
#define __INLINE inline /*use -pc99 on compile line !< inline keyword for COSMIC Compiler */
@@ -170,8 +170,8 @@
#define __FPU_USED 0
#endif
-#elif defined ( __CSMC__ ) /* Cosmic */
- #if ( __CSMC__ & 0x400) // FPU present for parser
+#elif defined ( __CSMC__ ) /* Cosmic */
+ #if ( __CSMC__ & 0x400) // FPU present for parser
#if (__FPU_PRESENT == 1)
#define __FPU_USED 1
#else
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/core_cmFunc.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/core_cmFunc.h
index 834bd17645..3c932e0d6e 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/core_cmFunc.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/core_cmFunc.h
@@ -1,39 +1,25 @@
/**************************************************************************//**
* @file core_cmFunc.h
* @brief CMSIS Cortex-M Core Function Access Header File
- * @version V4.10
- * @date 18. March 2015
+ * @version V3.01
+ * @date 06. March 2012
*
* @note
+ * Copyright (C) 2009-2012 ARM Limited. All rights reserved.
+ *
+ * @par
+ * ARM Limited (ARM) is supplying this software for use with Cortex-M
+ * processor based microcontrollers. This file can be freely distributed
+ * within development tools that are supporting such ARM based processors.
+ *
+ * @par
+ * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
+ * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
+ * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
+ * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
******************************************************************************/
-/* Copyright (c) 2009 - 2015 ARM LIMITED
-
- All rights reserved.
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- - Neither the name of ARM nor the names of its contributors may be used
- to endorse or promote products derived from this software without
- specific prior written permission.
- *
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
- ---------------------------------------------------------------------------*/
-
#ifndef __CORE_CMFUNC_H
#define __CORE_CMFUNC_H
@@ -198,7 +184,7 @@ __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
}
-#if (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300)
+#if (__CORTEX_M >= 0x03)
/** \brief Enable FIQ
@@ -242,20 +228,6 @@ __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
}
-/** \brief Set Base Priority with condition
-
- This function assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
- or the new value increases the BASEPRI priority level.
-
- \param [in] basePri Base Priority value to set
- */
-__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
-{
- register uint32_t __regBasePriMax __ASM("basepri_max");
- __regBasePriMax = (basePri & 0xff);
-}
-
-
/** \brief Get Fault Mask
This function returns the current value of the Fault Mask register.
@@ -281,10 +253,10 @@ __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
__regFaultMask = (faultMask & (uint32_t)1);
}
-#endif /* (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300) */
+#endif /* (__CORTEX_M >= 0x03) */
-#if (__CORTEX_M == 0x04) || (__CORTEX_M == 0x07)
+#if (__CORTEX_M == 0x04)
/** \brief Get FPSCR
@@ -317,7 +289,19 @@ __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
#endif
}
-#endif /* (__CORTEX_M == 0x04) || (__CORTEX_M == 0x07) */
+#endif /* (__CORTEX_M == 0x04) */
+
+
+#elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
+/* IAR iccarm specific functions */
+
+#include <cmsis_iar.h>
+
+
+#elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
+/* TI CCS specific functions */
+
+#include <cmsis_ccs.h>
#elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
@@ -330,7 +314,7 @@ __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void)
{
- __ASM volatile ("cpsie i" : : : "memory");
+ __ASM volatile ("cpsie i");
}
@@ -341,7 +325,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void)
{
- __ASM volatile ("cpsid i" : : : "memory");
+ __ASM volatile ("cpsid i");
}
@@ -368,7 +352,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control)
{
- __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
+ __ASM volatile ("MSR control, %0" : : "r" (control) );
}
@@ -440,7 +424,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
{
- __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp");
+ __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) );
}
@@ -467,7 +451,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
{
- __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp");
+ __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) );
}
@@ -494,7 +478,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
{
- __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
+ __ASM volatile ("MSR primask, %0" : : "r" (priMask) );
}
@@ -507,7 +491,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t p
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void)
{
- __ASM volatile ("cpsie f" : : : "memory");
+ __ASM volatile ("cpsie f");
}
@@ -518,7 +502,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void)
{
- __ASM volatile ("cpsid f" : : : "memory");
+ __ASM volatile ("cpsid f");
}
@@ -532,7 +516,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void)
{
uint32_t result;
- __ASM volatile ("MRS %0, basepri" : "=r" (result) );
+ __ASM volatile ("MRS %0, basepri_max" : "=r" (result) );
return(result);
}
@@ -545,20 +529,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value)
{
- __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory");
-}
-
-
-/** \brief Set Base Priority with condition
-
- This function assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
- or the new value increases the BASEPRI priority level.
-
- \param [in] basePri Base Priority value to set
- */
-__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t value)
-{
- __ASM volatile ("MSR basepri_max, %0" : : "r" (value) : "memory");
+ __ASM volatile ("MSR basepri, %0" : : "r" (value) );
}
@@ -585,13 +556,13 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
{
- __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
+ __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) );
}
#endif /* (__CORTEX_M >= 0x03) */
-#if (__CORTEX_M == 0x04) || (__CORTEX_M == 0x07)
+#if (__CORTEX_M == 0x04)
/** \brief Get FPSCR
@@ -604,10 +575,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void)
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
uint32_t result;
- /* Empty asm statement works as a scheduling barrier */
- __ASM volatile ("");
__ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
- __ASM volatile ("");
return(result);
#else
return(0);
@@ -624,41 +592,25 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void)
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
{
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
- /* Empty asm statement works as a scheduling barrier */
- __ASM volatile ("");
- __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc");
- __ASM volatile ("");
+ __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) );
#endif
}
-#endif /* (__CORTEX_M == 0x04) || (__CORTEX_M == 0x07) */
-
-
-#elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
-/* IAR iccarm specific functions */
-#include <cmsis_iar.h>
-
-
-#elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
-/* TI CCS specific functions */
-#include <cmsis_ccs.h>
+#endif /* (__CORTEX_M == 0x04) */
#elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
/* TASKING carm specific functions */
+
/*
* The CMSIS functions have been implemented as intrinsics in the compiler.
- * Please use "carm -?i" to get an up to date list of all intrinsics,
+ * Please use "carm -?i" to get an up to date list of all instrinsics,
* Including the CMSIS ones.
*/
-
-#elif defined ( __CSMC__ ) /*------------------ COSMIC Compiler -------------------*/
-/* Cosmic specific functions */
-#include <cmsis_csm.h>
-
#endif
/*@} end of CMSIS_Core_RegAccFunctions */
+
#endif /* __CORE_CMFUNC_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/core_cmInstr.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/core_cmInstr.h
index fca425c51d..597e64df04 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/core_cmInstr.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/CMSIS/core_cmInstr.h
@@ -1,39 +1,25 @@
/**************************************************************************//**
* @file core_cmInstr.h
* @brief CMSIS Cortex-M Core Instruction Access Header File
- * @version V4.10
- * @date 18. March 2015
+ * @version V3.01
+ * @date 06. March 2012
*
* @note
+ * Copyright (C) 2009-2012 ARM Limited. All rights reserved.
+ *
+ * @par
+ * ARM Limited (ARM) is supplying this software for use with Cortex-M
+ * processor based microcontrollers. This file can be freely distributed
+ * within development tools that are supporting such ARM based processors.
+ *
+ * @par
+ * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
+ * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
+ * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
+ * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
******************************************************************************/
-/* Copyright (c) 2009 - 2014 ARM LIMITED
-
- All rights reserved.
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- - Neither the name of ARM nor the names of its contributors may be used
- to endorse or promote products derived from this software without
- specific prior written permission.
- *
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
- ---------------------------------------------------------------------------*/
-
#ifndef __CORE_CMINSTR_H
#define __CORE_CMINSTR_H
@@ -89,33 +75,24 @@
so that all instructions following the ISB are fetched from cache or
memory, after the instruction has been completed.
*/
-#define __ISB() do {\
- __schedule_barrier();\
- __isb(0xF);\
- __schedule_barrier();\
- } while (0)
+#define __ISB() __isb(0xF)
+
/** \brief Data Synchronization Barrier
This function acts as a special kind of Data Memory Barrier.
It completes when all explicit memory accesses before this instruction complete.
*/
-#define __DSB() do {\
- __schedule_barrier();\
- __dsb(0xF);\
- __schedule_barrier();\
- } while (0)
+#define __DSB() __dsb(0xF)
+
/** \brief Data Memory Barrier
This function ensures the apparent order of the explicit memory operations before
and after the instruction, without ensuring their completion.
*/
-#define __DMB() do {\
- __schedule_barrier();\
- __dmb(0xF);\
- __schedule_barrier();\
- } while (0)
+#define __DMB() __dmb(0xF)
+
/** \brief Reverse byte order (32 bit)
@@ -134,13 +111,12 @@
\param [in] value Value to reverse
\return Reversed value
*/
-#ifndef __NO_EMBEDDED_ASM
__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
{
rev16 r0, r0
bx lr
}
-#endif
+
/** \brief Reverse byte order in signed short value
@@ -149,13 +125,11 @@ __attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(u
\param [in] value Value to reverse
\return Reversed value
*/
-#ifndef __NO_EMBEDDED_ASM
__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(int32_t value)
{
revsh r0, r0
bx lr
}
-#endif
/** \brief Rotate Right in unsigned value (32 bit)
@@ -169,16 +143,7 @@ __attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(in
#define __ROR __ror
-/** \brief Breakpoint
-
- This function causes the processor to enter Debug state.
- Debug tools can use this to investigate system state when the instruction at a particular address is reached.
-
- \param [in] value is ignored by the processor.
- If required, a debugger can use it to store additional information about the breakpoint.
- */
-#define __BKPT(value) __breakpoint(value)
-
+#if (__CORTEX_M >= 0x03)
/** \brief Reverse bit order of value
@@ -187,42 +152,12 @@ __attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(in
\param [in] value Value to reverse
\return Reversed value
*/
-#if (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300)
- #define __RBIT __rbit
-#else
-__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
-{
- uint32_t result;
- int32_t s = 4 /*sizeof(v)*/ * 8 - 1; // extra shift needed at end
-
- result = value; // r will be reversed bits of v; first get LSB of v
- for (value >>= 1; value; value >>= 1)
- {
- result <<= 1;
- result |= value & 1;
- s--;
- }
- result <<= s; // shift when v's highest bits are zero
- return(result);
-}
-#endif
-
-
-/** \brief Count leading zeros
+#define __RBIT __rbit
- This function counts the number of leading zeros of a data value.
-
- \param [in] value Value to count the leading zeros
- \return number of leading zeros in value
- */
-#define __CLZ __clz
-
-
-#if (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300)
/** \brief LDR Exclusive (8 bit)
- This function executes a exclusive LDR instruction for 8 bit value.
+ This function performs a exclusive LDR command for 8 bit value.
\param [in] ptr Pointer to data
\return value of type uint8_t at (*ptr)
@@ -232,7 +167,7 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
/** \brief LDR Exclusive (16 bit)
- This function executes a exclusive LDR instruction for 16 bit values.
+ This function performs a exclusive LDR command for 16 bit values.
\param [in] ptr Pointer to data
\return value of type uint16_t at (*ptr)
@@ -242,7 +177,7 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
/** \brief LDR Exclusive (32 bit)
- This function executes a exclusive LDR instruction for 32 bit values.
+ This function performs a exclusive LDR command for 32 bit values.
\param [in] ptr Pointer to data
\return value of type uint32_t at (*ptr)
@@ -252,7 +187,7 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
/** \brief STR Exclusive (8 bit)
- This function executes a exclusive STR instruction for 8 bit values.
+ This function performs a exclusive STR command for 8 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
@@ -264,7 +199,7 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
/** \brief STR Exclusive (16 bit)
- This function executes a exclusive STR instruction for 16 bit values.
+ This function performs a exclusive STR command for 16 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
@@ -276,7 +211,7 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
/** \brief STR Exclusive (32 bit)
- This function executes a exclusive STR instruction for 32 bit values.
+ This function performs a exclusive STR command for 32 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
@@ -316,104 +251,39 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
#define __USAT __usat
-/** \brief Rotate Right with Extend (32 bit)
-
- This function moves each bit of a bitstring right by one bit.
- The carry input is shifted in at the left end of the bitstring.
-
- \param [in] value Value to rotate
- \return Rotated value
- */
-#ifndef __NO_EMBEDDED_ASM
-__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
-{
- rrx r0, r0
- bx lr
-}
-#endif
-
-
-/** \brief LDRT Unprivileged (8 bit)
-
- This function executes a Unprivileged LDRT instruction for 8 bit value.
-
- \param [in] ptr Pointer to data
- \return value of type uint8_t at (*ptr)
- */
-#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
-
-
-/** \brief LDRT Unprivileged (16 bit)
-
- This function executes a Unprivileged LDRT instruction for 16 bit values.
-
- \param [in] ptr Pointer to data
- \return value of type uint16_t at (*ptr)
- */
-#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
-
-
-/** \brief LDRT Unprivileged (32 bit)
-
- This function executes a Unprivileged LDRT instruction for 32 bit values.
-
- \param [in] ptr Pointer to data
- \return value of type uint32_t at (*ptr)
- */
-#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
-
-
-/** \brief STRT Unprivileged (8 bit)
+/** \brief Count leading zeros
- This function executes a Unprivileged STRT instruction for 8 bit values.
+ This function counts the number of leading zeros of a data value.
- \param [in] value Value to store
- \param [in] ptr Pointer to location
+ \param [in] value Value to count the leading zeros
+ \return number of leading zeros in value
*/
-#define __STRBT(value, ptr) __strt(value, ptr)
-
+#define __CLZ __clz
-/** \brief STRT Unprivileged (16 bit)
+#endif /* (__CORTEX_M >= 0x03) */
- This function executes a Unprivileged STRT instruction for 16 bit values.
- \param [in] value Value to store
- \param [in] ptr Pointer to location
- */
-#define __STRHT(value, ptr) __strt(value, ptr)
+#elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
+/* IAR iccarm specific functions */
-/** \brief STRT Unprivileged (32 bit)
+#include <cmsis_iar.h>
- This function executes a Unprivileged STRT instruction for 32 bit values.
- \param [in] value Value to store
- \param [in] ptr Pointer to location
- */
-#define __STRT(value, ptr) __strt(value, ptr)
+#elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
+/* TI CCS specific functions */
-#endif /* (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300) */
+#include <cmsis_ccs.h>
#elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
/* GNU gcc specific functions */
-/* Define macros for porting to both thumb1 and thumb2.
- * For thumb1, use low register (r0-r7), specified by constrant "l"
- * Otherwise, use general registers, specified by constrant "r" */
-#if defined (__thumb__) && !defined (__thumb2__)
-#define __CMSIS_GCC_OUT_REG(r) "=l" (r)
-#define __CMSIS_GCC_USE_REG(r) "l" (r)
-#else
-#define __CMSIS_GCC_OUT_REG(r) "=r" (r)
-#define __CMSIS_GCC_USE_REG(r) "r" (r)
-#endif
-
/** \brief No Operation
No Operation does nothing. This instruction can be used for code alignment purposes.
*/
-__attribute__((always_inline)) __STATIC_INLINE void __NOP(void)
+__attribute__( ( always_inline ) ) __STATIC_INLINE void __NOP(void)
{
__ASM volatile ("nop");
}
@@ -424,7 +294,7 @@ __attribute__((always_inline)) __STATIC_INLINE void __NOP(void)
Wait For Interrupt is a hint instruction that suspends execution
until one of a number of events occurs.
*/
-__attribute__((always_inline)) __STATIC_INLINE void __WFI(void)
+__attribute__( ( always_inline ) ) __STATIC_INLINE void __WFI(void)
{
__ASM volatile ("wfi");
}
@@ -435,7 +305,7 @@ __attribute__((always_inline)) __STATIC_INLINE void __WFI(void)
Wait For Event is a hint instruction that permits the processor to enter
a low-power state until one of a number of events occurs.
*/
-__attribute__((always_inline)) __STATIC_INLINE void __WFE(void)
+__attribute__( ( always_inline ) ) __STATIC_INLINE void __WFE(void)
{
__ASM volatile ("wfe");
}
@@ -445,7 +315,7 @@ __attribute__((always_inline)) __STATIC_INLINE void __WFE(void)
Send Event is a hint instruction. It causes an event to be signaled to the CPU.
*/
-__attribute__((always_inline)) __STATIC_INLINE void __SEV(void)
+__attribute__( ( always_inline ) ) __STATIC_INLINE void __SEV(void)
{
__ASM volatile ("sev");
}
@@ -457,9 +327,9 @@ __attribute__((always_inline)) __STATIC_INLINE void __SEV(void)
so that all instructions following the ISB are fetched from cache or
memory, after the instruction has been completed.
*/
-__attribute__((always_inline)) __STATIC_INLINE void __ISB(void)
+__attribute__( ( always_inline ) ) __STATIC_INLINE void __ISB(void)
{
- __ASM volatile ("isb 0xF":::"memory");
+ __ASM volatile ("isb");
}
@@ -468,9 +338,9 @@ __attribute__((always_inline)) __STATIC_INLINE void __ISB(void)
This function acts as a special kind of Data Memory Barrier.
It completes when all explicit memory accesses before this instruction complete.
*/
-__attribute__((always_inline)) __STATIC_INLINE void __DSB(void)
+__attribute__( ( always_inline ) ) __STATIC_INLINE void __DSB(void)
{
- __ASM volatile ("dsb 0xF":::"memory");
+ __ASM volatile ("dsb");
}
@@ -479,9 +349,9 @@ __attribute__((always_inline)) __STATIC_INLINE void __DSB(void)
This function ensures the apparent order of the explicit memory operations before
and after the instruction, without ensuring their completion.
*/
-__attribute__((always_inline)) __STATIC_INLINE void __DMB(void)
+__attribute__( ( always_inline ) ) __STATIC_INLINE void __DMB(void)
{
- __ASM volatile ("dmb 0xF":::"memory");
+ __ASM volatile ("dmb");
}
@@ -492,16 +362,12 @@ __attribute__((always_inline)) __STATIC_INLINE void __DMB(void)
\param [in] value Value to reverse
\return Reversed value
*/
-__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV(uint32_t value)
+__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV(uint32_t value)
{
-#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
- return __builtin_bswap32(value);
-#else
uint32_t result;
- __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
+ __ASM volatile ("rev %0, %1" : "=r" (result) : "r" (value) );
return(result);
-#endif
}
@@ -512,11 +378,11 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV(uint32_t value)
\param [in] value Value to reverse
\return Reversed value
*/
-__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value)
+__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV16(uint32_t value)
{
uint32_t result;
- __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
+ __ASM volatile ("rev16 %0, %1" : "=r" (result) : "r" (value) );
return(result);
}
@@ -528,16 +394,12 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value)
\param [in] value Value to reverse
\return Reversed value
*/
-__attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value)
+__attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __REVSH(int32_t value)
{
-#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
- return (short)__builtin_bswap16(value);
-#else
uint32_t result;
- __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
+ __ASM volatile ("revsh %0, %1" : "=r" (result) : "r" (value) );
return(result);
-#endif
}
@@ -549,22 +411,15 @@ __attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value)
\param [in] value Number of Bits to rotate
\return Rotated value
*/
-__attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
+__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
{
- return (op1 >> op2) | (op1 << (32 - op2));
-}
+ __ASM volatile ("ror %0, %0, %1" : "+r" (op1) : "r" (op2) );
+ return(op1);
+}
-/** \brief Breakpoint
-
- This function causes the processor to enter Debug state.
- Debug tools can use this to investigate system state when the instruction at a particular address is reached.
-
- \param [in] value is ignored by the processor.
- If required, a debugger can use it to store additional information about the breakpoint.
- */
-#define __BKPT(value) __ASM volatile ("bkpt "#value)
+#if (__CORTEX_M >= 0x03)
/** \brief Reverse bit order of value
@@ -573,152 +428,113 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint
\param [in] value Value to reverse
\return Reversed value
*/
-__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
+__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
{
uint32_t result;
-#if (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300)
__ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
-#else
- int32_t s = 4 /*sizeof(v)*/ * 8 - 1; // extra shift needed at end
-
- result = value; // r will be reversed bits of v; first get LSB of v
- for (value >>= 1; value; value >>= 1)
- {
- result <<= 1;
- result |= value & 1;
- s--;
- }
- result <<= s; // shift when v's highest bits are zero
-#endif
- return(result);
+ return(result);
}
-/** \brief Count leading zeros
-
- This function counts the number of leading zeros of a data value.
-
- \param [in] value Value to count the leading zeros
- \return number of leading zeros in value
- */
-#define __CLZ __builtin_clz
-
-
-#if (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300)
-
/** \brief LDR Exclusive (8 bit)
- This function executes a exclusive LDR instruction for 8 bit value.
+ This function performs a exclusive LDR command for 8 bit value.
\param [in] ptr Pointer to data
\return value of type uint8_t at (*ptr)
*/
-__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr)
+__attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr)
{
- uint32_t result;
+ uint8_t result;
-#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
- __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) );
-#else
- /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
- accepted by assembler. So has to use following less efficient pattern.
- */
- __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
-#endif
- return ((uint8_t) result); /* Add explicit type cast here */
+ __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) );
+ return(result);
}
/** \brief LDR Exclusive (16 bit)
- This function executes a exclusive LDR instruction for 16 bit values.
+ This function performs a exclusive LDR command for 16 bit values.
\param [in] ptr Pointer to data
\return value of type uint16_t at (*ptr)
*/
-__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr)
+__attribute__( ( always_inline ) ) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr)
{
- uint32_t result;
+ uint16_t result;
-#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
- __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) );
-#else
- /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
- accepted by assembler. So has to use following less efficient pattern.
- */
- __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
-#endif
- return ((uint16_t) result); /* Add explicit type cast here */
+ __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) );
+ return(result);
}
/** \brief LDR Exclusive (32 bit)
- This function executes a exclusive LDR instruction for 32 bit values.
+ This function performs a exclusive LDR command for 32 bit values.
\param [in] ptr Pointer to data
\return value of type uint32_t at (*ptr)
*/
-__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr)
+__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr)
{
uint32_t result;
- __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) );
+ __ASM volatile ("ldrex %0, [%1]" : "=r" (result) : "r" (addr) );
return(result);
}
/** \brief STR Exclusive (8 bit)
- This function executes a exclusive STR instruction for 8 bit values.
+ This function performs a exclusive STR command for 8 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
\return 0 Function succeeded
\return 1 Function failed
*/
-__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
+__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
{
uint32_t result;
- __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
+ __ASM volatile ("strexb %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );
return(result);
}
/** \brief STR Exclusive (16 bit)
- This function executes a exclusive STR instruction for 16 bit values.
+ This function performs a exclusive STR command for 16 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
\return 0 Function succeeded
\return 1 Function failed
*/
-__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
+__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
{
uint32_t result;
- __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
+ __ASM volatile ("strexh %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );
return(result);
}
/** \brief STR Exclusive (32 bit)
- This function executes a exclusive STR instruction for 32 bit values.
+ This function performs a exclusive STR command for 32 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
\return 0 Function succeeded
\return 1 Function failed
*/
-__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
+__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
{
uint32_t result;
- __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
+ __ASM volatile ("strex %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );
return(result);
}
@@ -728,9 +544,9 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXW(uint32_t value,
This function removes the exclusive lock which is created by LDREX.
*/
-__attribute__((always_inline)) __STATIC_INLINE void __CLREX(void)
+__attribute__( ( always_inline ) ) __STATIC_INLINE void __CLREX(void)
{
- __ASM volatile ("clrex" ::: "memory");
+ __ASM volatile ("clrex");
}
@@ -766,149 +582,35 @@ __attribute__((always_inline)) __STATIC_INLINE void __CLREX(void)
})
-/** \brief Rotate Right with Extend (32 bit)
+/** \brief Count leading zeros
- This function moves each bit of a bitstring right by one bit.
- The carry input is shifted in at the left end of the bitstring.
+ This function counts the number of leading zeros of a data value.
- \param [in] value Value to rotate
- \return Rotated value
+ \param [in] value Value to count the leading zeros
+ \return number of leading zeros in value
*/
-__attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value)
+__attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __CLZ(uint32_t value)
{
- uint32_t result;
+ uint8_t result;
- __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
+ __ASM volatile ("clz %0, %1" : "=r" (result) : "r" (value) );
return(result);
}
-
-/** \brief LDRT Unprivileged (8 bit)
-
- This function executes a Unprivileged LDRT instruction for 8 bit value.
-
- \param [in] ptr Pointer to data
- \return value of type uint8_t at (*ptr)
- */
-__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *addr)
-{
- uint32_t result;
-
-#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
- __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*addr) );
-#else
- /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
- accepted by assembler. So has to use following less efficient pattern.
- */
- __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
-#endif
- return ((uint8_t) result); /* Add explicit type cast here */
-}
-
-
-/** \brief LDRT Unprivileged (16 bit)
-
- This function executes a Unprivileged LDRT instruction for 16 bit values.
-
- \param [in] ptr Pointer to data
- \return value of type uint16_t at (*ptr)
- */
-__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *addr)
-{
- uint32_t result;
-
-#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
- __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*addr) );
-#else
- /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
- accepted by assembler. So has to use following less efficient pattern.
- */
- __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
-#endif
- return ((uint16_t) result); /* Add explicit type cast here */
-}
-
-
-/** \brief LDRT Unprivileged (32 bit)
-
- This function executes a Unprivileged LDRT instruction for 32 bit values.
-
- \param [in] ptr Pointer to data
- \return value of type uint32_t at (*ptr)
- */
-__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *addr)
-{
- uint32_t result;
-
- __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*addr) );
- return(result);
-}
-
-
-/** \brief STRT Unprivileged (8 bit)
-
- This function executes a Unprivileged STRT instruction for 8 bit values.
-
- \param [in] value Value to store
- \param [in] ptr Pointer to location
- */
-__attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *addr)
-{
- __ASM volatile ("strbt %1, %0" : "=Q" (*addr) : "r" ((uint32_t)value) );
-}
-
-
-/** \brief STRT Unprivileged (16 bit)
-
- This function executes a Unprivileged STRT instruction for 16 bit values.
-
- \param [in] value Value to store
- \param [in] ptr Pointer to location
- */
-__attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *addr)
-{
- __ASM volatile ("strht %1, %0" : "=Q" (*addr) : "r" ((uint32_t)value) );
-}
-
-
-/** \brief STRT Unprivileged (32 bit)
-
- This function executes a Unprivileged STRT instruction for 32 bit values.
-
- \param [in] value Value to store
- \param [in] ptr Pointer to location
- */
-__attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *addr)
-{
- __ASM volatile ("strt %1, %0" : "=Q" (*addr) : "r" (value) );
-}
-
-#endif /* (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300) */
-
-
-#elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
-/* IAR iccarm specific functions */
-#include <cmsis_iar.h>
+#endif /* (__CORTEX_M >= 0x03) */
-#elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
-/* TI CCS specific functions */
-#include <cmsis_ccs.h>
#elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
/* TASKING carm specific functions */
+
/*
* The CMSIS functions have been implemented as intrinsics in the compiler.
* Please use "carm -?i" to get an up to date list of all intrinsics,
* Including the CMSIS ones.
*/
-
-#elif defined ( __CSMC__ ) /*------------------ COSMIC Compiler -------------------*/
-/* Cosmic specific functions */
-#include <cmsis_csm.h>
-
#endif
/*@}*/ /* end of group CMSIS_Core_InstructionInterface */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_adc.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_adc.h
index 4f6020a50a..096b0c9568 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_adc.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_adc.h
@@ -1,36 +1,37 @@
/*!
\file gd32f4xx_adc.h
\brief definitions for the ADC
-
+
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -45,365 +46,365 @@ OF SUCH DAMAGE.
#define ADC2 (ADC_BASE + 0x200U)
/* registers definitions */
-#define ADC_STAT(adcx) REG32((adcx) + 0x00U) /*!< ADC status register */
-#define ADC_CTL0(adcx) REG32((adcx) + 0x04U) /*!< ADC control register 0 */
-#define ADC_CTL1(adcx) REG32((adcx) + 0x08U) /*!< ADC control register 1 */
-#define ADC_SAMPT0(adcx) REG32((adcx) + 0x0CU) /*!< ADC sampling time register 0 */
-#define ADC_SAMPT1(adcx) REG32((adcx) + 0x10U) /*!< ADC sampling time register 1 */
-#define ADC_IOFF0(adcx) REG32((adcx) + 0x14U) /*!< ADC inserted channel data offset register 0 */
-#define ADC_IOFF1(adcx) REG32((adcx) + 0x18U) /*!< ADC inserted channel data offset register 1 */
-#define ADC_IOFF2(adcx) REG32((adcx) + 0x1CU) /*!< ADC inserted channel data offset register 2 */
-#define ADC_IOFF3(adcx) REG32((adcx) + 0x20U) /*!< ADC inserted channel data offset register 3 */
-#define ADC_WDHT(adcx) REG32((adcx) + 0x24U) /*!< ADC watchdog high threshold register */
-#define ADC_WDLT(adcx) REG32((adcx) + 0x28U) /*!< ADC watchdog low threshold register */
-#define ADC_RSQ0(adcx) REG32((adcx) + 0x2CU) /*!< ADC regular sequence register 0 */
-#define ADC_RSQ1(adcx) REG32((adcx) + 0x30U) /*!< ADC regular sequence register 1 */
-#define ADC_RSQ2(adcx) REG32((adcx) + 0x34U) /*!< ADC regular sequence register 2 */
-#define ADC_ISQ(adcx) REG32((adcx) + 0x38U) /*!< ADC inserted sequence register */
-#define ADC_IDATA0(adcx) REG32((adcx) + 0x3CU) /*!< ADC inserted data register 0 */
-#define ADC_IDATA1(adcx) REG32((adcx) + 0x40U) /*!< ADC inserted data register 1 */
-#define ADC_IDATA2(adcx) REG32((adcx) + 0x44U) /*!< ADC inserted data register 2 */
-#define ADC_IDATA3(adcx) REG32((adcx) + 0x48U) /*!< ADC inserted data register 3 */
-#define ADC_RDATA(adcx) REG32((adcx) + 0x4CU) /*!< ADC regular data register */
-#define ADC_OVSAMPCTL(adcx) REG32((adcx) + 0x80U) /*!< ADC oversampling control register */
-#define ADC_SSTAT REG32((ADC_BASE) + 0x300U) /*!< ADC summary status register */
-#define ADC_SYNCCTL REG32((ADC_BASE) + 0x304U) /*!< ADC synchronization control register */
-#define ADC_SYNCDATA REG32((ADC_BASE) + 0x308U) /*!< ADC synchronization regular data register */
+#define ADC_STAT(adcx) REG32((adcx) + 0x00U) /*!< ADC status register */
+#define ADC_CTL0(adcx) REG32((adcx) + 0x04U) /*!< ADC control register 0 */
+#define ADC_CTL1(adcx) REG32((adcx) + 0x08U) /*!< ADC control register 1 */
+#define ADC_SAMPT0(adcx) REG32((adcx) + 0x0CU) /*!< ADC sampling time register 0 */
+#define ADC_SAMPT1(adcx) REG32((adcx) + 0x10U) /*!< ADC sampling time register 1 */
+#define ADC_IOFF0(adcx) REG32((adcx) + 0x14U) /*!< ADC inserted channel data offset register 0 */
+#define ADC_IOFF1(adcx) REG32((adcx) + 0x18U) /*!< ADC inserted channel data offset register 1 */
+#define ADC_IOFF2(adcx) REG32((adcx) + 0x1CU) /*!< ADC inserted channel data offset register 2 */
+#define ADC_IOFF3(adcx) REG32((adcx) + 0x20U) /*!< ADC inserted channel data offset register 3 */
+#define ADC_WDHT(adcx) REG32((adcx) + 0x24U) /*!< ADC watchdog high threshold register */
+#define ADC_WDLT(adcx) REG32((adcx) + 0x28U) /*!< ADC watchdog low threshold register */
+#define ADC_RSQ0(adcx) REG32((adcx) + 0x2CU) /*!< ADC routine sequence register 0 */
+#define ADC_RSQ1(adcx) REG32((adcx) + 0x30U) /*!< ADC routine sequence register 1 */
+#define ADC_RSQ2(adcx) REG32((adcx) + 0x34U) /*!< ADC routine sequence register 2 */
+#define ADC_ISQ(adcx) REG32((adcx) + 0x38U) /*!< ADC inserted sequence register */
+#define ADC_IDATA0(adcx) REG32((adcx) + 0x3CU) /*!< ADC inserted data register 0 */
+#define ADC_IDATA1(adcx) REG32((adcx) + 0x40U) /*!< ADC inserted data register 1 */
+#define ADC_IDATA2(adcx) REG32((adcx) + 0x44U) /*!< ADC inserted data register 2 */
+#define ADC_IDATA3(adcx) REG32((adcx) + 0x48U) /*!< ADC inserted data register 3 */
+#define ADC_RDATA(adcx) REG32((adcx) + 0x4CU) /*!< ADC routine data register */
+#define ADC_OVSAMPCTL(adcx) REG32((adcx) + 0x80U) /*!< ADC oversampling control register */
+#define ADC_SSTAT REG32((ADC_BASE) + 0x300U) /*!< ADC summary status register */
+#define ADC_SYNCCTL REG32((ADC_BASE) + 0x304U) /*!< ADC synchronization control register */
+#define ADC_SYNCDATA REG32((ADC_BASE) + 0x308U) /*!< ADC synchronization routine data register */
/* bits definitions */
/* ADC_STAT */
-#define ADC_STAT_WDE BIT(0) /*!< analog watchdog event flag */
-#define ADC_STAT_EOC BIT(1) /*!< end of conversion */
-#define ADC_STAT_EOIC BIT(2) /*!< inserted channel end of conversion */
-#define ADC_STAT_STIC BIT(3) /*!< inserted channel start flag */
-#define ADC_STAT_STRC BIT(4) /*!< regular channel start flag */
-#define ADC_STAT_ROVF BIT(5) /*!< regular data register overflow */
+#define ADC_STAT_WDE BIT(0) /*!< analog watchdog event flag */
+#define ADC_STAT_EOC BIT(1) /*!< end of conversion */
+#define ADC_STAT_EOIC BIT(2) /*!< inserted channel end of conversion */
+#define ADC_STAT_STIC BIT(3) /*!< inserted channel start flag */
+#define ADC_STAT_STRC BIT(4) /*!< routine channel start flag */
+#define ADC_STAT_ROVF BIT(5) /*!< routine data register overflow */
/* ADC_CTL0 */
-#define ADC_CTL0_WDCHSEL BITS(0,4) /*!< analog watchdog channel select bits */
-#define ADC_CTL0_EOCIE BIT(5) /*!< interrupt enable for EOC */
-#define ADC_CTL0_WDEIE BIT(6) /*!< analog watchdog interrupt enable */
-#define ADC_CTL0_EOICIE BIT(7) /*!< interrupt enable for inserted channels */
-#define ADC_CTL0_SM BIT(8) /*!< scan mode */
-#define ADC_CTL0_WDSC BIT(9) /*!< when in scan mode, analog watchdog is effective on a single channel */
-#define ADC_CTL0_ICA BIT(10) /*!< automatic inserted group conversion */
-#define ADC_CTL0_DISRC BIT(11) /*!< discontinuous mode on regular channels */
-#define ADC_CTL0_DISIC BIT(12) /*!< discontinuous mode on inserted channels */
-#define ADC_CTL0_DISNUM BITS(13,15) /*!< discontinuous mode channel count */
-#define ADC_CTL0_IWDEN BIT(22) /*!< analog watchdog enable on inserted channels */
-#define ADC_CTL0_RWDEN BIT(23) /*!< analog watchdog enable on regular channels */
-#define ADC_CTL0_DRES BITS(24,25) /*!< ADC data resolution */
-#define ADC_CTL0_ROVFIE BIT(26) /*!< interrupt enable for ROVF */
+#define ADC_CTL0_WDCHSEL BITS(0,4) /*!< analog watchdog channel select bits */
+#define ADC_CTL0_EOCIE BIT(5) /*!< interrupt enable for EOC */
+#define ADC_CTL0_WDEIE BIT(6) /*!< analog watchdog interrupt enable */
+#define ADC_CTL0_EOICIE BIT(7) /*!< interrupt enable for inserted channels */
+#define ADC_CTL0_SM BIT(8) /*!< scan mode */
+#define ADC_CTL0_WDSC BIT(9) /*!< when in scan mode, analog watchdog is effective on a single channel */
+#define ADC_CTL0_ICA BIT(10) /*!< automatic inserted sequence conversion */
+#define ADC_CTL0_DISRC BIT(11) /*!< discontinuous mode on routine channels */
+#define ADC_CTL0_DISIC BIT(12) /*!< discontinuous mode on inserted channels */
+#define ADC_CTL0_DISNUM BITS(13,15) /*!< discontinuous mode channel count */
+#define ADC_CTL0_IWDEN BIT(22) /*!< analog watchdog enable on inserted channels */
+#define ADC_CTL0_RWDEN BIT(23) /*!< analog watchdog enable on routine channels */
+#define ADC_CTL0_DRES BITS(24,25) /*!< ADC data resolution */
+#define ADC_CTL0_ROVFIE BIT(26) /*!< interrupt enable for ROVF */
/* ADC_CTL1 */
-#define ADC_CTL1_ADCON BIT(0) /*!< ADC converter on */
-#define ADC_CTL1_CTN BIT(1) /*!< continuous conversion */
-#define ADC_CTL1_CLB BIT(2) /*!< ADC calibration */
-#define ADC_CTL1_RSTCLB BIT(3) /*!< reset calibration */
-#define ADC_CTL1_DMA BIT(8) /*!< direct memory access mode */
-#define ADC_CTL1_DDM BIT(9) /*!< DMA disable mode */
-#define ADC_CTL1_EOCM BIT(10) /*!< end of conversion mode */
-#define ADC_CTL1_DAL BIT(11) /*!< data alignment */
-#define ADC_CTL1_ETSIC BITS(16,19) /*!< external event select for inserted group */
-#define ADC_CTL1_ETMIC BITS(20,21) /*!< external trigger conversion mode for inserted channels */
-#define ADC_CTL1_SWICST BIT(22) /*!< start conversion of inserted channels */
-#define ADC_CTL1_ETSRC BITS(24,27) /*!< external event select for regular group */
-#define ADC_CTL1_ETMRC BITS(28,29) /*!< external trigger conversion mode for regular channels */
-#define ADC_CTL1_SWRCST BIT(30) /*!< start conversion of regular channels */
+#define ADC_CTL1_ADCON BIT(0) /*!< ADC converter on */
+#define ADC_CTL1_CTN BIT(1) /*!< continuous conversion */
+#define ADC_CTL1_CLB BIT(2) /*!< ADC calibration */
+#define ADC_CTL1_RSTCLB BIT(3) /*!< reset calibration */
+#define ADC_CTL1_DMA BIT(8) /*!< direct memory access mode */
+#define ADC_CTL1_DDM BIT(9) /*!< DMA disable mode */
+#define ADC_CTL1_EOCM BIT(10) /*!< end of conversion mode */
+#define ADC_CTL1_DAL BIT(11) /*!< data alignment */
+#define ADC_CTL1_ETSIC BITS(16,19) /*!< external event select for inserted sequence */
+#define ADC_CTL1_ETMIC BITS(20,21) /*!< external trigger conversion mode for inserted channels */
+#define ADC_CTL1_SWICST BIT(22) /*!< start conversion of inserted channels */
+#define ADC_CTL1_ETSRC BITS(24,27) /*!< external event select for routine sequence */
+#define ADC_CTL1_ETMRC BITS(28,29) /*!< external trigger conversion mode for routine channels */
+#define ADC_CTL1_SWRCST BIT(30) /*!< start conversion of routine channels */
/* ADC_SAMPTx x=0..1 */
-#define ADC_SAMPTX_SPTN BITS(0,2) /*!< channel x sample time selection */
+#define ADC_SAMPTX_SPTN BITS(0,2) /*!< channel x sample time selection */
/* ADC_IOFFx x=0..3 */
-#define ADC_IOFFX_IOFF BITS(0,11) /*!< data offset for inserted channel x */
+#define ADC_IOFFX_IOFF BITS(0,11) /*!< data offset for inserted channel x */
/* ADC_WDHT */
-#define ADC_WDHT_WDHT BITS(0,11) /*!< analog watchdog high threshold */
+#define ADC_WDHT_WDHT BITS(0,11) /*!< analog watchdog high threshold */
/* ADC_WDLT */
-#define ADC_WDLT_WDLT BITS(0,11) /*!< analog watchdog low threshold */
+#define ADC_WDLT_WDLT BITS(0,11) /*!< analog watchdog low threshold */
/* ADC_RSQx */
-#define ADC_RSQX_RSQN BITS(0,4) /*!< x conversion in regular sequence */
-#define ADC_RSQ0_RL BITS(20,23) /*!< regular channel sequence length */
+#define ADC_RSQX_RSQN BITS(0,4) /*!< x conversion in routine sequence */
+#define ADC_RSQ0_RL BITS(20,23) /*!< routine channel sequence length */
/* ADC_ISQ */
-#define ADC_ISQ_ISQN BITS(0,4) /*!< x conversion in regular sequence */
-#define ADC_ISQ_IL BITS(20,21) /*!< inserted sequence length */
+#define ADC_ISQ_ISQN BITS(0,4) /*!< x conversion in inserted sequence */
+#define ADC_ISQ_IL BITS(20,21) /*!< inserted sequence length */
/* ADC_IDATAx x=0..3*/
-#define ADC_IDATAX_IDATAN BITS(0,15) /*!< inserted data x */
+#define ADC_IDATAX_IDATAN BITS(0,15) /*!< inserted data x */
/* ADC_RDATA */
-#define ADC_RDATA_RDATA BITS(0,15) /*!< regular data */
+#define ADC_RDATA_RDATA BITS(0,15) /*!< routine data */
/* ADC_OVSAMPCTL */
-#define ADC_OVSAMPCTL_OVSEN BIT(0) /*!< oversampling enable */
-#define ADC_OVSAMPCTL_OVSR BITS(2,4) /*!< oversampling ratio */
-#define ADC_OVSAMPCTL_OVSS BITS(5,8) /*!< oversampling shift */
-#define ADC_OVSAMPCTL_TOVS BIT(9) /*!< triggered oversampling */
+#define ADC_OVSAMPCTL_OVSEN BIT(0) /*!< oversampling enable */
+#define ADC_OVSAMPCTL_OVSR BITS(2,4) /*!< oversampling ratio */
+#define ADC_OVSAMPCTL_OVSS BITS(5,8) /*!< oversampling shift */
+#define ADC_OVSAMPCTL_TOVS BIT(9) /*!< triggered oversampling */
/* ADC_SSTAT */
-#define ADC_SSTAT_WDE0 BIT(0) /*!< the mirror image of the WDE bit of ADC0 */
-#define ADC_SSTAT_EOC0 BIT(1) /*!< the mirror image of the EOC bit of ADC0 */
-#define ADC_SSTAT_EOIC0 BIT(2) /*!< the mirror image of the EOIC bit of ADC0 */
-#define ADC_SSTAT_STIC0 BIT(3) /*!< the mirror image of the STIC bit of ADC0 */
-#define ADC_SSTAT_STRC0 BIT(4) /*!< the mirror image of the STRC bit of ADC0 */
-#define ADC_SSTAT_ROVF0 BIT(5) /*!< the mirror image of the ROVF bit of ADC0 */
-#define ADC_SSTAT_WDE1 BIT(8) /*!< the mirror image of the WDE bit of ADC1 */
-#define ADC_SSTAT_EOC1 BIT(9) /*!< the mirror image of the EOC bit of ADC1 */
-#define ADC_SSTAT_EOIC1 BIT(10) /*!< the mirror image of the EOIC bit of ADC1 */
-#define ADC_SSTAT_STIC1 BIT(11) /*!< the mirror image of the STIC bit of ADC1 */
-#define ADC_SSTAT_STRC1 BIT(12) /*!< the mirror image of the STRC bit of ADC1 */
-#define ADC_SSTAT_ROVF1 BIT(13) /*!< the mirror image of the ROVF bit of ADC1 */
-#define ADC_SSTAT_WDE2 BIT(16) /*!< the mirror image of the WDE bit of ADC2 */
-#define ADC_SSTAT_EOC2 BIT(17) /*!< the mirror image of the EOC bit of ADC2 */
-#define ADC_SSTAT_EOIC2 BIT(18) /*!< the mirror image of the EOIC bit of ADC2 */
-#define ADC_SSTAT_STIC2 BIT(19) /*!< the mirror image of the STIC bit of ADC2 */
-#define ADC_SSTAT_STRC2 BIT(20) /*!< the mirror image of the STRC bit of ADC2 */
-#define ADC_SSTAT_ROVF2 BIT(21) /*!< the mirror image of the ROVF bit of ADC2 */
+#define ADC_SSTAT_WDE0 BIT(0) /*!< the mirror image of the WDE bit of ADC0 */
+#define ADC_SSTAT_EOC0 BIT(1) /*!< the mirror image of the EOC bit of ADC0 */
+#define ADC_SSTAT_EOIC0 BIT(2) /*!< the mirror image of the EOIC bit of ADC0 */
+#define ADC_SSTAT_STIC0 BIT(3) /*!< the mirror image of the STIC bit of ADC0 */
+#define ADC_SSTAT_STRC0 BIT(4) /*!< the mirror image of the STRC bit of ADC0 */
+#define ADC_SSTAT_ROVF0 BIT(5) /*!< the mirror image of the ROVF bit of ADC0 */
+#define ADC_SSTAT_WDE1 BIT(8) /*!< the mirror image of the WDE bit of ADC1 */
+#define ADC_SSTAT_EOC1 BIT(9) /*!< the mirror image of the EOC bit of ADC1 */
+#define ADC_SSTAT_EOIC1 BIT(10) /*!< the mirror image of the EOIC bit of ADC1 */
+#define ADC_SSTAT_STIC1 BIT(11) /*!< the mirror image of the STIC bit of ADC1 */
+#define ADC_SSTAT_STRC1 BIT(12) /*!< the mirror image of the STRC bit of ADC1 */
+#define ADC_SSTAT_ROVF1 BIT(13) /*!< the mirror image of the ROVF bit of ADC1 */
+#define ADC_SSTAT_WDE2 BIT(16) /*!< the mirror image of the WDE bit of ADC2 */
+#define ADC_SSTAT_EOC2 BIT(17) /*!< the mirror image of the EOC bit of ADC2 */
+#define ADC_SSTAT_EOIC2 BIT(18) /*!< the mirror image of the EOIC bit of ADC2 */
+#define ADC_SSTAT_STIC2 BIT(19) /*!< the mirror image of the STIC bit of ADC2 */
+#define ADC_SSTAT_STRC2 BIT(20) /*!< the mirror image of the STRC bit of ADC2 */
+#define ADC_SSTAT_ROVF2 BIT(21) /*!< the mirror image of the ROVF bit of ADC2 */
/* ADC_SYNCCTL */
-#define ADC_SYNCCTL_SYNCM BITS(0,4) /*!< ADC synchronization mode */
-#define ADC_SYNCCTL_SYNCDLY BITS(8,11) /*!< ADC synchronization delay */
-#define ADC_SYNCCTL_SYNCDDM BIT(13) /*!< ADC synchronization DMA disable mode */
-#define ADC_SYNCCTL_SYNCDMA BITS(14,15) /*!< ADC synchronization DMA mode selection */
-#define ADC_SYNCCTL_ADCCK BITS(16,18) /*!< ADC clock */
-#define ADC_SYNCCTL_VBATEN BIT(22) /*!< channel 18 (1/4 voltate of external battery) enable of ADC0 */
-#define ADC_SYNCCTL_TSVREN BIT(23) /*!< channel 16 (temperature sensor) and 17 (internal reference voltage) enable of ADC0 */
+#define ADC_SYNCCTL_SYNCM BITS(0,4) /*!< ADC synchronization mode */
+#define ADC_SYNCCTL_SYNCDLY BITS(8,11) /*!< ADC synchronization delay */
+#define ADC_SYNCCTL_SYNCDDM BIT(13) /*!< ADC synchronization DMA disable mode */
+#define ADC_SYNCCTL_SYNCDMA BITS(14,15) /*!< ADC synchronization DMA mode selection */
+#define ADC_SYNCCTL_ADCCK BITS(16,18) /*!< ADC clock */
+#define ADC_SYNCCTL_VBATEN BIT(22) /*!< channel 18 (1/4 voltate of external battery) enable of ADC0 */
+#define ADC_SYNCCTL_TSVREN BIT(23) /*!< channel 16 (temperature sensor) and 17 (internal reference voltage) enable of ADC0 */
/* ADC_SYNCDATA */
-#define ADC_SYNCDATA_SYNCDATA0 BITS(0,15) /*!< regular data1 in ADC synchronization mode */
-#define ADC_SYNCDATA_SYNCDATA1 BITS(16,31) /*!< regular data2 in ADC synchronization mode */
+#define ADC_SYNCDATA_SYNCDATA0 BITS(0,15) /*!< routine data1 in ADC synchronization mode */
+#define ADC_SYNCDATA_SYNCDATA1 BITS(16,31) /*!< routine data2 in ADC synchronization mode */
/* constants definitions */
/* ADC status flag */
-#define ADC_FLAG_WDE ADC_STAT_WDE /*!< analog watchdog event flag */
-#define ADC_FLAG_EOC ADC_STAT_EOC /*!< end of conversion */
-#define ADC_FLAG_EOIC ADC_STAT_EOIC /*!< inserted channel end of conversion */
-#define ADC_FLAG_STIC ADC_STAT_STIC /*!< inserted channel start flag */
-#define ADC_FLAG_STRC ADC_STAT_STRC /*!< regular channel start flag */
-#define ADC_FLAG_ROVF ADC_STAT_ROVF /*!< regular data register overflow */
+#define ADC_FLAG_WDE ADC_STAT_WDE /*!< analog watchdog event flag */
+#define ADC_FLAG_EOC ADC_STAT_EOC /*!< end of conversion */
+#define ADC_FLAG_EOIC ADC_STAT_EOIC /*!< inserted channel end of conversion */
+#define ADC_FLAG_STIC ADC_STAT_STIC /*!< inserted channel start flag */
+#define ADC_FLAG_STRC ADC_STAT_STRC /*!< routine channel start flag */
+#define ADC_FLAG_ROVF ADC_STAT_ROVF /*!< routine data register overflow */
/* adc_ctl0 register value */
#define CTL0_DISNUM(regval) (BITS(13,15) & ((uint32_t)(regval) << 13)) /*!< write value to ADC_CTL0_DISNUM bit field */
/* ADC special function definitions */
-#define ADC_SCAN_MODE ADC_CTL0_SM /*!< scan mode */
-#define ADC_INSERTED_CHANNEL_AUTO ADC_CTL0_ICA /*!< inserted channel group convert automatically */
-#define ADC_CONTINUOUS_MODE ADC_CTL1_CTN /*!< continuous mode */
+#define ADC_SCAN_MODE ADC_CTL0_SM /*!< scan mode */
+#define ADC_INSERTED_CHANNEL_AUTO ADC_CTL0_ICA /*!< inserted sequence convert automatically */
+#define ADC_CONTINUOUS_MODE ADC_CTL1_CTN /*!< continuous mode */
/* temperature sensor channel, internal reference voltage channel, VBAT channel */
#define ADC_VBAT_CHANNEL_SWITCH ADC_SYNCCTL_VBATEN /*!< VBAT channel */
#define ADC_TEMP_VREF_CHANNEL_SWITCH ADC_SYNCCTL_TSVREN /*!< Vref and Vtemp channel */
/* ADC synchronization mode */
-#define SYNCCTL_SYNCM(regval) (BITS(0,4) & ((uint32_t)(regval))) /*!< write value to ADC_CTL0_SYNCM bit field */
-#define ADC_SYNC_MODE_INDEPENDENT SYNCCTL_SYNCM(0) /*!< ADC synchronization mode disabled.All the ADCs work independently */
-#define ADC_DAUL_REGULAL_PARALLEL_INSERTED_PARALLEL SYNCCTL_SYNCM(1) /*!< ADC0 and ADC1 work in combined regular parallel & inserted parallel mode. ADC2 works independently */
-#define ADC_DAUL_REGULAL_PARALLEL_INSERTED_ROTATION SYNCCTL_SYNCM(2) /*!< ADC0 and ADC1 work in combined regular parallel & trigger rotation mode. ADC2 works independently */
-#define ADC_DAUL_INSERTED_PARALLEL SYNCCTL_SYNCM(5) /*!< ADC0 and ADC1 work in inserted parallel mode. ADC2 works independently */
-#define ADC_DAUL_REGULAL_PARALLEL SYNCCTL_SYNCM(6) /*!< ADC0 and ADC1 work in regular parallel mode. ADC2 works independently */
-#define ADC_DAUL_REGULAL_FOLLOW_UP SYNCCTL_SYNCM(7) /*!< ADC0 and ADC1 work in follow-up mode. ADC2 works independently */
-#define ADC_DAUL_INSERTED_TRRIGGER_ROTATION SYNCCTL_SYNCM(9) /*!< ADC0 and ADC1 work in trigger rotation mode. ADC2 works independently */
-#define ADC_ALL_REGULAL_PARALLEL_INSERTED_PARALLEL SYNCCTL_SYNCM(17) /*!< all ADCs work in combined regular parallel & inserted parallel mode */
-#define ADC_ALL_REGULAL_PARALLEL_INSERTED_ROTATION SYNCCTL_SYNCM(18) /*!< all ADCs work in combined regular parallel & trigger rotation mode */
+#define SYNCCTL_SYNCM(regval) (BITS(0,4) & ((uint32_t)(regval))) /*!< write value to ADC_CTL0_SYNCM bit field */
+#define ADC_SYNC_MODE_INDEPENDENT SYNCCTL_SYNCM(0) /*!< ADC synchronization mode disabled.All the ADCs work independently */
+#define ADC_DAUL_ROUTINE_PARALLEL_INSERTED_PARALLEL SYNCCTL_SYNCM(1) /*!< ADC0 and ADC1 work in combined routine parallel & inserted parallel mode. ADC2 works independently */
+#define ADC_DAUL_ROUTINE_PARALLEL_INSERTED_ROTATION SYNCCTL_SYNCM(2) /*!< ADC0 and ADC1 work in combined routine parallel & trigger rotation mode. ADC2 works independently */
+#define ADC_DAUL_INSERTED_PARALLEL SYNCCTL_SYNCM(5) /*!< ADC0 and ADC1 work in inserted parallel mode. ADC2 works independently */
+#define ADC_DAUL_ROUTINE_PARALLEL SYNCCTL_SYNCM(6) /*!< ADC0 and ADC1 work in routine parallel mode. ADC2 works independently */
+#define ADC_DAUL_ROUTINE_FOLLOW_UP SYNCCTL_SYNCM(7) /*!< ADC0 and ADC1 work in follow-up mode. ADC2 works independently */
+#define ADC_DAUL_INSERTED_TRRIGGER_ROTATION SYNCCTL_SYNCM(9) /*!< ADC0 and ADC1 work in trigger rotation mode. ADC2 works independently */
+#define ADC_ALL_ROUTINE_PARALLEL_INSERTED_PARALLEL SYNCCTL_SYNCM(17) /*!< all ADCs work in combined routine parallel & inserted parallel mode */
+#define ADC_ALL_ROUTINE_PARALLEL_INSERTED_ROTATION SYNCCTL_SYNCM(18) /*!< all ADCs work in combined routine parallel & trigger rotation mode */
#define ADC_ALL_INSERTED_PARALLEL SYNCCTL_SYNCM(21) /*!< all ADCs work in inserted parallel mode */
-#define ADC_ALL_REGULAL_PARALLEL SYNCCTL_SYNCM(22) /*!< all ADCs work in regular parallel mode */
-#define ADC_ALL_REGULAL_FOLLOW_UP SYNCCTL_SYNCM(23) /*!< all ADCs work in follow-up mode */
+#define ADC_ALL_ROUTINE_PARALLEL SYNCCTL_SYNCM(22) /*!< all ADCs work in routine parallel mode */
+#define ADC_ALL_ROUTINE_FOLLOW_UP SYNCCTL_SYNCM(23) /*!< all ADCs work in follow-up mode */
#define ADC_ALL_INSERTED_TRRIGGER_ROTATION SYNCCTL_SYNCM(25) /*!< all ADCs work in trigger rotation mode */
/* ADC data alignment */
-#define ADC_DATAALIGN_RIGHT ((uint32_t)0x00000000U) /*!< LSB alignment */
-#define ADC_DATAALIGN_LEFT ADC_CTL1_DAL /*!< MSB alignment */
+#define ADC_DATAALIGN_RIGHT ((uint32_t)0x00000000U) /*!< LSB alignment */
+#define ADC_DATAALIGN_LEFT ADC_CTL1_DAL /*!< MSB alignment */
-/* external trigger mode for regular and inserted channel */
-#define EXTERNAL_TRIGGER_DISABLE ((uint32_t)0x00000000U) /*!< external trigger disable */
-#define EXTERNAL_TRIGGER_RISING ((uint32_t)0x00000001U) /*!< rising edge of external trigger */
-#define EXTERNAL_TRIGGER_FALLING ((uint32_t)0x00000002U) /*!< falling edge of external trigger */
-#define EXTERNAL_TRIGGER_RISING_FALLING ((uint32_t)0x00000003U) /*!< rising and falling edge of external trigger */
+/* external trigger mode for routine and inserted channel */
+#define EXTERNAL_TRIGGER_DISABLE ((uint32_t)0x00000000U) /*!< external trigger disable */
+#define EXTERNAL_TRIGGER_RISING ((uint32_t)0x00000001U) /*!< rising edge of external trigger */
+#define EXTERNAL_TRIGGER_FALLING ((uint32_t)0x00000002U) /*!< falling edge of external trigger */
+#define EXTERNAL_TRIGGER_RISING_FALLING ((uint32_t)0x00000003U) /*!< rising and falling edge of external trigger */
-/* ADC external trigger select for regular channel */
+/* ADC external trigger select for routine channel */
#define CTL1_ETSRC(regval) (BITS(24,27) & ((uint32_t)(regval) << 24))
-#define ADC_EXTTRIG_REGULAR_T0_CH0 CTL1_ETSRC(0) /*!< timer 0 CC0 event select */
-#define ADC_EXTTRIG_REGULAR_T0_CH1 CTL1_ETSRC(1) /*!< timer 0 CC1 event select */
-#define ADC_EXTTRIG_REGULAR_T0_CH2 CTL1_ETSRC(2) /*!< timer 0 CC2 event select */
-#define ADC_EXTTRIG_REGULAR_T1_CH1 CTL1_ETSRC(3) /*!< timer 1 CC1 event select */
-#define ADC_EXTTRIG_REGULAR_T1_CH2 CTL1_ETSRC(4) /*!< timer 1 CC2 event select */
-#define ADC_EXTTRIG_REGULAR_T1_CH3 CTL1_ETSRC(5) /*!< timer 1 CC3 event select */
-#define ADC_EXTTRIG_REGULAR_T1_TRGO CTL1_ETSRC(6) /*!< timer 1 TRGO event select */
-#define ADC_EXTTRIG_REGULAR_T2_CH0 CTL1_ETSRC(7) /*!< timer 2 CC0 event select */
-#define ADC_EXTTRIG_REGULAR_T2_TRGO CTL1_ETSRC(8) /*!< timer 2 TRGO event select */
-#define ADC_EXTTRIG_REGULAR_T3_CH3 CTL1_ETSRC(9) /*!< timer 3 CC3 event select */
-#define ADC_EXTTRIG_REGULAR_T4_CH0 CTL1_ETSRC(10) /*!< timer 4 CC0 event select */
-#define ADC_EXTTRIG_REGULAR_T4_CH1 CTL1_ETSRC(11) /*!< timer 4 CC1 event select */
-#define ADC_EXTTRIG_REGULAR_T4_CH2 CTL1_ETSRC(12) /*!< timer 4 CC2 event select */
-#define ADC_EXTTRIG_REGULAR_T7_CH0 CTL1_ETSRC(13) /*!< timer 7 CC0 event select */
-#define ADC_EXTTRIG_REGULAR_T7_TRGO CTL1_ETSRC(14) /*!< timer 7 TRGO event select */
-#define ADC_EXTTRIG_REGULAR_EXTI_11 CTL1_ETSRC(15) /*!< extiline 11 select */
+#define ADC_EXTTRIG_ROUTINE_T0_CH0 CTL1_ETSRC(0) /*!< timer 0 CC0 event select */
+#define ADC_EXTTRIG_ROUTINE_T0_CH1 CTL1_ETSRC(1) /*!< timer 0 CC1 event select */
+#define ADC_EXTTRIG_ROUTINE_T0_CH2 CTL1_ETSRC(2) /*!< timer 0 CC2 event select */
+#define ADC_EXTTRIG_ROUTINE_T1_CH1 CTL1_ETSRC(3) /*!< timer 1 CC1 event select */
+#define ADC_EXTTRIG_ROUTINE_T1_CH2 CTL1_ETSRC(4) /*!< timer 1 CC2 event select */
+#define ADC_EXTTRIG_ROUTINE_T1_CH3 CTL1_ETSRC(5) /*!< timer 1 CC3 event select */
+#define ADC_EXTTRIG_ROUTINE_T1_TRGO CTL1_ETSRC(6) /*!< timer 1 TRGO event select */
+#define ADC_EXTTRIG_ROUTINE_T2_CH0 CTL1_ETSRC(7) /*!< timer 2 CC0 event select */
+#define ADC_EXTTRIG_ROUTINE_T2_TRGO CTL1_ETSRC(8) /*!< timer 2 TRGO event select */
+#define ADC_EXTTRIG_ROUTINE_T3_CH3 CTL1_ETSRC(9) /*!< timer 3 CC3 event select */
+#define ADC_EXTTRIG_ROUTINE_T4_CH0 CTL1_ETSRC(10) /*!< timer 4 CC0 event select */
+#define ADC_EXTTRIG_ROUTINE_T4_CH1 CTL1_ETSRC(11) /*!< timer 4 CC1 event select */
+#define ADC_EXTTRIG_ROUTINE_T4_CH2 CTL1_ETSRC(12) /*!< timer 4 CC2 event select */
+#define ADC_EXTTRIG_ROUTINE_T7_CH0 CTL1_ETSRC(13) /*!< timer 7 CC0 event select */
+#define ADC_EXTTRIG_ROUTINE_T7_TRGO CTL1_ETSRC(14) /*!< timer 7 TRGO event select */
+#define ADC_EXTTRIG_ROUTINE_EXTI_11 CTL1_ETSRC(15) /*!< extiline 11 select */
/* ADC external trigger select for inserted channel */
#define CTL1_ETSIC(regval) (BITS(16,19) & ((uint32_t)(regval) << 16))
-#define ADC_EXTTRIG_INSERTED_T0_CH3 CTL1_ETSIC(0) /*!< timer0 capture compare 3 */
-#define ADC_EXTTRIG_INSERTED_T0_TRGO CTL1_ETSIC(1) /*!< timer0 TRGO event */
-#define ADC_EXTTRIG_INSERTED_T1_CH0 CTL1_ETSIC(2) /*!< timer1 capture compare 0 */
-#define ADC_EXTTRIG_INSERTED_T1_TRGO CTL1_ETSIC(3) /*!< timer1 TRGO event */
-#define ADC_EXTTRIG_INSERTED_T2_CH1 CTL1_ETSIC(4) /*!< timer2 capture compare 1 */
-#define ADC_EXTTRIG_INSERTED_T2_CH3 CTL1_ETSIC(5) /*!< timer2 capture compare 3 */
-#define ADC_EXTTRIG_INSERTED_T3_CH0 CTL1_ETSIC(6) /*!< timer3 capture compare 0 */
-#define ADC_EXTTRIG_INSERTED_T3_CH1 CTL1_ETSIC(7) /*!< timer3 capture compare 1 */
-#define ADC_EXTTRIG_INSERTED_T3_CH2 CTL1_ETSIC(8) /*!< timer3 capture compare 2 */
-#define ADC_EXTTRIG_INSERTED_T3_TRGO CTL1_ETSIC(9) /*!< timer3 capture compare TRGO */
-#define ADC_EXTTRIG_INSERTED_T4_CH3 CTL1_ETSIC(10) /*!< timer4 capture compare 3 */
-#define ADC_EXTTRIG_INSERTED_T4_TRGO CTL1_ETSIC(11) /*!< timer4 capture compare TRGO */
-#define ADC_EXTTRIG_INSERTED_T7_CH1 CTL1_ETSIC(12) /*!< timer7 capture compare 1 */
-#define ADC_EXTTRIG_INSERTED_T7_CH2 CTL1_ETSIC(13) /*!< timer7 capture compare 2 */
-#define ADC_EXTTRIG_INSERTED_T7_CH3 CTL1_ETSIC(14) /*!< timer7 capture compare 3 */
-#define ADC_EXTTRIG_INSERTED_EXTI_15 CTL1_ETSIC(15) /*!< external interrupt line 15 */
+#define ADC_EXTTRIG_INSERTED_T0_CH3 CTL1_ETSIC(0) /*!< timer0 capture compare 3 */
+#define ADC_EXTTRIG_INSERTED_T0_TRGO CTL1_ETSIC(1) /*!< timer0 TRGO event */
+#define ADC_EXTTRIG_INSERTED_T1_CH0 CTL1_ETSIC(2) /*!< timer1 capture compare 0 */
+#define ADC_EXTTRIG_INSERTED_T1_TRGO CTL1_ETSIC(3) /*!< timer1 TRGO event */
+#define ADC_EXTTRIG_INSERTED_T2_CH1 CTL1_ETSIC(4) /*!< timer2 capture compare 1 */
+#define ADC_EXTTRIG_INSERTED_T2_CH3 CTL1_ETSIC(5) /*!< timer2 capture compare 3 */
+#define ADC_EXTTRIG_INSERTED_T3_CH0 CTL1_ETSIC(6) /*!< timer3 capture compare 0 */
+#define ADC_EXTTRIG_INSERTED_T3_CH1 CTL1_ETSIC(7) /*!< timer3 capture compare 1 */
+#define ADC_EXTTRIG_INSERTED_T3_CH2 CTL1_ETSIC(8) /*!< timer3 capture compare 2 */
+#define ADC_EXTTRIG_INSERTED_T3_TRGO CTL1_ETSIC(9) /*!< timer3 capture compare TRGO */
+#define ADC_EXTTRIG_INSERTED_T4_CH3 CTL1_ETSIC(10) /*!< timer4 capture compare 3 */
+#define ADC_EXTTRIG_INSERTED_T4_TRGO CTL1_ETSIC(11) /*!< timer4 capture compare TRGO */
+#define ADC_EXTTRIG_INSERTED_T7_CH1 CTL1_ETSIC(12) /*!< timer7 capture compare 1 */
+#define ADC_EXTTRIG_INSERTED_T7_CH2 CTL1_ETSIC(13) /*!< timer7 capture compare 2 */
+#define ADC_EXTTRIG_INSERTED_T7_CH3 CTL1_ETSIC(14) /*!< timer7 capture compare 3 */
+#define ADC_EXTTRIG_INSERTED_EXTI_15 CTL1_ETSIC(15) /*!< external interrupt line 15 */
/* ADC channel sample time */
-#define SAMPTX_SPT(regval) (BITS(0,2) & ((uint32_t)(regval) << 0)) /*!< write value to ADC_SAMPTX_SPT bit field */
-#define ADC_SAMPLETIME_3 SAMPTX_SPT(0) /*!< 3 sampling cycles */
-#define ADC_SAMPLETIME_15 SAMPTX_SPT(1) /*!< 15 sampling cycles */
-#define ADC_SAMPLETIME_28 SAMPTX_SPT(2) /*!< 28 sampling cycles */
-#define ADC_SAMPLETIME_56 SAMPTX_SPT(3) /*!< 56 sampling cycles */
-#define ADC_SAMPLETIME_84 SAMPTX_SPT(4) /*!< 84 sampling cycles */
-#define ADC_SAMPLETIME_112 SAMPTX_SPT(5) /*!< 112 sampling cycles */
-#define ADC_SAMPLETIME_144 SAMPTX_SPT(6) /*!< 144 sampling cycles */
-#define ADC_SAMPLETIME_480 SAMPTX_SPT(7) /*!< 480 sampling cycles */
+#define SAMPTX_SPT(regval) (BITS(0,2) & ((uint32_t)(regval) << 0)) /*!< write value to ADC_SAMPTX_SPT bit field */
+#define ADC_SAMPLETIME_3 SAMPTX_SPT(0) /*!< 3 sampling cycles */
+#define ADC_SAMPLETIME_15 SAMPTX_SPT(1) /*!< 15 sampling cycles */
+#define ADC_SAMPLETIME_28 SAMPTX_SPT(2) /*!< 28 sampling cycles */
+#define ADC_SAMPLETIME_56 SAMPTX_SPT(3) /*!< 56 sampling cycles */
+#define ADC_SAMPLETIME_84 SAMPTX_SPT(4) /*!< 84 sampling cycles */
+#define ADC_SAMPLETIME_112 SAMPTX_SPT(5) /*!< 112 sampling cycles */
+#define ADC_SAMPLETIME_144 SAMPTX_SPT(6) /*!< 144 sampling cycles */
+#define ADC_SAMPLETIME_480 SAMPTX_SPT(7) /*!< 480 sampling cycles */
/* adc_ioffx register value */
-#define IOFFX_IOFF(regval) (BITS(0,11) & ((uint32_t)(regval) << 0)) /*!< write value to ADC_IOFFX_IOFF bit field */
+#define IOFFX_IOFF(regval) (BITS(0,11) & ((uint32_t)(regval) << 0)) /*!< write value to ADC_IOFFX_IOFF bit field */
/* adc_wdht register value */
-#define WDHT_WDHT(regval) (BITS(0,11) & ((uint32_t)(regval) << 0)) /*!< write value to ADC_WDHT_WDHT bit field */
+#define WDHT_WDHT(regval) (BITS(0,11) & ((uint32_t)(regval) << 0)) /*!< write value to ADC_WDHT_WDHT bit field */
/* adc_wdlt register value */
-#define WDLT_WDLT(regval) (BITS(0,11) & ((uint32_t)(regval) << 0)) /*!< write value to ADC_WDLT_WDLT bit field */
+#define WDLT_WDLT(regval) (BITS(0,11) & ((uint32_t)(regval) << 0)) /*!< write value to ADC_WDLT_WDLT bit field */
/* adc_rsqx register value */
-#define RSQ0_RL(regval) (BITS(20,23) & ((uint32_t)(regval) << 20)) /*!< write value to ADC_RSQ0_RL bit field */
+#define RSQ0_RL(regval) (BITS(20,23) & ((uint32_t)(regval) << 20)) /*!< write value to ADC_RSQ0_RL bit field */
/* adc_isq register value */
-#define ISQ_IL(regval) (BITS(20,21) & ((uint32_t)(regval) << 20)) /*!< write value to ADC_ISQ_IL bit field */
+#define ISQ_IL(regval) (BITS(20,21) & ((uint32_t)(regval) << 20)) /*!< write value to ADC_ISQ_IL bit field */
/* adc_ovsampctl register value */
/* ADC resolution */
-#define CTL0_DRES(regval) (BITS(24,25) & ((uint32_t)(regval) << 24)) /*!< write value to ADC_CTL0_DRES bit field */
-#define ADC_RESOLUTION_12B CTL0_DRES(0) /*!< 12-bit ADC resolution */
-#define ADC_RESOLUTION_10B CTL0_DRES(1) /*!< 10-bit ADC resolution */
-#define ADC_RESOLUTION_8B CTL0_DRES(2) /*!< 8-bit ADC resolution */
-#define ADC_RESOLUTION_6B CTL0_DRES(3) /*!< 6-bit ADC resolution */
+#define CTL0_DRES(regval) (BITS(24,25) & ((uint32_t)(regval) << 24)) /*!< write value to ADC_CTL0_DRES bit field */
+#define ADC_RESOLUTION_12B CTL0_DRES(0) /*!< 12-bit ADC resolution */
+#define ADC_RESOLUTION_10B CTL0_DRES(1) /*!< 10-bit ADC resolution */
+#define ADC_RESOLUTION_8B CTL0_DRES(2) /*!< 8-bit ADC resolution */
+#define ADC_RESOLUTION_6B CTL0_DRES(3) /*!< 6-bit ADC resolution */
/* oversampling shift */
-#define OVSAMPCTL_OVSS(regval) (BITS(5,8) & ((uint32_t)(regval) << 5)) /*!< write value to ADC_OVSAMPCTL_OVSS bit field */
-#define ADC_OVERSAMPLING_SHIFT_NONE OVSAMPCTL_OVSS(0) /*!< no oversampling shift */
-#define ADC_OVERSAMPLING_SHIFT_1B OVSAMPCTL_OVSS(1) /*!< 1-bit oversampling shift */
-#define ADC_OVERSAMPLING_SHIFT_2B OVSAMPCTL_OVSS(2) /*!< 2-bit oversampling shift */
-#define ADC_OVERSAMPLING_SHIFT_3B OVSAMPCTL_OVSS(3) /*!< 3-bit oversampling shift */
-#define ADC_OVERSAMPLING_SHIFT_4B OVSAMPCTL_OVSS(4) /*!< 4-bit oversampling shift */
-#define ADC_OVERSAMPLING_SHIFT_5B OVSAMPCTL_OVSS(5) /*!< 5-bit oversampling shift */
-#define ADC_OVERSAMPLING_SHIFT_6B OVSAMPCTL_OVSS(6) /*!< 6-bit oversampling shift */
-#define ADC_OVERSAMPLING_SHIFT_7B OVSAMPCTL_OVSS(7) /*!< 7-bit oversampling shift */
-#define ADC_OVERSAMPLING_SHIFT_8B OVSAMPCTL_OVSS(8) /*!< 8-bit oversampling shift */
+#define OVSAMPCTL_OVSS(regval) (BITS(5,8) & ((uint32_t)(regval) << 5)) /*!< write value to ADC_OVSAMPCTL_OVSS bit field */
+#define ADC_OVERSAMPLING_SHIFT_NONE OVSAMPCTL_OVSS(0) /*!< no oversampling shift */
+#define ADC_OVERSAMPLING_SHIFT_1B OVSAMPCTL_OVSS(1) /*!< 1-bit oversampling shift */
+#define ADC_OVERSAMPLING_SHIFT_2B OVSAMPCTL_OVSS(2) /*!< 2-bit oversampling shift */
+#define ADC_OVERSAMPLING_SHIFT_3B OVSAMPCTL_OVSS(3) /*!< 3-bit oversampling shift */
+#define ADC_OVERSAMPLING_SHIFT_4B OVSAMPCTL_OVSS(4) /*!< 4-bit oversampling shift */
+#define ADC_OVERSAMPLING_SHIFT_5B OVSAMPCTL_OVSS(5) /*!< 5-bit oversampling shift */
+#define ADC_OVERSAMPLING_SHIFT_6B OVSAMPCTL_OVSS(6) /*!< 6-bit oversampling shift */
+#define ADC_OVERSAMPLING_SHIFT_7B OVSAMPCTL_OVSS(7) /*!< 7-bit oversampling shift */
+#define ADC_OVERSAMPLING_SHIFT_8B OVSAMPCTL_OVSS(8) /*!< 8-bit oversampling shift */
/* oversampling ratio */
-#define OVSAMPCTL_OVSR(regval) (BITS(2,4) & ((uint32_t)(regval) << 2)) /*!< write value to ADC_OVSAMPCTL_OVSR bit field */
-#define ADC_OVERSAMPLING_RATIO_MUL2 OVSAMPCTL_OVSR(0) /*!< oversampling ratio multiple 2 */
-#define ADC_OVERSAMPLING_RATIO_MUL4 OVSAMPCTL_OVSR(1) /*!< oversampling ratio multiple 4 */
-#define ADC_OVERSAMPLING_RATIO_MUL8 OVSAMPCTL_OVSR(2) /*!< oversampling ratio multiple 8 */
-#define ADC_OVERSAMPLING_RATIO_MUL16 OVSAMPCTL_OVSR(3) /*!< oversampling ratio multiple 16 */
-#define ADC_OVERSAMPLING_RATIO_MUL32 OVSAMPCTL_OVSR(4) /*!< oversampling ratio multiple 32 */
-#define ADC_OVERSAMPLING_RATIO_MUL64 OVSAMPCTL_OVSR(5) /*!< oversampling ratio multiple 64 */
-#define ADC_OVERSAMPLING_RATIO_MUL128 OVSAMPCTL_OVSR(6) /*!< oversampling ratio multiple 128 */
-#define ADC_OVERSAMPLING_RATIO_MUL256 OVSAMPCTL_OVSR(7) /*!< oversampling ratio multiple 256 */
+#define OVSAMPCTL_OVSR(regval) (BITS(2,4) & ((uint32_t)(regval) << 2)) /*!< write value to ADC_OVSAMPCTL_OVSR bit field */
+#define ADC_OVERSAMPLING_RATIO_MUL2 OVSAMPCTL_OVSR(0) /*!< oversampling ratio multiple 2 */
+#define ADC_OVERSAMPLING_RATIO_MUL4 OVSAMPCTL_OVSR(1) /*!< oversampling ratio multiple 4 */
+#define ADC_OVERSAMPLING_RATIO_MUL8 OVSAMPCTL_OVSR(2) /*!< oversampling ratio multiple 8 */
+#define ADC_OVERSAMPLING_RATIO_MUL16 OVSAMPCTL_OVSR(3) /*!< oversampling ratio multiple 16 */
+#define ADC_OVERSAMPLING_RATIO_MUL32 OVSAMPCTL_OVSR(4) /*!< oversampling ratio multiple 32 */
+#define ADC_OVERSAMPLING_RATIO_MUL64 OVSAMPCTL_OVSR(5) /*!< oversampling ratio multiple 64 */
+#define ADC_OVERSAMPLING_RATIO_MUL128 OVSAMPCTL_OVSR(6) /*!< oversampling ratio multiple 128 */
+#define ADC_OVERSAMPLING_RATIO_MUL256 OVSAMPCTL_OVSR(7) /*!< oversampling ratio multiple 256 */
-/* triggered Oversampling */
-#define ADC_OVERSAMPLING_ALL_CONVERT ((uint32_t)0x00000000U) /*!< all oversampled conversions for a channel are done consecutively after a trigger */
-#define ADC_OVERSAMPLING_ONE_CONVERT ADC_OVSAMPCTL_TOVS /*!< each oversampled conversion for a channel needs a trigger */
+/* triggered oversampling */
+#define ADC_OVERSAMPLING_ALL_CONVERT ((uint32_t)0x00000000U) /*!< all oversampled conversions for a channel are done consecutively after a trigger */
+#define ADC_OVERSAMPLING_ONE_CONVERT ADC_OVSAMPCTL_TOVS /*!< each oversampled conversion for a channel needs a trigger */
-/* ADC channel group definitions */
-#define ADC_REGULAR_CHANNEL ((uint8_t)0x01U) /*!< adc regular channel group */
-#define ADC_INSERTED_CHANNEL ((uint8_t)0x02U) /*!< adc inserted channel group */
-#define ADC_REGULAR_INSERTED_CHANNEL ((uint8_t)0x03U) /*!< both regular and inserted channel group */
-#define ADC_CHANNEL_DISCON_DISABLE ((uint8_t)0x04U) /*!< disable discontinuous mode of regular & inserted channel */
+/* ADC channel sequence definitions */
+#define ADC_ROUTINE_CHANNEL ((uint8_t)0x01U) /*!< adc routine sequence */
+#define ADC_INSERTED_CHANNEL ((uint8_t)0x02U) /*!< adc inserted sequence */
+#define ADC_ROUTINE_INSERTED_CHANNEL ((uint8_t)0x03U) /*!< both routine and inserted sequence */
+#define ADC_CHANNEL_DISCON_DISABLE ((uint8_t)0x04U) /*!< disable discontinuous mode of routine & inserted sequence */
/* ADC inserted channel definitions */
-#define ADC_INSERTED_CHANNEL_0 ((uint8_t)0x00U) /*!< adc inserted channel 0 */
-#define ADC_INSERTED_CHANNEL_1 ((uint8_t)0x01U) /*!< adc inserted channel 1 */
-#define ADC_INSERTED_CHANNEL_2 ((uint8_t)0x02U) /*!< adc inserted channel 2 */
-#define ADC_INSERTED_CHANNEL_3 ((uint8_t)0x03U) /*!< adc inserted channel 3 */
+#define ADC_INSERTED_CHANNEL_0 ((uint8_t)0x00U) /*!< adc inserted channel 0 */
+#define ADC_INSERTED_CHANNEL_1 ((uint8_t)0x01U) /*!< adc inserted channel 1 */
+#define ADC_INSERTED_CHANNEL_2 ((uint8_t)0x02U) /*!< adc inserted channel 2 */
+#define ADC_INSERTED_CHANNEL_3 ((uint8_t)0x03U) /*!< adc inserted channel 3 */
/* ADC channel definitions */
-#define ADC_CHANNEL_0 ((uint8_t)0x00U) /*!< ADC channel 0 */
-#define ADC_CHANNEL_1 ((uint8_t)0x01U) /*!< ADC channel 1 */
-#define ADC_CHANNEL_2 ((uint8_t)0x02U) /*!< ADC channel 2 */
-#define ADC_CHANNEL_3 ((uint8_t)0x03U) /*!< ADC channel 3 */
-#define ADC_CHANNEL_4 ((uint8_t)0x04U) /*!< ADC channel 4 */
-#define ADC_CHANNEL_5 ((uint8_t)0x05U) /*!< ADC channel 5 */
-#define ADC_CHANNEL_6 ((uint8_t)0x06U) /*!< ADC channel 6 */
-#define ADC_CHANNEL_7 ((uint8_t)0x07U) /*!< ADC channel 7 */
-#define ADC_CHANNEL_8 ((uint8_t)0x08U) /*!< ADC channel 8 */
-#define ADC_CHANNEL_9 ((uint8_t)0x09U) /*!< ADC channel 9 */
-#define ADC_CHANNEL_10 ((uint8_t)0x0AU) /*!< ADC channel 10 */
-#define ADC_CHANNEL_11 ((uint8_t)0x0BU) /*!< ADC channel 11 */
-#define ADC_CHANNEL_12 ((uint8_t)0x0CU) /*!< ADC channel 12 */
-#define ADC_CHANNEL_13 ((uint8_t)0x0DU) /*!< ADC channel 13 */
-#define ADC_CHANNEL_14 ((uint8_t)0x0EU) /*!< ADC channel 14 */
-#define ADC_CHANNEL_15 ((uint8_t)0x0FU) /*!< ADC channel 15 */
-#define ADC_CHANNEL_16 ((uint8_t)0x10U) /*!< ADC channel 16 */
-#define ADC_CHANNEL_17 ((uint8_t)0x11U) /*!< ADC channel 17 */
-#define ADC_CHANNEL_18 ((uint8_t)0x12U) /*!< ADC channel 18 */
+#define ADC_CHANNEL_0 ((uint8_t)0x00U) /*!< ADC channel 0 */
+#define ADC_CHANNEL_1 ((uint8_t)0x01U) /*!< ADC channel 1 */
+#define ADC_CHANNEL_2 ((uint8_t)0x02U) /*!< ADC channel 2 */
+#define ADC_CHANNEL_3 ((uint8_t)0x03U) /*!< ADC channel 3 */
+#define ADC_CHANNEL_4 ((uint8_t)0x04U) /*!< ADC channel 4 */
+#define ADC_CHANNEL_5 ((uint8_t)0x05U) /*!< ADC channel 5 */
+#define ADC_CHANNEL_6 ((uint8_t)0x06U) /*!< ADC channel 6 */
+#define ADC_CHANNEL_7 ((uint8_t)0x07U) /*!< ADC channel 7 */
+#define ADC_CHANNEL_8 ((uint8_t)0x08U) /*!< ADC channel 8 */
+#define ADC_CHANNEL_9 ((uint8_t)0x09U) /*!< ADC channel 9 */
+#define ADC_CHANNEL_10 ((uint8_t)0x0AU) /*!< ADC channel 10 */
+#define ADC_CHANNEL_11 ((uint8_t)0x0BU) /*!< ADC channel 11 */
+#define ADC_CHANNEL_12 ((uint8_t)0x0CU) /*!< ADC channel 12 */
+#define ADC_CHANNEL_13 ((uint8_t)0x0DU) /*!< ADC channel 13 */
+#define ADC_CHANNEL_14 ((uint8_t)0x0EU) /*!< ADC channel 14 */
+#define ADC_CHANNEL_15 ((uint8_t)0x0FU) /*!< ADC channel 15 */
+#define ADC_CHANNEL_16 ((uint8_t)0x10U) /*!< ADC channel 16 */
+#define ADC_CHANNEL_17 ((uint8_t)0x11U) /*!< ADC channel 17 */
+#define ADC_CHANNEL_18 ((uint8_t)0x12U) /*!< ADC channel 18 */
/* ADC interrupt flag */
-#define ADC_INT_WDE ADC_CTL0_WDEIE /*!< analog watchdog event interrupt */
-#define ADC_INT_EOC ADC_CTL0_EOCIE /*!< end of group conversion interrupt */
-#define ADC_INT_EOIC ADC_CTL0_EOICIE /*!< end of inserted group conversion interrupt */
-#define ADC_INT_ROVF ADC_CTL0_ROVFIE /*!< regular data register overflow */
+#define ADC_INT_WDE ADC_CTL0_WDEIE /*!< analog watchdog event interrupt */
+#define ADC_INT_EOC ADC_CTL0_EOCIE /*!< end of sequence conversion interrupt */
+#define ADC_INT_EOIC ADC_CTL0_EOICIE /*!< end of inserted sequence conversion interrupt */
+#define ADC_INT_ROVF ADC_CTL0_ROVFIE /*!< routine data register overflow */
/* ADC interrupt flag */
-#define ADC_INT_FLAG_WDE ADC_STAT_WDE /*!< analog watchdog event interrupt */
-#define ADC_INT_FLAG_EOC ADC_STAT_EOC /*!< end of group conversion interrupt */
-#define ADC_INT_FLAG_EOIC ADC_STAT_EOIC /*!< end of inserted group conversion interrupt */
-#define ADC_INT_FLAG_ROVF ADC_STAT_ROVF /*!< regular data register overflow */
+#define ADC_INT_FLAG_WDE ADC_STAT_WDE /*!< analog watchdog event interrupt */
+#define ADC_INT_FLAG_EOC ADC_STAT_EOC /*!< end of sequence conversion interrupt */
+#define ADC_INT_FLAG_EOIC ADC_STAT_EOIC /*!< end of inserted sequence conversion interrupt */
+#define ADC_INT_FLAG_ROVF ADC_STAT_ROVF /*!< routine data register overflow */
/* configure the ADC clock for all the ADCs */
#define SYNCCTL_ADCCK(regval) (BITS(16,18) & ((uint32_t)(regval) << 16))
-#define ADC_ADCCK_PCLK2_DIV2 SYNCCTL_ADCCK(0) /*!< PCLK2 div2 */
-#define ADC_ADCCK_PCLK2_DIV4 SYNCCTL_ADCCK(1) /*!< PCLK2 div4 */
-#define ADC_ADCCK_PCLK2_DIV6 SYNCCTL_ADCCK(2) /*!< PCLK2 div6 */
-#define ADC_ADCCK_PCLK2_DIV8 SYNCCTL_ADCCK(3) /*!< PCLK2 div8 */
-#define ADC_ADCCK_HCLK_DIV5 SYNCCTL_ADCCK(4) /*!< HCLK div5 */
-#define ADC_ADCCK_HCLK_DIV6 SYNCCTL_ADCCK(5) /*!< HCLK div6 */
-#define ADC_ADCCK_HCLK_DIV10 SYNCCTL_ADCCK(6) /*!< HCLK div10 */
-#define ADC_ADCCK_HCLK_DIV20 SYNCCTL_ADCCK(7) /*!< HCLK div20 */
+#define ADC_ADCCK_PCLK2_DIV2 SYNCCTL_ADCCK(0) /*!< PCLK2 div2 */
+#define ADC_ADCCK_PCLK2_DIV4 SYNCCTL_ADCCK(1) /*!< PCLK2 div4 */
+#define ADC_ADCCK_PCLK2_DIV6 SYNCCTL_ADCCK(2) /*!< PCLK2 div6 */
+#define ADC_ADCCK_PCLK2_DIV8 SYNCCTL_ADCCK(3) /*!< PCLK2 div8 */
+#define ADC_ADCCK_HCLK_DIV5 SYNCCTL_ADCCK(4) /*!< HCLK div5 */
+#define ADC_ADCCK_HCLK_DIV6 SYNCCTL_ADCCK(5) /*!< HCLK div6 */
+#define ADC_ADCCK_HCLK_DIV10 SYNCCTL_ADCCK(6) /*!< HCLK div10 */
+#define ADC_ADCCK_HCLK_DIV20 SYNCCTL_ADCCK(7) /*!< HCLK div20 */
/* ADC synchronization delay */
-#define ADC_SYNC_DELAY_5CYCLE ((uint32_t)0x00000000U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 5 ADC clock cycles. */
-#define ADC_SYNC_DELAY_6CYCLE ((uint32_t)0x00000100U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 6 ADC clock cycles. */
-#define ADC_SYNC_DELAY_7CYCLE ((uint32_t)0x00000200U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 7 ADC clock cycles. */
-#define ADC_SYNC_DELAY_8CYCLE ((uint32_t)0x00000300U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 8 ADC clock cycles. */
-#define ADC_SYNC_DELAY_9CYCLE ((uint32_t)0x00000400U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 9 ADC clock cycles. */
-#define ADC_SYNC_DELAY_10CYCLE ((uint32_t)0x00000500U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 10 ADC clock cycles. */
-#define ADC_SYNC_DELAY_11CYCLE ((uint32_t)0x00000600U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 11 ADC clock cycles. */
-#define ADC_SYNC_DELAY_12CYCLE ((uint32_t)0x00000700U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 12 ADC clock cycles. */
-#define ADC_SYNC_DELAY_13CYCLE ((uint32_t)0x00000800U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 13 ADC clock cycles. */
-#define ADC_SYNC_DELAY_14CYCLE ((uint32_t)0x00000900U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 14 ADC clock cycles. */
-#define ADC_SYNC_DELAY_15CYCLE ((uint32_t)0x00000A00U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 15 ADC clock cycles. */
-#define ADC_SYNC_DELAY_16CYCLE ((uint32_t)0x00000B00U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 16 ADC clock cycles. */
-#define ADC_SYNC_DELAY_17CYCLE ((uint32_t)0x00000C00U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 17 ADC clock cycles. */
-#define ADC_SYNC_DELAY_18CYCLE ((uint32_t)0x00000D00U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 18 ADC clock cycles. */
-#define ADC_SYNC_DELAY_19CYCLE ((uint32_t)0x00000E00U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 19 ADC clock cycles. */
-#define ADC_SYNC_DELAY_20CYCLE ((uint32_t)0x00000F00U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 20 ADC clock cycles. */
+#define ADC_SYNC_DELAY_5CYCLE ((uint32_t)0x00000000U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 5 ADC clock cycles. */
+#define ADC_SYNC_DELAY_6CYCLE ((uint32_t)0x00000100U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 6 ADC clock cycles. */
+#define ADC_SYNC_DELAY_7CYCLE ((uint32_t)0x00000200U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 7 ADC clock cycles. */
+#define ADC_SYNC_DELAY_8CYCLE ((uint32_t)0x00000300U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 8 ADC clock cycles. */
+#define ADC_SYNC_DELAY_9CYCLE ((uint32_t)0x00000400U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 9 ADC clock cycles. */
+#define ADC_SYNC_DELAY_10CYCLE ((uint32_t)0x00000500U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 10 ADC clock cycles. */
+#define ADC_SYNC_DELAY_11CYCLE ((uint32_t)0x00000600U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 11 ADC clock cycles. */
+#define ADC_SYNC_DELAY_12CYCLE ((uint32_t)0x00000700U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 12 ADC clock cycles. */
+#define ADC_SYNC_DELAY_13CYCLE ((uint32_t)0x00000800U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 13 ADC clock cycles. */
+#define ADC_SYNC_DELAY_14CYCLE ((uint32_t)0x00000900U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 14 ADC clock cycles. */
+#define ADC_SYNC_DELAY_15CYCLE ((uint32_t)0x00000A00U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 15 ADC clock cycles. */
+#define ADC_SYNC_DELAY_16CYCLE ((uint32_t)0x00000B00U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 16 ADC clock cycles. */
+#define ADC_SYNC_DELAY_17CYCLE ((uint32_t)0x00000C00U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 17 ADC clock cycles. */
+#define ADC_SYNC_DELAY_18CYCLE ((uint32_t)0x00000D00U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 18 ADC clock cycles. */
+#define ADC_SYNC_DELAY_19CYCLE ((uint32_t)0x00000E00U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 19 ADC clock cycles. */
+#define ADC_SYNC_DELAY_20CYCLE ((uint32_t)0x00000F00U) /*!< the delay between 2 sampling phases in ADC synchronization modes to 20 ADC clock cycles. */
/* ADC synchronization DMA mode selection */
-#define ADC_SYNC_DMA_DISABLE ((uint32_t)0x00000000U) /*!< ADC synchronization DMA disabled */
-#define ADC_SYNC_DMA_MODE0 ((uint32_t)0x00004000U) /*!< ADC synchronization DMA mode 0 */
-#define ADC_SYNC_DMA_MODE1 ((uint32_t)0x00008000U) /*!< ADC synchronization DMA mode 1 */
+#define ADC_SYNC_DMA_DISABLE ((uint32_t)0x00000000U) /*!< ADC synchronization DMA disabled */
+#define ADC_SYNC_DMA_MODE0 ((uint32_t)0x00004000U) /*!< ADC synchronization DMA mode 0 */
+#define ADC_SYNC_DMA_MODE1 ((uint32_t)0x00008000U) /*!< ADC synchronization DMA mode 1 */
/* end of conversion mode */
-#define ADC_EOC_SET_SEQUENCE ((uint8_t)0x00U) /*!< only at the end of a sequence of regular conversions, the EOC bit is set */
-#define ADC_EOC_SET_CONVERSION ((uint8_t)0x01U) /*!< at the end of each regular conversion, the EOC bit is set */
+#define ADC_EOC_SET_SEQUENCE ((uint8_t)0x00U) /*!< only at the end of a sequence of routine conversions, the EOC bit is set */
+#define ADC_EOC_SET_CONVERSION ((uint8_t)0x01U) /*!< at the end of each routine conversion, the EOC bit is set */
/* function declarations */
/* initialization config */
@@ -437,35 +438,35 @@ void adc_oversample_mode_disable(uint32_t adc_periph);
void adc_dma_mode_enable(uint32_t adc_periph);
/* disable DMA request */
void adc_dma_mode_disable(uint32_t adc_periph);
-/* when DMA=1, the DMA engine issues a request at end of each regular conversion */
+/* when DMA=1, the DMA engine issues a request at end of each routine conversion */
void adc_dma_request_after_last_enable(uint32_t adc_periph);
/* the DMA engine is disabled after the end of transfer signal from DMA controller is detected */
void adc_dma_request_after_last_disable(uint32_t adc_periph);
-/* regular group and inserted group config */
+/* routine sequence and inserted sequence config */
/* configure ADC discontinuous mode */
-void adc_discontinuous_mode_config(uint32_t adc_periph , uint8_t adc_channel_group , uint8_t length);
-/* configure the length of regular channel group or inserted channel group */
-void adc_channel_length_config(uint32_t adc_periph , uint8_t adc_channel_group , uint32_t length);
-/* configure ADC regular channel */
-void adc_regular_channel_config(uint32_t adc_periph , uint8_t rank , uint8_t adc_channel , uint32_t sample_time);
+void adc_discontinuous_mode_config(uint32_t adc_periph , uint8_t adc_sequence , uint8_t length);
+/* configure the length of routine sequence or inserted sequence */
+void adc_channel_length_config(uint32_t adc_periph , uint8_t adc_sequence , uint32_t length);
+/* configure ADC routine channel */
+void adc_routine_channel_config(uint32_t adc_periph , uint8_t rank , uint8_t adc_channel , uint32_t sample_time);
/* configure ADC inserted channel */
void adc_inserted_channel_config(uint32_t adc_periph , uint8_t rank , uint8_t adc_channel , uint32_t sample_time);
/* configure ADC inserted channel offset */
void adc_inserted_channel_offset_config(uint32_t adc_periph , uint8_t inserted_channel , uint16_t offset);
/* configure ADC external trigger source */
-void adc_external_trigger_source_config(uint32_t adc_periph , uint8_t adc_channel_group , uint32_t external_trigger_source);
+void adc_external_trigger_source_config(uint32_t adc_periph , uint8_t adc_sequence , uint32_t external_trigger_source);
/* enable ADC external trigger */
-void adc_external_trigger_config(uint32_t adc_periph , uint8_t adc_channel_group , uint32_t trigger_mode);
+void adc_external_trigger_config(uint32_t adc_periph , uint8_t adc_sequence , uint32_t trigger_mode);
/* enable ADC software trigger */
-void adc_software_trigger_enable(uint32_t adc_periph , uint8_t adc_channel_group);
+void adc_software_trigger_enable(uint32_t adc_periph , uint8_t adc_sequence);
/* configure end of conversion mode */
void adc_end_of_conversion_config(uint32_t adc_periph , uint8_t end_selection);
/* get channel data */
-/* read ADC regular group data register */
-uint16_t adc_regular_data_read(uint32_t adc_periph);
-/* read ADC inserted group data register */
+/* read ADC routine data register */
+uint16_t adc_routine_data_read(uint32_t adc_periph);
+/* read ADC inserted data register */
uint16_t adc_inserted_data_read(uint32_t adc_periph , uint8_t inserted_channel);
/* watchdog config */
@@ -473,10 +474,10 @@ uint16_t adc_inserted_data_read(uint32_t adc_periph , uint8_t inserted_channel);
void adc_watchdog_single_channel_disable(uint32_t adc_periph );
/* enable ADC analog watchdog single channel */
void adc_watchdog_single_channel_enable(uint32_t adc_periph , uint8_t adc_channel);
-/* configure ADC analog watchdog group channel */
-void adc_watchdog_group_channel_enable(uint32_t adc_periph , uint8_t adc_channel_group);
+/* configure ADC analog watchdog sequence */
+void adc_watchdog_sequence_channel_enable(uint32_t adc_periph , uint8_t adc_sequence);
/* disable ADC analog watchdog */
-void adc_watchdog_disable(uint32_t adc_periph , uint8_t adc_channel_group);
+void adc_watchdog_disable(uint32_t adc_periph , uint8_t adc_sequence);
/* configure ADC analog watchdog threshold */
void adc_watchdog_threshold_config(uint32_t adc_periph , uint16_t low_threshold , uint16_t high_threshold);
@@ -486,7 +487,7 @@ FlagStatus adc_flag_get(uint32_t adc_periph , uint32_t adc_flag);
/* clear the ADC flag bits */
void adc_flag_clear(uint32_t adc_periph , uint32_t adc_flag);
/* get the bit state of ADCx software start conversion */
-FlagStatus adc_regular_software_startconv_flag_get(uint32_t adc_periph);
+FlagStatus adc_routine_software_startconv_flag_get(uint32_t adc_periph);
/* get the bit state of ADCx software inserted channel start conversion */
FlagStatus adc_inserted_software_startconv_flag_get(uint32_t adc_periph);
/* get the ADC interrupt bits */
@@ -509,7 +510,7 @@ void adc_sync_dma_config(uint32_t dma_mode );
void adc_sync_dma_request_after_last_enable(void);
/* configure ADC sync DMA engine issues requests according to the SYNCDMA bits */
void adc_sync_dma_request_after_last_disable(void);
-/* read ADC sync regular data register */
-uint32_t adc_sync_regular_data_read(void);
+/* read ADC sync routine data register */
+uint32_t adc_sync_routine_data_read(void);
#endif /* GD32F4XX_ADC_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_can.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_can.h
index 7310f63a75..cff2ef7fc8 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_can.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_can.h
@@ -1,15 +1,16 @@
/*!
\file gd32f4xx_can.h
\brief definitions for the CAN
-
+
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2019-11-27, V2.0.1, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -35,105 +36,106 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
OF SUCH DAMAGE.
*/
+
#ifndef GD32F4XX_CAN_H
#define GD32F4XX_CAN_H
#include "gd32f4xx.h"
/* CAN definitions */
-#define CAN0 CAN_BASE /*!< CAN0 base address */
-#define CAN1 (CAN0 + 0x00000400U) /*!< CAN1 base address */
+#define CAN0 CAN_BASE /*!< CAN0 base address */
+#define CAN1 (CAN0 + 0x00000400U) /*!< CAN1 base address */
/* registers definitions */
-#define CAN_CTL(canx) REG32((canx) + 0x00U) /*!< CAN control register */
-#define CAN_STAT(canx) REG32((canx) + 0x04U) /*!< CAN status register */
-#define CAN_TSTAT(canx) REG32((canx) + 0x08U) /*!< CAN transmit status register*/
-#define CAN_RFIFO0(canx) REG32((canx) + 0x0CU) /*!< CAN receive FIFO0 register */
-#define CAN_RFIFO1(canx) REG32((canx) + 0x10U) /*!< CAN receive FIFO1 register */
-#define CAN_INTEN(canx) REG32((canx) + 0x14U) /*!< CAN interrupt enable register */
-#define CAN_ERR(canx) REG32((canx) + 0x18U) /*!< CAN error register */
-#define CAN_BT(canx) REG32((canx) + 0x1CU) /*!< CAN bit timing register */
-#define CAN_TMI0(canx) REG32((canx) + 0x180U) /*!< CAN transmit mailbox0 identifier register */
-#define CAN_TMP0(canx) REG32((canx) + 0x184U) /*!< CAN transmit mailbox0 property register */
-#define CAN_TMDATA00(canx) REG32((canx) + 0x188U) /*!< CAN transmit mailbox0 data0 register */
-#define CAN_TMDATA10(canx) REG32((canx) + 0x18CU) /*!< CAN transmit mailbox0 data1 register */
-#define CAN_TMI1(canx) REG32((canx) + 0x190U) /*!< CAN transmit mailbox1 identifier register */
-#define CAN_TMP1(canx) REG32((canx) + 0x194U) /*!< CAN transmit mailbox1 property register */
-#define CAN_TMDATA01(canx) REG32((canx) + 0x198U) /*!< CAN transmit mailbox1 data0 register */
-#define CAN_TMDATA11(canx) REG32((canx) + 0x19CU) /*!< CAN transmit mailbox1 data1 register */
-#define CAN_TMI2(canx) REG32((canx) + 0x1A0U) /*!< CAN transmit mailbox2 identifier register */
-#define CAN_TMP2(canx) REG32((canx) + 0x1A4U) /*!< CAN transmit mailbox2 property register */
-#define CAN_TMDATA02(canx) REG32((canx) + 0x1A8U) /*!< CAN transmit mailbox2 data0 register */
-#define CAN_TMDATA12(canx) REG32((canx) + 0x1ACU) /*!< CAN transmit mailbox2 data1 register */
-#define CAN_RFIFOMI0(canx) REG32((canx) + 0x1B0U) /*!< CAN receive FIFO0 mailbox identifier register */
-#define CAN_RFIFOMP0(canx) REG32((canx) + 0x1B4U) /*!< CAN receive FIFO0 mailbox property register */
-#define CAN_RFIFOMDATA00(canx) REG32((canx) + 0x1B8U) /*!< CAN receive FIFO0 mailbox data0 register */
-#define CAN_RFIFOMDATA10(canx) REG32((canx) + 0x1BCU) /*!< CAN receive FIFO0 mailbox data1 register */
-#define CAN_RFIFOMI1(canx) REG32((canx) + 0x1C0U) /*!< CAN receive FIFO1 mailbox identifier register */
-#define CAN_RFIFOMP1(canx) REG32((canx) + 0x1C4U) /*!< CAN receive FIFO1 mailbox property register */
-#define CAN_RFIFOMDATA01(canx) REG32((canx) + 0x1C8U) /*!< CAN receive FIFO1 mailbox data0 register */
-#define CAN_RFIFOMDATA11(canx) REG32((canx) + 0x1CCU) /*!< CAN receive FIFO1 mailbox data1 register */
-#define CAN_FCTL(canx) REG32((canx) + 0x200U) /*!< CAN filter control register */
-#define CAN_FMCFG(canx) REG32((canx) + 0x204U) /*!< CAN filter mode register */
-#define CAN_FSCFG(canx) REG32((canx) + 0x20CU) /*!< CAN filter scale register */
-#define CAN_FAFIFO(canx) REG32((canx) + 0x214U) /*!< CAN filter associated FIFO register */
-#define CAN_FW(canx) REG32((canx) + 0x21CU) /*!< CAN filter working register */
-#define CAN_F0DATA0(canx) REG32((canx) + 0x240U) /*!< CAN filter 0 data 0 register */
-#define CAN_F1DATA0(canx) REG32((canx) + 0x248U) /*!< CAN filter 1 data 0 register */
-#define CAN_F2DATA0(canx) REG32((canx) + 0x250U) /*!< CAN filter 2 data 0 register */
-#define CAN_F3DATA0(canx) REG32((canx) + 0x258U) /*!< CAN filter 3 data 0 register */
-#define CAN_F4DATA0(canx) REG32((canx) + 0x260U) /*!< CAN filter 4 data 0 register */
-#define CAN_F5DATA0(canx) REG32((canx) + 0x268U) /*!< CAN filter 5 data 0 register */
-#define CAN_F6DATA0(canx) REG32((canx) + 0x270U) /*!< CAN filter 6 data 0 register */
-#define CAN_F7DATA0(canx) REG32((canx) + 0x278U) /*!< CAN filter 7 data 0 register */
-#define CAN_F8DATA0(canx) REG32((canx) + 0x280U) /*!< CAN filter 8 data 0 register */
-#define CAN_F9DATA0(canx) REG32((canx) + 0x288U) /*!< CAN filter 9 data 0 register */
-#define CAN_F10DATA0(canx) REG32((canx) + 0x290U) /*!< CAN filter 10 data 0 register */
-#define CAN_F11DATA0(canx) REG32((canx) + 0x298U) /*!< CAN filter 11 data 0 register */
-#define CAN_F12DATA0(canx) REG32((canx) + 0x2A0U) /*!< CAN filter 12 data 0 register */
-#define CAN_F13DATA0(canx) REG32((canx) + 0x2A8U) /*!< CAN filter 13 data 0 register */
-#define CAN_F14DATA0(canx) REG32((canx) + 0x2B0U) /*!< CAN filter 14 data 0 register */
-#define CAN_F15DATA0(canx) REG32((canx) + 0x2B8U) /*!< CAN filter 15 data 0 register */
-#define CAN_F16DATA0(canx) REG32((canx) + 0x2C0U) /*!< CAN filter 16 data 0 register */
-#define CAN_F17DATA0(canx) REG32((canx) + 0x2C8U) /*!< CAN filter 17 data 0 register */
-#define CAN_F18DATA0(canx) REG32((canx) + 0x2D0U) /*!< CAN filter 18 data 0 register */
-#define CAN_F19DATA0(canx) REG32((canx) + 0x2D8U) /*!< CAN filter 19 data 0 register */
-#define CAN_F20DATA0(canx) REG32((canx) + 0x2E0U) /*!< CAN filter 20 data 0 register */
-#define CAN_F21DATA0(canx) REG32((canx) + 0x2E8U) /*!< CAN filter 21 data 0 register */
-#define CAN_F22DATA0(canx) REG32((canx) + 0x2F0U) /*!< CAN filter 22 data 0 register */
-#define CAN_F23DATA0(canx) REG32((canx) + 0x3F8U) /*!< CAN filter 23 data 0 register */
-#define CAN_F24DATA0(canx) REG32((canx) + 0x300U) /*!< CAN filter 24 data 0 register */
-#define CAN_F25DATA0(canx) REG32((canx) + 0x308U) /*!< CAN filter 25 data 0 register */
-#define CAN_F26DATA0(canx) REG32((canx) + 0x310U) /*!< CAN filter 26 data 0 register */
-#define CAN_F27DATA0(canx) REG32((canx) + 0x318U) /*!< CAN filter 27 data 0 register */
-#define CAN_F0DATA1(canx) REG32((canx) + 0x244U) /*!< CAN filter 0 data 1 register */
-#define CAN_F1DATA1(canx) REG32((canx) + 0x24CU) /*!< CAN filter 1 data 1 register */
-#define CAN_F2DATA1(canx) REG32((canx) + 0x254U) /*!< CAN filter 2 data 1 register */
-#define CAN_F3DATA1(canx) REG32((canx) + 0x25CU) /*!< CAN filter 3 data 1 register */
-#define CAN_F4DATA1(canx) REG32((canx) + 0x264U) /*!< CAN filter 4 data 1 register */
-#define CAN_F5DATA1(canx) REG32((canx) + 0x26CU) /*!< CAN filter 5 data 1 register */
-#define CAN_F6DATA1(canx) REG32((canx) + 0x274U) /*!< CAN filter 6 data 1 register */
-#define CAN_F7DATA1(canx) REG32((canx) + 0x27CU) /*!< CAN filter 7 data 1 register */
-#define CAN_F8DATA1(canx) REG32((canx) + 0x284U) /*!< CAN filter 8 data 1 register */
-#define CAN_F9DATA1(canx) REG32((canx) + 0x28CU) /*!< CAN filter 9 data 1 register */
-#define CAN_F10DATA1(canx) REG32((canx) + 0x294U) /*!< CAN filter 10 data 1 register */
-#define CAN_F11DATA1(canx) REG32((canx) + 0x29CU) /*!< CAN filter 11 data 1 register */
-#define CAN_F12DATA1(canx) REG32((canx) + 0x2A4U) /*!< CAN filter 12 data 1 register */
-#define CAN_F13DATA1(canx) REG32((canx) + 0x2ACU) /*!< CAN filter 13 data 1 register */
-#define CAN_F14DATA1(canx) REG32((canx) + 0x2B4U) /*!< CAN filter 14 data 1 register */
-#define CAN_F15DATA1(canx) REG32((canx) + 0x2BCU) /*!< CAN filter 15 data 1 register */
-#define CAN_F16DATA1(canx) REG32((canx) + 0x2C4U) /*!< CAN filter 16 data 1 register */
-#define CAN_F17DATA1(canx) REG32((canx) + 0x24CU) /*!< CAN filter 17 data 1 register */
-#define CAN_F18DATA1(canx) REG32((canx) + 0x2D4U) /*!< CAN filter 18 data 1 register */
-#define CAN_F19DATA1(canx) REG32((canx) + 0x2DCU) /*!< CAN filter 19 data 1 register */
-#define CAN_F20DATA1(canx) REG32((canx) + 0x2E4U) /*!< CAN filter 20 data 1 register */
-#define CAN_F21DATA1(canx) REG32((canx) + 0x2ECU) /*!< CAN filter 21 data 1 register */
-#define CAN_F22DATA1(canx) REG32((canx) + 0x2F4U) /*!< CAN filter 22 data 1 register */
-#define CAN_F23DATA1(canx) REG32((canx) + 0x2FCU) /*!< CAN filter 23 data 1 register */
-#define CAN_F24DATA1(canx) REG32((canx) + 0x304U) /*!< CAN filter 24 data 1 register */
-#define CAN_F25DATA1(canx) REG32((canx) + 0x30CU) /*!< CAN filter 25 data 1 register */
-#define CAN_F26DATA1(canx) REG32((canx) + 0x314U) /*!< CAN filter 26 data 1 register */
-#define CAN_F27DATA1(canx) REG32((canx) + 0x31CU) /*!< CAN filter 27 data 1 register */
+#define CAN_CTL(canx) REG32((canx) + 0x00000000U) /*!< CAN control register */
+#define CAN_STAT(canx) REG32((canx) + 0x00000004U) /*!< CAN status register */
+#define CAN_TSTAT(canx) REG32((canx) + 0x00000008U) /*!< CAN transmit status register*/
+#define CAN_RFIFO0(canx) REG32((canx) + 0x0000000CU) /*!< CAN receive FIFO0 register */
+#define CAN_RFIFO1(canx) REG32((canx) + 0x00000010U) /*!< CAN receive FIFO1 register */
+#define CAN_INTEN(canx) REG32((canx) + 0x00000014U) /*!< CAN interrupt enable register */
+#define CAN_ERR(canx) REG32((canx) + 0x00000018U) /*!< CAN error register */
+#define CAN_BT(canx) REG32((canx) + 0x0000001CU) /*!< CAN bit timing register */
+#define CAN_TMI0(canx) REG32((canx) + 0x00000180U) /*!< CAN transmit mailbox0 identifier register */
+#define CAN_TMP0(canx) REG32((canx) + 0x00000184U) /*!< CAN transmit mailbox0 property register */
+#define CAN_TMDATA00(canx) REG32((canx) + 0x00000188U) /*!< CAN transmit mailbox0 data0 register */
+#define CAN_TMDATA10(canx) REG32((canx) + 0x0000018CU) /*!< CAN transmit mailbox0 data1 register */
+#define CAN_TMI1(canx) REG32((canx) + 0x00000190U) /*!< CAN transmit mailbox1 identifier register */
+#define CAN_TMP1(canx) REG32((canx) + 0x00000194U) /*!< CAN transmit mailbox1 property register */
+#define CAN_TMDATA01(canx) REG32((canx) + 0x00000198U) /*!< CAN transmit mailbox1 data0 register */
+#define CAN_TMDATA11(canx) REG32((canx) + 0x0000019CU) /*!< CAN transmit mailbox1 data1 register */
+#define CAN_TMI2(canx) REG32((canx) + 0x000001A0U) /*!< CAN transmit mailbox2 identifier register */
+#define CAN_TMP2(canx) REG32((canx) + 0x000001A4U) /*!< CAN transmit mailbox2 property register */
+#define CAN_TMDATA02(canx) REG32((canx) + 0x000001A8U) /*!< CAN transmit mailbox2 data0 register */
+#define CAN_TMDATA12(canx) REG32((canx) + 0x000001ACU) /*!< CAN transmit mailbox2 data1 register */
+#define CAN_RFIFOMI0(canx) REG32((canx) + 0x000001B0U) /*!< CAN receive FIFO0 mailbox identifier register */
+#define CAN_RFIFOMP0(canx) REG32((canx) + 0x000001B4U) /*!< CAN receive FIFO0 mailbox property register */
+#define CAN_RFIFOMDATA00(canx) REG32((canx) + 0x000001B8U) /*!< CAN receive FIFO0 mailbox data0 register */
+#define CAN_RFIFOMDATA10(canx) REG32((canx) + 0x000001BCU) /*!< CAN receive FIFO0 mailbox data1 register */
+#define CAN_RFIFOMI1(canx) REG32((canx) + 0x000001C0U) /*!< CAN receive FIFO1 mailbox identifier register */
+#define CAN_RFIFOMP1(canx) REG32((canx) + 0x000001C4U) /*!< CAN receive FIFO1 mailbox property register */
+#define CAN_RFIFOMDATA01(canx) REG32((canx) + 0x000001C8U) /*!< CAN receive FIFO1 mailbox data0 register */
+#define CAN_RFIFOMDATA11(canx) REG32((canx) + 0x000001CCU) /*!< CAN receive FIFO1 mailbox data1 register */
+#define CAN_FCTL(canx) REG32((canx) + 0x00000200U) /*!< CAN filter control register */
+#define CAN_FMCFG(canx) REG32((canx) + 0x00000204U) /*!< CAN filter mode register */
+#define CAN_FSCFG(canx) REG32((canx) + 0x0000020CU) /*!< CAN filter scale register */
+#define CAN_FAFIFO(canx) REG32((canx) + 0x00000214U) /*!< CAN filter associated FIFO register */
+#define CAN_FW(canx) REG32((canx) + 0x0000021CU) /*!< CAN filter working register */
+#define CAN_F0DATA0(canx) REG32((canx) + 0x00000240U) /*!< CAN filter 0 data 0 register */
+#define CAN_F1DATA0(canx) REG32((canx) + 0x00000248U) /*!< CAN filter 1 data 0 register */
+#define CAN_F2DATA0(canx) REG32((canx) + 0x00000250U) /*!< CAN filter 2 data 0 register */
+#define CAN_F3DATA0(canx) REG32((canx) + 0x00000258U) /*!< CAN filter 3 data 0 register */
+#define CAN_F4DATA0(canx) REG32((canx) + 0x00000260U) /*!< CAN filter 4 data 0 register */
+#define CAN_F5DATA0(canx) REG32((canx) + 0x00000268U) /*!< CAN filter 5 data 0 register */
+#define CAN_F6DATA0(canx) REG32((canx) + 0x00000270U) /*!< CAN filter 6 data 0 register */
+#define CAN_F7DATA0(canx) REG32((canx) + 0x00000278U) /*!< CAN filter 7 data 0 register */
+#define CAN_F8DATA0(canx) REG32((canx) + 0x00000280U) /*!< CAN filter 8 data 0 register */
+#define CAN_F9DATA0(canx) REG32((canx) + 0x00000288U) /*!< CAN filter 9 data 0 register */
+#define CAN_F10DATA0(canx) REG32((canx) + 0x00000290U) /*!< CAN filter 10 data 0 register */
+#define CAN_F11DATA0(canx) REG32((canx) + 0x00000298U) /*!< CAN filter 11 data 0 register */
+#define CAN_F12DATA0(canx) REG32((canx) + 0x000002A0U) /*!< CAN filter 12 data 0 register */
+#define CAN_F13DATA0(canx) REG32((canx) + 0x000002A8U) /*!< CAN filter 13 data 0 register */
+#define CAN_F14DATA0(canx) REG32((canx) + 0x000002B0U) /*!< CAN filter 14 data 0 register */
+#define CAN_F15DATA0(canx) REG32((canx) + 0x000002B8U) /*!< CAN filter 15 data 0 register */
+#define CAN_F16DATA0(canx) REG32((canx) + 0x000002C0U) /*!< CAN filter 16 data 0 register */
+#define CAN_F17DATA0(canx) REG32((canx) + 0x000002C8U) /*!< CAN filter 17 data 0 register */
+#define CAN_F18DATA0(canx) REG32((canx) + 0x000002D0U) /*!< CAN filter 18 data 0 register */
+#define CAN_F19DATA0(canx) REG32((canx) + 0x000002D8U) /*!< CAN filter 19 data 0 register */
+#define CAN_F20DATA0(canx) REG32((canx) + 0x000002E0U) /*!< CAN filter 20 data 0 register */
+#define CAN_F21DATA0(canx) REG32((canx) + 0x000002E8U) /*!< CAN filter 21 data 0 register */
+#define CAN_F22DATA0(canx) REG32((canx) + 0x000002F0U) /*!< CAN filter 22 data 0 register */
+#define CAN_F23DATA0(canx) REG32((canx) + 0x000003F8U) /*!< CAN filter 23 data 0 register */
+#define CAN_F24DATA0(canx) REG32((canx) + 0x00000300U) /*!< CAN filter 24 data 0 register */
+#define CAN_F25DATA0(canx) REG32((canx) + 0x00000308U) /*!< CAN filter 25 data 0 register */
+#define CAN_F26DATA0(canx) REG32((canx) + 0x00000310U) /*!< CAN filter 26 data 0 register */
+#define CAN_F27DATA0(canx) REG32((canx) + 0x00000318U) /*!< CAN filter 27 data 0 register */
+#define CAN_F0DATA1(canx) REG32((canx) + 0x00000244U) /*!< CAN filter 0 data 1 register */
+#define CAN_F1DATA1(canx) REG32((canx) + 0x0000024CU) /*!< CAN filter 1 data 1 register */
+#define CAN_F2DATA1(canx) REG32((canx) + 0x00000254U) /*!< CAN filter 2 data 1 register */
+#define CAN_F3DATA1(canx) REG32((canx) + 0x0000025CU) /*!< CAN filter 3 data 1 register */
+#define CAN_F4DATA1(canx) REG32((canx) + 0x00000264U) /*!< CAN filter 4 data 1 register */
+#define CAN_F5DATA1(canx) REG32((canx) + 0x0000026CU) /*!< CAN filter 5 data 1 register */
+#define CAN_F6DATA1(canx) REG32((canx) + 0x00000274U) /*!< CAN filter 6 data 1 register */
+#define CAN_F7DATA1(canx) REG32((canx) + 0x0000027CU) /*!< CAN filter 7 data 1 register */
+#define CAN_F8DATA1(canx) REG32((canx) + 0x00000284U) /*!< CAN filter 8 data 1 register */
+#define CAN_F9DATA1(canx) REG32((canx) + 0x0000028CU) /*!< CAN filter 9 data 1 register */
+#define CAN_F10DATA1(canx) REG32((canx) + 0x00000294U) /*!< CAN filter 10 data 1 register */
+#define CAN_F11DATA1(canx) REG32((canx) + 0x0000029CU) /*!< CAN filter 11 data 1 register */
+#define CAN_F12DATA1(canx) REG32((canx) + 0x000002A4U) /*!< CAN filter 12 data 1 register */
+#define CAN_F13DATA1(canx) REG32((canx) + 0x000002ACU) /*!< CAN filter 13 data 1 register */
+#define CAN_F14DATA1(canx) REG32((canx) + 0x000002B4U) /*!< CAN filter 14 data 1 register */
+#define CAN_F15DATA1(canx) REG32((canx) + 0x000002BCU) /*!< CAN filter 15 data 1 register */
+#define CAN_F16DATA1(canx) REG32((canx) + 0x000002C4U) /*!< CAN filter 16 data 1 register */
+#define CAN_F17DATA1(canx) REG32((canx) + 0x0000024CU) /*!< CAN filter 17 data 1 register */
+#define CAN_F18DATA1(canx) REG32((canx) + 0x000002D4U) /*!< CAN filter 18 data 1 register */
+#define CAN_F19DATA1(canx) REG32((canx) + 0x000002DCU) /*!< CAN filter 19 data 1 register */
+#define CAN_F20DATA1(canx) REG32((canx) + 0x000002E4U) /*!< CAN filter 20 data 1 register */
+#define CAN_F21DATA1(canx) REG32((canx) + 0x000002ECU) /*!< CAN filter 21 data 1 register */
+#define CAN_F22DATA1(canx) REG32((canx) + 0x000002F4U) /*!< CAN filter 22 data 1 register */
+#define CAN_F23DATA1(canx) REG32((canx) + 0x000002FCU) /*!< CAN filter 23 data 1 register */
+#define CAN_F24DATA1(canx) REG32((canx) + 0x00000304U) /*!< CAN filter 24 data 1 register */
+#define CAN_F25DATA1(canx) REG32((canx) + 0x0000030CU) /*!< CAN filter 25 data 1 register */
+#define CAN_F26DATA1(canx) REG32((canx) + 0x00000314U) /*!< CAN filter 26 data 1 register */
+#define CAN_F27DATA1(canx) REG32((canx) + 0x0000031CU) /*!< CAN filter 27 data 1 register */
/* CAN transmit mailbox bank */
#define CAN_TMI(canx, bank) REG32((canx) + 0x180U + ((bank) * 0x10U)) /*!< CAN transmit mailbox identifier register */
@@ -145,7 +147,7 @@ OF SUCH DAMAGE.
#define CAN_FDATA0(canx, bank) REG32((canx) + 0x240U + ((bank) * 0x8U) + 0x0U) /*!< CAN filter data 0 register */
#define CAN_FDATA1(canx, bank) REG32((canx) + 0x240U + ((bank) * 0x8U) + 0x4U) /*!< CAN filter data 1 register */
-/* CAN receive fifo mailbox bank */
+/* CAN receive FIFO mailbox bank */
#define CAN_RFIFOMI(canx, bank) REG32((canx) + 0x1B0U + ((bank) * 0x10U)) /*!< CAN receive FIFO mailbox identifier register */
#define CAN_RFIFOMP(canx, bank) REG32((canx) + 0x1B4U + ((bank) * 0x10U)) /*!< CAN receive FIFO mailbox property register */
#define CAN_RFIFOMDATA0(canx, bank) REG32((canx) + 0x1B8U + ((bank) * 0x10U)) /*!< CAN receive FIFO mailbox data0 register */
@@ -295,10 +297,10 @@ OF SUCH DAMAGE.
#define CAN_FCTL_HBC1F BITS(8,13) /*!< header bank of CAN1 filter */
/* CAN_FMCFG */
-#define CAN_FMCFG_FMOD(regval) BIT(regval) /*!< filter mode, list or mask*/
+#define CAN_FMCFG_FMOD(regval) BIT(regval) /*!< filter mode, list or mask */
/* CAN_FSCFG */
-#define CAN_FSCFG_FS(regval) BIT(regval) /*!< filter scale, 32 bits or 16 bits*/
+#define CAN_FSCFG_FS(regval) BIT(regval) /*!< filter scale, 32 bits or 16 bits */
/* CAN_FAFIFO */
#define CAN_FAFIFOR_FAF(regval) BIT(regval) /*!< filter associated with FIFO */
@@ -309,7 +311,7 @@ OF SUCH DAMAGE.
/* CAN_FxDATAy */
#define CAN_FDATA_FD(regval) BIT(regval) /*!< filter data */
-/* consts definitions */
+/* constants definitions */
/* define the CAN bit position and its register index offset */
#define CAN_REGIDX_BIT(regidx, bitpos) (((uint32_t)(regidx) << 6) | (uint32_t)(bitpos))
#define CAN_REG_VAL(canx, offset) (REG32((canx) + ((uint32_t)(offset) >> 6)))
@@ -328,8 +330,7 @@ OF SUCH DAMAGE.
#define ERR_REG_OFFSET ((uint8_t)0x18U) /*!< ERR register offset */
/* CAN flags */
-typedef enum
-{
+typedef enum {
/* flags in STAT register */
CAN_FLAG_RXL = CAN_REGIDX_BIT(STAT_REG_OFFSET, 11U), /*!< RX level */
CAN_FLAG_LASTRX = CAN_REGIDX_BIT(STAT_REG_OFFSET, 10U), /*!< last sample value of RX pin */
@@ -341,9 +342,9 @@ typedef enum
CAN_FLAG_SLPWS = CAN_REGIDX_BIT(STAT_REG_OFFSET, 1U), /*!< sleep working state */
CAN_FLAG_IWS = CAN_REGIDX_BIT(STAT_REG_OFFSET, 0U), /*!< initial working state */
/* flags in TSTAT register */
- CAN_FLAG_TMLS2 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 31U), /*!< transmit mailbox 2 last sending in Tx FIFO */
- CAN_FLAG_TMLS1 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 30U), /*!< transmit mailbox 1 last sending in Tx FIFO */
- CAN_FLAG_TMLS0 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 29U), /*!< transmit mailbox 0 last sending in Tx FIFO */
+ CAN_FLAG_TMLS2 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 31U), /*!< transmit mailbox 2 last sending in TX FIFO */
+ CAN_FLAG_TMLS1 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 30U), /*!< transmit mailbox 1 last sending in TX FIFO */
+ CAN_FLAG_TMLS0 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 29U), /*!< transmit mailbox 0 last sending in TX FIFO */
CAN_FLAG_TME2 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 28U), /*!< transmit mailbox 2 empty */
CAN_FLAG_TME1 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 27U), /*!< transmit mailbox 1 empty */
CAN_FLAG_TME0 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 26U), /*!< transmit mailbox 0 empty */
@@ -369,11 +370,10 @@ typedef enum
CAN_FLAG_BOERR = CAN_REGIDX_BIT(ERR_REG_OFFSET, 2U), /*!< bus-off error */
CAN_FLAG_PERR = CAN_REGIDX_BIT(ERR_REG_OFFSET, 1U), /*!< passive error */
CAN_FLAG_WERR = CAN_REGIDX_BIT(ERR_REG_OFFSET, 0U), /*!< warning error */
-}can_flag_enum;
+} can_flag_enum;
/* CAN interrupt flags */
-typedef enum
-{
+typedef enum {
/* interrupt flags in STAT register */
CAN_INT_FLAG_SLPIF = CAN_REGIDX_BITS(STAT_REG_OFFSET, 4U, 17U), /*!< status change interrupt flag of sleep working mode entering */
CAN_INT_FLAG_WUIF = CAN_REGIDX_BITS(STAT_REG_OFFSET, 3U, 16), /*!< status change interrupt flag of wakeup from sleep working mode */
@@ -389,17 +389,16 @@ typedef enum
/* interrupt flags in RFIFO0 register */
CAN_INT_FLAG_RFO1 = CAN_REGIDX_BITS(RFIFO1_REG_OFFSET, 4U, 6U), /*!< receive FIFO1 overfull interrupt flag */
CAN_INT_FLAG_RFF1 = CAN_REGIDX_BITS(RFIFO1_REG_OFFSET, 3U, 5U), /*!< receive FIFO1 full interrupt flag */
- CAN_INT_FLAG_RFL1 = CAN_REGIDX_BITS(RFIFO1_REG_OFFSET, 2U, 4U), /*!< receive FIFO0 not empty interrupt flag */
+ CAN_INT_FLAG_RFL1 = CAN_REGIDX_BITS(RFIFO1_REG_OFFSET, 2U, 4U), /*!< receive FIFO1 not empty interrupt flag */
/* interrupt flags in ERR register */
CAN_INT_FLAG_ERRN = CAN_REGIDX_BITS(ERR_REG_OFFSET, 3U, 11U), /*!< error number interrupt flag */
CAN_INT_FLAG_BOERR = CAN_REGIDX_BITS(ERR_REG_OFFSET, 2U, 10U), /*!< bus-off error interrupt flag */
CAN_INT_FLAG_PERR = CAN_REGIDX_BITS(ERR_REG_OFFSET, 1U, 9U), /*!< passive error interrupt flag */
CAN_INT_FLAG_WERR = CAN_REGIDX_BITS(ERR_REG_OFFSET, 0U, 8U), /*!< warning error interrupt flag */
-}can_interrupt_flag_enum;
+} can_interrupt_flag_enum;
-/* CAN initiliaze parameters struct */
-typedef struct
-{
+/* CAN initiliaze parameters structure */
+typedef struct {
uint8_t working_mode; /*!< CAN working mode */
uint8_t resync_jump_width; /*!< CAN resynchronization jump width */
uint8_t time_segment_1; /*!< time segment 1 */
@@ -407,26 +406,24 @@ typedef struct
ControlStatus time_triggered; /*!< time triggered communication mode */
ControlStatus auto_bus_off_recovery; /*!< automatic bus-off recovery */
ControlStatus auto_wake_up; /*!< automatic wake-up mode */
- ControlStatus no_auto_retrans; /*!< automatic retransmission mode disable */
+ ControlStatus auto_retrans; /*!< automatic retransmission mode */
ControlStatus rec_fifo_overwrite; /*!< receive FIFO overwrite mode */
ControlStatus trans_fifo_order; /*!< transmit FIFO order */
uint16_t prescaler; /*!< baudrate prescaler */
-}can_parameter_struct;
+} can_parameter_struct;
-/* CAN transmit message struct */
-typedef struct
-{
+/* CAN transmit message structure */
+typedef struct {
uint32_t tx_sfid; /*!< standard format frame identifier */
uint32_t tx_efid; /*!< extended format frame identifier */
uint8_t tx_ff; /*!< format of frame, standard or extended format */
uint8_t tx_ft; /*!< type of frame, data or remote */
uint8_t tx_dlen; /*!< data length */
uint8_t tx_data[8]; /*!< transmit data */
-}can_trasnmit_message_struct;
+} can_trasnmit_message_struct;
-/* CAN receive message struct */
-typedef struct
-{
+/* CAN receive message structure */
+typedef struct {
uint32_t rx_sfid; /*!< standard format frame identifier */
uint32_t rx_efid; /*!< extended format frame identifier */
uint8_t rx_ff; /*!< format of frame, standard or extended format */
@@ -436,10 +433,9 @@ typedef struct
uint8_t rx_fi; /*!< filtering index */
} can_receive_message_struct;
-/* CAN filter parameters struct */
-typedef struct
-{
- uint16_t filter_list_high; /*!< filter list number high bits*/
+/* CAN filter parameters structure */
+typedef struct {
+ uint16_t filter_list_high; /*!< filter list number high bits */
uint16_t filter_list_low; /*!< filter list number low bits */
uint16_t filter_mask_high; /*!< filter mask number high bits */
uint16_t filter_mask_low; /*!< filter mask number low bits */
@@ -448,11 +444,10 @@ typedef struct
uint16_t filter_mode; /*!< filter mode, list or mask */
uint16_t filter_bits; /*!< filter scale */
ControlStatus filter_enable; /*!< filter work or not */
-}can_filter_parameter_struct;
+} can_filter_parameter_struct;
/* CAN errors */
-typedef enum
-{
+typedef enum {
CAN_ERROR_NONE = 0, /*!< no error */
CAN_ERROR_FILL, /*!< fill error */
CAN_ERROR_FORMATE, /*!< format error */
@@ -461,38 +456,36 @@ typedef enum
CAN_ERROR_BITDOMINANTER, /*!< bit dominant error */
CAN_ERROR_CRC, /*!< CRC error */
CAN_ERROR_SOFTWARECFG, /*!< software configure */
-}can_error_enum;
+} can_error_enum;
/* transmit states */
-typedef enum
-{
- CAN_TRANSMIT_FAILED = 0U, /*!< CAN transmitted failure */
- CAN_TRANSMIT_OK = 1U, /*!< CAN transmitted success */
- CAN_TRANSMIT_PENDING = 2U, /*!< CAN transmitted pending */
- CAN_TRANSMIT_NOMAILBOX = 4U, /*!< no empty mailbox to be used for CAN */
-}can_transmit_state_enum;
+typedef enum {
+ CAN_TRANSMIT_FAILED = 0U, /*!< CAN transmitted failure */
+ CAN_TRANSMIT_OK = 1U, /*!< CAN transmitted success */
+ CAN_TRANSMIT_PENDING = 2U, /*!< CAN transmitted pending */
+ CAN_TRANSMIT_NOMAILBOX = 4U, /*!< no empty mailbox to be used for CAN */
+} can_transmit_state_enum;
-typedef enum
-{
+typedef enum {
CAN_INIT_STRUCT = 0, /* CAN initiliaze parameters struct */
CAN_FILTER_STRUCT, /* CAN filter parameters struct */
CAN_TX_MESSAGE_STRUCT, /* CAN transmit message struct */
CAN_RX_MESSAGE_STRUCT, /* CAN receive message struct */
-}can_struct_type_enum;
+} can_struct_type_enum;
-/* CAN baudrate prescaler*/
+/* CAN baudrate prescaler */
#define BT_BAUDPSC(regval) (BITS(0,9) & ((uint32_t)(regval) << 0))
-/* CAN bit segment 1*/
+/* CAN bit segment 1 */
#define BT_BS1(regval) (BITS(16,19) & ((uint32_t)(regval) << 16))
-/* CAN bit segment 2*/
+/* CAN bit segment 2 */
#define BT_BS2(regval) (BITS(20,22) & ((uint32_t)(regval) << 20))
-/* CAN resynchronization jump width*/
+/* CAN resynchronization jump width */
#define BT_SJW(regval) (BITS(24,25) & ((uint32_t)(regval) << 24))
-/* CAN communication mode*/
+/* CAN communication mode */
#define BT_MODE(regval) (BITS(30,31) & ((uint32_t)(regval) << 30))
/* CAN FDATA high 16 bits */
@@ -501,13 +494,13 @@ typedef enum
/* CAN FDATA low 16 bits */
#define FDATA_MASK_LOW(regval) (BITS(0,15) & ((uint32_t)(regval) << 0))
-/* CAN1 filter start bank_number*/
+/* CAN1 filter start bank_number */
#define FCTL_HBC1F(regval) (BITS(8,13) & ((uint32_t)(regval) << 8))
-/* CAN transmit mailbox extended identifier*/
+/* CAN transmit mailbox extended identifier */
#define TMI_EFID(regval) (BITS(3,31) & ((uint32_t)(regval) << 3))
-/* CAN transmit mailbox standard identifier*/
+/* CAN transmit mailbox standard identifier */
#define TMI_SFID(regval) (BITS(21,31) & ((uint32_t)(regval) << 21))
/* transmit data byte 0 */
@@ -534,10 +527,10 @@ typedef enum
/* transmit data byte 7 */
#define TMDATA1_DB7(regval) (BITS(24,31) & ((uint32_t)(regval) << 24))
-/* receive mailbox extended identifier*/
+/* receive mailbox extended identifier */
#define GET_RFIFOMI_EFID(regval) GET_BITS((uint32_t)(regval), 3U, 31U)
-/* receive mailbox standrad identifier*/
+/* receive mailbox standard identifier */
#define GET_RFIFOMI_SFID(regval) GET_BITS((uint32_t)(regval), 21U, 31U)
/* receive data length */
@@ -581,14 +574,14 @@ typedef enum
/* CAN errors */
#define ERR_ERRN(regval) (BITS(4,6) & ((uint32_t)(regval) << 4))
-#define CAN_ERRN_0 ERR_ERRN(0U) /* no error */
-#define CAN_ERRN_1 ERR_ERRN(1U) /*!< fill error */
-#define CAN_ERRN_2 ERR_ERRN(2U) /*!< format error */
-#define CAN_ERRN_3 ERR_ERRN(3U) /*!< ACK error */
-#define CAN_ERRN_4 ERR_ERRN(4U) /*!< bit recessive error */
-#define CAN_ERRN_5 ERR_ERRN(5U) /*!< bit dominant error */
-#define CAN_ERRN_6 ERR_ERRN(6U) /*!< CRC error */
-#define CAN_ERRN_7 ERR_ERRN(7U) /*!< software error */
+#define CAN_ERRN_0 ERR_ERRN(0U) /*!< no error */
+#define CAN_ERRN_1 ERR_ERRN(1U) /*!< fill error */
+#define CAN_ERRN_2 ERR_ERRN(2U) /*!< format error */
+#define CAN_ERRN_3 ERR_ERRN(3U) /*!< ACK error */
+#define CAN_ERRN_4 ERR_ERRN(4U) /*!< bit recessive error */
+#define CAN_ERRN_5 ERR_ERRN(5U) /*!< bit dominant error */
+#define CAN_ERRN_6 ERR_ERRN(6U) /*!< CRC error */
+#define CAN_ERRN_7 ERR_ERRN(7U) /*!< software error */
#define CAN_STATE_PENDING ((uint32_t)0x00000000U) /*!< CAN pending */
@@ -642,11 +635,11 @@ typedef enum
#define CAN_FF_STANDARD ((uint32_t)0x00000000U) /*!< standard frame */
#define CAN_FF_EXTENDED ((uint32_t)0x00000004U) /*!< extended frame */
-/* CAN receive fifo */
+/* CAN receive FIFO */
#define CAN_FIFO0 ((uint8_t)0x00U) /*!< receive FIFO0 */
#define CAN_FIFO1 ((uint8_t)0x01U) /*!< receive FIFO1 */
-/* frame number of receive fifo */
+/* frame number of receive FIFO */
#define CAN_RFIF_RFL_MASK ((uint32_t)0x00000003U) /*!< mask for frame number in receive FIFOx */
#define CAN_SFID_MASK ((uint32_t)0x000007FFU) /*!< mask of standard identifier */
@@ -692,15 +685,18 @@ typedef enum
#define CAN_INT_SLPW CAN_INTEN_SLPWIE /*!< sleep working interrupt enable */
/* function declarations */
+/* initialization functions */
/* deinitialize CAN */
void can_deinit(uint32_t can_periph);
-/* initialize CAN struct */
-void can_struct_para_init(can_struct_type_enum type, void* p_struct);
+/* initialize CAN structure */
+void can_struct_para_init(can_struct_type_enum type, void *p_struct);
/* initialize CAN */
-ErrStatus can_init(uint32_t can_periph, can_parameter_struct* can_parameter_init);
-/* CAN filter init */
-void can_filter_init(can_filter_parameter_struct* can_filter_parameter_init);
-/* set can1 fliter start bank number */
+ErrStatus can_init(uint32_t can_periph, can_parameter_struct *can_parameter_init);
+/* CAN filter initialization */
+void can_filter_init(can_filter_parameter_struct *can_filter_parameter_init);
+
+/* function configuration */
+/* set can1 filter start bank number */
void can1_filter_start_bank(uint8_t start_bank);
/* enable functions */
/* CAN debug freeze enable */
@@ -714,14 +710,14 @@ void can_time_trigger_mode_disable(uint32_t can_periph);
/* transmit functions */
/* transmit CAN message */
-uint8_t can_message_transmit(uint32_t can_periph, can_trasnmit_message_struct* transmit_message);
+uint8_t can_message_transmit(uint32_t can_periph, can_trasnmit_message_struct *transmit_message);
/* get CAN transmit state */
can_transmit_state_enum can_transmit_states(uint32_t can_periph, uint8_t mailbox_number);
/* stop CAN transmission */
void can_transmission_stop(uint32_t can_periph, uint8_t mailbox_number);
/* CAN receive message */
-void can_message_receive(uint32_t can_periph, uint8_t fifo_number, can_receive_message_struct* receive_message);
-/* CAN release fifo */
+void can_message_receive(uint32_t can_periph, uint8_t fifo_number, can_receive_message_struct *receive_message);
+/* CAN release FIFO */
void can_fifo_release(uint32_t can_periph, uint8_t fifo_number);
/* CAN receive message length */
uint8_t can_receive_message_length_get(uint32_t can_periph, uint8_t fifo_number);
@@ -730,21 +726,22 @@ ErrStatus can_working_mode_set(uint32_t can_periph, uint8_t working_mode);
/* CAN wakeup from sleep mode */
ErrStatus can_wakeup(uint32_t can_periph);
-/* CAN get error */
+/* CAN get error type */
can_error_enum can_error_get(uint32_t can_periph);
/* get CAN receive error number */
uint8_t can_receive_error_number_get(uint32_t can_periph);
/* get CAN transmit error number */
uint8_t can_transmit_error_number_get(uint32_t can_periph);
-/* CAN interrupt enable */
-void can_interrupt_enable(uint32_t can_periph, uint32_t interrupt);
-/* CAN interrupt disable */
-void can_interrupt_disable(uint32_t can_periph, uint32_t interrupt);
+/* interrupt & flag functions */
/* CAN get flag state */
FlagStatus can_flag_get(uint32_t can_periph, can_flag_enum flag);
/* CAN clear flag state */
void can_flag_clear(uint32_t can_periph, can_flag_enum flag);
+/* CAN interrupt enable */
+void can_interrupt_enable(uint32_t can_periph, uint32_t interrupt);
+/* CAN interrupt disable */
+void can_interrupt_disable(uint32_t can_periph, uint32_t interrupt);
/* CAN get interrupt flag state */
FlagStatus can_interrupt_flag_get(uint32_t can_periph, can_interrupt_flag_enum flag);
/* CAN clear interrupt flag state */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_crc.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_crc.h
index 01f2c6bc3f..db3cd23ed7 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_crc.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_crc.h
@@ -5,32 +5,33 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -40,12 +41,12 @@ OF SUCH DAMAGE.
#include "gd32f4xx.h"
/* CRC definitions */
-#define CRC CRC_BASE
+#define CRC CRC_BASE /*!< CRC base address */
/* registers definitions */
-#define CRC_DATA REG32(CRC + 0x00U) /*!< CRC data register */
-#define CRC_FDATA REG32(CRC + 0x04U) /*!< CRC free data register */
-#define CRC_CTL REG32(CRC + 0x08U) /*!< CRC control register */
+#define CRC_DATA REG32(CRC + 0x00000000U) /*!< CRC data register */
+#define CRC_FDATA REG32(CRC + 0x00000004U) /*!< CRC free data register */
+#define CRC_CTL REG32(CRC + 0x00000008U) /*!< CRC control register */
/* bits definitions */
/* CRC_DATA */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_ctc.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_ctc.h
index 00e4e7f298..c07a5db82a 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_ctc.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_ctc.h
@@ -5,32 +5,33 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -50,7 +51,7 @@ OF SUCH DAMAGE.
/* bits definitions */
/* CTC_CTL0 */
-#define CTC_CTL0_CKOKIE BIT(0) /*!< clock trim OK(CKOKIF) interrupt enable */
+#define CTC_CTL0_CKOKIE BIT(0) /*!< clock trim OK(CKOKIF) interrupt enable */
#define CTC_CTL0_CKWARNIE BIT(1) /*!< clock trim warning(CKWARNIF) interrupt enable */
#define CTC_CTL0_ERRIE BIT(2) /*!< error(ERRIF) interrupt enable */
#define CTC_CTL0_EREFIE BIT(3) /*!< EREFIF interrupt enable */
@@ -64,7 +65,6 @@ OF SUCH DAMAGE.
#define CTC_CTL1_CKLIM BITS(16,23) /*!< clock trim base limit value */
#define CTC_CTL1_REFPSC BITS(24,26) /*!< reference signal source prescaler */
#define CTC_CTL1_REFSEL BITS(28,29) /*!< reference signal source selection */
-#define CTC_CTL1_USBSOFSEL BIT(30) /*!< USBFS or USBHS SOF signal selection */
#define CTC_CTL1_REFPOL BIT(31) /*!< reference signal source polarity */
/* CTC_STAT */
@@ -93,15 +93,10 @@ OF SUCH DAMAGE.
#define CTC_REFSOURCE_POLARITY_FALLING CTC_CTL1_REFPOL /*!< reference signal source polarity is falling edge*/
#define CTC_REFSOURCE_POLARITY_RISING ((uint32_t)0x00000000U) /*!< reference signal source polarity is rising edge*/
-/* USBFS or USBHS SOF signal selection definitions */
-#define CTC_USBSOFSEL_USBHS CTC_CTL1_USBSOFSEL /*!< USBHS SOF signal is selected*/
-#define CTC_USBSOFSEL_USBFS ((uint32_t)0x00000000U) /*!< USBFS SOF signal is selected*/
-
/* reference signal source selection definitions */
#define CTL1_REFSEL(regval) (BITS(28,29) & ((uint32_t)(regval) << 28))
#define CTC_REFSOURCE_GPIO CTL1_REFSEL(0) /*!< GPIO is selected */
#define CTC_REFSOURCE_LXTAL CTL1_REFSEL(1) /*!< LXTAL is clock selected */
-#define CTC_REFSOURCE_USBSOF CTL1_REFSEL(2) /*!< USBSOF is selected */
/* reference signal source prescaler definitions */
#define CTL1_REFPSC(regval) (BITS(24,26) & ((uint32_t)(regval) << 24))
@@ -155,8 +150,6 @@ void ctc_hardware_trim_mode_config(uint32_t hardmode);
/* configure reference signal source polarity */
void ctc_refsource_polarity_config(uint32_t polarity);
-/* select USBFS or USBHS SOF signal */
-void ctc_usbsof_signal_select(uint32_t usbsof);
/* select reference signal source */
void ctc_refsource_signal_select(uint32_t refs);
/* configure reference signal source prescaler */
@@ -181,7 +174,7 @@ void ctc_interrupt_enable(uint32_t interrupt);
/* disable the CTC interrupt */
void ctc_interrupt_disable(uint32_t interrupt);
/* get CTC interrupt flag */
-FlagStatus ctc_interrupt_flag_get(uint32_t int_flag);
+FlagStatus ctc_interrupt_flag_get(uint32_t int_flag);
/* clear CTC interrupt flag */
void ctc_interrupt_flag_clear(uint32_t int_flag);
/* get CTC flag */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dac.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dac.h
index 573fb31336..ee471c23f3 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dac.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dac.h
@@ -1,36 +1,37 @@
/*!
\file gd32f4xx_dac.h
\brief definitions for the DAC
-
+
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -70,7 +71,7 @@ OF SUCH DAMAGE.
#define DAC_CTL_DWBW0 BITS(8,11) /*!< DAC0 noise wave bit width */
#define DAC_CTL_DDMAEN0 BIT(12) /*!< DAC0 DMA enable/disable bit */
#define DAC_CTL_DDUDRIE0 BIT(13) /*!< DAC0 DMA underrun interrupt enable/disable bit */
-#define DAC_CTL_DEN1 BIT(16) /*!< DAC1 enable/disable bit */
+#define DAC_CTL_DEN1 BIT(16) /*!< DAC1 enable/disable bit */
#define DAC_CTL_DBOFF1 BIT(17) /*!< DAC1 output buffer turn on/turn off bit */
#define DAC_CTL_DTEN1 BIT(18) /*!< DAC1 trigger enable/disable bit */
#define DAC_CTL_DTSEL1 BITS(19,21) /*!< DAC1 trigger source selection enable/disable bits */
@@ -201,7 +202,7 @@ void dac_disable(uint32_t dac_periph);
/* enable DAC DMA */
void dac_dma_enable(uint32_t dac_periph);
/* disable DAC DMA */
-void dac_dma_disable(uint32_t dac_periph);
+void dac_dma_disable(uint32_t dac_periph);
/* enable DAC output buffer */
void dac_output_buffer_enable(uint32_t dac_periph);
/* disable DAC output buffer */
@@ -254,14 +255,14 @@ void dac_concurrent_interrupt_enable(void);
void dac_concurrent_interrupt_disable(void);
/* DAC interrupt configuration */
-/* enable DAC interrupt(DAC DMA underrun interrupt) */
-void dac_interrupt_enable(uint32_t dac_periph);
-/* disable DAC interrupt(DAC DMA underrun interrupt) */
-void dac_interrupt_disable(uint32_t dac_periph);
/* get the specified DAC flag(DAC DMA underrun flag) */
FlagStatus dac_flag_get(uint32_t dac_periph);
/* clear the specified DAC flag(DAC DMA underrun flag) */
void dac_flag_clear(uint32_t dac_periph);
+/* enable DAC interrupt(DAC DMA underrun interrupt) */
+void dac_interrupt_enable(uint32_t dac_periph);
+/* disable DAC interrupt(DAC DMA underrun interrupt) */
+void dac_interrupt_disable(uint32_t dac_periph);
/* get the specified DAC interrupt flag(DAC DMA underrun interrupt flag) */
FlagStatus dac_interrupt_flag_get(uint32_t dac_periph);
/* clear the specified DAC interrupt flag(DAC DMA underrun interrupt flag) */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dbg.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dbg.h
index fde91597f7..ba2fa8296e 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dbg.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dbg.h
@@ -1,36 +1,37 @@
/*!
\file gd32f4xx_dbg.h
\brief definitions for the DBG
-
+
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -57,7 +58,6 @@ OF SUCH DAMAGE.
#define DBG_CTL0_DSLP_HOLD BIT(1) /*!< keep debugger connection during deepsleep mode */
#define DBG_CTL0_STB_HOLD BIT(2) /*!< keep debugger connection during standby mode */
#define DBG_CTL0_TRACE_IOEN BIT(5) /*!< enable trace pin assignment */
-#define DBG_CTL0_TRACE_MODE BITS(6,7) /*!< trace pin mode selection */
/* DBG_CTL1 */
#define DBG_CTL1_TIMER1_HOLD BIT(0) /*!< hold TIMER1 counter when core is halted */
@@ -122,19 +122,13 @@ typedef enum
DBG_I2C2_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 23U), /*!< hold I2C2 smbus when core is halted */
DBG_CAN0_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 25U), /*!< debug CAN0 kept when core is halted */
DBG_CAN1_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 26U), /*!< debug CAN1 kept when core is halted */
- DBG_TIMER0_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL2, 0U), /*!< hold TIMER0 counter when core is halted */
- DBG_TIMER7_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL2, 1U), /*!< hold TIMER7 counter when core is halted */
- DBG_TIMER8_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL2, 16U), /*!< hold TIMER8 counter when core is halted */
- DBG_TIMER9_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL2, 17U), /*!< hold TIMER9 counter when core is halted */
- DBG_TIMER10_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL2, 18U) /*!< hold TIMER10 counter when core is halted */
+ DBG_TIMER0_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL2, 0U), /*!< hold TIMER0 counter when core is halted */
+ DBG_TIMER7_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL2, 1U), /*!< hold TIMER7 counter when core is halted */
+ DBG_TIMER8_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL2, 16U), /*!< hold TIMER8 counter when core is halted */
+ DBG_TIMER9_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL2, 17U), /*!< hold TIMER9 counter when core is halted */
+ DBG_TIMER10_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL2, 18U) /*!< hold TIMER10 counter when core is halted */
}dbg_periph_enum;
-#define CTL0_TRACE_MODE(regval) (BITS(6,7)&((uint32_t)(regval)<<6))
-#define TRACE_MODE_ASYNC CTL0_TRACE_MODE(0) /*!< trace pin used for async mode */
-#define TRACE_MODE_SYNC_DATASIZE_1 CTL0_TRACE_MODE(1) /*!< trace pin used for sync mode and data size is 1 */
-#define TRACE_MODE_SYNC_DATASIZE_2 CTL0_TRACE_MODE(2) /*!< trace pin used for sync mode and data size is 2 */
-#define TRACE_MODE_SYNC_DATASIZE_4 CTL0_TRACE_MODE(3) /*!< trace pin used for sync mode and data size is 4 */
-
/* function declarations */
/* deinitialize the DBG */
void dbg_deinit(void);
@@ -155,7 +149,5 @@ void dbg_periph_disable(dbg_periph_enum dbg_periph);
void dbg_trace_pin_enable(void);
/* disable trace pin assignment */
void dbg_trace_pin_disable(void);
-/* set trace pin mode */
-void dbg_trace_pin_mode_set(uint32_t trace_mode);
#endif /* GD32F4XX_DBG_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dci.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dci.h
index 4986d5afd4..c27e41a13d 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dci.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dci.h
@@ -5,32 +5,33 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -125,14 +126,14 @@ OF SUCH DAMAGE.
/* constants definitions */
/* DCI parameter structure definitions */
typedef struct
-{
+{
uint32_t capture_mode; /*!< DCI capture mode: continuous or snapshot */
uint32_t clock_polarity; /*!< clock polarity selection */
uint32_t hsync_polarity; /*!< horizontal polarity selection */
uint32_t vsync_polarity; /*!< vertical polarity selection */
uint32_t frame_rate; /*!< frame capture rate */
uint32_t interface_format; /*!< digital camera interface format */
-}dci_parameter_struct;
+}dci_parameter_struct;
#define DCI_CAPTURE_MODE_CONTINUOUS ((uint32_t)0x00000000U) /*!< continuous capture mode */
#define DCI_CAPTURE_MODE_SNAPSHOT DCI_CTL_SNAP /*!< snapshot capture mode */
@@ -145,13 +146,13 @@ typedef struct
#define DCI_VSYNC_POLARITY_LOW ((uint32_t)0x00000000U) /*!< low level during blanking period */
#define DCI_VSYNC_POLARITY_HIGH DCI_CTL_VPS /*!< high level during blanking period*/
-
-#define CTL_FR(regval) (BITS(8,9)&((uint32_t)(regval) << 8U))
+
+#define CTL_FR(regval) (BITS(8,9)&((uint32_t)(regval) << 8U))
#define DCI_FRAME_RATE_ALL CTL_FR(0) /*!< capture all frames */
#define DCI_FRAME_RATE_1_2 CTL_FR(1) /*!< capture one in 2 frames */
#define DCI_FRAME_RATE_1_4 CTL_FR(2) /*!< capture one in 4 frames */
-#define CTL_DCIF(regval) (BITS(10,11)&((uint32_t)(regval) << 10U))
+#define CTL_DCIF(regval) (BITS(10,11)&((uint32_t)(regval) << 10U))
#define DCI_INTERFACE_FORMAT_8BITS CTL_DCIF(0) /*!< 8-bit data on every pixel clock */
#define DCI_INTERFACE_FORMAT_10BITS CTL_DCIF(1) /*!< 10-bit data on every pixel clock */
#define DCI_INTERFACE_FORMAT_12BITS CTL_DCIF(2) /*!< 12-bit data on every pixel clock */
@@ -171,7 +172,7 @@ typedef struct
#define DCI_INT_FLAG_VSYNC BIT(3) /*!< vsync interrupt flag */
#define DCI_INT_FLAG_EL BIT(4) /*!< end of line interrupt flag */
-/* DCI flag definitions */
+/* DCI flag definitions */
#define DCI_FLAG_HS DCI_STAT0_HS /*!< HS line status */
#define DCI_FLAG_VS DCI_STAT0_VS /*!< VS line status */
#define DCI_FLAG_FV DCI_STAT0_FV /*!< FIFO valid */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dma.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dma.h
index cac70b85eb..044662a708 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dma.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_dma.h
@@ -1,36 +1,36 @@
/*!
- \file gd32f4xx_dma.c
+ \file gd32f4xx_dma.h
\brief definitions for the DMA
-
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -40,70 +40,70 @@ OF SUCH DAMAGE.
#include "gd32f4xx.h"
/* DMA definitions */
-#define DMA0 (DMA_BASE) /*!< DMA0 base address */
-#define DMA1 (DMA_BASE + 0x0400U) /*!< DMA1 base address */
+#define DMA0 (DMA_BASE) /*!< DMA0 base address */
+#define DMA1 (DMA_BASE + 0x00000400U) /*!< DMA1 base address */
/* registers definitions */
-#define DMA_INTF0(dmax) REG32((dmax) + 0x00U) /*!< DMA interrupt flag register 0 */
-#define DMA_INTF1(dmax) REG32((dmax) + 0x04U) /*!< DMA interrupt flag register 1 */
-#define DMA_INTC0(dmax) REG32((dmax) + 0x08U) /*!< DMA interrupt flag clear register 0 */
-#define DMA_INTC1(dmax) REG32((dmax) + 0x0CU) /*!< DMA interrupt flag clear register 1 */
+#define DMA_INTF0(dmax) REG32((dmax) + 0x00000000U) /*!< DMA interrupt flag register 0 */
+#define DMA_INTF1(dmax) REG32((dmax) + 0x00000004U) /*!< DMA interrupt flag register 1 */
+#define DMA_INTC0(dmax) REG32((dmax) + 0x00000008U) /*!< DMA interrupt flag clear register 0 */
+#define DMA_INTC1(dmax) REG32((dmax) + 0x0000000CU) /*!< DMA interrupt flag clear register 1 */
-#define DMA_CH0CTL(dmax) REG32((dmax) + 0x10U) /*!< DMA channel 0 control register */
-#define DMA_CH0CNT(dmax) REG32((dmax) + 0x14U) /*!< DMA channel 0 counter register */
-#define DMA_CH0PADDR(dmax) REG32((dmax) + 0x18U) /*!< DMA channel 0 peripheral base address register */
-#define DMA_CH0M0ADDR(dmax) REG32((dmax) + 0x1CU) /*!< DMA channel 0 memory 0 base address register */
-#define DMA_CH0M1ADDR(dmax) REG32((dmax) + 0x20U) /*!< DMA channel 0 memory 1 base address register */
-#define DMA_CH0FCTL(dmax) REG32((dmax) + 0x24U) /*!< DMA channel 0 FIFO control register */
+#define DMA_CH0CTL(dmax) REG32((dmax) + 0x00000010U) /*!< DMA channel 0 control register */
+#define DMA_CH0CNT(dmax) REG32((dmax) + 0x00000014U) /*!< DMA channel 0 counter register */
+#define DMA_CH0PADDR(dmax) REG32((dmax) + 0x00000018U) /*!< DMA channel 0 peripheral base address register */
+#define DMA_CH0M0ADDR(dmax) REG32((dmax) + 0x0000001CU) /*!< DMA channel 0 memory 0 base address register */
+#define DMA_CH0M1ADDR(dmax) REG32((dmax) + 0x00000020U) /*!< DMA channel 0 memory 1 base address register */
+#define DMA_CH0FCTL(dmax) REG32((dmax) + 0x00000024U) /*!< DMA channel 0 FIFO control register */
-#define DMA_CH1CTL(dmax) REG32((dmax) + 0x28U) /*!< DMA channel 1 control register */
-#define DMA_CH1CNT(dmax) REG32((dmax) + 0x2CU) /*!< DMA channel 1 counter register */
-#define DMA_CH1PADDR(dmax) REG32((dmax) + 0x30U) /*!< DMA channel 1 peripheral base address register */
-#define DMA_CH1M0ADDR(dmax) REG32((dmax) + 0x34U) /*!< DMA channel 1 memory 0 base address register */
-#define DMA_CH1M1ADDR(dmax) REG32((dmax) + 0x38U) /*!< DMA channel 1 memory 1 base address register */
-#define DMA_CH1FCTL(dmax) REG32((dmax) + 0x3CU) /*!< DMA channel 1 FIFO control register */
+#define DMA_CH1CTL(dmax) REG32((dmax) + 0x00000028U) /*!< DMA channel 1 control register */
+#define DMA_CH1CNT(dmax) REG32((dmax) + 0x0000002CU) /*!< DMA channel 1 counter register */
+#define DMA_CH1PADDR(dmax) REG32((dmax) + 0x00000030U) /*!< DMA channel 1 peripheral base address register */
+#define DMA_CH1M0ADDR(dmax) REG32((dmax) + 0x00000034U) /*!< DMA channel 1 memory 0 base address register */
+#define DMA_CH1M1ADDR(dmax) REG32((dmax) + 0x00000038U) /*!< DMA channel 1 memory 1 base address register */
+#define DMA_CH1FCTL(dmax) REG32((dmax) + 0x0000003CU) /*!< DMA channel 1 FIFO control register */
-#define DMA_CH2CTL(dmax) REG32((dmax) + 0x40U) /*!< DMA channel 2 control register */
-#define DMA_CH2CNT(dmax) REG32((dmax) + 0x44U) /*!< DMA channel 2 counter register */
-#define DMA_CH2PADDR(dmax) REG32((dmax) + 0x48U) /*!< DMA channel 2 peripheral base address register */
-#define DMA_CH2M0ADDR(dmax) REG32((dmax) + 0x4CU) /*!< DMA channel 2 memory 0 base address register */
-#define DMA_CH2M1ADDR(dmax) REG32((dmax) + 0x50U) /*!< DMA channel 2 memory 1 base address register */
-#define DMA_CH2FCTL(dmax) REG32((dmax) + 0x54U) /*!< DMA channel 2 FIFO control register */
+#define DMA_CH2CTL(dmax) REG32((dmax) + 0x00000040U) /*!< DMA channel 2 control register */
+#define DMA_CH2CNT(dmax) REG32((dmax) + 0x00000044U) /*!< DMA channel 2 counter register */
+#define DMA_CH2PADDR(dmax) REG32((dmax) + 0x00000048U) /*!< DMA channel 2 peripheral base address register */
+#define DMA_CH2M0ADDR(dmax) REG32((dmax) + 0x0000004CU) /*!< DMA channel 2 memory 0 base address register */
+#define DMA_CH2M1ADDR(dmax) REG32((dmax) + 0x00000050U) /*!< DMA channel 2 memory 1 base address register */
+#define DMA_CH2FCTL(dmax) REG32((dmax) + 0x00000054U) /*!< DMA channel 2 FIFO control register */
-#define DMA_CH3CTL(dmax) REG32((dmax) + 0x58U) /*!< DMA channel 3 control register */
-#define DMA_CH3CNT(dmax) REG32((dmax) + 0x5CU) /*!< DMA channel 3 counter register */
-#define DMA_CH3PADDR(dmax) REG32((dmax) + 0x60U) /*!< DMA channel 3 peripheral base address register */
-#define DMA_CH3M0ADDR(dmax) REG32((dmax) + 0x64U) /*!< DMA channel 3 memory 0 base address register */
-#define DMA_CH3M1ADDR(dmax) REG32((dmax) + 0x68U) /*!< DMA channel 3 memory 1 base address register */
-#define DMA_CH3FCTL(dmax) REG32((dmax) + 0x6CU) /*!< DMA channel 3 FIFO control register */
+#define DMA_CH3CTL(dmax) REG32((dmax) + 0x00000058U) /*!< DMA channel 3 control register */
+#define DMA_CH3CNT(dmax) REG32((dmax) + 0x0000005CU) /*!< DMA channel 3 counter register */
+#define DMA_CH3PADDR(dmax) REG32((dmax) + 0x00000060U) /*!< DMA channel 3 peripheral base address register */
+#define DMA_CH3M0ADDR(dmax) REG32((dmax) + 0x00000064U) /*!< DMA channel 3 memory 0 base address register */
+#define DMA_CH3M1ADDR(dmax) REG32((dmax) + 0x00000068U) /*!< DMA channel 3 memory 1 base address register */
+#define DMA_CH3FCTL(dmax) REG32((dmax) + 0x0000006CU) /*!< DMA channel 3 FIFO control register */
-#define DMA_CH4CTL(dmax) REG32((dmax) + 0x70U) /*!< DMA channel 4 control register */
-#define DMA_CH4CNT(dmax) REG32((dmax) + 0x74U) /*!< DMA channel 4 counter register */
-#define DMA_CH4PADDR(dmax) REG32((dmax) + 0x78U) /*!< DMA channel 4 peripheral base address register */
-#define DMA_CH4M0ADDR(dmax) REG32((dmax) + 0x7CU) /*!< DMA channel 4 memory 0 base address register */
-#define DMA_CH4M1ADDR(dmax) REG32((dmax) + 0x80U) /*!< DMA channel 4 memory 1 base address register */
-#define DMA_CH4FCTL(dmax) REG32((dmax) + 0x84U) /*!< DMA channel 4 FIFO control register */
+#define DMA_CH4CTL(dmax) REG32((dmax) + 0x00000070U) /*!< DMA channel 4 control register */
+#define DMA_CH4CNT(dmax) REG32((dmax) + 0x00000074U) /*!< DMA channel 4 counter register */
+#define DMA_CH4PADDR(dmax) REG32((dmax) + 0x00000078U) /*!< DMA channel 4 peripheral base address register */
+#define DMA_CH4M0ADDR(dmax) REG32((dmax) + 0x0000007CU) /*!< DMA channel 4 memory 0 base address register */
+#define DMA_CH4M1ADDR(dmax) REG32((dmax) + 0x00000080U) /*!< DMA channel 4 memory 1 base address register */
+#define DMA_CH4FCTL(dmax) REG32((dmax) + 0x00000084U) /*!< DMA channel 4 FIFO control register */
-#define DMA_CH5CTL(dmax) REG32((dmax) + 0x88U) /*!< DMA channel 5 control register */
-#define DMA_CH5CNT(dmax) REG32((dmax) + 0x8CU) /*!< DMA channel 5 counter register */
-#define DMA_CH5PADDR(dmax) REG32((dmax) + 0x90U) /*!< DMA channel 5 peripheral base address register */
-#define DMA_CH5M0ADDR(dmax) REG32((dmax) + 0x94U) /*!< DMA channel 5 memory 0 base address register */
-#define DMA_CH5M1ADDR(dmax) REG32((dmax) + 0x98U) /*!< DMA channel 5 memory 1 base address register */
-#define DMA_CH5FCTL(dmax) REG32((dmax) + 0x9CU) /*!< DMA channel 5 FIFO control register */
+#define DMA_CH5CTL(dmax) REG32((dmax) + 0x00000088U) /*!< DMA channel 5 control register */
+#define DMA_CH5CNT(dmax) REG32((dmax) + 0x0000008CU) /*!< DMA channel 5 counter register */
+#define DMA_CH5PADDR(dmax) REG32((dmax) + 0x00000090U) /*!< DMA channel 5 peripheral base address register */
+#define DMA_CH5M0ADDR(dmax) REG32((dmax) + 0x00000094U) /*!< DMA channel 5 memory 0 base address register */
+#define DMA_CH5M1ADDR(dmax) REG32((dmax) + 0x00000098U) /*!< DMA channel 5 memory 1 base address register */
+#define DMA_CH5FCTL(dmax) REG32((dmax) + 0x0000009CU) /*!< DMA channel 5 FIFO control register */
-#define DMA_CH6CTL(dmax) REG32((dmax) + 0xA0U) /*!< DMA channel 6 control register */
-#define DMA_CH6CNT(dmax) REG32((dmax) + 0xA4U) /*!< DMA channel 6 counter register */
-#define DMA_CH6PADDR(dmax) REG32((dmax) + 0xA8U) /*!< DMA channel 6 peripheral base address register */
-#define DMA_CH6M0ADDR(dmax) REG32((dmax) + 0xACU) /*!< DMA channel 6 memory 0 base address register */
-#define DMA_CH6M1ADDR(dmax) REG32((dmax) + 0xB0U) /*!< DMA channel 6 memory 1 base address register */
-#define DMA_CH6FCTL(dmax) REG32((dmax) + 0xB4U) /*!< DMA channel 6 FIFO control register */
+#define DMA_CH6CTL(dmax) REG32((dmax) + 0x000000A0U) /*!< DMA channel 6 control register */
+#define DMA_CH6CNT(dmax) REG32((dmax) + 0x000000A4U) /*!< DMA channel 6 counter register */
+#define DMA_CH6PADDR(dmax) REG32((dmax) + 0x000000A8U) /*!< DMA channel 6 peripheral base address register */
+#define DMA_CH6M0ADDR(dmax) REG32((dmax) + 0x000000ACU) /*!< DMA channel 6 memory 0 base address register */
+#define DMA_CH6M1ADDR(dmax) REG32((dmax) + 0x000000B0U) /*!< DMA channel 6 memory 1 base address register */
+#define DMA_CH6FCTL(dmax) REG32((dmax) + 0x000000B4U) /*!< DMA channel 6 FIFO control register */
-#define DMA_CH7CTL(dmax) REG32((dmax) + 0xB8U) /*!< DMA channel 7 control register */
-#define DMA_CH7CNT(dmax) REG32((dmax) + 0xBCU) /*!< DMA channel 7 counter register */
-#define DMA_CH7PADDR(dmax) REG32((dmax) + 0xC0U) /*!< DMA channel 7 peripheral base address register */
-#define DMA_CH7M0ADDR(dmax) REG32((dmax) + 0xC4U) /*!< DMA channel 7 memory 0 base address register */
-#define DMA_CH7M1ADDR(dmax) REG32((dmax) + 0xC8U) /*!< DMA channel 7 memory 1 base address register */
-#define DMA_CH7FCTL(dmax) REG32((dmax) + 0xCCU) /*!< DMA channel 7 FIFO control register */
+#define DMA_CH7CTL(dmax) REG32((dmax) + 0x000000B8U) /*!< DMA channel 7 control register */
+#define DMA_CH7CNT(dmax) REG32((dmax) + 0x000000BCU) /*!< DMA channel 7 counter register */
+#define DMA_CH7PADDR(dmax) REG32((dmax) + 0x000000C0U) /*!< DMA channel 7 peripheral base address register */
+#define DMA_CH7M0ADDR(dmax) REG32((dmax) + 0x000000C4U) /*!< DMA channel 7 memory 0 base address register */
+#define DMA_CH7M1ADDR(dmax) REG32((dmax) + 0x000000C8U) /*!< DMA channel 7 memory 1 base address register */
+#define DMA_CH7FCTL(dmax) REG32((dmax) + 0x000000CCU) /*!< DMA channel 7 FIFO control register */
/* bits definitions */
/* DMA_INTF */
@@ -161,7 +161,7 @@ OF SUCH DAMAGE.
/* constants definitions */
/* DMA channel select */
-typedef enum
+typedef enum
{
DMA_CH0 = 0, /*!< DMA Channel 0 */
DMA_CH1, /*!< DMA Channel 1 */
@@ -174,7 +174,7 @@ typedef enum
} dma_channel_enum;
/* DMA peripheral select */
-typedef enum
+typedef enum
{
DMA_SUBPERI0 = 0, /*!< DMA Peripheral 0 */
DMA_SUBPERI1, /*!< DMA Peripheral 1 */
@@ -191,7 +191,7 @@ typedef struct
{
uint32_t periph_addr; /*!< peripheral base address */
uint32_t periph_width; /*!< transfer data size of peripheral */
- uint32_t periph_inc; /*!< peripheral increasing mode */
+ uint32_t periph_inc; /*!< peripheral increasing mode */
uint32_t memory0_addr; /*!< memory 0 base address */
uint32_t memory_width; /*!< transfer data size of memory */
@@ -211,7 +211,7 @@ typedef struct
typedef struct
{
uint32_t periph_addr; /*!< peripheral base address */
- uint32_t periph_inc; /*!< peripheral increasing mode */
+ uint32_t periph_inc; /*!< peripheral increasing mode */
uint32_t memory0_addr; /*!< memory 0 base address */
uint32_t memory_inc; /*!< memory increasing mode */
@@ -416,13 +416,13 @@ uint32_t dma_fifo_status_get(uint32_t dma_periph, dma_channel_enum channelx);
FlagStatus dma_flag_get(uint32_t dma_periph, dma_channel_enum channelx, uint32_t flag);
/* clear DMA a channel flag */
void dma_flag_clear(uint32_t dma_periph, dma_channel_enum channelx, uint32_t flag);
-/* check DMA flag is set or not */
-FlagStatus dma_interrupt_flag_get(uint32_t dma_periph, dma_channel_enum channelx, uint32_t interrupt);
-/* clear DMA a channel flag */
-void dma_interrupt_flag_clear(uint32_t dma_periph, dma_channel_enum channelx, uint32_t interrupt);
/* enable DMA interrupt */
void dma_interrupt_enable(uint32_t dma_periph, dma_channel_enum channelx, uint32_t source);
/* disable DMA interrupt */
void dma_interrupt_disable(uint32_t dma_periph, dma_channel_enum channelx, uint32_t source);
+/* check DMA flag is set or not */
+FlagStatus dma_interrupt_flag_get(uint32_t dma_periph, dma_channel_enum channelx, uint32_t interrupt);
+/* clear DMA a channel flag */
+void dma_interrupt_flag_clear(uint32_t dma_periph, dma_channel_enum channelx, uint32_t interrupt);
#endif /* GD32F4XX_DMA_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_enet.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_enet.h
index 1dfc880d37..517c7c0d7d 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_enet.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_enet.h
@@ -5,32 +5,33 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -61,7 +62,7 @@ OF SUCH DAMAGE.
#define ENET_TXBUF_SIZE ENET_MAX_FRAME_SIZE /*!< ethernet transmit buffer size */
#endif
-//#define SELECT_DESCRIPTORS_ENHANCED_MODE
+//#define SELECT_DESCRIPTORS_ENHANCED_MODE
//#define USE_DELAY
@@ -72,7 +73,7 @@ OF SUCH DAMAGE.
#define PHY_ADDRESS ((uint16_t)1U) /*!< phy address determined by the hardware */
-/* PHY read write timeouts */
+/* PHY read write timeouts */
#define PHY_READ_TO ((uint32_t)0x0004FFFFU) /*!< PHY read timeout */
#define PHY_WRITE_TO ((uint32_t)0x0004FFFFU) /*!< PHY write timeout */
@@ -80,7 +81,7 @@ OF SUCH DAMAGE.
#define PHY_RESETDELAY ((uint32_t)0x008FFFFFU) /*!< PHY reset delay */
#define PHY_CONFIGDELAY ((uint32_t)0x00FFFFFFU) /*!< PHY configure delay */
-/* PHY register address */
+/* PHY register address */
#define PHY_REG_BCR 0U /*!< tranceiver basic control register */
#define PHY_REG_BSR 1U /*!< tranceiver basic status register */
@@ -101,7 +102,7 @@ OF SUCH DAMAGE.
#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< valid link established */
#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< jabber condition detected */
-#if(PHY_TYPE == LAN8700)
+#if(PHY_TYPE == LAN8700)
#define PHY_SR 31U /*!< tranceiver status register */
#define PHY_SPEED_STATUS ((uint16_t)0x0004) /*!< configured information of speed: 10Mbit/s */
#define PHY_DUPLEX_STATUS ((uint16_t)0x0010) /*!< configured information of duplex: full-duplex */
@@ -123,7 +124,7 @@ OF SUCH DAMAGE.
#define ENET_MAC_HLH REG32((ENET) + 0x0008U) /*!< ethernet MAC hash list high register */
#define ENET_MAC_HLL REG32((ENET) + 0x000CU) /*!< ethernet MAC hash list low register */
#define ENET_MAC_PHY_CTL REG32((ENET) + 0x0010U) /*!< ethernet MAC PHY control register */
-#define ENET_MAC_PHY_DATA REG32((ENET) + 0x0014U) /*!< ethernet MAC MII data register */
+#define ENET_MAC_PHY_DATA REG32((ENET) + 0x0014U) /*!< ethernet MAC PHY data register */
#define ENET_MAC_FCTL REG32((ENET) + 0x0018U) /*!< ethernet MAC flow control register */
#define ENET_MAC_VLT REG32((ENET) + 0x001CU) /*!< ethernet MAC VLAN tag register */
#define ENET_MAC_RWFF REG32((ENET) + 0x0028U) /*!< ethernet MAC remote wakeup frame filter register */
@@ -154,7 +155,7 @@ OF SUCH DAMAGE.
#define ENET_MSC_RGUFCNT REG32((ENET) + 0x01C4U) /*!< ethernet MSC received good unicast frames counter register */
#define ENET_PTP_TSCTL REG32((ENET) + 0x0700U) /*!< ethernet PTP time stamp control register */
-#define ENET_PTP_SSINC REG32((ENET) + 0x0704U) /*!< ethernet PTP subsecond increment register */
+#define ENET_PTP_SSINC REG32((ENET) + 0x0704U) /*!< ethernet PTP subsecond increment register */
#define ENET_PTP_TSH REG32((ENET) + 0x0708U) /*!< ethernet PTP time stamp high register */
#define ENET_PTP_TSL REG32((ENET) + 0x070CU) /*!< ethernet PTP time stamp low register */
#define ENET_PTP_TSUH REG32((ENET) + 0x0710U) /*!< ethernet PTP time stamp update high register */
@@ -166,7 +167,7 @@ OF SUCH DAMAGE.
#define ENET_PTP_PPSCTL REG32((ENET) + 0x072CU) /*!< ethernet PTP PPS control register */
#define ENET_DMA_BCTL REG32((ENET) + 0x1000U) /*!< ethernet DMA bus control register */
-#define ENET_DMA_TPEN REG32((ENET) + 0x1004U) /*!< ethernet DMA transmit poll enable register */
+#define ENET_DMA_TPEN REG32((ENET) + 0x1004U) /*!< ethernet DMA transmit poll enable register */
#define ENET_DMA_RPEN REG32((ENET) + 0x1008U) /*!< ethernet DMA receive poll enable register */
#define ENET_DMA_RDTADDR REG32((ENET) + 0x100CU) /*!< ethernet DMA receive descriptor table address register */
#define ENET_DMA_TDTADDR REG32((ENET) + 0x1010U) /*!< ethernet DMA transmit descriptor table address register */
@@ -175,7 +176,7 @@ OF SUCH DAMAGE.
#define ENET_DMA_INTEN REG32((ENET) + 0x101CU) /*!< ethernet DMA interrupt enable register */
#define ENET_DMA_MFBOCNT REG32((ENET) + 0x1020U) /*!< ethernet DMA missed frame and buffer overflow counter register */
#define ENET_DMA_RSWDC REG32((ENET) + 0x1024U) /*!< ethernet DMA receive state watchdog counter register */
-#define ENET_DMA_CTDADDR REG32((ENET) + 0x1048U) /*!< ethernet DMA current transmit descriptor address register */
+#define ENET_DMA_CTDADDR REG32((ENET) + 0x1048U) /*!< ethernet DMA current transmit descriptor address register */
#define ENET_DMA_CRDADDR REG32((ENET) + 0x104CU) /*!< ethernet DMA current receive descriptor address register */
#define ENET_DMA_CTBADDR REG32((ENET) + 0x1050U) /*!< ethernet DMA current transmit buffer address register */
#define ENET_DMA_CRBADDR REG32((ENET) + 0x1054U) /*!< ethernet DMA current receive buffer address register */
@@ -194,7 +195,7 @@ OF SUCH DAMAGE.
#define ENET_MAC_CFG_ROD BIT(13) /*!< receive own disable */
#define ENET_MAC_CFG_SPD BIT(14) /*!< fast eneternet speed */
#define ENET_MAC_CFG_CSD BIT(16) /*!< carrier sense disable */
-#define ENET_MAC_CFG_IGBS BITS(17,19) /*!< inter-frame gap bit selection */
+#define ENET_MAC_CFG_IGBS BITS(17,19) /*!< inter-frame gap bit selection */
#define ENET_MAC_CFG_JBD BIT(22) /*!< jabber disable */
#define ENET_MAC_CFG_WDD BIT(23) /*!< watchdog disable */
#define ENET_MAC_CFG_TFCD BIT(25) /*!< type frame CRC dropping */
@@ -202,49 +203,49 @@ OF SUCH DAMAGE.
/* ENET_MAC_FRMF */
#define ENET_MAC_FRMF_PM BIT(0) /*!< promiscuous mode */
#define ENET_MAC_FRMF_HUF BIT(1) /*!< hash unicast filter */
-#define ENET_MAC_FRMF_HMF BIT(2) /*!< hash multicast filter */
-#define ENET_MAC_FRMF_DAIFLT BIT(3) /*!< destination address inverse filtering enable */
-#define ENET_MAC_FRMF_MFD BIT(4) /*!< multicast filter disable */
-#define ENET_MAC_FRMF_BFRMD BIT(5) /*!< broadcast frame disable */
-#define ENET_MAC_FRMF_PCFRM BITS(6,7) /*!< pass control frames */
-#define ENET_MAC_FRMF_SAIFLT BIT(8) /*!< source address inverse filtering */
-#define ENET_MAC_FRMF_SAFLT BIT(9) /*!< source address filter */
-#define ENET_MAC_FRMF_HPFLT BIT(10) /*!< hash or perfect filter */
-#define ENET_MAC_FRMF_FAR BIT(31) /*!< frames all receive */
-
+#define ENET_MAC_FRMF_HMF BIT(2) /*!< hash multicast filter */
+#define ENET_MAC_FRMF_DAIFLT BIT(3) /*!< destination address inverse filtering enable */
+#define ENET_MAC_FRMF_MFD BIT(4) /*!< multicast filter disable */
+#define ENET_MAC_FRMF_BFRMD BIT(5) /*!< broadcast frame disable */
+#define ENET_MAC_FRMF_PCFRM BITS(6,7) /*!< pass control frames */
+#define ENET_MAC_FRMF_SAIFLT BIT(8) /*!< source address inverse filtering */
+#define ENET_MAC_FRMF_SAFLT BIT(9) /*!< source address filter */
+#define ENET_MAC_FRMF_HPFLT BIT(10) /*!< hash or perfect filter */
+#define ENET_MAC_FRMF_FAR BIT(31) /*!< frames all receive */
+
/* ENET_MAC_HLH */
#define ENET_MAC_HLH_HLH BITS(0,31) /*!< hash list high */
-
+
/* ENET_MAC_HLL */
#define ENET_MAC_HLL_HLL BITS(0,31) /*!< hash list low */
-
+
/* ENET_MAC_PHY_CTL */
-#define ENET_MAC_PHY_CTL_PB BIT(0) /*!< PHY busy */
-#define ENET_MAC_PHY_CTL_PW BIT(1) /*!< PHY write */
-#define ENET_MAC_PHY_CTL_CLR BITS(2,4) /*!< clock range */
-#define ENET_MAC_PHY_CTL_PR BITS(6,10) /*!< PHY register */
-#define ENET_MAC_PHY_CTL_PA BITS(11,15) /*!< PHY address */
-
+#define ENET_MAC_PHY_CTL_PB BIT(0) /*!< PHY busy */
+#define ENET_MAC_PHY_CTL_PW BIT(1) /*!< PHY write */
+#define ENET_MAC_PHY_CTL_CLR BITS(2,4) /*!< clock range */
+#define ENET_MAC_PHY_CTL_PR BITS(6,10) /*!< PHY register */
+#define ENET_MAC_PHY_CTL_PA BITS(11,15) /*!< PHY address */
+
/* ENET_MAC_PHY_DATA */
#define ENET_MAC_PHY_DATA_PD BITS(0,15) /*!< PHY data */
-
+
/* ENET_MAC_FCTL */
#define ENET_MAC_FCTL_FLCBBKPA BIT(0) /*!< flow control busy(in full duplex mode)/backpressure activate(in half duplex mode) */
#define ENET_MAC_FCTL_TFCEN BIT(1) /*!< transmit flow control enable */
#define ENET_MAC_FCTL_RFCEN BIT(2) /*!< receive flow control enable */
#define ENET_MAC_FCTL_UPFDT BIT(3) /*!< unicast pause frame detect */
-#define ENET_MAC_FCTL_PLTS BITS(4,5) /*!< pause low threshold */
+#define ENET_MAC_FCTL_PLTS BITS(4,5) /*!< pause low threshold */
#define ENET_MAC_FCTL_DZQP BIT(7) /*!< disable zero-quanta pause */
#define ENET_MAC_FCTL_PTM BITS(16,31) /*!< pause time */
-
+
/* ENET_MAC_VLT */
#define ENET_MAC_VLT_VLTI BITS(0,15) /*!< VLAN tag identifier(for receive frames) */
#define ENET_MAC_VLT_VLTC BIT(16) /*!< 12-bit VLAN tag comparison */
-
+
/* ENET_MAC_RWFF */
#define ENET_MAC_RWFF_DATA BITS(0,31) /*!< wakeup frame filter register data */
-
-/* ENET_MAC_WUM */
+
+/* ENET_MAC_WUM */
#define ENET_MAC_WUM_PWD BIT(0) /*!< power down */
#define ENET_MAC_WUM_MPEN BIT(1) /*!< magic packet enable */
#define ENET_MAC_WUM_WFEN BIT(2) /*!< wakeup frame enable */
@@ -253,7 +254,7 @@ OF SUCH DAMAGE.
#define ENET_MAC_WUM_GU BIT(9) /*!< global unicast */
#define ENET_MAC_WUM_WUFFRPR BIT(31) /*!< wakeup frame filter register pointer reset */
-/* ENET_MAC_DBG */
+/* ENET_MAC_DBG */
#define ENET_MAC_DBG_MRNI BIT(0) /*!< MAC receive state not idle */
#define ENET_MAC_DBG_RXAFS BITS(1,2) /*!< Rx asynchronous FIFO status */
#define ENET_MAC_DBG_RXFW BIT(4) /*!< RxFIFO is writing */
@@ -267,7 +268,7 @@ OF SUCH DAMAGE.
#define ENET_MAC_DBG_TXFNE BIT(24) /*!< TxFIFO not empty flag */
#define ENET_MAC_DBG_TXFF BIT(25) /*!< TxFIFO full flag */
-/* ENET_MAC_INTF */
+/* ENET_MAC_INTF */
#define ENET_MAC_INTF_WUM BIT(3) /*!< WUM status */
#define ENET_MAC_INTF_MSC BIT(4) /*!< MSC status */
#define ENET_MAC_INTF_MSCR BIT(5) /*!< MSC receive status */
@@ -281,28 +282,28 @@ OF SUCH DAMAGE.
/* ENET_MAC_ADDR0H */
#define ENET_MAC_ADDR0H_ADDR0H BITS(0,15) /*!< MAC address0 high */
#define ENET_MAC_ADDR0H_MO BIT(31) /*!< always read 1 and must be kept */
-
+
/* ENET_MAC_ADDR0L */
#define ENET_MAC_ADDR0L_ADDR0L BITS(0,31) /*!< MAC address0 low */
-
+
/* ENET_MAC_ADDR1H */
#define ENET_MAC_ADDR1H_ADDR1H BITS(0,15) /*!< MAC address1 high */
-#define ENET_MAC_ADDR1H_MB BITS(24,29) /*!< mask byte */
+#define ENET_MAC_ADDR1H_MB BITS(24,29) /*!< mask byte */
#define ENET_MAC_ADDR1H_SAF BIT(30) /*!< source address filter */
#define ENET_MAC_ADDR1H_AFE BIT(31) /*!< address filter enable */
-
+
/* ENET_MAC_ADDR1L */
#define ENET_MAC_ADDR1L_ADDR1L BITS(0,31) /*!< MAC address1 low */
-
+
/* ENET_MAC_ADDR2H */
#define ENET_MAC_ADDR2H_ADDR2H BITS(0,15) /*!< MAC address2 high */
#define ENET_MAC_ADDR2H_MB BITS(24,29) /*!< mask byte */
#define ENET_MAC_ADDR2H_SAF BIT(30) /*!< source address filter */
#define ENET_MAC_ADDR2H_AFE BIT(31) /*!< address filter enable */
-
+
/* ENET_MAC_ADDR2L */
#define ENET_MAC_ADDR2L_ADDR2L BITS(0,31) /*!< MAC address2 low */
-
+
/* ENET_MAC_ADDR3H */
#define ENET_MAC_ADDR3H_ADDR3H BITS(0,15) /*!< MAC address3 high */
#define ENET_MAC_ADDR3H_MB BITS(24,29) /*!< mask byte */
@@ -311,11 +312,11 @@ OF SUCH DAMAGE.
/* ENET_MAC_ADDR3L */
#define ENET_MAC_ADDR3L_ADDR3L BITS(0,31) /*!< MAC address3 low */
-
+
/* ENET_MAC_FCTH */
#define ENET_MAC_FCTH_RFA BITS(0,2) /*!< threshold of active flow control */
#define ENET_MAC_FCTH_RFD BITS(4,6) /*!< threshold of deactive flow control */
-
+
/* ENET_MSC_CTL */
#define ENET_MSC_CTL_CTR BIT(0) /*!< counter reset */
#define ENET_MSC_CTL_CTSR BIT(1) /*!< counter stop rollover */
@@ -328,7 +329,7 @@ OF SUCH DAMAGE.
#define ENET_MSC_RINTF_RFCE BIT(5) /*!< received frames CRC error */
#define ENET_MSC_RINTF_RFAE BIT(6) /*!< received frames alignment error */
#define ENET_MSC_RINTF_RGUF BIT(17) /*!< receive good unicast frames */
-
+
/* ENET_MSC_TINTF */
#define ENET_MSC_TINTF_TGFSC BIT(14) /*!< transmitted good frames single collision */
#define ENET_MSC_TINTF_TGFMSC BIT(15) /*!< transmitted good frames more single collision */
@@ -338,30 +339,30 @@ OF SUCH DAMAGE.
#define ENET_MSC_RINTMSK_RFCEIM BIT(5) /*!< received frame CRC error interrupt mask */
#define ENET_MSC_RINTMSK_RFAEIM BIT(6) /*!< received frames alignment error interrupt mask */
#define ENET_MSC_RINTMSK_RGUFIM BIT(17) /*!< received good unicast frames interrupt mask */
-
+
/* ENET_MSC_TINTMSK */
#define ENET_MSC_TINTMSK_TGFSCIM BIT(14) /*!< transmitted good frames single collision interrupt mask */
#define ENET_MSC_TINTMSK_TGFMSCIM BIT(15) /*!< transmitted good frames more single collision interrupt mask */
#define ENET_MSC_TINTMSK_TGFIM BIT(21) /*!< transmitted good frames interrupt mask */
-
+
/* ENET_MSC_SCCNT */
#define ENET_MSC_SCCNT_SCC BITS(0,31) /*!< transmitted good frames single collision counter */
-
+
/* ENET_MSC_MSCCNT */
#define ENET_MSC_MSCCNT_MSCC BITS(0,31) /*!< transmitted good frames more one single collision counter */
-
+
/* ENET_MSC_TGFCNT */
#define ENET_MSC_TGFCNT_TGF BITS(0,31) /*!< transmitted good frames counter */
-
+
/* ENET_MSC_RFCECNT */
#define ENET_MSC_RFCECNT_RFCER BITS(0,31) /*!< received frames with CRC error counter */
-
+
/* ENET_MSC_RFAECNT */
#define ENET_MSC_RFAECNT_RFAER BITS(0,31) /*!< received frames alignment error counter */
-
+
/* ENET_MSC_RGUFCNT */
#define ENET_MSC_RGUFCNT_RGUF BITS(0,31) /*!< received good unicast frames counter */
-
+
/* ENET_PTP_TSCTL */
#define PTP_TSCTL_CKNT(regval) (BITS(16,17) & ((uint32_t)(regval) << 16)) /*!< write value to ENET_PTP_TSCTL_CKNT bit field */
@@ -381,37 +382,37 @@ OF SUCH DAMAGE.
#define ENET_PTP_TSCTL_MNMSEN BIT(15) /*!< received master node message snapshot enable */
#define ENET_PTP_TSCTL_CKNT BITS(16,17) /*!< clock node type for time stamp */
#define ENET_PTP_TSCTL_MAFEN BIT(18) /*!< MAC address filter enable for PTP frame */
-
+
/* ENET_PTP_SSINC */
#define ENET_PTP_SSINC_STMSSI BITS(0,7) /*!< system time subsecond increment */
-
+
/* ENET_PTP_TSH */
#define ENET_PTP_TSH_STMS BITS(0,31) /*!< system time second */
-
+
/* ENET_PTP_TSL */
#define ENET_PTP_TSL_STMSS BITS(0,30) /*!< system time subseconds */
#define ENET_PTP_TSL_STS BIT(31) /*!< system time sign */
-
+
/* ENET_PTP_TSUH */
#define ENET_PTP_TSUH_TMSUS BITS(0,31) /*!< timestamp update seconds */
-
+
/* ENET_PTP_TSUL */
#define ENET_PTP_TSUL_TMSUSS BITS(0,30) /*!< timestamp update subseconds */
#define ENET_PTP_TSUL_TMSUPNS BIT(31) /*!< timestamp update positive or negative sign */
/* ENET_PTP_TSADDAND */
#define ENET_PTP_TSADDAND_TMSA BITS(0,31) /*!< timestamp addend */
-
+
/* ENET_PTP_ETH */
#define ENET_PTP_ETH_ETSH BITS(0,31) /*!< expected time high */
-
+
/* ENET_PTP_ETL */
#define ENET_PTP_ETL_ETSL BITS(0,31) /*!< expected time low */
-
+
/* ENET_PTP_TSF */
#define ENET_PTP_TSF_TSSCO BIT(0) /*!< timestamp second counter overflow */
#define ENET_PTP_TSF_TTM BIT(1) /*!< target time match */
-
+
/* ENET_PTP_PPSCTL */
#define ENET_PTP_PPSCTL_PPSOFC BITS(0,3) /*!< PPS output frequency configure */
@@ -428,19 +429,19 @@ OF SUCH DAMAGE.
#define ENET_DMA_BCTL_FPBL BIT(24) /*!< four times PGBL mode */
#define ENET_DMA_BCTL_AA BIT(25) /*!< address-aligned */
#define ENET_DMA_BCTL_MB BIT(26) /*!< mixed burst */
-
+
/* ENET_DMA_TPEN */
#define ENET_DMA_TPEN_TPE BITS(0,31) /*!< transmit poll enable */
-
+
/* ENET_DMA_RPEN */
#define ENET_DMA_RPEN_RPE BITS(0,31) /*!< receive poll enable */
/* ENET_DMA_RDTADDR */
#define ENET_DMA_RDTADDR_SRT BITS(0,31) /*!< start address of receive table */
-
+
/* ENET_DMA_TDTADDR */
#define ENET_DMA_TDTADDR_STT BITS(0,31) /*!< start address of transmit table */
-
+
/* ENET_DMA_STAT */
#define ENET_DMA_STAT_TS BIT(0) /*!< transmit status */
#define ENET_DMA_STAT_TPS BIT(1) /*!< transmit process stopped status */
@@ -463,7 +464,7 @@ OF SUCH DAMAGE.
#define ENET_DMA_STAT_MSC BIT(27) /*!< MSC status */
#define ENET_DMA_STAT_WUM BIT(28) /*!< WUM status */
#define ENET_DMA_STAT_TST BIT(29) /*!< timestamp trigger status */
-
+
/* ENET_DMA_CTL */
#define ENET_DMA_CTL_SRE BIT(1) /*!< start/stop receive enable */
#define ENET_DMA_CTL_OSF BIT(2) /*!< operate on second frame */
@@ -477,7 +478,7 @@ OF SUCH DAMAGE.
#define ENET_DMA_CTL_DAFRF BIT(24) /*!< disable flushing of received frames */
#define ENET_DMA_CTL_RSFD BIT(25) /*!< receive store-and-forward */
#define ENET_DMA_CTL_DTCERFD BIT(26) /*!< dropping of TCP/IP checksum error frames disable */
-
+
/* ENET_DMA_INTEN */
#define ENET_DMA_INTEN_TIE BIT(0) /*!< transmit interrupt enable */
#define ENET_DMA_INTEN_TPSIE BIT(1) /*!< transmit process stopped interrupt enable */
@@ -494,7 +495,7 @@ OF SUCH DAMAGE.
#define ENET_DMA_INTEN_ERIE BIT(14) /*!< early receive interrupt enable */
#define ENET_DMA_INTEN_AIE BIT(15) /*!< abnormal interrupt summary enable */
#define ENET_DMA_INTEN_NIE BIT(16) /*!< normal interrupt summary enable */
-
+
/* ENET_DMA_MFBOCNT */
#define ENET_DMA_MFBOCNT_MSFC BITS(0,15) /*!< missed frames by the controller */
#define ENET_DMA_MFBOCNT_MSFA BITS(17,27) /*!< missed frames by the application */
@@ -507,10 +508,10 @@ OF SUCH DAMAGE.
/* ENET_DMA_CRDADDR */
#define ENET_DMA_CRDADDR_RDAP BITS(0,31) /*!< receive descriptor address pointer */
-
+
/* ENET_DMA_CTBADDR */
#define ENET_DMA_CTBADDR_TBAP BITS(0,31) /*!< transmit buffer address pointer */
-
+
/* ENET_DMA_CRBADDR */
#define ENET_DMA_CRBADDR_RBAP BITS(0,31) /*!< receive buffer address pointer */
@@ -570,7 +571,7 @@ OF SUCH DAMAGE.
#define ENET_RDES0_LCO BIT(6) /*!< late collision */
#define ENET_RDES0_IPHERR BIT(7) /*!< IP frame header error */
#define ENET_RDES0_TSV BIT(7) /*!< timestamp valid */
-#define ENET_RDES0_LDES BIT(8) /*!< last descriptor */
+#define ENET_RDES0_LDES BIT(8) /*!< last descriptor */
#define ENET_RDES0_FDES BIT(9) /*!< first descriptor */
#define ENET_RDES0_VTAG BIT(10) /*!< VLAN tag */
#define ENET_RDES0_OERR BIT(11) /*!< overflow Error */
@@ -582,7 +583,7 @@ OF SUCH DAMAGE.
#define ENET_RDES0_DAFF BIT(30) /*!< destination address filter fail */
#define ENET_RDES0_DAV BIT(31) /*!< descriptor available */
-/* ENET DMA Rx descriptor RDES1 */
+/* ENET DMA Rx descriptor RDES1 */
#define ENET_RDES1_RB1S BITS(0,12) /*!< receive buffer 1 size */
#define ENET_RDES1_RCHM BIT(14) /*!< receive chained mode for second address */
#define ENET_RDES1_RERM BIT(15) /*!< receive end of ring mode*/
@@ -624,7 +625,7 @@ OF SUCH DAMAGE.
#define ENET_RANGE(hclk, n, m) (((hclk) >= (n))&&((hclk) < (m)))
/* define MAC address configuration and reference address */
-#define ENET_SET_MACADDRH(p) (((uint32_t)(p)[5] << 8) | (uint32_t)(p)[4])
+#define ENET_SET_MACADDRH(p) (((uint32_t)(p)[5] << 8) | (uint32_t)(p)[4])
#define ENET_SET_MACADDRL(p) (((uint32_t)(p)[3] << 24) | ((uint32_t)(p)[2] << 16) | ((uint32_t)(p)[1] << 8) | (uint32_t)(p)[0])
#define ENET_ADDRH_BASE ((ENET) + 0x40U)
#define ENET_ADDRL_BASE ((ENET) + 0x44U)
@@ -646,7 +647,7 @@ OF SUCH DAMAGE.
#define MSC_RFCECNT_REG_OFFSET ((uint16_t)0x0194U) /*!< MSC received frames with CRC error counter register offset */
#define MSC_RFAECNT_REG_OFFSET ((uint16_t)0x0198U) /*!< MSC received frames with alignment error counter register offset */
#define MSC_RGUFCNT_REG_OFFSET ((uint16_t)0x01C4U) /*!< MSC received good unicast frames counter register offset */
-
+
#define PTP_TSF_REG_OFFSET ((uint16_t)0x0728U) /*!< PTP time stamp flag register offset */
#define DMA_STAT_REG_OFFSET ((uint16_t)0x1014U) /*!< DMA status register offset */
@@ -663,7 +664,7 @@ typedef enum
{
/* ENET_MAC_WUM register */
ENET_MAC_FLAG_MPKR = ENET_REGIDX_BIT(MAC_WUM_REG_OFFSET, 5U), /*!< magic packet received flag */
- ENET_MAC_FLAG_WUFR = ENET_REGIDX_BIT(MAC_WUM_REG_OFFSET, 6U), /*!< wakeup frame received flag */
+ ENET_MAC_FLAG_WUFR = ENET_REGIDX_BIT(MAC_WUM_REG_OFFSET, 6U), /*!< wakeup frame received flag */
/* ENET_MAC_FCTL register */
ENET_MAC_FLAG_FLOWCONTROL = ENET_REGIDX_BIT(MAC_FCTL_REG_OFFSET, 0U), /*!< flow control status flag */
/* ENET_MAC_INTF register */
@@ -673,13 +674,13 @@ typedef enum
ENET_MAC_FLAG_MSCT = ENET_REGIDX_BIT(MAC_INTF_REG_OFFSET, 6U), /*!< MSC transmit status flag */
ENET_MAC_FLAG_TMST = ENET_REGIDX_BIT(MAC_INTF_REG_OFFSET, 9U), /*!< timestamp trigger status flag */
/* ENET_PTP_TSF register */
- ENET_PTP_FLAG_TSSCO = ENET_REGIDX_BIT(PTP_TSF_REG_OFFSET, 0U), /*!< timestamp second counter overflow flag */
+ ENET_PTP_FLAG_TSSCO = ENET_REGIDX_BIT(PTP_TSF_REG_OFFSET, 0U), /*!< timestamp second counter overflow flag */
ENET_PTP_FLAG_TTM = ENET_REGIDX_BIT(PTP_TSF_REG_OFFSET, 1U), /*!< target time match flag */
/* ENET_MSC_RINTF register */
ENET_MSC_FLAG_RFCE = ENET_REGIDX_BIT(MSC_RINTF_REG_OFFSET, 5U), /*!< received frames CRC error flag */
ENET_MSC_FLAG_RFAE = ENET_REGIDX_BIT(MSC_RINTF_REG_OFFSET, 6U), /*!< received frames alignment error flag */
ENET_MSC_FLAG_RGUF = ENET_REGIDX_BIT(MSC_RINTF_REG_OFFSET, 17U), /*!< received good unicast frames flag */
- /* ENET_MSC_TINTF register */
+ /* ENET_MSC_TINTF register */
ENET_MSC_FLAG_TGFSC = ENET_REGIDX_BIT(MSC_TINTF_REG_OFFSET, 14U), /*!< transmitted good frames single collision flag */
ENET_MSC_FLAG_TGFMSC = ENET_REGIDX_BIT(MSC_TINTF_REG_OFFSET, 15U), /*!< transmitted good frames more single collision flag */
ENET_MSC_FLAG_TGF = ENET_REGIDX_BIT(MSC_TINTF_REG_OFFSET, 21U), /*!< transmitted good frames flag */
@@ -704,7 +705,7 @@ typedef enum
ENET_DMA_FLAG_EB_ACCESS_ERROR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 25U), /*!< error during data buffer/descriptor access flag */
ENET_DMA_FLAG_MSC = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 27U), /*!< MSC status flag */
ENET_DMA_FLAG_WUM = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 28U), /*!< WUM status flag */
- ENET_DMA_FLAG_TST = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 29U), /*!< timestamp trigger status flag */
+ ENET_DMA_FLAG_TST = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 29U), /*!< timestamp trigger status flag */
}enet_flag_enum;
/* ENET stutus flag clear */
@@ -725,7 +726,7 @@ typedef enum
ENET_DMA_FLAG_FBE_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 13U), /*!< fatal bus error status flag */
ENET_DMA_FLAG_ER_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 14U), /*!< early receive status flag */
ENET_DMA_FLAG_AI_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 15U), /*!< abnormal interrupt summary flag */
- ENET_DMA_FLAG_NI_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 16U), /*!< normal interrupt summary flag */
+ ENET_DMA_FLAG_NI_CLR = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 16U), /*!< normal interrupt summary flag */
}enet_flag_clear_enum;
/* ENET interrupt enable/disable */
@@ -734,15 +735,15 @@ typedef enum
/* ENET_MAC_INTMSK register */
ENET_MAC_INT_WUMIM = ENET_REGIDX_BIT(MAC_INTMSK_REG_OFFSET, 3U), /*!< WUM interrupt mask */
ENET_MAC_INT_TMSTIM = ENET_REGIDX_BIT(MAC_INTMSK_REG_OFFSET, 9U), /*!< timestamp trigger interrupt mask */
- /* ENET_MSC_RINTMSK register */
+ /* ENET_MSC_RINTMSK register */
ENET_MSC_INT_RFCEIM = ENET_REGIDX_BIT(MSC_RINTMSK_REG_OFFSET, 5U), /*!< received frame CRC error interrupt mask */
ENET_MSC_INT_RFAEIM = ENET_REGIDX_BIT(MSC_RINTMSK_REG_OFFSET, 6U), /*!< received frames alignment error interrupt mask */
ENET_MSC_INT_RGUFIM = ENET_REGIDX_BIT(MSC_RINTMSK_REG_OFFSET, 17U), /*!< received good unicast frames interrupt mask */
- /* ENET_MSC_TINTMSK register */
+ /* ENET_MSC_TINTMSK register */
ENET_MSC_INT_TGFSCIM = ENET_REGIDX_BIT(MSC_TINTMSK_REG_OFFSET, 14U), /*!< transmitted good frames single collision interrupt mask */
ENET_MSC_INT_TGFMSCIM = ENET_REGIDX_BIT(MSC_TINTMSK_REG_OFFSET, 15U), /*!< transmitted good frames more single collision interrupt mask */
ENET_MSC_INT_TGFIM = ENET_REGIDX_BIT(MSC_TINTMSK_REG_OFFSET, 21U), /*!< transmitted good frames interrupt mask */
- /* ENET_DMA_INTEN register */
+ /* ENET_DMA_INTEN register */
ENET_DMA_INT_TIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 0U), /*!< transmit interrupt enable */
ENET_DMA_INT_TPSIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 1U), /*!< transmit process stopped interrupt enable */
ENET_DMA_INT_TBUIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 2U), /*!< transmit buffer unavailable interrupt enable */
@@ -759,7 +760,7 @@ typedef enum
ENET_DMA_INT_AIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 15U), /*!< abnormal interrupt summary enable */
ENET_DMA_INT_NIE = ENET_REGIDX_BIT(DMA_INTEN_REG_OFFSET, 16U), /*!< normal interrupt summary enable */
}enet_int_enum;
-
+
/* ENET interrupt flag get */
typedef enum
{
@@ -795,7 +796,7 @@ typedef enum
ENET_DMA_INT_FLAG_NI = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 16U), /*!< normal interrupt summary flag */
ENET_DMA_INT_FLAG_MSC = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 27U), /*!< MSC status flag */
ENET_DMA_INT_FLAG_WUM = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 28U), /*!< WUM status flag */
- ENET_DMA_INT_FLAG_TST = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 29U), /*!< timestamp trigger status flag */
+ ENET_DMA_INT_FLAG_TST = ENET_REGIDX_BIT(DMA_STAT_REG_OFFSET, 29U), /*!< timestamp trigger status flag */
}enet_int_flag_enum;
/* ENET interrupt flag clear */
@@ -839,7 +840,7 @@ typedef enum
ENET_MSC_RX_RFCECNT = MSC_RFCECNT_REG_OFFSET, /*!< MSC received frames with CRC error counter */
ENET_MSC_RX_RFAECNT = MSC_RFAECNT_REG_OFFSET, /*!< MSC received frames with alignment error counter */
ENET_MSC_RX_RGUFCNT = MSC_RGUFCNT_REG_OFFSET /*!< MSC received good unicast frames counter */
-}enet_msc_counter_enum;
+}enet_msc_counter_enum;
/* function option, used for ENET initialization */
typedef enum
@@ -919,7 +920,7 @@ typedef enum
ENET_REG_WRITE /*!< write register */
}enet_regdirection_enum;
-/* ENET MAC addresses */
+/* ENET MAC addresses */
typedef enum
{
ENET_MAC_ADDRESS0 = ((uint32_t)0x00000000), /*!< MAC address0 */
@@ -953,7 +954,7 @@ typedef enum{
ENET_CKNT_END_TO_END = PTP_TSCTL_CKNT(2), /*!< type of end-to-end transparent clock node type for timestamp */
ENET_CKNT_PEER_TO_PEER = PTP_TSCTL_CKNT(3), /*!< type of peer-to-peer transparent clock node type for timestamp */
ENET_PTP_SYSTIME_INIT = ENET_PTP_TSCTL_TMSSTI, /*!< timestamp initialize */
- ENET_PTP_SYSTIME_UPDATE = ENET_PTP_TSCTL_TMSSTU, /*!< timestamp update */
+ ENET_PTP_SYSTIME_UPDATE = ENET_PTP_TSCTL_TMSSTU, /*!< timestamp update */
ENET_PTP_ADDEND_UPDATE = ENET_PTP_TSCTL_TMSARU, /*!< addend register update */
ENET_PTP_FINEMODE = (int32_t)(ENET_PTP_TSCTL_TMSFCU| BIT(31)), /*!< the system timestamp uses the fine method for updating */
ENET_PTP_COARSEMODE = ENET_PTP_TSCTL_TMSFCU, /*!< the system timestamp uses the coarse method for updating */
@@ -971,24 +972,24 @@ typedef enum{
typedef struct
{
uint32_t option_enable; /*!< select which function to configure */
- uint32_t forward_frame; /*!< frame forward related parameters */
+ uint32_t forward_frame; /*!< frame forward related parameters */
uint32_t dmabus_mode; /*!< DMA bus mode related parameters */
uint32_t dma_maxburst; /*!< DMA max burst related parameters */
uint32_t dma_arbitration; /*!< DMA Tx and Rx arbitration related parameters */
uint32_t store_forward_mode; /*!< store forward mode related parameters */
uint32_t dma_function; /*!< DMA control related parameters */
- uint32_t vlan_config; /*!< VLAN tag related parameters */
+ uint32_t vlan_config; /*!< VLAN tag related parameters */
uint32_t flow_control; /*!< flow control related parameters */
uint32_t hashtable_high; /*!< hash list high 32-bit related parameters */
uint32_t hashtable_low; /*!< hash list low 32-bit related parameters */
uint32_t framesfilter_mode; /*!< frame filter control related parameters */
- uint32_t halfduplex_param; /*!< halfduplex related parameters */
+ uint32_t halfduplex_param; /*!< halfduplex related parameters */
uint32_t timer_config; /*!< frame timer related parameters */
uint32_t interframegap; /*!< inter frame gap related parameters */
}enet_initpara_struct;
-/* structure for ENET DMA desciptors */
-typedef struct
+/* structure for ENET DMA desciptors */
+typedef struct
{
uint32_t status; /*!< status */
uint32_t control_buffer_size; /*!< control and buffer1, buffer2 lengths */
@@ -999,12 +1000,12 @@ typedef struct
uint32_t extended_status; /*!< extended status */
uint32_t reserved; /*!< reserved */
uint32_t timestamp_low; /*!< timestamp low */
- uint32_t timestamp_high; /*!< timestamp high */
-#endif /* SELECT_DESCRIPTORS_ENHANCED_MODE */
-
+ uint32_t timestamp_high; /*!< timestamp high */
+#endif /* SELECT_DESCRIPTORS_ENHANCED_MODE */
+
} enet_descriptors_struct;
-/* structure of PTP system time */
+/* structure of PTP system time */
typedef struct
{
uint32_t second; /*!< second of system time */
@@ -1017,10 +1018,10 @@ typedef struct
#define ENET_BACKOFFLIMIT_10 MAC_CFG_BOL(0) /*!< min (n, 10) */
#define ENET_BACKOFFLIMIT_8 MAC_CFG_BOL(1) /*!< min (n, 8) */
#define ENET_BACKOFFLIMIT_4 MAC_CFG_BOL(2) /*!< min (n, 4) */
-#define ENET_BACKOFFLIMIT_1 MAC_CFG_BOL(3) /*!< min (n, 1) */
+#define ENET_BACKOFFLIMIT_1 MAC_CFG_BOL(3) /*!< min (n, 1) */
#define MAC_CFG_IGBS(regval) (BITS(17,19) & ((uint32_t)(regval) << 17)) /*!< write value to ENET_MAC_CFG_IGBS bit field */
-#define ENET_INTERFRAMEGAP_96BIT MAC_CFG_IGBS(0) /*!< minimum 96 bit times */
+#define ENET_INTERFRAMEGAP_96BIT MAC_CFG_IGBS(0) /*!< minimum 96 bit times */
#define ENET_INTERFRAMEGAP_88BIT MAC_CFG_IGBS(1) /*!< minimum 88 bit times */
#define ENET_INTERFRAMEGAP_80BIT MAC_CFG_IGBS(2) /*!< minimum 80 bit times */
#define ENET_INTERFRAMEGAP_72BIT MAC_CFG_IGBS(3) /*!< minimum 72 bit times */
@@ -1035,13 +1036,13 @@ typedef struct
#define ENET_WATCHDOG_ENABLE ((uint32_t)0x00000000U) /*!< the MAC allows no more than 2048 bytes of the frame being received */
#define ENET_WATCHDOG_DISABLE ENET_MAC_CFG_WDD /*!< the MAC disables the watchdog timer on the receiver, and can receive frames of up to 16384 bytes */
-
+
#define ENET_JABBER_ENABLE ((uint32_t)0x00000000U) /*!< the maximum transmission byte is 2048 */
#define ENET_JABBER_DISABLE ENET_MAC_CFG_JBD /*!< the maximum transmission byte can be 16384 */
#define ENET_CARRIERSENSE_ENABLE ((uint32_t)0x00000000U) /*!< the MAC transmitter generates carrier sense error and aborts the transmission */
#define ENET_CARRIERSENSE_DISABLE ENET_MAC_CFG_CSD /*!< the MAC transmitter ignores the MII CRS signal during frame transmission in half-duplex mode */
-
+
#define ENET_SPEEDMODE_10M ((uint32_t)0x00000000U) /*!< 10 Mbit/s */
#define ENET_SPEEDMODE_100M ENET_MAC_CFG_SPD /*!< 100 Mbit/s */
@@ -1073,10 +1074,10 @@ typedef struct
#define ENET_PCFRM_PREVENT_PAUSEFRAME MAC_FRMF_PCFRM(1) /*!< MAC only forwards all other control frames except pause control frame */
#define ENET_PCFRM_FORWARD_ALL MAC_FRMF_PCFRM(2) /*!< MAC forwards all control frames to application even if they fail the address filter */
#define ENET_PCFRM_FORWARD_FILTERED MAC_FRMF_PCFRM(3) /*!< MAC forwards control frames that only pass the address filter */
-
+
#define ENET_RX_FILTER_DISABLE ENET_MAC_FRMF_FAR /*!< all received frame are forwarded to application */
#define ENET_RX_FILTER_ENABLE ((uint32_t)0x00000000U) /*!< only the frame passed the filter can be forwarded to application */
-
+
#define ENET_SRC_FILTER_NORMAL_ENABLE ENET_MAC_FRMF_SAFLT /*!< filter source address */
#define ENET_SRC_FILTER_INVERSE_ENABLE (ENET_MAC_FRMF_SAFLT | ENET_MAC_FRMF_SAIFLT) /*!< inverse source address filtering result */
#define ENET_SRC_FILTER_DISABLE ((uint32_t)0x00000000U) /*!< source address function in filter disable */
@@ -1085,14 +1086,14 @@ typedef struct
#define ENET_BROADCASTFRAMES_ENABLE ((uint32_t)0x00000000U) /*!< the address filters pass all received broadcast frames */
#define ENET_BROADCASTFRAMES_DISABLE ENET_MAC_FRMF_BFRMD /*!< the address filters filter all incoming broadcast frames */
-
+
#define ENET_DEST_FILTER_INVERSE_ENABLE ENET_MAC_FRMF_DAIFLT /*!< inverse DA filtering result */
#define ENET_DEST_FILTER_INVERSE_DISABLE ((uint32_t)0x00000000U) /*!< not inverse DA filtering result */
#define ENET_DEST_FILTER_INVERSE ENET_MAC_FRMF_DAIFLT /*!< inverse DA filtering result function */
#define ENET_PROMISCUOUS_ENABLE ENET_MAC_FRMF_PM /*!< promiscuous mode enabled */
#define ENET_PROMISCUOUS_DISABLE ((uint32_t)0x00000000U) /*!< promiscuous mode disabled */
-
+
#define ENET_MULTICAST_FILTER_HASH_OR_PERFECT (ENET_MAC_FRMF_HMF | ENET_MAC_FRMF_HPFLT) /*!< pass multicast frames that match either the perfect or the hash filtering */
#define ENET_MULTICAST_FILTER_HASH ENET_MAC_FRMF_HMF /*!< pass multicast frames that match the hash filtering */
#define ENET_MULTICAST_FILTER_PERFECT ((uint32_t)0x00000000U) /*!< pass multicast frames that match the perfect filtering */
@@ -1112,7 +1113,7 @@ typedef struct
#define ENET_MDC_HCLK_DIV62 MAC_PHY_CTL_CLR(1) /*!< HCLK:100-150 MHz; MDC clock= HCLK/62 */
#define ENET_MDC_HCLK_DIV16 MAC_PHY_CTL_CLR(2) /*!< HCLK:20-35 MHz; MDC clock= HCLK/16 */
#define ENET_MDC_HCLK_DIV26 MAC_PHY_CTL_CLR(3) /*!< HCLK:35-60 MHz; MDC clock= HCLK/26 */
-#define ENET_MDC_HCLK_DIV102 MAC_PHY_CTL_CLR(4) /*!< HCLK:150-200 MHz; MDC clock= HCLK/102 */
+#define ENET_MDC_HCLK_DIV102 MAC_PHY_CTL_CLR(4) /*!< HCLK:150-240 MHz; MDC clock= HCLK/102 */
#define MAC_PHY_CTL_PR(regval) (BITS(6,10) & ((uint32_t)(regval) << 6)) /*!< write value to ENET_MAC_PHY_CTL_PR bit field */
@@ -1126,7 +1127,7 @@ typedef struct
#define ENET_PAUSETIME_MINUS4 MAC_FCTL_PLTS(0) /*!< pause time minus 4 slot times */
#define ENET_PAUSETIME_MINUS28 MAC_FCTL_PLTS(1) /*!< pause time minus 28 slot times */
#define ENET_PAUSETIME_MINUS144 MAC_FCTL_PLTS(2) /*!< pause time minus 144 slot times */
-#define ENET_PAUSETIME_MINUS256 MAC_FCTL_PLTS(3) /*!< pause time minus 256 slot times */
+#define ENET_PAUSETIME_MINUS256 MAC_FCTL_PLTS(3) /*!< pause time minus 256 slot times */
#define ENET_ZERO_QUANTA_PAUSE_ENABLE ((uint32_t)0x00000000U) /*!< enable the automatic zero-quanta generation function */
#define ENET_ZERO_QUANTA_PAUSE_DISABLE ENET_MAC_FCTL_DZQP /*!< disable the automatic zero-quanta generation function */
@@ -1134,7 +1135,7 @@ typedef struct
#define ENET_MAC0_AND_UNIQUE_ADDRESS_PAUSEDETECT ENET_MAC_FCTL_UPFDT /*!< besides the unique multicast address, MAC also use the MAC0 address to detect pause frame */
#define ENET_UNIQUE_PAUSEDETECT ((uint32_t)0x00000000U) /*!< only the unique multicast address for pause frame which is specified in IEEE802.3 can be detected */
-
+
#define ENET_RX_FLOWCONTROL_ENABLE ENET_MAC_FCTL_RFCEN /*!< enable decoding function for the received pause frame and process it */
#define ENET_RX_FLOWCONTROL_DISABLE ((uint32_t)0x00000000U) /*!< decode function for pause frame is disabled */
#define ENET_RX_FLOWCONTROL ENET_MAC_FCTL_RFCEN /*!< decoding function for the received pause frame and process it */
@@ -1146,21 +1147,21 @@ typedef struct
#define ENET_BACK_PRESSURE_ENABLE ENET_MAC_FCTL_FLCBBKPA /*!< enable the back pressure operation in the MAC */
#define ENET_BACK_PRESSURE_DISABLE ((uint32_t)0x00000000U) /*!< disable the back pressure operation in the MAC */
#define ENET_BACK_PRESSURE ENET_MAC_FCTL_FLCBBKPA /*!< the back pressure operation in the MAC */
-
+
#define MAC_FCTL_PTM(regval) (BITS(16,31) & ((uint32_t)(regval) << 16)) /*!< write value to ENET_MAC_FCTL_PTM bit field */
/* mac_vlt register value */
#define MAC_VLT_VLTI(regval) (BITS(0,15) & ((uint32_t)(regval) << 0)) /*!< write value to ENET_MAC_VLT_VLTI bit field */
-
+
#define ENET_VLANTAGCOMPARISON_12BIT ENET_MAC_VLT_VLTC /*!< only low 12 bits of the VLAN tag are used for comparison */
#define ENET_VLANTAGCOMPARISON_16BIT ((uint32_t)0x00000000U) /*!< all 16 bits of the VLAN tag are used for comparison */
-/* mac_wum register value */
+/* mac_wum register value */
#define ENET_WUM_FLAG_WUFFRPR ENET_MAC_WUM_WUFFRPR /*!< wakeup frame filter register poniter reset */
#define ENET_WUM_FLAG_WUFR ENET_MAC_WUM_WUFR /*!< wakeup frame received */
#define ENET_WUM_FLAG_MPKR ENET_MAC_WUM_MPKR /*!< magic packet received */
-#define ENET_WUM_POWER_DOWN ENET_MAC_WUM_PWD /*!< power down mode */
-#define ENET_WUM_MAGIC_PACKET_FRAME ENET_MAC_WUM_MPEN /*!< enable a wakeup event due to magic packet reception */
-#define ENET_WUM_WAKE_UP_FRAME ENET_MAC_WUM_WFEN /*!< enable a wakeup event due to wakeup frame reception */
+#define ENET_WUM_POWER_DOWN ENET_MAC_WUM_PWD /*!< power down mode */
+#define ENET_WUM_MAGIC_PACKET_FRAME ENET_MAC_WUM_MPEN /*!< enable a wakeup event due to magic packet reception */
+#define ENET_WUM_WAKE_UP_FRAME ENET_MAC_WUM_WFEN /*!< enable a wakeup event due to wakeup frame reception */
#define ENET_WUM_GLOBAL_UNICAST ENET_MAC_WUM_GU /*!< any received unicast frame passed filter is considered to be a wakeup frame */
/* mac_dbg register value */
@@ -1202,9 +1203,9 @@ typedef struct
#define ENET_ADDRESS_FILTER_SA BIT(30) /*!< use MAC address[47:0] is to compare with the SA fields of the received frame */
#define ENET_ADDRESS_FILTER_DA ((uint32_t)0x00000000) /*!< use MAC address[47:0] is to compare with the DA fields of the received frame */
-
+
/* mac_fcth register value */
-#define MAC_FCTH_RFA(regval) ((BITS(0,2) & ((uint32_t)(regval) << 0))<<8) /*!< write value to ENET_MAC_FCTH_RFA bit field */
+#define MAC_FCTH_RFA(regval) ((BITS(0,2) & ((uint32_t)(regval) << 0)) << 8) /*!< write value to ENET_MAC_FCTH_RFA bit field */
#define ENET_ACTIVE_THRESHOLD_256BYTES MAC_FCTH_RFA(0) /*!< threshold level is 256 bytes */
#define ENET_ACTIVE_THRESHOLD_512BYTES MAC_FCTH_RFA(1) /*!< threshold level is 512 bytes */
#define ENET_ACTIVE_THRESHOLD_768BYTES MAC_FCTH_RFA(2) /*!< threshold level is 768 bytes */
@@ -1213,7 +1214,7 @@ typedef struct
#define ENET_ACTIVE_THRESHOLD_1536BYTES MAC_FCTH_RFA(5) /*!< threshold level is 1536 bytes */
#define ENET_ACTIVE_THRESHOLD_1792BYTES MAC_FCTH_RFA(6) /*!< threshold level is 1792 bytes */
-#define MAC_FCTH_RFD(regval) ((BITS(4,6) & ((uint32_t)(regval) << 4))<<8) /*!< write value to ENET_MAC_FCTH_RFD bit field */
+#define MAC_FCTH_RFD(regval) ((BITS(4,6) & ((uint32_t)(regval) << 4)) << 8) /*!< write value to ENET_MAC_FCTH_RFD bit field */
#define ENET_DEACTIVE_THRESHOLD_256BYTES MAC_FCTH_RFD(0) /*!< threshold level is 256 bytes */
#define ENET_DEACTIVE_THRESHOLD_512BYTES MAC_FCTH_RFD(1) /*!< threshold level is 512 bytes */
#define ENET_DEACTIVE_THRESHOLD_768BYTES MAC_FCTH_RFD(2) /*!< threshold level is 768 bytes */
@@ -1241,7 +1242,7 @@ typedef struct
/* ptp_tsl register value */
#define GET_PTP_TSL_STMSS(regval) GET_BITS((uint32_t)(regval),0,30) /*!< get value of ENET_PTP_TSL_STMSS bit field */
-
+
#define ENET_PTP_TIME_POSITIVE ((uint32_t)0x00000000) /*!< time value is positive */
#define ENET_PTP_TIME_NEGATIVE ENET_PTP_TSL_STS /*!< time value is negative */
@@ -1285,7 +1286,7 @@ typedef struct
#define ENET_PGBL_4BEAT DMA_BCTL_PGBL(4) /*!< maximum number of beats is 4 */
#define ENET_PGBL_8BEAT DMA_BCTL_PGBL(8) /*!< maximum number of beats is 8 */
#define ENET_PGBL_16BEAT DMA_BCTL_PGBL(16) /*!< maximum number of beats is 16 */
-#define ENET_PGBL_32BEAT DMA_BCTL_PGBL(32) /*!< maximum number of beats is 32 */
+#define ENET_PGBL_32BEAT DMA_BCTL_PGBL(32) /*!< maximum number of beats is 32 */
#define ENET_PGBL_4xPGBL_4BEAT (DMA_BCTL_PGBL(1)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats is 4 */
#define ENET_PGBL_4xPGBL_8BEAT (DMA_BCTL_PGBL(2)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats is 8 */
#define ENET_PGBL_4xPGBL_16BEAT (DMA_BCTL_PGBL(4)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats is 16 */
@@ -1297,7 +1298,7 @@ typedef struct
#define ENET_ARBITRATION_RXTX_1_1 DMA_BCTL_RTPR(0) /*!< receive and transmit priority ratio is 1:1*/
#define ENET_ARBITRATION_RXTX_2_1 DMA_BCTL_RTPR(1) /*!< receive and transmit priority ratio is 2:1*/
#define ENET_ARBITRATION_RXTX_3_1 DMA_BCTL_RTPR(2) /*!< receive and transmit priority ratio is 3:1 */
-#define ENET_ARBITRATION_RXTX_4_1 DMA_BCTL_RTPR(3) /*!< receive and transmit priority ratio is 4:1 */
+#define ENET_ARBITRATION_RXTX_4_1 DMA_BCTL_RTPR(3) /*!< receive and transmit priority ratio is 4:1 */
#define ENET_ARBITRATION_RXPRIORTX ENET_DMA_BCTL_DAB /*!< RxDMA has higher priority than TxDMA */
#define ENET_FIXED_BURST_ENABLE ENET_DMA_BCTL_FB /*!< AHB can only use SINGLE/INCR4/INCR8/INCR16 during start of normal burst transfers */
@@ -1309,13 +1310,13 @@ typedef struct
#define ENET_RXDP_4BEAT DMA_BCTL_RXDP(4) /*!< maximum number of beats 4 */
#define ENET_RXDP_8BEAT DMA_BCTL_RXDP(8) /*!< maximum number of beats 8 */
#define ENET_RXDP_16BEAT DMA_BCTL_RXDP(16) /*!< maximum number of beats 16 */
-#define ENET_RXDP_32BEAT DMA_BCTL_RXDP(32) /*!< maximum number of beats 32 */
+#define ENET_RXDP_32BEAT DMA_BCTL_RXDP(32) /*!< maximum number of beats 32 */
#define ENET_RXDP_4xPGBL_4BEAT (DMA_BCTL_RXDP(1)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats 4 */
#define ENET_RXDP_4xPGBL_8BEAT (DMA_BCTL_RXDP(2)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats 8 */
#define ENET_RXDP_4xPGBL_16BEAT (DMA_BCTL_RXDP(4)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats 16 */
#define ENET_RXDP_4xPGBL_32BEAT (DMA_BCTL_RXDP(8)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats 32 */
#define ENET_RXDP_4xPGBL_64BEAT (DMA_BCTL_RXDP(16)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats 64 */
-#define ENET_RXDP_4xPGBL_128BEAT (DMA_BCTL_RXDP(32)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats 128 */
+#define ENET_RXDP_4xPGBL_128BEAT (DMA_BCTL_RXDP(32)|ENET_DMA_BCTL_FPBL) /*!< maximum number of beats 128 */
#define ENET_RXTX_DIFFERENT_PGBL ENET_DMA_BCTL_UIP /*!< RxDMA uses the RXDP[5:0], while TxDMA uses the PGBL[5:0] */
#define ENET_RXTX_SAME_PGBL ((uint32_t)0x00000000) /*!< RxDMA/TxDMA uses PGBL[5:0] */
@@ -1378,13 +1379,13 @@ typedef struct
#define ENET_TX_MODE_STOREFORWARD ENET_DMA_CTL_TSFD /*!< TxFIFO operates in store-and-forward mode */
#define ENET_TX_MODE_CUTTHROUGH ((uint32_t)0x00000000) /*!< TxFIFO operates in cut-through mode */
-#define ENET_FORWARD_ERRFRAMES_ENABLE (ENET_DMA_CTL_FERF<<2) /*!< all frame received with error except runt error are forwarded to memory */
+#define ENET_FORWARD_ERRFRAMES_ENABLE (ENET_DMA_CTL_FERF << 2) /*!< all frame received with error except runt error are forwarded to memory */
#define ENET_FORWARD_ERRFRAMES_DISABLE ((uint32_t)0x00000000) /*!< RxFIFO drop error frame */
-#define ENET_FORWARD_ERRFRAMES (ENET_DMA_CTL_FERF<<2) /*!< the function that all frame received with error except runt error are forwarded to memory */
+#define ENET_FORWARD_ERRFRAMES (ENET_DMA_CTL_FERF << 2) /*!< the function that all frame received with error except runt error are forwarded to memory */
-#define ENET_FORWARD_UNDERSZ_GOODFRAMES_ENABLE (ENET_DMA_CTL_FUF<<2) /*!< forward undersized good frames */
-#define ENET_FORWARD_UNDERSZ_GOODFRAMES_DISABLE ((uint32_t)0x00000000) /*!< RxFIFO drops all frames whose length is less than 64 bytes */
-#define ENET_FORWARD_UNDERSZ_GOODFRAMES (ENET_DMA_CTL_FUF<<2) /*!< the function that forwarding undersized good frames */
+#define ENET_FORWARD_UNDERSZ_GOODFRAMES_ENABLE (ENET_DMA_CTL_FUF << 2) /*!< forward undersized good frames */
+#define ENET_FORWARD_UNDERSZ_GOODFRAMES_DISABLE ((uint32_t)0x00000000) /*!< RxFIFO drops all frames whose length is less than 64 bytes */
+#define ENET_FORWARD_UNDERSZ_GOODFRAMES (ENET_DMA_CTL_FUF << 2) /*!< the function that forwarding undersized good frames */
#define ENET_SECONDFRAME_OPT_ENABLE ENET_DMA_CTL_OSF /*!< TxDMA controller operate on second frame mode enable*/
#define ENET_SECONDFRAME_OPT_DISABLE ((uint32_t)0x00000000) /*!< TxDMA controller operate on second frame mode disable */
@@ -1402,10 +1403,10 @@ typedef struct
#define GET_TDES0_COCNT(regval) GET_BITS((regval),3,6) /*!< get value of ENET DMA TDES0 CONT bit field */
#define TDES0_CM(regval) (BITS(22,23) & ((uint32_t)(regval) << 22)) /*!< write value to ENET DMA TDES0 CM bit field */
-#define ENET_CHECKSUM_DISABLE TDES0_CM(0) /*!< checksum insertion disabled */
-#define ENET_CHECKSUM_IPV4HEADER TDES0_CM(1) /*!< only IP header checksum calculation and insertion are enabled */
-#define ENET_CHECKSUM_TCPUDPICMP_SEGMENT TDES0_CM(2) /*!< TCP/UDP/ICMP checksum insertion calculated but pseudo-header */
-#define ENET_CHECKSUM_TCPUDPICMP_FULL TDES0_CM(3) /*!< TCP/UDP/ICMP checksum insertion fully calculated */
+#define ENET_CHECKSUM_DISABLE TDES0_CM(0) /*!< checksum insertion disabled */
+#define ENET_CHECKSUM_IPV4HEADER TDES0_CM(1) /*!< only IP header checksum calculation and insertion are enabled */
+#define ENET_CHECKSUM_TCPUDPICMP_SEGMENT TDES0_CM(2) /*!< TCP/UDP/ICMP checksum insertion calculated but pseudo-header */
+#define ENET_CHECKSUM_TCPUDPICMP_FULL TDES0_CM(3) /*!< TCP/UDP/ICMP checksum insertion fully calculated */
/* dma tx descriptor tdes1 register value */
#define TDES1_TB1S(regval) (BITS(0,12) & ((uint32_t)(regval) << 0)) /*!< write value to ENET DMA TDES1 TB1S bit field */
@@ -1444,13 +1445,13 @@ typedef struct
#else
#define ETH_DMATXDESC_SIZE ((uint32_t)0x00000010U) /*!< TxDMA descriptor size */
#define ETH_DMARXDESC_SIZE ((uint32_t)0x00000010U) /*!< RxDMA descriptor size */
-#endif /* SELECT_DESCRIPTORS_ENHANCED_MODE */
+#endif /* SELECT_DESCRIPTORS_ENHANCED_MODE */
/* ENET remote wake-up frame register length */
#define ETH_WAKEUP_REGISTER_LENGTH 8U /*!< remote wake-up frame register length */
-/* ENET frame size */
-#define ENET_MAX_FRAME_SIZE 1524U /*!< header + frame_extra + payload + CRC */
+/* ENET frame size */
+#define ENET_MAX_FRAME_SIZE 1524U /*!< header + frame_extra + payload + CRC */
/* ENET delay timeout */
#define ENET_DELAY_TO ((uint32_t)0x0004FFFFU) /*!< ENET delay timeout */
@@ -1485,12 +1486,12 @@ ErrStatus enet_frame_transmit(uint8_t *buffer, uint32_t length);
/* configure the transmit IP frame checksum offload calculation and insertion */
void enet_transmit_checksum_config(enet_descriptors_struct *desc, uint32_t checksum);
/* ENET Tx and Rx function enable (include MAC and DMA module) */
-void enet_enable(void);
+void enet_enable(void);
/* ENET Tx and Rx function disable (include MAC and DMA module) */
void enet_disable(void);
/* configure MAC address */
void enet_mac_address_set(enet_macaddress_enum mac_addr, uint8_t paddr[]);
-/* get MAC address */
+/* get MAC address */
void enet_mac_address_get(enet_macaddress_enum mac_addr, uint8_t paddr[]);
/* get the ENET MAC/MSC/PTP/DMA status flag */
@@ -1558,7 +1559,7 @@ void enet_flowcontrol_feature_disable(uint32_t feature);
/* DMA function */
/* get the dma transmit/receive process state */
-uint32_t enet_dmaprocess_state_get(enet_dmadirection_enum direction);
+uint32_t enet_dmaprocess_state_get(enet_dmadirection_enum direction);
/* poll the dma transmission/reception enable */
void enet_dmaprocess_resume(enet_dmadirection_enum direction);
/* check and recover the Rx process */
@@ -1578,7 +1579,7 @@ FlagStatus enet_desc_flag_get(enet_descriptors_struct *desc, uint32_t desc_flag)
/* set the bit flag of ENET dma tx descriptor */
void enet_desc_flag_set(enet_descriptors_struct *desc, uint32_t desc_flag);
/* clear the bit flag of ENET dma tx descriptor */
-void enet_desc_flag_clear(enet_descriptors_struct *desc, uint32_t desc_flag);
+void enet_desc_flag_clear(enet_descriptors_struct *desc, uint32_t desc_flag);
/* when receiving the completed, set RS bit in ENET_DMA_STAT register will immediately set */
void enet_rx_desc_immediate_receive_complete_interrupt(enet_descriptors_struct *desc);
/* when receiving the completed, set RS bit in ENET_DMA_STAT register will is set after a configurable delay time */
@@ -1642,13 +1643,13 @@ void enet_wum_feature_disable(uint32_t feature);
/* MSC function */
/* reset the MAC statistics counters */
void enet_msc_counters_reset(void);
-/* enable the MAC statistics counter features */
+/* enable the MAC statistics counter features */
void enet_msc_feature_enable(uint32_t feature);
-/* disable the MAC statistics counter features */
+/* disable the MAC statistics counter features */
void enet_msc_feature_disable(uint32_t feature);
/* configure MAC statistics counters preset mode */
void enet_msc_counters_preset_config(enet_msc_preset_enum mode);
-/* get MAC statistics counter */
+/* get MAC statistics counter */
uint32_t enet_msc_counters_get(enet_msc_counter_enum counter);
/* PTP function */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_exmc.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_exmc.h
index 94baf2f6f3..e46ec388a5 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_exmc.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_exmc.h
@@ -1,36 +1,38 @@
/*!
\file gd32f4xx_exmc.h
\brief definitions for the EXMC
-
+
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
+ \version 2022-06-08, V3.0.1, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -113,13 +115,13 @@ OF SUCH DAMAGE.
#define EXMC_SNCTL_NRWTPOL BIT(9) /*!< NWAIT signal polarity */
#define EXMC_SNCTL_WRAPEN BIT(10) /*!< wrapped burst mode enable */
#define EXMC_SNCTL_NRWTCFG BIT(11) /*!< NWAIT signal configuration, only work in synchronous mode */
-#define EXMC_SNCTL_WREN BIT(12) /*!< write enable */
+#define EXMC_SNCTL_WEN BIT(12) /*!< write enable */
#define EXMC_SNCTL_NRWTEN BIT(13) /*!< NWAIT signal enable */
#define EXMC_SNCTL_EXMODEN BIT(14) /*!< extended mode enable */
-#define EXMC_SNCTL_ASYNCWAIT BIT(15) /*!< asynchronous wait enable */
+#define EXMC_SNCTL_ASYNCWTEN BIT(15) /*!< asynchronous wait enable */
#define EXMC_SNCTL_CPS BITS(16,18) /*!< CRAM page size */
-#define EXMC_SNCTL_SYNCWR BIT(19) /*!< synchronous write config */
-#define EXMC_SNCTL_CCK BIT(20) /*!< consecutive clock config */
+#define EXMC_SNCTL_SYNCWR BIT(19) /*!< synchronous write configuration */
+#define EXMC_SNCTL_CCK BIT(20) /*!< consecutive clock configuration */
/* EXMC_SNTCFGx,x=0..3 */
#define EXMC_SNTCFG_ASET BITS(0,3) /*!< asynchronous address setup time */
@@ -207,7 +209,7 @@ OF SUCH DAMAGE.
/* EXMC_SDARI */
#define EXMC_SDARI_REC BIT(0) /*!< refresh error flag clear */
#define EXMC_SDARI_ARINTV BITS(1,13) /*!< auto-refresh interval */
-#define EXMC_SDARI_REIE BIT(14) /*!< interrupt refresh error enable */
+#define EXMC_SDARI_REIE BIT(14) /*!< refresh error interrupt enable */
/* EXMC_SDSTAT */
#define EXMC_SDSDAT_REIF BIT(0) /*!< refresh error interrupt flag */
@@ -273,12 +275,12 @@ typedef struct
uint32_t databus_width; /*!< specifies the databus width of external memory */
uint32_t memory_type; /*!< specifies the type of external memory */
uint32_t address_data_mux; /*!< specifies whether the data bus and address bus are multiplexed */
- exmc_norsram_timing_parameter_struct* read_write_timing; /*!< timing parameters for read and write if the extendedmode is not used or the timing
+ exmc_norsram_timing_parameter_struct* read_write_timing; /*!< timing parameters for read and write if the extendedmode is not used or the timing
parameters for read if the extendedmode is used. */
exmc_norsram_timing_parameter_struct* write_timing; /*!< timing parameters for write when the extendedmode is used. */
}exmc_norsram_parameter_struct;
-/* EXMC NAND/PC card timing initialize struct */
+/* EXMC NAND/PC card timing initialize structure */
typedef struct
{
uint32_t databus_hiztime; /*!< configure the dadtabus HiZ time for write operation */
@@ -287,10 +289,10 @@ typedef struct
uint32_t setuptime; /*!< configure the address setup time */
}exmc_nand_pccard_timing_parameter_struct;
-/* EXMC NAND initialize struct */
+/* EXMC NAND initialize structure */
typedef struct
{
- uint32_t nand_bank; /*!< select the bank of NAND */
+ uint32_t nand_bank; /*!< select the bank of NAND */
uint32_t ecc_size; /*!< the page size for the ECC calculation */
uint32_t atr_latency; /*!< configure the latency of ALE low to RB low */
uint32_t ctr_latency; /*!< configure the latency of CLE low to RB low */
@@ -301,7 +303,7 @@ typedef struct
exmc_nand_pccard_timing_parameter_struct* attribute_space_timing; /*!< the timing parameters for NAND flash attribute space */
}exmc_nand_parameter_struct;
-/* EXMC PC card initialize struct */
+/* EXMC PC card initialize structure */
typedef struct
{
uint32_t atr_latency; /*!< configure the latency of ALE low to RB low */
@@ -312,7 +314,7 @@ typedef struct
exmc_nand_pccard_timing_parameter_struct* io_space_timing; /*!< the timing parameters for PC card IO space */
}exmc_pccard_parameter_struct;
-/* EXMC SDRAM timing initialize struct */
+/* EXMC SDRAM timing initialize structure */
typedef struct
{
uint32_t row_to_column_delay; /*!< configure the row to column delay */
@@ -324,12 +326,12 @@ typedef struct
uint32_t load_mode_register_delay; /*!< configure the load mode register delay */
}exmc_sdram_timing_parameter_struct;
-/* EXMC SDRAM initialize struct */
+/* EXMC SDRAM initialize structure */
typedef struct
{
uint32_t sdram_device; /*!< device of SDRAM */
uint32_t pipeline_read_delay; /*!< the delay for reading data after CAS latency in HCLK clock cycles */
- uint32_t brust_read_switch; /*!< enable or disable the burst read */
+ uint32_t burst_read_switch; /*!< enable or disable the burst read */
uint32_t sdclock_config; /*!< the SDCLK memory clock for both SDRAM banks */
uint32_t write_protection; /*!< enable or disable SDRAM bank write protection function */
uint32_t cas_latency; /*!< configure the SDRAM CAS latency */
@@ -340,7 +342,7 @@ typedef struct
exmc_sdram_timing_parameter_struct* timing; /*!< the timing parameters for write and read SDRAM */
}exmc_sdram_parameter_struct;
-/* EXMC SDRAM command initialize struct */
+/* EXMC SDRAM command initialize structure */
typedef struct
{
uint32_t mode_register_content; /*!< the SDRAM mode register content */
@@ -349,7 +351,7 @@ typedef struct
uint32_t command; /*!< the commands that will be sent to SDRAM */
}exmc_sdram_command_parameter_struct;
-/* EXMC SQPISRAM initialize struct */
+/* EXMC SQPISRAM initialize structure */
typedef struct{
uint32_t sample_polarity; /*!< read data sample polarity */
uint32_t id_length; /*!< SPI PSRAM ID length */
@@ -357,7 +359,7 @@ typedef struct{
uint32_t command_bits; /*!< bit number of SPI PSRAM command phase */
}exmc_sqpipsram_parameter_struct;
-/* EXMC_register address */
+/* EXMC register address */
#define EXMC_SNCTL(region) REG32(EXMC + 0x08U*((uint32_t)(region))) /*!< EXMC SRAM/NOR flash control registers, region = 0,1,2,3 */
#define EXMC_SNTCFG(region) REG32(EXMC + 0x04U + 0x08U*((uint32_t)(region))) /*!< EXMC SRAM/NOR flash timing configuration registers, region = 0,1,2,3 */
#define EXMC_SNWTCFG(region) REG32(EXMC + 0x104U + 0x08U*((uint32_t)(region))) /*!< EXMC SRAM/NOR flash write timing configuration registers, region = 0,1,2,3 */
@@ -418,6 +420,7 @@ typedef struct{
/* synchronous clock divide ratio */
#define SNTCFG_CKDIV(regval) (BITS(20,23) & ((uint32_t)(regval) << 20))
+#define EXMC_SYN_CLOCK_RATIO_DISABLE SNTCFG_CKDIV(0) /*!< EXMC_CLK disable */
#define EXMC_SYN_CLOCK_RATIO_2_CLK SNTCFG_CKDIV(1) /*!< EXMC_CLK = 2*HCLK */
#define EXMC_SYN_CLOCK_RATIO_3_CLK SNTCFG_CKDIV(2) /*!< EXMC_CLK = 3*HCLK */
#define EXMC_SYN_CLOCK_RATIO_4_CLK SNTCFG_CKDIV(3) /*!< EXMC_CLK = 4*HCLK */
@@ -430,7 +433,7 @@ typedef struct{
#define EXMC_SYN_CLOCK_RATIO_11_CLK SNTCFG_CKDIV(10) /*!< EXMC_CLK = 11*HCLK */
#define EXMC_SYN_CLOCK_RATIO_12_CLK SNTCFG_CKDIV(11) /*!< EXMC_CLK = 12*HCLK */
#define EXMC_SYN_CLOCK_RATIO_13_CLK SNTCFG_CKDIV(12) /*!< EXMC_CLK = 13*HCLK */
-#define EXMC_SYN_CLOCK_RATIO_14_CLK SNTCFG_CKDIV(13) /*!< EXMC_CLK = 14*HCLK */
+#define EXMC_SYN_CLOCK_RATIO_14_CLK SNTCFG_CKDIV(13) /*!< EXMC_CLK = 14*HCLK*/
#define EXMC_SYN_CLOCK_RATIO_15_CLK SNTCFG_CKDIV(14) /*!< EXMC_CLK = 15*HCLK */
#define EXMC_SYN_CLOCK_RATIO_16_CLK SNTCFG_CKDIV(15) /*!< EXMC_CLK = 16*HCLK */
@@ -541,7 +544,7 @@ typedef struct{
#define EXMC_SDRAM_AUTO_REFLESH_14_SDCLK SDCMD_NARF(13) /*!< 14 auto-refresh cycles */
#define EXMC_SDRAM_AUTO_REFLESH_15_SDCLK SDCMD_NARF(14) /*!< 15 auto-refresh cycles */
-/* SDRAM command select */
+/* SDRAM command selection */
#define SDCMD_CMD(regval) (BITS(0,2) & ((uint32_t)(regval) << 0))
#define EXMC_SDRAM_NORMAL_OPERATION SDCMD_CMD(0) /*!< normal operation command */
#define EXMC_SDRAM_CLOCK_ENABLE SDCMD_CMD(1) /*!< clock enable command */
@@ -661,13 +664,13 @@ typedef struct{
#define EXMC_SDRAM_2_INTER_BANK ((uint32_t)0x00000000U) /*!< 2 internal banks */
#define EXMC_SDRAM_4_INTER_BANK EXMC_SDCTL_NBK /*!< 4 internal banks */
-/* SDRAM device0 select */
-#define EXMC_SDRAM_DEVICE0_UNSELECT ((uint32_t)0x00000000U) /*!< SDRAM device0 unselect */
-#define EXMC_SDRAM_DEVICE0_SELECT EXMC_SDCMD_DS0 /*!< SDRAM device0 select */
+/* SDRAM device0 selection */
+#define EXMC_SDRAM_DEVICE0_UNSELECT ((uint32_t)0x00000000U) /*!< unselect SDRAM device0 */
+#define EXMC_SDRAM_DEVICE0_SELECT EXMC_SDCMD_DS0 /*!< select SDRAM device0 */
-/* SDRAM device1 select */
-#define EXMC_SDRAM_DEVICE1_UNSELECT ((uint32_t)0x00000000U) /*!< SDRAM device1 unselect */
-#define EXMC_SDRAM_DEVICE1_SELECT EXMC_SDCMD_DS1 /*!< SDRAM device1 select */
+/* SDRAM device1 selection */
+#define EXMC_SDRAM_DEVICE1_UNSELECT ((uint32_t)0x00000000U) /*!< unselect SDRAM device1 */
+#define EXMC_SDRAM_DEVICE1_SELECT EXMC_SDCMD_DS1 /*!< select SDRAM device1 */
/* SDRAM device status */
#define EXMC_SDRAM_DEVICE_NORMAL ((uint32_t)0x00000000U) /*!< normal status */
@@ -716,7 +719,7 @@ void exmc_norsram_disable(uint32_t exmc_norsram_region);
/* NAND */
/* deinitialize EXMC NAND bank */
void exmc_nand_deinit(uint32_t exmc_nand_bank);
-/* initialize exmc_norsram_parameter_struct with the default values */
+/* initialize exmc_nand_parameter_struct with the default values */
void exmc_nand_struct_para_init(exmc_nand_parameter_struct* exmc_nand_init_struct);
/* initialize EXMC NAND bank */
void exmc_nand_init(exmc_nand_parameter_struct* exmc_nand_init_struct);
@@ -742,6 +745,8 @@ void exmc_sdram_deinit(uint32_t exmc_sdram_device);
void exmc_sdram_struct_para_init(exmc_sdram_parameter_struct* exmc_sdram_init_struct);
/* initialize EXMC SDRAM device */
void exmc_sdram_init(exmc_sdram_parameter_struct* exmc_sdram_init_struct);
+/* initialize exmc_sdram_command_parameter_struct with the default values */
+void exmc_sdram_struct_command_para_init(exmc_sdram_command_parameter_struct *exmc_sdram_command_init_struct);
/* SQPIPSRAM */
/* deinitialize EXMC SQPIPSRAM */
void exmc_sqpipsram_deinit(void);
@@ -772,7 +777,7 @@ void exmc_sdram_command_config(exmc_sdram_command_parameter_struct* exmc_sdram_c
void exmc_sdram_refresh_count_set(uint32_t exmc_count);
/* set the number of successive auto-refresh command */
void exmc_sdram_autorefresh_number_set(uint32_t exmc_number);
-/* config the write protection function */
+/* configure the write protection function */
void exmc_sdram_write_protection_config(uint32_t exmc_sdram_device, ControlStatus newvalue);
/* get the status of SDRAM device0 or device1 */
uint32_t exmc_sdram_bankstatus_get(uint32_t exmc_sdram_device);
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_exti.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_exti.h
index 3c2a27149d..294b5872b7 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_exti.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_exti.h
@@ -1,36 +1,36 @@
/*!
\file gd32f4xx_exti.h
\brief definitions for the EXTI
-
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
- \version 2018-12-12, V2.0.1, firmware for GD32F4xx
+ \version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -177,34 +177,33 @@ OF SUCH DAMAGE.
#define EXTI_SWIEV_SWIEV22 BIT(22) /*!< software interrupt/event request from line 22 */
/* EXTI_PD */
-#define EXTI_PD_PD0 BIT(0) /*!< interrupt/event pending status from line 0 */
-#define EXTI_PD_PD1 BIT(1) /*!< interrupt/event pending status from line 1 */
-#define EXTI_PD_PD2 BIT(2) /*!< interrupt/event pending status from line 2 */
-#define EXTI_PD_PD3 BIT(3) /*!< interrupt/event pending status from line 3 */
-#define EXTI_PD_PD4 BIT(4) /*!< interrupt/event pending status from line 4 */
-#define EXTI_PD_PD5 BIT(5) /*!< interrupt/event pending status from line 5 */
-#define EXTI_PD_PD6 BIT(6) /*!< interrupt/event pending status from line 6 */
-#define EXTI_PD_PD7 BIT(7) /*!< interrupt/event pending status from line 7 */
-#define EXTI_PD_PD8 BIT(8) /*!< interrupt/event pending status from line 8 */
-#define EXTI_PD_PD9 BIT(9) /*!< interrupt/event pending status from line 9 */
-#define EXTI_PD_PD10 BIT(10) /*!< interrupt/event pending status from line 10 */
-#define EXTI_PD_PD11 BIT(11) /*!< interrupt/event pending status from line 11 */
-#define EXTI_PD_PD12 BIT(12) /*!< interrupt/event pending status from line 12 */
-#define EXTI_PD_PD13 BIT(13) /*!< interrupt/event pending status from line 13 */
-#define EXTI_PD_PD14 BIT(14) /*!< interrupt/event pending status from line 14 */
-#define EXTI_PD_PD15 BIT(15) /*!< interrupt/event pending status from line 15 */
-#define EXTI_PD_PD16 BIT(16) /*!< interrupt/event pending status from line 16 */
-#define EXTI_PD_PD17 BIT(17) /*!< interrupt/event pending status from line 17 */
-#define EXTI_PD_PD18 BIT(18) /*!< interrupt/event pending status from line 18 */
-#define EXTI_PD_PD19 BIT(19) /*!< interrupt/event pending status from line 19 */
-#define EXTI_PD_PD20 BIT(20) /*!< interrupt/event pending status from line 20 */
-#define EXTI_PD_PD21 BIT(21) /*!< interrupt/event pending status from line 21 */
-#define EXTI_PD_PD22 BIT(22) /*!< interrupt/event pending status from line 22 */
+#define EXTI_PD_PD0 BIT(0) /*!< interrupt pending status from line 0 */
+#define EXTI_PD_PD1 BIT(1) /*!< interrupt pending status from line 1 */
+#define EXTI_PD_PD2 BIT(2) /*!< interrupt pending status from line 2 */
+#define EXTI_PD_PD3 BIT(3) /*!< interrupt pending status from line 3 */
+#define EXTI_PD_PD4 BIT(4) /*!< interrupt pending status from line 4 */
+#define EXTI_PD_PD5 BIT(5) /*!< interrupt pending status from line 5 */
+#define EXTI_PD_PD6 BIT(6) /*!< interrupt pending status from line 6 */
+#define EXTI_PD_PD7 BIT(7) /*!< interrupt pending status from line 7 */
+#define EXTI_PD_PD8 BIT(8) /*!< interrupt pending status from line 8 */
+#define EXTI_PD_PD9 BIT(9) /*!< interrupt pending status from line 9 */
+#define EXTI_PD_PD10 BIT(10) /*!< interrupt pending status from line 10 */
+#define EXTI_PD_PD11 BIT(11) /*!< interrupt pending status from line 11 */
+#define EXTI_PD_PD12 BIT(12) /*!< interrupt pending status from line 12 */
+#define EXTI_PD_PD13 BIT(13) /*!< interrupt pending status from line 13 */
+#define EXTI_PD_PD14 BIT(14) /*!< interrupt pending status from line 14 */
+#define EXTI_PD_PD15 BIT(15) /*!< interrupt pending status from line 15 */
+#define EXTI_PD_PD16 BIT(16) /*!< interrupt pending status from line 16 */
+#define EXTI_PD_PD17 BIT(17) /*!< interrupt pending status from line 17 */
+#define EXTI_PD_PD18 BIT(18) /*!< interrupt pending status from line 18 */
+#define EXTI_PD_PD19 BIT(19) /*!< interrupt pending status from line 19 */
+#define EXTI_PD_PD20 BIT(20) /*!< interrupt pending status from line 20 */
+#define EXTI_PD_PD21 BIT(21) /*!< interrupt pending status from line 21 */
+#define EXTI_PD_PD22 BIT(22) /*!< interrupt pending status from line 22 */
/* constants definitions */
/* EXTI line number */
-typedef enum
-{
+typedef enum {
EXTI_0 = BIT(0), /*!< EXTI line 0 */
EXTI_1 = BIT(1), /*!< EXTI line 1 */
EXTI_2 = BIT(2), /*!< EXTI line 2 */
@@ -225,31 +224,29 @@ typedef enum
EXTI_17 = BIT(17), /*!< EXTI line 17 */
EXTI_18 = BIT(18), /*!< EXTI line 18 */
EXTI_19 = BIT(19), /*!< EXTI line 19 */
- EXTI_20 = BIT(20), /*!< EXTI line 20 */
+ EXTI_20 = BIT(20), /*!< EXTI line 20 */
EXTI_21 = BIT(21), /*!< EXTI line 21 */
- EXTI_22 = BIT(22), /*!< EXTI line 22 */
-}exti_line_enum;
+ EXTI_22 = BIT(22) /*!< EXTI line 22 */
+} exti_line_enum;
/* external interrupt and event */
-typedef enum
-{
+typedef enum {
EXTI_INTERRUPT = 0, /*!< EXTI interrupt mode */
EXTI_EVENT /*!< EXTI event mode */
-}exti_mode_enum;
+} exti_mode_enum;
/* interrupt trigger mode */
-typedef enum
-{
+typedef enum {
EXTI_TRIG_RISING = 0, /*!< EXTI rising edge trigger */
EXTI_TRIG_FALLING, /*!< EXTI falling edge trigger */
EXTI_TRIG_BOTH, /*!< EXTI rising and falling edge trigger */
EXTI_TRIG_NONE /*!< none EXTI edge trigger */
-}exti_trig_type_enum;
+} exti_trig_type_enum;
/* function declarations */
/* deinitialize the EXTI */
void exti_deinit(void);
-/* enable the configuration of EXTI initialize */
+/* initialize the EXTI line x */
void exti_init(exti_line_enum linex, exti_mode_enum mode, exti_trig_type_enum trig_type);
/* enable the interrupts from EXTI line x */
void exti_interrupt_enable(exti_line_enum linex);
@@ -259,19 +256,19 @@ void exti_interrupt_disable(exti_line_enum linex);
void exti_event_enable(exti_line_enum linex);
/* disable the events from EXTI line x */
void exti_event_disable(exti_line_enum linex);
-/* EXTI software interrupt event enable */
+/* enable the software interrupt event from EXTI line x */
void exti_software_interrupt_enable(exti_line_enum linex);
-/* EXTI software interrupt event disable */
+/* disable the software interrupt event from EXTI line x */
void exti_software_interrupt_disable(exti_line_enum linex);
/* interrupt & flag functions */
-/* get EXTI lines pending flag */
+/* get EXTI line x interrupt pending flag */
FlagStatus exti_flag_get(exti_line_enum linex);
-/* clear EXTI lines pending flag */
+/* clear EXTI line x interrupt pending flag */
void exti_flag_clear(exti_line_enum linex);
-/* get EXTI lines flag when the interrupt flag is set */
+/* get EXTI line x interrupt pending flag */
FlagStatus exti_interrupt_flag_get(exti_line_enum linex);
-/* clear EXTI lines pending flag */
+/* clear EXTI line x interrupt pending flag */
void exti_interrupt_flag_clear(exti_line_enum linex);
#endif /* GD32F4XX_EXTI_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_fmc.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_fmc.h
index 9b1b82c083..db4d0f44f6 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_fmc.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_fmc.h
@@ -5,10 +5,12 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2020-12-20, V2.1.1, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -45,15 +47,17 @@ OF SUCH DAMAGE.
#define OB OB_BASE /*!< option byte base address */
/* registers definitions */
-#define FMC_WS REG32((FMC) + 0x0000U) /*!< FMC wait state register */
-#define FMC_KEY REG32((FMC) + 0x0004U) /*!< FMC unlock key register */
-#define FMC_OBKEY REG32((FMC) + 0x0008U) /*!< FMC option byte unlock key register */
-#define FMC_STAT REG32((FMC) + 0x000CU) /*!< FMC status register */
-#define FMC_CTL REG32((FMC) + 0x0010U) /*!< FMC control register */
-#define FMC_OBCTL0 REG32((FMC) + 0x0014U) /*!< FMC option byte control register 0 */
-#define FMC_OBCTL1 REG32((FMC) + 0x0018U) /*!< FMC option byte control register 1 */
-#define FMC_WSEN REG32((FMC) + 0x00FCU) /*!< FMC wait state enable register */
-#define FMC_PID REG32((FMC) + 0x0100U) /*!< FMC product ID register */
+#define FMC_WS REG32((FMC) + 0x00000000U) /*!< FMC wait state register */
+#define FMC_KEY REG32((FMC) + 0x00000004U) /*!< FMC unlock key register */
+#define FMC_OBKEY REG32((FMC) + 0x00000008U) /*!< FMC option byte unlock key register */
+#define FMC_STAT REG32((FMC) + 0x0000000CU) /*!< FMC status register */
+#define FMC_CTL REG32((FMC) + 0x00000010U) /*!< FMC control register */
+#define FMC_OBCTL0 REG32((FMC) + 0x00000014U) /*!< FMC option byte control register 0 */
+#define FMC_OBCTL1 REG32((FMC) + 0x00000018U) /*!< FMC option byte control register 1 */
+#define FMC_PECFG REG32((FMC) + 0x00000020U) /*!< FMC page erase configuration register */
+#define FMC_PEKEY REG32((FMC) + 0x00000024U) /*!< FMC unlock page erase key register */
+#define FMC_WSEN REG32((FMC) + 0x000000FCU) /*!< FMC wait state enable register */
+#define FMC_PID REG32((FMC) + 0x00000100U) /*!< FMC product ID register */
#define OB_WP1 REG32((OB) + 0x00000008U) /*!< option byte write protection 1 */
#define OB_USER REG32((OB) + 0x00010000U) /*!< option byte user value*/
@@ -107,6 +111,13 @@ OF SUCH DAMAGE.
/* FMC_OBCTL1 */
#define FMC_OBCTL1_WP1 BITS(16,27) /*!< erase/program protection of each sector when DRP is 0 */
+/* FMC_PECFG */
+#define FMC_PE_EN BIT(31) /*!< the enable bit of page erase function */
+#define FMC_PE_ADDR BITS(0,28) /*!< page erase address */
+
+/* FMC_PEKEY */
+#define FMC_PE_KEY BITS(0,31) /*!< FMC_PECFG unlock key value */
+
/* FMC_WSEN */
#define FMC_WSEN_WSEN BIT(0) /*!< FMC wait state enable bit */
@@ -115,21 +126,21 @@ OF SUCH DAMAGE.
/* constants definitions */
/* fmc state */
-typedef enum
-{
- FMC_READY, /*!< the operation has been completed */
+typedef enum {
+ FMC_READY = 0, /*!< the operation has been completed */
FMC_BUSY, /*!< the operation is in progress */
FMC_RDDERR, /*!< read D-bus protection error */
FMC_PGSERR, /*!< program sequence error */
FMC_PGMERR, /*!< program size not match error */
FMC_WPERR, /*!< erase/program protection error */
FMC_OPERR, /*!< operation error */
- FMC_PGERR, /*!< program error */
-}fmc_state_enum;
+ FMC_TOERR /*!< timeout error */
+} fmc_state_enum;
/* unlock key */
#define UNLOCK_KEY0 ((uint32_t)0x45670123U) /*!< unlock key 0 */
#define UNLOCK_KEY1 ((uint32_t)0xCDEF89ABU) /*!< unlock key 1 */
+#define UNLOCK_PE_KEY ((uint32_t)0xA9B8C7D6U) /*!< unlock page erase function key */
#define OB_UNLOCK_KEY0 ((uint32_t)0x08192A3BU) /*!< ob unlock key 0 */
#define OB_UNLOCK_KEY1 ((uint32_t)0x4C5D6E7FU) /*!< ob unlock key 1 */
@@ -241,14 +252,15 @@ typedef enum
#define OB_DRP_21 ((uint32_t)0x02000000U) /*!< D-bus read protection protection of sector 21 */
#define OB_DRP_22 ((uint32_t)0x04000000U) /*!< D-bus read protection protection of sector 22 */
#define OB_DRP_23_27 ((uint32_t)0x08000000U) /*!< D-bus read protection protection of sector 23~27 */
+#define OB_DRP_ALL ((uint32_t)0x0FFF0FFFU) /*!< D-bus read protection protection of all sectors */
/* double banks or single bank selection when flash size is 1M bytes */
-#define OBCTL0_DBS(regval) (BIT(30) & ((uint32_t)(regval)<<30))
+#define OBCTL0_DBS(regval) (BIT(30) & ((uint32_t)(regval) << 30U))
#define OB_DBS_DISABLE OBCTL0_DBS(0) /*!< single bank when flash size is 1M bytes */
#define OB_DBS_ENABLE OBCTL0_DBS(1) /*!< double bank when flash size is 1M bytes */
/* option bytes D-bus read protection mode */
-#define OBCTL0_DRP(regval) (BIT(31) & ((uint32_t)(regval)<<31))
+#define OBCTL0_DRP(regval) (BIT(31) & ((uint32_t)(regval) << 31U))
#define OB_DRP_DISABLE OBCTL0_DRP(0) /*!< the WPx bits used as erase/program protection of each sector */
#define OB_DRP_ENABLE OBCTL0_DRP(1) /*!< the WPx bits used as erase/program protection and D-bus read protection of each sector */
@@ -285,23 +297,35 @@ typedef enum
/* FMC program size */
-#define CTL_PSZ(regval) (BITS(8,9) & ((uint32_t)(regval))<< 8)
+#define CTL_PSZ(regval) (BITS(8,9) & ((uint32_t)(regval))<< 8U)
#define CTL_PSZ_BYTE CTL_PSZ(0) /*!< FMC program by byte access */
#define CTL_PSZ_HALF_WORD CTL_PSZ(1) /*!< FMC program by half-word access */
#define CTL_PSZ_WORD CTL_PSZ(2) /*!< FMC program by word access */
/* FMC interrupt enable */
-#define FMC_INT_END ((uint32_t)0x01000000U) /*!< enable FMC end of program interrupt */
-#define FMC_INT_ERR ((uint32_t)0x02000000U) /*!< enable FMC error interrupt */
+#define FMC_INT_END ((uint32_t)0x01000000U) /*!< enable FMC end of program interrupt */
+#define FMC_INT_ERR ((uint32_t)0x02000000U) /*!< enable FMC error interrupt */
/* FMC flags */
-#define FMC_FLAG_END ((uint32_t)0x00000001U) /*!< FMC end of operation flag bit */
-#define FMC_FLAG_OPERR ((uint32_t)0x00000002U) /*!< FMC operation error flag bit */
-#define FMC_FLAG_WPERR ((uint32_t)0x00000010U) /*!< FMC erase/program protection error flag bit */
-#define FMC_FLAG_PGMERR ((uint32_t)0x00000040U) /*!< FMC program size not match error flag bit */
-#define FMC_FLAG_PGSERR ((uint32_t)0x00000080U) /*!< FMC program sequence error flag bit */
-#define FMC_FLAG_RDDERR ((uint32_t)0x00000100U) /*!< FMC read D-bus protection error flag bit */
-#define FMC_FLAG_BUSY ((uint32_t)0x00010000U) /*!< FMC busy flag */
+#define FMC_FLAG_END FMC_STAT_END /*!< FMC end of operation flag bit */
+#define FMC_FLAG_OPERR FMC_STAT_OPERR /*!< FMC operation error flag bit */
+#define FMC_FLAG_WPERR FMC_STAT_WPERR /*!< FMC erase/program protection error flag bit */
+#define FMC_FLAG_PGMERR FMC_STAT_PGMERR /*!< FMC program size not match error flag bit */
+#define FMC_FLAG_PGSERR FMC_STAT_PGSERR /*!< FMC program sequence error flag bit */
+#define FMC_FLAG_RDDERR FMC_STAT_RDDERR /*!< FMC read D-bus protection error flag bit */
+#define FMC_FLAG_BUSY FMC_STAT_BUSY /*!< FMC busy flag */
+
+/* FMC interrupt flags */
+#define FMC_INT_FLAG_END FMC_STAT_END /*!< FMC end of operation interrupt flag */
+#define FMC_INT_FLAG_OPERR FMC_STAT_OPERR /*!< FMC operation error interrupt flag */
+#define FMC_INT_FLAG_WPERR FMC_STAT_WPERR /*!< FMC erase/program protection error interrupt flag */
+#define FMC_INT_FLAG_PGMERR FMC_STAT_PGMERR /*!< FMC program size not match error interrupt flag */
+#define FMC_INT_FLAG_PGSERR FMC_STAT_PGSERR /*!< FMC program sequence error interrupt flag */
+#define FMC_INT_FLAG_RDDERR FMC_STAT_RDDERR /*!< FMC read D-bus protection error interrupt flag */
+
+
+/* FMC time out */
+#define FMC_TIMEOUT_COUNT ((uint32_t)0x4FFFFFFFU) /*!< count to judge of FMC timeout */
/* function declarations */
/* FMC main memory programming functions */
@@ -311,6 +335,10 @@ void fmc_wscnt_set(uint32_t wscnt);
void fmc_unlock(void);
/* lock the main FMC operation */
void fmc_lock(void);
+#if defined (GD32F425) || defined (GD32F427) || defined (GD32F470)
+/* FMC erase page */
+fmc_state_enum fmc_page_erase(uint32_t page_addr);
+#endif
/* FMC erase sector */
fmc_state_enum fmc_sector_erase(uint32_t fmc_sector);
/* FMC erase whole chip */
@@ -336,22 +364,22 @@ void ob_start(void);
/* erase option byte */
void ob_erase(void);
/* enable write protect */
-void ob_write_protection_enable(uint32_t ob_wp);
+ErrStatus ob_write_protection_enable(uint32_t ob_wp);
/* disable write protect */
-void ob_write_protection_disable(uint32_t ob_wp);
+ErrStatus ob_write_protection_disable(uint32_t ob_wp);
/* enable erase/program protection and D-bus read protection */
void ob_drp_enable(uint32_t ob_drp);
/* disable erase/program protection and D-bus read protection */
-void ob_drp_disable(uint32_t ob_drp);
-/* set the option byte security protection level */
+void ob_drp_disable(void);
+/* configure security protection level */
void ob_security_protection_config(uint8_t ob_spc);
-/* write the FMC option byte user */
+/* program the FMC user option byte */
void ob_user_write(uint32_t ob_fwdgt, uint32_t ob_deepsleep, uint32_t ob_stdby);
-/* option byte BOR threshold value */
+/* program the option byte BOR threshold value */
void ob_user_bor_threshold(uint32_t ob_bor_th);
/* configure the boot mode */
void ob_boot_mode_config(uint32_t boot_mode);
-/* get the FMC option byte user */
+/* get the FMC user option byte */
uint8_t ob_user_get(void);
/* get the FMC option byte write protection */
uint16_t ob_write_protection0_get(void);
@@ -363,21 +391,25 @@ uint16_t ob_drp0_get(void);
uint16_t ob_drp1_get(void);
/* get option byte security protection code value */
FlagStatus ob_spc_get(void);
-/* get the FMC threshold value */
+/* get the FMC option byte BOR threshold value */
uint8_t ob_user_bor_threshold_get(void);
/* FMC interrupts and flags management functions */
-/* enable FMC interrupt */
-void fmc_interrupt_enable(uint32_t fmc_int);
-/* disable FMC interrupt */
-void fmc_interrupt_disable(uint32_t fmc_int);
/* get flag set or reset */
FlagStatus fmc_flag_get(uint32_t fmc_flag);
/* clear the FMC pending flag */
void fmc_flag_clear(uint32_t fmc_flag);
-/* return the FMC state */
+/* enable FMC interrupt */
+void fmc_interrupt_enable(uint32_t fmc_int);
+/* disable FMC interrupt */
+void fmc_interrupt_disable(uint32_t fmc_int);
+/* get FMC interrupt flag set or reset */
+FlagStatus fmc_interrupt_flag_get(uint32_t fmc_int_flag);
+/* clear the FMC interrupt flag */
+void fmc_interrupt_flag_clear(uint32_t fmc_int_flag);
+/* get the FMC state */
fmc_state_enum fmc_state_get(void);
-/* check FMC ready or not */
-fmc_state_enum fmc_ready_wait(void);
+/* check whether FMC is ready or not */
+fmc_state_enum fmc_ready_wait(uint32_t timeout);
#endif /* GD32F4XX_FMC_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_fwdgt.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_fwdgt.h
index ebee04b637..a3e6c6d7d4 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_fwdgt.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_fwdgt.h
@@ -5,32 +5,33 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -40,7 +41,7 @@ OF SUCH DAMAGE.
#include "gd32f4xx.h"
/* FWDGT definitions */
-#define FWDGT FWDGT_BASE
+#define FWDGT FWDGT_BASE /*!< FWDGT base address */
/* registers definitions */
#define FWDGT_CTL REG32((FWDGT) + 0x00U) /*!< FWDGT control register */
@@ -87,6 +88,9 @@ OF SUCH DAMAGE.
#define FWDGT_FLAG_PUD FWDGT_STAT_PUD /*!< FWDGT prescaler divider value update flag */
#define FWDGT_FLAG_RUD FWDGT_STAT_RUD /*!< FWDGT counter reload value update flag */
+/* write value to FWDGT_RLD_RLD bit field */
+#define RLD_RLD(regval) (BITS(0,11) & ((uint32_t)(regval) << 0))
+
/* function declarations */
/* enable write access to FWDGT_PSC and FWDGT_RLD */
void fwdgt_write_enable(void);
@@ -95,6 +99,10 @@ void fwdgt_write_disable(void);
/* start the free watchdog timer counter */
void fwdgt_enable(void);
+/* configure the free watchdog timer counter prescaler value */
+ErrStatus fwdgt_prescaler_value_config(uint16_t prescaler_value);
+/* configure the free watchdog timer counter reload value */
+ErrStatus fwdgt_reload_value_config(uint16_t reload_value);
/* reload the counter of FWDGT */
void fwdgt_counter_reload(void);
/* configure counter reload value, and prescaler divider value */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_gpio.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_gpio.h
index 81da899427..e62d99c69b 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_gpio.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_gpio.h
@@ -5,32 +5,33 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -57,7 +58,7 @@ OF SUCH DAMAGE.
#define GPIO_PUD(gpiox) REG32((gpiox) + 0x0CU) /*!< GPIO port pull-up/pull-down register */
#define GPIO_ISTAT(gpiox) REG32((gpiox) + 0x10U) /*!< GPIO port input status register */
#define GPIO_OCTL(gpiox) REG32((gpiox) + 0x14U) /*!< GPIO port output control register */
-#define GPIO_BOP(gpiox) REG32((gpiox) + 0x18U) /*!< GPIO port bit operation register */
+#define GPIO_BOP(gpiox) REG32((gpiox) + 0x18U) /*!< GPIO port bit operate register */
#define GPIO_LOCK(gpiox) REG32((gpiox) + 0x1CU) /*!< GPIO port configuration lock register */
#define GPIO_AFSEL0(gpiox) REG32((gpiox) + 0x20U) /*!< GPIO alternate function selected register 0 */
#define GPIO_AFSEL1(gpiox) REG32((gpiox) + 0x24U) /*!< GPIO alternate function selected register 1 */
@@ -66,7 +67,7 @@ OF SUCH DAMAGE.
/* bits definitions */
/* GPIO_CTL */
-#define GPIO_CTL_CTL0 BITS(0,1) /*!< pin 0 configuration bits */
+#define GPIO_CTL_CTL0 BITS(0,1) /*!< pin 0 configuration bits */
#define GPIO_CTL_CTL1 BITS(2,3) /*!< pin 1 configuration bits */
#define GPIO_CTL_CTL2 BITS(4,5) /*!< pin 2 configuration bits */
#define GPIO_CTL_CTL3 BITS(6,7) /*!< pin 3 configuration bits */
@@ -156,22 +157,22 @@ OF SUCH DAMAGE.
#define GPIO_ISTAT_ISTAT15 BIT(15) /*!< pin 15 input status */
/* GPIO_OCTL */
-#define GPIO_OCTL_OCTL0 BIT(0) /*!< pin 0 output bit */
-#define GPIO_OCTL_OCTL1 BIT(1) /*!< pin 1 output bit */
-#define GPIO_OCTL_OCTL2 BIT(2) /*!< pin 2 output bit */
-#define GPIO_OCTL_OCTL3 BIT(3) /*!< pin 3 output bit */
-#define GPIO_OCTL_OCTL4 BIT(4) /*!< pin 4 output bit */
-#define GPIO_OCTL_OCTL5 BIT(5) /*!< pin 5 output bit */
-#define GPIO_OCTL_OCTL6 BIT(6) /*!< pin 6 output bit */
-#define GPIO_OCTL_OCTL7 BIT(7) /*!< pin 7 output bit */
-#define GPIO_OCTL_OCTL8 BIT(8) /*!< pin 8 output bit */
-#define GPIO_OCTL_OCTL9 BIT(9) /*!< pin 9 output bit */
-#define GPIO_OCTL_OCTL10 BIT(10) /*!< pin 10 output bit */
-#define GPIO_OCTL_OCTL11 BIT(11) /*!< pin 11 output bit */
-#define GPIO_OCTL_OCTL12 BIT(12) /*!< pin 12 output bit */
-#define GPIO_OCTL_OCTL13 BIT(13) /*!< pin 13 output bit */
-#define GPIO_OCTL_OCTL14 BIT(14) /*!< pin 14 output bit */
-#define GPIO_OCTL_OCTL15 BIT(15) /*!< pin 15 output bit */
+#define GPIO_OCTL_OCTL0 BIT(0) /*!< pin 0 output control bit */
+#define GPIO_OCTL_OCTL1 BIT(1) /*!< pin 1 output control bit */
+#define GPIO_OCTL_OCTL2 BIT(2) /*!< pin 2 output control bit */
+#define GPIO_OCTL_OCTL3 BIT(3) /*!< pin 3 output control bit */
+#define GPIO_OCTL_OCTL4 BIT(4) /*!< pin 4 output control bit */
+#define GPIO_OCTL_OCTL5 BIT(5) /*!< pin 5 output control bit */
+#define GPIO_OCTL_OCTL6 BIT(6) /*!< pin 6 output control bit */
+#define GPIO_OCTL_OCTL7 BIT(7) /*!< pin 7 output control bit */
+#define GPIO_OCTL_OCTL8 BIT(8) /*!< pin 8 output control bit */
+#define GPIO_OCTL_OCTL9 BIT(9) /*!< pin 9 output control bit */
+#define GPIO_OCTL_OCTL10 BIT(10) /*!< pin 10 output control bit */
+#define GPIO_OCTL_OCTL11 BIT(11) /*!< pin 11 output control bit */
+#define GPIO_OCTL_OCTL12 BIT(12) /*!< pin 12 output control bit */
+#define GPIO_OCTL_OCTL13 BIT(13) /*!< pin 13 output control bit */
+#define GPIO_OCTL_OCTL14 BIT(14) /*!< pin 14 output control bit */
+#define GPIO_OCTL_OCTL15 BIT(15) /*!< pin 15 output control bit */
/* GPIO_BOP */
#define GPIO_BOP_BOP0 BIT(0) /*!< pin 0 set bit */
@@ -224,7 +225,7 @@ OF SUCH DAMAGE.
#define GPIO_LOCK_LK13 BIT(13) /*!< pin 13 lock bit */
#define GPIO_LOCK_LK14 BIT(14) /*!< pin 14 lock bit */
#define GPIO_LOCK_LK15 BIT(15) /*!< pin 15 lock bit */
-#define GPIO_LOCK_LKK BIT(16) /*!< pin sequence lock key */
+#define GPIO_LOCK_LKK BIT(16) /*!< pin lock sequence key */
/* GPIO_AFSEL0 */
#define GPIO_AFSEL0_SEL0 BITS(0,3) /*!< pin 0 alternate function selected */
@@ -344,14 +345,14 @@ typedef FlagStatus bit_status;
#define GPIO_OSPEED_2MHZ GPIO_OSPEED_LEVEL0 /*!< output max speed 2MHz */
#define GPIO_OSPEED_25MHZ GPIO_OSPEED_LEVEL1 /*!< output max speed 25MHz */
#define GPIO_OSPEED_50MHZ GPIO_OSPEED_LEVEL2 /*!< output max speed 50MHz */
-#define GPIO_OSPEED_200MHZ GPIO_OSPEED_LEVEL3 /*!< output max speed 200MHz */
+#define GPIO_OSPEED_MAX GPIO_OSPEED_LEVEL3 /*!< GPIO very high output speed, max speed more than 50MHz */
/* GPIO alternate function values */
#define GPIO_AFR_SET(n, af) ((uint32_t)((uint32_t)(af) << (4U * (n))))
#define GPIO_AFR_MASK(n) (0xFU << (4U * (n)))
-
+
/* GPIO alternate function */
-#define AF(regval) (BITS(0,3) & ((uint32_t)(regval) << 0))
+#define AF(regval) (BITS(0,3) & ((uint32_t)(regval) << 0))
#define GPIO_AF_0 AF(0) /*!< alternate function 0 selected */
#define GPIO_AF_1 AF(1) /*!< alternate function 1 selected */
#define GPIO_AF_2 AF(2) /*!< alternate function 2 selected */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_i2c.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_i2c.h
index 121e42f497..5876e50aa0 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_i2c.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_i2c.h
@@ -6,10 +6,11 @@
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2019-04-16, V2.0.1, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -35,198 +36,173 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
OF SUCH DAMAGE.
*/
-
#ifndef GD32F4XX_I2C_H
#define GD32F4XX_I2C_H
#include "gd32f4xx.h"
/* I2Cx(x=0,1,2) definitions */
-#define I2C0 I2C_BASE /*!< I2C0 base address */
-#define I2C1 (I2C_BASE+0x400U) /*!< I2C1 base address */
-#define I2C2 (I2C_BASE+0x800U) /*!< I2C2 base address */
+#define I2C0 I2C_BASE /*!< I2C0 base address */
+#define I2C1 (I2C_BASE + 0x00000400U) /*!< I2C1 base address */
+#define I2C2 (I2C_BASE + 0x00000800U) /*!< I2C2 base address */
/* registers definitions */
-#define I2C_CTL0(i2cx) REG32((i2cx) + 0x00U) /*!< I2C control register 0 */
-#define I2C_CTL1(i2cx) REG32((i2cx) + 0x04U) /*!< I2C control register 1 */
-#define I2C_SADDR0(i2cx) REG32((i2cx) + 0x08U) /*!< I2C slave address register 0 */
-#define I2C_SADDR1(i2cx) REG32((i2cx) + 0x0CU) /*!< I2C slave address register 1 */
-#define I2C_DATA(i2cx) REG32((i2cx) + 0x10U) /*!< I2C transfer buffer register */
-#define I2C_STAT0(i2cx) REG32((i2cx) + 0x14U) /*!< I2C transfer status register 0 */
-#define I2C_STAT1(i2cx) REG32((i2cx) + 0x18U) /*!< I2C transfer status register */
-#define I2C_CKCFG(i2cx) REG32((i2cx) + 0x1CU) /*!< I2C clock configure register */
-#define I2C_RT(i2cx) REG32((i2cx) + 0x20U) /*!< I2C rise time register */
-#define I2C_FCTL(i2cx) REG32((i2cx) + 0x24U) /*!< I2C filter control register */
-#define I2C_SAMCS(i2cx) REG32((i2cx) + 0x80U) /*!< I2C SAM control and status register */
+#define I2C_CTL0(i2cx) REG32((i2cx) + 0x00000000U) /*!< I2C control register 0 */
+#define I2C_CTL1(i2cx) REG32((i2cx) + 0x00000004U) /*!< I2C control register 1 */
+#define I2C_SADDR0(i2cx) REG32((i2cx) + 0x00000008U) /*!< I2C slave address register 0 */
+#define I2C_SADDR1(i2cx) REG32((i2cx) + 0x0000000CU) /*!< I2C slave address register 1 */
+#define I2C_DATA(i2cx) REG32((i2cx) + 0x00000010U) /*!< I2C transfer buffer register */
+#define I2C_STAT0(i2cx) REG32((i2cx) + 0x00000014U) /*!< I2C transfer status register 0 */
+#define I2C_STAT1(i2cx) REG32((i2cx) + 0x00000018U) /*!< I2C transfer status register */
+#define I2C_CKCFG(i2cx) REG32((i2cx) + 0x0000001CU) /*!< I2C clock configure register */
+#define I2C_RT(i2cx) REG32((i2cx) + 0x00000020U) /*!< I2C rise time register */
+#define I2C_FCTL(i2cx) REG32((i2cx) + 0x00000024U) /*!< I2C filter control register */
+#define I2C_SAMCS(i2cx) REG32((i2cx) + 0x00000080U) /*!< I2C SAM control and status register */
/* bits definitions */
/* I2Cx_CTL0 */
-#define I2C_CTL0_I2CEN BIT(0) /*!< peripheral enable */
-#define I2C_CTL0_SMBEN BIT(1) /*!< SMBus mode */
-#define I2C_CTL0_SMBSEL BIT(3) /*!< SMBus type */
-#define I2C_CTL0_ARPEN BIT(4) /*!< ARP enable */
-#define I2C_CTL0_PECEN BIT(5) /*!< PEC enable */
-#define I2C_CTL0_GCEN BIT(6) /*!< general call enable */
-#define I2C_CTL0_SS BIT(7) /*!< clock stretching disable (slave mode) */
-#define I2C_CTL0_START BIT(8) /*!< start generation */
-#define I2C_CTL0_STOP BIT(9) /*!< stop generation */
-#define I2C_CTL0_ACKEN BIT(10) /*!< acknowledge enable */
-#define I2C_CTL0_POAP BIT(11) /*!< acknowledge/PEC position (for data reception) */
-#define I2C_CTL0_PECTRANS BIT(12) /*!< packet error checking */
-#define I2C_CTL0_SALT BIT(13) /*!< SMBus alert */
-#define I2C_CTL0_SRESET BIT(15) /*!< software reset */
+#define I2C_CTL0_I2CEN BIT(0) /*!< peripheral enable */
+#define I2C_CTL0_SMBEN BIT(1) /*!< SMBus mode */
+#define I2C_CTL0_SMBSEL BIT(3) /*!< SMBus type */
+#define I2C_CTL0_ARPEN BIT(4) /*!< ARP enable */
+#define I2C_CTL0_PECEN BIT(5) /*!< PEC enable */
+#define I2C_CTL0_GCEN BIT(6) /*!< general call enable */
+#define I2C_CTL0_SS BIT(7) /*!< clock stretching disable (slave mode) */
+#define I2C_CTL0_START BIT(8) /*!< start generation */
+#define I2C_CTL0_STOP BIT(9) /*!< stop generation */
+#define I2C_CTL0_ACKEN BIT(10) /*!< acknowledge enable */
+#define I2C_CTL0_POAP BIT(11) /*!< acknowledge/PEC position (for data reception) */
+#define I2C_CTL0_PECTRANS BIT(12) /*!< packet error checking */
+#define I2C_CTL0_SALT BIT(13) /*!< SMBus alert */
+#define I2C_CTL0_SRESET BIT(15) /*!< software reset */
/* I2Cx_CTL1 */
-#define I2C_CTL1_I2CCLK BITS(0,5) /*!< I2CCLK[5:0] bits (peripheral clock frequency) */
-#define I2C_CTL1_ERRIE BIT(8) /*!< error interrupt enable */
-#define I2C_CTL1_EVIE BIT(9) /*!< event interrupt enable */
-#define I2C_CTL1_BUFIE BIT(10) /*!< buffer interrupt enable */
-#define I2C_CTL1_DMAON BIT(11) /*!< DMA requests enable */
-#define I2C_CTL1_DMALST BIT(12) /*!< DMA last transfer */
+#define I2C_CTL1_I2CCLK BITS(0,5) /*!< I2CCLK[5:0] bits (peripheral clock frequency) */
+#define I2C_CTL1_ERRIE BIT(8) /*!< error interrupt enable */
+#define I2C_CTL1_EVIE BIT(9) /*!< event interrupt enable */
+#define I2C_CTL1_BUFIE BIT(10) /*!< buffer interrupt enable */
+#define I2C_CTL1_DMAON BIT(11) /*!< DMA requests enable */
+#define I2C_CTL1_DMALST BIT(12) /*!< DMA last transfer */
/* I2Cx_SADDR0 */
-#define I2C_SADDR0_ADDRESS0 BIT(0) /*!< bit 0 of a 10-bit address */
-#define I2C_SADDR0_ADDRESS BITS(1,7) /*!< 7-bit address or bits 7:1 of a 10-bit address */
-#define I2C_SADDR0_ADDRESS_H BITS(8,9) /*!< highest two bits of a 10-bit address */
-#define I2C_SADDR0_ADDFORMAT BIT(15) /*!< address mode for the I2C slave */
+#define I2C_SADDR0_ADDRESS0 BIT(0) /*!< bit 0 of a 10-bit address */
+#define I2C_SADDR0_ADDRESS BITS(1,7) /*!< 7-bit address or bits 7:1 of a 10-bit address */
+#define I2C_SADDR0_ADDRESS_H BITS(8,9) /*!< highest two bits of a 10-bit address */
+#define I2C_SADDR0_ADDFORMAT BIT(15) /*!< address mode for the I2C slave */
/* I2Cx_SADDR1 */
-#define I2C_SADDR1_DUADEN BIT(0) /*!< aual-address mode switch */
-#define I2C_SADDR1_ADDRESS2 BITS(1,7) /*!< second I2C address for the slave in dual-address mode */
+#define I2C_SADDR1_DUADEN BIT(0) /*!< aual-address mode switch */
+#define I2C_SADDR1_ADDRESS2 BITS(1,7) /*!< second I2C address for the slave in dual-address mode */
/* I2Cx_DATA */
-#define I2C_DATA_TRB BITS(0,7) /*!< 8-bit data register */
+#define I2C_DATA_TRB BITS(0,7) /*!< 8-bit data register */
/* I2Cx_STAT0 */
-#define I2C_STAT0_SBSEND BIT(0) /*!< start bit (master mode) */
-#define I2C_STAT0_ADDSEND BIT(1) /*!< address sent (master mode)/matched (slave mode) */
-#define I2C_STAT0_BTC BIT(2) /*!< byte transfer finished */
-#define I2C_STAT0_ADD10SEND BIT(3) /*!< 10-bit header sent (master mode) */
-#define I2C_STAT0_STPDET BIT(4) /*!< stop detection (slave mode) */
-#define I2C_STAT0_RBNE BIT(6) /*!< data register not empty (receivers) */
-#define I2C_STAT0_TBE BIT(7) /*!< data register empty (transmitters) */
-#define I2C_STAT0_BERR BIT(8) /*!< bus error */
-#define I2C_STAT0_LOSTARB BIT(9) /*!< arbitration lost (master mode) */
-#define I2C_STAT0_AERR BIT(10) /*!< acknowledge failure */
-#define I2C_STAT0_OUERR BIT(11) /*!< overrun/underrun */
-#define I2C_STAT0_PECERR BIT(12) /*!< PEC error in reception */
-#define I2C_STAT0_SMBTO BIT(14) /*!< timeout signal in SMBus mode */
-#define I2C_STAT0_SMBALT BIT(15) /*!< SMBus alert status */
+#define I2C_STAT0_SBSEND BIT(0) /*!< start bit (master mode) */
+#define I2C_STAT0_ADDSEND BIT(1) /*!< address sent (master mode)/matched (slave mode) */
+#define I2C_STAT0_BTC BIT(2) /*!< byte transfer finished */
+#define I2C_STAT0_ADD10SEND BIT(3) /*!< 10-bit header sent (master mode) */
+#define I2C_STAT0_STPDET BIT(4) /*!< stop detection (slave mode) */
+#define I2C_STAT0_RBNE BIT(6) /*!< data register not empty (receivers) */
+#define I2C_STAT0_TBE BIT(7) /*!< data register empty (transmitters) */
+#define I2C_STAT0_BERR BIT(8) /*!< bus error */
+#define I2C_STAT0_LOSTARB BIT(9) /*!< arbitration lost (master mode) */
+#define I2C_STAT0_AERR BIT(10) /*!< acknowledge failure */
+#define I2C_STAT0_OUERR BIT(11) /*!< overrun/underrun */
+#define I2C_STAT0_PECERR BIT(12) /*!< PEC error in reception */
+#define I2C_STAT0_SMBTO BIT(14) /*!< timeout signal in SMBus mode */
+#define I2C_STAT0_SMBALT BIT(15) /*!< SMBus alert status */
/* I2Cx_STAT1 */
-#define I2C_STAT1_MASTER BIT(0) /*!< master/slave */
-#define I2C_STAT1_I2CBSY BIT(1) /*!< bus busy */
-#define I2C_STAT1_TR BIT(2) /*!< transmitter/receiver */
-#define I2C_STAT1_RXGC BIT(4) /*!< general call address (slave mode) */
-#define I2C_STAT1_DEFSMB BIT(5) /*!< SMBus device default address (slave mode) */
-#define I2C_STAT1_HSTSMB BIT(6) /*!< SMBus host header (slave mode) */
-#define I2C_STAT1_DUMODF BIT(7) /*!< dual flag (slave mode) */
-#define I2C_STAT1_PECV BITS(8,15) /*!< packet error checking value */
+#define I2C_STAT1_MASTER BIT(0) /*!< master/slave */
+#define I2C_STAT1_I2CBSY BIT(1) /*!< bus busy */
+#define I2C_STAT1_TR BIT(2) /*!< transmitter/receiver */
+#define I2C_STAT1_RXGC BIT(4) /*!< general call address (slave mode) */
+#define I2C_STAT1_DEFSMB BIT(5) /*!< SMBus device default address (slave mode) */
+#define I2C_STAT1_HSTSMB BIT(6) /*!< SMBus host header (slave mode) */
+#define I2C_STAT1_DUMODF BIT(7) /*!< dual flag (slave mode) */
+#define I2C_STAT1_PECV BITS(8,15) /*!< packet error checking value */
/* I2Cx_CKCFG */
-#define I2C_CKCFG_CLKC BITS(0,11) /*!< clock control register in fast/standard mode (master mode) */
-#define I2C_CKCFG_DTCY BIT(14) /*!< fast mode duty cycle */
-#define I2C_CKCFG_FAST BIT(15) /*!< I2C speed selection in master mode */
+#define I2C_CKCFG_CLKC BITS(0,11) /*!< clock control register in fast/standard mode (master mode) */
+#define I2C_CKCFG_DTCY BIT(14) /*!< fast mode duty cycle */
+#define I2C_CKCFG_FAST BIT(15) /*!< I2C speed selection in master mode */
/* I2Cx_RT */
-#define I2C_RT_RISETIME BITS(0,5) /*!< maximum rise time in fast/standard mode (Master mode) */
+#define I2C_RT_RISETIME BITS(0,5) /*!< maximum rise time in fast/standard mode (Master mode) */
/* I2Cx_FCTL */
-#define I2C_FCTL_DF BITS(0,3) /*!< digital noise filter */
-#define I2C_FCTL_AFD BIT(4) /*!< analog noise filter disable */
+#define I2C_FCTL_DF BITS(0,3) /*!< digital noise filter */
+#define I2C_FCTL_AFD BIT(4) /*!< analog noise filter disable */
/* I2Cx_SAMCS */
-#define I2C_SAMCS_SAMEN BIT(0) /*!< SAM_V interface enable */
-#define I2C_SAMCS_STOEN BIT(1) /*!< SAM_V interface timeout detect enable */
-#define I2C_SAMCS_TFFIE BIT(4) /*!< txframe fall interrupt enable */
-#define I2C_SAMCS_TFRIE BIT(5) /*!< txframe rise interrupt enable */
-#define I2C_SAMCS_RFFIE BIT(6) /*!< rxframe fall interrupt enable */
-#define I2C_SAMCS_RFRIE BIT(7) /*!< rxframe rise interrupt enable */
-#define I2C_SAMCS_TXF BIT(8) /*!< level of txframe signal */
-#define I2C_SAMCS_RXF BIT(9) /*!< level of rxframe signal */
-#define I2C_SAMCS_TFF BIT(12) /*!< txframe fall flag, cleared by software write 0 */
-#define I2C_SAMCS_TFR BIT(13) /*!< txframe rise flag, cleared by software write 0 */
-#define I2C_SAMCS_RFF BIT(14) /*!< rxframe fall flag, cleared by software write 0 */
-#define I2C_SAMCS_RFR BIT(15) /*!< rxframe rise flag, cleared by software write 0 */
-
-/* constants definitions */
-
-/* the digital noise filter can filter spikes's length */
-typedef enum {
- I2C_DF_DISABLE, /*!< disable digital noise filter */
- I2C_DF_1PCLK, /*!< enable digital noise filter and the maximum filtered spiker's length 1 PCLK1 */
- I2C_DF_2PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 2 PCLK1 */
- I2C_DF_3PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 3 PCLK1 */
- I2C_DF_4PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 4 PCLK1 */
- I2C_DF_5PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 5 PCLK1 */
- I2C_DF_6PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 6 PCLK1 */
- I2C_DF_7PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 7 PCLK1 */
- I2C_DF_8PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 8 PCLK1 */
- I2C_DF_9PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 9 PCLK1 */
- I2C_DF_10PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 10 PCLK1 */
- I2C_DF_11PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 11 PCLK1 */
- I2C_DF_12PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 12 PCLK1 */
- I2C_DF_13PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 13 PCLK1 */
- I2C_DF_14PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 14 PCLK1 */
- I2C_DF_15PCLKS /*!< enable digital noise filter and the maximum filtered spiker's length 15 PCLK1 */
-}i2c_digital_filter_enum;
+#define I2C_SAMCS_SAMEN BIT(0) /*!< SAM_V interface enable */
+#define I2C_SAMCS_STOEN BIT(1) /*!< SAM_V interface timeout detect enable */
+#define I2C_SAMCS_TFFIE BIT(4) /*!< txframe fall interrupt enable */
+#define I2C_SAMCS_TFRIE BIT(5) /*!< txframe rise interrupt enable */
+#define I2C_SAMCS_RFFIE BIT(6) /*!< rxframe fall interrupt enable */
+#define I2C_SAMCS_RFRIE BIT(7) /*!< rxframe rise interrupt enable */
+#define I2C_SAMCS_TXF BIT(8) /*!< level of txframe signal */
+#define I2C_SAMCS_RXF BIT(9) /*!< level of rxframe signal */
+#define I2C_SAMCS_TFF BIT(12) /*!< txframe fall flag */
+#define I2C_SAMCS_TFR BIT(13) /*!< txframe rise flag */
+#define I2C_SAMCS_RFF BIT(14) /*!< rxframe fall flag */
+#define I2C_SAMCS_RFR BIT(15) /*!< rxframe rise flag */
/* constants definitions */
/* define the I2C bit position and its register index offset */
#define I2C_REGIDX_BIT(regidx, bitpos) (((uint32_t)(regidx) << 6) | (uint32_t)(bitpos))
-#define I2C_REG_VAL(i2cx, offset) (REG32((i2cx) + (((uint32_t)(offset) & 0xFFFFU) >> 6)))
-#define I2C_BIT_POS(val) ((uint32_t)(val) & 0x1FU)
+#define I2C_REG_VAL(i2cx, offset) (REG32((i2cx) + (((uint32_t)(offset) & 0x0000FFFFU) >> 6)))
+#define I2C_BIT_POS(val) ((uint32_t)(val) & 0x0000001FU)
#define I2C_REGIDX_BIT2(regidx, bitpos, regidx2, bitpos2) (((uint32_t)(regidx2) << 22) | (uint32_t)((bitpos2) << 16)\
- | (((uint32_t)(regidx) << 6) | (uint32_t)(bitpos)))
+ | (((uint32_t)(regidx) << 6) | (uint32_t)(bitpos)))
#define I2C_REG_VAL2(i2cx, offset) (REG32((i2cx) + ((uint32_t)(offset) >> 22)))
-#define I2C_BIT_POS2(val) (((uint32_t)(val) & 0x1F0000U) >> 16)
+#define I2C_BIT_POS2(val) (((uint32_t)(val) & 0x001F0000U) >> 16)
/* register offset */
-#define I2C_CTL1_REG_OFFSET 0x04U /*!< CTL1 register offset */
-#define I2C_STAT0_REG_OFFSET 0x14U /*!< STAT0 register offset */
-#define I2C_STAT1_REG_OFFSET 0x18U /*!< STAT1 register offset */
-#define I2C_SAMCS_REG_OFFSET 0x80U /*!< SAMCS register offset */
+#define I2C_CTL1_REG_OFFSET ((uint32_t)0x00000004U) /*!< CTL1 register offset */
+#define I2C_STAT0_REG_OFFSET ((uint32_t)0x00000014U) /*!< STAT0 register offset */
+#define I2C_STAT1_REG_OFFSET ((uint32_t)0x00000018U) /*!< STAT1 register offset */
+#define I2C_SAMCS_REG_OFFSET ((uint32_t)0x00000080U) /*!< SAMCS register offset */
/* I2C flags */
-typedef enum
-{
+typedef enum {
/* flags in STAT0 register */
- I2C_FLAG_SBSEND = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 0U), /*!< start condition sent out in master mode */
- I2C_FLAG_ADDSEND = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 1U), /*!< address is sent in master mode or received and matches in slave mode */
- I2C_FLAG_BTC = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 2U), /*!< byte transmission finishes */
- I2C_FLAG_ADD10SEND = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 3U), /*!< header of 10-bit address is sent in master mode */
- I2C_FLAG_STPDET = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 4U), /*!< stop condition detected in slave mode */
- I2C_FLAG_RBNE = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 6U), /*!< I2C_DATA is not Empty during receiving */
- I2C_FLAG_TBE = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 7U), /*!< I2C_DATA is empty during transmitting */
- I2C_FLAG_BERR = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 8U), /*!< a bus error occurs indication a unexpected start or stop condition on I2C bus */
- I2C_FLAG_LOSTARB = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 9U), /*!< arbitration lost in master mode */
- I2C_FLAG_AERR = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 10U), /*!< acknowledge error */
- I2C_FLAG_OUERR = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 11U), /*!< over-run or under-run situation occurs in slave mode */
- I2C_FLAG_PECERR = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 12U), /*!< PEC error when receiving data */
- I2C_FLAG_SMBTO = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 14U), /*!< timeout signal in SMBus mode */
- I2C_FLAG_SMBALT = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 15U), /*!< SMBus alert status */
+ I2C_FLAG_SBSEND = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 0U), /*!< start condition sent out in master mode */
+ I2C_FLAG_ADDSEND = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 1U), /*!< address is sent in master mode or received and matches in slave mode */
+ I2C_FLAG_BTC = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 2U), /*!< byte transmission finishes */
+ I2C_FLAG_ADD10SEND = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 3U), /*!< header of 10-bit address is sent in master mode */
+ I2C_FLAG_STPDET = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 4U), /*!< stop condition detected in slave mode */
+ I2C_FLAG_RBNE = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 6U), /*!< I2C_DATA is not empty during receiving */
+ I2C_FLAG_TBE = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 7U), /*!< I2C_DATA is empty during transmitting */
+ I2C_FLAG_BERR = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 8U), /*!< a bus error occurs indication a unexpected start or stop condition on I2C bus */
+ I2C_FLAG_LOSTARB = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 9U), /*!< arbitration lost in master mode */
+ I2C_FLAG_AERR = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 10U), /*!< acknowledge error */
+ I2C_FLAG_OUERR = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 11U), /*!< over-run or under-run situation occurs in slave mode */
+ I2C_FLAG_PECERR = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 12U), /*!< PEC error when receiving data */
+ I2C_FLAG_SMBTO = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 14U), /*!< timeout signal in SMBus mode */
+ I2C_FLAG_SMBALT = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 15U), /*!< SMBus alert status */
/* flags in STAT1 register */
- I2C_FLAG_MASTER = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 0U), /*!< a flag indicating whether I2C block is in master or slave mode */
- I2C_FLAG_I2CBSY = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 1U), /*!< busy flag */
- I2C_FLAG_TRS = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 2U), /*!< whether the I2C is a transmitter or a receiver */
- I2C_FLAG_RXGC = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 4U), /*!< general call address (00h) received */
- I2C_FLAG_DEFSMB = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 5U), /*!< default address of SMBus device */
- I2C_FLAG_HSTSMB = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 6U), /*!< SMBus host header detected in slave mode */
- I2C_FLAG_DUMOD = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 7U), /*!< dual flag in slave mode indicating which address is matched in dual-address mode */
+ I2C_FLAG_MASTER = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 0U), /*!< a flag indicating whether I2C block is in master or slave mode */
+ I2C_FLAG_I2CBSY = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 1U), /*!< busy flag */
+ I2C_FLAG_TR = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 2U), /*!< whether the I2C is a transmitter or a receiver */
+ I2C_FLAG_RXGC = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 4U), /*!< general call address (00h) received */
+ I2C_FLAG_DEFSMB = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 5U), /*!< default address of SMBus device */
+ I2C_FLAG_HSTSMB = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 6U), /*!< SMBus host header detected in slave mode */
+ I2C_FLAG_DUMOD = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 7U), /*!< dual flag in slave mode indicating which address is matched in dual-address mode */
/* flags in SAMCS register */
- I2C_FLAG_TFF = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 12U), /*!< txframe fall flag */
- I2C_FLAG_TFR = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 13U), /*!< txframe rise flag */
- I2C_FLAG_RFF = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 14U), /*!< rxframe fall flag */
- I2C_FLAG_RFR = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 15U) /*!< rxframe rise flag */
-}i2c_flag_enum;
+ I2C_FLAG_TFF = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 12U), /*!< txframe fall flag */
+ I2C_FLAG_TFR = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 13U), /*!< txframe rise flag */
+ I2C_FLAG_RFF = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 14U), /*!< rxframe fall flag */
+ I2C_FLAG_RFR = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 15U) /*!< rxframe rise flag */
+} i2c_flag_enum;
/* I2C interrupt flags */
-typedef enum
-{
+typedef enum {
/* interrupt flags in CTL1 register */
I2C_INT_FLAG_SBSEND = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 9U, I2C_STAT0_REG_OFFSET, 0U), /*!< start condition sent out in master mode interrupt flag */
I2C_INT_FLAG_ADDSEND = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 9U, I2C_STAT0_REG_OFFSET, 1U), /*!< address is sent in master mode or received and matches in slave mode interrupt flag */
- I2C_INT_FLAG_BTC = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 9U, I2C_STAT0_REG_OFFSET, 2U), /*!< byte transmission finishes */
+ I2C_INT_FLAG_BTC = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 9U, I2C_STAT0_REG_OFFSET, 2U), /*!< byte transmission finishes interrupt flag */
I2C_INT_FLAG_ADD10SEND = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 9U, I2C_STAT0_REG_OFFSET, 3U), /*!< header of 10-bit address is sent in master mode interrupt flag */
I2C_INT_FLAG_STPDET = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 9U, I2C_STAT0_REG_OFFSET, 4U), /*!< stop condition detected in slave mode interrupt flag */
I2C_INT_FLAG_RBNE = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 9U, I2C_STAT0_REG_OFFSET, 6U), /*!< I2C_DATA is not Empty during receiving interrupt flag */
@@ -237,90 +213,105 @@ typedef enum
I2C_INT_FLAG_OUERR = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 8U, I2C_STAT0_REG_OFFSET, 11U), /*!< over-run or under-run situation occurs in slave mode interrupt flag */
I2C_INT_FLAG_PECERR = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 8U, I2C_STAT0_REG_OFFSET, 12U), /*!< PEC error when receiving data interrupt flag */
I2C_INT_FLAG_SMBTO = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 8U, I2C_STAT0_REG_OFFSET, 14U), /*!< timeout signal in SMBus mode interrupt flag */
- I2C_INT_FLAG_SMBALT = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 8U, I2C_STAT0_REG_OFFSET, 15U), /*!< SMBus Alert status interrupt flag */
+ I2C_INT_FLAG_SMBALT = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 8U, I2C_STAT0_REG_OFFSET, 15U), /*!< SMBus alert status interrupt flag */
/* interrupt flags in SAMCS register */
I2C_INT_FLAG_TFF = I2C_REGIDX_BIT2(I2C_SAMCS_REG_OFFSET, 4U, I2C_SAMCS_REG_OFFSET, 12U), /*!< txframe fall interrupt flag */
- I2C_INT_FLAG_TFR = I2C_REGIDX_BIT2(I2C_SAMCS_REG_OFFSET, 5U, I2C_SAMCS_REG_OFFSET, 13U), /*!< txframe rise interrupt flag */
+ I2C_INT_FLAG_TFR = I2C_REGIDX_BIT2(I2C_SAMCS_REG_OFFSET, 5U, I2C_SAMCS_REG_OFFSET, 13U), /*!< txframe rise interrupt flag */
I2C_INT_FLAG_RFF = I2C_REGIDX_BIT2(I2C_SAMCS_REG_OFFSET, 6U, I2C_SAMCS_REG_OFFSET, 14U), /*!< rxframe fall interrupt flag */
- I2C_INT_FLAG_RFR = I2C_REGIDX_BIT2(I2C_SAMCS_REG_OFFSET, 7U, I2C_SAMCS_REG_OFFSET, 15U) /*!< rxframe rise interrupt flag */
-}i2c_interrupt_flag_enum;
+ I2C_INT_FLAG_RFR = I2C_REGIDX_BIT2(I2C_SAMCS_REG_OFFSET, 7U, I2C_SAMCS_REG_OFFSET, 15U) /*!< rxframe rise interrupt flag */
+} i2c_interrupt_flag_enum;
-/* I2C interrupt enable or disable */
-typedef enum
-{
+/* I2C interrupt */
+typedef enum {
/* interrupt in CTL1 register */
- I2C_INT_ERR = I2C_REGIDX_BIT(I2C_CTL1_REG_OFFSET, 8U), /*!< error interrupt enable */
- I2C_INT_EV = I2C_REGIDX_BIT(I2C_CTL1_REG_OFFSET, 9U), /*!< event interrupt enable */
- I2C_INT_BUF = I2C_REGIDX_BIT(I2C_CTL1_REG_OFFSET, 10U), /*!< buffer interrupt enable */
+ I2C_INT_ERR = I2C_REGIDX_BIT(I2C_CTL1_REG_OFFSET, 8U), /*!< error interrupt */
+ I2C_INT_EV = I2C_REGIDX_BIT(I2C_CTL1_REG_OFFSET, 9U), /*!< event interrupt */
+ I2C_INT_BUF = I2C_REGIDX_BIT(I2C_CTL1_REG_OFFSET, 10U), /*!< buffer interrupt */
/* interrupt in SAMCS register */
- I2C_INT_TFF = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 4U), /*!< txframe fall interrupt enable */
- I2C_INT_TFR = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 5U), /*!< txframe rise interrupt enable */
- I2C_INT_RFF = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 6U), /*!< rxframe fall interrupt enable */
- I2C_INT_RFR = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 7U) /*!< rxframe rise interrupt enable */
-}i2c_interrupt_enum;
+ I2C_INT_TFF = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 4U), /*!< txframe fall interrupt */
+ I2C_INT_TFR = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 5U), /*!< txframe rise interrupt */
+ I2C_INT_RFF = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 6U), /*!< rxframe fall interrupt */
+ I2C_INT_RFR = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 7U) /*!< rxframe rise interrupt */
+} i2c_interrupt_enum;
+
+/* the digital noise filter can filter spikes's length */
+typedef enum {
+ I2C_DF_DISABLE = 0, /*!< disable digital noise filter */
+ I2C_DF_1PCLK, /*!< enable digital noise filter and the maximum filtered spiker's length 1 PCLK1 */
+ I2C_DF_2PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 2 PCLK1 */
+ I2C_DF_3PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 3 PCLK1 */
+ I2C_DF_4PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 4 PCLK1 */
+ I2C_DF_5PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 5 PCLK1 */
+ I2C_DF_6PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 6 PCLK1 */
+ I2C_DF_7PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 7 PCLK1 */
+ I2C_DF_8PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 8 PCLK1 */
+ I2C_DF_9PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 9 PCLK1 */
+ I2C_DF_10PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 10 PCLK1 */
+ I2C_DF_11PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 11 PCLK1 */
+ I2C_DF_12PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 12 PCLK1 */
+ I2C_DF_13PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 13 PCLK1 */
+ I2C_DF_14PCLKS, /*!< enable digital noise filter and the maximum filtered spiker's length 14 PCLK1 */
+ I2C_DF_15PCLKS /*!< enable digital noise filter and the maximum filtered spiker's length 15 PCLK1 */
+} i2c_digital_filter_enum;
/* SMBus/I2C mode switch and SMBus type selection */
-#define I2C_I2CMODE_ENABLE ((uint32_t)0x00000000U) /*!< I2C mode */
-#define I2C_SMBUSMODE_ENABLE I2C_CTL0_SMBEN /*!< SMBus mode */
+#define I2C_I2CMODE_ENABLE ((uint32_t)0x00000000U) /*!< I2C mode */
+#define I2C_SMBUSMODE_ENABLE I2C_CTL0_SMBEN /*!< SMBus mode */
/* SMBus/I2C mode switch and SMBus type selection */
-#define I2C_SMBUS_DEVICE ((uint32_t)0x00000000U) /*!< SMBus mode device type */
-#define I2C_SMBUS_HOST I2C_CTL0_SMBSEL /*!< SMBus mode host type */
+#define I2C_SMBUS_DEVICE ((uint32_t)0x00000000U) /*!< SMBus mode device type */
+#define I2C_SMBUS_HOST I2C_CTL0_SMBSEL /*!< SMBus mode host type */
/* I2C transfer direction */
-#define I2C_RECEIVER ((uint32_t)0x00000001U) /*!< receiver */
-#define I2C_TRANSMITTER ((uint32_t)0xFFFFFFFEU) /*!< transmitter */
+#define I2C_RECEIVER ((uint32_t)0x00000001U) /*!< receiver */
+#define I2C_TRANSMITTER ((uint32_t)0xFFFFFFFEU) /*!< transmitter */
/* whether or not to send an ACK */
-#define I2C_ACK_DISABLE ((uint32_t)0x00000000U) /*!< ACK will be not sent */
-#define I2C_ACK_ENABLE ((uint32_t)0x00000001U) /*!< ACK will be sent */
+#define I2C_ACK_DISABLE ((uint32_t)0x00000000U) /*!< ACK will be not sent */
+#define I2C_ACK_ENABLE I2C_CTL0_ACKEN /*!< ACK will be sent */
/* I2C POAP position*/
-#define I2C_ACKPOS_NEXT ((uint32_t)0x00000000U) /*!< ACKEN bit decides whether or not to send ACK for the next byte */
-#define I2C_ACKPOS_CURRENT ((uint32_t)0x00000001U) /*!< ACKEN bit decides whether or not to send ACK or not for the current byte */
-
-/* I2C dual-address mode switch */
-#define I2C_DUADEN_DISABLE ((uint32_t)0x00000000U) /*!< dual-address mode disabled */
-#define I2C_DUADEN_ENABLE ((uint32_t)0x00000001U) /*!< dual-address mode enabled */
+#define I2C_ACKPOS_CURRENT ((uint32_t)0x00000000U) /*!< ACKEN bit decides whether or not to send ACK or not for the current byte */
+#define I2C_ACKPOS_NEXT I2C_CTL0_POAP /*!< ACKEN bit decides whether or not to send ACK for the next byte */
/* whether or not to stretch SCL low */
-#define I2C_SCLSTRETCH_ENABLE ((uint32_t)0x00000000U) /*!< SCL stretching is enabled */
-#define I2C_SCLSTRETCH_DISABLE I2C_CTL0_SS /*!< SCL stretching is disabled */
+#define I2C_SCLSTRETCH_ENABLE ((uint32_t)0x00000000U) /*!< enable SCL stretching */
+#define I2C_SCLSTRETCH_DISABLE I2C_CTL0_SS /*!< disable SCL stretching */
/* whether or not to response to a general call */
-#define I2C_GCEN_ENABLE I2C_CTL0_GCEN /*!< slave will response to a general call */
-#define I2C_GCEN_DISABLE ((uint32_t)0x00000000U) /*!< slave will not response to a general call */
+#define I2C_GCEN_ENABLE I2C_CTL0_GCEN /*!< slave will response to a general call */
+#define I2C_GCEN_DISABLE ((uint32_t)0x00000000U) /*!< slave will not response to a general call */
/* software reset I2C */
-#define I2C_SRESET_SET I2C_CTL0_SRESET /*!< I2C is under reset */
-#define I2C_SRESET_RESET ((uint32_t)0x00000000U) /*!< I2C is not under reset */
+#define I2C_SRESET_RESET ((uint32_t)0x00000000U) /*!< I2C is not under reset */
+#define I2C_SRESET_SET I2C_CTL0_SRESET /*!< I2C is under reset */
/* I2C DMA mode configure */
/* DMA mode switch */
-#define I2C_DMA_ON I2C_CTL1_DMAON /*!< DMA mode enabled */
-#define I2C_DMA_OFF ((uint32_t)0x00000000U) /*!< DMA mode disabled */
+#define I2C_DMA_OFF ((uint32_t)0x00000000U) /*!< disable DMA mode */
+#define I2C_DMA_ON I2C_CTL1_DMAON /*!< enable DMA mode */
/* flag indicating DMA last transfer */
-#define I2C_DMALST_ON I2C_CTL1_DMALST /*!< next DMA EOT is the last transfer */
-#define I2C_DMALST_OFF ((uint32_t)0x00000000U) /*!< next DMA EOT is not the last transfer */
+#define I2C_DMALST_OFF ((uint32_t)0x00000000U) /*!< next DMA EOT is not the last transfer */
+#define I2C_DMALST_ON I2C_CTL1_DMALST /*!< next DMA EOT is the last transfer */
/* I2C PEC configure */
/* PEC enable */
-#define I2C_PEC_ENABLE I2C_CTL0_PECEN /*!< PEC calculation on */
-#define I2C_PEC_DISABLE ((uint32_t)0x00000000U) /*!< PEC calculation off */
+#define I2C_PEC_DISABLE ((uint32_t)0x00000000U) /*!< PEC calculation off */
+#define I2C_PEC_ENABLE I2C_CTL0_PECEN /*!< PEC calculation on */
/* PEC transfer */
-#define I2C_PECTRANS_ENABLE I2C_CTL0_PECTRANS /*!< transfer PEC */
-#define I2C_PECTRANS_DISABLE ((uint32_t)0x00000000U) /*!< not transfer PEC value */
+#define I2C_PECTRANS_DISABLE ((uint32_t)0x00000000U) /*!< not transfer PEC value */
+#define I2C_PECTRANS_ENABLE I2C_CTL0_PECTRANS /*!< transfer PEC value */
/* I2C SMBus configure */
/* issue or not alert through SMBA pin */
-#define I2C_SALTSEND_ENABLE I2C_CTL0_SALT /*!< issue alert through SMBA pin */
-#define I2C_SALTSEND_DISABLE ((uint32_t)0x00000000U) /*!< not issue alert through SMBA */
+#define I2C_SALTSEND_DISABLE ((uint32_t)0x00000000U) /*!< not issue alert through SMBA */
+#define I2C_SALTSEND_ENABLE I2C_CTL0_SALT /*!< issue alert through SMBA pin */
/* ARP protocol in SMBus switch */
-#define I2C_ARP_ENABLE I2C_CTL0_ARPEN /*!< ARP is enabled */
-#define I2C_ARP_DISABLE ((uint32_t)0x00000000U) /*!< ARP is disabled */
+#define I2C_ARP_DISABLE ((uint32_t)0x00000000U) /*!< disable ARP */
+#define I2C_ARP_ENABLE I2C_CTL0_ARPEN /*!< enable ARP */
/* transmit I2C data */
#define DATA_TRANS(regval) (BITS(0,7) & ((uint32_t)(regval) << 0))
@@ -329,21 +320,24 @@ typedef enum
#define DATA_RECV(regval) GET_BITS((uint32_t)(regval), 0, 7)
/* I2C duty cycle in fast mode */
-#define I2C_DTCY_2 ((uint32_t)0x00000000U) /*!< I2C fast mode Tlow/Thigh = 2 */
-#define I2C_DTCY_16_9 I2C_CKCFG_DTCY /*!< I2C fast mode Tlow/Thigh = 16/9 */
+#define I2C_DTCY_2 ((uint32_t)0x00000000U) /*!< T_low/T_high = 2 in fast mode */
+#define I2C_DTCY_16_9 I2C_CKCFG_DTCY /*!< T_low/T_high = 16/9 in fast mode */
/* address mode for the I2C slave */
-#define I2C_ADDFORMAT_7BITS ((uint32_t)0x00000000U) /*!< address:7 bits */
-#define I2C_ADDFORMAT_10BITS I2C_SADDR0_ADDFORMAT /*!< address:10 bits */
+#define I2C_ADDFORMAT_7BITS ((uint32_t)0x00000000U) /*!< address format is 7 bits */
+#define I2C_ADDFORMAT_10BITS I2C_SADDR0_ADDFORMAT /*!< address format is 10 bits */
/* function declarations */
+/* initialization functions */
/* reset I2C */
void i2c_deinit(uint32_t i2c_periph);
/* configure I2C clock */
void i2c_clock_config(uint32_t i2c_periph, uint32_t clkspeed, uint32_t dutycyc);
/* configure I2C address */
void i2c_mode_addr_config(uint32_t i2c_periph, uint32_t mode, uint32_t addformat, uint32_t addr);
-/* SMBus type selection */
+
+/* application function declarations */
+/* select SMBus type */
void i2c_smbus_type_config(uint32_t i2c_periph, uint32_t type);
/* whether or not to send an ACK */
void i2c_ack_config(uint32_t i2c_periph, uint32_t ack);
@@ -359,7 +353,6 @@ void i2c_dualaddr_disable(uint32_t i2c_periph);
void i2c_enable(uint32_t i2c_periph);
/* disable I2C */
void i2c_disable(uint32_t i2c_periph);
-
/* generate a START condition on I2C bus */
void i2c_start_on_bus(uint32_t i2c_periph);
/* generate a STOP condition on I2C bus */
@@ -368,35 +361,32 @@ void i2c_stop_on_bus(uint32_t i2c_periph);
void i2c_data_transmit(uint32_t i2c_periph, uint8_t data);
/* I2C receive data function */
uint8_t i2c_data_receive(uint32_t i2c_periph);
-/* enable I2C DMA mode */
-void i2c_dma_enable(uint32_t i2c_periph, uint32_t dmastate);
+/* configure I2C DMA mode */
+void i2c_dma_config(uint32_t i2c_periph, uint32_t dmastate);
/* configure whether next DMA EOT is DMA last transfer or not */
void i2c_dma_last_transfer_config(uint32_t i2c_periph, uint32_t dmalast);
/* whether to stretch SCL low when data is not ready in slave mode */
void i2c_stretch_scl_low_config(uint32_t i2c_periph, uint32_t stretchpara);
/* whether or not to response to a general call */
void i2c_slave_response_to_gcall_config(uint32_t i2c_periph, uint32_t gcallpara);
-/* software reset I2C */
+/* configure software reset of I2C */
void i2c_software_reset_config(uint32_t i2c_periph, uint32_t sreset);
-
-/* I2C PEC calculation on or off */
-void i2c_pec_enable(uint32_t i2c_periph, uint32_t pecstate);
-/* I2C whether to transfer PEC value */
-void i2c_pec_transfer_enable(uint32_t i2c_periph, uint32_t pecpara);
-/* packet error checking value */
+/* configure I2C PEC calculation */
+void i2c_pec_config(uint32_t i2c_periph, uint32_t pecstate);
+/* configure whether to transfer PEC value */
+void i2c_pec_transfer_config(uint32_t i2c_periph, uint32_t pecpara);
+/* get packet error checking value */
uint8_t i2c_pec_value_get(uint32_t i2c_periph);
-/* I2C issue alert through SMBA pin */
-void i2c_smbus_issue_alert(uint32_t i2c_periph, uint32_t smbuspara);
-/* I2C ARP protocol in SMBus switch */
-void i2c_smbus_arp_enable(uint32_t i2c_periph, uint32_t arpstate);
-
-/* I2C analog noise filter disable */
+/* configure I2C alert through SMBA pin */
+void i2c_smbus_alert_config(uint32_t i2c_periph, uint32_t smbuspara);
+/* configure I2C ARP protocol in SMBus */
+void i2c_smbus_arp_config(uint32_t i2c_periph, uint32_t arpstate);
+/* disable analog noise filter */
void i2c_analog_noise_filter_disable(uint32_t i2c_periph);
-/* I2C analog noise filter enable */
+/* enable analog noise filter */
void i2c_analog_noise_filter_enable(uint32_t i2c_periph);
-/* digital noise filter */
-void i2c_digital_noise_filter_config(uint32_t i2c_periph,i2c_digital_filter_enum dfilterpara);
-
+/* configure digital noise filter */
+void i2c_digital_noise_filter_config(uint32_t i2c_periph, i2c_digital_filter_enum dfilterpara);
/* enable SAM_V interface */
void i2c_sam_enable(uint32_t i2c_periph);
/* disable SAM_V interface */
@@ -406,17 +396,18 @@ void i2c_sam_timeout_enable(uint32_t i2c_periph);
/* disable SAM_V interface timeout detect */
void i2c_sam_timeout_disable(uint32_t i2c_periph);
-/* check I2C flag is set or not */
+/* interrupt & flag functions */
+/* get I2C flag status */
FlagStatus i2c_flag_get(uint32_t i2c_periph, i2c_flag_enum flag);
-/* clear I2C flag */
+/* clear I2C flag status */
void i2c_flag_clear(uint32_t i2c_periph, i2c_flag_enum flag);
/* enable I2C interrupt */
void i2c_interrupt_enable(uint32_t i2c_periph, i2c_interrupt_enum interrupt);
/* disable I2C interrupt */
void i2c_interrupt_disable(uint32_t i2c_periph, i2c_interrupt_enum interrupt);
-/* check I2C interrupt flag */
+/* get I2C interrupt flag status */
FlagStatus i2c_interrupt_flag_get(uint32_t i2c_periph, i2c_interrupt_flag_enum int_flag);
-/* clear I2C interrupt flag */
+/* clear I2C interrupt flag status */
void i2c_interrupt_flag_clear(uint32_t i2c_periph, i2c_interrupt_flag_enum int_flag);
#endif /* GD32F4XX_I2C_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_ipa.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_ipa.h
index d9ae8ce33a..354a490e26 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_ipa.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_ipa.h
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -40,30 +41,30 @@ OF SUCH DAMAGE.
#include "gd32f4xx.h"
/* TLI definitions */
-#define IPA IPA_BASE /*!< IPA base address */
+#define IPA IPA_BASE /*!< IPA base address */
/* bits definitions */
/* registers definitions */
-#define IPA_CTL REG32(IPA + 0x00U) /*!< IPA control register */
-#define IPA_INTF REG32(IPA + 0x04U) /*!< IPA interrupt flag register */
-#define IPA_INTC REG32(IPA + 0x08U) /*!< IPA interrupt flag clear register */
-#define IPA_FMADDR REG32(IPA + 0x0CU) /*!< IPA foreground memory base address register */
-#define IPA_FLOFF REG32(IPA + 0x10U) /*!< IPA foreground line offset register */
-#define IPA_BMADDR REG32(IPA + 0x14U) /*!< IPA background memory base address register */
-#define IPA_BLOFF REG32(IPA + 0x18U) /*!< IPA background line offset register */
-#define IPA_FPCTL REG32(IPA + 0x1CU) /*!< IPA foreground pixel control register */
-#define IPA_FPV REG32(IPA + 0x20U) /*!< IPA foreground pixel value register */
-#define IPA_BPCTL REG32(IPA + 0x24U) /*!< IPA background pixel control register */
-#define IPA_BPV REG32(IPA + 0x28U) /*!< IPA background pixel value register */
-#define IPA_FLMADDR REG32(IPA + 0x2CU) /*!< IPA foreground LUT memory base address register */
-#define IPA_BLMADDR REG32(IPA + 0x30U) /*!< IPA background LUT memory base address register */
-#define IPA_DPCTL REG32(IPA + 0x34U) /*!< IPA destination pixel control register */
-#define IPA_DPV REG32(IPA + 0x38U) /*!< IPA destination pixel value register */
-#define IPA_DMADDR REG32(IPA + 0x3CU) /*!< IPA destination memory base address register */
-#define IPA_DLOFF REG32(IPA + 0x40U) /*!< IPA destination line offset register */
-#define IPA_IMS REG32(IPA + 0x44U) /*!< IPA image size register */
-#define IPA_LM REG32(IPA + 0x48U) /*!< IPA line mark register */
-#define IPA_ITCTL REG32(IPA + 0x4CU) /*!< IPA inter-timer control register */
+#define IPA_CTL REG32(IPA + 0x00000000U) /*!< IPA control register */
+#define IPA_INTF REG32(IPA + 0x00000004U) /*!< IPA interrupt flag register */
+#define IPA_INTC REG32(IPA + 0x00000008U) /*!< IPA interrupt flag clear register */
+#define IPA_FMADDR REG32(IPA + 0x0000000CU) /*!< IPA foreground memory base address register */
+#define IPA_FLOFF REG32(IPA + 0x00000010U) /*!< IPA foreground line offset register */
+#define IPA_BMADDR REG32(IPA + 0x00000014U) /*!< IPA background memory base address register */
+#define IPA_BLOFF REG32(IPA + 0x00000018U) /*!< IPA background line offset register */
+#define IPA_FPCTL REG32(IPA + 0x0000001CU) /*!< IPA foreground pixel control register */
+#define IPA_FPV REG32(IPA + 0x00000020U) /*!< IPA foreground pixel value register */
+#define IPA_BPCTL REG32(IPA + 0x00000024U) /*!< IPA background pixel control register */
+#define IPA_BPV REG32(IPA + 0x00000028U) /*!< IPA background pixel value register */
+#define IPA_FLMADDR REG32(IPA + 0x0000002CU) /*!< IPA foreground LUT memory base address register */
+#define IPA_BLMADDR REG32(IPA + 0x00000030U) /*!< IPA background LUT memory base address register */
+#define IPA_DPCTL REG32(IPA + 0x00000034U) /*!< IPA destination pixel control register */
+#define IPA_DPV REG32(IPA + 0x00000038U) /*!< IPA destination pixel value register */
+#define IPA_DMADDR REG32(IPA + 0x0000003CU) /*!< IPA destination memory base address register */
+#define IPA_DLOFF REG32(IPA + 0x00000040U) /*!< IPA destination line offset register */
+#define IPA_IMS REG32(IPA + 0x00000044U) /*!< IPA image size register */
+#define IPA_LM REG32(IPA + 0x00000048U) /*!< IPA line mark register */
+#define IPA_ITCTL REG32(IPA + 0x0000004CU) /*!< IPA inter-timer control register */
/* IPA_CTL */
#define IPA_CTL_TEN BIT(0) /*!< transfer enable */
@@ -189,8 +190,7 @@ OF SUCH DAMAGE.
/* constants definitions */
/* IPA foreground parameter struct definitions */
-typedef struct
-{
+typedef struct {
uint32_t foreground_memaddr; /*!< foreground memory base address */
uint32_t foreground_lineoff; /*!< foreground line offset */
uint32_t foreground_prealpha; /*!< foreground pre-defined alpha value */
@@ -199,11 +199,10 @@ typedef struct
uint32_t foreground_prered; /*!< foreground pre-defined red value */
uint32_t foreground_pregreen; /*!< foreground pre-defined green value */
uint32_t foreground_preblue; /*!< foreground pre-defined blue value */
-}ipa_foreground_parameter_struct;
+} ipa_foreground_parameter_struct;
/* IPA background parameter struct definitions */
-typedef struct
-{
+typedef struct {
uint32_t background_memaddr; /*!< background memory base address */
uint32_t background_lineoff; /*!< background line offset */
uint32_t background_prealpha; /*!< background pre-defined alpha value */
@@ -212,11 +211,10 @@ typedef struct
uint32_t background_prered; /*!< background pre-defined red value */
uint32_t background_pregreen; /*!< background pre-defined green value */
uint32_t background_preblue; /*!< background pre-defined blue value */
-}ipa_background_parameter_struct;
+} ipa_background_parameter_struct;
/* IPA destination parameter struct definitions */
-typedef struct
-{
+typedef struct {
uint32_t destination_memaddr; /*!< destination memory base address */
uint32_t destination_lineoff; /*!< destination line offset */
uint32_t destination_prealpha; /*!< destination pre-defined alpha value */
@@ -226,11 +224,10 @@ typedef struct
uint32_t destination_preblue; /*!< destination pre-defined blue value */
uint32_t image_width; /*!< width of the image to be processed */
uint32_t image_height; /*!< height of the image to be processed */
-}ipa_destination_parameter_struct;
+} ipa_destination_parameter_struct;
/* destination pixel format */
-typedef enum
-{
+typedef enum {
IPA_DPF_ARGB8888, /*!< destination pixel format ARGB8888 */
IPA_DPF_RGB888, /*!< destination pixel format RGB888 */
IPA_DPF_RGB565, /*!< destination pixel format RGB565 */
@@ -341,19 +338,19 @@ void ipa_pixel_format_convert_mode_set(uint32_t pfcm);
/* structure initialization, foreground, background, destination and LUT initialization */
/* initialize the structure of IPA foreground parameter struct with the default values, it is
suggested that call this function after an ipa_foreground_parameter_struct structure is defined */
-void ipa_foreground_struct_para_init(ipa_foreground_parameter_struct* foreground_struct);
+void ipa_foreground_struct_para_init(ipa_foreground_parameter_struct *foreground_struct);
/* initialize foreground parameters */
-void ipa_foreground_init(ipa_foreground_parameter_struct* foreground_struct);
+void ipa_foreground_init(ipa_foreground_parameter_struct *foreground_struct);
/* initialize the structure of IPA background parameter struct with the default values, it is
suggested that call this function after an ipa_background_parameter_struct structure is defined */
-void ipa_background_struct_para_init(ipa_background_parameter_struct* background_struct);
+void ipa_background_struct_para_init(ipa_background_parameter_struct *background_struct);
/* initialize background parameters */
-void ipa_background_init(ipa_background_parameter_struct* background_struct);
+void ipa_background_init(ipa_background_parameter_struct *background_struct);
/* initialize the structure of IPA destination parameter struct with the default values, it is
suggested that call this function after an ipa_destination_parameter_struct structure is defined */
-void ipa_destination_struct_para_init(ipa_destination_parameter_struct* destination_struct);
+void ipa_destination_struct_para_init(ipa_destination_parameter_struct *destination_struct);
/* initialize destination parameters */
-void ipa_destination_init(ipa_destination_parameter_struct* destination_struct);
+void ipa_destination_init(ipa_destination_parameter_struct *destination_struct);
/* initialize IPA foreground LUT parameters */
void ipa_foreground_lut_init(uint8_t fg_lut_num, uint8_t fg_lut_pf, uint32_t fg_lut_addr);
/* initialize IPA background LUT parameters */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_iref.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_iref.h
index 4be9181ed8..807ab08ba8 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_iref.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_iref.h
@@ -5,32 +5,33 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -50,7 +51,7 @@ OF SUCH DAMAGE.
#define IREF_CTL_CSDT BITS(0,5) /*!< current step data */
#define IREF_CTL_SCMOD BIT(7) /*!< sink current mode */
#define IREF_CTL_CPT BITS(8,12) /*!< current precision trim */
-#define IREF_CTL_SSEL BIT(14) /*!< step selection */
+#define IREF_CTL_SSEL BIT(14) /*!< step selection */
#define IREF_CTL_CREN BIT(15) /*!< current reference enable */
/* constants definitions */
@@ -155,19 +156,19 @@ OF SUCH DAMAGE.
#define IREF_CUR_STEP_DATA_61 CTL_CSDT(61) /*!< IREF current step data 61 */
#define IREF_CUR_STEP_DATA_62 CTL_CSDT(62) /*!< IREF current step data 62 */
#define IREF_CUR_STEP_DATA_63 CTL_CSDT(63) /*!< IREF current step data 63 */
-
+
/* IREF mode selection */
#define IREF_STEP(regval) (BIT(14) & ((uint32_t)(regval) << 14))
#define IREF_MODE_LOW_POWER IREF_STEP(0) /*!< low power, 1uA step */
#define IREF_MODE_HIGH_CURRENT IREF_STEP(1) /*!< high current, 8uA step */
-
-/* IREF sink current mode*/
+
+/* IREF sink current mode*/
#define IREF_CURRENT(regval) (BIT(7) & ((uint32_t)(regval) << 7))
#define IREF_SOURCE_CURRENT IREF_CURRENT(0) /*!< IREF source current */
#define IREF_SINK_CURRENT IREF_CURRENT(1) /*!< IREF sink current */
/* function declarations */
-/* deinit IREF */
+/* deinitialize IREF */
void iref_deinit(void);
/* enable IREF */
void iref_enable(void);
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_misc.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_misc.h
index 21ae664c14..b265608b41 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_misc.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_misc.h
@@ -1,36 +1,36 @@
/*!
\file gd32f4xx_misc.h
\brief definitions for the MISC
-
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -41,8 +41,8 @@ OF SUCH DAMAGE.
/* constants definitions */
/* set the RAM and FLASH base address */
-#define NVIC_VECTTAB_RAM ((uint32_t)0x20000000) /*!< RAM base address */
-#define NVIC_VECTTAB_FLASH ((uint32_t)0x08000000) /*!< Flash base address */
+#define NVIC_VECTTAB_RAM ((uint32_t)0x20000000) /*!< RAM base address */
+#define NVIC_VECTTAB_FLASH ((uint32_t)0x08000000) /*!< Flash base address */
/* set the NVIC vector table offset mask */
#define NVIC_VECTTAB_OFFSET_MASK ((uint32_t)0x1FFFFF80)
@@ -51,24 +51,24 @@ OF SUCH DAMAGE.
#define NVIC_AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
/* priority group - define the pre-emption priority and the subpriority */
-#define NVIC_PRIGROUP_PRE0_SUB4 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority 4 bits for subpriority */
-#define NVIC_PRIGROUP_PRE1_SUB3 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority 3 bits for subpriority */
-#define NVIC_PRIGROUP_PRE2_SUB2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority 2 bits for subpriority */
-#define NVIC_PRIGROUP_PRE3_SUB1 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority 1 bits for subpriority */
-#define NVIC_PRIGROUP_PRE4_SUB0 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority 0 bits for subpriority */
+#define NVIC_PRIGROUP_PRE0_SUB4 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority 4 bits for subpriority */
+#define NVIC_PRIGROUP_PRE1_SUB3 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority 3 bits for subpriority */
+#define NVIC_PRIGROUP_PRE2_SUB2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority 2 bits for subpriority */
+#define NVIC_PRIGROUP_PRE3_SUB1 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority 1 bits for subpriority */
+#define NVIC_PRIGROUP_PRE4_SUB0 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority 0 bits for subpriority */
/* choose the method to enter or exit the lowpower mode */
-#define SCB_SCR_SLEEPONEXIT ((uint8_t)0x02) /*!< choose the the system whether enter low power mode by exiting from ISR */
-#define SCB_SCR_SLEEPDEEP ((uint8_t)0x04) /*!< choose the the system enter the DEEPSLEEP mode or SLEEP mode */
-#define SCB_SCR_SEVONPEND ((uint8_t)0x10) /*!< choose the interrupt source that can wake up the lowpower mode */
+#define SCB_SCR_SLEEPONEXIT ((uint8_t)0x02) /*!< choose the the system whether enter low power mode by exiting from ISR */
+#define SCB_SCR_SLEEPDEEP ((uint8_t)0x04) /*!< choose the the system enter the DEEPSLEEP mode or SLEEP mode */
+#define SCB_SCR_SEVONPEND ((uint8_t)0x10) /*!< choose the interrupt source that can wake up the lowpower mode */
#define SCB_LPM_SLEEP_EXIT_ISR SCB_SCR_SLEEPONEXIT
#define SCB_LPM_DEEPSLEEP SCB_SCR_SLEEPDEEP
#define SCB_LPM_WAKE_BY_ALL_INT SCB_SCR_SEVONPEND
/* choose the systick clock source */
-#define SYSTICK_CLKSOURCE_HCLK_DIV8 ((uint32_t)0xFFFFFFFBU) /*!< systick clock source is from HCLK/8 */
-#define SYSTICK_CLKSOURCE_HCLK ((uint32_t)0x00000004U) /*!< systick clock source is from HCLK */
+#define SYSTICK_CLKSOURCE_HCLK_DIV8 ((uint32_t)0xFFFFFFFBU) /*!< systick clock source is from HCLK/8 */
+#define SYSTICK_CLKSOURCE_HCLK ((uint32_t)0x00000004U) /*!< systick clock source is from HCLK */
/* function declarations */
/* set the priority group */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_pmu.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_pmu.h
index f19b1cb2ec..64f6dfd5c7 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_pmu.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_pmu.h
@@ -5,32 +5,33 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -41,159 +42,165 @@ OF SUCH DAMAGE.
#include "gd32f4xx.h"
/* PMU definitions */
-#define PMU PMU_BASE /*!< PMU base address */
+#define PMU PMU_BASE /*!< PMU base address */
/* registers definitions */
-#define PMU_CTL REG32((PMU) + 0x00U) /*!< PMU control register */
-#define PMU_CS REG32((PMU) + 0x04U) /*!< PMU control and status register */
+#define PMU_CTL REG32((PMU) + 0x00000000U) /*!< PMU control register */
+#define PMU_CS REG32((PMU) + 0x00000004U) /*!< PMU control and status register */
/* bits definitions */
/* PMU_CTL */
-#define PMU_CTL_LDOLP BIT(0) /*!< LDO low power mode */
-#define PMU_CTL_STBMOD BIT(1) /*!< standby mode */
-#define PMU_CTL_WURST BIT(2) /*!< wakeup flag reset */
-#define PMU_CTL_STBRST BIT(3) /*!< standby flag reset */
-#define PMU_CTL_LVDEN BIT(4) /*!< low voltage detector enable */
-#define PMU_CTL_LVDT BITS(5,7) /*!< low voltage detector threshold */
-#define PMU_CTL_BKPWEN BIT(8) /*!< backup domain write enable */
-#define PMU_CTL_LDLP BIT(10) /*!< low-driver mode when use low power LDO */
-#define PMU_CTL_LDNP BIT(11) /*!< low-driver mode when use normal power LDO */
-#define PMU_CTL_LDOVS BITS(14,15) /*!< LDO output voltage select */
-#define PMU_CTL_HDEN BIT(16) /*!< high-driver mode enable */
-#define PMU_CTL_HDS BIT(17) /*!< high-driver mode switch */
-#define PMU_CTL_LDEN BITS(18,19) /*!< low-driver mode enable in deep-sleep mode */
+#define PMU_CTL_LDOLP BIT(0) /*!< LDO low power mode */
+#define PMU_CTL_STBMOD BIT(1) /*!< standby mode */
+#define PMU_CTL_WURST BIT(2) /*!< wakeup flag reset */
+#define PMU_CTL_STBRST BIT(3) /*!< standby flag reset */
+#define PMU_CTL_LVDEN BIT(4) /*!< low voltage detector enable */
+#define PMU_CTL_LVDT BITS(5,7) /*!< low voltage detector threshold */
+#define PMU_CTL_BKPWEN BIT(8) /*!< backup domain write enable */
+#define PMU_CTL_LDLP BIT(10) /*!< low-driver mode when use low power LDO */
+#define PMU_CTL_LDNP BIT(11) /*!< low-driver mode when use normal power LDO */
+#define PMU_CTL_LDOVS BITS(14,15) /*!< LDO output voltage select */
+#define PMU_CTL_HDEN BIT(16) /*!< high-driver mode enable */
+#define PMU_CTL_HDS BIT(17) /*!< high-driver mode switch */
+#define PMU_CTL_LDEN BITS(18,19) /*!< low-driver mode enable in deep-sleep mode */
/* PMU_CS */
-#define PMU_CS_WUF BIT(0) /*!< wakeup flag */
-#define PMU_CS_STBF BIT(1) /*!< standby flag */
-#define PMU_CS_LVDF BIT(2) /*!< low voltage detector status flag */
-#define PMU_CS_BLDORF BIT(3) /*!< backup SRAM LDO ready flag */
-#define PMU_CS_WUPEN BIT(8) /*!< wakeup pin enable */
-#define PMU_CS_BLDOON BIT(9) /*!< backup SRAM LDO on */
-#define PMU_CS_LDOVSRF BIT(14) /*!< LDO voltage select ready flag */
-#define PMU_CS_HDRF BIT(16) /*!< high-driver ready flag */
-#define PMU_CS_HDSRF BIT(17) /*!< high-driver switch ready flag */
-#define PMU_CS_LDRF BITS(18,19) /*!< Low-driver mode ready flag */
+#define PMU_CS_WUF BIT(0) /*!< wakeup flag */
+#define PMU_CS_STBF BIT(1) /*!< standby flag */
+#define PMU_CS_LVDF BIT(2) /*!< low voltage detector status flag */
+#define PMU_CS_BLDORF BIT(3) /*!< backup SRAM LDO ready flag */
+#define PMU_CS_WUPEN BIT(8) /*!< wakeup pin enable */
+#define PMU_CS_BLDOON BIT(9) /*!< backup SRAM LDO on */
+#define PMU_CS_LDOVSRF BIT(14) /*!< LDO voltage select ready flag */
+#define PMU_CS_HDRF BIT(16) /*!< high-driver ready flag */
+#define PMU_CS_HDSRF BIT(17) /*!< high-driver switch ready flag */
+#define PMU_CS_LDRF BITS(18,19) /*!< low-driver mode ready flag */
/* constants definitions */
+/* PMU ldo definitions */
+#define PMU_LDO_NORMAL ((uint32_t)0x00000000U) /*!< LDO normal work when PMU enter deep-sleep mode */
+#define PMU_LDO_LOWPOWER PMU_CTL_LDOLP /*!< LDO work at low power status when PMU enter deep-sleep mode */
+
/* PMU low voltage detector threshold definitions */
#define CTL_LVDT(regval) (BITS(5,7)&((uint32_t)(regval)<<5))
-#define PMU_LVDT_0 CTL_LVDT(0) /*!< voltage threshold is 2.1V */
-#define PMU_LVDT_1 CTL_LVDT(1) /*!< voltage threshold is 2.3V */
-#define PMU_LVDT_2 CTL_LVDT(2) /*!< voltage threshold is 2.4V */
-#define PMU_LVDT_3 CTL_LVDT(3) /*!< voltage threshold is 2.6V */
-#define PMU_LVDT_4 CTL_LVDT(4) /*!< voltage threshold is 2.7V */
-#define PMU_LVDT_5 CTL_LVDT(5) /*!< voltage threshold is 2.9V */
-#define PMU_LVDT_6 CTL_LVDT(6) /*!< voltage threshold is 3.0V */
-#define PMU_LVDT_7 CTL_LVDT(7) /*!< voltage threshold is 3.1V */
+#define PMU_LVDT_0 CTL_LVDT(0) /*!< voltage threshold is 2.1V */
+#define PMU_LVDT_1 CTL_LVDT(1) /*!< voltage threshold is 2.3V */
+#define PMU_LVDT_2 CTL_LVDT(2) /*!< voltage threshold is 2.4V */
+#define PMU_LVDT_3 CTL_LVDT(3) /*!< voltage threshold is 2.6V */
+#define PMU_LVDT_4 CTL_LVDT(4) /*!< voltage threshold is 2.7V */
+#define PMU_LVDT_5 CTL_LVDT(5) /*!< voltage threshold is 2.9V */
+#define PMU_LVDT_6 CTL_LVDT(6) /*!< voltage threshold is 3.0V */
+#define PMU_LVDT_7 CTL_LVDT(7) /*!< voltage threshold is 3.1V */
+
+/* PMU low-driver mode when use low power LDO */
+#define CTL_LDLP(regval) (BIT(10)&((uint32_t)(regval)<<10))
+#define PMU_NORMALDR_LOWPWR CTL_LDLP(0) /*!< normal driver when use low power LDO */
+#define PMU_LOWDR_LOWPWR CTL_LDLP(1) /*!< low-driver mode enabled when LDEN is 11 and use low power LDO */
+
+/* PMU low-driver mode when use normal power LDO */
+#define CTL_LDNP(regval) (BIT(11)&((uint32_t)(regval)<<11))
+#define PMU_NORMALDR_NORMALPWR CTL_LDNP(0) /*!< normal driver when use normal power LDO */
+#define PMU_LOWDR_NORMALPWR CTL_LDNP(1) /*!< low-driver mode enabled when LDEN is 11 and use normal power LDO */
/* PMU LDO output voltage select definitions */
#define CTL_LDOVS(regval) (BITS(14,15)&((uint32_t)(regval)<<14))
-#define PMU_LDOVS_LOW CTL_LDOVS(1) /*!< LDO output voltage low mode */
-#define PMU_LDOVS_MID CTL_LDOVS(2) /*!< LDO output voltage mid mode */
-#define PMU_LDOVS_HIGH CTL_LDOVS(3) /*!< LDO output voltage high mode */
+#define PMU_LDOVS_LOW CTL_LDOVS(1) /*!< LDO output voltage low mode */
+#define PMU_LDOVS_MID CTL_LDOVS(2) /*!< LDO output voltage mid mode */
+#define PMU_LDOVS_HIGH CTL_LDOVS(3) /*!< LDO output voltage high mode */
-/* PMU low-driver mode enable in deep-sleep mode */
-#define CTL_LDEN(regval) (BITS(18,19)&((uint32_t)(regval)<<18))
-#define PMU_LOWDRIVER_DISABLE CTL_LDEN(0) /*!< low-driver mode disable in deep-sleep mode */
-#define PMU_LOWDRIVER_ENABLE CTL_LDEN(3) /*!< low-driver mode enable in deep-sleep mode */
/* PMU high-driver mode switch */
#define CTL_HDS(regval) (BIT(17)&((uint32_t)(regval)<<17))
-#define PMU_HIGHDR_SWITCH_NONE CTL_HDS(0) /*!< no high-driver mode switch */
-#define PMU_HIGHDR_SWITCH_EN CTL_HDS(1) /*!< high-driver mode switch */
+#define PMU_HIGHDR_SWITCH_NONE CTL_HDS(0) /*!< no high-driver mode switch */
+#define PMU_HIGHDR_SWITCH_EN CTL_HDS(1) /*!< high-driver mode switch */
-/* PMU low-driver mode when use low power LDO */
-#define CTL_LDLP(regval) (BIT(10)&((uint32_t)(regval)<<10))
-#define PMU_NORMALDR_LOWPWR CTL_LDLP(0) /*!< normal driver when use low power LDO */
-#define PMU_LOWDR_LOWPWR CTL_LDLP(1) /*!< low-driver mode enabled when LDEN is 11 and use low power LDO */
+/* PMU low-driver mode enable in deep-sleep mode */
+#define CTL_LDEN(regval) (BITS(18,19)&((uint32_t)(regval)<<18))
+#define PMU_LOWDRIVER_DISABLE CTL_LDEN(0) /*!< low-driver mode disable in deep-sleep mode */
+#define PMU_LOWDRIVER_ENABLE CTL_LDEN(3) /*!< low-driver mode enable in deep-sleep mode */
-/* PMU low-driver mode when use normal power LDO */
-#define CTL_LDNP(regval) (BIT(11)&((uint32_t)(regval)<<11))
-#define PMU_NORMALDR_NORMALPWR CTL_LDNP(0) /*!< normal driver when use normal power LDO */
-#define PMU_LOWDR_NORMALPWR CTL_LDNP(1) /*!< low-driver mode enabled when LDEN is 11 and use normal power LDO */
+/* PMU backup SRAM LDO on or off */
+#define CS_BLDOON(regval) (BIT(9)&((uint32_t)(regval)<<9))
+#define PMU_BLDOON_OFF CS_BLDOON(0) /*!< backup SRAM LDO off */
+#define PMU_BLDOON_ON CS_BLDOON(1) /*!< the backup SRAM LDO on */
/* PMU low power mode ready flag definitions */
#define CS_LDRF(regval) (BITS(18,19)&((uint32_t)(regval)<<18))
-#define PMU_LDRF_NORMAL CS_LDRF(0) /*!< normal driver in deep-sleep mode */
-#define PMU_LDRF_LOWDRIVER CS_LDRF(3) /*!< low-driver mode in deep-sleep mode */
-
-/* PMU backup SRAM LDO on or off */
-#define CS_BLDOON(regval) (BIT(9)&((uint32_t)(regval)<<9))
-#define PMU_BLDOON_OFF CS_BLDOON(0) /*!< backup SRAM LDO off */
-#define PMU_BLDOON_ON CS_BLDOON(1) /*!< the backup SRAM LDO on */
+#define PMU_LDRF_NORMAL CS_LDRF(0) /*!< normal driver in deep-sleep mode */
+#define PMU_LDRF_LOWDRIVER CS_LDRF(3) /*!< low-driver mode in deep-sleep mode */
/* PMU flag definitions */
-#define PMU_FLAG_WAKEUP PMU_CS_WUF /*!< wakeup flag status */
-#define PMU_FLAG_STANDBY PMU_CS_STBF /*!< standby flag status */
-#define PMU_FLAG_LVD PMU_CS_LVDF /*!< lvd flag status */
-#define PMU_FLAG_BLDORF PMU_CS_BLDORF /*!< backup SRAM LDO ready flag */
-#define PMU_FLAG_LDOVSRF PMU_CS_LDOVSRF /*!< LDO voltage select ready flag */
-#define PMU_FLAG_HDRF PMU_CS_HDRF /*!< high-driver ready flag */
-#define PMU_FLAG_HDSRF PMU_CS_HDSRF /*!< high-driver switch ready flag */
-#define PMU_FLAG_LDRF PMU_CS_LDRF /*!< low-driver mode ready flag */
-
-/* PMU ldo definitions */
-#define PMU_LDO_NORMAL ((uint32_t)0x00000000U) /*!< LDO normal work when PMU enter deepsleep mode */
-#define PMU_LDO_LOWPOWER PMU_CTL_LDOLP /*!< LDO work at low power status when PMU enter deepsleep mode */
+#define PMU_FLAG_WAKEUP PMU_CS_WUF /*!< wakeup flag status */
+#define PMU_FLAG_STANDBY PMU_CS_STBF /*!< standby flag status */
+#define PMU_FLAG_LVD PMU_CS_LVDF /*!< lvd flag status */
+#define PMU_FLAG_BLDORF PMU_CS_BLDORF /*!< backup SRAM LDO ready flag */
+#define PMU_FLAG_LDOVSRF PMU_CS_LDOVSRF /*!< LDO voltage select ready flag */
+#define PMU_FLAG_HDRF PMU_CS_HDRF /*!< high-driver ready flag */
+#define PMU_FLAG_HDSRF PMU_CS_HDSRF /*!< high-driver switch ready flag */
+#define PMU_FLAG_LDRF PMU_CS_LDRF /*!< low-driver mode ready flag */
/* PMU flag reset definitions */
-#define PMU_FLAG_RESET_WAKEUP ((uint8_t)0x00U) /*!< wakeup flag reset */
-#define PMU_FLAG_RESET_STANDBY ((uint8_t)0x01U) /*!< standby flag reset */
+#define PMU_FLAG_RESET_WAKEUP ((uint8_t)0x00U) /*!< wakeup flag reset */
+#define PMU_FLAG_RESET_STANDBY ((uint8_t)0x01U) /*!< standby flag reset */
/* PMU command constants definitions */
-#define WFI_CMD ((uint8_t)0x00U) /*!< use WFI command */
-#define WFE_CMD ((uint8_t)0x01U) /*!< use WFE command */
+#define WFI_CMD ((uint8_t)0x00U) /*!< use WFI command */
+#define WFE_CMD ((uint8_t)0x01U) /*!< use WFE command */
/* function declarations */
-/* reset PMU register */
+/* reset PMU registers */
void pmu_deinit(void);
+/* LVD functions */
/* select low voltage detector threshold */
void pmu_lvd_select(uint32_t lvdt_n);
-/* LDO output voltage select */
-void pmu_ldo_output_select(uint32_t ldo_output);
-/* PMU lvd disable */
+/* disable PMU lvd */
void pmu_lvd_disable(void);
-/* functions of low-driver mode and high-driver mode in deep-sleep mode */
-/* high-driver mode switch */
-void pmu_highdriver_switch_select(uint32_t highdr_switch);
-/* high-driver mode enable */
+/* LDO functions */
+/* select LDO output voltage */
+void pmu_ldo_output_select(uint32_t ldo_output);
+
+/* functions of low-driver mode and high-driver mode */
+/* enable high-driver mode */
void pmu_highdriver_mode_enable(void);
-/* high-driver mode disable */
+/* disable high-driver mode */
void pmu_highdriver_mode_disable(void);
-/* low-driver mode enable in deep-sleep mode */
-void pmu_low_driver_mode_enable(uint32_t lowdr_mode);
-/* in deep-sleep mode, low-driver mode when use low power LDO */
-void pmu_lowdriver_lowpower_config(uint32_t mode);
-/* in deep-sleep mode, low-driver mode when use normal power LDO */
-void pmu_lowdriver_normalpower_config(uint32_t mode);
+/* switch high-driver mode */
+void pmu_highdriver_switch_select(uint32_t highdr_switch);
+/* enable low-driver mode in deep-sleep */
+void pmu_lowdriver_mode_enable(void);
+/* disable low-driver mode in deep-sleep */
+void pmu_lowdriver_mode_disable(void);
+/* in deep-sleep mode, driver mode when use low power LDO */
+void pmu_lowpower_driver_config(uint32_t mode);
+/* in deep-sleep mode, driver mode when use normal power LDO */
+void pmu_normalpower_driver_config(uint32_t mode);
/* set PMU mode */
-/* PMU work at sleep mode */
+/* PMU work in sleep mode */
void pmu_to_sleepmode(uint8_t sleepmodecmd);
-/* PMU work at deepsleep mode */
-void pmu_to_deepsleepmode(uint32_t ldo, uint8_t deepsleepmodecmd);
-/* PMU work at standby mode */
-void pmu_to_standbymode(uint8_t standbymodecmd);
-/* PMU wakeup pin enable */
+/* PMU work in deepsleep mode */
+void pmu_to_deepsleepmode(uint32_t ldo, uint32_t lowdrive, uint8_t deepsleepmodecmd);
+/* PMU work in standby mode */
+void pmu_to_standbymode(void);
+/* enable PMU wakeup pin */
void pmu_wakeup_pin_enable(void);
-/* PMU wakeup pin disable */
+/* disable PMU wakeup pin */
void pmu_wakeup_pin_disable(void);
/* backup related functions */
/* backup SRAM LDO on */
void pmu_backup_ldo_config(uint32_t bkp_ldo);
-/* backup domain write enable */
+/* enable write access to the registers in backup domain */
void pmu_backup_write_enable(void);
-/* backup domain write disable */
+/* disable write access to the registers in backup domain */
void pmu_backup_write_disable(void);
/* flag functions */
-/* reset flag bit */
-void pmu_flag_reset(uint32_t flag_reset);
-/* get flag status */
-FlagStatus pmu_flag_get(uint32_t pmu_flag);
+/* get flag state */
+FlagStatus pmu_flag_get(uint32_t flag);
+/* clear flag bit */
+void pmu_flag_clear(uint32_t flag);
#endif /* GD32F4XX_PMU_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_rcu.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_rcu.h
index 0445df4eb0..c2471ddcb9 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_rcu.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_rcu.h
@@ -1,36 +1,37 @@
/*!
\file gd32f4xx_rcu.h
\brief definitions for the RCU
-
+
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -59,14 +60,14 @@ OF SUCH DAMAGE.
#define RCU_APB2EN REG32(RCU + 0x44U) /*!< APB2 enable register */
#define RCU_AHB1SPEN REG32(RCU + 0x50U) /*!< AHB1 sleep mode enable register */
#define RCU_AHB2SPEN REG32(RCU + 0x54U) /*!< AHB2 sleep mode enable register */
-#define RCU_AHB3SPEN REG32(RCU + 0x58U) /*!< AHB3 sleep mode enable register */
+#define RCU_AHB3SPEN REG32(RCU + 0x58U) /*!< AHB3 sleep mode enable register */
#define RCU_APB1SPEN REG32(RCU + 0x60U) /*!< APB1 sleep mode enable register */
#define RCU_APB2SPEN REG32(RCU + 0x64U) /*!< APB2 sleep mode enable register */
#define RCU_BDCTL REG32(RCU + 0x70U) /*!< backup domain control register */
#define RCU_RSTSCK REG32(RCU + 0x74U) /*!< reset source / clock register */
#define RCU_PLLSSCTL REG32(RCU + 0x80U) /*!< PLL clock spread spectrum control register */
-#define RCU_PLLI2S REG32(RCU + 0x84U) /*!< PLLI2S register */
-#define RCU_PLLSAI REG32(RCU + 0x88U) /*!< PLLSAI register */
+#define RCU_PLLI2S REG32(RCU + 0x84U) /*!< PLLI2S register */
+#define RCU_PLLSAI REG32(RCU + 0x88U) /*!< PLLSAI register */
#define RCU_CFG1 REG32(RCU + 0x8CU) /*!< clock configuration register 1 */
#define RCU_ADDCTL REG32(RCU + 0xC0U) /*!< Additional clock control register */
#define RCU_ADDINT REG32(RCU + 0xCCU) /*!< Additional clock interrupt register */
@@ -148,7 +149,7 @@ OF SUCH DAMAGE.
#define RCU_AHB1RST_PGRST BIT(6) /*!< GPIO port G reset */
#define RCU_AHB1RST_PHRST BIT(7) /*!< GPIO port H reset */
#define RCU_AHB1RST_PIRST BIT(8) /*!< GPIO port I reset */
-#define RCU_AHB1RST_CRCRST BIT(12) /*!< CRC reset */
+#define RCU_AHB1RST_CRCRST BIT(12) /*!< CRC reset */
#define RCU_AHB1RST_DMA0RST BIT(21) /*!< DMA0 reset */
#define RCU_AHB1RST_DMA1RST BIT(22) /*!< DMA1 reset */
#define RCU_AHB1RST_IPARST BIT(23) /*!< IPA reset */
@@ -159,7 +160,7 @@ OF SUCH DAMAGE.
#define RCU_AHB2RST_DCIRST BIT(0) /*!< DCI reset */
#define RCU_AHB2RST_TRNGRST BIT(6) /*!< TRNG reset */
#define RCU_AHB2RST_USBFSRST BIT(7) /*!< USBFS reset */
-
+
/* RCU_AHB3RST */
#define RCU_AHB3RST_EXMCRST BIT(0) /*!< EXMC reset */
@@ -386,24 +387,22 @@ OF SUCH DAMAGE.
#define RCU_RSTSCK_LPRSTF BIT(31) /*!< low-power reset flag */
/* RCU_PLLSSCTL */
-#define RCU_PLLSSCTL_MODCNT BITS(0,12) /*!< these bits configure PLL spread spectrum modulation
- profile amplitude and frequency. the following criteria
+#define RCU_PLLSSCTL_MODCNT BITS(0,12) /*!< these bits configure PLL spread spectrum modulation
+ profile amplitude and frequency. the following criteria
must be met: MODSTEP*MODCNT=215-1 */
-#define RCU_PLLSSCTL_MODSTEP BITS(13,27) /*!< these bits configure PLL spread spectrum modulation
- profile amplitude and frequency. the following criteria
+#define RCU_PLLSSCTL_MODSTEP BITS(13,27) /*!< these bits configure PLL spread spectrum modulation
+ profile amplitude and frequency. the following criteria
must be met: MODSTEP*MODCNT=215-1 */
#define RCU_PLLSSCTL_SS_TYPE BIT(30) /*!< PLL spread spectrum modulation type select */
#define RCU_PLLSSCTL_SSCGON BIT(31) /*!< PLL spread spectrum modulation enable */
/* RCU_PLLI2S */
#define RCU_PLLI2S_PLLI2SN BITS(6,14) /*!< the PLLI2S VCO clock multi factor */
-#define RCU_PLLI2S_PLLI2SQ BITS(24,27) /*!< the PLLI2S Q output frequency division factor from PLLI2S VCO clock */
#define RCU_PLLI2S_PLLI2SR BITS(28,30) /*!< the PLLI2S R output frequency division factor from PLLI2S VCO clock */
/* RCU_PLLSAI */
#define RCU_PLLSAI_PLLSAIN BITS(6,14) /*!< the PLLSAI VCO clock multi factor */
#define RCU_PLLSAI_PLLSAIP BITS(16,17) /*!< the PLLSAI P output frequency division factor from PLLSAI VCO clock */
-#define RCU_PLLSAI_PLLSAIQ BITS(24,27) /*!< the PLLSAI Q output frequency division factor from PLLSAI VCO clock */
#define RCU_PLLSAI_PLLSAIR BITS(28,30) /*!< the PLLSAI R output frequency division factor from PLLSAI VCO clock */
/* RCU_CFG1 */
@@ -463,7 +462,7 @@ OF SUCH DAMAGE.
#define ADD_APB1EN_REG_OFFSET 0xE4U /*!< APB1 additional enable register offset */
#define ADD_APB1SPEN_REG_OFFSET 0xE8U /*!< APB1 additional sleep mode enable register offset */
-/* peripherals reset */
+/* peripherals reset */
#define AHB1RST_REG_OFFSET 0x10U /*!< AHB1 reset register offset */
#define AHB2RST_REG_OFFSET 0x14U /*!< AHB2 reset register offset */
#define AHB3RST_REG_OFFSET 0x18U /*!< AHB3 reset register offset */
@@ -529,7 +528,7 @@ typedef enum
RCU_TIMER6 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 5U), /*!< TIMER6 clock */
RCU_TIMER11 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 6U), /*!< TIMER11 clock */
RCU_TIMER12 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 7U), /*!< TIMER12 clock */
- RCU_TIMER13 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 8U), /*!< TIMER13 clock */
+ RCU_TIMER13 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 8U), /*!< TIMER13 clock */
RCU_WWDGT = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 11U), /*!< WWDGT clock */
RCU_SPI1 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 14U), /*!< SPI1 clock */
RCU_SPI2 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 15U), /*!< SPI2 clock */
@@ -539,7 +538,7 @@ typedef enum
RCU_UART4 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 20U), /*!< UART4 clock */
RCU_I2C0 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 21U), /*!< I2C0 clock */
RCU_I2C1 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 22U), /*!< I2C1 clock */
- RCU_I2C2 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 23U), /*!< I2C2 clock */
+ RCU_I2C2 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 23U), /*!< I2C2 clock */
RCU_CAN0 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 25U), /*!< CAN0 clock */
RCU_CAN1 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 26U), /*!< CAN1 clock */
RCU_PMU = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 28U), /*!< PMU clock */
@@ -613,7 +612,7 @@ typedef enum
RCU_TIMER6_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 5U), /*!< TIMER6 clock */
RCU_TIMER11_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 6U), /*!< TIMER11 clock */
RCU_TIMER12_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 7U), /*!< TIMER12 clock */
- RCU_TIMER13_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 8U), /*!< TIMER13 clock */
+ RCU_TIMER13_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 8U), /*!< TIMER13 clock */
RCU_WWDGT_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 11U), /*!< WWDGT clock */
RCU_SPI1_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 14U), /*!< SPI1 clock */
RCU_SPI2_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 15U), /*!< SPI2 clock */
@@ -623,7 +622,7 @@ typedef enum
RCU_UART4_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 20U), /*!< UART4 clock */
RCU_I2C0_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 21U), /*!< I2C0 clock */
RCU_I2C1_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 22U), /*!< I2C1 clock */
- RCU_I2C2_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 23U), /*!< I2C2 clock */
+ RCU_I2C2_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 23U), /*!< I2C2 clock */
RCU_CAN0_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 25U), /*!< CAN0 clock */
RCU_CAN1_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 26U), /*!< CAN1 clock */
RCU_PMU_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 28U), /*!< PMU clock */
@@ -670,7 +669,7 @@ typedef enum
RCU_DMA0RST = RCU_REGIDX_BIT(AHB1RST_REG_OFFSET, 21U), /*!< DMA0 clock reset */
RCU_DMA1RST = RCU_REGIDX_BIT(AHB1RST_REG_OFFSET, 22U), /*!< DMA1 clock reset */
RCU_IPARST = RCU_REGIDX_BIT(AHB1RST_REG_OFFSET, 23U), /*!< IPA clock reset */
- RCU_ENETRST = RCU_REGIDX_BIT(AHB1RST_REG_OFFSET, 25U), /*!< ENET clock reset */
+ RCU_ENETRST = RCU_REGIDX_BIT(AHB1RST_REG_OFFSET, 25U), /*!< ENET clock reset */
RCU_USBHSRST = RCU_REGIDX_BIT(AHB1RST_REG_OFFSET, 29U), /*!< USBHS clock reset */
/* AHB2 peripherals */
RCU_DCIRST = RCU_REGIDX_BIT(AHB2RST_REG_OFFSET, 0U), /*!< DCI clock reset */
@@ -687,7 +686,7 @@ typedef enum
RCU_TIMER6RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 5U), /*!< TIMER6 clock reset */
RCU_TIMER11RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 6U), /*!< TIMER11 clock reset */
RCU_TIMER12RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 7U), /*!< TIMER12 clock reset */
- RCU_TIMER13RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 8U), /*!< TIMER13 clock reset */
+ RCU_TIMER13RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 8U), /*!< TIMER13 clock reset */
RCU_WWDGTRST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 11U), /*!< WWDGT clock reset */
RCU_SPI1RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 14U), /*!< SPI1 clock reset */
RCU_SPI2RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 15U), /*!< SPI2 clock reset */
@@ -697,7 +696,7 @@ typedef enum
RCU_UART4RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 20U), /*!< UART4 clock reset */
RCU_I2C0RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 21U), /*!< I2C0 clock reset */
RCU_I2C1RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 22U), /*!< I2C1 clock reset */
- RCU_I2C2RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 23U), /*!< I2C2 clock reset */
+ RCU_I2C2RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 23U), /*!< I2C2 clock reset */
RCU_CAN0RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 25U), /*!< CAN0 clock reset */
RCU_CAN1RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 26U), /*!< CAN1 clock reset */
RCU_PMURST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 28U), /*!< PMU clock reset */
@@ -963,13 +962,13 @@ typedef enum
#define RCU_PLLSAIR_DIV16 CFG1_PLLSAIRDIV(3) /*!< CK_PLLSAIRDIV clock select CK_PLLSAIR/16 */
/* TIMER clock selection */
-#define RCU_TIMER_PSC_MUL2 ~RCU_CFG1_TIMERSEL /*!< if APB1PSC/APB2PSC in RCU_CFG0 register is 0b0xx(CK_APBx = CK_AHB)
+#define RCU_TIMER_PSC_MUL2 ~RCU_CFG1_TIMERSEL /*!< if APB1PSC/APB2PSC in RCU_CFG0 register is 0b0xx(CK_APBx = CK_AHB)
or 0b100(CK_APBx = CK_AHB/2), the TIMER clock is equal to CK_AHB(CK_TIMERx = CK_AHB).
- or else, the TIMER clock is twice the corresponding APB clock (TIMER in APB1 domain: CK_TIMERx = 2 x CK_APB1;
+ or else, the TIMER clock is twice the corresponding APB clock (TIMER in APB1 domain: CK_TIMERx = 2 x CK_APB1;
TIMER in APB2 domain: CK_TIMERx = 2 x CK_APB2) */
-#define RCU_TIMER_PSC_MUL4 RCU_CFG1_TIMERSEL /*!< if APB1PSC/APB2PSC in RCU_CFG0 register is 0b0xx(CK_APBx = CK_AHB),
- 0b100(CK_APBx = CK_AHB/2), or 0b101(CK_APBx = CK_AHB/4), the TIMER clock is equal to CK_AHB(CK_TIMERx = CK_AHB).
- or else, the TIMER clock is four timers the corresponding APB clock (TIMER in APB1 domain: CK_TIMERx = 4 x CK_APB1;
+#define RCU_TIMER_PSC_MUL4 RCU_CFG1_TIMERSEL /*!< if APB1PSC/APB2PSC in RCU_CFG0 register is 0b0xx(CK_APBx = CK_AHB),
+ 0b100(CK_APBx = CK_AHB/2), or 0b101(CK_APBx = CK_AHB/4), the TIMER clock is equal to CK_AHB(CK_TIMERx = CK_AHB).
+ or else, the TIMER clock is four timers the corresponding APB clock (TIMER in APB1 domain: CK_TIMERx = 4 x CK_APB1;
TIMER in APB2 domain: CK_TIMERx = 4 x CK_APB2) */
/* RCU_PLLSSCTL register bit define */
@@ -991,7 +990,7 @@ typedef enum
/* The PLLP output frequency division factor from PLL VCO clock */
#define RCU_PLLP_DIV_MIN ((uint32_t)2U) /*!< PLLP_DIV min value */
#define RCU_PLLP_DIV_MAX ((uint32_t)8U) /*!< PLLP_DIV max value */
-
+
/* PLL Clock Source Selection */
#define RCU_PLLSRC_IRC16M ((uint32_t)0x00000000U) /*!< IRC16M clock selected as source clock of PLL, PLLSAI, PLLI2S */
#define RCU_PLLSRC_HXTAL RCU_PLL_PLLSEL /*!< HXTAL clock selected as source clock of PLL, PLLSAI, PLLI2S */
@@ -1000,10 +999,10 @@ typedef enum
#define RCU_PLLQ_DIV_MIN ((uint32_t)2U) /*!< PLLQ_DIV min value */
#define RCU_PLLQ_DIV_MAX ((uint32_t)15U) /*!< PLLQ_DIV max value */
-#define CHECK_PLL_PSC_VALID(val) (((val) >= RCU_PLLPSC_DIV_MIN)&&((val) <= RCU_PLLPSC_DIV_MAX))
-#define CHECK_PLL_N_VALID(val, inc) (((val) >= (RCU_PLLN_MUL_MIN + (inc)))&&((val) <= RCU_PLLN_MUL_MAX))
-#define CHECK_PLL_P_VALID(val) (((val) == 2U) || ((val) == 4U) || ((val) == 6U) || ((val) == 8U))
-#define CHECK_PLL_Q_VALID(val) (((val) >= RCU_PLLQ_DIV_MIN)&&((val) <= RCU_PLLQ_DIV_MAX))
+#define CHECK_PLL_PSC_VALID(val) (((val) >= RCU_PLLPSC_DIV_MIN)&&((val) <= RCU_PLLPSC_DIV_MAX))
+#define CHECK_PLL_N_VALID(val, inc) (((val) >= (RCU_PLLN_MUL_MIN + (inc)))&&((val) <= RCU_PLLN_MUL_MAX))
+#define CHECK_PLL_P_VALID(val) (((val) == 2U) || ((val) == 4U) || ((val) == 6U) || ((val) == 8U))
+#define CHECK_PLL_Q_VALID(val) (((val) >= RCU_PLLQ_DIV_MIN)&&((val) <= RCU_PLLQ_DIV_MAX))
/* RCU_BDCTL register bit define */
/* LXTAL drive capability */
@@ -1058,7 +1057,7 @@ typedef enum
#define CHECK_PLLSAI_R_VALID(val) (((val) >= RCU_PLLSAIR_DIV_MIN)&&((val) <= RCU_PLLSAIR_DIV_MAX))
/* RCU_ADDCTL register bit define */
-/* 48MHz clock selection */
+/* 48MHz clock selection */
#define RCU_CK48MSRC_PLL48M ((uint32_t)0x00000000U) /*!< CK48M source clock select PLL48M */
#define RCU_CK48MSRC_IRC48M RCU_ADDCTL_CK48MSEL /*!< CK48M source clock select IRC48M */
@@ -1068,13 +1067,14 @@ typedef enum
/* Deep-sleep mode voltage */
#define DSV_DSLPVS(regval) (BITS(0,2) & ((uint32_t)(regval) << 0))
-#define RCU_DEEPSLEEP_V_1_2 DSV_DSLPVS(0) /*!< core voltage is 1.2V in deep-sleep mode */
-#define RCU_DEEPSLEEP_V_1_1 DSV_DSLPVS(1) /*!< core voltage is 1.1V in deep-sleep mode */
-#define RCU_DEEPSLEEP_V_1_0 DSV_DSLPVS(2) /*!< core voltage is 1.0V in deep-sleep mode */
-#define RCU_DEEPSLEEP_V_0_9 DSV_DSLPVS(3) /*!< core voltage is 0.9V in deep-sleep mode */
+#define RCU_DEEPSLEEP_V_0 DSV_DSLPVS(0) /*!< core voltage is default value in deep-sleep mode */
+#define RCU_DEEPSLEEP_V_1 DSV_DSLPVS(1) /*!< core voltage is (default value-0.1)V in deep-sleep mode(customers are not recommended to use it)*/
+#define RCU_DEEPSLEEP_V_2 DSV_DSLPVS(2) /*!< core voltage is (default value-0.2)V in deep-sleep mode(customers are not recommended to use it)*/
+#define RCU_DEEPSLEEP_V_3 DSV_DSLPVS(3) /*!< core voltage is (default value-0.3)V in deep-sleep mode(customers are not recommended to use it)*/
/* function declarations */
+/* peripherals clock configure functions */
/* deinitialize the RCU */
void rcu_deinit(void);
/* enable the peripherals clock */
@@ -1094,6 +1094,7 @@ void rcu_bkp_reset_enable(void);
/* disable the BKP reset */
void rcu_bkp_reset_disable(void);
+/* system and peripherals clock source, system reset configure functions */
/* configure the system clock source */
void rcu_system_clock_source_config(uint32_t ck_sys);
/* get the system clock source */
@@ -1125,24 +1126,11 @@ void rcu_ck48m_clock_config(uint32_t ck48m_clock_source);
/* configure the PLL48M clock selection */
void rcu_pll48m_clock_config(uint32_t pll48m_clock_source);
/* configure the TIMER clock prescaler selection */
-void rcu_timer_clock_prescaler_config(uint32_t timer_clock_prescaler);
+void rcu_timer_clock_prescaler_config(uint32_t timer_clock_prescaler);
/* configure the TLI clock division selection */
void rcu_tli_clock_div_config(uint32_t pllsai_r_div);
-
-/* get the clock stabilization and periphral reset flags */
-FlagStatus rcu_flag_get(rcu_flag_enum flag);
-/* clear the reset flag */
-void rcu_all_reset_flag_clear(void);
-/* get the clock stabilization interrupt and ckm flags */
-FlagStatus rcu_interrupt_flag_get(rcu_int_flag_enum int_flag);
-/* clear the interrupt flags */
-void rcu_interrupt_flag_clear(rcu_int_flag_clear_enum int_flag);
-/* enable the stabilization interrupt */
-void rcu_interrupt_enable(rcu_int_enum interrupt);
-/* disable the stabilization interrupt */
-void rcu_interrupt_disable(rcu_int_enum interrupt);
-
+/* LXTAL, IRC8M, PLL and other oscillator configure functions */
/* configure the LXTAL drive capability */
void rcu_lxtal_drive_capability_config(uint32_t lxtal_dricap);
/* wait for oscillator stabilization flags is SET or oscillator startup is timeout */
@@ -1155,11 +1143,6 @@ void rcu_osci_off(rcu_osci_type_enum osci);
void rcu_osci_bypass_mode_enable(rcu_osci_type_enum osci);
/* disable the oscillator bypass mode, HXTALEN or LXTALEN must be reset before it */
void rcu_osci_bypass_mode_disable(rcu_osci_type_enum osci);
-/* enable the HXTAL clock monitor */
-void rcu_hxtal_clock_monitor_enable(void);
-/* disable the HXTAL clock monitor */
-void rcu_hxtal_clock_monitor_disable(void);
-
/* set the IRC16M adjust value */
void rcu_irc16m_adjust_value_set(uint32_t irc16m_adjval);
/* configure the spread spectrum modulation for the main PLL clock */
@@ -1168,12 +1151,33 @@ void rcu_spread_spectrum_config(uint32_t spread_spectrum_type, uint32_t modstep,
void rcu_spread_spectrum_enable(void);
/* disable the spread spectrum modulation for the main PLL clock */
void rcu_spread_spectrum_disable(void);
+
+/* clock monitor configure functions */
+/* enable the HXTAL clock monitor */
+void rcu_hxtal_clock_monitor_enable(void);
+/* disable the HXTAL clock monitor */
+void rcu_hxtal_clock_monitor_disable(void);
+
+/* voltage configure and clock frequency get functions */
/* unlock the voltage key */
void rcu_voltage_key_unlock(void);
/* set the deep sleep mode voltage */
void rcu_deepsleep_voltage_set(uint32_t dsvol);
-
/* get the system clock, bus and peripheral clock frequency */
uint32_t rcu_clock_freq_get(rcu_clock_freq_enum clock);
+/* flag & interrupt functions */
+/* get the clock stabilization and periphral reset flags */
+FlagStatus rcu_flag_get(rcu_flag_enum flag);
+/* clear the reset flag */
+void rcu_all_reset_flag_clear(void);
+/* get the clock stabilization interrupt and ckm flags */
+FlagStatus rcu_interrupt_flag_get(rcu_int_flag_enum int_flag);
+/* clear the interrupt flags */
+void rcu_interrupt_flag_clear(rcu_int_flag_clear_enum int_flag);
+/* enable the stabilization interrupt */
+void rcu_interrupt_enable(rcu_int_enum interrupt);
+/* disable the stabilization interrupt */
+void rcu_interrupt_disable(rcu_int_enum interrupt);
+
#endif /* GD32F4XX_RCU_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_rtc.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_rtc.h
index 75e66f236e..fe6df1fca2 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_rtc.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_rtc.h
@@ -5,32 +5,33 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -280,7 +281,7 @@ typedef struct
ControlStatus tamper_precharge_enable; /*!< RTC tamper precharge feature during a voltage level detection */
uint32_t tamper_precharge_time; /*!< RTC tamper precharge duration if precharge feature is enabled */
ControlStatus tamper_with_timestamp; /*!< RTC tamper time-stamp feature */
-}rtc_tamper_struct;
+}rtc_tamper_struct;
/* time register value */
#define TIME_SC(regval) (BITS(0,6) & ((uint32_t)(regval) << 0)) /*!< write value to RTC_TIME_SC bit field */
@@ -501,12 +502,12 @@ typedef struct
#define RTC_WUT_RESET ((uint32_t)0x0000FFFFU) /*!< RTC_WUT register reset value */
/* RTC alarm */
-#define RTC_ALARM0 ((uint8_t)0x01U) /*!< RTC alarm 0 */
-#define RTC_ALARM1 ((uint8_t)0x02U) /*!< RTC alarm 1 */
+#define RTC_ALARM0 ((uint8_t)0x01U) /*!< RTC alarm 0 */
+#define RTC_ALARM1 ((uint8_t)0x02U) /*!< RTC alarm 1 */
/* RTC coarse calibration direction */
-#define CALIB_INCREASE ((uint8_t)0x01U) /*!< RTC coarse calibration increase */
-#define CALIB_DECREASE ((uint8_t)0x02U) /*!< RTC coarse calibration decrease */
+#define CALIB_INCREASE ((uint8_t)0x01U) /*!< RTC coarse calibration increase */
+#define CALIB_DECREASE ((uint8_t)0x02U) /*!< RTC coarse calibration decrease */
/* RTC wakeup timer clock */
#define CTL_WTCS(regval) (BITS(0,2) & ((regval)<< 0))
@@ -516,7 +517,7 @@ typedef struct
#define WAKEUP_RTCCK_DIV2 CTL_WTCS(3) /*!< wakeup timer clock is RTC clock divided by 2 */
#define WAKEUP_CKSPRE CTL_WTCS(4) /*!< wakeup timer clock is ckapre */
#define WAKEUP_CKSPRE_2EXP16 CTL_WTCS(6) /*!< wakeup timer clock is ckapre and wakeup timer add 2exp16 */
-
+
/* RTC_AF pin */
#define RTC_AF0_TIMESTAMP ((uint32_t)0x00000000) /*!< RTC_AF0 use for timestamp */
#define RTC_AF1_TIMESTAMP RTC_TAMP_TSSEL /*!< RTC_AF1 use for timestamp */
@@ -524,7 +525,7 @@ typedef struct
#define RTC_AF1_TAMPER0 RTC_TAMP_TP0SEL /*!< RTC_AF1 use for tamper0 */
/* RTC flags */
-#define RTC_FLAG_ALRM0W RTC_STAT_ALRM0WF /*!< alarm0 configuration can be write flag */
+#define RTC_FLAG_ALRM0W RTC_STAT_ALRM0WF /*!< alarm0 configuration can be write flag */
#define RTC_FLAG_ALRM1W RTC_STAT_ALRM1WF /*!< alarm1 configuration can be write flag */
#define RTC_FLAG_WTW RTC_STAT_WTWF /*!< wakeup timer can be write flag */
#define RTC_FLAG_SOP RTC_STAT_SOPF /*!< shift function operation pending flag */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_sdio.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_sdio.h
index a18214c023..7b8189d62b 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_sdio.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_sdio.h
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -43,24 +44,24 @@ OF SUCH DAMAGE.
#define SDIO SDIO_BASE
/* registers definitions */
-#define SDIO_PWRCTL REG32(SDIO + 0x00U) /*!< SDIO power control register */
-#define SDIO_CLKCTL REG32(SDIO + 0x04U) /*!< SDIO clock control register */
-#define SDIO_CMDAGMT REG32(SDIO + 0x08U) /*!< SDIO command argument register */
-#define SDIO_CMDCTL REG32(SDIO + 0x0CU) /*!< SDIO command control register */
-#define SDIO_RSPCMDIDX REG32(SDIO + 0x10U) /*!< SDIO command index response register */
-#define SDIO_RESP0 REG32(SDIO + 0x14U) /*!< SDIO response register 0 */
-#define SDIO_RESP1 REG32(SDIO + 0x18U) /*!< SDIO response register 1 */
-#define SDIO_RESP2 REG32(SDIO + 0x1CU) /*!< SDIO response register 2 */
-#define SDIO_RESP3 REG32(SDIO + 0x20U) /*!< SDIO response register 3 */
-#define SDIO_DATATO REG32(SDIO + 0x24U) /*!< SDIO data timeout register */
-#define SDIO_DATALEN REG32(SDIO + 0x28U) /*!< SDIO data length register */
-#define SDIO_DATACTL REG32(SDIO + 0x2CU) /*!< SDIO data control register */
-#define SDIO_DATACNT REG32(SDIO + 0x30U) /*!< SDIO data counter register */
-#define SDIO_STAT REG32(SDIO + 0x34U) /*!< SDIO status register */
-#define SDIO_INTC REG32(SDIO + 0x38U) /*!< SDIO interrupt clear register */
-#define SDIO_INTEN REG32(SDIO + 0x3CU) /*!< SDIO interrupt enable register */
-#define SDIO_FIFOCNT REG32(SDIO + 0x48U) /*!< SDIO FIFO counter register */
-#define SDIO_FIFO REG32(SDIO + 0x80U) /*!< SDIO FIFO data register */
+#define SDIO_PWRCTL REG32(SDIO + 0x00000000U) /*!< SDIO power control register */
+#define SDIO_CLKCTL REG32(SDIO + 0x00000004U) /*!< SDIO clock control register */
+#define SDIO_CMDAGMT REG32(SDIO + 0x00000008U) /*!< SDIO command argument register */
+#define SDIO_CMDCTL REG32(SDIO + 0x0000000CU) /*!< SDIO command control register */
+#define SDIO_RSPCMDIDX REG32(SDIO + 0x00000010U) /*!< SDIO command index response register */
+#define SDIO_RESP0 REG32(SDIO + 0x00000014U) /*!< SDIO response register 0 */
+#define SDIO_RESP1 REG32(SDIO + 0x00000018U) /*!< SDIO response register 1 */
+#define SDIO_RESP2 REG32(SDIO + 0x0000001CU) /*!< SDIO response register 2 */
+#define SDIO_RESP3 REG32(SDIO + 0x00000020U) /*!< SDIO response register 3 */
+#define SDIO_DATATO REG32(SDIO + 0x00000024U) /*!< SDIO data timeout register */
+#define SDIO_DATALEN REG32(SDIO + 0x00000028U) /*!< SDIO data length register */
+#define SDIO_DATACTL REG32(SDIO + 0x0000002CU) /*!< SDIO data control register */
+#define SDIO_DATACNT REG32(SDIO + 0x00000030U) /*!< SDIO data counter register */
+#define SDIO_STAT REG32(SDIO + 0x00000034U) /*!< SDIO status register */
+#define SDIO_INTC REG32(SDIO + 0x00000038U) /*!< SDIO interrupt clear register */
+#define SDIO_INTEN REG32(SDIO + 0x0000003CU) /*!< SDIO interrupt enable register */
+#define SDIO_FIFOCNT REG32(SDIO + 0x00000048U) /*!< SDIO FIFO counter register */
+#define SDIO_FIFO REG32(SDIO + 0x00000080U) /*!< SDIO FIFO data register */
/* bits definitions */
/* SDIO_PWRCTL */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_spi.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_spi.h
index 61bf8b1af2..d56967877f 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_spi.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_spi.h
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -53,27 +54,27 @@ OF SUCH DAMAGE.
#define I2S2_ADD (I2S_ADD_BASE + 0x00000C00U)
/* SPI registers definitions */
-#define SPI_CTL0(spix) REG32((spix) + 0x00U) /*!< SPI control register 0 */
-#define SPI_CTL1(spix) REG32((spix) + 0x04U) /*!< SPI control register 1*/
-#define SPI_STAT(spix) REG32((spix) + 0x08U) /*!< SPI status register */
-#define SPI_DATA(spix) REG32((spix) + 0x0CU) /*!< SPI data register */
-#define SPI_CRCPOLY(spix) REG32((spix) + 0x10U) /*!< SPI CRC polynomial register */
-#define SPI_RCRC(spix) REG32((spix) + 0x14U) /*!< SPI receive CRC register */
-#define SPI_TCRC(spix) REG32((spix) + 0x18U) /*!< SPI transmit CRC register */
-#define SPI_I2SCTL(spix) REG32((spix) + 0x1CU) /*!< SPI I2S control register */
-#define SPI_I2SPSC(spix) REG32((spix) + 0x20U) /*!< SPI I2S clock prescaler register */
-#define SPI_QCTL(spix) REG32((spix) + 0x80U) /*!< SPI quad mode control register */
+#define SPI_CTL0(spix) REG32((spix) + 0x00000000U) /*!< SPI control register 0 */
+#define SPI_CTL1(spix) REG32((spix) + 0x00000004U) /*!< SPI control register 1*/
+#define SPI_STAT(spix) REG32((spix) + 0x00000008U) /*!< SPI status register */
+#define SPI_DATA(spix) REG32((spix) + 0x0000000CU) /*!< SPI data register */
+#define SPI_CRCPOLY(spix) REG32((spix) + 0x00000010U) /*!< SPI CRC polynomial register */
+#define SPI_RCRC(spix) REG32((spix) + 0x00000014U) /*!< SPI receive CRC register */
+#define SPI_TCRC(spix) REG32((spix) + 0x00000018U) /*!< SPI transmit CRC register */
+#define SPI_I2SCTL(spix) REG32((spix) + 0x0000001CU) /*!< SPI I2S control register */
+#define SPI_I2SPSC(spix) REG32((spix) + 0x00000020U) /*!< SPI I2S clock prescaler register */
+#define SPI_QCTL(spix) REG32((spix) + 0x00000080U) /*!< SPI quad mode control register */
/* I2S_ADD registers definitions */
-#define I2S_ADD_CTL0(i2sx_add) REG32((i2sx_add) + 0x00U) /*!< I2S_ADD control register 0 */
-#define I2S_ADD_CTL1(i2sx_add) REG32((i2sx_add) + 0x04U) /*!< I2S_ADD control register 1*/
-#define I2S_ADD_STAT(i2sx_add) REG32((i2sx_add) + 0x08U) /*!< I2S_ADD status register */
-#define I2S_ADD_DATA(i2sx_add) REG32((i2sx_add) + 0x0CU) /*!< I2S_ADD data register */
-#define I2S_ADD_CRCPOLY(i2sx_add) REG32((i2sx_add) + 0x10U) /*!< I2S_ADD CRC polynomial register */
-#define I2S_ADD_RCRC(i2sx_add) REG32((i2sx_add) + 0x14U) /*!< I2S_ADD receive CRC register */
-#define I2S_ADD_TCRC(i2sx_add) REG32((i2sx_add) + 0x18U) /*!< I2S_ADD transmit CRC register */
-#define I2S_ADD_I2SCTL(i2sx_add) REG32((i2sx_add) + 0x1CU) /*!< I2S_ADD I2S control register */
-#define I2S_ADD_I2SPSC(i2sx_add) REG32((i2sx_add) + 0x20U) /*!< I2S_ADD I2S clock prescaler register */
+#define I2S_ADD_CTL0(i2sx_add) REG32((i2sx_add) + 0x00000000U) /*!< I2S_ADD control register 0 */
+#define I2S_ADD_CTL1(i2sx_add) REG32((i2sx_add) + 0x00000004U) /*!< I2S_ADD control register 1*/
+#define I2S_ADD_STAT(i2sx_add) REG32((i2sx_add) + 0x00000008U) /*!< I2S_ADD status register */
+#define I2S_ADD_DATA(i2sx_add) REG32((i2sx_add) + 0x0000000CU) /*!< I2S_ADD data register */
+#define I2S_ADD_CRCPOLY(i2sx_add) REG32((i2sx_add) + 0x00000010U) /*!< I2S_ADD CRC polynomial register */
+#define I2S_ADD_RCRC(i2sx_add) REG32((i2sx_add) + 0x00000014U) /*!< I2S_ADD receive CRC register */
+#define I2S_ADD_TCRC(i2sx_add) REG32((i2sx_add) + 0x00000018U) /*!< I2S_ADD transmit CRC register */
+#define I2S_ADD_I2SCTL(i2sx_add) REG32((i2sx_add) + 0x0000001CU) /*!< I2S_ADD I2S control register */
+#define I2S_ADD_I2SPSC(i2sx_add) REG32((i2sx_add) + 0x00000020U) /*!< I2S_ADD I2S clock prescaler register */
/* bits definitions */
/* SPI_CTL0 */
@@ -146,8 +147,7 @@ OF SUCH DAMAGE.
/* constants definitions */
/* SPI and I2S parameter struct definitions */
-typedef struct
-{
+typedef struct {
uint32_t device_mode; /*!< SPI master or slave */
uint32_t trans_mode; /*!< SPI transtype */
uint32_t frame_size; /*!< SPI frame size */
@@ -155,7 +155,7 @@ typedef struct
uint32_t endian; /*!< SPI big endian or little endian */
uint32_t clock_polarity_phase; /*!< SPI clock phase and polarity */
uint32_t prescale; /*!< SPI prescale factor */
-}spi_parameter_struct;
+} spi_parameter_struct;
/* SPI mode definitions */
#define SPI_MASTER (SPI_CTL0_MSTMOD | SPI_CTL0_SWNSS) /*!< SPI as master */
@@ -283,19 +283,19 @@ typedef struct
/* initialization functions */
/* deinitialize SPI and I2S */
void spi_i2s_deinit(uint32_t spi_periph);
-/* initialize the parameters of SPI struct with the default values */
-void spi_struct_para_init(spi_parameter_struct* spi_struct);
+/* initialize the parameters of SPI struct with default values */
+void spi_struct_para_init(spi_parameter_struct *spi_struct);
/* initialize SPI parameter */
-void spi_init(uint32_t spi_periph,spi_parameter_struct* spi_struct);
+void spi_init(uint32_t spi_periph, spi_parameter_struct *spi_struct);
/* enable SPI */
void spi_enable(uint32_t spi_periph);
/* disable SPI */
void spi_disable(uint32_t spi_periph);
/* initialize I2S parameter */
-void i2s_init(uint32_t spi_periph,uint32_t i2s_mode,uint32_t i2s_standard,uint32_t i2s_ckpl);
+void i2s_init(uint32_t spi_periph, uint32_t i2s_mode, uint32_t i2s_standard, uint32_t i2s_ckpl);
/* configure I2S prescale */
-void i2s_psc_config(uint32_t spi_periph,uint32_t i2s_audiosample,uint32_t i2s_frameformat,uint32_t i2s_mckout);
+void i2s_psc_config(uint32_t spi_periph, uint32_t i2s_audiosample, uint32_t i2s_frameformat, uint32_t i2s_mckout);
/* enable I2S */
void i2s_enable(uint32_t spi_periph);
/* disable I2S */
@@ -312,24 +312,28 @@ void spi_nss_internal_high(uint32_t spi_periph);
void spi_nss_internal_low(uint32_t spi_periph);
/* SPI DMA functions */
-/* enable SPI DMA */
-void spi_dma_enable(uint32_t spi_periph,uint8_t spi_dma);
-/* disable SPI DMA */
-void spi_dma_disable(uint32_t spi_periph,uint8_t spi_dma);
+/* enable SPI DMA send or receive */
+void spi_dma_enable(uint32_t spi_periph, uint8_t spi_dma);
+/* diable SPI DMA send or receive */
+void spi_dma_disable(uint32_t spi_periph, uint8_t spi_dma);
/* SPI/I2S transfer configure functions */
/* configure SPI/I2S data frame format */
-void spi_i2s_data_frame_format_config(uint32_t spi_periph,uint16_t frame_format);
+void spi_i2s_data_frame_format_config(uint32_t spi_periph, uint16_t frame_format);
/* SPI transmit data */
-void spi_i2s_data_transmit(uint32_t spi_periph,uint16_t data);
+void spi_i2s_data_transmit(uint32_t spi_periph, uint16_t data);
/* SPI receive data */
uint16_t spi_i2s_data_receive(uint32_t spi_periph);
/* configure SPI bidirectional transfer direction */
-void spi_bidirectional_transfer_config(uint32_t spi_periph,uint32_t transfer_direction);
+void spi_bidirectional_transfer_config(uint32_t spi_periph, uint32_t transfer_direction);
+/* configure i2s full duplex mode */
+void i2s_full_duplex_mode_config(uint32_t i2s_add_periph, uint32_t i2s_mode, uint32_t i2s_standard, uint32_t i2s_ckpl, uint32_t i2s_frameformat);
+/* clear TI Mode Format Error flag status */
+void spi_i2s_format_error_clear(uint32_t spi_periph, uint32_t flag);
/* SPI CRC functions */
/* set SPI CRC polynomial */
-void spi_crc_polynomial_set(uint32_t spi_periph,uint16_t crc_poly);
+void spi_crc_polynomial_set(uint32_t spi_periph, uint16_t crc_poly);
/* get SPI CRC polynomial */
uint16_t spi_crc_polynomial_get(uint32_t spi_periph);
/* turn on SPI CRC function */
@@ -339,7 +343,9 @@ void spi_crc_off(uint32_t spi_periph);
/* SPI next data is CRC value */
void spi_crc_next(uint32_t spi_periph);
/* get SPI CRC send value or receive value */
-uint16_t spi_crc_get(uint32_t spi_periph,uint8_t spi_crc);
+uint16_t spi_crc_get(uint32_t spi_periph, uint8_t spi_crc);
+/* clear SPI CRC error flag status */
+void spi_crc_error_clear(uint32_t spi_periph);
/* SPI TI mode functions */
/* enable SPI TI mode */
@@ -347,33 +353,28 @@ void spi_ti_mode_enable(uint32_t spi_periph);
/* disable SPI TI mode */
void spi_ti_mode_disable(uint32_t spi_periph);
-/* configure i2s full duplex mode */
-void i2s_full_duplex_mode_config(uint32_t i2s_add_periph,uint32_t i2s_mode,uint32_t i2s_standard,uint32_t i2s_ckpl,uint32_t i2s_frameformat);
-
/* quad wire SPI functions */
/* enable quad wire SPI */
-void qspi_enable(uint32_t spi_periph);
+void spi_quad_enable(uint32_t spi_periph);
/* disable quad wire SPI */
-void qspi_disable(uint32_t spi_periph);
+void spi_quad_disable(uint32_t spi_periph);
/* enable quad wire SPI write */
-void qspi_write_enable(uint32_t spi_periph);
+void spi_quad_write_enable(uint32_t spi_periph);
/* enable quad wire SPI read */
-void qspi_read_enable(uint32_t spi_periph);
-/* enable quad wire SPI_IO2 and SPI_IO3 pin output */
-void qspi_io23_output_enable(uint32_t spi_periph);
-/* disable quad wire SPI_IO2 and SPI_IO3 pin output */
-void qspi_io23_output_disable(uint32_t spi_periph);
+void spi_quad_read_enable(uint32_t spi_periph);
+/* enable SPI_IO2 and SPI_IO3 pin output */
+void spi_quad_io23_output_enable(uint32_t spi_periph);
+/* disable SPI_IO2 and SPI_IO3 pin output */
+void spi_quad_io23_output_disable(uint32_t spi_periph);
-/* flag & interrupt functions */
-/* enable SPI interrupt */
-void spi_i2s_interrupt_enable(uint32_t spi_periph,uint8_t spi_i2s_int);
-/* disable SPI interrupt */
-void spi_i2s_interrupt_disable(uint32_t spi_periph,uint8_t spi_i2s_int);
-/* get SPI and I2S interrupt status*/
-FlagStatus spi_i2s_interrupt_flag_get(uint32_t spi_periph,uint8_t spi_i2s_int);
+/* flag and interrupt functions */
/* get SPI and I2S flag status */
-FlagStatus spi_i2s_flag_get(uint32_t spi_periph,uint32_t spi_i2s_flag);
-/* clear SPI CRC error flag status */
-void spi_crc_error_clear(uint32_t spi_periph);
+FlagStatus spi_i2s_flag_get(uint32_t spi_periph, uint32_t flag);
+/* enable SPI and I2S interrupt */
+void spi_i2s_interrupt_enable(uint32_t spi_periph, uint8_t interrupt);
+/* disable SPI and I2S interrupt */
+void spi_i2s_interrupt_disable(uint32_t spi_periph, uint8_t interrupt);
+/* get SPI and I2S interrupt status*/
+FlagStatus spi_i2s_interrupt_flag_get(uint32_t spi_periph, uint8_t interrupt);
#endif /* GD32F4XX_SPI_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_syscfg.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_syscfg.h
index 047910478a..2e9922db1d 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_syscfg.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_syscfg.h
@@ -1,36 +1,37 @@
/*!
\file gd32f4xx_syscfg.h
\brief definitions for the SYSCFG
-
+
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -166,7 +167,7 @@ void syscfg_bootmode_config(uint8_t syscfg_bootmode);
/* configure FMC memory mapping swap */
void syscfg_fmc_swap_config(uint32_t syscfg_fmc_swap);
/* configure the EXMC swap */
-void syscfg_exmc_swap_config(uint32_t syscfg_exmc_swap);
+void syscfg_exmc_swap_config(uint32_t syscfg_exmc_swap);
/* configure the GPIO pin as EXTI Line */
void syscfg_exti_line_config(uint8_t exti_port, uint8_t exti_pin);
/* configure the PHY interface for the ethernet MAC */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_timer.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_timer.h
index 9da6e12bdd..f80c8014be 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_timer.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_timer.h
@@ -5,33 +5,33 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
- All rights reserved.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -113,7 +113,7 @@ OF SUCH DAMAGE.
#define TIMER_SMCFG_ETPSC BITS(12,13) /*!< external trigger prescaler */
#define TIMER_SMCFG_SMC1 BIT(14) /*!< part of SMC for enable external clock mode 1 */
#define TIMER_SMCFG_ETP BIT(15) /*!< external trigger polarity */
-
+
/* TIMER_DMAINTEN */
#define TIMER_DMAINTEN_UPIE BIT(0) /*!< update interrupt enable */
#define TIMER_DMAINTEN_CH0IE BIT(1) /*!< channel 0 capture/compare interrupt enable */
@@ -266,7 +266,7 @@ OF SUCH DAMAGE.
/* constants definitions */
/* TIMER init parameter struct definitions*/
typedef struct
-{
+{
uint16_t prescaler; /*!< prescaler value */
uint16_t alignedmode; /*!< aligned mode */
uint16_t counterdirection; /*!< counter direction */
@@ -277,7 +277,7 @@ typedef struct
/* break parameter struct definitions*/
typedef struct
-{
+{
uint16_t runoffstate; /*!< run mode off-state */
uint16_t ideloffstate; /*!< idle mode off-state */
uint16_t deadtime; /*!< dead time */
@@ -289,7 +289,7 @@ typedef struct
/* channel output parameter struct definitions */
typedef struct
-{
+{
uint16_t outputstate; /*!< channel output state */
uint16_t outputnstate; /*!< channel complementary output state */
uint16_t ocpolarity; /*!< channel output polarity */
@@ -300,7 +300,7 @@ typedef struct
/* channel input parameter struct definitions */
typedef struct
-{
+{
uint16_t icpolarity; /*!< channel input polarity */
uint16_t icselection; /*!< channel input mode selection */
uint16_t icprescaler; /*!< channel input capture prescaler */
@@ -341,8 +341,6 @@ typedef struct
#define TIMER_INT_FLAG_TRG TIMER_INTF_TRGIF /*!< trigger interrupt flag */
#define TIMER_INT_FLAG_BRK TIMER_INTF_BRKIF
-
-
/* TIMER DMA source enable */
#define TIMER_DMA_UPD ((uint16_t)TIMER_DMAINTEN_UPDEN) /*!< update DMA enable */
#define TIMER_DMA_CH0D ((uint16_t)TIMER_DMAINTEN_CH0DEN) /*!< channel 0 DMA enable */
@@ -352,7 +350,7 @@ typedef struct
#define TIMER_DMA_CMTD ((uint16_t)TIMER_DMAINTEN_CMTDEN) /*!< commutation DMA request enable */
#define TIMER_DMA_TRGD ((uint16_t)TIMER_DMAINTEN_TRGDEN) /*!< trigger DMA enable */
-/* channel DMA request source selection */
+/* channel DMA request source selection */
#define TIMER_DMAREQUEST_UPDATEEVENT ((uint8_t)0x00U) /*!< DMA request of channel y is sent when update event occurs */
#define TIMER_DMAREQUEST_CHANNELEVENT ((uint8_t)0x01U) /*!< DMA request of channel y is sent when channel y event occurs */
@@ -418,8 +416,8 @@ typedef struct
#define TIMER_COUNTER_CENTER_BOTH CTL0_CAM(3) /*!< center-aligned and counting up/down assert mode */
/* TIMER prescaler reload mode */
-#define TIMER_PSC_RELOAD_NOW ((uint32_t)0x00000000U) /*!< the prescaler is loaded right now */
-#define TIMER_PSC_RELOAD_UPDATE ((uint32_t)0x00000001U) /*!< the prescaler is loaded at the next update event */
+#define TIMER_PSC_RELOAD_NOW ((uint32_t)0x00000000U) /*!< the prescaler is loaded right now */
+#define TIMER_PSC_RELOAD_UPDATE ((uint32_t)0x00000001U) /*!< the prescaler is loaded at the next update event */
/* count direction */
#define TIMER_COUNTER_UP ((uint16_t)0x0000U) /*!< counter up direction */
@@ -432,18 +430,18 @@ typedef struct
#define TIMER_CKDIV_DIV4 CTL0_CKDIV(2) /*!< clock division value is 4, fDTS= fTIMER_CK/4 */
/* single pulse mode */
-#define TIMER_SP_MODE_SINGLE ((uint32_t)0x00000000U) /*!< single pulse mode */
-#define TIMER_SP_MODE_REPETITIVE ((uint32_t)0x00000001U) /*!< repetitive pulse mode */
+#define TIMER_SP_MODE_SINGLE ((uint32_t)0x00000000U) /*!< single pulse mode */
+#define TIMER_SP_MODE_REPETITIVE ((uint32_t)0x00000001U) /*!< repetitive pulse mode */
/* update source */
-#define TIMER_UPDATE_SRC_REGULAR ((uint32_t)0x00000000U) /*!< update generate only by counter overflow/underflow */
-#define TIMER_UPDATE_SRC_GLOBAL ((uint32_t)0x00000001U) /*!< update generate by setting of UPG bit or the counter overflow/underflow,or the slave mode controller trigger */
+#define TIMER_UPDATE_SRC_REGULAR ((uint32_t)0x00000000U) /*!< update generate only by counter overflow/underflow */
+#define TIMER_UPDATE_SRC_GLOBAL ((uint32_t)0x00000001U) /*!< update generate by setting of UPG bit or the counter overflow/underflow,or the slave mode controller trigger */
/* run mode off-state configure */
#define TIMER_ROS_STATE_ENABLE ((uint16_t)TIMER_CCHP_ROS) /*!< when POEN bit is set, the channel output signals (CHx_O/CHx_ON) are enabled, with relationship to CHxEN/CHxNEN bits */
#define TIMER_ROS_STATE_DISABLE ((uint16_t)0x0000U) /*!< when POEN bit is set, the channel output signals (CHx_O/CHx_ON) are disabled */
-/* idle mode off-state configure */
+/* idle mode off-state configure */
#define TIMER_IOS_STATE_ENABLE ((uint16_t)TIMER_CCHP_IOS) /*!< when POEN bit is reset, the channel output signals (CHx_O/CHx_ON) are enabled, with relationship to CHxEN/CHxNEN bits */
#define TIMER_IOS_STATE_DISABLE ((uint16_t)0x0000U) /*!< when POEN bit is reset, the channel output signals (CHx_O/CHx_ON) are disabled */
@@ -488,11 +486,11 @@ typedef struct
#define TIMER_OCN_POLARITY_HIGH ((uint16_t)0x0000U) /*!< channel complementary output polarity is high */
#define TIMER_OCN_POLARITY_LOW ((uint16_t)0x0008U) /*!< channel complementary output polarity is low */
-/* idle state of channel output */
+/* idle state of channel output */
#define TIMER_OC_IDLE_STATE_HIGH ((uint16_t)0x0100) /*!< idle state of channel output is high */
#define TIMER_OC_IDLE_STATE_LOW ((uint16_t)0x0000) /*!< idle state of channel output is low */
-/* idle state of channel complementary output */
+/* idle state of channel complementary output */
#define TIMER_OCN_IDLE_STATE_HIGH ((uint16_t)0x0200U) /*!< idle state of channel complementary output is high */
#define TIMER_OCN_IDLE_STATE_LOW ((uint16_t)0x0000U) /*!< idle state of channel complementary output is low */
@@ -518,7 +516,7 @@ typedef struct
#define TIMER_OC_CLEAR_ENABLE ((uint16_t)0x0080U) /*!< channel output clear function enable */
#define TIMER_OC_CLEAR_DISABLE ((uint16_t)0x0000U) /*!< channel output clear function disable */
-/* channel control shadow register update control */
+/* channel control shadow register update control */
#define TIMER_UPDATECTL_CCU ((uint32_t)0x00000000U) /*!< the shadow registers are updated when CMTG bit is set */
#define TIMER_UPDATECTL_CCUTRI ((uint32_t)0x00000001U) /*!< the shadow registers update by when CMTG bit is set or an rising edge of TRGI occurs */
@@ -539,7 +537,7 @@ typedef struct
#define TIMER_IC_PSC_DIV8 ((uint16_t)0x000CU) /*!< divided by 8 */
/* trigger selection */
-#define SMCFG_TRGSEL(regval) (BITS(4, 6) & ((uint32_t)(regval) << 4U))
+#define SMCFG_TRGSEL(regval) (BITS(4, 6) & ((uint32_t)(regval) << 4U))
#define TIMER_SMCFG_TRGSEL_ITI0 SMCFG_TRGSEL(0) /*!< internal trigger 0 */
#define TIMER_SMCFG_TRGSEL_ITI1 SMCFG_TRGSEL(1) /*!< internal trigger 1 */
#define TIMER_SMCFG_TRGSEL_ITI2 SMCFG_TRGSEL(2) /*!< internal trigger 2 */
@@ -561,19 +559,19 @@ typedef struct
#define TIMER_TRI_OUT_SRC_O3CPRE CTL1_MMC(7) /*!< O3CPRE as trigger output */
/* slave mode control */
-#define SMCFG_SMC(regval) (BITS(0, 2) & ((uint32_t)(regval) << 0U))
+#define SMCFG_SMC(regval) (BITS(0, 2) & ((uint32_t)(regval) << 0U))
#define TIMER_SLAVE_MODE_DISABLE SMCFG_SMC(0) /*!< slave mode disable */
-#define TIMER_ENCODER_MODE0 SMCFG_SMC(1) /*!< encoder mode 0 */
-#define TIMER_ENCODER_MODE1 SMCFG_SMC(2) /*!< encoder mode 1 */
-#define TIMER_ENCODER_MODE2 SMCFG_SMC(3) /*!< encoder mode 2 */
+#define TIMER_QUAD_DECODER_MODE0 SMCFG_SMC(1) /*!< quadrature decoder mode 0 */
+#define TIMER_QUAD_DECODER_MODE1 SMCFG_SMC(2) /*!< quadrature decoder mode 1 */
+#define TIMER_QUAD_DECODER_MODE2 SMCFG_SMC(3) /*!< quadrature decoder mode 2 */
#define TIMER_SLAVE_MODE_RESTART SMCFG_SMC(4) /*!< restart mode */
#define TIMER_SLAVE_MODE_PAUSE SMCFG_SMC(5) /*!< pause mode */
#define TIMER_SLAVE_MODE_EVENT SMCFG_SMC(6) /*!< event mode */
#define TIMER_SLAVE_MODE_EXTERNAL0 SMCFG_SMC(7) /*!< external clock mode 0 */
-/* master slave mode selection */
-#define TIMER_MASTER_SLAVE_MODE_ENABLE ((uint32_t)0x00000000U) /*!< master slave mode enable */
-#define TIMER_MASTER_SLAVE_MODE_DISABLE ((uint32_t)0x00000001U) /*!< master slave mode disable */
+/* master slave mode selection */
+#define TIMER_MASTER_SLAVE_MODE_ENABLE ((uint32_t)0x00000000U) /*!< master slave mode enable */
+#define TIMER_MASTER_SLAVE_MODE_DISABLE ((uint32_t)0x00000001U) /*!< master slave mode disable */
/* external trigger prescaler */
#define SMCFG_ETPSC(regval) (BITS(12, 13) & ((uint32_t)(regval) << 12U))
@@ -586,19 +584,19 @@ typedef struct
#define TIMER_ETP_FALLING TIMER_SMCFG_ETP /*!< active low or falling edge active */
#define TIMER_ETP_RISING ((uint32_t)0x00000000U) /*!< active high or rising edge active */
-/* channel 0 trigger input selection */
-#define TIMER_HALLINTERFACE_ENABLE ((uint32_t)0x00000000U) /*!< TIMER hall sensor mode enable */
-#define TIMER_HALLINTERFACE_DISABLE ((uint32_t)0x00000001U) /*!< TIMER hall sensor mode disable */
+/* channel 0 trigger input selection */
+#define TIMER_HALLINTERFACE_ENABLE ((uint32_t)0x00000000U) /*!< TIMER hall sensor mode enable */
+#define TIMER_HALLINTERFACE_DISABLE ((uint32_t)0x00000001U) /*!< TIMER hall sensor mode disable */
/* timer1 internal trigger input1 remap */
-#define TIMER1_IRMP(regval) (BITS(10, 11) & ((uint32_t)(regval) << 10U))
+#define TIMER1_IRMP(regval) (BITS(10, 11) & ((uint32_t)(regval) << 10U))
#define TIMER1_ITI1_RMP_TIMER7_TRGO TIMER1_IRMP(0) /*!< timer1 internal trigger input 1 remap to TIMER7_TRGO */
#define TIMER1_ITI1_RMP_ETHERNET_PTP TIMER1_IRMP(1) /*!< timer1 internal trigger input 1 remap to ethernet PTP */
#define TIMER1_ITI1_RMP_USB_FS_SOF TIMER1_IRMP(2) /*!< timer1 internal trigger input 1 remap to USB FS SOF */
#define TIMER1_ITI1_RMP_USB_HS_SOF TIMER1_IRMP(3) /*!< timer1 internal trigger input 1 remap to USB HS SOF */
/* timer4 channel 3 input remap */
-#define TIMER4_IRMP(regval) (BITS(6, 7) & ((uint32_t)(regval) << 6U))
+#define TIMER4_IRMP(regval) (BITS(6, 7) & ((uint32_t)(regval) << 6U))
#define TIMER4_CI3_RMP_GPIO TIMER4_IRMP(0) /*!< timer4 channel 3 input remap to GPIO pin */
#define TIMER4_CI3_RMP_IRC32K TIMER4_IRMP(1) /*!< timer4 channel 3 input remap to IRC32K */
#define TIMER4_CI3_RMP_LXTAL TIMER4_IRMP(2) /*!< timer4 channel 3 input remap to LXTAL */
@@ -610,8 +608,8 @@ typedef struct
#define TIMER10_ITI1_RMP_RTC_HXTAL_DIV TIMER10_IRMP(2) /*!< timer10 internal trigger input1 remap HXTAL _DIV(clock used for RTC which is HXTAL clock divided by RTCDIV bits in RCU_CFG0 register) */
/* timerx(x=0,1,2,13,14,15,16) write cc register selection */
-#define TIMER_CHVSEL_ENABLE ((uint16_t)0x0002U) /*!< write CHxVAL register selection enable */
-#define TIMER_CHVSEL_DISABLE ((uint16_t)0x0000U) /*!< write CHxVAL register selection disable */
+#define TIMER_CHVSEL_ENABLE ((uint16_t)0x0002U) /*!< write CHxVAL register selection enable */
+#define TIMER_CHVSEL_DISABLE ((uint16_t)0x0000U) /*!< write CHxVAL register selection disable */
/* the output value selection */
#define TIMER_OUTSEL_ENABLE ((uint16_t)0x0001U) /*!< output value selection enable */
@@ -660,20 +658,6 @@ void timer_single_pulse_mode_config(uint32_t timer_periph, uint32_t spmode);
/* configure TIMER update source */
void timer_update_source_config(uint32_t timer_periph, uint32_t update);
-/* TIMER interrupt and flag*/
-/* enable the TIMER interrupt */
-void timer_interrupt_enable(uint32_t timer_periph, uint32_t interrupt);
-/* disable the TIMER interrupt */
-void timer_interrupt_disable(uint32_t timer_periph, uint32_t interrupt);
-/* get timer interrupt flag */
-FlagStatus timer_interrupt_flag_get(uint32_t timer_periph, uint32_t interrupt);
-/* clear TIMER interrupt flag */
-void timer_interrupt_flag_clear(uint32_t timer_periph, uint32_t interrupt);
-/* get TIMER flags */
-FlagStatus timer_flag_get(uint32_t timer_periph, uint32_t flag);
-/* clear TIMER flags */
-void timer_flag_clear(uint32_t timer_periph, uint32_t flag);
-
/* timer DMA and event*/
/* enable the TIMER DMA */
void timer_dma_enable(uint32_t timer_periph, uint16_t dma);
@@ -778,4 +762,18 @@ void timer_write_chxval_register_config(uint32_t timer_periph, uint16_t ccsel);
/* configure TIMER output value selection */
void timer_output_value_selection_config(uint32_t timer_periph, uint16_t outsel);
+/* TIMER interrupt and flag*/
+/* get TIMER flags */
+FlagStatus timer_flag_get(uint32_t timer_periph, uint32_t flag);
+/* clear TIMER flags */
+void timer_flag_clear(uint32_t timer_periph, uint32_t flag);
+/* enable the TIMER interrupt */
+void timer_interrupt_enable(uint32_t timer_periph, uint32_t interrupt);
+/* disable the TIMER interrupt */
+void timer_interrupt_disable(uint32_t timer_periph, uint32_t interrupt);
+/* get timer interrupt flag */
+FlagStatus timer_interrupt_flag_get(uint32_t timer_periph, uint32_t interrupt);
+/* clear TIMER interrupt flag */
+void timer_interrupt_flag_clear(uint32_t timer_periph, uint32_t interrupt);
+
#endif /* GD32F4XX_TIMER_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_tli.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_tli.h
index 8b1232fa17..78e6670177 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_tli.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_tli.h
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -40,37 +41,37 @@ OF SUCH DAMAGE.
#include "gd32f4xx.h"
/* TLI definitions */
-#define TLI TLI_BASE /*!< TLI base address */
+#define TLI TLI_BASE /*!< TLI base address */
/* TLI layer definitions */
-#define LAYER0 TLI_BASE /*!< TLI layer0 base address */
-#define LAYER1 (TLI_BASE+0x80) /*!< TLI layer1 base address */
+#define LAYER0 TLI_BASE /*!< TLI layer0 base address */
+#define LAYER1 (TLI_BASE + 0x00000080U) /*!< TLI layer1 base address */
/* registers definitions */
-#define TLI_SPSZ REG32(TLI + 0x08U) /*!< TLI synchronous pulse size register */
-#define TLI_BPSZ REG32(TLI + 0x0CU) /*!< TLI back-porch size register */
-#define TLI_ASZ REG32(TLI + 0x10U) /*!< TLI active size register */
-#define TLI_TSZ REG32(TLI + 0x14U) /*!< TLI total size register */
-#define TLI_CTL REG32(TLI + 0x18U) /*!< TLI control register */
-#define TLI_RL REG32(TLI + 0x24U) /*!< TLI reload Layer register */
-#define TLI_BGC REG32(TLI + 0x2CU) /*!< TLI background color register */
-#define TLI_INTEN REG32(TLI + 0x34U) /*!< TLI interrupt enable register */
-#define TLI_INTF REG32(TLI + 0x38U) /*!< TLI interrupt flag register */
-#define TLI_INTC REG32(TLI + 0x3CU) /*!< TLI interrupt flag clear register */
-#define TLI_LM REG32(TLI + 0x40U) /*!< TLI line mark register */
-#define TLI_CPPOS REG32(TLI + 0x44U) /*!< TLI current pixel position register */
-#define TLI_STAT REG32(TLI + 0x48U) /*!< TLI status register */
-#define TLI_LxCTL(layerx) REG32((layerx) + 0x84U) /*!< TLI layer x control register */
-#define TLI_LxHPOS(layerx) REG32((layerx) + 0x88U) /*!< TLI layer x horizontal position parameters register */
-#define TLI_LxVPOS(layerx) REG32((layerx) + 0x8CU) /*!< TLI layer x vertical position parameters register */
-#define TLI_LxCKEY(layerx) REG32((layerx) + 0x90U) /*!< TLI layer x color key register */
-#define TLI_LxPPF(layerx) REG32((layerx) + 0x94U) /*!< TLI layer x packeted pixel format register */
-#define TLI_LxSA(layerx) REG32((layerx) + 0x98U) /*!< TLI layer x specified alpha register */
-#define TLI_LxDC(layerx) REG32((layerx) + 0x9CU) /*!< TLI layer x default color register */
-#define TLI_LxBLEND(layerx) REG32((layerx) + 0xA0U) /*!< TLI layer x blending register */
-#define TLI_LxFBADDR(layerx) REG32((layerx) + 0xACU) /*!< TLI layer x frame base address register */
-#define TLI_LxFLLEN(layerx) REG32((layerx) + 0xB0U) /*!< TLI layer x frame line length register */
-#define TLI_LxFTLN(layerx) REG32((layerx) + 0xB4U) /*!< TLI layer x frame total line number register */
-#define TLI_LxLUT(layerx) REG32((layerx) + 0xC4U) /*!< TLI layer x look up table register */
+#define TLI_SPSZ REG32(TLI + 0x00000008U) /*!< TLI synchronous pulse size register */
+#define TLI_BPSZ REG32(TLI + 0x0000000CU) /*!< TLI back-porch size register */
+#define TLI_ASZ REG32(TLI + 0x00000010U) /*!< TLI active size register */
+#define TLI_TSZ REG32(TLI + 0x00000014U) /*!< TLI total size register */
+#define TLI_CTL REG32(TLI + 0x00000018U) /*!< TLI control register */
+#define TLI_RL REG32(TLI + 0x00000024U) /*!< TLI reload Layer register */
+#define TLI_BGC REG32(TLI + 0x0000002CU) /*!< TLI background color register */
+#define TLI_INTEN REG32(TLI + 0x00000034U) /*!< TLI interrupt enable register */
+#define TLI_INTF REG32(TLI + 0x00000038U) /*!< TLI interrupt flag register */
+#define TLI_INTC REG32(TLI + 0x0000003CU) /*!< TLI interrupt flag clear register */
+#define TLI_LM REG32(TLI + 0x00000040U) /*!< TLI line mark register */
+#define TLI_CPPOS REG32(TLI + 0x00000044U) /*!< TLI current pixel position register */
+#define TLI_STAT REG32(TLI + 0x00000048U) /*!< TLI status register */
+#define TLI_LxCTL(layerx) REG32((layerx) + 0x00000084U) /*!< TLI layer x control register */
+#define TLI_LxHPOS(layerx) REG32((layerx) + 0x00000088U) /*!< TLI layer x horizontal position parameters register */
+#define TLI_LxVPOS(layerx) REG32((layerx) + 0x0000008CU) /*!< TLI layer x vertical position parameters register */
+#define TLI_LxCKEY(layerx) REG32((layerx) + 0x00000090U) /*!< TLI layer x color key register */
+#define TLI_LxPPF(layerx) REG32((layerx) + 0x00000094U) /*!< TLI layer x packeted pixel format register */
+#define TLI_LxSA(layerx) REG32((layerx) + 0x00000098U) /*!< TLI layer x specified alpha register */
+#define TLI_LxDC(layerx) REG32((layerx) + 0x0000009CU) /*!< TLI layer x default color register */
+#define TLI_LxBLEND(layerx) REG32((layerx) + 0x000000A0U) /*!< TLI layer x blending register */
+#define TLI_LxFBADDR(layerx) REG32((layerx) + 0x000000ACU) /*!< TLI layer x frame base address register */
+#define TLI_LxFLLEN(layerx) REG32((layerx) + 0x000000B0U) /*!< TLI layer x frame line length register */
+#define TLI_LxFTLN(layerx) REG32((layerx) + 0x000000B4U) /*!< TLI layer x frame total line number register */
+#define TLI_LxLUT(layerx) REG32((layerx) + 0x000000C4U) /*!< TLI layer x look up table register */
/* bits definitions */
/* TLI_SPSZ */
@@ -192,8 +193,7 @@ OF SUCH DAMAGE.
/* constants definitions */
/* TLI parameter struct definitions */
-typedef struct
-{
+typedef struct {
uint16_t synpsz_vpsz; /*!< size of the vertical synchronous pulse */
uint16_t synpsz_hpsz; /*!< size of the horizontal synchronous pulse */
uint16_t backpsz_vbpsz; /*!< size of the vertical back porch plus synchronous pulse */
@@ -209,11 +209,10 @@ typedef struct
uint32_t signalpolarity_vs; /*!< vertical pulse polarity selection */
uint32_t signalpolarity_de; /*!< data enable polarity selection */
uint32_t signalpolarity_pixelck; /*!< pixel clock polarity selection */
-}tli_parameter_struct;
+} tli_parameter_struct;
/* TLI layer parameter struct definitions */
-typedef struct
-{
+typedef struct {
uint16_t layer_window_rightpos; /*!< window right position */
uint16_t layer_window_leftpos; /*!< window left position */
uint16_t layer_window_bottompos; /*!< window bottom position */
@@ -230,29 +229,27 @@ typedef struct
uint16_t layer_frame_buf_stride_offset; /*!< frame buffer stride offset */
uint16_t layer_frame_line_length; /*!< frame line length */
uint16_t layer_frame_total_line_number; /*!< frame total line number */
-}tli_layer_parameter_struct;
+} tli_layer_parameter_struct;
/* TLI layer LUT parameter struct definitions */
-typedef struct
-{
+typedef struct {
uint32_t layer_table_addr; /*!< look up table write address */
uint8_t layer_lut_channel_red; /*!< red channel of a LUT entry */
uint8_t layer_lut_channel_green; /*!< green channel of a LUT entry */
uint8_t layer_lut_channel_blue; /*!< blue channel of a LUT entry */
-}tli_layer_lut_parameter_struct;
+} tli_layer_lut_parameter_struct;
/* packeted pixel format */
-typedef enum
-{
- LAYER_PPF_ARGB8888, /*!< layerx pixel format ARGB8888 */
- LAYER_PPF_RGB888, /*!< layerx pixel format RGB888 */
- LAYER_PPF_RGB565, /*!< layerx pixel format RGB565 */
- LAYER_PPF_ARGB1555, /*!< layerx pixel format ARGB1555 */
- LAYER_PPF_ARGB4444, /*!< layerx pixel format ARGB4444 */
- LAYER_PPF_L8, /*!< layerx pixel format L8 */
- LAYER_PPF_AL44, /*!< layerx pixel format AL44 */
- LAYER_PPF_AL88 /*!< layerx pixel format AL88 */
-}tli_layer_ppf_enum;
+typedef enum {
+ LAYER_PPF_ARGB8888, /*!< layerx pixel format ARGB8888 */
+ LAYER_PPF_RGB888, /*!< layerx pixel format RGB888 */
+ LAYER_PPF_RGB565, /*!< layerx pixel format RGB565 */
+ LAYER_PPF_ARGB1555, /*!< layerx pixel format ARGB1555 */
+ LAYER_PPF_ARGB4444, /*!< layerx pixel format ARGB4444 */
+ LAYER_PPF_L8, /*!< layerx pixel format L8 */
+ LAYER_PPF_AL44, /*!< layerx pixel format AL44 */
+ LAYER_PPF_AL88 /*!< layerx pixel format AL88 */
+} tli_layer_ppf_enum;
/* TLI flags */
#define TLI_FLAG_VDE TLI_STAT_VDE /*!< current VDE status */
@@ -333,16 +330,16 @@ void tli_reload_config(uint8_t reload_mod);
that call this function after a tli_layer_parameter_struct structure is defined */
void tli_layer_struct_para_init(tli_layer_parameter_struct *layer_struct);
/* initialize TLI layer */
-void tli_layer_init(uint32_t layerx,tli_layer_parameter_struct *layer_struct);
+void tli_layer_init(uint32_t layerx, tli_layer_parameter_struct *layer_struct);
/* reconfigure window position */
-void tli_layer_window_offset_modify(uint32_t layerx,uint16_t offset_x,uint16_t offset_y);
+void tli_layer_window_offset_modify(uint32_t layerx, uint16_t offset_x, uint16_t offset_y);
/* initialize the parameters of TLI layer LUT structure with the default values, it is suggested
that call this function after a tli_layer_lut_parameter_struct structure is defined */
void tli_lut_struct_para_init(tli_layer_lut_parameter_struct *lut_struct);
/* initialize TLI layer LUT */
-void tli_lut_init(uint32_t layerx,tli_layer_lut_parameter_struct *lut_struct);
+void tli_lut_init(uint32_t layerx, tli_layer_lut_parameter_struct *lut_struct);
/* initialize TLI layer color key */
-void tli_color_key_init(uint32_t layerx,uint8_t redkey,uint8_t greenkey,uint8_t bluekey);
+void tli_color_key_init(uint32_t layerx, uint8_t redkey, uint8_t greenkey, uint8_t bluekey);
/* enable TLI layer */
void tli_layer_enable(uint32_t layerx);
/* disable TLI layer */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_trng.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_trng.h
index f321b15d28..dc6cd3af42 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_trng.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_trng.h
@@ -5,32 +5,33 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -43,14 +44,14 @@ OF SUCH DAMAGE.
#define TRNG TRNG_BASE
/* registers definitions */
-#define TRNG_CTL REG32(TRNG + 0x00U) /*!< control register */
-#define TRNG_STAT REG32(TRNG + 0x04U) /*!< status register */
-#define TRNG_DATA REG32(TRNG + 0x08U) /*!< data register */
+#define TRNG_CTL REG32(TRNG + 0x00000000U) /*!< control register */
+#define TRNG_STAT REG32(TRNG + 0x00000004U) /*!< status register */
+#define TRNG_DATA REG32(TRNG + 0x00000008U) /*!< data register */
/* bits definitions */
/* TRNG_CTL */
#define TRNG_CTL_TRNGEN BIT(2) /*!< TRNG enable bit */
-#define TRNG_CTL_IE BIT(3) /*!< interrupt enable bit */
+#define TRNG_CTL_TRNGIE BIT(3) /*!< interrupt enable bit */
/* TRNG_STAT */
#define TRNG_STAT_DRDY BIT(0) /*!< random data ready status bit */
@@ -60,45 +61,43 @@ OF SUCH DAMAGE.
#define TRNG_STAT_SEIF BIT(6) /*!< seed error interrupt flag */
/* TRNG_DATA */
-#define TRNG_DATA_TRNDATA BITS(0,31) /*!< 32-Bit Random data */
+#define TRNG_DATA_TRNGDATA BITS(0,31) /*!< 32-Bit Random data */
/* constants definitions */
-/* trng status flag */
-typedef enum
-{
+/* TRNG status flag */
+typedef enum {
TRNG_FLAG_DRDY = TRNG_STAT_DRDY, /*!< random Data ready status */
TRNG_FLAG_CECS = TRNG_STAT_CECS, /*!< clock error current status */
TRNG_FLAG_SECS = TRNG_STAT_SECS /*!< seed error current status */
-}trng_flag_enum;
+} trng_flag_enum;
-/* trng inerrupt flag */
-typedef enum
-{
+/* TRNG inerrupt flag */
+typedef enum {
TRNG_INT_FLAG_CEIF = TRNG_STAT_CEIF, /*!< clock error interrupt flag */
TRNG_INT_FLAG_SEIF = TRNG_STAT_SEIF /*!< seed error interrupt flag */
-}trng_int_flag_enum;
+} trng_int_flag_enum;
/* function declarations */
/* initialization functions */
-/* deinitialize the TRNG */
+/* reset TRNG */
void trng_deinit(void);
-/* enable the TRNG interface */
+/* enable TRNG */
void trng_enable(void);
-/* disable the TRNG interface */
+/* disable TRNG */
void trng_disable(void);
/* get the true random data */
uint32_t trng_get_true_random_data(void);
-/* flag & interrupt functions */
-/* trng interrupt enable */
+/* interrupt & flag functions */
+/* enable TRNG interrupt */
void trng_interrupt_enable(void);
-/* trng interrupt disable */
+/* disable TRNG interrupt */
void trng_interrupt_disable(void);
-/* get the trng status flags */
+/* get TRNG flag status */
FlagStatus trng_flag_get(trng_flag_enum flag);
-/* get the trng interrupt flags */
+/* get TRNG interrupt flag status */
FlagStatus trng_interrupt_flag_get(trng_int_flag_enum int_flag);
-/* clear the trng interrupt flags */
+/* clear TRNG interrupt flag status */
void trng_interrupt_flag_clear(trng_int_flag_enum int_flag);
#endif /* GD32F4XX_TRNG_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_usart.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_usart.h
index 3cd49d827f..6f55eeee35 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_usart.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_usart.h
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -64,94 +65,94 @@ OF SUCH DAMAGE.
/* bits definitions */
/* USARTx_STAT0 */
-#define USART_STAT0_PERR BIT(0) /*!< parity error flag */
-#define USART_STAT0_FERR BIT(1) /*!< frame error flag */
-#define USART_STAT0_NERR BIT(2) /*!< noise error flag */
-#define USART_STAT0_ORERR BIT(3) /*!< overrun error */
-#define USART_STAT0_IDLEF BIT(4) /*!< IDLE frame detected flag */
-#define USART_STAT0_RBNE BIT(5) /*!< read data buffer not empty */
-#define USART_STAT0_TC BIT(6) /*!< transmission complete */
-#define USART_STAT0_TBE BIT(7) /*!< transmit data buffer empty */
-#define USART_STAT0_LBDF BIT(8) /*!< LIN break detected flag */
-#define USART_STAT0_CTSF BIT(9) /*!< CTS change flag */
+#define USART_STAT0_PERR BIT(0) /*!< parity error flag */
+#define USART_STAT0_FERR BIT(1) /*!< frame error flag */
+#define USART_STAT0_NERR BIT(2) /*!< noise error flag */
+#define USART_STAT0_ORERR BIT(3) /*!< overrun error */
+#define USART_STAT0_IDLEF BIT(4) /*!< IDLE frame detected flag */
+#define USART_STAT0_RBNE BIT(5) /*!< read data buffer not empty */
+#define USART_STAT0_TC BIT(6) /*!< transmission complete */
+#define USART_STAT0_TBE BIT(7) /*!< transmit data buffer empty */
+#define USART_STAT0_LBDF BIT(8) /*!< LIN break detected flag */
+#define USART_STAT0_CTSF BIT(9) /*!< CTS change flag */
/* USARTx_DATA */
-#define USART_DATA_DATA BITS(0,8) /*!< transmit or read data value */
+#define USART_DATA_DATA BITS(0,8) /*!< transmit or read data value */
/* USARTx_BAUD */
-#define USART_BAUD_FRADIV BITS(0,3) /*!< fraction part of baud-rate divider */
-#define USART_BAUD_INTDIV BITS(4,15) /*!< integer part of baud-rate divider */
+#define USART_BAUD_FRADIV BITS(0,3) /*!< fraction part of baud-rate divider */
+#define USART_BAUD_INTDIV BITS(4,15) /*!< integer part of baud-rate divider */
/* USARTx_CTL0 */
-#define USART_CTL0_SBKCMD BIT(0) /*!< send break command */
-#define USART_CTL0_RWU BIT(1) /*!< receiver wakeup from mute mode */
-#define USART_CTL0_REN BIT(2) /*!< receiver enable */
-#define USART_CTL0_TEN BIT(3) /*!< transmitter enable */
-#define USART_CTL0_IDLEIE BIT(4) /*!< idle line detected interrupt enable */
-#define USART_CTL0_RBNEIE BIT(5) /*!< read data buffer not empty interrupt and overrun error interrupt enable */
-#define USART_CTL0_TCIE BIT(6) /*!< transmission complete interrupt enable */
-#define USART_CTL0_TBEIE BIT(7) /*!< transmitter buffer empty interrupt enable */
-#define USART_CTL0_PERRIE BIT(8) /*!< parity error interrupt enable */
-#define USART_CTL0_PM BIT(9) /*!< parity mode */
-#define USART_CTL0_PCEN BIT(10) /*!< parity check function enable */
-#define USART_CTL0_WM BIT(11) /*!< wakeup method in mute mode */
-#define USART_CTL0_WL BIT(12) /*!< word length */
-#define USART_CTL0_UEN BIT(13) /*!< USART enable */
-#define USART_CTL0_OVSMOD BIT(15) /*!< oversample mode */
+#define USART_CTL0_SBKCMD BIT(0) /*!< send break command */
+#define USART_CTL0_RWU BIT(1) /*!< receiver wakeup from mute mode */
+#define USART_CTL0_REN BIT(2) /*!< enable receiver */
+#define USART_CTL0_TEN BIT(3) /*!< enable transmitter */
+#define USART_CTL0_IDLEIE BIT(4) /*!< enable idle line detected interrupt */
+#define USART_CTL0_RBNEIE BIT(5) /*!< enable read data buffer not empty interrupt and overrun error interrupt */
+#define USART_CTL0_TCIE BIT(6) /*!< enable transmission complete interrupt */
+#define USART_CTL0_TBEIE BIT(7) /*!< enable transmitter buffer empty interrupt */
+#define USART_CTL0_PERRIE BIT(8) /*!< enable parity error interrupt */
+#define USART_CTL0_PM BIT(9) /*!< parity mode */
+#define USART_CTL0_PCEN BIT(10) /*!< enable parity check function */
+#define USART_CTL0_WM BIT(11) /*!< wakeup method in mute mode */
+#define USART_CTL0_WL BIT(12) /*!< word length */
+#define USART_CTL0_UEN BIT(13) /*!< enable USART */
+#define USART_CTL0_OVSMOD BIT(15) /*!< oversample mode */
/* USARTx_CTL1 */
-#define USART_CTL1_ADDR BITS(0,3) /*!< address of USART */
-#define USART_CTL1_LBLEN BIT(5) /*!< LIN break frame length */
-#define USART_CTL1_LBDIE BIT(6) /*!< LIN break detected interrupt eanble */
-#define USART_CTL1_CLEN BIT(8) /*!< CK length */
-#define USART_CTL1_CPH BIT(9) /*!< CK phase */
-#define USART_CTL1_CPL BIT(10) /*!< CK polarity */
-#define USART_CTL1_CKEN BIT(11) /*!< CK pin enable */
-#define USART_CTL1_STB BITS(12,13) /*!< STOP bits length */
-#define USART_CTL1_LMEN BIT(14) /*!< LIN mode enable */
+#define USART_CTL1_ADDR BITS(0,3) /*!< address of USART */
+#define USART_CTL1_LBLEN BIT(5) /*!< LIN break frame length */
+#define USART_CTL1_LBDIE BIT(6) /*!< enable LIN break detected interrupt */
+#define USART_CTL1_CLEN BIT(8) /*!< CK length */
+#define USART_CTL1_CPH BIT(9) /*!< CK phase */
+#define USART_CTL1_CPL BIT(10) /*!< CK polarity */
+#define USART_CTL1_CKEN BIT(11) /*!< enable CK pin */
+#define USART_CTL1_STB BITS(12,13) /*!< STOP bits length */
+#define USART_CTL1_LMEN BIT(14) /*!< enable LIN mode */
/* USARTx_CTL2 */
-#define USART_CTL2_ERRIE BIT(0) /*!< error interrupt enable */
-#define USART_CTL2_IREN BIT(1) /*!< IrDA mode enable */
-#define USART_CTL2_IRLP BIT(2) /*!< IrDA low-power */
-#define USART_CTL2_HDEN BIT(3) /*!< half-duplex enable */
-#define USART_CTL2_NKEN BIT(4) /*!< NACK enable in smartcard mode */
-#define USART_CTL2_SCEN BIT(5) /*!< smartcard mode enable */
-#define USART_CTL2_DENR BIT(6) /*!< DMA request enable for reception */
-#define USART_CTL2_DENT BIT(7) /*!< DMA request enable for transmission */
-#define USART_CTL2_RTSEN BIT(8) /*!< RTS enable */
-#define USART_CTL2_CTSEN BIT(9) /*!< CTS enable */
-#define USART_CTL2_CTSIE BIT(10) /*!< CTS interrupt enable */
-#define USART_CTL2_OSB BIT(11) /*!< one sample bit method */
+#define USART_CTL2_ERRIE BIT(0) /*!< enable error interrupt */
+#define USART_CTL2_IREN BIT(1) /*!< enable IrDA mode */
+#define USART_CTL2_IRLP BIT(2) /*!< IrDA low-power */
+#define USART_CTL2_HDEN BIT(3) /*!< enable half-duplex */
+#define USART_CTL2_NKEN BIT(4) /*!< NACK enable in smartcard mode */
+#define USART_CTL2_SCEN BIT(5) /*!< enable smartcard mode */
+#define USART_CTL2_DENR BIT(6) /*!< enable DMA request for reception */
+#define USART_CTL2_DENT BIT(7) /*!< enable DMA request for transmission */
+#define USART_CTL2_RTSEN BIT(8) /*!< enable RTS */
+#define USART_CTL2_CTSEN BIT(9) /*!< enable CTS */
+#define USART_CTL2_CTSIE BIT(10) /*!< enable CTS interrupt */
+#define USART_CTL2_OSB BIT(11) /*!< one sample bit method */
/* USARTx_GP */
-#define USART_GP_PSC BITS(0,7) /*!< prescaler value for dividing the system clock */
-#define USART_GP_GUAT BITS(8,15) /*!< guard time value in smartcard mode */
+#define USART_GP_PSC BITS(0,7) /*!< prescaler value for dividing the system clock */
+#define USART_GP_GUAT BITS(8,15) /*!< guard time value in smartcard mode */
/* USARTx_CTL3 */
-#define USART_CTL3_RTEN BIT(0) /*!< receiver timeout enable */
-#define USART_CTL3_SCRTNUM BITS(1,3) /*!< smartcard auto-retry number */
-#define USART_CTL3_RTIE BIT(4) /*!< interrupt enable bit of receive timeout event */
-#define USART_CTL3_EBIE BIT(5) /*!< interrupt enable bit of end of block event */
-#define USART_CTL3_RINV BIT(8) /*!< RX pin level inversion */
-#define USART_CTL3_TINV BIT(9) /*!< TX pin level inversion */
-#define USART_CTL3_DINV BIT(10) /*!< data bit level inversion */
-#define USART_CTL3_MSBF BIT(11) /*!< most significant bit first */
+#define USART_CTL3_RTEN BIT(0) /*!< enable receiver timeout */
+#define USART_CTL3_SCRTNUM BITS(1,3) /*!< smartcard auto-retry number */
+#define USART_CTL3_RTIE BIT(4) /*!< interrupt enable bit of receive timeout event */
+#define USART_CTL3_EBIE BIT(5) /*!< interrupt enable bit of end of block event */
+#define USART_CTL3_RINV BIT(8) /*!< RX pin level inversion */
+#define USART_CTL3_TINV BIT(9) /*!< TX pin level inversion */
+#define USART_CTL3_DINV BIT(10) /*!< data bit level inversion */
+#define USART_CTL3_MSBF BIT(11) /*!< most significant bit first */
/* USARTx_RT */
-#define USART_RT_RT BITS(0,23) /*!< receiver timeout threshold */
-#define USART_RT_BL BITS(24,31) /*!< block length */
+#define USART_RT_RT BITS(0,23) /*!< receiver timeout threshold */
+#define USART_RT_BL BITS(24,31) /*!< block length */
/* USARTx_STAT1 */
-#define USART_STAT1_RTF BIT(11) /*!< receiver timeout flag */
-#define USART_STAT1_EBF BIT(12) /*!< end of block flag */
-#define USART_STAT1_BSY BIT(16) /*!< busy flag */
+#define USART_STAT1_RTF BIT(11) /*!< receiver timeout flag */
+#define USART_STAT1_EBF BIT(12) /*!< end of block flag */
+#define USART_STAT1_BSY BIT(16) /*!< busy flag */
/* USARTx_CHC */
-#define USART_CHC_HCM BIT(0) /*!< hardware flow control coherence mode */
-#define USART_CHC_PCM BIT(1) /*!< parity check coherence mode */
-#define USART_CHC_BCM BIT(2) /*!< break frame coherence mode */
-#define USART_CHC_EPERR BIT(8) /*!< early parity error flag */
+#define USART_CHC_HCM BIT(0) /*!< hardware flow control coherence mode */
+#define USART_CHC_PCM BIT(1) /*!< parity check coherence mode */
+#define USART_CHC_BCM BIT(2) /*!< break frame coherence mode */
+#define USART_CHC_EPERR BIT(8) /*!< early parity error flag */
/* constants definitions */
/* define the USART bit position and its register index offset */
@@ -164,17 +165,16 @@ OF SUCH DAMAGE.
#define USART_BIT_POS2(val) (((uint32_t)(val) & 0x1F0000U) >> 16)
/* register offset */
-#define USART_STAT0_REG_OFFSET 0x00U /*!< STAT0 register offset */
-#define USART_STAT1_REG_OFFSET 0x88U /*!< STAT1 register offset */
-#define USART_CTL0_REG_OFFSET 0x0CU /*!< CTL0 register offset */
-#define USART_CTL1_REG_OFFSET 0x10U /*!< CTL1 register offset */
-#define USART_CTL2_REG_OFFSET 0x14U /*!< CTL2 register offset */
-#define USART_CTL3_REG_OFFSET 0x80U /*!< CTL3 register offset */
-#define USART_CHC_REG_OFFSET 0xC0U /*!< CHC register offset */
+#define USART_STAT0_REG_OFFSET 0x00U /*!< STAT0 register offset */
+#define USART_STAT1_REG_OFFSET 0x88U /*!< STAT1 register offset */
+#define USART_CTL0_REG_OFFSET 0x0CU /*!< CTL0 register offset */
+#define USART_CTL1_REG_OFFSET 0x10U /*!< CTL1 register offset */
+#define USART_CTL2_REG_OFFSET 0x14U /*!< CTL2 register offset */
+#define USART_CTL3_REG_OFFSET 0x80U /*!< CTL3 register offset */
+#define USART_CHC_REG_OFFSET 0xC0U /*!< CHC register offset */
/* USART flags */
-typedef enum
-{
+typedef enum {
/* flags in STAT0 register */
USART_FLAG_CTS = USART_REGIDX_BIT(USART_STAT0_REG_OFFSET, 9U), /*!< CTS change flag */
USART_FLAG_LBD = USART_REGIDX_BIT(USART_STAT0_REG_OFFSET, 8U), /*!< LIN break detected flag */
@@ -192,11 +192,10 @@ typedef enum
USART_FLAG_RT = USART_REGIDX_BIT(USART_STAT1_REG_OFFSET, 11U), /*!< receiver timeout flag */
/* flags in CHC register */
USART_FLAG_EPERR = USART_REGIDX_BIT(USART_CHC_REG_OFFSET, 8U), /*!< early parity error flag */
-}usart_flag_enum;
+} usart_flag_enum;
/* USART interrupt flags */
-typedef enum
-{
+typedef enum {
/* interrupt flags in CTL0 register */
USART_INT_FLAG_PERR = USART_REGIDX_BIT2(USART_CTL0_REG_OFFSET, 8U, USART_STAT0_REG_OFFSET, 0U), /*!< parity error interrupt and flag */
USART_INT_FLAG_TBE = USART_REGIDX_BIT2(USART_CTL0_REG_OFFSET, 7U, USART_STAT0_REG_OFFSET, 7U), /*!< transmitter buffer empty interrupt and flag */
@@ -214,11 +213,10 @@ typedef enum
/* interrupt flags in CTL3 register */
USART_INT_FLAG_EB = USART_REGIDX_BIT2(USART_CTL3_REG_OFFSET, 5U, USART_STAT1_REG_OFFSET, 12U), /*!< interrupt enable bit of end of block event and flag */
USART_INT_FLAG_RT = USART_REGIDX_BIT2(USART_CTL3_REG_OFFSET, 4U, USART_STAT1_REG_OFFSET, 11U), /*!< interrupt enable bit of receive timeout event and flag */
-}usart_interrupt_flag_enum;
+} usart_interrupt_flag_enum;
/* USART interrupt flags */
-typedef enum
-{
+typedef enum {
/* interrupt in CTL0 register */
USART_INT_PERR = USART_REGIDX_BIT(USART_CTL0_REG_OFFSET, 8U), /*!< parity error interrupt */
USART_INT_TBE = USART_REGIDX_BIT(USART_CTL0_REG_OFFSET, 7U), /*!< transmitter buffer empty interrupt */
@@ -233,11 +231,10 @@ typedef enum
/* interrupt in CTL3 register */
USART_INT_EB = USART_REGIDX_BIT(USART_CTL3_REG_OFFSET, 5U), /*!< interrupt enable bit of end of block event */
USART_INT_RT = USART_REGIDX_BIT(USART_CTL3_REG_OFFSET, 4U), /*!< interrupt enable bit of receive timeout event */
-}usart_interrupt_enum;
+} usart_interrupt_enum;
-/* USART invert configure */
-typedef enum
-{
+/* configure USART invert */
+typedef enum {
/* data bit level inversion */
USART_DINV_ENABLE, /*!< data bit level inversion */
USART_DINV_DISABLE, /*!< data bit level not inversion */
@@ -247,14 +244,14 @@ typedef enum
/* RX pin level inversion */
USART_RXPIN_ENABLE, /*!< RX pin level inversion */
USART_RXPIN_DISABLE, /*!< RX pin level not inversion */
-}usart_invert_enum;
+} usart_invert_enum;
-/* USART receiver configure */
+/* configure USART receiver */
#define CTL0_REN(regval) (BIT(2) & ((uint32_t)(regval) << 2))
#define USART_RECEIVE_ENABLE CTL0_REN(1) /*!< enable receiver */
#define USART_RECEIVE_DISABLE CTL0_REN(0) /*!< disable receiver */
-/* USART transmitter configure */
+/* configure USART transmitter */
#define CTL0_TEN(regval) (BIT(3) & ((uint32_t)(regval) << 3))
#define USART_TRANSMIT_ENABLE CTL0_TEN(1) /*!< enable transmitter */
#define USART_TRANSMIT_DISABLE CTL0_TEN(0) /*!< disable transmitter */
@@ -307,32 +304,32 @@ typedef enum
#define USART_CPL_LOW CTL1_CPL(0) /*!< steady low value on CK pin */
#define USART_CPL_HIGH CTL1_CPL(1) /*!< steady high value on CK pin */
-/* USART DMA request for receive configure */
+/* configure USART DMA request for receive */
#define CLT2_DENR(regval) (BIT(6) & ((uint32_t)(regval) << 6))
-#define USART_DENR_ENABLE CLT2_DENR(1) /*!< DMA request enable for reception */
-#define USART_DENR_DISABLE CLT2_DENR(0) /*!< DMA request disable for reception */
+#define USART_RECEIVE_DMA_ENABLE CLT2_DENR(1) /*!< DMA request enable for reception */
+#define USART_RECEIVE_DMA_DISABLE CLT2_DENR(0) /*!< DMA request disable for reception */
-/* USART DMA request for transmission configure */
+/* configure USART DMA request for transmission */
#define CLT2_DENT(regval) (BIT(7) & ((uint32_t)(regval) << 7))
-#define USART_DENT_ENABLE CLT2_DENT(1) /*!< DMA request enable for transmission */
-#define USART_DENT_DISABLE CLT2_DENT(0) /*!< DMA request disable for transmission */
+#define USART_TRANSMIT_DMA_ENABLE CLT2_DENT(1) /*!< DMA request enable for transmission */
+#define USART_TRANSMIT_DMA_DISABLE CLT2_DENT(0) /*!< DMA request disable for transmission */
-/* USART RTS configure */
+/* configure USART RTS */
#define CLT2_RTSEN(regval) (BIT(8) & ((uint32_t)(regval) << 8))
-#define USART_RTS_ENABLE CLT2_RTSEN(1) /*!< RTS enable */
-#define USART_RTS_DISABLE CLT2_RTSEN(0) /*!< RTS disable */
+#define USART_RTS_ENABLE CLT2_RTSEN(1) /*!< enable RTS */
+#define USART_RTS_DISABLE CLT2_RTSEN(0) /*!< disable RTS */
-/* USART CTS configure */
+/* configure USART CTS */
#define CLT2_CTSEN(regval) (BIT(9) & ((uint32_t)(regval) << 9))
-#define USART_CTS_ENABLE CLT2_CTSEN(1) /*!< CTS enable */
-#define USART_CTS_DISABLE CLT2_CTSEN(0) /*!< CTS disable */
+#define USART_CTS_ENABLE CLT2_CTSEN(1) /*!< enable CTS */
+#define USART_CTS_DISABLE CLT2_CTSEN(0) /*!< disable CTS */
-/* USART one sample bit method configure */
+/* configure USART one sample bit method */
#define CTL2_OSB(regval) (BIT(11) & ((uint32_t)(regval) << 11))
#define USART_OSB_1bit CTL2_OSB(1) /*!< 1 bit */
#define USART_OSB_3bit CTL2_OSB(0) /*!< 3 bits */
-/* USART IrDA low-power enable */
+/* enable USART IrDA low-power */
#define CTL2_IRLP(regval) (BIT(2) & ((uint32_t)(regval) << 2))
#define USART_IRLP_LOW CTL2_IRLP(1) /*!< low-power */
#define USART_IRLP_NORMAL CTL2_IRLP(0) /*!< normal */
@@ -394,7 +391,7 @@ void usart_receiver_timeout_disable(uint32_t usart_periph);
/* configure receiver timeout threshold */
void usart_receiver_timeout_threshold_config(uint32_t usart_periph, uint32_t rtimeout);
/* USART transmit data function */
-void usart_data_transmit(uint32_t usart_periph, uint32_t data);
+void usart_data_transmit(uint32_t usart_periph, uint16_t data);
/* USART receive data function */
uint16_t usart_data_receive(uint32_t usart_periph);
@@ -434,7 +431,7 @@ void usart_synchronous_clock_config(uint32_t usart_periph, uint32_t clen, uint32
/* smartcard communication */
/* configure guard time value in smartcard mode */
-void usart_guard_time_config(uint32_t usart_periph, uint32_t guat);
+void usart_guard_time_config(uint32_t usart_periph, uint8_t guat);
/* enable smartcard mode */
void usart_smartcard_mode_enable(uint32_t usart_periph);
/* disable smartcard mode */
@@ -444,9 +441,9 @@ void usart_smartcard_mode_nack_enable(uint32_t usart_periph);
/* disable NACK in smartcard mode */
void usart_smartcard_mode_nack_disable(uint32_t usart_periph);
/* configure smartcard auto-retry number */
-void usart_smartcard_autoretry_config(uint32_t usart_periph, uint32_t scrtnum);
+void usart_smartcard_autoretry_config(uint32_t usart_periph, uint8_t scrtnum);
/* configure block length */
-void usart_block_length_config(uint32_t usart_periph, uint32_t bl);
+void usart_block_length_config(uint32_t usart_periph, uint8_t bl);
/* IrDA communication */
/* enable IrDA mode */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_wwdgt.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_wwdgt.h
index 525b9a6e5a..69cdbff306 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_wwdgt.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Include/gd32f4xx_wwdgt.h
@@ -1,36 +1,37 @@
/*!
\file gd32f4xx_wwdgt.h
- \brief definitions for the WWDGT
+ \brief definitions for the WWDGT
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -40,7 +41,7 @@ OF SUCH DAMAGE.
#include "gd32f4xx.h"
/* WWDGT definitions */
-#define WWDGT WWDGT_BASE
+#define WWDGT WWDGT_BASE /*!< WWDGT base address */
/* registers definitions */
#define WWDGT_CTL REG32((WWDGT) + 0x00U) /*!< WWDGT control register */
@@ -67,6 +68,11 @@ OF SUCH DAMAGE.
#define WWDGT_CFG_PSC_DIV4 CFG_PSC(2) /*!< the time base of WWDGT = (PCLK1/4096)/4 */
#define WWDGT_CFG_PSC_DIV8 CFG_PSC(3) /*!< the time base of WWDGT = (PCLK1/4096)/8 */
+/* write value to WWDGT_CTL_CNT bit field */
+#define CTL_CNT(regval) (BITS(0,6) & ((uint32_t)(regval) << 0))
+/* write value to WWDGT_CFG_WIN bit field */
+#define CFG_WIN(regval) (BITS(0,6) & ((uint32_t)(regval) << 0))
+
/* function declarations */
/* reset the window watchdog timer configuration */
void wwdgt_deinit(void);
@@ -78,11 +84,11 @@ void wwdgt_counter_update(uint16_t counter_value);
/* configure counter value, window value, and prescaler divider value */
void wwdgt_config(uint16_t counter, uint16_t window, uint32_t prescaler);
-/* enable early wakeup interrupt of WWDGT */
-void wwdgt_interrupt_enable(void);
/* check early wakeup interrupt state of WWDGT */
FlagStatus wwdgt_flag_get(void);
/* clear early wakeup interrupt state of WWDGT */
void wwdgt_flag_clear(void);
+/* enable early wakeup interrupt of WWDGT */
+void wwdgt_interrupt_enable(void);
#endif /* GD32F4XX_WWDGT_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_adc.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_adc.c
index f249e6c840..3ea466fcd6 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_adc.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_adc.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -36,32 +37,32 @@ OF SUCH DAMAGE.
#include "gd32f4xx_adc.h"
-#define REGULAR_TRIGGER_MODE ((uint32_t)28U)
-#define INSERTED_TRIGGER_MODE ((uint32_t)20U)
+#define ROUTINE_TRIGGER_MODE ((uint32_t)28U)
+#define INSERTED_TRIGGER_MODE ((uint32_t)20U)
/* discontinuous mode macro*/
-#define ADC_CHANNEL_LENGTH_SUBTRACT_ONE ((uint8_t)1U)
+#define ADC_CHANNEL_LENGTH_SUBTRACT_ONE ((uint8_t)1U)
-/* ADC regular channel macro */
-#define ADC_REGULAR_CHANNEL_RANK_SIX ((uint8_t)6U)
-#define ADC_REGULAR_CHANNEL_RANK_TWELVE ((uint8_t)12U)
-#define ADC_REGULAR_CHANNEL_RANK_SIXTEEN ((uint8_t)16U)
-#define ADC_REGULAR_CHANNEL_RANK_LENGTH ((uint8_t)5U)
+/* ADC routine channel macro */
+#define ADC_ROUTINE_CHANNEL_RANK_SIX ((uint8_t)6U)
+#define ADC_ROUTINE_CHANNEL_RANK_TWELVE ((uint8_t)12U)
+#define ADC_ROUTINE_CHANNEL_RANK_SIXTEEN ((uint8_t)16U)
+#define ADC_ROUTINE_CHANNEL_RANK_LENGTH ((uint8_t)5U)
/* ADC sampling time macro */
-#define ADC_CHANNEL_SAMPLE_TEN ((uint8_t)10U)
-#define ADC_CHANNEL_SAMPLE_EIGHTEEN ((uint8_t)18U)
-#define ADC_CHANNEL_SAMPLE_LENGTH ((uint8_t)3U)
+#define ADC_CHANNEL_SAMPLE_TEN ((uint8_t)10U)
+#define ADC_CHANNEL_SAMPLE_EIGHTEEN ((uint8_t)18U)
+#define ADC_CHANNEL_SAMPLE_LENGTH ((uint8_t)3U)
/* ADC inserted channel macro */
-#define ADC_INSERTED_CHANNEL_RANK_LENGTH ((uint8_t)5U)
-#define ADC_INSERTED_CHANNEL_SHIFT_LENGTH ((uint8_t)15U)
+#define ADC_INSERTED_CHANNEL_RANK_LENGTH ((uint8_t)5U)
+#define ADC_INSERTED_CHANNEL_SHIFT_LENGTH ((uint8_t)15U)
/* ADC inserted channel offset macro */
-#define ADC_OFFSET_LENGTH ((uint8_t)3U)
-#define ADC_OFFSET_SHIFT_LENGTH ((uint8_t)4U)
+#define ADC_OFFSET_LENGTH ((uint8_t)3U)
+#define ADC_OFFSET_SHIFT_LENGTH ((uint8_t)4U)
/*!
- \brief reset ADC
+ \brief reset ADC
\param[in] none
\param[out] none
\retval none
@@ -73,9 +74,9 @@ void adc_deinit(void)
}
/*!
- \brief configure the ADC clock for all the ADCs
- \param[in] prescaler: configure ADCs prescaler ratio
- only one parameter can be selected which is shown as below:
+ \brief configure the ADC clock for all the ADCs
+ \param[in] prescaler: configure ADCs prescaler ratio
+ only one parameter can be selected which is shown as below:
\arg ADC_ADCCK_PCLK2_DIV2: PCLK2 div2
\arg ADC_ADCCK_PCLK2_DIV4: PCLK2 div4
\arg ADC_ADCCK_PCLK2_DIV6: PCLK2 div6
@@ -84,8 +85,8 @@ void adc_deinit(void)
\arg ADC_ADCCK_HCLK_DIV6: HCLK div6
\arg ADC_ADCCK_HCLK_DIV10: HCLK div10
\arg ADC_ADCCK_HCLK_DIV20: HCLK div20
- \param[out] none
- \retval none
+ \param[out] none
+ \retval none
*/
void adc_clock_config(uint32_t prescaler)
{
@@ -94,42 +95,42 @@ void adc_clock_config(uint32_t prescaler)
}
/*!
- \brief enable or disable ADC special function
- \param[in] adc_periph: ADCx,x=0,1,2
- \param[in] function: the function to config
- only one parameter can be selected which is shown as below:
- \arg ADC_SCAN_MODE: scan mode select
- \arg ADC_INSERTED_CHANNEL_AUTO: inserted channel group convert automatically
- \arg ADC_CONTINUOUS_MODE: continuous mode select
- \param[in] newvalue: ENABLE or DISABLE
- \param[out] none
- \retval none
+ \brief enable or disable ADC special function
+ \param[in] adc_periph: ADCx,x=0,1,2
+ \param[in] function: the function to config
+ only one parameter can be selected which is shown as below:
+ \arg ADC_SCAN_MODE: scan mode select
+ \arg ADC_INSERTED_CHANNEL_AUTO: inserted sequence convert automatically
+ \arg ADC_CONTINUOUS_MODE: continuous mode select
+ \param[in] newvalue: ENABLE or DISABLE
+ \param[out] none
+ \retval none
*/
-void adc_special_function_config(uint32_t adc_periph , uint32_t function , ControlStatus newvalue)
+void adc_special_function_config(uint32_t adc_periph, uint32_t function, ControlStatus newvalue)
{
- if(newvalue){
- if(0U != (function & ADC_SCAN_MODE)){
+ if(newvalue) {
+ if(0U != (function & ADC_SCAN_MODE)) {
/* enable scan mode */
ADC_CTL0(adc_periph) |= ADC_SCAN_MODE;
}
- if(0U != (function & ADC_INSERTED_CHANNEL_AUTO)){
- /* enable inserted channel group convert automatically */
+ if(0U != (function & ADC_INSERTED_CHANNEL_AUTO)) {
+ /* enable inserted sequence convert automatically */
ADC_CTL0(adc_periph) |= ADC_INSERTED_CHANNEL_AUTO;
}
- if(0U != (function & ADC_CONTINUOUS_MODE)){
+ if(0U != (function & ADC_CONTINUOUS_MODE)) {
/* enable continuous mode */
ADC_CTL1(adc_periph) |= ADC_CONTINUOUS_MODE;
}
- }else{
- if(0U != (function & ADC_SCAN_MODE)){
+ } else {
+ if(0U != (function & ADC_SCAN_MODE)) {
/* disable scan mode */
ADC_CTL0(adc_periph) &= ~ADC_SCAN_MODE;
}
- if(0U != (function & ADC_INSERTED_CHANNEL_AUTO)){
- /* disable inserted channel group convert automatically */
+ if(0U != (function & ADC_INSERTED_CHANNEL_AUTO)) {
+ /* disable inserted sequence convert automatically */
ADC_CTL0(adc_periph) &= ~ADC_INSERTED_CHANNEL_AUTO;
}
- if(0U != (function & ADC_CONTINUOUS_MODE)){
+ if(0U != (function & ADC_CONTINUOUS_MODE)) {
/* disable continuous mode */
ADC_CTL1(adc_periph) &= ~ADC_CONTINUOUS_MODE;
}
@@ -137,45 +138,45 @@ void adc_special_function_config(uint32_t adc_periph , uint32_t function , Contr
}
/*!
- \brief configure ADC data alignment
- \param[in] adc_periph: ADCx,x=0,1,2
- \param[in] data_alignment: data alignment select
- only one parameter can be selected which is shown as below:
- \arg ADC_DATAALIGN_RIGHT: LSB alignment
- \arg ADC_DATAALIGN_LEFT: MSB alignment
- \param[out] none
- \retval none
+ \brief configure ADC data alignment
+ \param[in] adc_periph: ADCx,x=0,1,2
+ \param[in] data_alignment: data alignment select
+ only one parameter can be selected which is shown as below:
+ \arg ADC_DATAALIGN_RIGHT: LSB alignment
+ \arg ADC_DATAALIGN_LEFT: MSB alignment
+ \param[out] none
+ \retval none
*/
-void adc_data_alignment_config(uint32_t adc_periph , uint32_t data_alignment)
+void adc_data_alignment_config(uint32_t adc_periph, uint32_t data_alignment)
{
- if(ADC_DATAALIGN_RIGHT != data_alignment){
+ if(ADC_DATAALIGN_RIGHT != data_alignment) {
/* MSB alignment */
ADC_CTL1(adc_periph) |= ADC_CTL1_DAL;
- }else{
+ } else {
/* LSB alignment */
ADC_CTL1(adc_periph) &= ~((uint32_t)ADC_CTL1_DAL);
}
}
/*!
- \brief enable ADC interface
- \param[in] adc_periph: ADCx,x=0,1,2
- \param[out] none
- \retval none
+ \brief enable ADC interface
+ \param[in] adc_periph: ADCx,x=0,1,2
+ \param[out] none
+ \retval none
*/
void adc_enable(uint32_t adc_periph)
{
- if(RESET == (ADC_CTL1(adc_periph) & ADC_CTL1_ADCON)){
+ if(RESET == (ADC_CTL1(adc_periph) & ADC_CTL1_ADCON)) {
/* enable ADC */
ADC_CTL1(adc_periph) |= (uint32_t)ADC_CTL1_ADCON;
}
}
/*!
- \brief disable ADC interface
- \param[in] adc_periph: ADCx,x=0,1,2
- \param[out] none
- \retval none
+ \brief disable ADC interface
+ \param[in] adc_periph: ADCx,x=0,1,2
+ \param[out] none
+ \retval none
*/
void adc_disable(uint32_t adc_periph)
{
@@ -184,52 +185,52 @@ void adc_disable(uint32_t adc_periph)
}
/*!
- \brief ADC calibration and reset calibration
- \param[in] adc_periph: ADCx,x=0,1,2
- \param[out] none
- \retval none
+ \brief ADC calibration and reset calibration
+ \param[in] adc_periph: ADCx,x=0,1,2
+ \param[out] none
+ \retval none
*/
void adc_calibration_enable(uint32_t adc_periph)
{
/* reset the selected ADC calibration registers */
ADC_CTL1(adc_periph) |= (uint32_t) ADC_CTL1_RSTCLB;
/* check the RSTCLB bit state */
- while(RESET != (ADC_CTL1(adc_periph) & ADC_CTL1_RSTCLB)){
+ while(RESET != (ADC_CTL1(adc_periph) & ADC_CTL1_RSTCLB)) {
}
/* enable ADC calibration process */
ADC_CTL1(adc_periph) |= ADC_CTL1_CLB;
/* check the CLB bit state */
- while(RESET != (ADC_CTL1(adc_periph) & ADC_CTL1_CLB)){
+ while(RESET != (ADC_CTL1(adc_periph) & ADC_CTL1_CLB)) {
}
}
/*!
- \brief configure temperature sensor and internal reference voltage channel or VBAT channel function
- \param[in] function: temperature sensor and internal reference voltage channel or VBAT channel
- only one parameter can be selected which is shown as below:
- \arg ADC_VBAT_CHANNEL_SWITCH: channel 18 (1/4 voltate of external battery) switch of ADC0
- \arg ADC_TEMP_VREF_CHANNEL_SWITCH: channel 16 (temperature sensor) and 17 (internal reference voltage) switch of ADC0
- \param[in] newvalue: ENABLE or DISABLE
-\param[out] none
- \retval none
+ \brief configure temperature sensor and internal reference voltage channel or VBAT channel function
+ \param[in] function: temperature sensor and internal reference voltage channel or VBAT channel
+ only one parameter can be selected which is shown as below:
+ \arg ADC_VBAT_CHANNEL_SWITCH: channel 18 (1/4 voltate of external battery) switch of ADC0
+ \arg ADC_TEMP_VREF_CHANNEL_SWITCH: channel 16 (temperature sensor) and 17 (internal reference voltage) switch of ADC0
+ \param[in] newvalue: ENABLE or DISABLE
+ \param[out] none
+ \retval none
*/
void adc_channel_16_to_18(uint32_t function, ControlStatus newvalue)
{
- if(newvalue){
- if(RESET != (function & ADC_VBAT_CHANNEL_SWITCH)){
+ if(newvalue) {
+ if(RESET != (function & ADC_VBAT_CHANNEL_SWITCH)) {
/* enable ADC0 Vbat channel */
ADC_SYNCCTL |= ADC_VBAT_CHANNEL_SWITCH;
}
- if(RESET != (function & ADC_TEMP_VREF_CHANNEL_SWITCH)){
+ if(RESET != (function & ADC_TEMP_VREF_CHANNEL_SWITCH)) {
/* enable ADC0 Vref and Temperature channel */
ADC_SYNCCTL |= ADC_TEMP_VREF_CHANNEL_SWITCH;
}
- }else{
- if(RESET != (function & ADC_VBAT_CHANNEL_SWITCH)){
+ } else {
+ if(RESET != (function & ADC_VBAT_CHANNEL_SWITCH)) {
/* disable ADC0 Vbat channel */
ADC_SYNCCTL &= ~ADC_VBAT_CHANNEL_SWITCH;
}
- if(RESET != (function & ADC_TEMP_VREF_CHANNEL_SWITCH)){
+ if(RESET != (function & ADC_TEMP_VREF_CHANNEL_SWITCH)) {
/* disable ADC0 Vref and Temperature channel */
ADC_SYNCCTL &= ~ADC_TEMP_VREF_CHANNEL_SWITCH;
}
@@ -237,59 +238,59 @@ void adc_channel_16_to_18(uint32_t function, ControlStatus newvalue)
}
/*!
- \brief configure ADC resolution
- \param[in] adc_periph: ADCx,x=0,1,2
- \param[in] resolution: ADC resolution
- only one parameter can be selected which is shown as below:
- \arg ADC_RESOLUTION_12B: 12-bit ADC resolution
- \arg ADC_RESOLUTION_10B: 10-bit ADC resolution
- \arg ADC_RESOLUTION_8B: 8-bit ADC resolution
- \arg ADC_RESOLUTION_6B: 6-bit ADC resolution
- \param[out] none
- \retval none
+ \brief configure ADC resolution
+ \param[in] adc_periph: ADCx,x=0,1,2
+ \param[in] resolution: ADC resolution
+ only one parameter can be selected which is shown as below:
+ \arg ADC_RESOLUTION_12B: 12-bit ADC resolution
+ \arg ADC_RESOLUTION_10B: 10-bit ADC resolution
+ \arg ADC_RESOLUTION_8B: 8-bit ADC resolution
+ \arg ADC_RESOLUTION_6B: 6-bit ADC resolution
+ \param[out] none
+ \retval none
*/
-void adc_resolution_config(uint32_t adc_periph , uint32_t resolution)
+void adc_resolution_config(uint32_t adc_periph, uint32_t resolution)
{
ADC_CTL0(adc_periph) &= ~((uint32_t)ADC_CTL0_DRES);
ADC_CTL0(adc_periph) |= (uint32_t)resolution;
}
/*!
- \brief configure ADC oversample mode
- \param[in] adc_periph: ADCx,x=0,1,2
- \param[in] mode: ADC oversampling mode
- only one parameter can be selected which is shown as below:
- \arg ADC_OVERSAMPLING_ALL_CONVERT: all oversampled conversions for a channel are done consecutively after a trigger
- \arg ADC_OVERSAMPLING_ONE_CONVERT: each oversampled conversion for a channel needs a trigger
- \param[in] shift: ADC oversampling shift
- only one parameter can be selected which is shown as below:
- \arg ADC_OVERSAMPLING_SHIFT_NONE: no oversampling shift
- \arg ADC_OVERSAMPLING_SHIFT_1B: 1-bit oversampling shift
- \arg ADC_OVERSAMPLING_SHIFT_2B: 2-bit oversampling shift
- \arg ADC_OVERSAMPLING_SHIFT_3B: 3-bit oversampling shift
- \arg ADC_OVERSAMPLING_SHIFT_4B: 3-bit oversampling shift
- \arg ADC_OVERSAMPLING_SHIFT_5B: 5-bit oversampling shift
- \arg ADC_OVERSAMPLING_SHIFT_6B: 6-bit oversampling shift
- \arg ADC_OVERSAMPLING_SHIFT_7B: 7-bit oversampling shift
- \arg ADC_OVERSAMPLING_SHIFT_8B: 8-bit oversampling shift
- \param[in] ratio: ADC oversampling ratio
- only one parameter can be selected which is shown as below:
- \arg ADC_OVERSAMPLING_RATIO_MUL2: oversampling ratio multiple 2
- \arg ADC_OVERSAMPLING_RATIO_MUL4: oversampling ratio multiple 4
- \arg ADC_OVERSAMPLING_RATIO_MUL8: oversampling ratio multiple 8
- \arg ADC_OVERSAMPLING_RATIO_MUL16: oversampling ratio multiple 16
- \arg ADC_OVERSAMPLING_RATIO_MUL32: oversampling ratio multiple 32
- \arg ADC_OVERSAMPLING_RATIO_MUL64: oversampling ratio multiple 64
- \arg ADC_OVERSAMPLING_RATIO_MUL128: oversampling ratio multiple 128
- \arg ADC_OVERSAMPLING_RATIO_MUL256: oversampling ratio multiple 256
- \param[out] none
- \retval none
+ \brief configure ADC oversample mode
+ \param[in] adc_periph: ADCx,x=0,1,2
+ \param[in] mode: ADC oversampling mode
+ only one parameter can be selected which is shown as below:
+ \arg ADC_OVERSAMPLING_ALL_CONVERT: all oversampled conversions for a channel are done consecutively after a trigger
+ \arg ADC_OVERSAMPLING_ONE_CONVERT: each oversampled conversion for a channel needs a trigger
+ \param[in] shift: ADC oversampling shift
+ only one parameter can be selected which is shown as below:
+ \arg ADC_OVERSAMPLING_SHIFT_NONE: no oversampling shift
+ \arg ADC_OVERSAMPLING_SHIFT_1B: 1-bit oversampling shift
+ \arg ADC_OVERSAMPLING_SHIFT_2B: 2-bit oversampling shift
+ \arg ADC_OVERSAMPLING_SHIFT_3B: 3-bit oversampling shift
+ \arg ADC_OVERSAMPLING_SHIFT_4B: 3-bit oversampling shift
+ \arg ADC_OVERSAMPLING_SHIFT_5B: 5-bit oversampling shift
+ \arg ADC_OVERSAMPLING_SHIFT_6B: 6-bit oversampling shift
+ \arg ADC_OVERSAMPLING_SHIFT_7B: 7-bit oversampling shift
+ \arg ADC_OVERSAMPLING_SHIFT_8B: 8-bit oversampling shift
+ \param[in] ratio: ADC oversampling ratio
+ only one parameter can be selected which is shown as below:
+ \arg ADC_OVERSAMPLING_RATIO_MUL2: oversampling ratio multiple 2
+ \arg ADC_OVERSAMPLING_RATIO_MUL4: oversampling ratio multiple 4
+ \arg ADC_OVERSAMPLING_RATIO_MUL8: oversampling ratio multiple 8
+ \arg ADC_OVERSAMPLING_RATIO_MUL16: oversampling ratio multiple 16
+ \arg ADC_OVERSAMPLING_RATIO_MUL32: oversampling ratio multiple 32
+ \arg ADC_OVERSAMPLING_RATIO_MUL64: oversampling ratio multiple 64
+ \arg ADC_OVERSAMPLING_RATIO_MUL128: oversampling ratio multiple 128
+ \arg ADC_OVERSAMPLING_RATIO_MUL256: oversampling ratio multiple 256
+ \param[out] none
+ \retval none
*/
-void adc_oversample_mode_config(uint32_t adc_periph , uint32_t mode , uint16_t shift , uint8_t ratio)
+void adc_oversample_mode_config(uint32_t adc_periph, uint32_t mode, uint16_t shift, uint8_t ratio)
{
- if(ADC_OVERSAMPLING_ONE_CONVERT == mode){
+ if(ADC_OVERSAMPLING_ONE_CONVERT == mode) {
ADC_OVSAMPCTL(adc_periph) |= (uint32_t)ADC_OVSAMPCTL_TOVS;
- }else{
+ } else {
ADC_OVSAMPCTL(adc_periph) &= ~((uint32_t)ADC_OVSAMPCTL_TOVS);
}
/* config the shift and ratio */
@@ -298,10 +299,10 @@ void adc_oversample_mode_config(uint32_t adc_periph , uint32_t mode , uint16_t s
}
/*!
- \brief enable ADC oversample mode
- \param[in] adc_periph: ADCx,x=0,1,2
- \param[out] none
- \retval none
+ \brief enable ADC oversample mode
+ \param[in] adc_periph: ADCx,x=0,1,2
+ \param[out] none
+ \retval none
*/
void adc_oversample_mode_enable(uint32_t adc_periph)
{
@@ -309,10 +310,10 @@ void adc_oversample_mode_enable(uint32_t adc_periph)
}
/*!
- \brief disable ADC oversample mode
- \param[in] adc_periph: ADCx,x=0,1,2
- \param[out] none
- \retval none
+ \brief disable ADC oversample mode
+ \param[in] adc_periph: ADCx,x=0,1,2
+ \param[out] none
+ \retval none
*/
void adc_oversample_mode_disable(uint32_t adc_periph)
{
@@ -320,10 +321,10 @@ void adc_oversample_mode_disable(uint32_t adc_periph)
}
/*!
- \brief enable DMA request
- \param[in] adc_periph: ADCx,x=0,1,2
- \param[out] none
- \retval none
+ \brief enable DMA request
+ \param[in] adc_periph: ADCx,x=0,1,2
+ \param[out] none
+ \retval none
*/
void adc_dma_mode_enable(uint32_t adc_periph)
{
@@ -344,7 +345,7 @@ void adc_dma_mode_disable(uint32_t adc_periph)
}
/*!
- \brief when DMA=1, the DMA engine issues a request at end of each regular conversion
+ \brief when DMA=1, the DMA engine issues a request at end of each routine conversion
\param[in] adc_periph: ADCx,x=0,1,2
\param[out] none
\retval none
@@ -355,7 +356,7 @@ void adc_dma_request_after_last_enable(uint32_t adc_periph)
}
/*!
- \brief the DMA engine is disabled after the end of transfer signal from DMA controller is detected
+ \brief the DMA engine is disabled after the end of transfer signal from DMA controller is detected
\param[in] adc_periph: ADCx,x=0,1,2
\param[out] none
\retval none
@@ -366,69 +367,69 @@ void adc_dma_request_after_last_disable(uint32_t adc_periph)
}
/*!
- \brief configure ADC discontinuous mode
- \param[in] adc_periph: ADCx,x=0,1,2
- \param[in] adc_channel_group: select the channel group
- only one parameter can be selected which is shown as below:
- \arg ADC_REGULAR_CHANNEL: regular channel group
- \arg ADC_INSERTED_CHANNEL: inserted channel group
- \arg ADC_CHANNEL_DISCON_DISABLE: disable discontinuous mode of regular & inserted channel
- \param[in] length: number of conversions in discontinuous mode,the number can be 1..8
- for regular channel ,the number has no effect for inserted channel
- \param[out] none
- \retval none
+ \brief configure ADC discontinuous mode
+ \param[in] adc_periph: ADCx,x=0,1,2
+ \param[in] adc_sequence: select the sequence
+ only one parameter can be selected which is shown as below:
+ \arg ADC_ROUTINE_CHANNEL: routine sequence
+ \arg ADC_INSERTED_CHANNEL: inserted sequence
+ \arg ADC_CHANNEL_DISCON_DISABLE: disable discontinuous mode of routine & inserted channel
+ \param[in] length: number of conversions in discontinuous mode,the number can be 1..8
+ for routine sequence ,the number has no effect for inserted sequence
+ \param[out] none
+ \retval none
*/
-void adc_discontinuous_mode_config(uint32_t adc_periph , uint8_t adc_channel_group , uint8_t length)
+void adc_discontinuous_mode_config(uint32_t adc_periph, uint8_t adc_sequence, uint8_t length)
{
- /* disable discontinuous mode of regular & inserted channel */
- ADC_CTL0(adc_periph) &= ~((uint32_t)( ADC_CTL0_DISRC | ADC_CTL0_DISIC ));
- switch(adc_channel_group){
- case ADC_REGULAR_CHANNEL:
+ /* disable discontinuous mode of routine & inserted channel */
+ ADC_CTL0(adc_periph) &= ~((uint32_t)(ADC_CTL0_DISRC | ADC_CTL0_DISIC));
+ switch(adc_sequence) {
+ case ADC_ROUTINE_CHANNEL:
/* config the number of conversions in discontinuous mode */
ADC_CTL0(adc_periph) &= ~((uint32_t)ADC_CTL0_DISNUM);
- if((length <= 8U) && (length >= 1U)){
+ if((length <= 8U) && (length >= 1U)) {
ADC_CTL0(adc_periph) |= CTL0_DISNUM(((uint32_t)length - ADC_CHANNEL_LENGTH_SUBTRACT_ONE));
}
- /* enable regular channel group discontinuous mode */
+ /* enable routine sequence discontinuous mode */
ADC_CTL0(adc_periph) |= (uint32_t)ADC_CTL0_DISRC;
break;
case ADC_INSERTED_CHANNEL:
- /* enable inserted channel group discontinuous mode */
+ /* enable inserted sequence discontinuous mode */
ADC_CTL0(adc_periph) |= (uint32_t)ADC_CTL0_DISIC;
break;
case ADC_CHANNEL_DISCON_DISABLE:
- /* disable discontinuous mode of regular & inserted channel */
+ /* disable discontinuous mode of routine & inserted channel */
default:
break;
}
}
/*!
- \brief configure the length of regular channel group or inserted channel group
- \param[in] adc_periph: ADCx,x=0,1,2
- \param[in] adc_channel_group: select the channel group
- only one parameter can be selected which is shown as below:
- \arg ADC_REGULAR_CHANNEL: regular channel group
- \arg ADC_INSERTED_CHANNEL: inserted channel group
- \param[in] length: the length of the channel
- regular channel 1-16
- inserted channel 1-4
- \param[out] none
- \retval none
+ \brief configure the length of routine sequence or inserted sequence
+ \param[in] adc_periph: ADCx,x=0,1,2
+ \param[in] adc_sequence: select the sequence
+ only one parameter can be selected which is shown as below:
+ \arg ADC_ROUTINE_CHANNEL: routine sequence
+ \arg ADC_INSERTED_CHANNEL: inserted sequence
+ \param[in] length: the length of the channel
+ routine channel 1-16
+ inserted channel 1-4
+ \param[out] none
+ \retval none
*/
-void adc_channel_length_config(uint32_t adc_periph , uint8_t adc_channel_group , uint32_t length)
+void adc_channel_length_config(uint32_t adc_periph, uint8_t adc_sequence, uint32_t length)
{
- switch(adc_channel_group){
- case ADC_REGULAR_CHANNEL:
- if((length >= 1U) && (length <= 16U)){
- ADC_RSQ0(adc_periph) &= ~((uint32_t)ADC_RSQ0_RL);
- ADC_RSQ0(adc_periph) |= RSQ0_RL((uint32_t)(length-ADC_CHANNEL_LENGTH_SUBTRACT_ONE));
+ switch(adc_sequence) {
+ case ADC_ROUTINE_CHANNEL:
+ if((length >= 1U) && (length <= 16U)) {
+ ADC_RSQ0(adc_periph) &= ~((uint32_t)ADC_RSQ0_RL);
+ ADC_RSQ0(adc_periph) |= RSQ0_RL((uint32_t)(length - ADC_CHANNEL_LENGTH_SUBTRACT_ONE));
}
break;
case ADC_INSERTED_CHANNEL:
- if((length >= 1U) && (length <= 4U)){
- ADC_ISQ(adc_periph) &= ~((uint32_t)ADC_ISQ_IL);
- ADC_ISQ(adc_periph) |= ISQ_IL((uint32_t)(length-ADC_CHANNEL_LENGTH_SUBTRACT_ONE));
+ if((length >= 1U) && (length <= 4U)) {
+ ADC_ISQ(adc_periph) &= ~((uint32_t)ADC_ISQ_IL);
+ ADC_ISQ(adc_periph) |= ISQ_IL((uint32_t)(length - ADC_CHANNEL_LENGTH_SUBTRACT_ONE));
}
break;
default:
@@ -437,124 +438,124 @@ void adc_channel_length_config(uint32_t adc_periph , uint8_t adc_channel_group ,
}
/*!
- \brief configure ADC regular channel
- \param[in] adc_periph: ADCx,x=0,1,2
- \param[in] rank: the regular group sequencer rank,this parameter must be between 0 to 15
- \param[in] adc_channel: the selected ADC channel
- only one parameter can be selected which is shown as below:
- \arg ADC_CHANNEL_x(x=0..18): ADC Channelx
- \param[in] sample_time: the sample time value
- only one parameter can be selected which is shown as below:
- \arg ADC_SAMPLETIME_3: 3 cycles
- \arg ADC_SAMPLETIME_15: 15 cycles
- \arg ADC_SAMPLETIME_28: 28 cycles
- \arg ADC_SAMPLETIME_56: 56 cycles
- \arg ADC_SAMPLETIME_84: 84 cycles
- \arg ADC_SAMPLETIME_112: 112 cycles
- \arg ADC_SAMPLETIME_144: 144 cycles
- \arg ADC_SAMPLETIME_480: 480 cycles
- \param[out] none
- \retval none
+ \brief configure ADC routine channel
+ \param[in] adc_periph: ADCx,x=0,1,2
+ \param[in] rank: the routine sequence rank,this parameter must be between 0 to 15
+ \param[in] adc_channel: the selected ADC channel
+ only one parameter can be selected which is shown as below:
+ \arg ADC_CHANNEL_x(x=0..18): ADC channelx
+ \param[in] sample_time: the sample time value
+ only one parameter can be selected which is shown as below:
+ \arg ADC_SAMPLETIME_3: 3 cycles
+ \arg ADC_SAMPLETIME_15: 15 cycles
+ \arg ADC_SAMPLETIME_28: 28 cycles
+ \arg ADC_SAMPLETIME_56: 56 cycles
+ \arg ADC_SAMPLETIME_84: 84 cycles
+ \arg ADC_SAMPLETIME_112: 112 cycles
+ \arg ADC_SAMPLETIME_144: 144 cycles
+ \arg ADC_SAMPLETIME_480: 480 cycles
+ \param[out] none
+ \retval none
*/
-void adc_regular_channel_config(uint32_t adc_periph , uint8_t rank , uint8_t adc_channel , uint32_t sample_time)
+void adc_routine_channel_config(uint32_t adc_periph, uint8_t rank, uint8_t adc_channel, uint32_t sample_time)
{
- uint32_t rsq,sampt;
+ uint32_t rsq, sampt;
- /* ADC regular sequence config */
- if(rank < ADC_REGULAR_CHANNEL_RANK_SIX){
- /* the regular group sequence rank is smaller than six */
+ /* ADC routine sequence config */
+ if(rank < ADC_ROUTINE_CHANNEL_RANK_SIX) {
+ /* the routine sequence rank is smaller than six */
rsq = ADC_RSQ2(adc_periph);
- rsq &= ~((uint32_t)(ADC_RSQX_RSQN << (ADC_REGULAR_CHANNEL_RANK_LENGTH*rank)));
- /* the channel number is written to these bits to select a channel as the nth conversion in the regular channel group */
- rsq |= ((uint32_t)adc_channel << (ADC_REGULAR_CHANNEL_RANK_LENGTH*rank));
+ rsq &= ~((uint32_t)(ADC_RSQX_RSQN << (ADC_ROUTINE_CHANNEL_RANK_LENGTH * rank)));
+ /* the channel number is written to these bits to select a channel as the nth conversion in the routine sequence */
+ rsq |= ((uint32_t)adc_channel << (ADC_ROUTINE_CHANNEL_RANK_LENGTH * rank));
ADC_RSQ2(adc_periph) = rsq;
- }else if(rank < ADC_REGULAR_CHANNEL_RANK_TWELVE){
- /* the regular group sequence rank is smaller than twelve */
+ } else if(rank < ADC_ROUTINE_CHANNEL_RANK_TWELVE) {
+ /* the routine sequence rank is smaller than twelve */
rsq = ADC_RSQ1(adc_periph);
- rsq &= ~((uint32_t)(ADC_RSQX_RSQN << (ADC_REGULAR_CHANNEL_RANK_LENGTH*(rank-ADC_REGULAR_CHANNEL_RANK_SIX))));
- /* the channel number is written to these bits to select a channel as the nth conversion in the regular channel group */
- rsq |= ((uint32_t)adc_channel << (ADC_REGULAR_CHANNEL_RANK_LENGTH*(rank-ADC_REGULAR_CHANNEL_RANK_SIX)));
+ rsq &= ~((uint32_t)(ADC_RSQX_RSQN << (ADC_ROUTINE_CHANNEL_RANK_LENGTH * (rank - ADC_ROUTINE_CHANNEL_RANK_SIX))));
+ /* the channel number is written to these bits to select a channel as the nth conversion in the routine sequence */
+ rsq |= ((uint32_t)adc_channel << (ADC_ROUTINE_CHANNEL_RANK_LENGTH * (rank - ADC_ROUTINE_CHANNEL_RANK_SIX)));
ADC_RSQ1(adc_periph) = rsq;
- }else if(rank < ADC_REGULAR_CHANNEL_RANK_SIXTEEN){
- /* the regular group sequence rank is smaller than sixteen */
+ } else if(rank < ADC_ROUTINE_CHANNEL_RANK_SIXTEEN) {
+ /* the routine sequence rank is smaller than sixteen */
rsq = ADC_RSQ0(adc_periph);
- rsq &= ~((uint32_t)(ADC_RSQX_RSQN << (ADC_REGULAR_CHANNEL_RANK_LENGTH*(rank-ADC_REGULAR_CHANNEL_RANK_TWELVE))));
- /* the channel number is written to these bits to select a channel as the nth conversion in the regular channel group */
- rsq |= ((uint32_t)adc_channel << (ADC_REGULAR_CHANNEL_RANK_LENGTH*(rank-ADC_REGULAR_CHANNEL_RANK_TWELVE)));
+ rsq &= ~((uint32_t)(ADC_RSQX_RSQN << (ADC_ROUTINE_CHANNEL_RANK_LENGTH * (rank - ADC_ROUTINE_CHANNEL_RANK_TWELVE))));
+ /* the channel number is written to these bits to select a channel as the nth conversion in the routine sequence */
+ rsq |= ((uint32_t)adc_channel << (ADC_ROUTINE_CHANNEL_RANK_LENGTH * (rank - ADC_ROUTINE_CHANNEL_RANK_TWELVE)));
ADC_RSQ0(adc_periph) = rsq;
- }else{
+ } else {
}
/* ADC sampling time config */
- if(adc_channel < ADC_CHANNEL_SAMPLE_TEN){
- /* the regular group sequence rank is smaller than ten */
+ if(adc_channel < ADC_CHANNEL_SAMPLE_TEN) {
+ /* the routine sequence rank is smaller than ten */
sampt = ADC_SAMPT1(adc_periph);
- sampt &= ~((uint32_t)(ADC_SAMPTX_SPTN << (ADC_CHANNEL_SAMPLE_LENGTH*adc_channel)));
+ sampt &= ~((uint32_t)(ADC_SAMPTX_SPTN << (ADC_CHANNEL_SAMPLE_LENGTH * adc_channel)));
/* channel sample time set*/
- sampt |= (uint32_t)(sample_time << (ADC_CHANNEL_SAMPLE_LENGTH*adc_channel));
+ sampt |= (uint32_t)(sample_time << (ADC_CHANNEL_SAMPLE_LENGTH * adc_channel));
ADC_SAMPT1(adc_periph) = sampt;
- }else if(adc_channel <= ADC_CHANNEL_SAMPLE_EIGHTEEN){
- /* the regular group sequence rank is smaller than eighteen */
+ } else if(adc_channel <= ADC_CHANNEL_SAMPLE_EIGHTEEN) {
+ /* the routine sequence rank is smaller than eighteen */
sampt = ADC_SAMPT0(adc_periph);
- sampt &= ~((uint32_t)(ADC_SAMPTX_SPTN << (ADC_CHANNEL_SAMPLE_LENGTH*(adc_channel-ADC_CHANNEL_SAMPLE_TEN))));
+ sampt &= ~((uint32_t)(ADC_SAMPTX_SPTN << (ADC_CHANNEL_SAMPLE_LENGTH * (adc_channel - ADC_CHANNEL_SAMPLE_TEN))));
/* channel sample time set*/
- sampt |= (uint32_t)(sample_time << (ADC_CHANNEL_SAMPLE_LENGTH*(adc_channel-ADC_CHANNEL_SAMPLE_TEN)));
+ sampt |= (uint32_t)(sample_time << (ADC_CHANNEL_SAMPLE_LENGTH * (adc_channel - ADC_CHANNEL_SAMPLE_TEN)));
ADC_SAMPT0(adc_periph) = sampt;
- }else{
+ } else {
}
}
/*!
- \brief configure ADC inserted channel
+ \brief configure ADC inserted channel
\param[in] adc_periph: ADCx,x=0,1,2
- \param[in] rank: the inserted group sequencer rank,this parameter must be between 0 to 3
+ \param[in] rank: the inserted sequence rank,this parameter must be between 0 to 3
\param[in] adc_channel: the selected ADC channel
only one parameter can be selected which is shown as below:
- \arg ADC_CHANNEL_x(x=0..18): ADC Channelx
+ \arg ADC_CHANNEL_x(x=0..18): ADC Channelx
\param[in] sample_time: The sample time value
only one parameter can be selected which is shown as below:
- \arg ADC_SAMPLETIME_3: 3 cycles
- \arg ADC_SAMPLETIME_15: 15 cycles
- \arg ADC_SAMPLETIME_28: 28 cycles
- \arg ADC_SAMPLETIME_56: 56 cycles
- \arg ADC_SAMPLETIME_84: 84 cycles
- \arg ADC_SAMPLETIME_112: 112 cycles
- \arg ADC_SAMPLETIME_144: 144 cycles
- \arg ADC_SAMPLETIME_480: 480 cycles
+ \arg ADC_SAMPLETIME_3: 3 cycles
+ \arg ADC_SAMPLETIME_15: 15 cycles
+ \arg ADC_SAMPLETIME_28: 28 cycles
+ \arg ADC_SAMPLETIME_56: 56 cycles
+ \arg ADC_SAMPLETIME_84: 84 cycles
+ \arg ADC_SAMPLETIME_112: 112 cycles
+ \arg ADC_SAMPLETIME_144: 144 cycles
+ \arg ADC_SAMPLETIME_480: 480 cycles
\param[out] none
\retval none
*/
-void adc_inserted_channel_config(uint32_t adc_periph , uint8_t rank , uint8_t adc_channel , uint32_t sample_time)
+void adc_inserted_channel_config(uint32_t adc_periph, uint8_t rank, uint8_t adc_channel, uint32_t sample_time)
{
uint8_t inserted_length;
- uint32_t isq,sampt;
+ uint32_t isq, sampt;
- /* get inserted channel group length */
- inserted_length = (uint8_t)GET_BITS(ADC_ISQ(adc_periph) , 20U , 21U);
- /* the channel number is written to these bits to select a channel as the nth conversion in the inserted channel group */
- if(rank < 4U){
+ /* get inserted sequence length */
+ inserted_length = (uint8_t)GET_BITS(ADC_ISQ(adc_periph), 20U, 21U);
+ /* the channel number is written to these bits to select a channel as the nth conversion in the inserted sequence */
+ if(rank < 4U) {
isq = ADC_ISQ(adc_periph);
- isq &= ~((uint32_t)(ADC_ISQ_ISQN << (ADC_INSERTED_CHANNEL_SHIFT_LENGTH-(inserted_length-rank)*ADC_INSERTED_CHANNEL_RANK_LENGTH)));
- isq |= ((uint32_t)adc_channel << (ADC_INSERTED_CHANNEL_SHIFT_LENGTH-(inserted_length-rank)*ADC_INSERTED_CHANNEL_RANK_LENGTH));
+ isq &= ~((uint32_t)(ADC_ISQ_ISQN << (ADC_INSERTED_CHANNEL_SHIFT_LENGTH - (inserted_length - rank) * ADC_INSERTED_CHANNEL_RANK_LENGTH)));
+ isq |= ((uint32_t)adc_channel << (ADC_INSERTED_CHANNEL_SHIFT_LENGTH - (inserted_length - rank) * ADC_INSERTED_CHANNEL_RANK_LENGTH));
ADC_ISQ(adc_periph) = isq;
}
/* ADC sampling time config */
- if(adc_channel < ADC_CHANNEL_SAMPLE_TEN){
- /* the inserted group sequence rank is smaller than ten */
+ if(adc_channel < ADC_CHANNEL_SAMPLE_TEN) {
+ /* the inserted sequence rank is smaller than ten */
sampt = ADC_SAMPT1(adc_periph);
- sampt &= ~((uint32_t)(ADC_SAMPTX_SPTN << (ADC_CHANNEL_SAMPLE_LENGTH*adc_channel)));
+ sampt &= ~((uint32_t)(ADC_SAMPTX_SPTN << (ADC_CHANNEL_SAMPLE_LENGTH * adc_channel)));
/* channel sample time set*/
- sampt |= (uint32_t) sample_time << (ADC_CHANNEL_SAMPLE_LENGTH*adc_channel);
+ sampt |= (uint32_t) sample_time << (ADC_CHANNEL_SAMPLE_LENGTH * adc_channel);
ADC_SAMPT1(adc_periph) = sampt;
- }else if(adc_channel <= ADC_CHANNEL_SAMPLE_EIGHTEEN){
- /* the inserted group sequence rank is smaller than eighteen */
+ } else if(adc_channel <= ADC_CHANNEL_SAMPLE_EIGHTEEN) {
+ /* the inserted sequence rank is smaller than eighteen */
sampt = ADC_SAMPT0(adc_periph);
- sampt &= ~((uint32_t)(ADC_SAMPTX_SPTN << (ADC_CHANNEL_SAMPLE_LENGTH*(adc_channel - ADC_CHANNEL_SAMPLE_TEN))));
+ sampt &= ~((uint32_t)(ADC_SAMPTX_SPTN << (ADC_CHANNEL_SAMPLE_LENGTH * (adc_channel - ADC_CHANNEL_SAMPLE_TEN))));
/* channel sample time set*/
- sampt |= ((uint32_t)sample_time << (ADC_CHANNEL_SAMPLE_LENGTH*(adc_channel - ADC_CHANNEL_SAMPLE_TEN)));
+ sampt |= ((uint32_t)sample_time << (ADC_CHANNEL_SAMPLE_LENGTH * (adc_channel - ADC_CHANNEL_SAMPLE_TEN)));
ADC_SAMPT0(adc_periph) = sampt;
- }else{
+ } else {
}
}
@@ -563,23 +564,23 @@ void adc_inserted_channel_config(uint32_t adc_periph , uint8_t rank , uint8_t ad
\param[in] adc_periph: ADCx,x=0,1,2
\param[in] inserted_channel : insert channel select
only one parameter can be selected which is shown as below:
- \arg ADC_INSERTED_CHANNEL_0: inserted channel0
- \arg ADC_INSERTED_CHANNEL_1: inserted channel1
- \arg ADC_INSERTED_CHANNEL_2: inserted channel2
- \arg ADC_INSERTED_CHANNEL_3: inserted channel3
+ \arg ADC_INSERTED_CHANNEL_0: inserted channel0
+ \arg ADC_INSERTED_CHANNEL_1: inserted channel1
+ \arg ADC_INSERTED_CHANNEL_2: inserted channel2
+ \arg ADC_INSERTED_CHANNEL_3: inserted channel3
\param[in] offset : the offset data
\param[out] none
\retval none
*/
-void adc_inserted_channel_offset_config(uint32_t adc_periph , uint8_t inserted_channel , uint16_t offset)
+void adc_inserted_channel_offset_config(uint32_t adc_periph, uint8_t inserted_channel, uint16_t offset)
{
uint8_t inserted_length;
uint32_t num = 0U;
- inserted_length = (uint8_t)GET_BITS(ADC_ISQ(adc_periph) , 20U , 21U);
+ inserted_length = (uint8_t)GET_BITS(ADC_ISQ(adc_periph), 20U, 21U);
num = ((uint32_t)ADC_OFFSET_LENGTH - ((uint32_t)inserted_length - (uint32_t)inserted_channel));
- if(num <= ADC_OFFSET_LENGTH){
+ if(num <= ADC_OFFSET_LENGTH) {
/* calculate the offset of the register */
num = num * ADC_OFFSET_SHIFT_LENGTH;
/* config the offset of the selected channels */
@@ -590,60 +591,60 @@ void adc_inserted_channel_offset_config(uint32_t adc_periph , uint8_t inserted_c
/*!
\brief configure ADC external trigger source
\param[in] adc_periph: ADCx,x=0,1,2
- \param[in] adc_channel_group: select the channel group
+ \param[in] adc_sequence: select the sequence
only one parameter can be selected which is shown as below:
- \arg ADC_REGULAR_CHANNEL: regular channel group
- \arg ADC_INSERTED_CHANNEL: inserted channel group
- \param[in] external_trigger_source: regular or inserted group trigger source
- for regular channel:
+ \arg ADC_ROUTINE_CHANNEL: routine sequence
+ \arg ADC_INSERTED_CHANNEL: inserted sequence
+ \param[in] external_trigger_source: routine or inserted sequence trigger source
+ for routine sequence:
only one parameter can be selected which is shown as below:
- \arg ADC_EXTTRIG_REGULAR_T0_CH0: external trigger timer 0 CC0 event select for regular channel
- \arg ADC_EXTTRIG_REGULAR_T0_CH1: external trigger timer 0 CC1 event select for regular channel
- \arg ADC_EXTTRIG_REGULAR_T0_CH2: external trigger timer 0 CC2 event select for regular channel
- \arg ADC_EXTTRIG_REGULAR_T1_CH1: external trigger timer 1 CC1 event select for regular channel
- \arg ADC_EXTTRIG_REGULAR_T1_CH2: external trigger timer 1 CC2 event select for regular channel
- \arg ADC_EXTTRIG_REGULAR_T1_CH3: external trigger timer 1 CC3 event select for regular channel
- \arg ADC_EXTTRIG_REGULAR_T1_TRGO: external trigger timer 1 TRGO event select for regular channel
- \arg ADC_EXTTRIG_REGULAR_T2_CH0 : external trigger timer 2 CC0 event select for regular channel
- \arg ADC_EXTTRIG_REGULAR_T2_TRGO : external trigger timer 2 TRGO event select for regular channel
- \arg ADC_EXTTRIG_REGULAR_T3_CH3: external trigger timer 3 CC3 event select for regular channel
- \arg ADC_EXTTRIG_REGULAR_T4_CH0: external trigger timer 4 CC0 event select for regular channel
- \arg ADC_EXTTRIG_REGULAR_T4_CH1: external trigger timer 4 CC1 event select for regular channel
- \arg ADC_EXTTRIG_REGULAR_T4_CH2: external trigger timer 4 CC2 event select for regular channel
- \arg ADC_EXTTRIG_REGULAR_T7_CH0: external trigger timer 7 CC0 event select for regular channel
- \arg ADC_EXTTRIG_REGULAR_T7_TRGO: external trigger timer 7 TRGO event select for regular channel
- \arg ADC_EXTTRIG_REGULAR_EXTI_11: external trigger extiline 11 select for regular channel
- for inserted channel:
+ \arg ADC_EXTTRIG_ROUTINE_T0_CH0: external trigger timer 0 CC0 event select for routine sequence
+ \arg ADC_EXTTRIG_ROUTINE_T0_CH1: external trigger timer 0 CC1 event select for routine sequence
+ \arg ADC_EXTTRIG_ROUTINE_T0_CH2: external trigger timer 0 CC2 event select for routine sequence
+ \arg ADC_EXTTRIG_ROUTINE_T1_CH1: external trigger timer 1 CC1 event select for routine sequence
+ \arg ADC_EXTTRIG_ROUTINE_T1_CH2: external trigger timer 1 CC2 event select for routine sequence
+ \arg ADC_EXTTRIG_ROUTINE_T1_CH3: external trigger timer 1 CC3 event select for routine sequence
+ \arg ADC_EXTTRIG_ROUTINE_T1_TRGO: external trigger timer 1 TRGO event select for routine sequence
+ \arg ADC_EXTTRIG_ROUTINE_T2_CH0 : external trigger timer 2 CC0 event select for routine sequence
+ \arg ADC_EXTTRIG_ROUTINE_T2_TRGO : external trigger timer 2 TRGO event select for routine sequence
+ \arg ADC_EXTTRIG_ROUTINE_T3_CH3: external trigger timer 3 CC3 event select for routine sequence
+ \arg ADC_EXTTRIG_ROUTINE_T4_CH0: external trigger timer 4 CC0 event select for routine sequence
+ \arg ADC_EXTTRIG_ROUTINE_T4_CH1: external trigger timer 4 CC1 event select for routine sequence
+ \arg ADC_EXTTRIG_ROUTINE_T4_CH2: external trigger timer 4 CC2 event select for routine sequence
+ \arg ADC_EXTTRIG_ROUTINE_T7_CH0: external trigger timer 7 CC0 event select for routine sequence
+ \arg ADC_EXTTRIG_ROUTINE_T7_TRGO: external trigger timer 7 TRGO event select for routine sequence
+ \arg ADC_EXTTRIG_ROUTINE_EXTI_11: external trigger extiline 11 select for routine sequence
+ for inserted sequence:
only one parameter can be selected which is shown as below:
- \arg ADC_EXTTRIG_INSERTED_T0_CH3: timer0 capture compare 3
- \arg ADC_EXTTRIG_INSERTED_T0_TRGO: timer0 TRGO event
- \arg ADC_EXTTRIG_INSERTED_T1_CH0: timer1 capture compare 0
- \arg ADC_EXTTRIG_INSERTED_T1_TRGO: timer1 TRGO event
- \arg ADC_EXTTRIG_INSERTED_T2_CH1: timer2 capture compare 1
- \arg ADC_EXTTRIG_INSERTED_T2_CH3: timer2 capture compare 3
- \arg ADC_EXTTRIG_INSERTED_T3_CH0: timer3 capture compare 0
- \arg ADC_EXTTRIG_INSERTED_T3_CH1: timer3 capture compare 1
- \arg ADC_EXTTRIG_INSERTED_T3_CH2: timer3 capture compare 2
- \arg ADC_EXTTRIG_INSERTED_T3_TRGO: timer3 capture compare TRGO
- \arg ADC_EXTTRIG_INSERTED_T4_CH3: timer4 capture compare 3
- \arg ADC_EXTTRIG_INSERTED_T4_TRGO: timer4 capture compare TRGO
- \arg ADC_EXTTRIG_INSERTED_T7_CH1: timer7 capture compare 1
- \arg ADC_EXTTRIG_INSERTED_T7_CH2: timer7 capture compare 2
- \arg ADC_EXTTRIG_INSERTED_T7_CH3: timer7 capture compare 3
- \arg ADC_EXTTRIG_INSERTED_EXTI_15: external interrupt line 15
+ \arg ADC_EXTTRIG_INSERTED_T0_CH3: timer0 capture compare 3
+ \arg ADC_EXTTRIG_INSERTED_T0_TRGO: timer0 TRGO event
+ \arg ADC_EXTTRIG_INSERTED_T1_CH0: timer1 capture compare 0
+ \arg ADC_EXTTRIG_INSERTED_T1_TRGO: timer1 TRGO event
+ \arg ADC_EXTTRIG_INSERTED_T2_CH1: timer2 capture compare 1
+ \arg ADC_EXTTRIG_INSERTED_T2_CH3: timer2 capture compare 3
+ \arg ADC_EXTTRIG_INSERTED_T3_CH0: timer3 capture compare 0
+ \arg ADC_EXTTRIG_INSERTED_T3_CH1: timer3 capture compare 1
+ \arg ADC_EXTTRIG_INSERTED_T3_CH2: timer3 capture compare 2
+ \arg ADC_EXTTRIG_INSERTED_T3_TRGO: timer3 capture compare TRGO
+ \arg ADC_EXTTRIG_INSERTED_T4_CH3: timer4 capture compare 3
+ \arg ADC_EXTTRIG_INSERTED_T4_TRGO: timer4 capture compare TRGO
+ \arg ADC_EXTTRIG_INSERTED_T7_CH1: timer7 capture compare 1
+ \arg ADC_EXTTRIG_INSERTED_T7_CH2: timer7 capture compare 2
+ \arg ADC_EXTTRIG_INSERTED_T7_CH3: timer7 capture compare 3
+ \arg ADC_EXTTRIG_INSERTED_EXTI_15: external interrupt line 15
\param[out] none
\retval none
*/
-void adc_external_trigger_source_config(uint32_t adc_periph , uint8_t adc_channel_group , uint32_t external_trigger_source)
+void adc_external_trigger_source_config(uint32_t adc_periph, uint8_t adc_sequence, uint32_t external_trigger_source)
{
- switch(adc_channel_group){
- case ADC_REGULAR_CHANNEL:
- /* configure ADC regular group external trigger source */
+ switch(adc_sequence) {
+ case ADC_ROUTINE_CHANNEL:
+ /* configure ADC routine sequence external trigger source */
ADC_CTL1(adc_periph) &= ~((uint32_t)ADC_CTL1_ETSRC);
ADC_CTL1(adc_periph) |= (uint32_t)external_trigger_source;
break;
case ADC_INSERTED_CHANNEL:
- /* configure ADC inserted group external trigger source */
+ /* configure ADC inserted sequence external trigger source */
ADC_CTL1(adc_periph) &= ~((uint32_t)ADC_CTL1_ETSIC);
ADC_CTL1(adc_periph) |= (uint32_t)external_trigger_source;
break;
@@ -655,56 +656,56 @@ void adc_external_trigger_source_config(uint32_t adc_periph , uint8_t adc_channe
/*!
\brief enable ADC external trigger
\param[in] adc_periph: ADCx,x=0,1,2
- \param[in] adc_channel_group: select the channel group
+ \param[in] adc_sequence: select the sequence
only one parameter can be selected which is shown as below:
- \arg ADC_REGULAR_CHANNEL: regular channel group
- \arg ADC_INSERTED_CHANNEL: inserted channel group
+ \arg ADC_ROUTINE_CHANNEL: routine sequence
+ \arg ADC_INSERTED_CHANNEL: inserted sequence
\param[in] trigger_mode: external trigger mode
only one parameter can be selected which is shown as below:
- \arg EXTERNAL_TRIGGER_DISABLE: external trigger disable
- \arg EXTERNAL_TRIGGER_RISING: rising edge of external trigger
- \arg EXTERNAL_TRIGGER_FALLING: falling edge of external trigger
- \arg EXTERNAL_TRIGGER_RISING_FALLING: rising and falling edge of external trigger
+ \arg EXTERNAL_TRIGGER_DISABLE: external trigger disable
+ \arg EXTERNAL_TRIGGER_RISING: rising edge of external trigger
+ \arg EXTERNAL_TRIGGER_FALLING: falling edge of external trigger
+ \arg EXTERNAL_TRIGGER_RISING_FALLING: rising and falling edge of external trigger
\param[out] none
\retval none
*/
-void adc_external_trigger_config(uint32_t adc_periph , uint8_t adc_channel_group , uint32_t trigger_mode)
+void adc_external_trigger_config(uint32_t adc_periph, uint8_t adc_sequence, uint32_t trigger_mode)
{
- switch(adc_channel_group){
- case ADC_REGULAR_CHANNEL:
- /* configure ADC regular channel group external trigger mode */
- ADC_CTL1(adc_periph) &= ~((uint32_t)ADC_CTL1_ETMRC);
- ADC_CTL1(adc_periph) |= (uint32_t) (trigger_mode << REGULAR_TRIGGER_MODE);
- break;
- case ADC_INSERTED_CHANNEL:
- /* configure ADC inserted channel group external trigger mode */
- ADC_CTL1(adc_periph) &= ~((uint32_t)ADC_CTL1_ETMIC);
- ADC_CTL1(adc_periph) |= (uint32_t) (trigger_mode << INSERTED_TRIGGER_MODE);
- break;
- default:
- break;
- }
+ switch(adc_sequence) {
+ case ADC_ROUTINE_CHANNEL:
+ /* configure ADC routine sequence external trigger mode */
+ ADC_CTL1(adc_periph) &= ~((uint32_t)ADC_CTL1_ETMRC);
+ ADC_CTL1(adc_periph) |= (uint32_t)(trigger_mode << ROUTINE_TRIGGER_MODE);
+ break;
+ case ADC_INSERTED_CHANNEL:
+ /* configure ADC inserted sequence external trigger mode */
+ ADC_CTL1(adc_periph) &= ~((uint32_t)ADC_CTL1_ETMIC);
+ ADC_CTL1(adc_periph) |= (uint32_t)(trigger_mode << INSERTED_TRIGGER_MODE);
+ break;
+ default:
+ break;
+ }
}
/*!
\brief enable ADC software trigger
\param[in] adc_periph: ADCx,x=0,1,2
- \param[in] adc_channel_group: select the channel group
+ \param[in] adc_sequence: select the sequence
only one parameter can be selected which is shown as below:
- \arg ADC_REGULAR_CHANNEL: regular channel group
- \arg ADC_INSERTED_CHANNEL: inserted channel group
+ \arg ADC_ROUTINE_CHANNEL: routine sequence
+ \arg ADC_INSERTED_CHANNEL: inserted sequence
\param[out] none
\retval none
*/
-void adc_software_trigger_enable(uint32_t adc_periph , uint8_t adc_channel_group)
+void adc_software_trigger_enable(uint32_t adc_periph, uint8_t adc_sequence)
{
- switch(adc_channel_group){
- case ADC_REGULAR_CHANNEL:
- /* enable ADC regular channel group software trigger */
+ switch(adc_sequence) {
+ case ADC_ROUTINE_CHANNEL:
+ /* enable ADC routine sequence software trigger */
ADC_CTL1(adc_periph) |= (uint32_t)ADC_CTL1_SWRCST;
break;
case ADC_INSERTED_CHANNEL:
- /* enable ADC inserted channel group software trigger */
+ /* enable ADC inserted sequence software trigger */
ADC_CTL1(adc_periph) |= (uint32_t)ADC_CTL1_SWICST;
break;
default:
@@ -717,56 +718,56 @@ void adc_software_trigger_enable(uint32_t adc_periph , uint8_t adc_channel_group
\param[in] adc_periph: ADCx,x=0,1,2
\param[in] end_selection: end of conversion mode
only one parameter can be selected which is shown as below:
- \arg ADC_EOC_SET_SEQUENCE: only at the end of a sequence of regular conversions, the EOC bit is set.Overflow detection is disabled unless DMA=1.
- \arg ADC_EOC_SET_CONVERSION: at the end of each regular conversion, the EOC bit is set.Overflow is detected automatically.
+ \arg ADC_EOC_SET_SEQUENCE: only at the end of a sequence of routine conversions, the EOC bit is set.Overflow detection is disabled unless DMA=1.
+ \arg ADC_EOC_SET_CONVERSION: at the end of each routine conversion, the EOC bit is set.Overflow is detected automatically.
\param[out] none
\retval none
*/
-void adc_end_of_conversion_config(uint32_t adc_periph , uint8_t end_selection)
+void adc_end_of_conversion_config(uint32_t adc_periph, uint8_t end_selection)
{
- switch(end_selection){
- case ADC_EOC_SET_SEQUENCE:
- /* only at the end of a sequence of regular conversions, the EOC bit is set */
- ADC_CTL1(adc_periph) &= ~((uint32_t)ADC_CTL1_EOCM);
- break;
- case ADC_EOC_SET_CONVERSION:
- /* at the end of each regular conversion, the EOC bit is set.Overflow is detected automatically */
- ADC_CTL1(adc_periph) |= (uint32_t)(ADC_CTL1_EOCM);
- break;
- default:
- break;
+ switch(end_selection) {
+ case ADC_EOC_SET_SEQUENCE:
+ /* only at the end of a sequence of routine conversions, the EOC bit is set */
+ ADC_CTL1(adc_periph) &= ~((uint32_t)ADC_CTL1_EOCM);
+ break;
+ case ADC_EOC_SET_CONVERSION:
+ /* at the end of each routine conversion, the EOC bit is set.Overflow is detected automatically */
+ ADC_CTL1(adc_periph) |= (uint32_t)(ADC_CTL1_EOCM);
+ break;
+ default:
+ break;
}
}
/*!
- \brief read ADC regular group data register
+ \brief read ADC routine data register
\param[in] adc_periph: ADCx,x=0,1,2
\param[in] none
\param[out] none
\retval the conversion value
*/
-uint16_t adc_regular_data_read(uint32_t adc_periph)
+uint16_t adc_routine_data_read(uint32_t adc_periph)
{
return (uint16_t)(ADC_RDATA(adc_periph));
}
/*!
- \brief read ADC inserted group data register
+ \brief read ADC inserted data register
\param[in] adc_periph: ADCx,x=0,1,2
\param[in] inserted_channel : insert channel select
only one parameter can be selected which is shown as below:
- \arg ADC_INSERTED_CHANNEL_0: inserted Channel0
- \arg ADC_INSERTED_CHANNEL_1: inserted channel1
- \arg ADC_INSERTED_CHANNEL_2: inserted Channel2
- \arg ADC_INSERTED_CHANNEL_3: inserted Channel3
+ \arg ADC_INSERTED_CHANNEL_0: inserted channel0
+ \arg ADC_INSERTED_CHANNEL_1: inserted channel1
+ \arg ADC_INSERTED_CHANNEL_2: inserted channel2
+ \arg ADC_INSERTED_CHANNEL_3: inserted channel3
\param[out] none
\retval the conversion value
*/
-uint16_t adc_inserted_data_read(uint32_t adc_periph , uint8_t inserted_channel)
+uint16_t adc_inserted_data_read(uint32_t adc_periph, uint8_t inserted_channel)
{
uint32_t idata;
/* read the data of the selected channel */
- switch(inserted_channel){
+ switch(inserted_channel) {
case ADC_INSERTED_CHANNEL_0:
/* read the data of channel 0 */
idata = ADC_IDATA0(adc_periph);
@@ -796,7 +797,7 @@ uint16_t adc_inserted_data_read(uint32_t adc_periph , uint8_t inserted_channel)
\param[out] none
\retval none
*/
-void adc_watchdog_single_channel_disable(uint32_t adc_periph )
+void adc_watchdog_single_channel_disable(uint32_t adc_periph)
{
ADC_CTL0(adc_periph) &= ~((uint32_t)ADC_CTL0_WDSC);
}
@@ -806,11 +807,11 @@ void adc_watchdog_single_channel_disable(uint32_t adc_periph )
\param[in] adc_periph: ADCx,x=0,1,2
\param[in] adc_channel: the selected ADC channel
only one parameter can be selected which is shown as below:
- \arg ADC_CHANNEL_x: ADC Channelx(x=0..18)
+ \arg ADC_CHANNEL_x: ADC Channelx(x=0..18)
\param[out] none
\retval none
*/
-void adc_watchdog_single_channel_enable(uint32_t adc_periph , uint8_t adc_channel)
+void adc_watchdog_single_channel_enable(uint32_t adc_periph, uint8_t adc_channel)
{
ADC_CTL0(adc_periph) &= ~((uint32_t)ADC_CTL0_WDCHSEL);
@@ -820,31 +821,31 @@ void adc_watchdog_single_channel_enable(uint32_t adc_periph , uint8_t adc_channe
}
/*!
- \brief configure ADC analog watchdog group channel
+ \brief configure ADC analog watchdog sequence channel
\param[in] adc_periph: ADCx,x=0,1,2
- \param[in] adc_channel_group: the channel group use analog watchdog
+ \param[in] adc_sequence: the sequence use analog watchdog
only one parameter can be selected which is shown as below:
- \arg ADC_REGULAR_CHANNEL: regular channel group
- \arg ADC_INSERTED_CHANNEL: inserted channel group
- \arg ADC_REGULAR_INSERTED_CHANNEL: both regular and inserted group
+ \arg ADC_ROUTINE_CHANNEL: routine sequence
+ \arg ADC_INSERTED_CHANNEL: inserted sequence
+ \arg ADC_ROUTINE_INSERTED_CHANNEL: both routine and inserted sequence
\param[out] none
\retval none
*/
-void adc_watchdog_group_channel_enable(uint32_t adc_periph , uint8_t adc_channel_group)
+void adc_watchdog_sequence_channel_enable(uint32_t adc_periph, uint8_t adc_sequence)
{
ADC_CTL0(adc_periph) &= ~((uint32_t)(ADC_CTL0_RWDEN | ADC_CTL0_IWDEN | ADC_CTL0_WDSC));
- /* select the group */
- switch(adc_channel_group){
- case ADC_REGULAR_CHANNEL:
- /* regular channel analog watchdog enable */
+ /* select the sequence */
+ switch(adc_sequence) {
+ case ADC_ROUTINE_CHANNEL:
+ /* routine channel analog watchdog enable */
ADC_CTL0(adc_periph) |= (uint32_t) ADC_CTL0_RWDEN;
break;
case ADC_INSERTED_CHANNEL:
/* inserted channel analog watchdog enable */
ADC_CTL0(adc_periph) |= (uint32_t) ADC_CTL0_IWDEN;
break;
- case ADC_REGULAR_INSERTED_CHANNEL:
- /* regular and inserted channel analog watchdog enable */
+ case ADC_ROUTINE_INSERTED_CHANNEL:
+ /* routine and inserted channel analog watchdog enable */
ADC_CTL0(adc_periph) |= (uint32_t)(ADC_CTL0_RWDEN | ADC_CTL0_IWDEN);
break;
default:
@@ -855,28 +856,28 @@ void adc_watchdog_group_channel_enable(uint32_t adc_periph , uint8_t adc_channel
/*!
\brief disable ADC analog watchdog
\param[in] adc_periph: ADCx,x=0,1,2
- \param[in] adc_channel_group: the channel group use analog watchdog
+ \param[in] adc_sequence: the sequence use analog watchdog
only one parameter can be selected which is shown as below:
- \arg ADC_REGULAR_CHANNEL: regular channel group
- \arg ADC_INSERTED_CHANNEL: inserted channel group
- \arg ADC_REGULAR_INSERTED_CHANNEL: both regular and inserted group
+ \arg ADC_ROUTINE_CHANNEL: routine sequence
+ \arg ADC_INSERTED_CHANNEL: inserted sequence
+ \arg ADC_ROUTINE_INSERTED_CHANNEL: both routine and inserted sequence
\param[out] none
\retval none
*/
-void adc_watchdog_disable(uint32_t adc_periph , uint8_t adc_channel_group)
+void adc_watchdog_disable(uint32_t adc_periph, uint8_t adc_sequence)
{
- /* select the group */
- switch(adc_channel_group){
- case ADC_REGULAR_CHANNEL:
- /* disable ADC analog watchdog regular channel group */
+ /* select the sequence */
+ switch(adc_sequence) {
+ case ADC_ROUTINE_CHANNEL:
+ /* disable ADC analog watchdog routine sequence */
ADC_CTL0(adc_periph) &= ~((uint32_t)ADC_CTL0_RWDEN);
break;
case ADC_INSERTED_CHANNEL:
- /* disable ADC analog watchdog inserted channel group */
+ /* disable ADC analog watchdog inserted sequence */
ADC_CTL0(adc_periph) &= ~((uint32_t)ADC_CTL0_IWDEN);
break;
- case ADC_REGULAR_INSERTED_CHANNEL:
- /* disable ADC analog watchdog regular and inserted channel group */
+ case ADC_ROUTINE_INSERTED_CHANNEL:
+ /* disable ADC analog watchdog routine and inserted sequence */
ADC_CTL0(adc_periph) &= ~((uint32_t)(ADC_CTL0_RWDEN | ADC_CTL0_IWDEN));
break;
default:
@@ -892,7 +893,7 @@ void adc_watchdog_disable(uint32_t adc_periph , uint8_t adc_channel_group)
\param[out] none
\retval none
*/
-void adc_watchdog_threshold_config(uint32_t adc_periph , uint16_t low_threshold , uint16_t high_threshold)
+void adc_watchdog_threshold_config(uint32_t adc_periph, uint16_t low_threshold, uint16_t high_threshold)
{
/* configure ADC analog watchdog low threshold */
ADC_WDLT(adc_periph) = (uint32_t)WDLT_WDLT(low_threshold);
@@ -905,19 +906,19 @@ void adc_watchdog_threshold_config(uint32_t adc_periph , uint16_t low_threshold
\param[in] adc_periph: ADCx,x=0,1,2
\param[in] adc_flag: the adc flag bits
only one parameter can be selected which is shown as below:
- \arg ADC_FLAG_WDE: analog watchdog event flag
- \arg ADC_FLAG_EOC: end of group conversion flag
- \arg ADC_FLAG_EOIC: end of inserted group conversion flag
- \arg ADC_FLAG_STIC: start flag of inserted channel group
- \arg ADC_FLAG_STRC: start flag of regular channel group
- \arg ADC_FLAG_ROVF: regular data register overflow flag
+ \arg ADC_FLAG_WDE: analog watchdog event flag
+ \arg ADC_FLAG_EOC: end of sequence conversion flag
+ \arg ADC_FLAG_EOIC: end of inserted sequence conversion flag
+ \arg ADC_FLAG_STIC: start flag of inserted sequence
+ \arg ADC_FLAG_STRC: start flag of routine sequence
+ \arg ADC_FLAG_ROVF: routine data register overflow flag
\param[out] none
\retval FlagStatus: SET or RESET
*/
-FlagStatus adc_flag_get(uint32_t adc_periph , uint32_t adc_flag)
+FlagStatus adc_flag_get(uint32_t adc_periph, uint32_t adc_flag)
{
FlagStatus reval = RESET;
- if(ADC_STAT(adc_periph) & adc_flag){
+ if(ADC_STAT(adc_periph) & adc_flag) {
reval = SET;
}
return reval;
@@ -929,16 +930,16 @@ FlagStatus adc_flag_get(uint32_t adc_periph , uint32_t adc_flag)
\param[in] adc_periph: ADCx,x=0,1,2
\param[in] adc_flag: the adc flag bits
only one parameter can be selected which is shown as below:
- \arg ADC_FLAG_WDE: analog watchdog event flag
- \arg ADC_FLAG_EOC: end of group conversion flag
- \arg ADC_FLAG_EOIC: end of inserted group conversion flag
- \arg ADC_FLAG_STIC: start flag of inserted channel group
- \arg ADC_FLAG_STRC: start flag of regular channel group
- \arg ADC_FLAG_ROVF: regular data register overflow flag
+ \arg ADC_FLAG_WDE: analog watchdog event flag
+ \arg ADC_FLAG_EOC: end of sequence conversion flag
+ \arg ADC_FLAG_EOIC: end of inserted sequence conversion flag
+ \arg ADC_FLAG_STIC: start flag of inserted sequence
+ \arg ADC_FLAG_STRC: start flag of routine sequence
+ \arg ADC_FLAG_ROVF: routine data register overflow flag
\param[out] none
\retval none
*/
-void adc_flag_clear(uint32_t adc_periph , uint32_t adc_flag)
+void adc_flag_clear(uint32_t adc_periph, uint32_t adc_flag)
{
ADC_STAT(adc_periph) &= ~((uint32_t)adc_flag);
}
@@ -950,10 +951,10 @@ void adc_flag_clear(uint32_t adc_periph , uint32_t adc_flag)
\param[out] none
\retval FlagStatus: SET or RESET
*/
-FlagStatus adc_regular_software_startconv_flag_get(uint32_t adc_periph)
+FlagStatus adc_routine_software_startconv_flag_get(uint32_t adc_periph)
{
FlagStatus reval = RESET;
- if((uint32_t)RESET != (ADC_STAT(adc_periph) & ADC_STAT_STRC)){
+ if((uint32_t)RESET != (ADC_STAT(adc_periph) & ADC_STAT_STRC)) {
reval = SET;
}
return reval;
@@ -969,7 +970,7 @@ FlagStatus adc_regular_software_startconv_flag_get(uint32_t adc_periph)
FlagStatus adc_inserted_software_startconv_flag_get(uint32_t adc_periph)
{
FlagStatus reval = RESET;
- if((uint32_t)RESET != (ADC_STAT(adc_periph) & ADC_STAT_STIC)){
+ if((uint32_t)RESET != (ADC_STAT(adc_periph) & ADC_STAT_STIC)) {
reval = SET;
}
return reval;
@@ -980,45 +981,45 @@ FlagStatus adc_inserted_software_startconv_flag_get(uint32_t adc_periph)
\param[in] adc_periph: ADCx,x=0,1,2
\param[in] adc_interrupt: the adc interrupt bits
only one parameter can be selected which is shown as below:
- \arg ADC_INT_FLAG_WDE: analog watchdog interrupt
- \arg ADC_INT_FLAG_EOC: end of group conversion interrupt
- \arg ADC_INT_FLAG_EOIC: end of inserted group conversion interrupt
- \arg ADC_INT_FLAG_ROVF: regular data register overflow interrupt
+ \arg ADC_INT_FLAG_WDE: analog watchdog interrupt
+ \arg ADC_INT_FLAG_EOC: end of sequence conversion interrupt
+ \arg ADC_INT_FLAG_EOIC: end of inserted sequence conversion interrupt
+ \arg ADC_INT_FLAG_ROVF: routine data register overflow interrupt
\param[out] none
\retval FlagStatus: SET or RESET
*/
-FlagStatus adc_interrupt_flag_get(uint32_t adc_periph , uint32_t adc_interrupt)
+FlagStatus adc_interrupt_flag_get(uint32_t adc_periph, uint32_t adc_interrupt)
{
FlagStatus interrupt_flag = RESET;
uint32_t state;
/* check the interrupt bits */
- switch(adc_interrupt){
+ switch(adc_interrupt) {
case ADC_INT_FLAG_WDE:
/* get the ADC analog watchdog interrupt bits */
state = ADC_STAT(adc_periph) & ADC_STAT_WDE;
- if((ADC_CTL0(adc_periph) & ADC_CTL0_WDEIE) && state){
- interrupt_flag = SET;
+ if((ADC_CTL0(adc_periph) & ADC_CTL0_WDEIE) && state) {
+ interrupt_flag = SET;
}
break;
case ADC_INT_FLAG_EOC:
- /* get the ADC end of group conversion interrupt bits */
+ /* get the ADC end of sequence conversion interrupt bits */
state = ADC_STAT(adc_periph) & ADC_STAT_EOC;
- if((ADC_CTL0(adc_periph) & ADC_CTL0_EOCIE) && state){
+ if((ADC_CTL0(adc_periph) & ADC_CTL0_EOCIE) && state) {
interrupt_flag = SET;
- }
+ }
break;
case ADC_INT_FLAG_EOIC:
- /* get the ADC end of inserted group conversion interrupt bits */
+ /* get the ADC end of inserted sequence conversion interrupt bits */
state = ADC_STAT(adc_periph) & ADC_STAT_EOIC;
- if((ADC_CTL0(adc_periph) & ADC_CTL0_EOICIE) && state){
+ if((ADC_CTL0(adc_periph) & ADC_CTL0_EOICIE) && state) {
interrupt_flag = SET;
}
break;
case ADC_INT_FLAG_ROVF:
- /* get the ADC regular data register overflow interrupt bits */
+ /* get the ADC routine data register overflow interrupt bits */
state = ADC_STAT(adc_periph) & ADC_STAT_ROVF;
- if((ADC_CTL0(adc_periph) & ADC_CTL0_ROVFIE) && state){
- interrupt_flag = SET;
+ if((ADC_CTL0(adc_periph) & ADC_CTL0_ROVFIE) && state) {
+ interrupt_flag = SET;
}
break;
default:
@@ -1032,14 +1033,14 @@ FlagStatus adc_interrupt_flag_get(uint32_t adc_periph , uint32_t adc_interrupt)
\param[in] adc_periph: ADCx,x=0,1,2
\param[in] adc_interrupt: the adc status flag
only one parameter can be selected which is shown as below:
- \arg ADC_INT_FLAG_WDE: analog watchdog interrupt
- \arg ADC_INT_FLAG_EOC: end of group conversion interrupt
- \arg ADC_INT_FLAG_EOIC: end of inserted group conversion interrupt
- \arg ADC_INT_FLAG_ROVF: regular data register overflow interrupt
+ \arg ADC_INT_FLAG_WDE: analog watchdog interrupt
+ \arg ADC_INT_FLAG_EOC: end of sequence conversion interrupt
+ \arg ADC_INT_FLAG_EOIC: end of inserted sequence conversion interrupt
+ \arg ADC_INT_FLAG_ROVF: routine data register overflow interrupt
\param[out] none
\retval none
*/
-void adc_interrupt_flag_clear(uint32_t adc_periph , uint32_t adc_interrupt)
+void adc_interrupt_flag_clear(uint32_t adc_periph, uint32_t adc_interrupt)
{
ADC_STAT(adc_periph) &= ~((uint32_t)adc_interrupt);
}
@@ -1049,26 +1050,26 @@ void adc_interrupt_flag_clear(uint32_t adc_periph , uint32_t adc_interrupt)
\param[in] adc_periph: ADCx,x=0,1,2
\param[in] adc_interrupt: the adc interrupt flag
only one parameter can be selected which is shown as below:
- \arg ADC_INT_WDE: analog watchdog interrupt flag
- \arg ADC_INT_EOC: end of group conversion interrupt flag
- \arg ADC_INT_EOIC: end of inserted group conversion interrupt flag
- \arg ADC_INT_ROVF: regular data register overflow interrupt flag
+ \arg ADC_INT_WDE: analog watchdog interrupt flag
+ \arg ADC_INT_EOC: end of sequence conversion interrupt flag
+ \arg ADC_INT_EOIC: end of inserted sequence conversion interrupt flag
+ \arg ADC_INT_ROVF: routine data register overflow interrupt flag
\param[out] none
\retval none
*/
-void adc_interrupt_enable(uint32_t adc_periph , uint32_t adc_interrupt)
+void adc_interrupt_enable(uint32_t adc_periph, uint32_t adc_interrupt)
{
- switch(adc_interrupt){
+ switch(adc_interrupt) {
case ADC_INT_WDE:
/* enable analog watchdog interrupt */
ADC_CTL0(adc_periph) |= (uint32_t) ADC_CTL0_WDEIE;
break;
case ADC_INT_EOC:
- /* enable end of group conversion interrupt */
+ /* enable end of sequence conversion interrupt */
ADC_CTL0(adc_periph) |= (uint32_t) ADC_CTL0_EOCIE;
break;
case ADC_INT_EOIC:
- /* enable end of inserted group conversion interrupt */
+ /* enable end of inserted sequence conversion interrupt */
ADC_CTL0(adc_periph) |= (uint32_t) ADC_CTL0_EOICIE;
break;
case ADC_INT_ROVF:
@@ -1084,16 +1085,16 @@ void adc_interrupt_enable(uint32_t adc_periph , uint32_t adc_interrupt)
\param[in] adc_periph: ADCx,x=0,1,2
\param[in] adc_flag: the adc interrupt flag
only one parameter can be selected which is shown as below:
- \arg ADC_INT_WDE: analog watchdog interrupt flag
- \arg ADC_INT_EOC: end of group conversion interrupt flag
- \arg ADC_INT_EOIC: end of inserted group conversion interrupt flag
- \arg ADC_INT_ROVF: regular data register overflow interrupt flag
+ \arg ADC_INT_WDE: analog watchdog interrupt flag
+ \arg ADC_INT_EOC: end of sequence conversion interrupt flag
+ \arg ADC_INT_EOIC: end of inserted sequence conversion interrupt flag
+ \arg ADC_INT_ROVF: routine data register overflow interrupt flag
\param[out] none
\retval none
*/
-void adc_interrupt_disable(uint32_t adc_periph , uint32_t adc_interrupt)
+void adc_interrupt_disable(uint32_t adc_periph, uint32_t adc_interrupt)
{
- switch(adc_interrupt){
+ switch(adc_interrupt) {
/* select the interrupt source */
case ADC_INT_WDE:
ADC_CTL0(adc_periph) &= ~((uint32_t)ADC_CTL0_WDEIE);
@@ -1116,19 +1117,19 @@ void adc_interrupt_disable(uint32_t adc_periph , uint32_t adc_interrupt)
\brief configure the ADC sync mode
\param[in] sync_mode: ADC sync mode
only one parameter can be selected which is shown as below:
- \arg ADC_SYNC_MODE_INDEPENDENT: all the ADCs work independently
- \arg ADC_DAUL_REGULAL_PARALLEL_INSERTED_PARALLEL: ADC0 and ADC1 work in combined regular parallel & inserted parallel mode
- \arg ADC_DAUL_REGULAL_PARALLEL_INSERTED_ROTATION: ADC0 and ADC1 work in combined regular parallel & trigger rotation mode
- \arg ADC_DAUL_INSERTED_PARALLEL: ADC0 and ADC1 work in inserted parallel mode
- \arg ADC_DAUL_REGULAL_PARALLEL: ADC0 and ADC1 work in regular parallel mode
- \arg ADC_DAUL_REGULAL_FOLLOW_UP: ADC0 and ADC1 work in follow-up mode
- \arg ADC_DAUL_INSERTED_TRRIGGER_ROTATION: ADC0 and ADC1 work in trigger rotation mode
- \arg ADC_ALL_REGULAL_PARALLEL_INSERTED_PARALLEL: all ADCs work in combined regular parallel & inserted parallel mode
- \arg ADC_ALL_REGULAL_PARALLEL_INSERTED_ROTATION: all ADCs work in combined regular parallel & trigger rotation mode
- \arg ADC_ALL_INSERTED_PARALLEL: all ADCs work in inserted parallel mode
- \arg ADC_ALL_REGULAL_PARALLEL: all ADCs work in regular parallel mode
- \arg ADC_ALL_REGULAL_FOLLOW_UP: all ADCs work in follow-up mode
- \arg ADC_ALL_INSERTED_TRRIGGER_ROTATION: all ADCs work in trigger rotation mode
+ \arg ADC_SYNC_MODE_INDEPENDENT: all the ADCs work independently
+ \arg ADC_DAUL_ROUTINE_PARALLEL_INSERTED_PARALLEL: ADC0 and ADC1 work in combined routine parallel & inserted parallel mode
+ \arg ADC_DAUL_ROUTINE_PARALLEL_INSERTED_ROTATION: ADC0 and ADC1 work in combined routine parallel & trigger rotation mode
+ \arg ADC_DAUL_INSERTED_PARALLEL: ADC0 and ADC1 work in inserted parallel mode
+ \arg ADC_DAUL_ROUTINE_PARALLEL: ADC0 and ADC1 work in routine parallel mode
+ \arg ADC_DAUL_ROUTINE_FOLLOW_UP: ADC0 and ADC1 work in follow-up mode
+ \arg ADC_DAUL_INSERTED_TRRIGGER_ROTATION: ADC0 and ADC1 work in trigger rotation mode
+ \arg ADC_ALL_ROUTINE_PARALLEL_INSERTED_PARALLEL: all ADCs work in combined routine parallel & inserted parallel mode
+ \arg ADC_ALL_ROUTINE_PARALLEL_INSERTED_ROTATION: all ADCs work in combined routine parallel & trigger rotation mode
+ \arg ADC_ALL_INSERTED_PARALLEL: all ADCs work in inserted parallel mode
+ \arg ADC_ALL_ROUTINE_PARALLEL: all ADCs work in routine parallel mode
+ \arg ADC_ALL_ROUTINE_FOLLOW_UP: all ADCs work in follow-up mode
+ \arg ADC_ALL_INSERTED_TRRIGGER_ROTATION: all ADCs work in trigger rotation mode
\param[out] none
\retval none
*/
@@ -1142,7 +1143,7 @@ void adc_sync_mode_config(uint32_t sync_mode)
\brief configure the delay between 2 sampling phases in ADC sync modes
\param[in] sample_delay: the delay between 2 sampling phases in ADC sync modes
only one parameter can be selected which is shown as below:
- \arg ADC_SYNC_DELAY_xCYCLE: x=5..20,the delay between 2 sampling phases in ADC sync modes is x ADC clock cycles
+ \arg ADC_SYNC_DELAY_xCYCLE: x=5..20,the delay between 2 sampling phases in ADC sync modes is x ADC clock cycles
\param[out] none
\retval none
*/
@@ -1156,13 +1157,13 @@ void adc_sync_delay_config(uint32_t sample_delay)
\brief configure ADC sync DMA mode selection
\param[in] dma_mode: ADC sync DMA mode
only one parameter can be selected which is shown as below:
- \arg ADC_SYNC_DMA_DISABLE: ADC sync DMA disabled
- \arg ADC_SYNC_DMA_MODE0: ADC sync DMA mode 0
- \arg ADC_SYNC_DMA_MODE1: ADC sync DMA mode 1
+ \arg ADC_SYNC_DMA_DISABLE: ADC sync DMA disabled
+ \arg ADC_SYNC_DMA_MODE0: ADC sync DMA mode 0
+ \arg ADC_SYNC_DMA_MODE1: ADC sync DMA mode 1
\param[out] none
\retval none
*/
-void adc_sync_dma_config(uint32_t dma_mode )
+void adc_sync_dma_config(uint32_t dma_mode)
{
ADC_SYNCCTL &= ~(ADC_SYNCCTL_SYNCDMA);
ADC_SYNCCTL |= dma_mode;
@@ -1191,12 +1192,12 @@ void adc_sync_dma_request_after_last_disable(void)
}
/*!
- \brief read ADC sync regular data register
+ \brief read ADC sync routine data register
\param[in] none
\param[out] none
- \retval sync regular data
+ \retval sync routine data
*/
-uint32_t adc_sync_regular_data_read(void)
+uint32_t adc_sync_routine_data_read(void)
{
return (uint32_t)ADC_SYNCDATA;
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_can.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_can.c
index 5eb2974739..09a246217c 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_can.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_can.c
@@ -7,10 +7,12 @@
\version 2019-11-27, V2.0.1, firmware for GD32F4xx
\version 2020-07-14, V2.0.2, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2021-12-28, V2.1.1, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -37,6 +39,7 @@ OF SUCH DAMAGE.
*/
#include "gd32f4xx_can.h"
+#include <stdlib.h>
#define CAN_ERROR_HANDLE(s) do{}while(1)
@@ -66,74 +69,77 @@ void can_deinit(uint32_t can_periph)
\arg CAN_FILTER_STRUCT: the CAN filter struct
\arg CAN_TX_MESSAGE_STRUCT: the CAN TX message struct
\arg CAN_RX_MESSAGE_STRUCT: the CAN RX message struct
- \param[in] p_struct: the pointer of the specific struct
- \param[out] none
+ \param[out] p_struct: the pointer of the specific struct
\retval none
*/
-void can_struct_para_init(can_struct_type_enum type, void* p_struct)
+void can_struct_para_init(can_struct_type_enum type, void *p_struct)
{
uint8_t i;
+ if(NULL == p_struct) {
+ CAN_ERROR_HANDLE("struct parameter can not be NULL \r\n");
+ }
+
/* get type of the struct */
- switch(type){
- /* used for can_init() */
- case CAN_INIT_STRUCT:
- ((can_parameter_struct*)p_struct)->auto_bus_off_recovery = DISABLE;
- ((can_parameter_struct*)p_struct)->no_auto_retrans = DISABLE;
- ((can_parameter_struct*)p_struct)->auto_wake_up = DISABLE;
- ((can_parameter_struct*)p_struct)->prescaler = 0x03FFU;
- ((can_parameter_struct*)p_struct)->rec_fifo_overwrite = DISABLE;
- ((can_parameter_struct*)p_struct)->resync_jump_width = CAN_BT_SJW_1TQ;
- ((can_parameter_struct*)p_struct)->time_segment_1 = CAN_BT_BS1_3TQ;
- ((can_parameter_struct*)p_struct)->time_segment_2 = CAN_BT_BS2_1TQ;
- ((can_parameter_struct*)p_struct)->time_triggered = DISABLE;
- ((can_parameter_struct*)p_struct)->trans_fifo_order = DISABLE;
- ((can_parameter_struct*)p_struct)->working_mode = CAN_NORMAL_MODE;
+ switch(type) {
+ /* used for can_init() */
+ case CAN_INIT_STRUCT:
+ ((can_parameter_struct *)p_struct)->auto_bus_off_recovery = DISABLE;
+ ((can_parameter_struct *)p_struct)->auto_retrans = DISABLE;
+ ((can_parameter_struct *)p_struct)->auto_wake_up = DISABLE;
+ ((can_parameter_struct *)p_struct)->prescaler = 0x03FFU;
+ ((can_parameter_struct *)p_struct)->rec_fifo_overwrite = DISABLE;
+ ((can_parameter_struct *)p_struct)->resync_jump_width = CAN_BT_SJW_1TQ;
+ ((can_parameter_struct *)p_struct)->time_segment_1 = CAN_BT_BS1_3TQ;
+ ((can_parameter_struct *)p_struct)->time_segment_2 = CAN_BT_BS2_1TQ;
+ ((can_parameter_struct *)p_struct)->time_triggered = DISABLE;
+ ((can_parameter_struct *)p_struct)->trans_fifo_order = DISABLE;
+ ((can_parameter_struct *)p_struct)->working_mode = CAN_NORMAL_MODE;
- break;
- /* used for can_filter_init() */
- case CAN_FILTER_STRUCT:
- ((can_filter_parameter_struct*)p_struct)->filter_bits = CAN_FILTERBITS_32BIT;
- ((can_filter_parameter_struct*)p_struct)->filter_enable = DISABLE;
- ((can_filter_parameter_struct*)p_struct)->filter_fifo_number = CAN_FIFO0;
- ((can_filter_parameter_struct*)p_struct)->filter_list_high = 0x0000U;
- ((can_filter_parameter_struct*)p_struct)->filter_list_low = 0x0000U;
- ((can_filter_parameter_struct*)p_struct)->filter_mask_high = 0x0000U;
- ((can_filter_parameter_struct*)p_struct)->filter_mask_low = 0x0000U;
- ((can_filter_parameter_struct*)p_struct)->filter_mode = CAN_FILTERMODE_MASK;
- ((can_filter_parameter_struct*)p_struct)->filter_number = 0U;
+ break;
+ /* used for can_filter_init() */
+ case CAN_FILTER_STRUCT:
+ ((can_filter_parameter_struct *)p_struct)->filter_bits = CAN_FILTERBITS_32BIT;
+ ((can_filter_parameter_struct *)p_struct)->filter_enable = DISABLE;
+ ((can_filter_parameter_struct *)p_struct)->filter_fifo_number = CAN_FIFO0;
+ ((can_filter_parameter_struct *)p_struct)->filter_list_high = 0x0000U;
+ ((can_filter_parameter_struct *)p_struct)->filter_list_low = 0x0000U;
+ ((can_filter_parameter_struct *)p_struct)->filter_mask_high = 0x0000U;
+ ((can_filter_parameter_struct *)p_struct)->filter_mask_low = 0x0000U;
+ ((can_filter_parameter_struct *)p_struct)->filter_mode = CAN_FILTERMODE_MASK;
+ ((can_filter_parameter_struct *)p_struct)->filter_number = 0U;
- break;
- /* used for can_message_transmit() */
- case CAN_TX_MESSAGE_STRUCT:
- for(i = 0U; i < 8U; i++){
- ((can_trasnmit_message_struct*)p_struct)->tx_data[i] = 0U;
- }
+ break;
+ /* used for can_message_transmit() */
+ case CAN_TX_MESSAGE_STRUCT:
+ for(i = 0U; i < 8U; i++) {
+ ((can_trasnmit_message_struct *)p_struct)->tx_data[i] = 0U;
+ }
- ((can_trasnmit_message_struct*)p_struct)->tx_dlen = 0u;
- ((can_trasnmit_message_struct*)p_struct)->tx_efid = 0U;
- ((can_trasnmit_message_struct*)p_struct)->tx_ff = (uint8_t)CAN_FF_STANDARD;
- ((can_trasnmit_message_struct*)p_struct)->tx_ft = (uint8_t)CAN_FT_DATA;
- ((can_trasnmit_message_struct*)p_struct)->tx_sfid = 0U;
+ ((can_trasnmit_message_struct *)p_struct)->tx_dlen = 0u;
+ ((can_trasnmit_message_struct *)p_struct)->tx_efid = 0U;
+ ((can_trasnmit_message_struct *)p_struct)->tx_ff = (uint8_t)CAN_FF_STANDARD;
+ ((can_trasnmit_message_struct *)p_struct)->tx_ft = (uint8_t)CAN_FT_DATA;
+ ((can_trasnmit_message_struct *)p_struct)->tx_sfid = 0U;
- break;
- /* used for can_message_receive() */
- case CAN_RX_MESSAGE_STRUCT:
- for(i = 0U; i < 8U; i++){
- ((can_receive_message_struct*)p_struct)->rx_data[i] = 0U;
- }
+ break;
+ /* used for can_message_receive() */
+ case CAN_RX_MESSAGE_STRUCT:
+ for(i = 0U; i < 8U; i++) {
+ ((can_receive_message_struct *)p_struct)->rx_data[i] = 0U;
+ }
- ((can_receive_message_struct*)p_struct)->rx_dlen = 0U;
- ((can_receive_message_struct*)p_struct)->rx_efid = 0U;
- ((can_receive_message_struct*)p_struct)->rx_ff = (uint8_t)CAN_FF_STANDARD;
- ((can_receive_message_struct*)p_struct)->rx_fi = 0U;
- ((can_receive_message_struct*)p_struct)->rx_ft = (uint8_t)CAN_FT_DATA;
- ((can_receive_message_struct*)p_struct)->rx_sfid = 0U;
+ ((can_receive_message_struct *)p_struct)->rx_dlen = 0U;
+ ((can_receive_message_struct *)p_struct)->rx_efid = 0U;
+ ((can_receive_message_struct *)p_struct)->rx_ff = (uint8_t)CAN_FF_STANDARD;
+ ((can_receive_message_struct *)p_struct)->rx_fi = 0U;
+ ((can_receive_message_struct *)p_struct)->rx_ft = (uint8_t)CAN_FT_DATA;
+ ((can_receive_message_struct *)p_struct)->rx_sfid = 0U;
- break;
+ break;
- default:
- CAN_ERROR_HANDLE("parameter is invalid \r\n");
+ default:
+ CAN_ERROR_HANDLE("parameter is invalid \r\n");
}
}
@@ -149,14 +155,14 @@ void can_struct_para_init(can_struct_type_enum type, void* p_struct)
\arg time_triggered: ENABLE or DISABLE
\arg auto_bus_off_recovery: ENABLE or DISABLE
\arg auto_wake_up: ENABLE or DISABLE
- \arg no_auto_retrans: ENABLE or DISABLE
+ \arg auto_retrans: ENABLE or DISABLE
\arg rec_fifo_overwrite: ENABLE or DISABLE
\arg trans_fifo_order: ENABLE or DISABLE
\arg prescaler: 0x0001 - 0x0400
\param[out] none
\retval ErrStatus: SUCCESS or ERROR
*/
-ErrStatus can_init(uint32_t can_periph, can_parameter_struct* can_parameter_init)
+ErrStatus can_init(uint32_t can_periph, can_parameter_struct *can_parameter_init)
{
uint32_t timeout = CAN_TIMEOUT;
ErrStatus flag = ERROR;
@@ -166,64 +172,65 @@ ErrStatus can_init(uint32_t can_periph, can_parameter_struct* can_parameter_init
/* enable initialize mode */
CAN_CTL(can_periph) |= CAN_CTL_IWMOD;
/* wait ACK */
- while((CAN_STAT_IWS != (CAN_STAT(can_periph) & CAN_STAT_IWS)) && (0U != timeout)){
+ while((CAN_STAT_IWS != (CAN_STAT(can_periph) & CAN_STAT_IWS)) && (0U != timeout)) {
timeout--;
}
/* check initialize working success */
- if(CAN_STAT_IWS != (CAN_STAT(can_periph) & CAN_STAT_IWS)){
+ if(CAN_STAT_IWS != (CAN_STAT(can_periph) & CAN_STAT_IWS)) {
flag = ERROR;
- }else{
+ } else {
/* set the bit timing register */
CAN_BT(can_periph) = (BT_MODE((uint32_t)can_parameter_init->working_mode) | \
BT_SJW((uint32_t)can_parameter_init->resync_jump_width) | \
BT_BS1((uint32_t)can_parameter_init->time_segment_1) | \
BT_BS2((uint32_t)can_parameter_init->time_segment_2) | \
BT_BAUDPSC(((uint32_t)(can_parameter_init->prescaler) - 1U)));
+
/* time trigger communication mode */
- if(ENABLE == can_parameter_init->time_triggered){
+ if(ENABLE == can_parameter_init->time_triggered) {
CAN_CTL(can_periph) |= CAN_CTL_TTC;
- }else{
+ } else {
CAN_CTL(can_periph) &= ~CAN_CTL_TTC;
}
- /* automatic bus-off managment */
- if(ENABLE == can_parameter_init->auto_bus_off_recovery){
+ /* automatic bus-off management */
+ if(ENABLE == can_parameter_init->auto_bus_off_recovery) {
CAN_CTL(can_periph) |= CAN_CTL_ABOR;
- }else{
+ } else {
CAN_CTL(can_periph) &= ~CAN_CTL_ABOR;
}
/* automatic wakeup mode */
- if(ENABLE == can_parameter_init->auto_wake_up){
+ if(ENABLE == can_parameter_init->auto_wake_up) {
CAN_CTL(can_periph) |= CAN_CTL_AWU;
- }else{
+ } else {
CAN_CTL(can_periph) &= ~CAN_CTL_AWU;
}
- /* automatic retransmission mode disable*/
- if(ENABLE == can_parameter_init->no_auto_retrans){
- CAN_CTL(can_periph) |= CAN_CTL_ARD;
- }else{
+ /* automatic retransmission mode */
+ if(ENABLE == can_parameter_init->auto_retrans) {
CAN_CTL(can_periph) &= ~CAN_CTL_ARD;
+ } else {
+ CAN_CTL(can_periph) |= CAN_CTL_ARD;
}
- /* receive fifo overwrite mode */
- if(ENABLE == can_parameter_init->rec_fifo_overwrite){
- CAN_CTL(can_periph) |= CAN_CTL_RFOD;
- }else{
+ /* receive FIFO overwrite mode */
+ if(ENABLE == can_parameter_init->rec_fifo_overwrite) {
CAN_CTL(can_periph) &= ~CAN_CTL_RFOD;
+ } else {
+ CAN_CTL(can_periph) |= CAN_CTL_RFOD;
}
- /* transmit fifo order */
- if(ENABLE == can_parameter_init->trans_fifo_order){
+ /* transmit FIFO order */
+ if(ENABLE == can_parameter_init->trans_fifo_order) {
CAN_CTL(can_periph) |= CAN_CTL_TFO;
- }else{
+ } else {
CAN_CTL(can_periph) &= ~CAN_CTL_TFO;
}
/* disable initialize mode */
CAN_CTL(can_periph) &= ~CAN_CTL_IWMOD;
timeout = CAN_TIMEOUT;
/* wait the ACK */
- while((CAN_STAT_IWS == (CAN_STAT(can_periph) & CAN_STAT_IWS)) && (0U != timeout)){
+ while((CAN_STAT_IWS == (CAN_STAT(can_periph) & CAN_STAT_IWS)) && (0U != timeout)) {
timeout--;
}
/* check exit initialize mode */
- if(CAN_STAT_IWS == (CAN_STAT(can_periph) & CAN_STAT_IWS)){
+ if(0U != timeout) {
flag = SUCCESS;
}
}
@@ -245,7 +252,7 @@ ErrStatus can_init(uint32_t can_periph, can_parameter_struct* can_parameter_init
\param[out] none
\retval none
*/
-void can_filter_init(can_filter_parameter_struct* can_filter_parameter_init)
+void can_filter_init(can_filter_parameter_struct *can_filter_parameter_init)
{
uint32_t val = 0U;
@@ -256,54 +263,52 @@ void can_filter_init(can_filter_parameter_struct* can_filter_parameter_init)
CAN_FW(CAN0) &= ~(uint32_t)val;
/* filter 16 bits */
- if(CAN_FILTERBITS_16BIT == can_filter_parameter_init->filter_bits){
+ if(CAN_FILTERBITS_16BIT == can_filter_parameter_init->filter_bits) {
/* set filter 16 bits */
CAN_FSCFG(CAN0) &= ~(uint32_t)val;
- /* first 16 bits list and first 16 bits mask or first 16 bits list and second 16 bits list */
+ /* first 16 bits list and first 16 bits mask or first 16 bits list and second 16 bits list */
CAN_FDATA0(CAN0, can_filter_parameter_init->filter_number) = \
- FDATA_MASK_HIGH((can_filter_parameter_init->filter_mask_low) & CAN_FILTER_MASK_16BITS) | \
- FDATA_MASK_LOW((can_filter_parameter_init->filter_list_low) & CAN_FILTER_MASK_16BITS);
- /* second 16 bits list and second 16 bits mask or third 16 bits list and fourth 16 bits list */
+ FDATA_MASK_HIGH((can_filter_parameter_init->filter_mask_low) & CAN_FILTER_MASK_16BITS) | \
+ FDATA_MASK_LOW((can_filter_parameter_init->filter_list_low) & CAN_FILTER_MASK_16BITS);
+ /* second 16 bits list and second 16 bits mask or third 16 bits list and fourth 16 bits list */
CAN_FDATA1(CAN0, can_filter_parameter_init->filter_number) = \
- FDATA_MASK_HIGH((can_filter_parameter_init->filter_mask_high) & CAN_FILTER_MASK_16BITS) | \
- FDATA_MASK_LOW((can_filter_parameter_init->filter_list_high) & CAN_FILTER_MASK_16BITS);
+ FDATA_MASK_HIGH((can_filter_parameter_init->filter_mask_high) & CAN_FILTER_MASK_16BITS) | \
+ FDATA_MASK_LOW((can_filter_parameter_init->filter_list_high) & CAN_FILTER_MASK_16BITS);
}
/* filter 32 bits */
- if(CAN_FILTERBITS_32BIT == can_filter_parameter_init->filter_bits){
+ if(CAN_FILTERBITS_32BIT == can_filter_parameter_init->filter_bits) {
/* set filter 32 bits */
CAN_FSCFG(CAN0) |= (uint32_t)val;
/* 32 bits list or first 32 bits list */
CAN_FDATA0(CAN0, can_filter_parameter_init->filter_number) = \
- FDATA_MASK_HIGH((can_filter_parameter_init->filter_list_high) & CAN_FILTER_MASK_16BITS) |
- FDATA_MASK_LOW((can_filter_parameter_init->filter_list_low) & CAN_FILTER_MASK_16BITS);
+ FDATA_MASK_HIGH((can_filter_parameter_init->filter_list_high) & CAN_FILTER_MASK_16BITS) |
+ FDATA_MASK_LOW((can_filter_parameter_init->filter_list_low) & CAN_FILTER_MASK_16BITS);
/* 32 bits mask or second 32 bits list */
CAN_FDATA1(CAN0, can_filter_parameter_init->filter_number) = \
- FDATA_MASK_HIGH((can_filter_parameter_init->filter_mask_high) & CAN_FILTER_MASK_16BITS) |
- FDATA_MASK_LOW((can_filter_parameter_init->filter_mask_low) & CAN_FILTER_MASK_16BITS);
+ FDATA_MASK_HIGH((can_filter_parameter_init->filter_mask_high) & CAN_FILTER_MASK_16BITS) |
+ FDATA_MASK_LOW((can_filter_parameter_init->filter_mask_low) & CAN_FILTER_MASK_16BITS);
}
/* filter mode */
- if(CAN_FILTERMODE_MASK == can_filter_parameter_init->filter_mode){
+ if(CAN_FILTERMODE_MASK == can_filter_parameter_init->filter_mode) {
/* mask mode */
CAN_FMCFG(CAN0) &= ~(uint32_t)val;
- }else{
+ } else {
/* list mode */
CAN_FMCFG(CAN0) |= (uint32_t)val;
}
/* filter FIFO */
- if(CAN_FIFO0 == (can_filter_parameter_init->filter_fifo_number)){
+ if(CAN_FIFO0 == (can_filter_parameter_init->filter_fifo_number)) {
/* FIFO0 */
CAN_FAFIFO(CAN0) &= ~(uint32_t)val;
- }
-
- if(CAN_FIFO1 == can_filter_parameter_init->filter_fifo_number){
+ } else {
/* FIFO1 */
CAN_FAFIFO(CAN0) |= (uint32_t)val;
}
/* filter working */
- if(ENABLE == can_filter_parameter_init->filter_enable){
+ if(ENABLE == can_filter_parameter_init->filter_enable) {
CAN_FW(CAN0) |= (uint32_t)val;
}
@@ -313,8 +318,9 @@ void can_filter_init(can_filter_parameter_struct* can_filter_parameter_init)
}
/*!
- \brief set CAN1 fliter start bank number
- \param[in] can1_start_bank_number
+ \brief set CAN1 filter start bank number
+ \param[in] start_bank: CAN1 start bank number
+ only one parameter can be selected which is shown as below:
\arg (1..27)
\param[out] none
\retval none
@@ -326,7 +332,7 @@ void can1_filter_start_bank(uint8_t start_bank)
/* set CAN1 filter start number */
CAN_FCTL(CAN0) &= ~(uint32_t)CAN_FCTL_HBC1F;
CAN_FCTL(CAN0) |= FCTL_HBC1F(start_bank);
- /* filter lock enaable */
+ /* filter lock enable */
CAN_FCTL(CAN0) &= ~CAN_FCTL_FLD;
}
@@ -339,8 +345,10 @@ void can1_filter_start_bank(uint8_t start_bank)
*/
void can_debug_freeze_enable(uint32_t can_periph)
{
+ /* set DFZ bit */
CAN_CTL(can_periph) |= CAN_CTL_DFZ;
- if(CAN0 == can_periph){
+
+ if(CAN0 == can_periph) {
dbg_periph_enable(DBG_CAN0_HOLD);
}else{
dbg_periph_enable(DBG_CAN1_HOLD);
@@ -356,11 +364,13 @@ void can_debug_freeze_enable(uint32_t can_periph)
*/
void can_debug_freeze_disable(uint32_t can_periph)
{
+ /* set DFZ bit */
CAN_CTL(can_periph) &= ~CAN_CTL_DFZ;
+
if(CAN0 == can_periph){
dbg_periph_disable(DBG_CAN0_HOLD);
}else{
- dbg_periph_disable(DBG_CAN0_HOLD);
+ dbg_periph_disable(DBG_CAN1_HOLD);
}
}
@@ -375,10 +385,10 @@ void can_time_trigger_mode_enable(uint32_t can_periph)
{
uint8_t mailbox_number;
- /* enable the tcc mode */
+ /* enable the TTC mode */
CAN_CTL(can_periph) |= CAN_CTL_TTC;
/* enable time stamp */
- for(mailbox_number = 0U; mailbox_number < 3U; mailbox_number++){
+ for(mailbox_number = 0U; mailbox_number < 3U; mailbox_number++) {
CAN_TMP(can_periph, mailbox_number) |= CAN_TMP_TSEN;
}
}
@@ -394,16 +404,16 @@ void can_time_trigger_mode_disable(uint32_t can_periph)
{
uint8_t mailbox_number;
- /* disable the TCC mode */
+ /* disable the TTC mode */
CAN_CTL(can_periph) &= ~CAN_CTL_TTC;
/* reset TSEN bits */
- for(mailbox_number = 0U; mailbox_number < 3U; mailbox_number++){
+ for(mailbox_number = 0U; mailbox_number < 3U; mailbox_number++) {
CAN_TMP(can_periph, mailbox_number) &= ~CAN_TMP_TSEN;
}
}
/*!
- \brief transmit CAN message
+ \brief transmit CAN message
\param[in] can_periph
\arg CANx(x=0,1)
\param[in] transmit_message: struct for CAN transmit message
@@ -416,49 +426,48 @@ void can_time_trigger_mode_disable(uint32_t can_periph)
\param[out] none
\retval mailbox_number
*/
-uint8_t can_message_transmit(uint32_t can_periph, can_trasnmit_message_struct* transmit_message)
+uint8_t can_message_transmit(uint32_t can_periph, can_trasnmit_message_struct *transmit_message)
{
uint8_t mailbox_number = CAN_MAILBOX0;
/* select one empty mailbox */
- if(CAN_TSTAT_TME0 == (CAN_TSTAT(can_periph)&CAN_TSTAT_TME0)){
+ if(CAN_TSTAT_TME0 == (CAN_TSTAT(can_periph)&CAN_TSTAT_TME0)) {
mailbox_number = CAN_MAILBOX0;
- }else if(CAN_TSTAT_TME1 == (CAN_TSTAT(can_periph)&CAN_TSTAT_TME1)){
+ } else if(CAN_TSTAT_TME1 == (CAN_TSTAT(can_periph)&CAN_TSTAT_TME1)) {
mailbox_number = CAN_MAILBOX1;
- }else if(CAN_TSTAT_TME2 == (CAN_TSTAT(can_periph)&CAN_TSTAT_TME2)){
+ } else if(CAN_TSTAT_TME2 == (CAN_TSTAT(can_periph)&CAN_TSTAT_TME2)) {
mailbox_number = CAN_MAILBOX2;
- }else{
+ } else {
mailbox_number = CAN_NOMAILBOX;
}
/* return no mailbox empty */
- if(CAN_NOMAILBOX == mailbox_number){
+ if(CAN_NOMAILBOX == mailbox_number) {
return CAN_NOMAILBOX;
}
CAN_TMI(can_periph, mailbox_number) &= CAN_TMI_TEN;
- if(CAN_FF_STANDARD == transmit_message->tx_ff){
+ if(CAN_FF_STANDARD == transmit_message->tx_ff) {
/* set transmit mailbox standard identifier */
CAN_TMI(can_periph, mailbox_number) |= (uint32_t)(TMI_SFID(transmit_message->tx_sfid) | \
- transmit_message->tx_ft);
- }else{
+ transmit_message->tx_ft);
+ } else {
/* set transmit mailbox extended identifier */
CAN_TMI(can_periph, mailbox_number) |= (uint32_t)(TMI_EFID(transmit_message->tx_efid) | \
- transmit_message->tx_ff | \
- transmit_message->tx_ft);
+ transmit_message->tx_ff | \
+ transmit_message->tx_ft);
}
/* set the data length */
- transmit_message->tx_dlen &= (uint8_t)(CAN_TMP_DLENC);
- CAN_TMP(can_periph, mailbox_number) &= ((uint32_t)~CAN_TMP_DLENC);
+ CAN_TMP(can_periph, mailbox_number) &= ~CAN_TMP_DLENC;
CAN_TMP(can_periph, mailbox_number) |= transmit_message->tx_dlen;
/* set the data */
CAN_TMDATA0(can_periph, mailbox_number) = TMDATA0_DB3(transmit_message->tx_data[3]) | \
- TMDATA0_DB2(transmit_message->tx_data[2]) | \
- TMDATA0_DB1(transmit_message->tx_data[1]) | \
- TMDATA0_DB0(transmit_message->tx_data[0]);
+ TMDATA0_DB2(transmit_message->tx_data[2]) | \
+ TMDATA0_DB1(transmit_message->tx_data[1]) | \
+ TMDATA0_DB0(transmit_message->tx_data[0]);
CAN_TMDATA1(can_periph, mailbox_number) = TMDATA1_DB7(transmit_message->tx_data[7]) | \
- TMDATA1_DB6(transmit_message->tx_data[6]) | \
- TMDATA1_DB5(transmit_message->tx_data[5]) | \
- TMDATA1_DB4(transmit_message->tx_data[4]);
+ TMDATA1_DB6(transmit_message->tx_data[6]) | \
+ TMDATA1_DB5(transmit_message->tx_data[5]) | \
+ TMDATA1_DB4(transmit_message->tx_data[4]);
/* enable transmission */
CAN_TMI(can_periph, mailbox_number) |= CAN_TMI_TEN;
@@ -481,7 +490,7 @@ can_transmit_state_enum can_transmit_states(uint32_t can_periph, uint8_t mailbox
uint32_t val = 0U;
/* check selected mailbox state */
- switch(mailbox_number){
+ switch(mailbox_number) {
/* mailbox0 */
case CAN_MAILBOX0:
val = CAN_TSTAT(can_periph) & (CAN_TSTAT_MTF0 | CAN_TSTAT_MTFNERR0 | CAN_TSTAT_TME0);
@@ -499,34 +508,24 @@ can_transmit_state_enum can_transmit_states(uint32_t can_periph, uint8_t mailbox
break;
}
- switch(val){
- /* transmit pending */
- case (CAN_STATE_PENDING):
+ switch(val) {
+ /* transmit pending */
+ case(CAN_STATE_PENDING):
state = CAN_TRANSMIT_PENDING;
break;
- /* transmit failed */
- case (CAN_TSTAT_MTF0 | CAN_TSTAT_TME0):
- state = CAN_TRANSMIT_FAILED;
- break;
- case (CAN_TSTAT_MTF1 | CAN_TSTAT_TME1):
- state = CAN_TRANSMIT_FAILED;
- break;
- case (CAN_TSTAT_MTF2 | CAN_TSTAT_TME2):
- state = CAN_TRANSMIT_FAILED;
- break;
- /* transmit succeeded */
- case (CAN_TSTAT_MTF0 | CAN_TSTAT_MTFNERR0 | CAN_TSTAT_TME0):
+ /* mailbox0 transmit succeeded */
+ case(CAN_TSTAT_MTF0 | CAN_TSTAT_MTFNERR0 | CAN_TSTAT_TME0):
state = CAN_TRANSMIT_OK;
break;
- /* mailbox1 transmit succeeded */
- case (CAN_TSTAT_MTF1 | CAN_TSTAT_MTFNERR1 | CAN_TSTAT_TME1):
+ /* mailbox1 transmit succeeded */
+ case(CAN_TSTAT_MTF1 | CAN_TSTAT_MTFNERR1 | CAN_TSTAT_TME1):
state = CAN_TRANSMIT_OK;
break;
- /* mailbox2 transmit succeeded */
- case (CAN_TSTAT_MTF2 | CAN_TSTAT_MTFNERR2 | CAN_TSTAT_TME2):
+ /* mailbox2 transmit succeeded */
+ case(CAN_TSTAT_MTF2 | CAN_TSTAT_MTFNERR2 | CAN_TSTAT_TME2):
state = CAN_TRANSMIT_OK;
break;
- /* transmit failed */
+ /* transmit failed */
default:
state = CAN_TRANSMIT_FAILED;
break;
@@ -546,19 +545,19 @@ can_transmit_state_enum can_transmit_states(uint32_t can_periph, uint8_t mailbox
*/
void can_transmission_stop(uint32_t can_periph, uint8_t mailbox_number)
{
- if(CAN_MAILBOX0 == mailbox_number){
+ if(CAN_MAILBOX0 == mailbox_number) {
CAN_TSTAT(can_periph) |= CAN_TSTAT_MST0;
- while(CAN_TSTAT_MST0 == (CAN_TSTAT(can_periph) & CAN_TSTAT_MST0)){
+ while(CAN_TSTAT_MST0 == (CAN_TSTAT(can_periph) & CAN_TSTAT_MST0)) {
}
- }else if(CAN_MAILBOX1 == mailbox_number){
+ } else if(CAN_MAILBOX1 == mailbox_number) {
CAN_TSTAT(can_periph) |= CAN_TSTAT_MST1;
- while(CAN_TSTAT_MST1 == (CAN_TSTAT(can_periph) & CAN_TSTAT_MST1)){
+ while(CAN_TSTAT_MST1 == (CAN_TSTAT(can_periph) & CAN_TSTAT_MST1)) {
}
- }else if(CAN_MAILBOX2 == mailbox_number){
+ } else if(CAN_MAILBOX2 == mailbox_number) {
CAN_TSTAT(can_periph) |= CAN_TSTAT_MST2;
- while(CAN_TSTAT_MST2 == (CAN_TSTAT(can_periph) & CAN_TSTAT_MST2)){
+ while(CAN_TSTAT_MST2 == (CAN_TSTAT(can_periph) & CAN_TSTAT_MST2)) {
}
- }else{
+ } else {
/* illegal parameters */
}
}
@@ -579,14 +578,14 @@ void can_transmission_stop(uint32_t can_periph, uint8_t mailbox_number)
\arg rx_fi: 0 - 27
\retval none
*/
-void can_message_receive(uint32_t can_periph, uint8_t fifo_number, can_receive_message_struct* receive_message)
+void can_message_receive(uint32_t can_periph, uint8_t fifo_number, can_receive_message_struct *receive_message)
{
/* get the frame format */
receive_message->rx_ff = (uint8_t)(CAN_RFIFOMI_FF & CAN_RFIFOMI(can_periph, fifo_number));
- if(CAN_FF_STANDARD == receive_message->rx_ff){
+ if(CAN_FF_STANDARD == receive_message->rx_ff) {
/* get standard identifier */
receive_message->rx_sfid = (uint32_t)(GET_RFIFOMI_SFID(CAN_RFIFOMI(can_periph, fifo_number)));
- }else{
+ } else {
/* get extended identifier */
receive_message->rx_efid = (uint32_t)(GET_RFIFOMI_EFID(CAN_RFIFOMI(can_periph, fifo_number)));
}
@@ -595,7 +594,7 @@ void can_message_receive(uint32_t can_periph, uint8_t fifo_number, can_receive_m
receive_message->rx_ft = (uint8_t)(CAN_RFIFOMI_FT & CAN_RFIFOMI(can_periph, fifo_number));
/* filtering index */
receive_message->rx_fi = (uint8_t)(GET_RFIFOMP_FI(CAN_RFIFOMP(can_periph, fifo_number)));
- /* get recevie data length */
+ /* get receive data length */
receive_message->rx_dlen = (uint8_t)(GET_RFIFOMP_DLENC(CAN_RFIFOMP(can_periph, fifo_number)));
/* receive data */
@@ -609,15 +608,15 @@ void can_message_receive(uint32_t can_periph, uint8_t fifo_number, can_receive_m
receive_message -> rx_data[7] = (uint8_t)(GET_RFIFOMDATA1_DB7(CAN_RFIFOMDATA1(can_periph, fifo_number)));
/* release FIFO */
- if(CAN_FIFO0 == fifo_number){
+ if(CAN_FIFO0 == fifo_number) {
CAN_RFIFO0(can_periph) |= CAN_RFIFO0_RFD0;
- }else{
+ } else {
CAN_RFIFO1(can_periph) |= CAN_RFIFO1_RFD1;
}
}
/*!
- \brief release FIFO0
+ \brief release FIFO
\param[in] can_periph
\arg CANx(x=0,1)
\param[in] fifo_number
@@ -628,11 +627,11 @@ void can_message_receive(uint32_t can_periph, uint8_t fifo_number, can_receive_m
*/
void can_fifo_release(uint32_t can_periph, uint8_t fifo_number)
{
- if(CAN_FIFO0 == fifo_number){
+ if(CAN_FIFO0 == fifo_number) {
CAN_RFIFO0(can_periph) |= CAN_RFIFO0_RFD0;
- }else if(CAN_FIFO1 == fifo_number){
+ } else if(CAN_FIFO1 == fifo_number) {
CAN_RFIFO1(can_periph) |= CAN_RFIFO1_RFD1;
- }else{
+ } else {
/* illegal parameters */
CAN_ERROR_HANDLE("CAN FIFO NUM is invalid \r\n");
}
@@ -652,13 +651,13 @@ uint8_t can_receive_message_length_get(uint32_t can_periph, uint8_t fifo_number)
{
uint8_t val = 0U;
- if(CAN_FIFO0 == fifo_number){
+ if(CAN_FIFO0 == fifo_number) {
/* FIFO0 */
val = (uint8_t)(CAN_RFIFO0(can_periph) & CAN_RFIF_RFL_MASK);
- }else if(CAN_FIFO1 == fifo_number){
+ } else if(CAN_FIFO1 == fifo_number) {
/* FIFO1 */
val = (uint8_t)(CAN_RFIFO1(can_periph) & CAN_RFIF_RFL_MASK);
- }else{
+ } else {
/* illegal parameters */
}
return val;
@@ -682,47 +681,47 @@ ErrStatus can_working_mode_set(uint32_t can_periph, uint8_t working_mode)
/* timeout for IWS or also for SLPWS bits */
uint32_t timeout = CAN_TIMEOUT;
- if(CAN_MODE_INITIALIZE == working_mode){
+ if(CAN_MODE_INITIALIZE == working_mode) {
/* disable sleep mode */
CAN_CTL(can_periph) &= (~(uint32_t)CAN_CTL_SLPWMOD);
/* set initialize mode */
CAN_CTL(can_periph) |= (uint8_t)CAN_CTL_IWMOD;
/* wait the acknowledge */
- while((CAN_STAT_IWS != (CAN_STAT(can_periph) & CAN_STAT_IWS)) && (0U != timeout)){
+ while((CAN_STAT_IWS != (CAN_STAT(can_periph) & CAN_STAT_IWS)) && (0U != timeout)) {
timeout--;
}
- if(CAN_STAT_IWS != (CAN_STAT(can_periph) & CAN_STAT_IWS)){
+ if(CAN_STAT_IWS != (CAN_STAT(can_periph) & CAN_STAT_IWS)) {
flag = ERROR;
- }else{
+ } else {
flag = SUCCESS;
}
- }else if(CAN_MODE_NORMAL == working_mode){
+ } else if(CAN_MODE_NORMAL == working_mode) {
/* enter normal mode */
CAN_CTL(can_periph) &= ~(uint32_t)(CAN_CTL_SLPWMOD | CAN_CTL_IWMOD);
/* wait the acknowledge */
- while((0U != (CAN_STAT(can_periph) & (CAN_STAT_IWS | CAN_STAT_SLPWS))) && (0U != timeout)){
+ while((0U != (CAN_STAT(can_periph) & (CAN_STAT_IWS | CAN_STAT_SLPWS))) && (0U != timeout)) {
timeout--;
}
- if(0U != (CAN_STAT(can_periph) & (CAN_STAT_IWS | CAN_STAT_SLPWS))){
+ if(0U != (CAN_STAT(can_periph) & (CAN_STAT_IWS | CAN_STAT_SLPWS))) {
flag = ERROR;
- }else{
+ } else {
flag = SUCCESS;
}
- }else if(CAN_MODE_SLEEP == working_mode){
+ } else if(CAN_MODE_SLEEP == working_mode) {
/* disable initialize mode */
CAN_CTL(can_periph) &= (~(uint32_t)CAN_CTL_IWMOD);
/* set sleep mode */
CAN_CTL(can_periph) |= (uint8_t)CAN_CTL_SLPWMOD;
/* wait the acknowledge */
- while((CAN_STAT_SLPWS != (CAN_STAT(can_periph) & CAN_STAT_SLPWS)) && (0U != timeout)){
+ while((CAN_STAT_SLPWS != (CAN_STAT(can_periph) & CAN_STAT_SLPWS)) && (0U != timeout)) {
timeout--;
}
- if(CAN_STAT_SLPWS != (CAN_STAT(can_periph) & CAN_STAT_SLPWS)){
+ if(CAN_STAT_SLPWS != (CAN_STAT(can_periph) & CAN_STAT_SLPWS)) {
flag = ERROR;
- }else{
+ } else {
flag = SUCCESS;
}
- }else{
+ } else {
flag = ERROR;
}
return flag;
@@ -743,13 +742,13 @@ ErrStatus can_wakeup(uint32_t can_periph)
/* wakeup */
CAN_CTL(can_periph) &= ~CAN_CTL_SLPWMOD;
- while((0U != (CAN_STAT(can_periph) & CAN_STAT_SLPWS)) && (0x00U != timeout)){
+ while((0U != (CAN_STAT(can_periph) & CAN_STAT_SLPWS)) && (0x00U != timeout)) {
timeout--;
}
/* check state */
- if(0U != (CAN_STAT(can_periph) & CAN_STAT_SLPWS)){
+ if(0U != (CAN_STAT(can_periph) & CAN_STAT_SLPWS)) {
flag = ERROR;
- }else{
+ } else {
flag = SUCCESS;
}
return flag;
@@ -812,62 +811,6 @@ uint8_t can_transmit_error_number_get(uint32_t can_periph)
}
/*!
- \brief enable CAN interrupt
- \param[in] can_periph
- \arg CANx(x=0,1)
- \param[in] interrupt
- one or more parameters can be selected which are shown as below:
- \arg CAN_INT_TME: transmit mailbox empty interrupt enable
- \arg CAN_INT_RFNE0: receive FIFO0 not empty interrupt enable
- \arg CAN_INT_RFF0: receive FIFO0 full interrupt enable
- \arg CAN_INT_RFO0: receive FIFO0 overfull interrupt enable
- \arg CAN_INT_RFNE1: receive FIFO1 not empty interrupt enable
- \arg CAN_INT_RFF1: receive FIFO1 full interrupt enable
- \arg CAN_INT_RFO1: receive FIFO1 overfull interrupt enable
- \arg CAN_INT_WERR: warning error interrupt enable
- \arg CAN_INT_PERR: passive error interrupt enable
- \arg CAN_INT_BO: bus-off interrupt enable
- \arg CAN_INT_ERRN: error number interrupt enable
- \arg CAN_INT_ERR: error interrupt enable
- \arg CAN_INT_WU: wakeup interrupt enable
- \arg CAN_INT_SLPW: sleep working interrupt enable
- \param[out] none
- \retval none
-*/
-void can_interrupt_enable(uint32_t can_periph, uint32_t interrupt)
-{
- CAN_INTEN(can_periph) |= interrupt;
-}
-
-/*!
- \brief disable CAN interrupt
- \param[in] can_periph
- \arg CANx(x=0,1)
- \param[in] interrupt
- one or more parameters can be selected which are shown as below:
- \arg CAN_INT_TME: transmit mailbox empty interrupt enable
- \arg CAN_INT_RFNE0: receive FIFO0 not empty interrupt enable
- \arg CAN_INT_RFF0: receive FIFO0 full interrupt enable
- \arg CAN_INT_RFO0: receive FIFO0 overfull interrupt enable
- \arg CAN_INT_RFNE1: receive FIFO1 not empty interrupt enable
- \arg CAN_INT_RFF1: receive FIFO1 full interrupt enable
- \arg CAN_INT_RFO1: receive FIFO1 overfull interrupt enable
- \arg CAN_INT_WERR: warning error interrupt enable
- \arg CAN_INT_PERR: passive error interrupt enable
- \arg CAN_INT_BO: bus-off interrupt enable
- \arg CAN_INT_ERRN: error number interrupt enable
- \arg CAN_INT_ERR: error interrupt enable
- \arg CAN_INT_WU: wakeup interrupt enable
- \arg CAN_INT_SLPW: sleep working interrupt enable
- \param[out] none
- \retval none
-*/
-void can_interrupt_disable(uint32_t can_periph, uint32_t interrupt)
-{
- CAN_INTEN(can_periph) &= ~interrupt;
-}
-
-/*!
\brief get CAN flag state
\param[in] can_periph
\arg CANx(x=0,1)
@@ -882,9 +825,9 @@ void can_interrupt_disable(uint32_t can_periph, uint32_t interrupt)
\arg CAN_FLAG_ERRIF: error flag
\arg CAN_FLAG_SLPWS: sleep working state
\arg CAN_FLAG_IWS: initial working state
- \arg CAN_FLAG_TMLS2: transmit mailbox 2 last sending in Tx FIFO
- \arg CAN_FLAG_TMLS1: transmit mailbox 1 last sending in Tx FIFO
- \arg CAN_FLAG_TMLS0: transmit mailbox 0 last sending in Tx FIFO
+ \arg CAN_FLAG_TMLS2: transmit mailbox 2 last sending in TX FIFO
+ \arg CAN_FLAG_TMLS1: transmit mailbox 1 last sending in TX FIFO
+ \arg CAN_FLAG_TMLS0: transmit mailbox 0 last sending in TX FIFO
\arg CAN_FLAG_TME2: transmit mailbox 2 empty
\arg CAN_FLAG_TME1: transmit mailbox 1 empty
\arg CAN_FLAG_TME0: transmit mailbox 0 empty
@@ -913,9 +856,9 @@ void can_interrupt_disable(uint32_t can_periph, uint32_t interrupt)
FlagStatus can_flag_get(uint32_t can_periph, can_flag_enum flag)
{
/* get flag and interrupt enable state */
- if(RESET != (CAN_REG_VAL(can_periph, flag) & BIT(CAN_BIT_POS(flag)))){
+ if(RESET != (CAN_REG_VAL(can_periph, flag) & BIT(CAN_BIT_POS(flag)))) {
return SET;
- }else{
+ } else {
return RESET;
}
}
@@ -954,6 +897,62 @@ void can_flag_clear(uint32_t can_periph, can_flag_enum flag)
}
/*!
+ \brief enable CAN interrupt
+ \param[in] can_periph
+ \arg CANx(x=0,1)
+ \param[in] interrupt
+ one or more parameters can be selected which are shown as below:
+ \arg CAN_INT_TME: transmit mailbox empty interrupt enable
+ \arg CAN_INT_RFNE0: receive FIFO0 not empty interrupt enable
+ \arg CAN_INT_RFF0: receive FIFO0 full interrupt enable
+ \arg CAN_INT_RFO0: receive FIFO0 overfull interrupt enable
+ \arg CAN_INT_RFNE1: receive FIFO1 not empty interrupt enable
+ \arg CAN_INT_RFF1: receive FIFO1 full interrupt enable
+ \arg CAN_INT_RFO1: receive FIFO1 overfull interrupt enable
+ \arg CAN_INT_WERR: warning error interrupt enable
+ \arg CAN_INT_PERR: passive error interrupt enable
+ \arg CAN_INT_BO: bus-off interrupt enable
+ \arg CAN_INT_ERRN: error number interrupt enable
+ \arg CAN_INT_ERR: error interrupt enable
+ \arg CAN_INT_WAKEUP: wakeup interrupt enable
+ \arg CAN_INT_SLPW: sleep working interrupt enable
+ \param[out] none
+ \retval none
+*/
+void can_interrupt_enable(uint32_t can_periph, uint32_t interrupt)
+{
+ CAN_INTEN(can_periph) |= interrupt;
+}
+
+/*!
+ \brief disable CAN interrupt
+ \param[in] can_periph
+ \arg CANx(x=0,1)
+ \param[in] interrupt
+ one or more parameters can be selected which are shown as below:
+ \arg CAN_INT_TME: transmit mailbox empty interrupt enable
+ \arg CAN_INT_RFNE0: receive FIFO0 not empty interrupt enable
+ \arg CAN_INT_RFF0: receive FIFO0 full interrupt enable
+ \arg CAN_INT_RFO0: receive FIFO0 overfull interrupt enable
+ \arg CAN_INT_RFNE1: receive FIFO1 not empty interrupt enable
+ \arg CAN_INT_RFF1: receive FIFO1 full interrupt enable
+ \arg CAN_INT_RFO1: receive FIFO1 overfull interrupt enable
+ \arg CAN_INT_WERR: warning error interrupt enable
+ \arg CAN_INT_PERR: passive error interrupt enable
+ \arg CAN_INT_BO: bus-off interrupt enable
+ \arg CAN_INT_ERRN: error number interrupt enable
+ \arg CAN_INT_ERR: error interrupt enable
+ \arg CAN_INT_WAKEUP: wakeup interrupt enable
+ \arg CAN_INT_SLPW: sleep working interrupt enable
+ \param[out] none
+ \retval none
+*/
+void can_interrupt_disable(uint32_t can_periph, uint32_t interrupt)
+{
+ CAN_INTEN(can_periph) &= ~interrupt;
+}
+
+/*!
\brief get CAN interrupt flag state
\param[in] can_periph
\arg CANx(x=0,1)
@@ -983,28 +982,28 @@ FlagStatus can_interrupt_flag_get(uint32_t can_periph, can_interrupt_flag_enum f
uint32_t ret1 = RESET;
uint32_t ret2 = RESET;
- /* get the staus of interrupt flag */
- if (flag == CAN_INT_FLAG_RFF0) {
+ /* get the status of interrupt flag */
+ if(flag == CAN_INT_FLAG_RFL0) {
ret1 = can_receive_message_length_get(can_periph, CAN_FIFO0);
- } else if (flag == CAN_INT_FLAG_RFF1) {
+ } else if(flag == CAN_INT_FLAG_RFL1) {
ret1 = can_receive_message_length_get(can_periph, CAN_FIFO1);
- } else if (flag == CAN_INT_FLAG_ERRN) {
+ } else if(flag == CAN_INT_FLAG_ERRN) {
ret1 = can_error_get(can_periph);
} else {
ret1 = CAN_REG_VALS(can_periph, flag) & BIT(CAN_BIT_POS0(flag));
}
- /* get the staus of interrupt enale bit */
+ /* get the status of interrupt enable bit */
ret2 = CAN_INTEN(can_periph) & BIT(CAN_BIT_POS1(flag));
- if(ret1 && ret2){
+ if(ret1 && ret2) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
\brief clear CAN interrupt flag state
- \param[in] can_periph
+ \param[in] can_periph
\arg CANx(x=0,1)
\param[in] flag: CAN interrupt flags, refer to can_interrupt_flag_enum
only one parameter can be selected which is shown as below:
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_crc.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_crc.c
index bfe79cb9aa..24bf512870 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_crc.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_crc.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -38,6 +39,7 @@ OF SUCH DAMAGE.
#define CRC_DATA_RESET_VALUE ((uint32_t)0xFFFFFFFFU)
#define CRC_FDATA_RESET_VALUE ((uint32_t)0x00000000U)
+
/*!
\brief deinit CRC calculation unit
\param[in] none
@@ -121,7 +123,7 @@ uint32_t crc_single_data_calculate(uint32_t sdata)
uint32_t crc_block_data_calculate(uint32_t array[], uint32_t size)
{
uint32_t index;
- for(index = 0U; index < size; index++){
+ for(index = 0U; index < size; index++) {
CRC_DATA = array[index];
}
return (CRC_DATA);
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_ctc.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_ctc.c
index ab67c4ad73..4ae5ccde4e 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_ctc.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_ctc.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -45,7 +46,7 @@ OF SUCH DAMAGE.
#define CTC_LIMIT_VALUE_OFFSET ((uint32_t)16U)
/*!
- \brief reset CTC clock trim controller
+ \brief reset CTC clock trim controller
\param[in] none
\param[out] none
\retval none
@@ -58,7 +59,7 @@ void ctc_deinit(void)
}
/*!
- \brief enable CTC trim counter
+ \brief enable CTC trim counter
\param[in] none
\param[out] none
\retval none
@@ -69,7 +70,7 @@ void ctc_counter_enable(void)
}
/*!
- \brief disable CTC trim counter
+ \brief disable CTC trim counter
\param[in] none
\param[out] none
\retval none
@@ -80,7 +81,7 @@ void ctc_counter_disable(void)
}
/*!
- \brief configure the IRC48M trim value
+ \brief configure the IRC48M trim value
\param[in] ctc_trim_value: 8-bit IRC48M trim value
\arg 0x00 - 0x3F
\param[out] none
@@ -95,7 +96,7 @@ void ctc_irc48m_trim_value_config(uint8_t trim_value)
}
/*!
- \brief generate software reference source sync pulse
+ \brief generate software reference source sync pulse
\param[in] none
\param[out] none
\retval none
@@ -106,7 +107,7 @@ void ctc_software_refsource_pulse_generate(void)
}
/*!
- \brief configure hardware automatically trim mode
+ \brief configure hardware automatically trim mode
\param[in] hardmode:
only one parameter can be selected which is shown as below:
\arg CTC_HARDWARE_TRIM_MODE_ENABLE: hardware automatically trim mode enable
@@ -121,7 +122,7 @@ void ctc_hardware_trim_mode_config(uint32_t hardmode)
}
/*!
- \brief configure reference signal source polarity
+ \brief configure reference signal source polarity
\param[in] polarity:
only one parameter can be selected which is shown as below:
\arg CTC_REFSOURCE_POLARITY_FALLING: reference signal source polarity is falling edge
@@ -136,26 +137,11 @@ void ctc_refsource_polarity_config(uint32_t polarity)
}
/*!
- \brief select USBFS or USBHS SOF signal
- \param[in] usbsof:
- \arg CTC_USBSOFSEL_USBHS: USBHS SOF signal is selected
- \arg CTC_USBSOFSEL_USBFS: USBFS SOF signal is selected
- \param[out] none
- \retval none
-*/
-void ctc_usbsof_signal_select(uint32_t usbsof)
-{
- CTC_CTL1 &= (uint32_t)(~CTC_CTL1_USBSOFSEL);
- CTC_CTL1 |= (uint32_t)usbsof;
-}
-
-/*!
- \brief select reference signal source
+ \brief select reference signal source
\param[in] refs:
only one parameter can be selected which is shown as below:
\arg CTC_REFSOURCE_GPIO: GPIO is selected
\arg CTC_REFSOURCE_LXTAL: LXTAL is selected
- \arg CTC_REFSOURCE_USBSOF: USBSOF is selected
\param[out] none
\retval none
*/
@@ -166,7 +152,7 @@ void ctc_refsource_signal_select(uint32_t refs)
}
/*!
- \brief configure reference signal source prescaler
+ \brief configure reference signal source prescaler
\param[in] prescaler:
only one parameter can be selected which is shown as below:
\arg CTC_REFSOURCE_PSC_OFF: reference signal not divided
@@ -187,7 +173,7 @@ void ctc_refsource_prescaler_config(uint32_t prescaler)
}
/*!
- \brief configure clock trim base limit value
+ \brief configure clock trim base limit value
\param[in] limit_value: 8-bit clock trim base limit value
\arg 0x00 - 0xFF
\param[out] none
@@ -200,7 +186,7 @@ void ctc_clock_limit_value_config(uint8_t limit_value)
}
/*!
- \brief configure CTC counter reload value
+ \brief configure CTC counter reload value
\param[in] reload_value: 16-bit CTC counter reload value
\arg 0x0000 - 0xFFFF
\param[out] none
@@ -213,7 +199,7 @@ void ctc_counter_reload_value_config(uint16_t reload_value)
}
/*!
- \brief read CTC counter capture value when reference sync pulse occurred
+ \brief read CTC counter capture value when reference sync pulse occurred
\param[in] none
\param[out] none
\retval the 16-bit CTC counter capture value
@@ -221,12 +207,12 @@ void ctc_counter_reload_value_config(uint16_t reload_value)
uint16_t ctc_counter_capture_value_read(void)
{
uint16_t capture_value = 0U;
- capture_value = (uint16_t)((CTC_STAT & CTC_STAT_REFCAP)>> CTC_REFCAP_OFFSET);
+ capture_value = (uint16_t)((CTC_STAT & CTC_STAT_REFCAP) >> CTC_REFCAP_OFFSET);
return (capture_value);
}
/*!
- \brief read CTC trim counter direction when reference sync pulse occurred
+ \brief read CTC trim counter direction when reference sync pulse occurred
\param[in] none
\param[out] none
\retval FlagStatus: SET or RESET
@@ -235,15 +221,15 @@ uint16_t ctc_counter_capture_value_read(void)
*/
FlagStatus ctc_counter_direction_read(void)
{
- if(RESET != (CTC_STAT & CTC_STAT_REFDIR)){
+ if(RESET != (CTC_STAT & CTC_STAT_REFDIR)) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief read CTC counter reload value
+ \brief read CTC counter reload value
\param[in] none
\param[out] none
\retval the 16-bit CTC counter reload value
@@ -256,7 +242,7 @@ uint16_t ctc_counter_reload_value_read(void)
}
/*!
- \brief read the IRC48M trim value
+ \brief read the IRC48M trim value
\param[in] none
\param[out] none
\retval the 8-bit IRC48M trim value
@@ -269,7 +255,7 @@ uint8_t ctc_irc48m_trim_value_read(void)
}
/*!
- \brief enable the CTC interrupt
+ \brief enable the CTC interrupt
\param[in] interrupt: CTC interrupt enable
one or more parameters can be selected which are shown as below:
\arg CTC_INT_CKOK: clock trim OK interrupt enable
@@ -285,7 +271,7 @@ void ctc_interrupt_enable(uint32_t interrupt)
}
/*!
- \brief disable the CTC interrupt
+ \brief disable the CTC interrupt
\param[in] interrupt: CTC interrupt enable source
one or more parameters can be selected which are shown as below:
\arg CTC_INT_CKOK: clock trim OK interrupt enable
@@ -301,7 +287,7 @@ void ctc_interrupt_disable(uint32_t interrupt)
}
/*!
- \brief get CTC interrupt flag
+ \brief get CTC interrupt flag
\param[in] int_flag: the CTC interrupt flag
only one parameter can be selected which is shown as below:
\arg CTC_INT_FLAG_CKOK: clock trim OK interrupt
@@ -319,24 +305,24 @@ FlagStatus ctc_interrupt_flag_get(uint32_t int_flag)
uint32_t interrupt_flag = 0U, intenable = 0U;
/* check whether the interrupt is enabled */
- if(RESET != (int_flag & CTC_FLAG_MASK)){
+ if(RESET != (int_flag & CTC_FLAG_MASK)) {
intenable = CTC_CTL0 & CTC_CTL0_ERRIE;
- }else{
+ } else {
intenable = CTC_CTL0 & int_flag;
}
/* get interrupt flag status */
interrupt_flag = CTC_STAT & int_flag;
- if(interrupt_flag && intenable){
+ if(interrupt_flag && intenable) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief clear CTC interrupt flag
+ \brief clear CTC interrupt flag
\param[in] int_flag: the CTC interrupt flag
only one parameter can be selected which is shown as below:
\arg CTC_INT_FLAG_CKOK: clock trim OK interrupt
@@ -351,15 +337,15 @@ FlagStatus ctc_interrupt_flag_get(uint32_t int_flag)
*/
void ctc_interrupt_flag_clear(uint32_t int_flag)
{
- if(RESET != (int_flag & CTC_FLAG_MASK)){
+ if(RESET != (int_flag & CTC_FLAG_MASK)) {
CTC_INTC |= CTC_INTC_ERRIC;
- }else{
+ } else {
CTC_INTC |= int_flag;
}
}
/*!
- \brief get CTC flag
+ \brief get CTC flag
\param[in] flag: the CTC flag
only one parameter can be selected which is shown as below:
\arg CTC_FLAG_CKOK: clock trim OK flag
@@ -374,15 +360,15 @@ void ctc_interrupt_flag_clear(uint32_t int_flag)
*/
FlagStatus ctc_flag_get(uint32_t flag)
{
- if(RESET != (CTC_STAT & flag)){
+ if(RESET != (CTC_STAT & flag)) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief clear CTC flag
+ \brief clear CTC flag
\param[in] flag: the CTC flag
only one parameter can be selected which is shown as below:
\arg CTC_FLAG_CKOK: clock trim OK flag
@@ -397,9 +383,9 @@ FlagStatus ctc_flag_get(uint32_t flag)
*/
void ctc_flag_clear(uint32_t flag)
{
- if(RESET != (flag & CTC_FLAG_MASK)){
+ if(RESET != (flag & CTC_FLAG_MASK)) {
CTC_INTC |= CTC_INTC_ERRIC;
- }else{
+ } else {
CTC_INTC |= flag;
}
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dac.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dac.c
index 3a5dd52cdd..e92ea25d32 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dac.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dac.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -61,9 +62,9 @@ void dac_deinit(void)
*/
void dac_enable(uint32_t dac_periph)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
DAC_CTL |= DAC_CTL_DEN0;
- }else{
+ } else {
DAC_CTL |= DAC_CTL_DEN1;
}
}
@@ -76,9 +77,9 @@ void dac_enable(uint32_t dac_periph)
*/
void dac_disable(uint32_t dac_periph)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
DAC_CTL &= ~DAC_CTL_DEN0;
- }else{
+ } else {
DAC_CTL &= ~DAC_CTL_DEN1;
}
}
@@ -91,9 +92,9 @@ void dac_disable(uint32_t dac_periph)
*/
void dac_dma_enable(uint32_t dac_periph)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
DAC_CTL |= DAC_CTL_DDMAEN0;
- }else{
+ } else {
DAC_CTL |= DAC_CTL_DDMAEN1;
}
}
@@ -106,9 +107,9 @@ void dac_dma_enable(uint32_t dac_periph)
*/
void dac_dma_disable(uint32_t dac_periph)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
DAC_CTL &= ~DAC_CTL_DDMAEN0;
- }else{
+ } else {
DAC_CTL &= ~DAC_CTL_DDMAEN1;
}
}
@@ -121,9 +122,9 @@ void dac_dma_disable(uint32_t dac_periph)
*/
void dac_output_buffer_enable(uint32_t dac_periph)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
DAC_CTL &= ~DAC_CTL_DBOFF0;
- }else{
+ } else {
DAC_CTL &= ~DAC_CTL_DBOFF1;
}
}
@@ -136,9 +137,9 @@ void dac_output_buffer_enable(uint32_t dac_periph)
*/
void dac_output_buffer_disable(uint32_t dac_periph)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
DAC_CTL |= DAC_CTL_DBOFF0;
- }else{
+ } else {
DAC_CTL |= DAC_CTL_DBOFF1;
}
}
@@ -152,10 +153,10 @@ void dac_output_buffer_disable(uint32_t dac_periph)
uint16_t dac_output_value_get(uint32_t dac_periph)
{
uint16_t data = 0U;
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
/* store the DAC0 output value */
data = (uint16_t)DAC0_DO;
- }else{
+ } else {
/* store the DAC1 output value */
data = (uint16_t)DAC1_DO;
}
@@ -176,8 +177,8 @@ uint16_t dac_output_value_get(uint32_t dac_periph)
*/
void dac_data_set(uint32_t dac_periph, uint32_t dac_align, uint16_t data)
{
- if(DAC0 == dac_periph){
- switch(dac_align){
+ if(DAC0 == dac_periph) {
+ switch(dac_align) {
/* data right 12 bit alignment */
case DAC_ALIGN_12B_R:
DAC0_R12DH = data;
@@ -193,8 +194,8 @@ void dac_data_set(uint32_t dac_periph, uint32_t dac_align, uint16_t data)
default:
break;
}
- }else{
- switch(dac_align){
+ } else {
+ switch(dac_align) {
/* data right 12 bit alignment */
case DAC_ALIGN_12B_R:
DAC1_R12DH = data;
@@ -221,9 +222,9 @@ void dac_data_set(uint32_t dac_periph, uint32_t dac_align, uint16_t data)
*/
void dac_trigger_enable(uint32_t dac_periph)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
DAC_CTL |= DAC_CTL_DTEN0;
- }else{
+ } else {
DAC_CTL |= DAC_CTL_DTEN1;
}
}
@@ -236,9 +237,9 @@ void dac_trigger_enable(uint32_t dac_periph)
*/
void dac_trigger_disable(uint32_t dac_periph)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
DAC_CTL &= ~DAC_CTL_DTEN0;
- }else{
+ } else {
DAC_CTL &= ~DAC_CTL_DTEN1;
}
}
@@ -259,13 +260,13 @@ void dac_trigger_disable(uint32_t dac_periph)
\param[out] none
\retval none
*/
-void dac_trigger_source_config(uint32_t dac_periph,uint32_t triggersource)
+void dac_trigger_source_config(uint32_t dac_periph, uint32_t triggersource)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
/* configure DAC0 trigger source */
DAC_CTL &= ~DAC_CTL_DTSEL0;
DAC_CTL |= triggersource;
- }else{
+ } else {
/* configure DAC1 trigger source */
DAC_CTL &= ~DAC_CTL_DTSEL1;
DAC_CTL |= (triggersource << DAC1_REG_OFFSET);
@@ -279,9 +280,9 @@ void dac_trigger_source_config(uint32_t dac_periph,uint32_t triggersource)
*/
void dac_software_trigger_enable(uint32_t dac_periph)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
DAC_SWT |= DAC_SWT_SWTR0;
- }else{
+ } else {
DAC_SWT |= DAC_SWT_SWTR1;
}
}
@@ -294,9 +295,9 @@ void dac_software_trigger_enable(uint32_t dac_periph)
*/
void dac_software_trigger_disable(uint32_t dac_periph)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
DAC_SWT &= ~DAC_SWT_SWTR0;
- }else{
+ } else {
DAC_SWT &= ~DAC_SWT_SWTR1;
}
}
@@ -314,11 +315,11 @@ void dac_software_trigger_disable(uint32_t dac_periph)
*/
void dac_wave_mode_config(uint32_t dac_periph, uint32_t wave_mode)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
/* configure DAC0 wave mode */
DAC_CTL &= ~DAC_CTL_DWM0;
DAC_CTL |= wave_mode;
- }else{
+ } else {
/* configure DAC1 wave mode */
DAC_CTL &= ~DAC_CTL_DWM1;
DAC_CTL |= (wave_mode << DAC1_REG_OFFSET);
@@ -347,11 +348,11 @@ void dac_wave_mode_config(uint32_t dac_periph, uint32_t wave_mode)
*/
void dac_wave_bit_width_config(uint32_t dac_periph, uint32_t bit_width)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
/* configure DAC0 wave bit width */
DAC_CTL &= ~DAC_CTL_DWBW0;
DAC_CTL |= bit_width;
- }else{
+ } else {
/* configure DAC1 wave bit width */
DAC_CTL &= ~DAC_CTL_DWBW1;
DAC_CTL |= (bit_width << DAC1_REG_OFFSET);
@@ -380,11 +381,11 @@ void dac_wave_bit_width_config(uint32_t dac_periph, uint32_t bit_width)
*/
void dac_lfsr_noise_config(uint32_t dac_periph, uint32_t unmask_bits)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
/* configure DAC0 LFSR noise mode */
DAC_CTL &= ~DAC_CTL_DWBW0;
DAC_CTL |= unmask_bits;
- }else{
+ } else {
/* configure DAC1 LFSR noise mode */
DAC_CTL &= ~DAC_CTL_DWBW1;
DAC_CTL |= (unmask_bits << DAC1_REG_OFFSET);
@@ -413,11 +414,11 @@ void dac_lfsr_noise_config(uint32_t dac_periph, uint32_t unmask_bits)
*/
void dac_triangle_noise_config(uint32_t dac_periph, uint32_t amplitude)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
/* configure DAC0 triangle noise mode */
DAC_CTL &= ~DAC_CTL_DWBW0;
DAC_CTL |= amplitude;
- }else{
+ } else {
/* configure DAC1 triangle noise mode */
DAC_CTL &= ~DAC_CTL_DWBW1;
DAC_CTL |= (amplitude << DAC1_REG_OFFSET);
@@ -517,7 +518,7 @@ void dac_concurrent_output_buffer_disable(void)
void dac_concurrent_data_set(uint32_t dac_align, uint16_t data0, uint16_t data1)
{
uint32_t data = 0U;
- switch(dac_align){
+ switch(dac_align) {
/* data right 12b alignment */
case DAC_ALIGN_12B_R:
data = ((uint32_t)data1 << DH_12BIT_OFFSET) | data0;
@@ -565,70 +566,70 @@ void dac_concurrent_interrupt_disable(void)
}
/*!
- \brief enable DAC interrupt(DAC DMA underrun interrupt)
+ \brief get the specified DAC flag (DAC DMA underrun flag)
\param[in] dac_periph: DACx(x = 0,1)
\param[out] none
- \retval none
+ \retval FlagStatus: SET or RESET
*/
-void dac_interrupt_enable(uint32_t dac_periph)
+FlagStatus dac_flag_get(uint32_t dac_periph)
{
- if(DAC0 == dac_periph){
- DAC_CTL |= DAC_CTL_DDUDRIE0;
- }else{
- DAC_CTL |= DAC_CTL_DDUDRIE1;
+ FlagStatus temp_flag = RESET;
+ if(DAC0 == dac_periph) {
+ /* check the DMA underrun flag */
+ if(RESET != (DAC_STAT & DAC_STAT_DDUDR0)) {
+ temp_flag = SET;
+ }
+ } else {
+ /* check the DMA underrun flag */
+ if(RESET != (DAC_STAT & DAC_STAT_DDUDR1)) {
+ temp_flag = SET;
+ }
}
+ return temp_flag;
}
/*!
- \brief disable DAC interrupt(DAC DMA underrun interrupt)
+ \brief clear the specified DAC flag (DAC DMA underrun flag)
\param[in] dac_periph: DACx(x = 0,1)
\param[out] none
\retval none
*/
-void dac_interrupt_disable(uint32_t dac_periph)
+void dac_flag_clear(uint32_t dac_periph)
{
- if(DAC0 == dac_periph){
- DAC_CTL &= ~DAC_CTL_DDUDRIE0;
- }else{
- DAC_CTL &= ~DAC_CTL_DDUDRIE1;
+ if(DAC0 == dac_periph) {
+ DAC_STAT |= DAC_STAT_DDUDR0;
+ } else {
+ DAC_STAT |= DAC_STAT_DDUDR1;
}
}
/*!
- \brief get the specified DAC flag (DAC DMA underrun flag)
+ \brief enable DAC interrupt(DAC DMA underrun interrupt)
\param[in] dac_periph: DACx(x = 0,1)
\param[out] none
- \retval FlagStatus: SET or RESET
+ \retval none
*/
-FlagStatus dac_flag_get(uint32_t dac_periph)
+void dac_interrupt_enable(uint32_t dac_periph)
{
- FlagStatus temp_flag = RESET;
- if(DAC0 == dac_periph){
- /* check the DMA underrun flag */
- if(RESET != (DAC_STAT & DAC_STAT_DDUDR0)){
- temp_flag = SET;
- }
- }else{
- /* check the DMA underrun flag */
- if(RESET != (DAC_STAT & DAC_STAT_DDUDR1)){
- temp_flag = SET;
- }
+ if(DAC0 == dac_periph) {
+ DAC_CTL |= DAC_CTL_DDUDRIE0;
+ } else {
+ DAC_CTL |= DAC_CTL_DDUDRIE1;
}
- return temp_flag;
}
/*!
- \brief clear the specified DAC flag (DAC DMA underrun flag)
+ \brief disable DAC interrupt(DAC DMA underrun interrupt)
\param[in] dac_periph: DACx(x = 0,1)
\param[out] none
\retval none
*/
-void dac_flag_clear(uint32_t dac_periph)
+void dac_interrupt_disable(uint32_t dac_periph)
{
- if(DAC0 == dac_periph){
- DAC_STAT |= DAC_STAT_DDUDR0;
- }else{
- DAC_STAT |= DAC_STAT_DDUDR1;
+ if(DAC0 == dac_periph) {
+ DAC_CTL &= ~DAC_CTL_DDUDRIE0;
+ } else {
+ DAC_CTL &= ~DAC_CTL_DDUDRIE1;
}
}
@@ -643,18 +644,18 @@ FlagStatus dac_interrupt_flag_get(uint32_t dac_periph)
FlagStatus temp_flag = RESET;
uint32_t ddudr_flag = 0U, ddudrie_flag = 0U;
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
/* check the DMA underrun flag and DAC DMA underrun interrupt enable flag */
ddudr_flag = DAC_STAT & DAC_STAT_DDUDR0;
ddudrie_flag = DAC_CTL & DAC_CTL_DDUDRIE0;
- if((RESET != ddudr_flag) && (RESET != ddudrie_flag)){
+ if((RESET != ddudr_flag) && (RESET != ddudrie_flag)) {
temp_flag = SET;
}
- }else{
+ } else {
/* check the DMA underrun flag and DAC DMA underrun interrupt enable flag */
ddudr_flag = DAC_STAT & DAC_STAT_DDUDR1;
ddudrie_flag = DAC_CTL & DAC_CTL_DDUDRIE1;
- if((RESET != ddudr_flag) && (RESET != ddudrie_flag)){
+ if((RESET != ddudr_flag) && (RESET != ddudrie_flag)) {
temp_flag = SET;
}
}
@@ -669,9 +670,9 @@ FlagStatus dac_interrupt_flag_get(uint32_t dac_periph)
*/
void dac_interrupt_flag_clear(uint32_t dac_periph)
{
- if(DAC0 == dac_periph){
+ if(DAC0 == dac_periph) {
DAC_STAT |= DAC_STAT_DDUDR0;
- }else{
+ } else {
DAC_STAT |= DAC_STAT_DDUDR1;
}
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dbg.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dbg.c
index a408136ea4..992dd592b7 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dbg.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dbg.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -39,7 +40,7 @@ OF SUCH DAMAGE.
#define DBG_RESET_VAL 0x00000000U
/*!
- \brief deinitialize the DBG
+ \brief deinitialize the DBG
\param[in] none
\param[out] none
\retval none
@@ -51,7 +52,7 @@ void dbg_deinit(void)
}
/*!
- \brief read DBG_ID code register
+ \brief read DBG_ID code register
\param[in] none
\param[out] none
\retval DBG_ID code
@@ -62,7 +63,7 @@ uint32_t dbg_id_get(void)
}
/*!
- \brief enable low power behavior when the mcu is in debug mode
+ \brief enable low power behavior when the mcu is in debug mode
\param[in] dbg_low_power:
this parameter can be any combination of the following values:
\arg DBG_LOW_POWER_SLEEP: keep debugger connection during sleep mode
@@ -77,7 +78,7 @@ void dbg_low_power_enable(uint32_t dbg_low_power)
}
/*!
- \brief disable low power behavior when the mcu is in debug mode
+ \brief disable low power behavior when the mcu is in debug mode
\param[in] dbg_low_power:
this parameter can be any combination of the following values:
\arg DBG_LOW_POWER_SLEEP: donot keep debugger connection during sleep mode
@@ -92,7 +93,7 @@ void dbg_low_power_disable(uint32_t dbg_low_power)
}
/*!
- \brief enable peripheral behavior when the mcu is in debug mode
+ \brief enable peripheral behavior when the mcu is in debug mode
\param[in] dbg_periph: dbg_periph_enum
only one parameter can be selected which is shown as below:
\arg DBG_TIMER1_HOLD: hold TIMER1 counter when core is halted
@@ -117,7 +118,6 @@ void dbg_low_power_disable(uint32_t dbg_low_power)
\arg DBG_TIMER8_HOLD: hold TIMER8 counter when core is halted
\arg DBG_TIMER9_HOLD: hold TIMER9 counter when core is halted
\arg DBG_TIMER10_HOLD: hold TIMER10 counter when core is halted
- \arg \param[out] none
\retval none
*/
void dbg_periph_enable(dbg_periph_enum dbg_periph)
@@ -126,7 +126,7 @@ void dbg_periph_enable(dbg_periph_enum dbg_periph)
}
/*!
- \brief disable peripheral behavior when the mcu is in debug mode
+ \brief disable peripheral behavior when the mcu is in debug mode
\param[in] dbg_periph: dbg_periph_enum
only one parameter can be selected which is shown as below:
\arg DBG_TIMER1_HOLD: hold TIMER1 counter when core is halted
@@ -160,7 +160,7 @@ void dbg_periph_disable(dbg_periph_enum dbg_periph)
}
/*!
- \brief enable trace pin assignment
+ \brief enable trace pin assignment
\param[in] none
\param[out] none
\retval none
@@ -171,7 +171,7 @@ void dbg_trace_pin_enable(void)
}
/*!
- \brief disable trace pin assignment
+ \brief disable trace pin assignment
\param[in] none
\param[out] none
\retval none
@@ -181,18 +181,3 @@ void dbg_trace_pin_disable(void)
DBG_CTL0 &= ~DBG_CTL0_TRACE_IOEN;
}
-/*!
- \brief trace pin mode selection
- \param[in] trace_mode:
- \arg TRACE_MODE_ASYNC: trace pin used for async mode
- \arg TRACE_MODE_SYNC_DATASIZE_1: trace pin used for sync mode and data size is 1
- \arg TRACE_MODE_SYNC_DATASIZE_2: trace pin used for sync mode and data size is 2
- \arg TRACE_MODE_SYNC_DATASIZE_4: trace pin used for sync mode and data size is 4
- \param[out] none
- \retval none
-*/
-void dbg_trace_pin_mode_set(uint32_t trace_mode)
-{
- DBG_CTL0 &= ~DBG_CTL0_TRACE_MODE;
- DBG_CTL0 |= trace_mode;
-}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dci.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dci.c
index a1ddcab384..730410ad2a 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dci.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dci.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -37,7 +38,7 @@ OF SUCH DAMAGE.
#include "gd32f4xx_dci.h"
/*!
- \brief DCI deinit
+ \brief DCI deinit
\param[in] none
\param[out] none
\retval none
@@ -49,7 +50,7 @@ void dci_deinit(void)
}
/*!
- \brief initialize DCI registers
+ \brief initialize DCI registers
\param[in] dci_struct: DCI parameter initialization structure
members of the structure and the member values are shown as below:
capture_mode : DCI_CAPTURE_MODE_CONTINUOUS, DCI_CAPTURE_MODE_SNAPSHOT
@@ -62,7 +63,7 @@ void dci_deinit(void)
\param[out] none
\retval none
*/
-void dci_init(dci_parameter_struct* dci_struct)
+void dci_init(dci_parameter_struct *dci_struct)
{
uint32_t reg = 0U;
/* disable capture function and DCI */
@@ -79,7 +80,7 @@ void dci_init(dci_parameter_struct* dci_struct)
}
/*!
- \brief enable DCI function
+ \brief enable DCI function
\param[in] none
\param[out] none
\retval none
@@ -90,7 +91,7 @@ void dci_enable(void)
}
/*!
- \brief disable DCI function
+ \brief disable DCI function
\param[in] none
\param[out] none
\retval none
@@ -101,7 +102,7 @@ void dci_disable(void)
}
/*!
- \brief enable DCI capture
+ \brief enable DCI capture
\param[in] none
\param[out] none
\retval none
@@ -112,7 +113,7 @@ void dci_capture_enable(void)
}
/*!
- \brief disable DCI capture
+ \brief disable DCI capture
\param[in] none
\param[out] none
\retval none
@@ -123,7 +124,7 @@ void dci_capture_disable(void)
}
/*!
- \brief enable DCI jpeg mode
+ \brief enable DCI jpeg mode
\param[in] none
\param[out] none
\retval none
@@ -134,7 +135,7 @@ void dci_jpeg_enable(void)
}
/*!
- \brief disable DCI jpeg mode
+ \brief disable DCI jpeg mode
\param[in] none
\param[out] none
\retval none
@@ -145,7 +146,7 @@ void dci_jpeg_disable(void)
}
/*!
- \brief enable cropping window function
+ \brief enable cropping window function
\param[in] none
\param[out] none
\retval none
@@ -156,7 +157,7 @@ void dci_crop_window_enable(void)
}
/*!
- \brief disable cropping window function
+ \brief disable cropping window function
\param[in] none
\param[out] none
\retval none
@@ -167,7 +168,7 @@ void dci_crop_window_disable(void)
}
/*!
- \brief configure DCI cropping window
+ \brief configure DCI cropping window
\param[in] start_x: window horizontal start position
\param[in] start_y: window vertical start position
\param[in] size_width: window horizontal size
@@ -177,12 +178,12 @@ void dci_crop_window_disable(void)
*/
void dci_crop_window_config(uint16_t start_x, uint16_t start_y, uint16_t size_width, uint16_t size_height)
{
- DCI_CWSPOS = ((uint32_t)start_x | ((uint32_t)start_y<<16));
- DCI_CWSZ = ((uint32_t)size_width | ((uint32_t)size_height<<16));
+ DCI_CWSPOS = ((uint32_t)start_x | ((uint32_t)start_y << 16));
+ DCI_CWSZ = ((uint32_t)size_width | ((uint32_t)size_height << 16));
}
/*!
- \brief enable embedded synchronous mode
+ \brief enable embedded synchronous mode
\param[in] none
\param[out] none
\retval none
@@ -193,7 +194,7 @@ void dci_embedded_sync_enable(void)
}
/*!
- \brief disble embedded synchronous mode
+ \brief disble embedded synchronous mode
\param[in] none
\param[out] none
\retval none
@@ -203,7 +204,7 @@ void dci_embedded_sync_disable(void)
DCI_CTL &= ~DCI_CTL_ESM;
}
/*!
- \brief config synchronous codes in embedded synchronous mode
+ \brief config synchronous codes in embedded synchronous mode
\param[in] frame_start: frame start code in embedded synchronous mode
\param[in] line_start: line start code in embedded synchronous mode
\param[in] line_end: line end code in embedded synchronous mode
@@ -213,11 +214,11 @@ void dci_embedded_sync_disable(void)
*/
void dci_sync_codes_config(uint8_t frame_start, uint8_t line_start, uint8_t line_end, uint8_t frame_end)
{
- DCI_SC = ((uint32_t)frame_start | ((uint32_t)line_start<<8) | ((uint32_t)line_end<<16) | ((uint32_t)frame_end<<24));
+ DCI_SC = ((uint32_t)frame_start | ((uint32_t)line_start << 8) | ((uint32_t)line_end << 16) | ((uint32_t)frame_end << 24));
}
/*!
- \brief config synchronous codes unmask in embedded synchronous mode
+ \brief config synchronous codes unmask in embedded synchronous mode
\param[in] frame_start: frame start code unmask bits in embedded synchronous mode
\param[in] line_start: line start code unmask bits in embedded synchronous mode
\param[in] line_end: line end code unmask bits in embedded synchronous mode
@@ -227,11 +228,11 @@ void dci_sync_codes_config(uint8_t frame_start, uint8_t line_start, uint8_t line
*/
void dci_sync_codes_unmask_config(uint8_t frame_start, uint8_t line_start, uint8_t line_end, uint8_t frame_end)
{
- DCI_SCUMSK = ((uint32_t)frame_start | ((uint32_t)line_start<<8) | ((uint32_t)line_end<<16) | ((uint32_t)frame_end<<24));
+ DCI_SCUMSK = ((uint32_t)frame_start | ((uint32_t)line_start << 8) | ((uint32_t)line_end << 16) | ((uint32_t)frame_end << 24));
}
/*!
- \brief read DCI data register
+ \brief read DCI data register
\param[in] none
\param[out] none
\retval data
@@ -242,7 +243,7 @@ uint32_t dci_data_read(void)
}
/*!
- \brief get specified flag
+ \brief get specified flag
\param[in] flag:
\arg DCI_FLAG_HS: HS line status
\arg DCI_FLAG_VS: VS line status
@@ -259,23 +260,23 @@ FlagStatus dci_flag_get(uint32_t flag)
{
uint32_t stat = 0U;
- if(flag >> 31){
+ if(flag >> 31) {
/* get flag status from DCI_STAT1 register */
stat = DCI_STAT1;
- }else{
+ } else {
/* get flag status from DCI_STAT0 register */
stat = DCI_STAT0;
}
- if(flag & stat){
+ if(flag & stat) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief enable specified DCI interrupt
+ \brief enable specified DCI interrupt
\param[in] interrupt:
\arg DCI_INT_EF: end of frame interrupt
\arg DCI_INT_OVR: FIFO overrun interrupt
@@ -291,7 +292,7 @@ void dci_interrupt_enable(uint32_t interrupt)
}
/*!
- \brief disable specified DCI interrupt
+ \brief disable specified DCI interrupt
\param[in] interrupt:
\arg DCI_INT_EF: end of frame interrupt
\arg DCI_INT_OVR: FIFO overrun interrupt
@@ -307,7 +308,7 @@ void dci_interrupt_disable(uint32_t interrupt)
}
/*!
- \brief clear specified interrupt flag
+ \brief clear specified interrupt flag
\param[in] int_flag:
\arg DCI_INT_EF: end of frame interrupt
\arg DCI_INT_OVR: FIFO overrun interrupt
@@ -323,7 +324,7 @@ void dci_interrupt_flag_clear(uint32_t int_flag)
}
/*!
- \brief get specified interrupt flag
+ \brief get specified interrupt flag
\param[in] int_flag:
\arg DCI_INT_FLAG_EF: end of frame interrupt flag
\arg DCI_INT_FLAG_OVR: FIFO overrun interrupt flag
@@ -335,9 +336,9 @@ void dci_interrupt_flag_clear(uint32_t int_flag)
*/
FlagStatus dci_interrupt_flag_get(uint32_t int_flag)
{
- if(RESET == (DCI_INTF & int_flag)){
+ if(RESET == (DCI_INTF & int_flag)) {
return RESET;
- }else{
+ } else {
return SET;
}
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dma.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dma.c
index d8bd7be2d7..9e528782d0 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dma.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_dma.c
@@ -1,14 +1,14 @@
/*!
\file gd32f4xx_dma.c
\brief DMA driver
-
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -34,14 +34,13 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
OF SUCH DAMAGE.
*/
-
#include "gd32f4xx_dma.h"
/* DMA register bit offset */
#define CHXCTL_PERIEN_OFFSET ((uint32_t)25U)
/*!
- \brief deinitialize DMA a channel registers
+ \brief deinitialize DMA a channel registers
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel is deinitialized
@@ -52,29 +51,29 @@ OF SUCH DAMAGE.
void dma_deinit(uint32_t dma_periph, dma_channel_enum channelx)
{
/* disable DMA a channel */
- DMA_CHCTL(dma_periph,channelx) &= ~DMA_CHXCTL_CHEN;
+ DMA_CHCTL(dma_periph, channelx) &= ~DMA_CHXCTL_CHEN;
/* reset DMA channel registers */
- DMA_CHCTL(dma_periph,channelx) = DMA_CHCTL_RESET_VALUE;
- DMA_CHCNT(dma_periph,channelx) = DMA_CHCNT_RESET_VALUE;
- DMA_CHPADDR(dma_periph,channelx) = DMA_CHPADDR_RESET_VALUE;
- DMA_CHM0ADDR(dma_periph,channelx) = DMA_CHMADDR_RESET_VALUE;
- DMA_CHM1ADDR(dma_periph,channelx) = DMA_CHMADDR_RESET_VALUE;
- DMA_CHFCTL(dma_periph,channelx) = DMA_CHFCTL_RESET_VALUE;
- if(channelx < DMA_CH4){
- DMA_INTC0(dma_periph) |= DMA_FLAG_ADD(DMA_CHINTF_RESET_VALUE,channelx);
- }else{
+ DMA_CHCTL(dma_periph, channelx) = DMA_CHCTL_RESET_VALUE;
+ DMA_CHCNT(dma_periph, channelx) = DMA_CHCNT_RESET_VALUE;
+ DMA_CHPADDR(dma_periph, channelx) = DMA_CHPADDR_RESET_VALUE;
+ DMA_CHM0ADDR(dma_periph, channelx) = DMA_CHMADDR_RESET_VALUE;
+ DMA_CHM1ADDR(dma_periph, channelx) = DMA_CHMADDR_RESET_VALUE;
+ DMA_CHFCTL(dma_periph, channelx) = DMA_CHFCTL_RESET_VALUE;
+ if(channelx < DMA_CH4) {
+ DMA_INTC0(dma_periph) |= DMA_FLAG_ADD(DMA_CHINTF_RESET_VALUE, channelx);
+ } else {
channelx -= (dma_channel_enum)4;
- DMA_INTC1(dma_periph) |= DMA_FLAG_ADD(DMA_CHINTF_RESET_VALUE,channelx);
+ DMA_INTC1(dma_periph) |= DMA_FLAG_ADD(DMA_CHINTF_RESET_VALUE, channelx);
}
}
/*!
- \brief initialize the DMA single data mode parameters struct with the default values
+ \brief initialize the DMA single data mode parameters struct with the default values
\param[in] init_struct: the initialization data needed to initialize DMA channel
\param[out] none
\retval none
*/
-void dma_single_data_para_struct_init(dma_single_data_parameter_struct* init_struct)
+void dma_single_data_para_struct_init(dma_single_data_parameter_struct *init_struct)
{
/* set the DMA struct with the default values */
init_struct->periph_addr = 0U;
@@ -89,12 +88,12 @@ void dma_single_data_para_struct_init(dma_single_data_parameter_struct* init_str
}
/*!
- \brief initialize the DMA multi data mode parameters struct with the default values
+ \brief initialize the DMA multi data mode parameters struct with the default values
\param[in] init_struct: the initialization data needed to initialize DMA channel
\param[out] none
\retval none
*/
-void dma_multi_data_para_struct_init(dma_multi_data_parameter_struct* init_struct)
+void dma_multi_data_para_struct_init(dma_multi_data_parameter_struct *init_struct)
{
/* set the DMA struct with the default values */
init_struct->periph_addr = 0U;
@@ -112,7 +111,7 @@ void dma_multi_data_para_struct_init(dma_multi_data_parameter_struct* init_struc
}
/*!
- \brief initialize DMA single data mode
+ \brief initialize DMA single data mode
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel is initialized
@@ -130,54 +129,54 @@ void dma_multi_data_para_struct_init(dma_multi_data_parameter_struct* init_struc
\param[out] none
\retval none
*/
-void dma_single_data_mode_init(uint32_t dma_periph, dma_channel_enum channelx, dma_single_data_parameter_struct* init_struct)
+void dma_single_data_mode_init(uint32_t dma_periph, dma_channel_enum channelx, dma_single_data_parameter_struct *init_struct)
{
uint32_t ctl;
/* select single data mode */
- DMA_CHFCTL(dma_periph,channelx) &= ~DMA_CHXFCTL_MDMEN;
+ DMA_CHFCTL(dma_periph, channelx) &= ~DMA_CHXFCTL_MDMEN;
/* configure peripheral base address */
- DMA_CHPADDR(dma_periph,channelx) = init_struct->periph_addr;
+ DMA_CHPADDR(dma_periph, channelx) = init_struct->periph_addr;
/* configure memory base address */
- DMA_CHM0ADDR(dma_periph,channelx) = init_struct->memory0_addr;
+ DMA_CHM0ADDR(dma_periph, channelx) = init_struct->memory0_addr;
/* configure the number of remaining data to be transferred */
- DMA_CHCNT(dma_periph,channelx) = init_struct->number;
+ DMA_CHCNT(dma_periph, channelx) = init_struct->number;
/* configure peripheral and memory transfer width,channel priotity,transfer mode */
- ctl = DMA_CHCTL(dma_periph,channelx);
+ ctl = DMA_CHCTL(dma_periph, channelx);
ctl &= ~(DMA_CHXCTL_PWIDTH | DMA_CHXCTL_MWIDTH | DMA_CHXCTL_PRIO | DMA_CHXCTL_TM);
ctl |= (init_struct->periph_memory_width | (init_struct->periph_memory_width << 2) | init_struct->priority | init_struct->direction);
- DMA_CHCTL(dma_periph,channelx) = ctl;
+ DMA_CHCTL(dma_periph, channelx) = ctl;
/* configure peripheral increasing mode */
- if(DMA_PERIPH_INCREASE_ENABLE == init_struct->periph_inc){
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_PNAGA;
- }else if(DMA_PERIPH_INCREASE_DISABLE == init_struct->periph_inc){
- DMA_CHCTL(dma_periph,channelx) &= ~DMA_CHXCTL_PNAGA;
- }else{
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_PAIF;
+ if(DMA_PERIPH_INCREASE_ENABLE == init_struct->periph_inc) {
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_PNAGA;
+ } else if(DMA_PERIPH_INCREASE_DISABLE == init_struct->periph_inc) {
+ DMA_CHCTL(dma_periph, channelx) &= ~DMA_CHXCTL_PNAGA;
+ } else {
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_PAIF;
}
/* configure memory increasing mode */
- if(DMA_MEMORY_INCREASE_ENABLE == init_struct->memory_inc){
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_MNAGA;
- }else{
- DMA_CHCTL(dma_periph,channelx) &= ~DMA_CHXCTL_MNAGA;
+ if(DMA_MEMORY_INCREASE_ENABLE == init_struct->memory_inc) {
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_MNAGA;
+ } else {
+ DMA_CHCTL(dma_periph, channelx) &= ~DMA_CHXCTL_MNAGA;
}
/* configure DMA circular mode */
- if(DMA_CIRCULAR_MODE_ENABLE == init_struct->circular_mode){
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_CMEN;
- }else{
- DMA_CHCTL(dma_periph,channelx) &= ~DMA_CHXCTL_CMEN;
+ if(DMA_CIRCULAR_MODE_ENABLE == init_struct->circular_mode) {
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_CMEN;
+ } else {
+ DMA_CHCTL(dma_periph, channelx) &= ~DMA_CHXCTL_CMEN;
}
}
/*!
- \brief initialize DMA multi data mode
+ \brief initialize DMA multi data mode
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel is initialized
@@ -199,54 +198,55 @@ void dma_single_data_mode_init(uint32_t dma_periph, dma_channel_enum channelx, d
\param[out] none
\retval none
*/
-void dma_multi_data_mode_init(uint32_t dma_periph, dma_channel_enum channelx, dma_multi_data_parameter_struct* init_struct)
+void dma_multi_data_mode_init(uint32_t dma_periph, dma_channel_enum channelx, dma_multi_data_parameter_struct *init_struct)
{
uint32_t ctl;
/* select multi data mode and configure FIFO critical value */
- DMA_CHFCTL(dma_periph,channelx) |= (DMA_CHXFCTL_MDMEN | init_struct->critical_value);
+ DMA_CHFCTL(dma_periph, channelx) |= (DMA_CHXFCTL_MDMEN | init_struct->critical_value);
/* configure peripheral base address */
- DMA_CHPADDR(dma_periph,channelx) = init_struct->periph_addr;
+ DMA_CHPADDR(dma_periph, channelx) = init_struct->periph_addr;
/* configure memory base address */
- DMA_CHM0ADDR(dma_periph,channelx) = init_struct->memory0_addr;
+ DMA_CHM0ADDR(dma_periph, channelx) = init_struct->memory0_addr;
/* configure the number of remaining data to be transferred */
- DMA_CHCNT(dma_periph,channelx) = init_struct->number;
+ DMA_CHCNT(dma_periph, channelx) = init_struct->number;
/* configure peripheral and memory transfer width,channel priotity,transfer mode,peripheral and memory burst transfer width */
- ctl = DMA_CHCTL(dma_periph,channelx);
+ ctl = DMA_CHCTL(dma_periph, channelx);
ctl &= ~(DMA_CHXCTL_PWIDTH | DMA_CHXCTL_MWIDTH | DMA_CHXCTL_PRIO | DMA_CHXCTL_TM | DMA_CHXCTL_PBURST | DMA_CHXCTL_MBURST);
- ctl |= (init_struct->periph_width | (init_struct->memory_width ) | init_struct->priority | init_struct->direction | init_struct->memory_burst_width | init_struct->periph_burst_width);
- DMA_CHCTL(dma_periph,channelx) = ctl;
+ ctl |= (init_struct->periph_width | (init_struct->memory_width) | init_struct->priority | init_struct->direction | init_struct->memory_burst_width |
+ init_struct->periph_burst_width);
+ DMA_CHCTL(dma_periph, channelx) = ctl;
/* configure peripheral increasing mode */
- if(DMA_PERIPH_INCREASE_ENABLE == init_struct->periph_inc){
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_PNAGA;
- }else if(DMA_PERIPH_INCREASE_DISABLE == init_struct->periph_inc){
- DMA_CHCTL(dma_periph,channelx) &= ~DMA_CHXCTL_PNAGA;
- }else{
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_PAIF;
+ if(DMA_PERIPH_INCREASE_ENABLE == init_struct->periph_inc) {
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_PNAGA;
+ } else if(DMA_PERIPH_INCREASE_DISABLE == init_struct->periph_inc) {
+ DMA_CHCTL(dma_periph, channelx) &= ~DMA_CHXCTL_PNAGA;
+ } else {
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_PAIF;
}
/* configure memory increasing mode */
- if(DMA_MEMORY_INCREASE_ENABLE == init_struct->memory_inc){
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_MNAGA;
- }else{
- DMA_CHCTL(dma_periph,channelx) &= ~DMA_CHXCTL_MNAGA;
+ if(DMA_MEMORY_INCREASE_ENABLE == init_struct->memory_inc) {
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_MNAGA;
+ } else {
+ DMA_CHCTL(dma_periph, channelx) &= ~DMA_CHXCTL_MNAGA;
}
/* configure DMA circular mode */
- if(DMA_CIRCULAR_MODE_ENABLE == init_struct->circular_mode){
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_CMEN;
- }else{
- DMA_CHCTL(dma_periph,channelx) &= ~DMA_CHXCTL_CMEN;
+ if(DMA_CIRCULAR_MODE_ENABLE == init_struct->circular_mode) {
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_CMEN;
+ } else {
+ DMA_CHCTL(dma_periph, channelx) &= ~DMA_CHXCTL_CMEN;
}
}
/*!
- \brief set DMA peripheral base address
+ \brief set DMA peripheral base address
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel to set peripheral base address
@@ -257,11 +257,11 @@ void dma_multi_data_mode_init(uint32_t dma_periph, dma_channel_enum channelx, dm
*/
void dma_periph_address_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_t address)
{
- DMA_CHPADDR(dma_periph,channelx) = address;
+ DMA_CHPADDR(dma_periph, channelx) = address;
}
/*!
- \brief set DMA Memory0 base address
+ \brief set DMA Memory0 base address
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel to set Memory base address
@@ -273,15 +273,15 @@ void dma_periph_address_config(uint32_t dma_periph, dma_channel_enum channelx, u
*/
void dma_memory_address_config(uint32_t dma_periph, dma_channel_enum channelx, uint8_t memory_flag, uint32_t address)
{
- if(memory_flag){
- DMA_CHM1ADDR(dma_periph,channelx) = address;
- }else{
- DMA_CHM0ADDR(dma_periph,channelx) = address;
+ if(memory_flag) {
+ DMA_CHM1ADDR(dma_periph, channelx) = address;
+ } else {
+ DMA_CHM0ADDR(dma_periph, channelx) = address;
}
}
/*!
- \brief set the number of remaining data to be transferred by the DMA
+ \brief set the number of remaining data to be transferred by the DMA
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel to set number
@@ -292,11 +292,11 @@ void dma_memory_address_config(uint32_t dma_periph, dma_channel_enum channelx, u
*/
void dma_transfer_number_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_t number)
{
- DMA_CHCNT(dma_periph,channelx) = number;
+ DMA_CHCNT(dma_periph, channelx) = number;
}
/*!
- \brief get the number of remaining data to be transferred by the DMA
+ \brief get the number of remaining data to be transferred by the DMA
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel to set number
@@ -306,11 +306,11 @@ void dma_transfer_number_config(uint32_t dma_periph, dma_channel_enum channelx,
*/
uint32_t dma_transfer_number_get(uint32_t dma_periph, dma_channel_enum channelx)
{
- return (uint32_t)DMA_CHCNT(dma_periph,channelx);
+ return (uint32_t)DMA_CHCNT(dma_periph, channelx);
}
/*!
- \brief configure priority level of DMA channel
+ \brief configure priority level of DMA channel
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -328,15 +328,15 @@ void dma_priority_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_
{
uint32_t ctl;
/* acquire DMA_CHxCTL register */
- ctl = DMA_CHCTL(dma_periph,channelx);
+ ctl = DMA_CHCTL(dma_periph, channelx);
/* assign regiser */
ctl &= ~DMA_CHXCTL_PRIO;
ctl |= priority;
- DMA_CHCTL(dma_periph,channelx) = ctl;
+ DMA_CHCTL(dma_periph, channelx) = ctl;
}
/*!
- \brief configure transfer burst beats of memory
+ \brief configure transfer burst beats of memory
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -349,19 +349,19 @@ void dma_priority_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_
\param[out] none
\retval none
*/
-void dma_memory_burst_beats_config (uint32_t dma_periph, dma_channel_enum channelx, uint32_t mbeat)
+void dma_memory_burst_beats_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_t mbeat)
{
uint32_t ctl;
/* acquire DMA_CHxCTL register */
- ctl = DMA_CHCTL(dma_periph,channelx);
+ ctl = DMA_CHCTL(dma_periph, channelx);
/* assign regiser */
ctl &= ~DMA_CHXCTL_MBURST;
ctl |= mbeat;
- DMA_CHCTL(dma_periph,channelx) = ctl;
+ DMA_CHCTL(dma_periph, channelx) = ctl;
}
/*!
- \brief configure transfer burst beats of peripheral
+ \brief configure transfer burst beats of peripheral
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -375,19 +375,19 @@ void dma_memory_burst_beats_config (uint32_t dma_periph, dma_channel_enum channe
\param[out] none
\retval none
*/
-void dma_periph_burst_beats_config (uint32_t dma_periph, dma_channel_enum channelx, uint32_t pbeat)
+void dma_periph_burst_beats_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_t pbeat)
{
uint32_t ctl;
/* acquire DMA_CHxCTL register */
- ctl = DMA_CHCTL(dma_periph,channelx);
+ ctl = DMA_CHCTL(dma_periph, channelx);
/* assign regiser */
ctl &= ~DMA_CHXCTL_PBURST;
ctl |= pbeat;
- DMA_CHCTL(dma_periph,channelx) = ctl;
+ DMA_CHCTL(dma_periph, channelx) = ctl;
}
/*!
- \brief configure transfer data size of memory
+ \brief configure transfer data size of memory
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -404,15 +404,15 @@ void dma_memory_width_config(uint32_t dma_periph, dma_channel_enum channelx, uin
{
uint32_t ctl;
/* acquire DMA_CHxCTL register */
- ctl = DMA_CHCTL(dma_periph,channelx);
+ ctl = DMA_CHCTL(dma_periph, channelx);
/* assign regiser */
ctl &= ~DMA_CHXCTL_MWIDTH;
ctl |= msize;
- DMA_CHCTL(dma_periph,channelx) = ctl;
+ DMA_CHCTL(dma_periph, channelx) = ctl;
}
/*!
- \brief configure transfer data size of peripheral
+ \brief configure transfer data size of peripheral
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -425,19 +425,19 @@ void dma_memory_width_config(uint32_t dma_periph, dma_channel_enum channelx, uin
\param[out] none
\retval none
*/
-void dma_periph_width_config (uint32_t dma_periph, dma_channel_enum channelx, uint32_t psize)
+void dma_periph_width_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_t psize)
{
uint32_t ctl;
/* acquire DMA_CHxCTL register */
- ctl = DMA_CHCTL(dma_periph,channelx);
+ ctl = DMA_CHCTL(dma_periph, channelx);
/* assign regiser */
ctl &= ~DMA_CHXCTL_PWIDTH;
ctl |= psize;
- DMA_CHCTL(dma_periph,channelx) = ctl;
+ DMA_CHCTL(dma_periph, channelx) = ctl;
}
/*!
- \brief configure memory address generation generation_algorithm
+ \brief configure memory address generation generation_algorithm
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -451,15 +451,15 @@ void dma_periph_width_config (uint32_t dma_periph, dma_channel_enum channelx, ui
*/
void dma_memory_address_generation_config(uint32_t dma_periph, dma_channel_enum channelx, uint8_t generation_algorithm)
{
- if(DMA_MEMORY_INCREASE_ENABLE == generation_algorithm){
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_MNAGA;
- }else{
- DMA_CHCTL(dma_periph,channelx) &= ~DMA_CHXCTL_MNAGA;
+ if(DMA_MEMORY_INCREASE_ENABLE == generation_algorithm) {
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_MNAGA;
+ } else {
+ DMA_CHCTL(dma_periph, channelx) &= ~DMA_CHXCTL_MNAGA;
}
}
/*!
- \brief configure peripheral address generation_algorithm
+ \brief configure peripheral address generation_algorithm
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -474,18 +474,18 @@ void dma_memory_address_generation_config(uint32_t dma_periph, dma_channel_enum
*/
void dma_peripheral_address_generation_config(uint32_t dma_periph, dma_channel_enum channelx, uint8_t generation_algorithm)
{
- if(DMA_PERIPH_INCREASE_ENABLE == generation_algorithm){
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_PNAGA;
- }else if(DMA_PERIPH_INCREASE_DISABLE == generation_algorithm){
- DMA_CHCTL(dma_periph,channelx) &= ~DMA_CHXCTL_PNAGA;
- }else{
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_PNAGA;
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_PAIF;
+ if(DMA_PERIPH_INCREASE_ENABLE == generation_algorithm) {
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_PNAGA;
+ } else if(DMA_PERIPH_INCREASE_DISABLE == generation_algorithm) {
+ DMA_CHCTL(dma_periph, channelx) &= ~DMA_CHXCTL_PNAGA;
+ } else {
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_PNAGA;
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_PAIF;
}
}
/*!
- \brief enable DMA circulation mode
+ \brief enable DMA circulation mode
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -495,11 +495,11 @@ void dma_peripheral_address_generation_config(uint32_t dma_periph, dma_channel_e
*/
void dma_circulation_enable(uint32_t dma_periph, dma_channel_enum channelx)
{
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_CMEN;
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_CMEN;
}
/*!
- \brief disable DMA circulation mode
+ \brief disable DMA circulation mode
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -509,11 +509,11 @@ void dma_circulation_enable(uint32_t dma_periph, dma_channel_enum channelx)
*/
void dma_circulation_disable(uint32_t dma_periph, dma_channel_enum channelx)
{
- DMA_CHCTL(dma_periph,channelx) &= ~DMA_CHXCTL_CMEN;
+ DMA_CHCTL(dma_periph, channelx) &= ~DMA_CHXCTL_CMEN;
}
/*!
- \brief enable DMA channel
+ \brief enable DMA channel
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -523,11 +523,11 @@ void dma_circulation_disable(uint32_t dma_periph, dma_channel_enum channelx)
*/
void dma_channel_enable(uint32_t dma_periph, dma_channel_enum channelx)
{
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_CHEN;
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_CHEN;
}
/*!
- \brief disable DMA channel
+ \brief disable DMA channel
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -537,11 +537,11 @@ void dma_channel_enable(uint32_t dma_periph, dma_channel_enum channelx)
*/
void dma_channel_disable(uint32_t dma_periph, dma_channel_enum channelx)
{
- DMA_CHCTL(dma_periph,channelx) &= ~DMA_CHXCTL_CHEN;
+ DMA_CHCTL(dma_periph, channelx) &= ~DMA_CHXCTL_CHEN;
}
/*!
- \brief configure the direction of data transfer on the channel
+ \brief configure the direction of data transfer on the channel
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -558,16 +558,16 @@ void dma_transfer_direction_config(uint32_t dma_periph, dma_channel_enum channel
{
uint32_t ctl;
/* acquire DMA_CHxCTL register */
- ctl = DMA_CHCTL(dma_periph,channelx);
+ ctl = DMA_CHCTL(dma_periph, channelx);
/* assign regiser */
ctl &= ~DMA_CHXCTL_TM;
ctl |= direction;
- DMA_CHCTL(dma_periph,channelx) = ctl;
+ DMA_CHCTL(dma_periph, channelx) = ctl;
}
/*!
- \brief DMA switch buffer mode config
+ \brief DMA switch buffer mode config
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -580,17 +580,17 @@ void dma_transfer_direction_config(uint32_t dma_periph, dma_channel_enum channel
void dma_switch_buffer_mode_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_t memory1_addr, uint32_t memory_select)
{
/* configure memory1 base address */
- DMA_CHM1ADDR(dma_periph,channelx) = memory1_addr;
+ DMA_CHM1ADDR(dma_periph, channelx) = memory1_addr;
- if(DMA_MEMORY_0 == memory_select){
- DMA_CHCTL(dma_periph,channelx) &= ~DMA_CHXCTL_MBS;
- }else{
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_MBS;
+ if(DMA_MEMORY_0 == memory_select) {
+ DMA_CHCTL(dma_periph, channelx) &= ~DMA_CHXCTL_MBS;
+ } else {
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_MBS;
}
}
/*!
- \brief DMA using memory get
+ \brief DMA using memory get
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -600,15 +600,15 @@ void dma_switch_buffer_mode_config(uint32_t dma_periph, dma_channel_enum channel
*/
uint32_t dma_using_memory_get(uint32_t dma_periph, dma_channel_enum channelx)
{
- if((DMA_CHCTL(dma_periph,channelx)) & DMA_CHXCTL_MBS){
+ if((DMA_CHCTL(dma_periph, channelx)) & DMA_CHXCTL_MBS) {
return DMA_MEMORY_1;
- }else{
+ } else {
return DMA_MEMORY_0;
}
}
/*!
- \brief DMA channel peripheral select
+ \brief DMA channel peripheral select
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -622,16 +622,16 @@ void dma_channel_subperipheral_select(uint32_t dma_periph, dma_channel_enum chan
{
uint32_t ctl;
/* acquire DMA_CHxCTL register */
- ctl = DMA_CHCTL(dma_periph,channelx);
+ ctl = DMA_CHCTL(dma_periph, channelx);
/* assign regiser */
ctl &= ~DMA_CHXCTL_PERIEN;
ctl |= ((uint32_t)sub_periph << CHXCTL_PERIEN_OFFSET);
- DMA_CHCTL(dma_periph,channelx) = ctl;
+ DMA_CHCTL(dma_periph, channelx) = ctl;
}
/*!
- \brief DMA flow controller configure
+ \brief DMA flow controller configure
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -645,15 +645,15 @@ void dma_channel_subperipheral_select(uint32_t dma_periph, dma_channel_enum chan
*/
void dma_flow_controller_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_t controller)
{
- if(DMA_FLOW_CONTROLLER_DMA == controller){
- DMA_CHCTL(dma_periph,channelx) &= ~DMA_CHXCTL_TFCS;
- }else{
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_TFCS;
+ if(DMA_FLOW_CONTROLLER_DMA == controller) {
+ DMA_CHCTL(dma_periph, channelx) &= ~DMA_CHXCTL_TFCS;
+ } else {
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_TFCS;
}
}
/*!
- \brief DMA switch buffer mode enable
+ \brief DMA switch buffer mode enable
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -664,17 +664,17 @@ void dma_flow_controller_config(uint32_t dma_periph, dma_channel_enum channelx,
*/
void dma_switch_buffer_mode_enable(uint32_t dma_periph, dma_channel_enum channelx, ControlStatus newvalue)
{
- if(ENABLE == newvalue){
+ if(ENABLE == newvalue) {
/* switch buffer mode enable */
- DMA_CHCTL(dma_periph,channelx) |= DMA_CHXCTL_SBMEN;
- }else{
+ DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_SBMEN;
+ } else {
/* switch buffer mode disable */
- DMA_CHCTL(dma_periph,channelx) &= ~DMA_CHXCTL_SBMEN;
+ DMA_CHCTL(dma_periph, channelx) &= ~DMA_CHXCTL_SBMEN;
}
}
/*!
- \brief DMA FIFO status get
+ \brief DMA FIFO status get
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel
@@ -684,11 +684,11 @@ void dma_switch_buffer_mode_enable(uint32_t dma_periph, dma_channel_enum channel
*/
uint32_t dma_fifo_status_get(uint32_t dma_periph, dma_channel_enum channelx)
{
- return (DMA_CHFCTL(dma_periph,channelx) & DMA_CHXFCTL_FCNT);
+ return (DMA_CHFCTL(dma_periph, channelx) & DMA_CHXFCTL_FCNT);
}
/*!
- \brief get DMA flag is set or not
+ \brief get DMA flag is set or not
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel to get flag
@@ -705,24 +705,24 @@ uint32_t dma_fifo_status_get(uint32_t dma_periph, dma_channel_enum channelx)
*/
FlagStatus dma_flag_get(uint32_t dma_periph, dma_channel_enum channelx, uint32_t flag)
{
- if(channelx < DMA_CH4){
- if(DMA_INTF0(dma_periph) & DMA_FLAG_ADD(flag,channelx)){
+ if(channelx < DMA_CH4) {
+ if(DMA_INTF0(dma_periph) & DMA_FLAG_ADD(flag, channelx)) {
return SET;
- }else{
+ } else {
return RESET;
}
- }else{
+ } else {
channelx -= (dma_channel_enum)4;
- if(DMA_INTF1(dma_periph) & DMA_FLAG_ADD(flag,channelx)){
+ if(DMA_INTF1(dma_periph) & DMA_FLAG_ADD(flag, channelx)) {
return SET;
- }else{
+ } else {
return RESET;
}
}
}
/*!
- \brief clear DMA a channel flag
+ \brief clear DMA a channel flag
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel to get flag
@@ -739,16 +739,66 @@ FlagStatus dma_flag_get(uint32_t dma_periph, dma_channel_enum channelx, uint32_t
*/
void dma_flag_clear(uint32_t dma_periph, dma_channel_enum channelx, uint32_t flag)
{
- if(channelx < DMA_CH4){
- DMA_INTC0(dma_periph) |= DMA_FLAG_ADD(flag,channelx);
- }else{
+ if(channelx < DMA_CH4) {
+ DMA_INTC0(dma_periph) |= DMA_FLAG_ADD(flag, channelx);
+ } else {
channelx -= (dma_channel_enum)4;
- DMA_INTC1(dma_periph) |= DMA_FLAG_ADD(flag,channelx);
+ DMA_INTC1(dma_periph) |= DMA_FLAG_ADD(flag, channelx);
+ }
+}
+
+/*!
+ \brief enable DMA interrupt
+ \param[in] dma_periph: DMAx(x=0,1)
+ \arg DMAx(x=0,1)
+ \param[in] channelx: specify which DMA channel
+ \arg DMA_CHx(x=0..7)
+ \param[in] source: specify which interrupt to enbale
+ only one parameters can be selected which are shown as below:
+ \arg DMA_CHXCTL_SDEIE: single data mode exception interrupt enable
+ \arg DMA_CHXCTL_TAEIE: tranfer access error interrupt enable
+ \arg DMA_CHXCTL_HTFIE: half transfer finish interrupt enable
+ \arg DMA_CHXCTL_FTFIE: full transfer finish interrupt enable
+ \arg DMA_CHXFCTL_FEEIE: FIFO exception interrupt enable
+ \param[out] none
+ \retval none
+*/
+void dma_interrupt_enable(uint32_t dma_periph, dma_channel_enum channelx, uint32_t source)
+{
+ if(DMA_CHXFCTL_FEEIE != source) {
+ DMA_CHCTL(dma_periph, channelx) |= source;
+ } else {
+ DMA_CHFCTL(dma_periph, channelx) |= source;
+ }
+}
+
+/*!
+ \brief disable DMA interrupt
+ \param[in] dma_periph: DMAx(x=0,1)
+ \arg DMAx(x=0,1)
+ \param[in] channelx: specify which DMA channel
+ \arg DMA_CHx(x=0..7)
+ \param[in] source: specify which interrupt to disbale
+ only one parameters can be selected which are shown as below:
+ \arg DMA_CHXCTL_SDEIE: single data mode exception interrupt enable
+ \arg DMA_CHXCTL_TAEIE: tranfer access error interrupt enable
+ \arg DMA_CHXCTL_HTFIE: half transfer finish interrupt enable
+ \arg DMA_CHXCTL_FTFIE: full transfer finish interrupt enable
+ \arg DMA_CHXFCTL_FEEIE: FIFO exception interrupt enable
+ \param[out] none
+ \retval none
+*/
+void dma_interrupt_disable(uint32_t dma_periph, dma_channel_enum channelx, uint32_t source)
+{
+ if(DMA_CHXFCTL_FEEIE != source) {
+ DMA_CHCTL(dma_periph, channelx) &= ~source;
+ } else {
+ DMA_CHFCTL(dma_periph, channelx) &= ~source;
}
}
/*!
- \brief get DMA interrupt flag is set or not
+ \brief get DMA interrupt flag is set or not
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel to get interrupt flag
@@ -765,70 +815,70 @@ void dma_flag_clear(uint32_t dma_periph, dma_channel_enum channelx, uint32_t fla
*/
FlagStatus dma_interrupt_flag_get(uint32_t dma_periph, dma_channel_enum channelx, uint32_t interrupt)
{
- uint32_t interrupt_enable = 0U,interrupt_flag = 0U;
+ uint32_t interrupt_enable = 0U, interrupt_flag = 0U;
dma_channel_enum channel_flag_offset = channelx;
- if(channelx < DMA_CH4){
- switch(interrupt){
+ if(channelx < DMA_CH4) {
+ switch(interrupt) {
case DMA_INTF_FEEIF:
- interrupt_flag = DMA_INTF0(dma_periph) & DMA_FLAG_ADD(interrupt,channelx);
- interrupt_enable = DMA_CHFCTL(dma_periph,channelx) & DMA_CHXFCTL_FEEIE;
+ interrupt_flag = DMA_INTF0(dma_periph) & DMA_FLAG_ADD(interrupt, channelx);
+ interrupt_enable = DMA_CHFCTL(dma_periph, channelx) & DMA_CHXFCTL_FEEIE;
break;
case DMA_INTF_SDEIF:
- interrupt_flag = DMA_INTF0(dma_periph) & DMA_FLAG_ADD(interrupt,channelx);
- interrupt_enable = DMA_CHCTL(dma_periph,channelx) & DMA_CHXCTL_SDEIE;
+ interrupt_flag = DMA_INTF0(dma_periph) & DMA_FLAG_ADD(interrupt, channelx);
+ interrupt_enable = DMA_CHCTL(dma_periph, channelx) & DMA_CHXCTL_SDEIE;
break;
case DMA_INTF_TAEIF:
- interrupt_flag = DMA_INTF0(dma_periph) & DMA_FLAG_ADD(interrupt,channelx);
- interrupt_enable = DMA_CHCTL(dma_periph,channelx) & DMA_CHXCTL_TAEIE;
+ interrupt_flag = DMA_INTF0(dma_periph) & DMA_FLAG_ADD(interrupt, channelx);
+ interrupt_enable = DMA_CHCTL(dma_periph, channelx) & DMA_CHXCTL_TAEIE;
break;
case DMA_INTF_HTFIF:
- interrupt_flag = DMA_INTF0(dma_periph) & DMA_FLAG_ADD(interrupt,channelx);
- interrupt_enable = DMA_CHCTL(dma_periph,channelx) & DMA_CHXCTL_HTFIE;
+ interrupt_flag = DMA_INTF0(dma_periph) & DMA_FLAG_ADD(interrupt, channelx);
+ interrupt_enable = DMA_CHCTL(dma_periph, channelx) & DMA_CHXCTL_HTFIE;
break;
case DMA_INTF_FTFIF:
- interrupt_flag = (DMA_INTF0(dma_periph) & DMA_FLAG_ADD(interrupt,channelx));
- interrupt_enable = (DMA_CHCTL(dma_periph,channelx) & DMA_CHXCTL_FTFIE);
+ interrupt_flag = (DMA_INTF0(dma_periph) & DMA_FLAG_ADD(interrupt, channelx));
+ interrupt_enable = (DMA_CHCTL(dma_periph, channelx) & DMA_CHXCTL_FTFIE);
break;
default:
break;
}
- }else{
+ } else {
channel_flag_offset -= (dma_channel_enum)4;
- switch(interrupt){
+ switch(interrupt) {
case DMA_INTF_FEEIF:
- interrupt_flag = DMA_INTF1(dma_periph) & DMA_FLAG_ADD(interrupt,channel_flag_offset);
- interrupt_enable = DMA_CHFCTL(dma_periph,channelx) & DMA_CHXFCTL_FEEIE;
+ interrupt_flag = DMA_INTF1(dma_periph) & DMA_FLAG_ADD(interrupt, channel_flag_offset);
+ interrupt_enable = DMA_CHFCTL(dma_periph, channelx) & DMA_CHXFCTL_FEEIE;
break;
case DMA_INTF_SDEIF:
- interrupt_flag = DMA_INTF1(dma_periph) & DMA_FLAG_ADD(interrupt,channel_flag_offset);
- interrupt_enable = DMA_CHCTL(dma_periph,channelx) & DMA_CHXCTL_SDEIE;
+ interrupt_flag = DMA_INTF1(dma_periph) & DMA_FLAG_ADD(interrupt, channel_flag_offset);
+ interrupt_enable = DMA_CHCTL(dma_periph, channelx) & DMA_CHXCTL_SDEIE;
break;
case DMA_INTF_TAEIF:
- interrupt_flag = DMA_INTF1(dma_periph) & DMA_FLAG_ADD(interrupt,channel_flag_offset);
- interrupt_enable = DMA_CHCTL(dma_periph,channelx) & DMA_CHXCTL_TAEIE;
+ interrupt_flag = DMA_INTF1(dma_periph) & DMA_FLAG_ADD(interrupt, channel_flag_offset);
+ interrupt_enable = DMA_CHCTL(dma_periph, channelx) & DMA_CHXCTL_TAEIE;
break;
case DMA_INTF_HTFIF:
- interrupt_flag = DMA_INTF1(dma_periph) & DMA_FLAG_ADD(interrupt,channel_flag_offset);
- interrupt_enable = DMA_CHCTL(dma_periph,channelx) & DMA_CHXCTL_HTFIE;
+ interrupt_flag = DMA_INTF1(dma_periph) & DMA_FLAG_ADD(interrupt, channel_flag_offset);
+ interrupt_enable = DMA_CHCTL(dma_periph, channelx) & DMA_CHXCTL_HTFIE;
break;
case DMA_INTF_FTFIF:
- interrupt_flag = DMA_INTF1(dma_periph) & DMA_FLAG_ADD(interrupt,channel_flag_offset);
- interrupt_enable = DMA_CHCTL(dma_periph,channelx) & DMA_CHXCTL_FTFIE;
+ interrupt_flag = DMA_INTF1(dma_periph) & DMA_FLAG_ADD(interrupt, channel_flag_offset);
+ interrupt_enable = DMA_CHCTL(dma_periph, channelx) & DMA_CHXCTL_FTFIE;
break;
default:
break;
}
}
- if(interrupt_flag && interrupt_enable){
+ if(interrupt_flag && interrupt_enable) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief clear DMA a channel interrupt flag
+ \brief clear DMA a channel interrupt flag
\param[in] dma_periph: DMAx(x=0,1)
\arg DMAx(x=0,1)
\param[in] channelx: specify which DMA channel to clear interrupt flag
@@ -845,61 +895,10 @@ FlagStatus dma_interrupt_flag_get(uint32_t dma_periph, dma_channel_enum channelx
*/
void dma_interrupt_flag_clear(uint32_t dma_periph, dma_channel_enum channelx, uint32_t interrupt)
{
- if(channelx < DMA_CH4){
- DMA_INTC0(dma_periph) |= DMA_FLAG_ADD(interrupt,channelx);
- }else{
+ if(channelx < DMA_CH4) {
+ DMA_INTC0(dma_periph) |= DMA_FLAG_ADD(interrupt, channelx);
+ } else {
channelx -= (dma_channel_enum)4;
- DMA_INTC1(dma_periph) |= DMA_FLAG_ADD(interrupt,channelx);
+ DMA_INTC1(dma_periph) |= DMA_FLAG_ADD(interrupt, channelx);
}
}
-
-/*!
- \brief enable DMA interrupt
- \param[in] dma_periph: DMAx(x=0,1)
- \arg DMAx(x=0,1)
- \param[in] channelx: specify which DMA channel
- \arg DMA_CHx(x=0..7)
- \param[in] source: specify which interrupt to enbale
- one or more parameters can be selected which are shown as below:
- \arg DMA_CHXCTL_SDEIE: single data mode exception interrupt enable
- \arg DMA_CHXCTL_TAEIE: tranfer access error interrupt enable
- \arg DMA_CHXCTL_HTFIE: half transfer finish interrupt enable
- \arg DMA_CHXCTL_FTFIE: full transfer finish interrupt enable
- \arg DMA_CHXFCTL_FEEIE: FIFO exception interrupt enable
- \param[out] none
- \retval none
-*/
-void dma_interrupt_enable(uint32_t dma_periph, dma_channel_enum channelx, uint32_t source)
-{
- if(DMA_CHXFCTL_FEEIE != source){
- DMA_CHCTL(dma_periph,channelx) |= source;
- }else{
- DMA_CHFCTL(dma_periph,channelx) |= source;
- }
-}
-
-/*!
- \brief disable DMA interrupt
- \param[in] dma_periph: DMAx(x=0,1)
- \arg DMAx(x=0,1)
- \param[in] channelx: specify which DMA channel
- \arg DMA_CHx(x=0..7)
- \param[in] source: specify which interrupt to disbale
- one or more parameters can be selected which are shown as below:
- \arg DMA_CHXCTL_SDEIE: single data mode exception interrupt enable
- \arg DMA_CHXCTL_TAEIE: tranfer access error interrupt enable
- \arg DMA_CHXCTL_HTFIE: half transfer finish interrupt enable
- \arg DMA_CHXCTL_FTFIE: full transfer finish interrupt enable
- \arg DMA_CHXFCTL_FEEIE: FIFO exception interrupt enable
- \param[out] none
- \retval none
-*/
-void dma_interrupt_disable(uint32_t dma_periph, dma_channel_enum channelx, uint32_t source)
-{
- if(DMA_CHXFCTL_FEEIE != source){
- DMA_CHCTL(dma_periph,channelx) &= ~source;
- }else{
- DMA_CHFCTL(dma_periph,channelx) &= ~source;
- }
-}
-
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_enet.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_enet.c
index 456e476fd8..ba17638266 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_enet.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_enet.c
@@ -5,11 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
-
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -57,10 +57,10 @@ uint8_t rx_buff[ENET_RXBUF_NUM][ENET_RXBUF_SIZE]; /*!< ENET receive bu
uint8_t tx_buff[ENET_TXBUF_NUM][ENET_TXBUF_SIZE]; /*!< ENET transmit buffer */
#elif defined (__GNUC__) /* GNU Compiler */
-enet_descriptors_struct rxdesc_tab[ENET_RXBUF_NUM] __attribute__ ((aligned (4))); /*!< ENET RxDMA descriptor */
-enet_descriptors_struct txdesc_tab[ENET_TXBUF_NUM] __attribute__ ((aligned (4))); /*!< ENET TxDMA descriptor */
-uint8_t rx_buff[ENET_RXBUF_NUM][ENET_RXBUF_SIZE] __attribute__ ((aligned (4))); /*!< ENET receive buffer */
-uint8_t tx_buff[ENET_TXBUF_NUM][ENET_TXBUF_SIZE] __attribute__ ((aligned (4))); /*!< ENET transmit buffer */
+enet_descriptors_struct rxdesc_tab[ENET_RXBUF_NUM] __attribute__((aligned(4))); /*!< ENET RxDMA descriptor */
+enet_descriptors_struct txdesc_tab[ENET_TXBUF_NUM] __attribute__((aligned(4))); /*!< ENET TxDMA descriptor */
+uint8_t rx_buff[ENET_RXBUF_NUM][ENET_RXBUF_SIZE] __attribute__((aligned(4))); /*!< ENET receive buffer */
+uint8_t tx_buff[ENET_TXBUF_NUM][ENET_TXBUF_SIZE] __attribute__((aligned(4))); /*!< ENET transmit buffer */
#endif /* __CC_ARM */
@@ -73,19 +73,20 @@ enet_descriptors_struct *dma_current_ptp_txdesc = NULL;
enet_descriptors_struct *dma_current_ptp_rxdesc = NULL;
/* init structure parameters for ENET initialization */
-static enet_initpara_struct enet_initpara ={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+static enet_initpara_struct enet_initpara = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
static uint32_t enet_unknow_err = 0U;
/* array of register offset for debug information get */
static const uint16_t enet_reg_tab[] = {
-0x0000, 0x0004, 0x0008, 0x000C, 0x0010, 0x0014, 0x0018, 0x001C, 0x0028, 0x002C, 0x0034,
-0x0038, 0x003C, 0x0040, 0x0044, 0x0048, 0x004C, 0x0050, 0x0054, 0x0058, 0x005C, 0x1080,
+ 0x0000, 0x0004, 0x0008, 0x000C, 0x0010, 0x0014, 0x0018, 0x001C, 0x0028, 0x002C, 0x0034,
+ 0x0038, 0x003C, 0x0040, 0x0044, 0x0048, 0x004C, 0x0050, 0x0054, 0x0058, 0x005C, 0x1080,
-0x0100, 0x0104, 0x0108, 0x010C, 0x0110, 0x014C, 0x0150, 0x0168, 0x0194, 0x0198, 0x01C4,
+ 0x0100, 0x0104, 0x0108, 0x010C, 0x0110, 0x014C, 0x0150, 0x0168, 0x0194, 0x0198, 0x01C4,
-0x0700, 0x0704,0x0708, 0x070C, 0x0710, 0x0714, 0x0718, 0x071C, 0x0720, 0x0728, 0x072C,
+ 0x0700, 0x0704, 0x0708, 0x070C, 0x0710, 0x0714, 0x0718, 0x071C, 0x0720, 0x0728, 0x072C,
-0x1000, 0x1004, 0x1008, 0x100C, 0x1010, 0x1014, 0x1018, 0x101C, 0x1020, 0x1024, 0x1048,
-0x104C, 0x1050, 0x1054};
+ 0x1000, 0x1004, 0x1008, 0x100C, 0x1010, 0x1014, 0x1018, 0x101C, 0x1020, 0x1024, 0x1048,
+ 0x104C, 0x1050, 0x1054
+};
/* initialize ENET peripheral with generally concerned parameters, call it by enet_init() */
static void enet_default_init(void);
@@ -101,7 +102,7 @@ static void enet_delay(uint32_t ncount);
/*!
- \brief deinitialize the ENET, and reset structure parameters for ENET initialization
+ \brief deinitialize the ENET, and reset structure parameters for ENET initialization
\param[in] none
\param[out] none
\retval none
@@ -114,7 +115,7 @@ void enet_deinit(void)
}
/*!
- \brief configure the parameters which are usually less cared for initialization
+ \brief configure the parameters which are usually less cared for initialization
note -- this function must be called before enet_init(), otherwise
configuration will be no effect
\param[in] option: different function option, which is related to several parameters, refer to enet_option_enum
@@ -183,7 +184,15 @@ void enet_deinit(void)
ENET_PAUSETIME_MINUS144/ENET_PAUSETIME_MINUS256 ;
- ENET_MAC0_AND_UNIQUE_ADDRESS_PAUSEDETECT/ ENET_UNIQUE_PAUSEDETECT ;
- ENET_RX_FLOWCONTROL_ENABLE/ ENET_RX_FLOWCONTROL_DISABLE ;
- - ENET_TX_FLOWCONTROL_ENABLE/ ENET_TX_FLOWCONTROL_DISABLE .
+ - ENET_TX_FLOWCONTROL_ENABLE/ ENET_TX_FLOWCONTROL_DISABLE ;
+ - ENET_ACTIVE_THRESHOLD_256BYTES/ ENET_ACTIVE_THRESHOLD_512BYTES ;
+ - ENET_ACTIVE_THRESHOLD_768BYTES/ ENET_ACTIVE_THRESHOLD_1024BYTES ;
+ - ENET_ACTIVE_THRESHOLD_1280BYTES/ ENET_ACTIVE_THRESHOLD_1536BYTES ;
+ - ENET_ACTIVE_THRESHOLD_1792BYTES ;
+ - ENET_DEACTIVE_THRESHOLD_256BYTES/ ENET_DEACTIVE_THRESHOLD_512BYTES ;
+ - ENET_DEACTIVE_THRESHOLD_768BYTES/ ENET_DEACTIVE_THRESHOLD_1024BYTES ;
+ - ENET_DEACTIVE_THRESHOLD_1280BYTES/ ENET_DEACTIVE_THRESHOLD_1536BYTES ;
+ - ENET_DEACTIVE_THRESHOLD_1792BYTES .
HASHH_OPTION related parameters:
- 0x0~0xFFFF FFFFU
HASHL_OPTION related parameters:
@@ -218,7 +227,7 @@ void enet_deinit(void)
*/
void enet_initpara_config(enet_option_enum option, uint32_t para)
{
- switch(option){
+ switch(option) {
case FORWARD_OPTION:
/* choose to configure forward_frame, and save the configuration parameters */
enet_initpara.option_enable |= (uint32_t)FORWARD_OPTION;
@@ -300,7 +309,7 @@ void enet_initpara_config(enet_option_enum option, uint32_t para)
}
/*!
- \brief initialize ENET peripheral with generally concerned parameters and the less cared
+ \brief initialize ENET peripheral with generally concerned parameters and the less cared
parameters
\param[in] mediamode: PHY mode and mac loopback configurations, refer to enet_mediamode_enum
only one parameter can be selected which is shown as below
@@ -327,16 +336,16 @@ void enet_initpara_config(enet_option_enum option, uint32_t para)
*/
ErrStatus enet_init(enet_mediamode_enum mediamode, enet_chksumconf_enum checksum, enet_frmrecept_enum recept)
{
- uint32_t reg_value=0U, reg_temp = 0U, temp = 0U;
+ uint32_t reg_value = 0U, reg_temp = 0U, temp = 0U;
uint32_t media_temp = 0U;
uint32_t timeout = 0U;
uint16_t phy_value = 0U;
- ErrStatus phy_state= ERROR, enet_state = ERROR;
+ ErrStatus phy_state = ERROR, enet_state = ERROR;
/* PHY interface configuration, configure SMI clock and reset PHY chip */
- if(ERROR == enet_phy_config()){
+ if(ERROR == enet_phy_config()) {
_ENET_DELAY_(PHY_RESETDELAY);
- if(ERROR == enet_phy_config()){
+ if(ERROR == enet_phy_config()) {
return enet_state;
}
}
@@ -346,15 +355,15 @@ ErrStatus enet_init(enet_mediamode_enum mediamode, enet_chksumconf_enum checksum
/* 1st, configure mediamode */
media_temp = (uint32_t)mediamode;
/* if is PHY auto negotiation */
- if((uint32_t)ENET_AUTO_NEGOTIATION == media_temp){
+ if((uint32_t)ENET_AUTO_NEGOTIATION == media_temp) {
/* wait for PHY_LINKED_STATUS bit be set */
- do{
+ do {
enet_phy_write_read(ENET_PHY_READ, PHY_ADDRESS, PHY_REG_BSR, &phy_value);
phy_value &= PHY_LINKED_STATUS;
timeout++;
- }while((RESET == phy_value) && (timeout < PHY_READ_TO));
+ } while((RESET == phy_value) && (timeout < PHY_READ_TO));
/* return ERROR due to timeout */
- if(PHY_READ_TO == timeout){
+ if(PHY_READ_TO == timeout) {
return enet_state;
}
/* reset timeout counter */
@@ -363,19 +372,19 @@ ErrStatus enet_init(enet_mediamode_enum mediamode, enet_chksumconf_enum checksum
/* enable auto-negotiation */
phy_value = PHY_AUTONEGOTIATION;
phy_state = enet_phy_write_read(ENET_PHY_WRITE, PHY_ADDRESS, PHY_REG_BCR, &phy_value);
- if(!phy_state){
+ if(!phy_state) {
/* return ERROR due to write timeout */
return enet_state;
}
/* wait for the PHY_AUTONEGO_COMPLETE bit be set */
- do{
+ do {
enet_phy_write_read(ENET_PHY_READ, PHY_ADDRESS, PHY_REG_BSR, &phy_value);
phy_value &= PHY_AUTONEGO_COMPLETE;
timeout++;
- }while((RESET == phy_value) && (timeout < (uint32_t)PHY_READ_TO));
+ } while((RESET == phy_value) && (timeout < (uint32_t)PHY_READ_TO));
/* return ERROR due to timeout */
- if(PHY_READ_TO == timeout){
+ if(PHY_READ_TO == timeout) {
return enet_state;
}
/* reset timeout counter */
@@ -384,22 +393,22 @@ ErrStatus enet_init(enet_mediamode_enum mediamode, enet_chksumconf_enum checksum
/* read the result of the auto-negotiation */
enet_phy_write_read(ENET_PHY_READ, PHY_ADDRESS, PHY_SR, &phy_value);
/* configure the duplex mode of MAC following the auto-negotiation result */
- if((uint16_t)RESET != (phy_value & PHY_DUPLEX_STATUS)){
+ if((uint16_t)RESET != (phy_value & PHY_DUPLEX_STATUS)) {
media_temp = ENET_MODE_FULLDUPLEX;
- }else{
+ } else {
media_temp = ENET_MODE_HALFDUPLEX;
}
/* configure the communication speed of MAC following the auto-negotiation result */
- if((uint16_t)RESET !=(phy_value & PHY_SPEED_STATUS)){
+ if((uint16_t)RESET != (phy_value & PHY_SPEED_STATUS)) {
media_temp |= ENET_SPEEDMODE_10M;
- }else{
+ } else {
media_temp |= ENET_SPEEDMODE_100M;
}
- }else{
+ } else {
phy_value = (uint16_t)((media_temp & ENET_MAC_CFG_DPM) >> 3);
phy_value |= (uint16_t)((media_temp & ENET_MAC_CFG_SPD) >> 1);
phy_state = enet_phy_write_read(ENET_PHY_WRITE, PHY_ADDRESS, PHY_REG_BCR, &phy_value);
- if(!phy_state){
+ if(!phy_state) {
/* return ERROR due to write timeout */
return enet_state;
}
@@ -409,13 +418,13 @@ ErrStatus enet_init(enet_mediamode_enum mediamode, enet_chksumconf_enum checksum
/* after configuring the PHY, use mediamode to configure registers */
reg_value = ENET_MAC_CFG;
/* configure ENET_MAC_CFG register */
- reg_value &= (~(ENET_MAC_CFG_SPD |ENET_MAC_CFG_DPM |ENET_MAC_CFG_LBM));
+ reg_value &= (~(ENET_MAC_CFG_SPD | ENET_MAC_CFG_DPM | ENET_MAC_CFG_LBM));
reg_value |= media_temp;
ENET_MAC_CFG = reg_value;
/* 2st, configure checksum */
- if(RESET != ((uint32_t)checksum & ENET_CHECKSUMOFFLOAD_ENABLE)){
+ if(RESET != ((uint32_t)checksum & ENET_CHECKSUMOFFLOAD_ENABLE)) {
ENET_MAC_CFG |= ENET_CHECKSUMOFFLOAD_ENABLE;
reg_value = ENET_DMA_CTL;
@@ -430,13 +439,13 @@ ErrStatus enet_init(enet_mediamode_enum mediamode, enet_chksumconf_enum checksum
/* 4th, configure different function options */
/* configure forward_frame related registers */
- if(RESET != (enet_initpara.option_enable & (uint32_t)FORWARD_OPTION)){
+ if(RESET != (enet_initpara.option_enable & (uint32_t)FORWARD_OPTION)) {
reg_temp = enet_initpara.forward_frame;
reg_value = ENET_MAC_CFG;
temp = reg_temp;
/* configure ENET_MAC_CFG register */
- reg_value &= (~(ENET_MAC_CFG_TFCD |ENET_MAC_CFG_APCD));
+ reg_value &= (~(ENET_MAC_CFG_TFCD | ENET_MAC_CFG_APCD));
temp &= (ENET_MAC_CFG_TFCD | ENET_MAC_CFG_APCD);
reg_value |= temp;
ENET_MAC_CFG = reg_value;
@@ -444,37 +453,37 @@ ErrStatus enet_init(enet_mediamode_enum mediamode, enet_chksumconf_enum checksum
reg_value = ENET_DMA_CTL;
temp = reg_temp;
/* configure ENET_DMA_CTL register */
- reg_value &= (~(ENET_DMA_CTL_FERF |ENET_DMA_CTL_FUF));
- temp &= ((ENET_DMA_CTL_FERF | ENET_DMA_CTL_FUF)<<2);
+ reg_value &= (~(ENET_DMA_CTL_FERF | ENET_DMA_CTL_FUF));
+ temp &= ((ENET_DMA_CTL_FERF | ENET_DMA_CTL_FUF) << 2);
reg_value |= (temp >> 2);
ENET_DMA_CTL = reg_value;
}
/* configure dmabus_mode related registers */
- if(RESET != (enet_initpara.option_enable & (uint32_t)DMABUS_OPTION)){
+ if(RESET != (enet_initpara.option_enable & (uint32_t)DMABUS_OPTION)) {
temp = enet_initpara.dmabus_mode;
reg_value = ENET_DMA_BCTL;
/* configure ENET_DMA_BCTL register */
reg_value &= ~(ENET_DMA_BCTL_AA | ENET_DMA_BCTL_FB \
- |ENET_DMA_BCTL_FPBL | ENET_DMA_BCTL_MB);
+ | ENET_DMA_BCTL_FPBL | ENET_DMA_BCTL_MB);
reg_value |= temp;
ENET_DMA_BCTL = reg_value;
}
/* configure dma_maxburst related registers */
- if(RESET != (enet_initpara.option_enable & (uint32_t)DMA_MAXBURST_OPTION)){
+ if(RESET != (enet_initpara.option_enable & (uint32_t)DMA_MAXBURST_OPTION)) {
temp = enet_initpara.dma_maxburst;
reg_value = ENET_DMA_BCTL;
/* configure ENET_DMA_BCTL register */
- reg_value &= ~(ENET_DMA_BCTL_RXDP| ENET_DMA_BCTL_PGBL | ENET_DMA_BCTL_UIP);
+ reg_value &= ~(ENET_DMA_BCTL_RXDP | ENET_DMA_BCTL_PGBL | ENET_DMA_BCTL_UIP);
reg_value |= temp;
ENET_DMA_BCTL = reg_value;
}
/* configure dma_arbitration related registers */
- if(RESET != (enet_initpara.option_enable & (uint32_t)DMA_ARBITRATION_OPTION)){
+ if(RESET != (enet_initpara.option_enable & (uint32_t)DMA_ARBITRATION_OPTION)) {
temp = enet_initpara.dma_arbitration;
reg_value = ENET_DMA_BCTL;
@@ -485,24 +494,24 @@ ErrStatus enet_init(enet_mediamode_enum mediamode, enet_chksumconf_enum checksum
}
/* configure store_forward_mode related registers */
- if(RESET != (enet_initpara.option_enable & (uint32_t)STORE_OPTION)){
+ if(RESET != (enet_initpara.option_enable & (uint32_t)STORE_OPTION)) {
temp = enet_initpara.store_forward_mode;
reg_value = ENET_DMA_CTL;
/* configure ENET_DMA_CTL register */
- reg_value &= ~(ENET_DMA_CTL_RSFD | ENET_DMA_CTL_TSFD| ENET_DMA_CTL_RTHC| ENET_DMA_CTL_TTHC);
+ reg_value &= ~(ENET_DMA_CTL_RSFD | ENET_DMA_CTL_TSFD | ENET_DMA_CTL_RTHC | ENET_DMA_CTL_TTHC);
reg_value |= temp;
ENET_DMA_CTL = reg_value;
}
/* configure dma_function related registers */
- if(RESET != (enet_initpara.option_enable & (uint32_t)DMA_OPTION)){
+ if(RESET != (enet_initpara.option_enable & (uint32_t)DMA_OPTION)) {
reg_temp = enet_initpara.dma_function;
reg_value = ENET_DMA_CTL;
temp = reg_temp;
/* configure ENET_DMA_CTL register */
- reg_value &= (~(ENET_DMA_CTL_DAFRF |ENET_DMA_CTL_OSF));
+ reg_value &= (~(ENET_DMA_CTL_DAFRF | ENET_DMA_CTL_OSF));
temp &= (ENET_DMA_CTL_DAFRF | ENET_DMA_CTL_OSF);
reg_value |= temp;
ENET_DMA_CTL = reg_value;
@@ -517,7 +526,7 @@ ErrStatus enet_init(enet_mediamode_enum mediamode, enet_chksumconf_enum checksum
}
/* configure vlan_config related registers */
- if(RESET != (enet_initpara.option_enable & (uint32_t)VLAN_OPTION)){
+ if(RESET != (enet_initpara.option_enable & (uint32_t)VLAN_OPTION)) {
reg_temp = enet_initpara.vlan_config;
reg_value = ENET_MAC_VLT;
@@ -528,65 +537,65 @@ ErrStatus enet_init(enet_mediamode_enum mediamode, enet_chksumconf_enum checksum
}
/* configure flow_control related registers */
- if(RESET != (enet_initpara.option_enable & (uint32_t)FLOWCTL_OPTION)){
+ if(RESET != (enet_initpara.option_enable & (uint32_t)FLOWCTL_OPTION)) {
reg_temp = enet_initpara.flow_control;
reg_value = ENET_MAC_FCTL;
temp = reg_temp;
/* configure ENET_MAC_FCTL register */
- reg_value &= ~(ENET_MAC_FCTL_PTM |ENET_MAC_FCTL_DZQP |ENET_MAC_FCTL_PLTS \
- | ENET_MAC_FCTL_UPFDT |ENET_MAC_FCTL_RFCEN |ENET_MAC_FCTL_TFCEN);
- temp &= (ENET_MAC_FCTL_PTM |ENET_MAC_FCTL_DZQP |ENET_MAC_FCTL_PLTS \
- | ENET_MAC_FCTL_UPFDT |ENET_MAC_FCTL_RFCEN |ENET_MAC_FCTL_TFCEN);
+ reg_value &= ~(ENET_MAC_FCTL_PTM | ENET_MAC_FCTL_DZQP | ENET_MAC_FCTL_PLTS \
+ | ENET_MAC_FCTL_UPFDT | ENET_MAC_FCTL_RFCEN | ENET_MAC_FCTL_TFCEN);
+ temp &= (ENET_MAC_FCTL_PTM | ENET_MAC_FCTL_DZQP | ENET_MAC_FCTL_PLTS \
+ | ENET_MAC_FCTL_UPFDT | ENET_MAC_FCTL_RFCEN | ENET_MAC_FCTL_TFCEN);
reg_value |= temp;
ENET_MAC_FCTL = reg_value;
reg_value = ENET_MAC_FCTH;
temp = reg_temp;
/* configure ENET_MAC_FCTH register */
- reg_value &= ~(ENET_MAC_FCTH_RFA |ENET_MAC_FCTH_RFD);
- temp &= ((ENET_MAC_FCTH_RFA | ENET_MAC_FCTH_RFD )<<8);
+ reg_value &= ~(ENET_MAC_FCTH_RFA | ENET_MAC_FCTH_RFD);
+ temp &= ((ENET_MAC_FCTH_RFA | ENET_MAC_FCTH_RFD) << 8);
reg_value |= (temp >> 8);
ENET_MAC_FCTH = reg_value;
}
/* configure hashtable_high related registers */
- if(RESET != (enet_initpara.option_enable & (uint32_t)HASHH_OPTION)){
+ if(RESET != (enet_initpara.option_enable & (uint32_t)HASHH_OPTION)) {
ENET_MAC_HLH = enet_initpara.hashtable_high;
}
/* configure hashtable_low related registers */
- if(RESET != (enet_initpara.option_enable & (uint32_t)HASHL_OPTION)){
+ if(RESET != (enet_initpara.option_enable & (uint32_t)HASHL_OPTION)) {
ENET_MAC_HLL = enet_initpara.hashtable_low;
}
/* configure framesfilter_mode related registers */
- if(RESET != (enet_initpara.option_enable & (uint32_t)FILTER_OPTION)){
+ if(RESET != (enet_initpara.option_enable & (uint32_t)FILTER_OPTION)) {
reg_temp = enet_initpara.framesfilter_mode;
reg_value = ENET_MAC_FRMF;
/* configure ENET_MAC_FRMF register */
reg_value &= ~(ENET_MAC_FRMF_SAFLT | ENET_MAC_FRMF_SAIFLT | ENET_MAC_FRMF_DAIFLT \
- | ENET_MAC_FRMF_HMF | ENET_MAC_FRMF_HPFLT | ENET_MAC_FRMF_MFD \
- | ENET_MAC_FRMF_HUF | ENET_MAC_FRMF_PCFRM);
+ | ENET_MAC_FRMF_HMF | ENET_MAC_FRMF_HPFLT | ENET_MAC_FRMF_MFD \
+ | ENET_MAC_FRMF_HUF | ENET_MAC_FRMF_PCFRM);
reg_value |= reg_temp;
ENET_MAC_FRMF = reg_value;
}
/* configure halfduplex_param related registers */
- if(RESET != (enet_initpara.option_enable & (uint32_t)HALFDUPLEX_OPTION)){
+ if(RESET != (enet_initpara.option_enable & (uint32_t)HALFDUPLEX_OPTION)) {
reg_temp = enet_initpara.halfduplex_param;
reg_value = ENET_MAC_CFG;
/* configure ENET_MAC_CFG register */
reg_value &= ~(ENET_MAC_CFG_CSD | ENET_MAC_CFG_ROD | ENET_MAC_CFG_RTD \
- | ENET_MAC_CFG_BOL | ENET_MAC_CFG_DFC);
+ | ENET_MAC_CFG_BOL | ENET_MAC_CFG_DFC);
reg_value |= reg_temp;
ENET_MAC_CFG = reg_value;
}
/* configure timer_config related registers */
- if(RESET != (enet_initpara.option_enable & (uint32_t)TIMER_OPTION)){
+ if(RESET != (enet_initpara.option_enable & (uint32_t)TIMER_OPTION)) {
reg_temp = enet_initpara.timer_config;
reg_value = ENET_MAC_CFG;
@@ -597,7 +606,7 @@ ErrStatus enet_init(enet_mediamode_enum mediamode, enet_chksumconf_enum checksum
}
/* configure interframegap related registers */
- if(RESET != (enet_initpara.option_enable & (uint32_t)INTERFRAMEGAP_OPTION)){
+ if(RESET != (enet_initpara.option_enable & (uint32_t)INTERFRAMEGAP_OPTION)) {
reg_temp = enet_initpara.interframegap;
reg_value = ENET_MAC_CFG;
@@ -612,7 +621,7 @@ ErrStatus enet_init(enet_mediamode_enum mediamode, enet_chksumconf_enum checksum
}
/*!
- \brief reset all core internal registers located in CLK_TX and CLK_RX
+ \brief reset all core internal registers located in CLK_TX and CLK_RX
\param[in] none
\param[out] none
\retval ErrStatus: SUCCESS or ERROR
@@ -627,13 +636,13 @@ ErrStatus enet_software_reset(void)
ENET_DMA_BCTL |= ENET_DMA_BCTL_SWR;
/* wait for reset operation complete */
- do{
+ do {
dma_flag = (ENET_DMA_BCTL & ENET_DMA_BCTL_SWR);
timeout++;
- }while((RESET != dma_flag) && (ENET_DELAY_TO != timeout));
+ } while((RESET != dma_flag) && (ENET_DELAY_TO != timeout));
/* reset operation complete */
- if(RESET == (ENET_DMA_BCTL & ENET_DMA_BCTL_SWR)){
+ if(RESET == (ENET_DMA_BCTL & ENET_DMA_BCTL_SWR)) {
enet_state = SUCCESS;
}
@@ -641,7 +650,7 @@ ErrStatus enet_software_reset(void)
}
/*!
- \brief check receive frame valid and return frame size
+ \brief check receive frame valid and return frame size
\param[in] none
\param[out] none
\retval size of received frame: 0x0 - 0x3FFF
@@ -655,14 +664,14 @@ uint32_t enet_rxframe_size_get(void)
status = dma_current_rxdesc->status;
/* if the desciptor is owned by DMA */
- if((uint32_t)RESET != (status & ENET_RDES0_DAV)){
+ if((uint32_t)RESET != (status & ENET_RDES0_DAV)) {
return 0U;
}
/* if has any error, or the frame uses two or more descriptors */
if((((uint32_t)RESET) != (status & ENET_RDES0_ERRS)) ||
- (((uint32_t)RESET) == (status & ENET_RDES0_LDES)) ||
- (((uint32_t)RESET) == (status & ENET_RDES0_FDES))){
+ (((uint32_t)RESET) == (status & ENET_RDES0_LDES)) ||
+ (((uint32_t)RESET) == (status & ENET_RDES0_FDES))) {
/* drop current receive frame */
enet_rxframe_drop();
@@ -671,37 +680,37 @@ uint32_t enet_rxframe_size_get(void)
#ifdef SELECT_DESCRIPTORS_ENHANCED_MODE
/* if is an ethernet-type frame, and IP frame payload error occurred */
if(((uint32_t)RESET) != (dma_current_rxdesc->status & ENET_RDES0_FRMT) &&
- ((uint32_t)RESET) != (dma_current_rxdesc->extended_status & ENET_RDES4_IPPLDERR)){
- /* drop current receive frame */
- enet_rxframe_drop();
+ ((uint32_t)RESET) != (dma_current_rxdesc->extended_status & ENET_RDES4_IPPLDERR)) {
+ /* drop current receive frame */
+ enet_rxframe_drop();
return 1U;
}
#else
/* if is an ethernet-type frame, and IP frame payload error occurred */
if((((uint32_t)RESET) != (status & ENET_RDES0_FRMT)) &&
- (((uint32_t)RESET) != (status & ENET_RDES0_PCERR))){
- /* drop current receive frame */
- enet_rxframe_drop();
+ (((uint32_t)RESET) != (status & ENET_RDES0_PCERR))) {
+ /* drop current receive frame */
+ enet_rxframe_drop();
return 1U;
}
#endif
/* if CPU owns current descriptor, no error occured, the frame uses only one descriptor */
if((((uint32_t)RESET) == (status & ENET_RDES0_DAV)) &&
- (((uint32_t)RESET) == (status & ENET_RDES0_ERRS)) &&
- (((uint32_t)RESET) != (status & ENET_RDES0_LDES)) &&
- (((uint32_t)RESET) != (status & ENET_RDES0_FDES))){
+ (((uint32_t)RESET) == (status & ENET_RDES0_ERRS)) &&
+ (((uint32_t)RESET) != (status & ENET_RDES0_LDES)) &&
+ (((uint32_t)RESET) != (status & ENET_RDES0_FDES))) {
/* get the size of the received data including CRC */
size = GET_RDES0_FRML(status);
/* substract the CRC size */
size = size - 4U;
/* if is a type frame, and CRC is not included in forwarding frame */
- if((RESET != (ENET_MAC_CFG & ENET_MAC_CFG_TFCD)) && (RESET != (status & ENET_RDES0_FRMT))){
+ if((RESET != (ENET_MAC_CFG & ENET_MAC_CFG_TFCD)) && (RESET != (status & ENET_RDES0_FRMT))) {
size = size + 4U;
}
- }else{
+ } else {
enet_unknow_err++;
enet_rxframe_drop();
@@ -713,7 +722,7 @@ uint32_t enet_rxframe_size_get(void)
}
/*!
- \brief initialize the DMA Tx/Rx descriptors's parameters in chain mode
+ \brief initialize the DMA Tx/Rx descriptors's parameters in chain mode
\param[in] direction: the descriptors which users want to init, refer to enet_dmadirection_enum
only one parameter can be selected which is shown as below
\arg ENET_DMA_TX: DMA Tx descriptors
@@ -729,7 +738,7 @@ void enet_descriptors_chain_init(enet_dmadirection_enum direction)
uint8_t *buf;
/* if want to initialize DMA Tx descriptors */
- if (ENET_DMA_TX == direction){
+ if(ENET_DMA_TX == direction) {
/* save a copy of the DMA Tx descriptors */
desc_tab = txdesc_tab;
buf = &tx_buff[0][0];
@@ -742,7 +751,7 @@ void enet_descriptors_chain_init(enet_dmadirection_enum direction)
/* configure DMA Tx descriptor table address register */
ENET_DMA_TDTADDR = (uint32_t)desc_tab;
dma_current_txdesc = desc_tab;
- }else{
+ } else {
/* if want to initialize DMA Rx descriptors */
/* save a copy of the DMA Rx descriptors */
desc_tab = rxdesc_tab;
@@ -763,7 +772,7 @@ void enet_descriptors_chain_init(enet_dmadirection_enum direction)
dma_current_ptp_txdesc = NULL;
/* configure each descriptor */
- for(num=0U; num < count; num++){
+ for(num = 0U; num < count; num++) {
/* get the pointer to the next descriptor of the descriptor table */
desc = desc_tab + num;
@@ -773,10 +782,10 @@ void enet_descriptors_chain_init(enet_dmadirection_enum direction)
desc->buffer1_addr = (uint32_t)(&buf[num * maxsize]);
/* if is not the last descriptor */
- if(num < (count - 1U)){
+ if(num < (count - 1U)) {
/* configure the next descriptor address */
desc->buffer2_next_desc_addr = (uint32_t)(desc_tab + num + 1U);
- }else{
+ } else {
/* when it is the last descriptor, the next descriptor address
equals to first descriptor address in descriptor table */
desc->buffer2_next_desc_addr = (uint32_t) desc_tab;
@@ -785,7 +794,7 @@ void enet_descriptors_chain_init(enet_dmadirection_enum direction)
}
/*!
- \brief initialize the DMA Tx/Rx descriptors's parameters in ring mode
+ \brief initialize the DMA Tx/Rx descriptors's parameters in ring mode
\param[in] direction: the descriptors which users want to init, refer to enet_dmadirection_enum
only one parameter can be selected which is shown as below
\arg ENET_DMA_TX: DMA Tx descriptors
@@ -806,7 +815,7 @@ void enet_descriptors_ring_init(enet_dmadirection_enum direction)
ENET_DMA_BCTL |= DMA_BCTL_DPSL(0);
/* if want to initialize DMA Tx descriptors */
- if (ENET_DMA_TX == direction){
+ if(ENET_DMA_TX == direction) {
/* save a copy of the DMA Tx descriptors */
desc_tab = txdesc_tab;
buf = &tx_buff[0][0];
@@ -816,7 +825,7 @@ void enet_descriptors_ring_init(enet_dmadirection_enum direction)
/* configure DMA Tx descriptor table address register */
ENET_DMA_TDTADDR = (uint32_t)desc_tab;
dma_current_txdesc = desc_tab;
- }else{
+ } else {
/* if want to initialize DMA Rx descriptors */
/* save a copy of the DMA Rx descriptors */
desc_tab = rxdesc_tab;
@@ -829,7 +838,7 @@ void enet_descriptors_ring_init(enet_dmadirection_enum direction)
/* set buffer1 size */
desc_bufsize = ENET_RXBUF_SIZE;
- /* configure DMA Rx descriptor table address register */
+ /* configure DMA Rx descriptor table address register */
ENET_DMA_RDTADDR = (uint32_t)desc_tab;
dma_current_rxdesc = desc_tab;
}
@@ -837,7 +846,7 @@ void enet_descriptors_ring_init(enet_dmadirection_enum direction)
dma_current_ptp_txdesc = NULL;
/* configure each descriptor */
- for(num=0U; num < count; num++){
+ for(num = 0U; num < count; num++) {
/* get the pointer to the next descriptor of the descriptor table */
desc = desc_tab + num;
@@ -847,11 +856,11 @@ void enet_descriptors_ring_init(enet_dmadirection_enum direction)
desc->buffer1_addr = (uint32_t)(&buf[num * maxsize]);
/* when it is the last descriptor */
- if(num == (count - 1U)){
- if (ENET_DMA_TX == direction){
+ if(num == (count - 1U)) {
+ if(ENET_DMA_TX == direction) {
/* configure transmit end of ring mode */
desc->status |= ENET_TDES0_TERM;
- }else{
+ } else {
/* configure receive end of ring mode */
desc->control_buffer_size |= ENET_RDES1_RERM;
}
@@ -860,7 +869,7 @@ void enet_descriptors_ring_init(enet_dmadirection_enum direction)
}
/*!
- \brief handle current received frame data to application buffer
+ \brief handle current received frame data to application buffer
\param[in] bufsize: the size of buffer which is the parameter in function
\param[out] buffer: pointer to the received frame data
note -- if the input is NULL, user should copy data in application by himself
@@ -871,37 +880,37 @@ ErrStatus enet_frame_receive(uint8_t *buffer, uint32_t bufsize)
uint32_t offset = 0U, size = 0U;
/* the descriptor is busy due to own by the DMA */
- if((uint32_t)RESET != (dma_current_rxdesc->status & ENET_RDES0_DAV)){
+ if((uint32_t)RESET != (dma_current_rxdesc->status & ENET_RDES0_DAV)) {
return ERROR;
}
/* if buffer pointer is null, indicates that users has copied data in application */
- if(NULL != buffer){
+ if(NULL != buffer) {
/* if no error occurs, and the frame uses only one descriptor */
if((((uint32_t)RESET) == (dma_current_rxdesc->status & ENET_RDES0_ERRS)) &&
- (((uint32_t)RESET) != (dma_current_rxdesc->status & ENET_RDES0_LDES)) &&
- (((uint32_t)RESET) != (dma_current_rxdesc->status & ENET_RDES0_FDES))){
+ (((uint32_t)RESET) != (dma_current_rxdesc->status & ENET_RDES0_LDES)) &&
+ (((uint32_t)RESET) != (dma_current_rxdesc->status & ENET_RDES0_FDES))) {
/* get the frame length except CRC */
size = GET_RDES0_FRML(dma_current_rxdesc->status);
size = size - 4U;
/* if is a type frame, and CRC is not included in forwarding frame */
- if((RESET != (ENET_MAC_CFG & ENET_MAC_CFG_TFCD)) && (RESET != (dma_current_rxdesc->status & ENET_RDES0_FRMT))){
+ if((RESET != (ENET_MAC_CFG & ENET_MAC_CFG_TFCD)) && (RESET != (dma_current_rxdesc->status & ENET_RDES0_FRMT))) {
size = size + 4U;
}
/* to avoid situation that the frame size exceeds the buffer length */
- if(size > bufsize){
+ if(size > bufsize) {
return ERROR;
}
/* copy data from Rx buffer to application buffer */
- for(offset = 0U; offset<size; offset++){
- (*(buffer + offset)) = (*(__IO uint8_t *) (uint32_t)((dma_current_rxdesc->buffer1_addr) + offset));
+ for(offset = 0U; offset < size; offset++) {
+ (*(buffer + offset)) = (*(__IO uint8_t *)(uint32_t)((dma_current_rxdesc->buffer1_addr) + offset));
}
- }else{
+ } else {
/* return ERROR */
return ERROR;
}
@@ -910,7 +919,7 @@ ErrStatus enet_frame_receive(uint8_t *buffer, uint32_t bufsize)
dma_current_rxdesc->status = ENET_RDES0_DAV;
/* check Rx buffer unavailable flag status */
- if ((uint32_t)RESET != (ENET_DMA_STAT & ENET_DMA_STAT_RBU)){
+ if((uint32_t)RESET != (ENET_DMA_STAT & ENET_DMA_STAT_RBU)) {
/* clear RBU flag */
ENET_DMA_STAT = ENET_DMA_STAT_RBU;
/* resume DMA reception by writing to the RPEN register*/
@@ -919,16 +928,16 @@ ErrStatus enet_frame_receive(uint8_t *buffer, uint32_t bufsize)
/* update the current RxDMA descriptor pointer to the next decriptor in RxDMA decriptor table */
/* chained mode */
- if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RCHM)){
- dma_current_rxdesc = (enet_descriptors_struct*) (dma_current_rxdesc->buffer2_next_desc_addr);
- }else{
+ if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RCHM)) {
+ dma_current_rxdesc = (enet_descriptors_struct *)(dma_current_rxdesc->buffer2_next_desc_addr);
+ } else {
/* ring mode */
- if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RERM)){
+ if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RERM)) {
/* if is the last descriptor in table, the next descriptor is the table header */
- dma_current_rxdesc = (enet_descriptors_struct*) (ENET_DMA_RDTADDR);
- }else{
+ dma_current_rxdesc = (enet_descriptors_struct *)(ENET_DMA_RDTADDR);
+ } else {
/* the next descriptor is the current address, add the descriptor size, and descriptor skip length */
- dma_current_rxdesc = (enet_descriptors_struct*) (uint32_t)((uint32_t)dma_current_rxdesc + ETH_DMARXDESC_SIZE + (GET_DMA_BCTL_DPSL(ENET_DMA_BCTL)));
+ dma_current_rxdesc = (enet_descriptors_struct *)(uint32_t)((uint32_t)dma_current_rxdesc + ETH_DMARXDESC_SIZE + (GET_DMA_BCTL_DPSL(ENET_DMA_BCTL)));
}
}
@@ -936,7 +945,7 @@ ErrStatus enet_frame_receive(uint8_t *buffer, uint32_t bufsize)
}
/*!
- \brief handle application buffer data to transmit it
+ \brief handle application buffer data to transmit it
\param[in] buffer: pointer to the frame data to be transmitted,
note -- if the input is NULL, user should handle the data in application by himself
\param[in] length: the length of frame data to be transmitted
@@ -949,20 +958,20 @@ ErrStatus enet_frame_transmit(uint8_t *buffer, uint32_t length)
uint32_t dma_tbu_flag, dma_tu_flag;
/* the descriptor is busy due to own by the DMA */
- if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_DAV)){
+ if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_DAV)) {
return ERROR;
}
/* only frame length no more than ENET_MAX_FRAME_SIZE is allowed */
- if(length > ENET_MAX_FRAME_SIZE){
+ if(length > ENET_MAX_FRAME_SIZE) {
return ERROR;
}
/* if buffer pointer is null, indicates that users has handled data in application */
- if(NULL != buffer){
+ if(NULL != buffer) {
/* copy frame data from application buffer to Tx buffer */
- for(offset = 0U; offset < length; offset++){
- (*(__IO uint8_t *) (uint32_t)((dma_current_txdesc->buffer1_addr) + offset)) = (*(buffer + offset));
+ for(offset = 0U; offset < length; offset++) {
+ (*(__IO uint8_t *)(uint32_t)((dma_current_txdesc->buffer1_addr) + offset)) = (*(buffer + offset));
}
}
@@ -977,7 +986,7 @@ ErrStatus enet_frame_transmit(uint8_t *buffer, uint32_t length)
dma_tbu_flag = (ENET_DMA_STAT & ENET_DMA_STAT_TBU);
dma_tu_flag = (ENET_DMA_STAT & ENET_DMA_STAT_TU);
- if ((RESET != dma_tbu_flag) || (RESET != dma_tu_flag)){
+ if((RESET != dma_tbu_flag) || (RESET != dma_tu_flag)) {
/* clear TBU and TU flag */
ENET_DMA_STAT = (dma_tbu_flag | dma_tu_flag);
/* resume DMA transmission by writing to the TPEN register*/
@@ -986,16 +995,16 @@ ErrStatus enet_frame_transmit(uint8_t *buffer, uint32_t length)
/* update the current TxDMA descriptor pointer to the next decriptor in TxDMA decriptor table*/
/* chained mode */
- if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_TCHM)){
- dma_current_txdesc = (enet_descriptors_struct*) (dma_current_txdesc->buffer2_next_desc_addr);
- }else{
+ if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_TCHM)) {
+ dma_current_txdesc = (enet_descriptors_struct *)(dma_current_txdesc->buffer2_next_desc_addr);
+ } else {
/* ring mode */
- if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_TERM)){
+ if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_TERM)) {
/* if is the last descriptor in table, the next descriptor is the table header */
- dma_current_txdesc = (enet_descriptors_struct*) (ENET_DMA_TDTADDR);
- }else{
+ dma_current_txdesc = (enet_descriptors_struct *)(ENET_DMA_TDTADDR);
+ } else {
/* the next descriptor is the current address, add the descriptor size, and descriptor skip length */
- dma_current_txdesc = (enet_descriptors_struct*) (uint32_t)((uint32_t)dma_current_txdesc + ETH_DMATXDESC_SIZE + (GET_DMA_BCTL_DPSL(ENET_DMA_BCTL)));
+ dma_current_txdesc = (enet_descriptors_struct *)(uint32_t)((uint32_t)dma_current_txdesc + ETH_DMATXDESC_SIZE + (GET_DMA_BCTL_DPSL(ENET_DMA_BCTL)));
}
}
@@ -1003,7 +1012,7 @@ ErrStatus enet_frame_transmit(uint8_t *buffer, uint32_t length)
}
/*!
- \brief configure the transmit IP frame checksum offload calculation and insertion
+ \brief configure the transmit IP frame checksum offload calculation and insertion
\param[in] desc: the descriptor pointer which users want to configure, refer to enet_descriptors_struct
\param[in] checksum: IP frame checksum configuration
only one parameter can be selected which is shown as below
@@ -1021,7 +1030,7 @@ void enet_transmit_checksum_config(enet_descriptors_struct *desc, uint32_t check
}
/*!
- \brief ENET Tx and Rx function enable (include MAC and DMA module)
+ \brief ENET Tx and Rx function enable (include MAC and DMA module)
\param[in] none
\param[out] none
\retval none
@@ -1033,7 +1042,7 @@ void enet_enable(void)
}
/*!
- \brief ENET Tx and Rx function disable (include MAC and DMA module)
+ \brief ENET Tx and Rx function disable (include MAC and DMA module)
\param[in] none
\param[out] none
\retval none
@@ -1045,7 +1054,7 @@ void enet_disable(void)
}
/*!
- \brief configure MAC address
+ \brief configure MAC address
\param[in] mac_addr: select which MAC address will be set, refer to enet_macaddress_enum
only one parameter can be selected which is shown as below
\arg ENET_MAC_ADDRESS0: set MAC address 0 filter
@@ -1064,7 +1073,7 @@ void enet_mac_address_set(enet_macaddress_enum mac_addr, uint8_t paddr[])
}
/*!
- \brief get MAC address
+ \brief get MAC address
\param[in] mac_addr: select which MAC address will be get, refer to enet_macaddress_enum
only one parameter can be selected which is shown as below
\arg ENET_MAC_ADDRESS0: get MAC address 0 filter
@@ -1086,7 +1095,7 @@ void enet_mac_address_get(enet_macaddress_enum mac_addr, uint8_t paddr[])
}
/*!
- \brief get the ENET MAC/MSC/PTP/DMA status flag
+ \brief get the ENET MAC/MSC/PTP/DMA status flag
\param[in] enet_flag: ENET status flag, refer to enet_flag_enum,
only one parameter can be selected which is shown as below
\arg ENET_MAC_FLAG_MPKR: magic packet received flag
@@ -1131,15 +1140,15 @@ void enet_mac_address_get(enet_macaddress_enum mac_addr, uint8_t paddr[])
*/
FlagStatus enet_flag_get(enet_flag_enum enet_flag)
{
- if(RESET != (ENET_REG_VAL(enet_flag) & BIT(ENET_BIT_POS(enet_flag)))){
+ if(RESET != (ENET_REG_VAL(enet_flag) & BIT(ENET_BIT_POS(enet_flag)))) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief clear the ENET DMA status flag
+ \brief clear the ENET DMA status flag
\param[in] enet_flag: ENET DMA flag clear, refer to enet_flag_clear_enum
only one parameter can be selected which is shown as below
\arg ENET_DMA_FLAG_TS_CLR: transmit status flag clear
@@ -1167,7 +1176,7 @@ void enet_flag_clear(enet_flag_clear_enum enet_flag)
}
/*!
- \brief enable ENET MAC/MSC/DMA interrupt
+ \brief enable ENET MAC/MSC/DMA interrupt
\param[in] enet_int: ENET interrupt,, refer to enet_int_enum
only one parameter can be selected which is shown as below
\arg ENET_MAC_INT_WUMIM: WUM interrupt mask
@@ -1198,17 +1207,17 @@ void enet_flag_clear(enet_flag_clear_enum enet_flag)
*/
void enet_interrupt_enable(enet_int_enum enet_int)
{
- if(DMA_INTEN_REG_OFFSET == ((uint32_t)enet_int >> 6)){
+ if(DMA_INTEN_REG_OFFSET == ((uint32_t)enet_int >> 6)) {
/* ENET_DMA_INTEN register interrupt */
ENET_REG_VAL(enet_int) |= BIT(ENET_BIT_POS(enet_int));
- }else{
+ } else {
/* other INTMSK register interrupt */
ENET_REG_VAL(enet_int) &= ~BIT(ENET_BIT_POS(enet_int));
}
}
/*!
- \brief disable ENET MAC/MSC/DMA interrupt
+ \brief disable ENET MAC/MSC/DMA interrupt
\param[in] enet_int: ENET interrupt, refer to enet_int_enum
only one parameter can be selected which is shown as below
\arg ENET_MAC_INT_WUMIM: WUM interrupt mask
@@ -1239,17 +1248,17 @@ void enet_interrupt_enable(enet_int_enum enet_int)
*/
void enet_interrupt_disable(enet_int_enum enet_int)
{
- if(DMA_INTEN_REG_OFFSET == ((uint32_t)enet_int >> 6)){
+ if(DMA_INTEN_REG_OFFSET == ((uint32_t)enet_int >> 6)) {
/* ENET_DMA_INTEN register interrupt */
ENET_REG_VAL(enet_int) &= ~BIT(ENET_BIT_POS(enet_int));
- }else{
+ } else {
/* other INTMSK register interrupt */
ENET_REG_VAL(enet_int) |= BIT(ENET_BIT_POS(enet_int));
}
}
/*!
- \brief get ENET MAC/MSC/DMA interrupt flag
+ \brief get ENET MAC/MSC/DMA interrupt flag
\param[in] int_flag: ENET interrupt flag, refer to enet_int_flag_enum
only one parameter can be selected which is shown as below
\arg ENET_MAC_INT_FLAG_WUM: WUM status flag
@@ -1286,15 +1295,15 @@ void enet_interrupt_disable(enet_int_enum enet_int)
*/
FlagStatus enet_interrupt_flag_get(enet_int_flag_enum int_flag)
{
- if(RESET != (ENET_REG_VAL(int_flag) & BIT(ENET_BIT_POS(int_flag)))){
+ if(RESET != (ENET_REG_VAL(int_flag) & BIT(ENET_BIT_POS(int_flag)))) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief clear ENET DMA interrupt flag
+ \brief clear ENET DMA interrupt flag
\param[in] int_flag_clear: clear ENET interrupt flag, refer to enet_int_flag_clear_enum
only one parameter can be selected which is shown as below
\arg ENET_DMA_INT_FLAG_TS_CLR: transmit status flag
@@ -1322,7 +1331,7 @@ void enet_interrupt_flag_clear(enet_int_flag_clear_enum int_flag_clear)
}
/*!
- \brief ENET Tx function enable (include MAC and DMA module)
+ \brief ENET Tx function enable (include MAC and DMA module)
\param[in] none
\param[out] none
\retval none
@@ -1335,7 +1344,7 @@ void enet_tx_enable(void)
}
/*!
- \brief ENET Tx function disable (include MAC and DMA module)
+ \brief ENET Tx function disable (include MAC and DMA module)
\param[in] none
\param[out] none
\retval none
@@ -1348,7 +1357,7 @@ void enet_tx_disable(void)
}
/*!
- \brief ENET Rx function enable (include MAC and DMA module)
+ \brief ENET Rx function enable (include MAC and DMA module)
\param[in] none
\param[out] none
\retval none
@@ -1360,7 +1369,7 @@ void enet_rx_enable(void)
}
/*!
- \brief ENET Rx function disable (include MAC and DMA module)
+ \brief ENET Rx function disable (include MAC and DMA module)
\param[in] none
\param[out] none
\retval none
@@ -1372,7 +1381,7 @@ void enet_rx_disable(void)
}
/*!
- \brief put registers value into the application buffer
+ \brief put registers value into the application buffer
\param[in] type: register type which will be get, refer to enet_registers_type_enum,
only one parameter can be selected which is shown as below
\arg ALL_MAC_REG: get the registers within the offset scope between ENET_MAC_CFG and ENET_MAC_FCTH
@@ -1389,14 +1398,14 @@ void enet_registers_get(enet_registers_type_enum type, uint32_t *preg, uint32_t
offset = (uint32_t)type;
max = (uint32_t)type + num;
- limit = sizeof(enet_reg_tab)/sizeof(uint16_t);
+ limit = sizeof(enet_reg_tab) / sizeof(uint16_t);
/* prevent element in this array is out of range */
- if(max > limit){
+ if(max > limit) {
max = limit;
}
- for(; offset < max; offset++){
+ for(; offset < max; offset++) {
/* get value of the corresponding register */
*preg = REG32((ENET) + enet_reg_tab[offset]);
preg++;
@@ -1404,7 +1413,7 @@ void enet_registers_get(enet_registers_type_enum type, uint32_t *preg, uint32_t
}
/*!
- \brief get the enet debug status from the debug register
+ \brief get the enet debug status from the debug register
\param[in] mac_debug: enet debug status
only one parameter can be selected which is shown as below
\arg ENET_MAC_RECEIVER_NOT_IDLE: MAC receiver is not in idle state
@@ -1426,7 +1435,7 @@ uint32_t enet_debug_status_get(uint32_t mac_debug)
{
uint32_t temp_state = 0U;
- switch(mac_debug){
+ switch(mac_debug) {
case ENET_RX_ASYNCHRONOUS_FIFO_STATE:
temp_state = GET_MAC_DBG_RXAFS(ENET_MAC_DBG);
break;
@@ -1443,7 +1452,7 @@ uint32_t enet_debug_status_get(uint32_t mac_debug)
temp_state = GET_MAC_DBG_TXFRS(ENET_MAC_DBG);
break;
default:
- if(RESET != (ENET_MAC_DBG & mac_debug)){
+ if(RESET != (ENET_MAC_DBG & mac_debug)) {
temp_state = 0x1U;
}
break;
@@ -1452,7 +1461,7 @@ uint32_t enet_debug_status_get(uint32_t mac_debug)
}
/*!
- \brief enable the MAC address filter
+ \brief enable the MAC address filter
\param[in] mac_addr: select which MAC address will be enable, refer to enet_macaddress_enum
\arg ENET_MAC_ADDRESS1: enable MAC address 1 filter
\arg ENET_MAC_ADDRESS2: enable MAC address 2 filter
@@ -1466,7 +1475,7 @@ void enet_address_filter_enable(enet_macaddress_enum mac_addr)
}
/*!
- \brief disable the MAC address filter
+ \brief disable the MAC address filter
\param[in] mac_addr: select which MAC address will be disable, refer to enet_macaddress_enum
only one parameter can be selected which is shown as below
\arg ENET_MAC_ADDRESS1: disable MAC address 1 filter
@@ -1481,7 +1490,7 @@ void enet_address_filter_disable(enet_macaddress_enum mac_addr)
}
/*!
- \brief configure the MAC address filter
+ \brief configure the MAC address filter
\param[in] mac_addr: select which MAC address will be configured, refer to enet_macaddress_enum
only one parameter can be selected which is shown as below
\arg ENET_MAC_ADDRESS1: configure MAC address 1 filter
@@ -1516,7 +1525,7 @@ void enet_address_filter_config(enet_macaddress_enum mac_addr, uint32_t addr_mas
}
/*!
- \brief PHY interface configuration (configure SMI clock and reset PHY chip)
+ \brief PHY interface configuration (configure SMI clock and reset PHY chip)
\param[in] none
\param[out] none
\retval ErrStatus: SUCCESS or ERROR
@@ -1536,36 +1545,36 @@ ErrStatus enet_phy_config(void)
ahbclk = rcu_clock_freq_get(CK_AHB);
/* configure MDC clock according to HCLK frequency range */
- if(ENET_RANGE(ahbclk, 20000000U, 35000000U)){
+ if(ENET_RANGE(ahbclk, 20000000U, 35000000U)) {
reg |= ENET_MDC_HCLK_DIV16;
- }else if(ENET_RANGE(ahbclk, 35000000U, 60000000U)){
+ } else if(ENET_RANGE(ahbclk, 35000000U, 60000000U)) {
reg |= ENET_MDC_HCLK_DIV26;
- }else if(ENET_RANGE(ahbclk, 60000000U, 100000000U)){
+ } else if(ENET_RANGE(ahbclk, 60000000U, 100000000U)) {
reg |= ENET_MDC_HCLK_DIV42;
- }else if(ENET_RANGE(ahbclk, 100000000U, 150000000U)){
+ } else if(ENET_RANGE(ahbclk, 100000000U, 150000000U)) {
reg |= ENET_MDC_HCLK_DIV62;
- }else if((ENET_RANGE(ahbclk, 150000000U, 200000000U))||(200000000U == ahbclk)){
+ } else if((ENET_RANGE(ahbclk, 150000000U, 240000000U)) || (240000000U == ahbclk)) {
reg |= ENET_MDC_HCLK_DIV102;
- }else{
+ } else {
return enet_state;
}
ENET_MAC_PHY_CTL = reg;
/* reset PHY */
phy_value = PHY_RESET;
- if(ERROR == (enet_phy_write_read(ENET_PHY_WRITE, PHY_ADDRESS, PHY_REG_BCR, &phy_value))){
+ if(ERROR == (enet_phy_write_read(ENET_PHY_WRITE, PHY_ADDRESS, PHY_REG_BCR, &phy_value))) {
return enet_state;
}
/* PHY reset need some time */
_ENET_DELAY_(ENET_DELAY_TO);
/* check whether PHY reset is complete */
- if(ERROR == (enet_phy_write_read(ENET_PHY_READ, PHY_ADDRESS, PHY_REG_BCR, &phy_value))){
+ if(ERROR == (enet_phy_write_read(ENET_PHY_READ, PHY_ADDRESS, PHY_REG_BCR, &phy_value))) {
return enet_state;
}
/* PHY reset complete */
- if(RESET == (phy_value & PHY_RESET)){
+ if(RESET == (phy_value & PHY_RESET)) {
enet_state = SUCCESS;
}
@@ -1573,7 +1582,7 @@ ErrStatus enet_phy_config(void)
}
/*!
- \brief write to / read from a PHY register
+ \brief write to / read from a PHY register
\param[in] direction: only one parameter can be selected which is shown as below, refer to enet_phydirection_enum
\arg ENET_PHY_WRITE: write data to phy register
\arg ENET_PHY_READ: read data from phy register
@@ -1595,25 +1604,24 @@ ErrStatus enet_phy_write_read(enet_phydirection_enum direction, uint16_t phy_add
reg |= (direction | MAC_PHY_CTL_PR(phy_reg) | MAC_PHY_CTL_PA(phy_address) | ENET_MAC_PHY_CTL_PB);
/* if do the write operation, write value to the register */
- if(ENET_PHY_WRITE == direction){
+ if(ENET_PHY_WRITE == direction) {
ENET_MAC_PHY_DATA = *pvalue;
}
/* do PHY write/read operation, and wait the operation complete */
ENET_MAC_PHY_CTL = reg;
- do{
+ do {
phy_flag = (ENET_MAC_PHY_CTL & ENET_MAC_PHY_CTL_PB);
timeout++;
- }
- while((RESET != phy_flag) && (ENET_DELAY_TO != timeout));
+ } while((RESET != phy_flag) && (ENET_DELAY_TO != timeout));
/* write/read operation complete */
- if(RESET == (ENET_MAC_PHY_CTL & ENET_MAC_PHY_CTL_PB)){
+ if(RESET == (ENET_MAC_PHY_CTL & ENET_MAC_PHY_CTL_PB)) {
enet_state = SUCCESS;
}
/* if do the read operation, get value from the register */
- if(ENET_PHY_READ == direction){
+ if(ENET_PHY_READ == direction) {
*pvalue = (uint16_t)ENET_MAC_PHY_DATA;
}
@@ -1621,7 +1629,7 @@ ErrStatus enet_phy_write_read(enet_phydirection_enum direction, uint16_t phy_add
}
/*!
- \brief enable the loopback function of PHY chip
+ \brief enable the loopback function of PHY chip
\param[in] none
\param[out] none
\retval ErrStatus: ERROR or SUCCESS
@@ -1644,7 +1652,7 @@ ErrStatus enet_phyloopback_enable(void)
}
/*!
- \brief disable the loopback function of PHY chip
+ \brief disable the loopback function of PHY chip
\param[in] none
\param[out] none
\retval ErrStatus: ERROR or SUCCESS
@@ -1667,7 +1675,7 @@ ErrStatus enet_phyloopback_disable(void)
}
/*!
- \brief enable ENET forward feature
+ \brief enable ENET forward feature
\param[in] feature: the feature of ENET forward mode
one or more parameters can be selected which are shown as below
\arg ENET_AUTO_PADCRC_DROP: the function of the MAC strips the Pad/FCS field on received frames
@@ -1689,13 +1697,13 @@ void enet_forward_feature_enable(uint32_t feature)
}
/*!
- \brief disable ENET forward feature
+ \brief disable ENET forward feature
\param[in] feature: the feature of ENET forward mode
one or more parameters can be selected which are shown as below
- \arg ENET_AUTO_PADCRC_DROP: the automatic zero-quanta generation function
- \arg ENET_TYPEFRAME_CRC_DROP: the flow control operation in the MAC
- \arg ENET_FORWARD_ERRFRAMES: decoding function for the received pause frame and process it
- \arg ENET_FORWARD_UNDERSZ_GOODFRAMES: back pressure operation in the MAC(only use in half-dulex mode)
+ \arg ENET_AUTO_PADCRC_DROP: the function of the MAC strips the Pad/FCS field on received frames
+ \arg ENET_TYPEFRAME_CRC_DROP: the function that FCS field(last 4 bytes) of frame will be dropped before forwarding
+ \arg ENET_FORWARD_ERRFRAMES: the function that all frame received with error except runt error are forwarded to memory
+ \arg ENET_FORWARD_UNDERSZ_GOODFRAMES: the function that forwarding undersized good frames
\param[out] none
\retval none
*/
@@ -1730,7 +1738,7 @@ void enet_fliter_feature_enable(uint32_t feature)
}
/*!
- \brief disable ENET fliter feature
+ \brief disable ENET fliter feature
\param[in] feature: the feature of ENET fliter mode
one or more parameters can be selected which are shown as below
\arg ENET_SRC_FILTER: filter source address function
@@ -1749,7 +1757,7 @@ void enet_fliter_feature_disable(uint32_t feature)
}
/*!
- \brief generate the pause frame, ENET will send pause frame after enable transmit flow control
+ \brief generate the pause frame, ENET will send pause frame after enable transmit flow control
this function only use in full-dulex mode
\param[in] none
\param[out] none
@@ -1757,12 +1765,12 @@ void enet_fliter_feature_disable(uint32_t feature)
*/
ErrStatus enet_pauseframe_generate(void)
{
- ErrStatus enet_state =ERROR;
+ ErrStatus enet_state = ERROR;
uint32_t temp = 0U;
/* in full-duplex mode, must make sure this bit is 0 before writing register */
temp = ENET_MAC_FCTL & ENET_MAC_FCTL_FLCBBKPA;
- if(RESET == temp){
+ if(RESET == temp) {
ENET_MAC_FCTL |= ENET_MAC_FCTL_FLCBBKPA;
enet_state = SUCCESS;
}
@@ -1770,7 +1778,7 @@ ErrStatus enet_pauseframe_generate(void)
}
/*!
- \brief configure the pause frame detect type
+ \brief configure the pause frame detect type
\param[in] detect: pause frame detect type
only one parameter can be selected which is shown as below
\arg ENET_MAC0_AND_UNIQUE_ADDRESS_PAUSEDETECT: besides the unique multicast address, MAC can also
@@ -1787,7 +1795,7 @@ void enet_pauseframe_detect_config(uint32_t detect)
}
/*!
- \brief configure the pause frame parameters
+ \brief configure the pause frame parameters
\param[in] pausetime: pause time in transmit pause control frame
\param[in] pause_threshold: the threshold of the pause timer for retransmitting frames automatically
this value must make sure to be less than configured pause time
@@ -1806,7 +1814,7 @@ void enet_pauseframe_config(uint32_t pausetime, uint32_t pause_threshold)
}
/*!
- \brief configure the threshold of the flow control(deactive and active threshold)
+ \brief configure the threshold of the flow control(deactive and active threshold)
\param[in] deactive: the threshold of the deactive flow control
this value should always be less than active flow control value
only one parameter can be selected which is shown as below
@@ -1835,7 +1843,7 @@ void enet_flowcontrol_threshold_config(uint32_t deactive, uint32_t active)
}
/*!
- \brief enable ENET flow control feature
+ \brief enable ENET flow control feature
\param[in] feature: the feature of ENET flow control mode
one or more parameters can be selected which are shown as below
\arg ENET_ZERO_QUANTA_PAUSE: the automatic zero-quanta generation function
@@ -1847,7 +1855,7 @@ void enet_flowcontrol_threshold_config(uint32_t deactive, uint32_t active)
*/
void enet_flowcontrol_feature_enable(uint32_t feature)
{
- if(RESET != (feature & ENET_ZERO_QUANTA_PAUSE)){
+ if(RESET != (feature & ENET_ZERO_QUANTA_PAUSE)) {
ENET_MAC_FCTL &= ~ENET_ZERO_QUANTA_PAUSE;
}
feature &= ~ENET_ZERO_QUANTA_PAUSE;
@@ -1855,7 +1863,7 @@ void enet_flowcontrol_feature_enable(uint32_t feature)
}
/*!
- \brief disable ENET flow control feature
+ \brief disable ENET flow control feature
\param[in] feature: the feature of ENET flow control mode
one or more parameters can be selected which are shown as below
\arg ENET_ZERO_QUANTA_PAUSE: the automatic zero-quanta generation function
@@ -1867,7 +1875,7 @@ void enet_flowcontrol_feature_enable(uint32_t feature)
*/
void enet_flowcontrol_feature_disable(uint32_t feature)
{
- if(RESET != (feature & ENET_ZERO_QUANTA_PAUSE)){
+ if(RESET != (feature & ENET_ZERO_QUANTA_PAUSE)) {
ENET_MAC_FCTL |= ENET_ZERO_QUANTA_PAUSE;
}
feature &= ~ENET_ZERO_QUANTA_PAUSE;
@@ -1875,7 +1883,7 @@ void enet_flowcontrol_feature_disable(uint32_t feature)
}
/*!
- \brief get the dma transmit/receive process state
+ \brief get the dma transmit/receive process state
\param[in] direction: choose the direction of dma process which users want to check, refer to enet_dmadirection_enum
only one parameter can be selected which is shown as below
\arg ENET_DMA_TX: dma transmit process
@@ -1895,7 +1903,7 @@ uint32_t enet_dmaprocess_state_get(enet_dmadirection_enum direction)
}
/*!
- \brief poll the DMA transmission/reception enable by writing any value to the
+ \brief poll the DMA transmission/reception enable by writing any value to the
ENET_DMA_TPEN/ENET_DMA_RPEN register, this will make the DMA to resume transmission/reception
\param[in] direction: choose the direction of DMA process which users want to resume, refer to enet_dmadirection_enum
only one parameter can be selected which is shown as below
@@ -1906,15 +1914,15 @@ uint32_t enet_dmaprocess_state_get(enet_dmadirection_enum direction)
*/
void enet_dmaprocess_resume(enet_dmadirection_enum direction)
{
- if(ENET_DMA_TX == direction){
+ if(ENET_DMA_TX == direction) {
ENET_DMA_TPEN = 0U;
- }else{
+ } else {
ENET_DMA_RPEN = 0U;
}
}
/*!
- \brief check and recover the Rx process
+ \brief check and recover the Rx process
\param[in] none
\param[out] none
\retval none
@@ -1930,13 +1938,13 @@ void enet_rxprocess_check_recovery(void)
/* if current descriptor is owned by DMA, but the descriptor address mismatches with
receive descriptor address pointer updated by RxDMA controller */
if((ENET_DMA_CRDADDR != ((uint32_t)dma_current_rxdesc)) &&
- (ENET_RDES0_DAV == status)){
- dma_current_rxdesc = (enet_descriptors_struct*)ENET_DMA_CRDADDR;
+ (ENET_RDES0_DAV == status)) {
+ dma_current_rxdesc = (enet_descriptors_struct *)ENET_DMA_CRDADDR;
}
}
/*!
- \brief flush the ENET transmit FIFO, and wait until the flush operation completes
+ \brief flush the ENET transmit FIFO, and wait until the flush operation completes
\param[in] none
\param[out] none
\retval ErrStatus: ERROR or SUCCESS
@@ -1950,12 +1958,12 @@ ErrStatus enet_txfifo_flush(void)
/* set the FTF bit for flushing transmit FIFO */
ENET_DMA_CTL |= ENET_DMA_CTL_FTF;
/* wait until the flush operation completes */
- do{
+ do {
flush_state = ENET_DMA_CTL & ENET_DMA_CTL_FTF;
timeout++;
- }while((RESET != flush_state) && (timeout < ENET_DELAY_TO));
+ } while((RESET != flush_state) && (timeout < ENET_DELAY_TO));
/* return ERROR due to timeout */
- if(RESET == flush_state){
+ if(RESET == flush_state) {
enet_state = SUCCESS;
}
@@ -1963,7 +1971,7 @@ ErrStatus enet_txfifo_flush(void)
}
/*!
- \brief get the transmit/receive address of current descriptor, or current buffer, or descriptor table
+ \brief get the transmit/receive address of current descriptor, or current buffer, or descriptor table
\param[in] addr_get: choose the address which users want to get, refer to enet_desc_reg_enum
only one parameter can be selected which is shown as below
\arg ENET_RX_DESC_TABLE: the start address of the receive descriptor table
@@ -1981,12 +1989,12 @@ uint32_t enet_current_desc_address_get(enet_desc_reg_enum addr_get)
{
uint32_t reval = 0U;
- reval = REG32((ENET) +(uint32_t)addr_get);
+ reval = REG32((ENET) + (uint32_t)addr_get);
return reval;
}
/*!
- \brief get the Tx or Rx descriptor information
+ \brief get the Tx or Rx descriptor information
\param[in] desc: the descriptor pointer which users want to get information
\param[in] info_get: the descriptor information type which is selected, refer to enet_descstate_enum
only one parameter can be selected which is shown as below
@@ -2003,7 +2011,7 @@ uint32_t enet_desc_information_get(enet_descriptors_struct *desc, enet_descstate
{
uint32_t reval = 0xFFFFFFFFU;
- switch(info_get){
+ switch(info_get) {
case RXDESC_BUFFER_1_SIZE:
reval = GET_RDES1_RB1S(desc->control_buffer_size);
break;
@@ -2012,14 +2020,14 @@ uint32_t enet_desc_information_get(enet_descriptors_struct *desc, enet_descstate
break;
case RXDESC_FRAME_LENGTH:
reval = GET_RDES0_FRML(desc->status);
- if(reval > 4U){
+ if(reval > 4U) {
reval = reval - 4U;
/* if is a type frame, and CRC is not included in forwarding frame */
- if((RESET != (ENET_MAC_CFG & ENET_MAC_CFG_TFCD)) && (RESET != (desc->status & ENET_RDES0_FRMT))){
+ if((RESET != (ENET_MAC_CFG & ENET_MAC_CFG_TFCD)) && (RESET != (desc->status & ENET_RDES0_FRMT))) {
reval = reval + 4U;
}
- }else{
+ } else {
reval = 0U;
}
@@ -2040,7 +2048,7 @@ uint32_t enet_desc_information_get(enet_descriptors_struct *desc, enet_descstate
}
/*!
- \brief get the number of missed frames during receiving
+ \brief get the number of missed frames during receiving
\param[in] none
\param[out] rxfifo_drop: pointer to the number of frames dropped by RxFIFO
\param[out] rxdma_drop: pointer to the number of frames missed by the RxDMA controller
@@ -2056,7 +2064,7 @@ void enet_missed_frame_counter_get(uint32_t *rxfifo_drop, uint32_t *rxdma_drop)
}
/*!
- \brief get the bit flag of ENET DMA descriptor
+ \brief get the bit flag of ENET DMA descriptor
\param[in] desc: the descriptor pointer which users want to get flag
\param[in] desc_flag: the bit flag of ENET DMA descriptor
only one parameter can be selected which is shown as below
@@ -2111,7 +2119,7 @@ FlagStatus enet_desc_flag_get(enet_descriptors_struct *desc, uint32_t desc_flag)
{
FlagStatus enet_flag = RESET;
- if ((uint32_t)RESET != (desc->status & desc_flag)){
+ if((uint32_t)RESET != (desc->status & desc_flag)) {
enet_flag = SET;
}
@@ -2119,7 +2127,7 @@ FlagStatus enet_desc_flag_get(enet_descriptors_struct *desc, uint32_t desc_flag)
}
/*!
- \brief set the bit flag of ENET DMA descriptor
+ \brief set the bit flag of ENET DMA descriptor
\param[in] desc: the descriptor pointer which users want to set flag
\param[in] desc_flag: the bit flag of ENET DMA descriptor
only one parameter can be selected which is shown as below
@@ -2144,7 +2152,7 @@ void enet_desc_flag_set(enet_descriptors_struct *desc, uint32_t desc_flag)
}
/*!
- \brief clear the bit flag of ENET DMA descriptor
+ \brief clear the bit flag of ENET DMA descriptor
\param[in] desc: the descriptor pointer which users want to clear flag
\param[in] desc_flag: the bit flag of ENET DMA descriptor
only one parameter can be selected which is shown as below
@@ -2169,7 +2177,7 @@ void enet_desc_flag_clear(enet_descriptors_struct *desc, uint32_t desc_flag)
}
/*!
- \brief when receiving completed, set RS bit in ENET_DMA_STAT register will immediately set
+ \brief when receiving completed, set RS bit in ENET_DMA_STAT register will immediately set
\param[in] desc: the descriptor pointer which users want to configure
\param[out] none
\retval none
@@ -2180,7 +2188,7 @@ void enet_rx_desc_immediate_receive_complete_interrupt(enet_descriptors_struct *
}
/*!
- \brief when receiving completed, set RS bit in ENET_DMA_STAT register will is set after a configurable delay time
+ \brief when receiving completed, set RS bit in ENET_DMA_STAT register will is set after a configurable delay time
\param[in] desc: the descriptor pointer which users want to configure
\param[in] delay_time: delay a time of 256*delay_time HCLK(0x00000000 - 0x000000FF)
\param[out] none
@@ -2193,7 +2201,7 @@ void enet_rx_desc_delay_receive_complete_interrupt(enet_descriptors_struct *desc
}
/*!
- \brief drop current receive frame
+ \brief drop current receive frame
\param[in] none
\param[out] none
\retval none
@@ -2204,33 +2212,33 @@ void enet_rxframe_drop(void)
dma_current_rxdesc->status = ENET_RDES0_DAV;
/* chained mode */
- if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RCHM)){
- if(NULL != dma_current_ptp_rxdesc){
- dma_current_rxdesc = (enet_descriptors_struct*) (dma_current_ptp_rxdesc->buffer2_next_desc_addr);
+ if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RCHM)) {
+ if(NULL != dma_current_ptp_rxdesc) {
+ dma_current_rxdesc = (enet_descriptors_struct *)(dma_current_ptp_rxdesc->buffer2_next_desc_addr);
/* if it is the last ptp descriptor */
- if(0U != dma_current_ptp_rxdesc->status){
+ if(0U != dma_current_ptp_rxdesc->status) {
/* pointer back to the first ptp descriptor address in the desc_ptptab list address */
- dma_current_ptp_rxdesc = (enet_descriptors_struct*) (dma_current_ptp_rxdesc->status);
- }else{
+ dma_current_ptp_rxdesc = (enet_descriptors_struct *)(dma_current_ptp_rxdesc->status);
+ } else {
/* ponter to the next ptp descriptor */
dma_current_ptp_rxdesc++;
}
- }else{
- dma_current_rxdesc = (enet_descriptors_struct*) (dma_current_rxdesc->buffer2_next_desc_addr);
+ } else {
+ dma_current_rxdesc = (enet_descriptors_struct *)(dma_current_rxdesc->buffer2_next_desc_addr);
}
- }else{
+ } else {
/* ring mode */
- if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RERM)){
+ if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RERM)) {
/* if is the last descriptor in table, the next descriptor is the table header */
- dma_current_rxdesc = (enet_descriptors_struct*) (ENET_DMA_RDTADDR);
- if(NULL != dma_current_ptp_rxdesc){
- dma_current_ptp_rxdesc = (enet_descriptors_struct*) (dma_current_ptp_rxdesc->status);
+ dma_current_rxdesc = (enet_descriptors_struct *)(ENET_DMA_RDTADDR);
+ if(NULL != dma_current_ptp_rxdesc) {
+ dma_current_ptp_rxdesc = (enet_descriptors_struct *)(dma_current_ptp_rxdesc->status);
}
- }else{
+ } else {
/* the next descriptor is the current address, add the descriptor size, and descriptor skip length */
- dma_current_rxdesc = (enet_descriptors_struct*) (uint32_t)((uint32_t)dma_current_rxdesc + ETH_DMARXDESC_SIZE + GET_DMA_BCTL_DPSL(ENET_DMA_BCTL));
- if(NULL != dma_current_ptp_rxdesc){
+ dma_current_rxdesc = (enet_descriptors_struct *)(uint32_t)((uint32_t)dma_current_rxdesc + ETH_DMARXDESC_SIZE + GET_DMA_BCTL_DPSL(ENET_DMA_BCTL));
+ if(NULL != dma_current_ptp_rxdesc) {
dma_current_ptp_rxdesc++;
}
}
@@ -2238,7 +2246,7 @@ void enet_rxframe_drop(void)
}
/*!
- \brief enable DMA feature
+ \brief enable DMA feature
\param[in] feature: the feature of DMA mode
one or more parameters can be selected which are shown as below
\arg ENET_NO_FLUSH_RXFRAME: RxDMA does not flushes frames function
@@ -2252,7 +2260,7 @@ void enet_dma_feature_enable(uint32_t feature)
}
/*!
- \brief disable DMA feature
+ \brief disable DMA feature
\param[in] feature: the feature of DMA mode
one or more parameters can be selected which are shown as below
\arg ENET_NO_FLUSH_RXFRAME: RxDMA does not flushes frames function
@@ -2267,7 +2275,7 @@ void enet_dma_feature_disable(uint32_t feature)
#ifdef SELECT_DESCRIPTORS_ENHANCED_MODE
/*!
- \brief get the bit of extended status flag in ENET DMA descriptor
+ \brief get the bit of extended status flag in ENET DMA descriptor
\param[in] desc: the descriptor pointer which users want to get the extended status flag
\param[in] desc_status: the extended status want to get
only one parameter can be selected which is shown as below
@@ -2287,7 +2295,7 @@ uint32_t enet_rx_desc_enhanced_status_get(enet_descriptors_struct *desc, uint32_
{
uint32_t reval = 0xFFFFFFFFU;
- switch (desc_status){
+ switch(desc_status) {
case ENET_RDES4_IPPLDT:
reval = GET_RDES4_IPPLDT(desc->extended_status);
break;
@@ -2295,9 +2303,9 @@ uint32_t enet_rx_desc_enhanced_status_get(enet_descriptors_struct *desc, uint32_
reval = GET_RDES4_PTPMT(desc->extended_status);
break;
default:
- if ((uint32_t)RESET != (desc->extended_status & desc_status)){
+ if((uint32_t)RESET != (desc->extended_status & desc_status)) {
reval = 1U;
- }else{
+ } else {
reval = 0U;
}
}
@@ -2306,7 +2314,7 @@ uint32_t enet_rx_desc_enhanced_status_get(enet_descriptors_struct *desc, uint32_
}
/*!
- \brief configure descriptor to work in enhanced mode
+ \brief configure descriptor to work in enhanced mode
\param[in] none
\param[out] none
\retval none
@@ -2317,7 +2325,7 @@ void enet_desc_select_enhanced_mode(void)
}
/*!
- \brief initialize the DMA Tx/Rx descriptors's parameters in enhanced chain mode with ptp function
+ \brief initialize the DMA Tx/Rx descriptors's parameters in enhanced chain mode with ptp function
\param[in] direction: the descriptors which users want to init, refer to enet_dmadirection_enum
only one parameter can be selected which is shown as below
\arg ENET_DMA_TX: DMA Tx descriptors
@@ -2333,7 +2341,7 @@ void enet_ptp_enhanced_descriptors_chain_init(enet_dmadirection_enum direction)
uint8_t *buf;
/* if want to initialize DMA Tx descriptors */
- if (ENET_DMA_TX == direction){
+ if(ENET_DMA_TX == direction) {
/* save a copy of the DMA Tx descriptors */
desc_tab = txdesc_tab;
buf = &tx_buff[0][0];
@@ -2346,7 +2354,7 @@ void enet_ptp_enhanced_descriptors_chain_init(enet_dmadirection_enum direction)
/* configure DMA Tx descriptor table address register */
ENET_DMA_TDTADDR = (uint32_t)desc_tab;
dma_current_txdesc = desc_tab;
- }else{
+ } else {
/* if want to initialize DMA Rx descriptors */
/* save a copy of the DMA Rx descriptors */
desc_tab = rxdesc_tab;
@@ -2365,7 +2373,7 @@ void enet_ptp_enhanced_descriptors_chain_init(enet_dmadirection_enum direction)
}
/* configuration each descriptor */
- for(num = 0U; num < count; num++){
+ for(num = 0U; num < count; num++) {
/* get the pointer to the next descriptor of the descriptor table */
desc = desc_tab + num;
@@ -2375,10 +2383,10 @@ void enet_ptp_enhanced_descriptors_chain_init(enet_dmadirection_enum direction)
desc->buffer1_addr = (uint32_t)(&buf[num * maxsize]);
/* if is not the last descriptor */
- if(num < (count - 1U)){
+ if(num < (count - 1U)) {
/* configure the next descriptor address */
desc->buffer2_next_desc_addr = (uint32_t)(desc_tab + num + 1U);
- }else{
+ } else {
/* when it is the last descriptor, the next descriptor address
equals to first descriptor address in descriptor table */
desc->buffer2_next_desc_addr = (uint32_t)desc_tab;
@@ -2387,7 +2395,7 @@ void enet_ptp_enhanced_descriptors_chain_init(enet_dmadirection_enum direction)
}
/*!
- \brief initialize the DMA Tx/Rx descriptors's parameters in enhanced ring mode with ptp function
+ \brief initialize the DMA Tx/Rx descriptors's parameters in enhanced ring mode with ptp function
\param[in] direction: the descriptors which users want to init, refer to enet_dmadirection_enum
only one parameter can be selected which is shown as below
\arg ENET_DMA_TX: DMA Tx descriptors
@@ -2408,7 +2416,7 @@ void enet_ptp_enhanced_descriptors_ring_init(enet_dmadirection_enum direction)
ENET_DMA_BCTL |= DMA_BCTL_DPSL(0);
/* if want to initialize DMA Tx descriptors */
- if (ENET_DMA_TX == direction){
+ if(ENET_DMA_TX == direction) {
/* save a copy of the DMA Tx descriptors */
desc_tab = txdesc_tab;
buf = &tx_buff[0][0];
@@ -2421,7 +2429,7 @@ void enet_ptp_enhanced_descriptors_ring_init(enet_dmadirection_enum direction)
/* configure DMA Tx descriptor table address register */
ENET_DMA_TDTADDR = (uint32_t)desc_tab;
dma_current_txdesc = desc_tab;
- }else{
+ } else {
/* if want to initialize DMA Rx descriptors */
/* save a copy of the DMA Rx descriptors */
desc_tab = rxdesc_tab;
@@ -2434,13 +2442,13 @@ void enet_ptp_enhanced_descriptors_ring_init(enet_dmadirection_enum direction)
/* set buffer1 size */
desc_bufsize = ENET_RXBUF_SIZE;
- /* configure DMA Rx descriptor table address register */
+ /* configure DMA Rx descriptor table address register */
ENET_DMA_RDTADDR = (uint32_t)desc_tab;
dma_current_rxdesc = desc_tab;
}
/* configure each descriptor */
- for(num=0U; num < count; num++){
+ for(num = 0U; num < count; num++) {
/* get the pointer to the next descriptor of the descriptor table */
desc = desc_tab + num;
@@ -2450,11 +2458,11 @@ void enet_ptp_enhanced_descriptors_ring_init(enet_dmadirection_enum direction)
desc->buffer1_addr = (uint32_t)(&buf[num * maxsize]);
/* when it is the last descriptor */
- if(num == (count - 1U)){
- if (ENET_DMA_TX == direction){
+ if(num == (count - 1U)) {
+ if(ENET_DMA_TX == direction) {
/* configure transmit end of ring mode */
desc->status |= ENET_TDES0_TERM;
- }else{
+ } else {
/* configure receive end of ring mode */
desc->control_buffer_size |= ENET_RDES1_RERM;
}
@@ -2463,7 +2471,7 @@ void enet_ptp_enhanced_descriptors_ring_init(enet_dmadirection_enum direction)
}
/*!
- \brief receive a packet data with timestamp values to application buffer, when the DMA is in enhanced mode
+ \brief receive a packet data with timestamp values to application buffer, when the DMA is in enhanced mode
\param[in] bufsize: the size of buffer which is the parameter in function
\param[out] buffer: pointer to the application buffer
note -- if the input is NULL, user should copy data in application by himself
@@ -2478,49 +2486,49 @@ ErrStatus enet_ptpframe_receive_enhanced_mode(uint8_t *buffer, uint32_t bufsize,
uint32_t rdes0_tsv_flag;
/* the descriptor is busy due to own by the DMA */
- if((uint32_t)RESET != (dma_current_rxdesc->status & ENET_RDES0_DAV)){
+ if((uint32_t)RESET != (dma_current_rxdesc->status & ENET_RDES0_DAV)) {
return ERROR;
}
/* if buffer pointer is null, indicates that users has copied data in application */
- if(NULL != buffer){
+ if(NULL != buffer) {
/* if no error occurs, and the frame uses only one descriptor */
if(((uint32_t)RESET == (dma_current_rxdesc->status & ENET_RDES0_ERRS)) &&
- ((uint32_t)RESET != (dma_current_rxdesc->status & ENET_RDES0_LDES)) &&
- ((uint32_t)RESET != (dma_current_rxdesc->status & ENET_RDES0_FDES))){
+ ((uint32_t)RESET != (dma_current_rxdesc->status & ENET_RDES0_LDES)) &&
+ ((uint32_t)RESET != (dma_current_rxdesc->status & ENET_RDES0_FDES))) {
/* get the frame length except CRC */
size = GET_RDES0_FRML(dma_current_rxdesc->status) - 4U;
/* if is a type frame, and CRC is not included in forwarding frame */
- if((RESET != (ENET_MAC_CFG & ENET_MAC_CFG_TFCD)) && (RESET != (dma_current_rxdesc->status & ENET_RDES0_FRMT))){
+ if((RESET != (ENET_MAC_CFG & ENET_MAC_CFG_TFCD)) && (RESET != (dma_current_rxdesc->status & ENET_RDES0_FRMT))) {
size = size + 4U;
}
/* to avoid situation that the frame size exceeds the buffer length */
- if(size > bufsize){
+ if(size > bufsize) {
return ERROR;
}
/* copy data from Rx buffer to application buffer */
- for(offset = 0; offset < size; offset++){
+ for(offset = 0; offset < size; offset++) {
(*(buffer + offset)) = (*(__IO uint8_t *)((dma_current_rxdesc->buffer1_addr) + offset));
}
- }else{
+ } else {
return ERROR;
}
}
/* if timestamp pointer is null, indicates that users don't care timestamp in application */
- if(NULL != timestamp){
+ if(NULL != timestamp) {
/* wait for ENET_RDES0_TSV flag to be set, the timestamp value is taken and
write to the RDES6 and RDES7 */
- do{
+ do {
rdes0_tsv_flag = (dma_current_rxdesc->status & ENET_RDES0_TSV);
timeout++;
- }while ((RESET == rdes0_tsv_flag) && (timeout < ENET_DELAY_TO));
+ } while((RESET == rdes0_tsv_flag) && (timeout < ENET_DELAY_TO));
/* return ERROR due to timeout */
- if(ENET_DELAY_TO == timeout){
+ if(ENET_DELAY_TO == timeout) {
return ERROR;
}
@@ -2535,7 +2543,7 @@ ErrStatus enet_ptpframe_receive_enhanced_mode(uint8_t *buffer, uint32_t bufsize,
dma_current_rxdesc->status = ENET_RDES0_DAV;
/* check Rx buffer unavailable flag status */
- if ((uint32_t)RESET != (ENET_DMA_STAT & ENET_DMA_STAT_RBU)){
+ if((uint32_t)RESET != (ENET_DMA_STAT & ENET_DMA_STAT_RBU)) {
/* Clear RBU flag */
ENET_DMA_STAT = ENET_DMA_STAT_RBU;
/* resume DMA reception by writing to the RPEN register*/
@@ -2544,16 +2552,16 @@ ErrStatus enet_ptpframe_receive_enhanced_mode(uint8_t *buffer, uint32_t bufsize,
/* update the current RxDMA descriptor pointer to the next decriptor in RxDMA decriptor table */
/* chained mode */
- if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RCHM)){
- dma_current_rxdesc = (enet_descriptors_struct*) (dma_current_rxdesc->buffer2_next_desc_addr);
- }else{
+ if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RCHM)) {
+ dma_current_rxdesc = (enet_descriptors_struct *)(dma_current_rxdesc->buffer2_next_desc_addr);
+ } else {
/* ring mode */
- if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RERM)){
+ if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RERM)) {
/* if is the last descriptor in table, the next descriptor is the table header */
- dma_current_rxdesc = (enet_descriptors_struct*) (ENET_DMA_RDTADDR);
- }else{
+ dma_current_rxdesc = (enet_descriptors_struct *)(ENET_DMA_RDTADDR);
+ } else {
/* the next descriptor is the current address, add the descriptor size, and descriptor skip length */
- dma_current_rxdesc = (enet_descriptors_struct*) ((uint32_t)dma_current_rxdesc + ETH_DMARXDESC_SIZE + GET_DMA_BCTL_DPSL(ENET_DMA_BCTL));
+ dma_current_rxdesc = (enet_descriptors_struct *)((uint32_t)dma_current_rxdesc + ETH_DMARXDESC_SIZE + GET_DMA_BCTL_DPSL(ENET_DMA_BCTL));
}
}
@@ -2561,7 +2569,7 @@ ErrStatus enet_ptpframe_receive_enhanced_mode(uint8_t *buffer, uint32_t bufsize,
}
/*!
- \brief send data with timestamp values in application buffer as a transmit packet, when the DMA is in enhanced mode
+ \brief send data with timestamp values in application buffer as a transmit packet, when the DMA is in enhanced mode
\param[in] buffer: pointer on the application buffer
note -- if the input is NULL, user should copy data in application by himself
\param[in] length: the length of frame data to be transmitted
@@ -2577,19 +2585,19 @@ ErrStatus enet_ptpframe_transmit_enhanced_mode(uint8_t *buffer, uint32_t length,
uint32_t timeout = 0;
/* the descriptor is busy due to own by the DMA */
- if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_DAV)){
+ if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_DAV)) {
return ERROR;
}
/* only frame length no more than ENET_MAX_FRAME_SIZE is allowed */
- if(length > ENET_MAX_FRAME_SIZE){
+ if(length > ENET_MAX_FRAME_SIZE) {
return ERROR;
}
/* if buffer pointer is null, indicates that users has handled data in application */
- if(NULL != buffer){
+ if(NULL != buffer) {
/* copy frame data from application buffer to Tx buffer */
- for(offset = 0; offset < length; offset++){
+ for(offset = 0; offset < length; offset++) {
(*(__IO uint8_t *)((dma_current_txdesc->buffer1_addr) + offset)) = (*(buffer + offset));
}
}
@@ -2604,7 +2612,7 @@ ErrStatus enet_ptpframe_transmit_enhanced_mode(uint8_t *buffer, uint32_t length,
dma_tbu_flag = (ENET_DMA_STAT & ENET_DMA_STAT_TBU);
dma_tu_flag = (ENET_DMA_STAT & ENET_DMA_STAT_TU);
- if ((RESET != dma_tbu_flag) || (RESET != dma_tu_flag)){
+ if((RESET != dma_tbu_flag) || (RESET != dma_tu_flag)) {
/* Clear TBU and TU flag */
ENET_DMA_STAT = (dma_tbu_flag | dma_tu_flag);
/* resume DMA transmission by writing to the TPEN register*/
@@ -2612,15 +2620,15 @@ ErrStatus enet_ptpframe_transmit_enhanced_mode(uint8_t *buffer, uint32_t length,
}
/* if timestamp pointer is null, indicates that users don't care timestamp in application */
- if(NULL != timestamp){
+ if(NULL != timestamp) {
/* wait for ENET_TDES0_TTMSS flag to be set, a timestamp was captured */
- do{
+ do {
tdes0_ttmss_flag = (dma_current_txdesc->status & ENET_TDES0_TTMSS);
timeout++;
- }while((RESET == tdes0_ttmss_flag) && (timeout < ENET_DELAY_TO));
+ } while((RESET == tdes0_ttmss_flag) && (timeout < ENET_DELAY_TO));
/* return ERROR due to timeout */
- if(ENET_DELAY_TO == timeout){
+ if(ENET_DELAY_TO == timeout) {
return ERROR;
}
@@ -2633,16 +2641,16 @@ ErrStatus enet_ptpframe_transmit_enhanced_mode(uint8_t *buffer, uint32_t length,
/* update the current TxDMA descriptor pointer to the next decriptor in TxDMA decriptor table*/
/* chained mode */
- if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_TCHM)){
- dma_current_txdesc = (enet_descriptors_struct*) (dma_current_txdesc->buffer2_next_desc_addr);
- }else{
+ if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_TCHM)) {
+ dma_current_txdesc = (enet_descriptors_struct *)(dma_current_txdesc->buffer2_next_desc_addr);
+ } else {
/* ring mode */
- if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_TERM)){
+ if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_TERM)) {
/* if is the last descriptor in table, the next descriptor is the table header */
- dma_current_txdesc = (enet_descriptors_struct*) (ENET_DMA_TDTADDR);
- }else{
+ dma_current_txdesc = (enet_descriptors_struct *)(ENET_DMA_TDTADDR);
+ } else {
/* the next descriptor is the current address, add the descriptor size, and descriptor skip length */
- dma_current_txdesc = (enet_descriptors_struct*) ((uint32_t)dma_current_txdesc + ETH_DMATXDESC_SIZE + GET_DMA_BCTL_DPSL(ENET_DMA_BCTL));
+ dma_current_txdesc = (enet_descriptors_struct *)((uint32_t)dma_current_txdesc + ETH_DMATXDESC_SIZE + GET_DMA_BCTL_DPSL(ENET_DMA_BCTL));
}
}
@@ -2652,7 +2660,7 @@ ErrStatus enet_ptpframe_transmit_enhanced_mode(uint8_t *buffer, uint32_t length,
#else
/*!
- \brief configure descriptor to work in normal mode
+ \brief configure descriptor to work in normal mode
\param[in] none
\param[out] none
\retval none
@@ -2663,7 +2671,7 @@ void enet_desc_select_normal_mode(void)
}
/*!
- \brief initialize the DMA Tx/Rx descriptors's parameters in normal chain mode with PTP function
+ \brief initialize the DMA Tx/Rx descriptors's parameters in normal chain mode with PTP function
\param[in] direction: the descriptors which users want to init, refer to enet_dmadirection_enum
only one parameter can be selected which is shown as below
\arg ENET_DMA_TX: DMA Tx descriptors
@@ -2680,7 +2688,7 @@ void enet_ptp_normal_descriptors_chain_init(enet_dmadirection_enum direction, en
uint8_t *buf;
/* if want to initialize DMA Tx descriptors */
- if (ENET_DMA_TX == direction){
+ if(ENET_DMA_TX == direction) {
/* save a copy of the DMA Tx descriptors */
desc_tab = txdesc_tab;
buf = &tx_buff[0][0];
@@ -2694,7 +2702,7 @@ void enet_ptp_normal_descriptors_chain_init(enet_dmadirection_enum direction, en
ENET_DMA_TDTADDR = (uint32_t)desc_tab;
dma_current_txdesc = desc_tab;
dma_current_ptp_txdesc = desc_ptptab;
- }else{
+ } else {
/* if want to initialize DMA Rx descriptors */
/* save a copy of the DMA Rx descriptors */
desc_tab = rxdesc_tab;
@@ -2714,7 +2722,7 @@ void enet_ptp_normal_descriptors_chain_init(enet_dmadirection_enum direction, en
}
/* configure each descriptor */
- for(num = 0U; num < count; num++){
+ for(num = 0U; num < count; num++) {
/* get the pointer to the next descriptor of the descriptor table */
desc = desc_tab + num;
@@ -2724,10 +2732,10 @@ void enet_ptp_normal_descriptors_chain_init(enet_dmadirection_enum direction, en
desc->buffer1_addr = (uint32_t)(&buf[num * maxsize]);
/* if is not the last descriptor */
- if(num < (count - 1U)){
+ if(num < (count - 1U)) {
/* configure the next descriptor address */
desc->buffer2_next_desc_addr = (uint32_t)(desc_tab + num + 1U);
- }else{
+ } else {
/* when it is the last descriptor, the next descriptor address
equals to first descriptor address in descriptor table */
desc->buffer2_next_desc_addr = (uint32_t)desc_tab;
@@ -2738,11 +2746,11 @@ void enet_ptp_normal_descriptors_chain_init(enet_dmadirection_enum direction, en
}
/* when it is the last ptp descriptor, preserve the first descriptor
address of desc_ptptab in ptp descriptor status */
- (&desc_ptptab[num-1U])->status = (uint32_t)desc_ptptab;
+ (&desc_ptptab[num - 1U])->status = (uint32_t)desc_ptptab;
}
/*!
- \brief initialize the DMA Tx/Rx descriptors's parameters in normal ring mode with PTP function
+ \brief initialize the DMA Tx/Rx descriptors's parameters in normal ring mode with PTP function
\param[in] direction: the descriptors which users want to init, refer to enet_dmadirection_enum
only one parameter can be selected which is shown as below
\arg ENET_DMA_TX: DMA Tx descriptors
@@ -2763,7 +2771,7 @@ void enet_ptp_normal_descriptors_ring_init(enet_dmadirection_enum direction, ene
ENET_DMA_BCTL |= DMA_BCTL_DPSL(0);
/* if want to initialize DMA Tx descriptors */
- if (ENET_DMA_TX == direction){
+ if(ENET_DMA_TX == direction) {
/* save a copy of the DMA Tx descriptors */
desc_tab = txdesc_tab;
buf = &tx_buff[0][0];
@@ -2777,7 +2785,7 @@ void enet_ptp_normal_descriptors_ring_init(enet_dmadirection_enum direction, ene
ENET_DMA_TDTADDR = (uint32_t)desc_tab;
dma_current_txdesc = desc_tab;
dma_current_ptp_txdesc = desc_ptptab;
- }else{
+ } else {
/* if want to initialize DMA Rx descriptors */
/* save a copy of the DMA Rx descriptors */
desc_tab = rxdesc_tab;
@@ -2797,7 +2805,7 @@ void enet_ptp_normal_descriptors_ring_init(enet_dmadirection_enum direction, ene
}
/* configure each descriptor */
- for(num = 0U; num < count; num++){
+ for(num = 0U; num < count; num++) {
/* get the pointer to the next descriptor of the descriptor table */
desc = desc_tab + num;
@@ -2807,11 +2815,11 @@ void enet_ptp_normal_descriptors_ring_init(enet_dmadirection_enum direction, ene
desc->buffer1_addr = (uint32_t)(&buf[num * maxsize]);
/* when it is the last descriptor */
- if(num == (count - 1U)){
- if (ENET_DMA_TX == direction){
+ if(num == (count - 1U)) {
+ if(ENET_DMA_TX == direction) {
/* configure transmit end of ring mode */
desc->status |= ENET_TDES0_TERM;
- }else{
+ } else {
/* configure receive end of ring mode */
desc->control_buffer_size |= ENET_RDES1_RERM;
}
@@ -2822,11 +2830,11 @@ void enet_ptp_normal_descriptors_ring_init(enet_dmadirection_enum direction, ene
}
/* when it is the last ptp descriptor, preserve the first descriptor
address of desc_ptptab in ptp descriptor status */
- (&desc_ptptab[num-1U])->status = (uint32_t)desc_ptptab;
+ (&desc_ptptab[num - 1U])->status = (uint32_t)desc_ptptab;
}
/*!
- \brief receive a packet data with timestamp values to application buffer, when the DMA is in normal mode
+ \brief receive a packet data with timestamp values to application buffer, when the DMA is in normal mode
\param[in] bufsize: the size of buffer which is the parameter in function
\param[out] buffer: pointer to the application buffer
note -- if the input is NULL, user should copy data in application by himself
@@ -2838,35 +2846,35 @@ ErrStatus enet_ptpframe_receive_normal_mode(uint8_t *buffer, uint32_t bufsize, u
uint32_t offset = 0U, size = 0U;
/* the descriptor is busy due to own by the DMA */
- if((uint32_t)RESET != (dma_current_rxdesc->status & ENET_RDES0_DAV)){
+ if((uint32_t)RESET != (dma_current_rxdesc->status & ENET_RDES0_DAV)) {
return ERROR;
}
/* if buffer pointer is null, indicates that users has copied data in application */
- if(NULL != buffer){
+ if(NULL != buffer) {
/* if no error occurs, and the frame uses only one descriptor */
if(((uint32_t)RESET == (dma_current_rxdesc->status & ENET_RDES0_ERRS)) &&
- ((uint32_t)RESET != (dma_current_rxdesc->status & ENET_RDES0_LDES)) &&
- ((uint32_t)RESET != (dma_current_rxdesc->status & ENET_RDES0_FDES))){
+ ((uint32_t)RESET != (dma_current_rxdesc->status & ENET_RDES0_LDES)) &&
+ ((uint32_t)RESET != (dma_current_rxdesc->status & ENET_RDES0_FDES))) {
/* get the frame length except CRC */
size = GET_RDES0_FRML(dma_current_rxdesc->status) - 4U;
/* if is a type frame, and CRC is not included in forwarding frame */
- if((RESET != (ENET_MAC_CFG & ENET_MAC_CFG_TFCD)) && (RESET != (dma_current_rxdesc->status & ENET_RDES0_FRMT))){
+ if((RESET != (ENET_MAC_CFG & ENET_MAC_CFG_TFCD)) && (RESET != (dma_current_rxdesc->status & ENET_RDES0_FRMT))) {
size = size + 4U;
}
/* to avoid situation that the frame size exceeds the buffer length */
- if(size > bufsize){
+ if(size > bufsize) {
return ERROR;
}
/* copy data from Rx buffer to application buffer */
- for(offset = 0U; offset < size; offset++){
+ for(offset = 0U; offset < size; offset++) {
(*(buffer + offset)) = (*(__IO uint8_t *)(uint32_t)((dma_current_ptp_rxdesc->buffer1_addr) + offset));
}
- }else{
+ } else {
return ERROR;
}
}
@@ -2881,7 +2889,7 @@ ErrStatus enet_ptpframe_receive_normal_mode(uint8_t *buffer, uint32_t bufsize, u
dma_current_rxdesc->status = ENET_RDES0_DAV;
/* check Rx buffer unavailable flag status */
- if ((uint32_t)RESET != (ENET_DMA_STAT & ENET_DMA_STAT_RBU)){
+ if((uint32_t)RESET != (ENET_DMA_STAT & ENET_DMA_STAT_RBU)) {
/* clear RBU flag */
ENET_DMA_STAT = ENET_DMA_STAT_RBU;
/* resume DMA reception by writing to the RPEN register*/
@@ -2891,27 +2899,27 @@ ErrStatus enet_ptpframe_receive_normal_mode(uint8_t *buffer, uint32_t bufsize, u
/* update the current RxDMA descriptor pointer to the next decriptor in RxDMA decriptor table */
/* chained mode */
- if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RCHM)){
- dma_current_rxdesc = (enet_descriptors_struct*) (dma_current_ptp_rxdesc->buffer2_next_desc_addr);
+ if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RCHM)) {
+ dma_current_rxdesc = (enet_descriptors_struct *)(dma_current_ptp_rxdesc->buffer2_next_desc_addr);
/* if it is the last ptp descriptor */
- if(0U != dma_current_ptp_rxdesc->status){
+ if(0U != dma_current_ptp_rxdesc->status) {
/* pointer back to the first ptp descriptor address in the desc_ptptab list address */
- dma_current_ptp_rxdesc = (enet_descriptors_struct*) (dma_current_ptp_rxdesc->status);
- }else{
+ dma_current_ptp_rxdesc = (enet_descriptors_struct *)(dma_current_ptp_rxdesc->status);
+ } else {
/* ponter to the next ptp descriptor */
dma_current_ptp_rxdesc++;
}
- }else{
+ } else {
/* ring mode */
- if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RERM)){
+ if((uint32_t)RESET != (dma_current_rxdesc->control_buffer_size & ENET_RDES1_RERM)) {
/* if is the last descriptor in table, the next descriptor is the table header */
- dma_current_rxdesc = (enet_descriptors_struct*) (ENET_DMA_RDTADDR);
+ dma_current_rxdesc = (enet_descriptors_struct *)(ENET_DMA_RDTADDR);
/* RDES2 and RDES3 will not be covered by buffer address, so do not need to preserve a new table,
use the same table with RxDMA descriptor */
- dma_current_ptp_rxdesc = (enet_descriptors_struct*) (dma_current_ptp_rxdesc->status);
- }else{
+ dma_current_ptp_rxdesc = (enet_descriptors_struct *)(dma_current_ptp_rxdesc->status);
+ } else {
/* the next descriptor is the current address, add the descriptor size, and descriptor skip length */
- dma_current_rxdesc = (enet_descriptors_struct*) (uint32_t)((uint32_t)dma_current_rxdesc + ETH_DMARXDESC_SIZE + GET_DMA_BCTL_DPSL(ENET_DMA_BCTL));
+ dma_current_rxdesc = (enet_descriptors_struct *)(uint32_t)((uint32_t)dma_current_rxdesc + ETH_DMARXDESC_SIZE + GET_DMA_BCTL_DPSL(ENET_DMA_BCTL));
dma_current_ptp_rxdesc ++;
}
}
@@ -2920,7 +2928,7 @@ ErrStatus enet_ptpframe_receive_normal_mode(uint8_t *buffer, uint32_t bufsize, u
}
/*!
- \brief send data with timestamp values in application buffer as a transmit packet, when the DMA is in normal mode
+ \brief send data with timestamp values in application buffer as a transmit packet, when the DMA is in normal mode
\param[in] buffer: pointer on the application buffer
note -- if the input is NULL, user should copy data in application by himself
\param[in] length: the length of frame data to be transmitted
@@ -2934,20 +2942,20 @@ ErrStatus enet_ptpframe_transmit_normal_mode(uint8_t *buffer, uint32_t length, u
uint32_t dma_tbu_flag, dma_tu_flag, tdes0_ttmss_flag;
/* the descriptor is busy due to own by the DMA */
- if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_DAV)){
+ if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_DAV)) {
return ERROR;
}
/* only frame length no more than ENET_MAX_FRAME_SIZE is allowed */
- if(length > ENET_MAX_FRAME_SIZE){
+ if(length > ENET_MAX_FRAME_SIZE) {
return ERROR;
}
/* if buffer pointer is null, indicates that users has handled data in application */
- if(NULL != buffer){
+ if(NULL != buffer) {
/* copy frame data from application buffer to Tx buffer */
- for(offset = 0U; offset < length; offset++){
- (*(__IO uint8_t *) (uint32_t)((dma_current_ptp_txdesc->buffer1_addr) + offset)) = (*(buffer + offset));
+ for(offset = 0U; offset < length; offset++) {
+ (*(__IO uint8_t *)(uint32_t)((dma_current_ptp_txdesc->buffer1_addr) + offset)) = (*(buffer + offset));
}
}
/* set the frame length */
@@ -2961,7 +2969,7 @@ ErrStatus enet_ptpframe_transmit_normal_mode(uint8_t *buffer, uint32_t length, u
dma_tbu_flag = (ENET_DMA_STAT & ENET_DMA_STAT_TBU);
dma_tu_flag = (ENET_DMA_STAT & ENET_DMA_STAT_TU);
- if((RESET != dma_tbu_flag) || (RESET != dma_tu_flag)){
+ if((RESET != dma_tbu_flag) || (RESET != dma_tu_flag)) {
/* clear TBU and TU flag */
ENET_DMA_STAT = (dma_tbu_flag | dma_tu_flag);
/* resume DMA transmission by writing to the TPEN register*/
@@ -2969,15 +2977,15 @@ ErrStatus enet_ptpframe_transmit_normal_mode(uint8_t *buffer, uint32_t length, u
}
/* if timestamp pointer is null, indicates that users don't care timestamp in application */
- if(NULL != timestamp){
+ if(NULL != timestamp) {
/* wait for ENET_TDES0_TTMSS flag to be set, a timestamp was captured */
- do{
+ do {
tdes0_ttmss_flag = (dma_current_txdesc->status & ENET_TDES0_TTMSS);
timeout++;
- }while((RESET == tdes0_ttmss_flag) && (timeout < ENET_DELAY_TO));
+ } while((RESET == tdes0_ttmss_flag) && (timeout < ENET_DELAY_TO));
/* return ERROR due to timeout */
- if(ENET_DELAY_TO == timeout){
+ if(ENET_DELAY_TO == timeout) {
return ERROR;
}
@@ -2992,27 +3000,27 @@ ErrStatus enet_ptpframe_transmit_normal_mode(uint8_t *buffer, uint32_t length, u
/* update the current TxDMA descriptor pointer to the next decriptor in TxDMA decriptor table */
/* chained mode */
- if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_TCHM)){
- dma_current_txdesc = (enet_descriptors_struct*) (dma_current_ptp_txdesc->buffer2_next_desc_addr);
+ if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_TCHM)) {
+ dma_current_txdesc = (enet_descriptors_struct *)(dma_current_ptp_txdesc->buffer2_next_desc_addr);
/* if it is the last ptp descriptor */
- if(0U != dma_current_ptp_txdesc->status){
+ if(0U != dma_current_ptp_txdesc->status) {
/* pointer back to the first ptp descriptor address in the desc_ptptab list address */
- dma_current_ptp_txdesc = (enet_descriptors_struct*) (dma_current_ptp_txdesc->status);
- }else{
+ dma_current_ptp_txdesc = (enet_descriptors_struct *)(dma_current_ptp_txdesc->status);
+ } else {
/* ponter to the next ptp descriptor */
dma_current_ptp_txdesc++;
}
- }else{
+ } else {
/* ring mode */
- if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_TERM)){
+ if((uint32_t)RESET != (dma_current_txdesc->status & ENET_TDES0_TERM)) {
/* if is the last descriptor in table, the next descriptor is the table header */
- dma_current_txdesc = (enet_descriptors_struct*) (ENET_DMA_TDTADDR);
+ dma_current_txdesc = (enet_descriptors_struct *)(ENET_DMA_TDTADDR);
/* TDES2 and TDES3 will not be covered by buffer address, so do not need to preserve a new table,
use the same table with TxDMA descriptor */
- dma_current_ptp_txdesc = (enet_descriptors_struct*) (dma_current_ptp_txdesc->status);
- }else{
+ dma_current_ptp_txdesc = (enet_descriptors_struct *)(dma_current_ptp_txdesc->status);
+ } else {
/* the next descriptor is the current address, add the descriptor size, and descriptor skip length */
- dma_current_txdesc = (enet_descriptors_struct*) (uint32_t)((uint32_t)dma_current_txdesc + ETH_DMATXDESC_SIZE + GET_DMA_BCTL_DPSL(ENET_DMA_BCTL));
+ dma_current_txdesc = (enet_descriptors_struct *)(uint32_t)((uint32_t)dma_current_txdesc + ETH_DMATXDESC_SIZE + GET_DMA_BCTL_DPSL(ENET_DMA_BCTL));
dma_current_ptp_txdesc ++;
}
}
@@ -3022,7 +3030,7 @@ ErrStatus enet_ptpframe_transmit_normal_mode(uint8_t *buffer, uint32_t length, u
#endif /* SELECT_DESCRIPTORS_ENHANCED_MODE */
/*!
- \brief wakeup frame filter register pointer reset
+ \brief wakeup frame filter register pointer reset
\param[in] none
\param[out] none
\retval none
@@ -3033,7 +3041,7 @@ void enet_wum_filter_register_pointer_reset(void)
}
/*!
- \brief set the remote wakeup frame registers
+ \brief set the remote wakeup frame registers
\param[in] pdata: pointer to buffer data which is written to remote wakeup frame registers (8 words total)
\param[out] none
\retval none
@@ -3043,13 +3051,13 @@ void enet_wum_filter_config(uint32_t pdata[])
uint32_t num = 0U;
/* configure ENET_MAC_RWFF register */
- for(num = 0U; num < ETH_WAKEUP_REGISTER_LENGTH; num++){
+ for(num = 0U; num < ETH_WAKEUP_REGISTER_LENGTH; num++) {
ENET_MAC_RWFF = pdata[num];
}
}
/*!
- \brief enable wakeup management features
+ \brief enable wakeup management features
\param[in] feature: the wake up type which is selected
one or more parameters can be selected which are shown as below
\arg ENET_WUM_POWER_DOWN: power down mode
@@ -3065,7 +3073,7 @@ void enet_wum_feature_enable(uint32_t feature)
}
/*!
- \brief disable wakeup management features
+ \brief disable wakeup management features
\param[in] feature: the wake up type which is selected
one or more parameters can be selected which are shown as below
\arg ENET_WUM_MAGIC_PACKET_FRAME: enable a wakeup event due to magic packet reception
@@ -3080,7 +3088,7 @@ void enet_wum_feature_disable(uint32_t feature)
}
/*!
- \brief reset the MAC statistics counters
+ \brief reset the MAC statistics counters
\param[in] none
\param[out] none
\retval none
@@ -3092,7 +3100,7 @@ void enet_msc_counters_reset(void)
}
/*!
- \brief enable the MAC statistics counter features
+ \brief enable the MAC statistics counter features
\param[in] feature: the feature of MAC statistics counter
one or more parameters can be selected which are shown as below
\arg ENET_MSC_COUNTER_STOP_ROLLOVER: counter stop rollover
@@ -3107,7 +3115,7 @@ void enet_msc_feature_enable(uint32_t feature)
}
/*!
- \brief disable the MAC statistics counter features
+ \brief disable the MAC statistics counter features
\param[in] feature: the feature of MAC statistics counter
one or more parameters can be selected which are shown as below
\arg ENET_MSC_COUNTER_STOP_ROLLOVER: counter stop rollover
@@ -3118,11 +3126,11 @@ void enet_msc_feature_enable(uint32_t feature)
*/
void enet_msc_feature_disable(uint32_t feature)
{
- ENET_MSC_CTL &= (~feature);
+ ENET_MSC_CTL &= (~feature);
}
/*!
- \brief configure MAC statistics counters preset mode
+ \brief configure MAC statistics counters preset mode
\param[in] mode: MSC counters preset mode, refer to enet_msc_preset_enum
only one parameter can be selected which is shown as below
\arg ENET_MSC_PRESET_NONE: do not preset MSC counter
@@ -3138,7 +3146,7 @@ void enet_msc_counters_preset_config(enet_msc_preset_enum mode)
}
/*!
- \brief get MAC statistics counter
+ \brief get MAC statistics counter
\param[in] counter: MSC counters which is selected, refer to enet_msc_counter_enum
only one parameter can be selected which is shown as below
\arg ENET_MSC_TX_SCCNT: MSC transmitted good frames after a single collision counter
@@ -3160,7 +3168,7 @@ uint32_t enet_msc_counters_get(enet_msc_counter_enum counter)
}
/*!
- \brief enable the PTP features
+ \brief enable the PTP features
\param[in] feature: the feature of ENET PTP mode
one or more parameters can be selected which are shown as below
\arg ENET_RXTX_TIMESTAMP: timestamp function for transmit and receive frames
@@ -3179,7 +3187,7 @@ void enet_ptp_feature_enable(uint32_t feature)
}
/*!
- \brief disable the PTP features
+ \brief disable the PTP features
\param[in] feature: the feature of ENET PTP mode
one or more parameters can be selected which are shown as below
\arg ENET_RXTX_TIMESTAMP: timestamp function for transmit and receive frames
@@ -3198,7 +3206,7 @@ void enet_ptp_feature_disable(uint32_t feature)
}
/*!
- \brief configure the PTP timestamp function
+ \brief configure the PTP timestamp function
\param[in] func: the function of PTP timestamp
only one parameter can be selected which is shown as below
\arg ENET_CKNT_ORDINARY: type of ordinary clock node type for timestamp
@@ -3228,7 +3236,7 @@ ErrStatus enet_ptp_timestamp_function_config(enet_ptp_function_enum func)
uint32_t timeout = 0U;
ErrStatus enet_state = SUCCESS;
- switch(func){
+ switch(func) {
case ENET_CKNT_ORDINARY:
case ENET_CKNT_BOUNDARY:
case ENET_CKNT_END_TO_END:
@@ -3238,48 +3246,48 @@ ErrStatus enet_ptp_timestamp_function_config(enet_ptp_function_enum func)
break;
case ENET_PTP_ADDEND_UPDATE:
/* this bit must be read as zero before application set it */
- do{
+ do {
temp_state = ENET_PTP_TSCTL & ENET_PTP_TSCTL_TMSARU;
timeout++;
- }while((RESET != temp_state) && (timeout < ENET_DELAY_TO));
+ } while((RESET != temp_state) && (timeout < ENET_DELAY_TO));
/* return ERROR due to timeout */
- if(ENET_DELAY_TO == timeout){
+ if(ENET_DELAY_TO == timeout) {
enet_state = ERROR;
- }else{
+ } else {
ENET_PTP_TSCTL |= ENET_PTP_TSCTL_TMSARU;
}
break;
case ENET_PTP_SYSTIME_UPDATE:
/* both the TMSSTU and TMSSTI bits must be read as zero before application set this bit */
- do{
+ do {
temp_state = ENET_PTP_TSCTL & (ENET_PTP_TSCTL_TMSSTU | ENET_PTP_TSCTL_TMSSTI);
timeout++;
- }while((RESET != temp_state) && (timeout < ENET_DELAY_TO));
+ } while((RESET != temp_state) && (timeout < ENET_DELAY_TO));
/* return ERROR due to timeout */
- if(ENET_DELAY_TO == timeout){
+ if(ENET_DELAY_TO == timeout) {
enet_state = ERROR;
- }else{
+ } else {
ENET_PTP_TSCTL |= ENET_PTP_TSCTL_TMSSTU;
}
break;
case ENET_PTP_SYSTIME_INIT:
/* this bit must be read as zero before application set it */
- do{
+ do {
temp_state = ENET_PTP_TSCTL & ENET_PTP_TSCTL_TMSSTI;
timeout++;
- }while((RESET != temp_state) && (timeout < ENET_DELAY_TO));
+ } while((RESET != temp_state) && (timeout < ENET_DELAY_TO));
/* return ERROR due to timeout */
- if(ENET_DELAY_TO == timeout){
+ if(ENET_DELAY_TO == timeout) {
enet_state = ERROR;
- }else{
+ } else {
ENET_PTP_TSCTL |= ENET_PTP_TSCTL_TMSSTI;
}
break;
default:
temp_config = (uint32_t)func & (~BIT(31));
- if(RESET != ((uint32_t)func & BIT(31))){
+ if(RESET != ((uint32_t)func & BIT(31))) {
ENET_PTP_TSCTL |= temp_config;
- }else{
+ } else {
ENET_PTP_TSCTL &= ~temp_config;
}
break;
@@ -3289,7 +3297,7 @@ ErrStatus enet_ptp_timestamp_function_config(enet_ptp_function_enum func)
}
/*!
- \brief configure system time subsecond increment value
+ \brief configure system time subsecond increment value
\param[in] subsecond: the value will be added to the subsecond value of system time(0x00000000 - 0x000000FF)
\param[out] none
\retval none
@@ -3300,7 +3308,7 @@ void enet_ptp_subsecond_increment_config(uint32_t subsecond)
}
/*!
- \brief adjusting the clock frequency only in fine update mode
+ \brief adjusting the clock frequency only in fine update mode
\param[in] add: the value will be added to the accumulator register to achieve time synchronization
\param[out] none
\retval none
@@ -3311,7 +3319,7 @@ void enet_ptp_timestamp_addend_config(uint32_t add)
}
/*!
- \brief initialize or add/subtract to second of the system time
+ \brief initialize or add/subtract to second of the system time
\param[in] sign: timestamp update positive or negative sign
only one parameter can be selected which is shown as below
\arg ENET_PTP_ADD_TO_TIME: timestamp update value is added to system time
@@ -3329,7 +3337,7 @@ void enet_ptp_timestamp_update_config(uint32_t sign, uint32_t second, uint32_t s
}
/*!
- \brief configure the expected target time
+ \brief configure the expected target time
\param[in] second: the expected target second time
\param[in] nanosecond: the expected target nanosecond time (signed)
\param[out] none
@@ -3342,7 +3350,7 @@ void enet_ptp_expected_time_config(uint32_t second, uint32_t nanosecond)
}
/*!
- \brief get the current system time
+ \brief get the current system time
\param[in] none
\param[out] systime_struct: pointer to a enet_ptp_systime_struct structure which contains
parameters of PTP system time
@@ -3367,7 +3375,7 @@ void enet_ptp_system_time_get(enet_ptp_systime_struct *systime_struct)
}
/*!
- \brief configure the PPS output frequency
+ \brief configure the PPS output frequency
\param[in] freq: PPS output frequency
only one parameter can be selected which is shown as below
\arg ENET_PPSOFC_1HZ: PPS output 1Hz frequency
@@ -3395,7 +3403,7 @@ void enet_ptp_pps_output_frequency_config(uint32_t freq)
}
/*!
- \brief reset the ENET initpara struct, call it before using enet_initpara_config()
+ \brief reset the ENET initpara struct, call it before using enet_initpara_config()
\param[in] none
\param[out] none
\retval none
@@ -3420,7 +3428,7 @@ void enet_initpara_reset(void)
}
/*!
- \brief initialize ENET peripheral with generally concerned parameters, call it by enet_init()
+ \brief initialize ENET peripheral with generally concerned parameters, call it by enet_init()
\param[in] none
\param[out] none
\retval none
@@ -3434,20 +3442,20 @@ static void enet_default_init(void)
reg_value = ENET_MAC_CFG;
reg_value &= MAC_CFG_MASK;
reg_value |= ENET_WATCHDOG_ENABLE | ENET_JABBER_ENABLE | ENET_INTERFRAMEGAP_96BIT \
- | ENET_SPEEDMODE_10M |ENET_MODE_HALFDUPLEX | ENET_LOOPBACKMODE_DISABLE \
- | ENET_CARRIERSENSE_ENABLE | ENET_RECEIVEOWN_ENABLE \
- | ENET_RETRYTRANSMISSION_ENABLE | ENET_BACKOFFLIMIT_10 \
- | ENET_DEFERRALCHECK_DISABLE \
- | ENET_TYPEFRAME_CRC_DROP_DISABLE \
- | ENET_AUTO_PADCRC_DROP_DISABLE \
- | ENET_CHECKSUMOFFLOAD_DISABLE;
+ | ENET_SPEEDMODE_10M | ENET_MODE_HALFDUPLEX | ENET_LOOPBACKMODE_DISABLE \
+ | ENET_CARRIERSENSE_ENABLE | ENET_RECEIVEOWN_ENABLE \
+ | ENET_RETRYTRANSMISSION_ENABLE | ENET_BACKOFFLIMIT_10 \
+ | ENET_DEFERRALCHECK_DISABLE \
+ | ENET_TYPEFRAME_CRC_DROP_DISABLE \
+ | ENET_AUTO_PADCRC_DROP_DISABLE \
+ | ENET_CHECKSUMOFFLOAD_DISABLE;
ENET_MAC_CFG = reg_value;
/* configure ENET_MAC_FRMF register */
- ENET_MAC_FRMF = ENET_SRC_FILTER_DISABLE |ENET_DEST_FILTER_INVERSE_DISABLE \
- |ENET_MULTICAST_FILTER_PERFECT |ENET_UNICAST_FILTER_PERFECT \
- |ENET_PCFRM_PREVENT_ALL |ENET_BROADCASTFRAMES_ENABLE \
- |ENET_PROMISCUOUS_DISABLE |ENET_RX_FILTER_ENABLE;
+ ENET_MAC_FRMF = ENET_SRC_FILTER_DISABLE | ENET_DEST_FILTER_INVERSE_DISABLE \
+ | ENET_MULTICAST_FILTER_PERFECT | ENET_UNICAST_FILTER_PERFECT \
+ | ENET_PCFRM_PREVENT_ALL | ENET_BROADCASTFRAMES_ENABLE \
+ | ENET_PROMISCUOUS_DISABLE | ENET_RX_FILTER_ENABLE;
/* configure ENET_MAC_HLH, ENET_MAC_HLL register */
ENET_MAC_HLH = 0x0U;
@@ -3457,40 +3465,37 @@ static void enet_default_init(void)
/* configure ENET_MAC_FCTL, ENET_MAC_FCTH register */
reg_value = ENET_MAC_FCTL;
reg_value &= MAC_FCTL_MASK;
- reg_value |= MAC_FCTL_PTM(0) |ENET_ZERO_QUANTA_PAUSE_DISABLE \
- |ENET_PAUSETIME_MINUS4 |ENET_UNIQUE_PAUSEDETECT \
- |ENET_RX_FLOWCONTROL_DISABLE |ENET_TX_FLOWCONTROL_DISABLE;
+ reg_value |= MAC_FCTL_PTM(0) | ENET_ZERO_QUANTA_PAUSE_DISABLE \
+ | ENET_PAUSETIME_MINUS4 | ENET_UNIQUE_PAUSEDETECT \
+ | ENET_RX_FLOWCONTROL_DISABLE | ENET_TX_FLOWCONTROL_DISABLE;
ENET_MAC_FCTL = reg_value;
- ENET_MAC_FCTH = ENET_DEACTIVE_THRESHOLD_512BYTES |ENET_ACTIVE_THRESHOLD_1536BYTES;
-
/* configure ENET_MAC_VLT register */
- ENET_MAC_VLT = ENET_VLANTAGCOMPARISON_16BIT |MAC_VLT_VLTI(0);
+ ENET_MAC_VLT = ENET_VLANTAGCOMPARISON_16BIT | MAC_VLT_VLTI(0);
/* DMA */
/* configure ENET_DMA_CTL register */
reg_value = ENET_DMA_CTL;
reg_value &= DMA_CTL_MASK;
- reg_value |= ENET_TCPIP_CKSUMERROR_DROP |ENET_RX_MODE_STOREFORWARD \
- |ENET_FLUSH_RXFRAME_ENABLE |ENET_TX_MODE_STOREFORWARD \
- |ENET_TX_THRESHOLD_64BYTES |ENET_RX_THRESHOLD_64BYTES \
- |ENET_FORWARD_ERRFRAMES_DISABLE |ENET_FORWARD_UNDERSZ_GOODFRAMES_DISABLE \
- |ENET_SECONDFRAME_OPT_DISABLE;
+ reg_value |= ENET_TCPIP_CKSUMERROR_DROP | ENET_RX_MODE_STOREFORWARD \
+ | ENET_FLUSH_RXFRAME_ENABLE | ENET_TX_MODE_STOREFORWARD \
+ | ENET_TX_THRESHOLD_64BYTES | ENET_RX_THRESHOLD_64BYTES \
+ | ENET_SECONDFRAME_OPT_DISABLE;
ENET_DMA_CTL = reg_value;
/* configure ENET_DMA_BCTL register */
reg_value = ENET_DMA_BCTL;
reg_value &= DMA_BCTL_MASK;
- reg_value = ENET_ADDRESS_ALIGN_ENABLE |ENET_ARBITRATION_RXTX_2_1 \
- |ENET_RXDP_32BEAT |ENET_PGBL_32BEAT |ENET_RXTX_DIFFERENT_PGBL \
- |ENET_FIXED_BURST_ENABLE |ENET_MIXED_BURST_DISABLE \
- |ENET_NORMAL_DESCRIPTOR;
+ reg_value = ENET_ADDRESS_ALIGN_ENABLE | ENET_ARBITRATION_RXTX_2_1 \
+ | ENET_RXDP_32BEAT | ENET_PGBL_32BEAT | ENET_RXTX_DIFFERENT_PGBL \
+ | ENET_FIXED_BURST_ENABLE | ENET_MIXED_BURST_DISABLE \
+ | ENET_NORMAL_DESCRIPTOR;
ENET_DMA_BCTL = reg_value;
}
#ifndef USE_DELAY
/*!
- \brief insert a delay time
+ \brief insert a delay time
\param[in] ncount: specifies the delay time length
\param[out] none
\param[out] none
@@ -3499,7 +3504,7 @@ static void enet_delay(uint32_t ncount)
{
__IO uint32_t delay_time = 0U;
- for(delay_time = ncount; delay_time != 0U; delay_time--){
+ for(delay_time = ncount; delay_time != 0U; delay_time--) {
}
}
#endif /* USE_DELAY */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_exmc.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_exmc.c
index e225258eb5..71d26c3a73 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_exmc.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_exmc.c
@@ -5,10 +5,12 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
+ \version 2022-06-08, V3.0.1, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -112,9 +114,6 @@ OF SUCH DAMAGE.
#define SDARI_ARINTV_OFFSET ((uint32_t)1U)
-#define SDRSCTL_SSCR_OFFSET ((uint32_t)1U)
-#define SDRSCTL_SDSC_OFFSET ((uint32_t)4U)
-
#define SDSTAT_STA0_OFFSET ((uint32_t)1U)
#define SDSTAT_STA1_OFFSET ((uint32_t)3U)
@@ -145,7 +144,7 @@ void exmc_norsram_deinit(uint32_t exmc_norsram_region)
\param[out] exmc_norsram_init_struct: the initialized struct exmc_norsram_parameter_struct pointer
\retval none
*/
-void exmc_norsram_struct_para_init(exmc_norsram_parameter_struct* exmc_norsram_init_struct)
+void exmc_norsram_struct_para_init(exmc_norsram_parameter_struct *exmc_norsram_init_struct)
{
/* configure the structure with default values */
exmc_norsram_init_struct->norsram_region = EXMC_BANK0_NORSRAM_REGION0;
@@ -171,7 +170,7 @@ void exmc_norsram_struct_para_init(exmc_norsram_parameter_struct* exmc_norsram_i
exmc_norsram_init_struct->read_write_timing->syn_data_latency = EXMC_DATALAT_17_CLK;
exmc_norsram_init_struct->read_write_timing->asyn_access_mode = EXMC_ACCESS_MODE_A;
- /* write timing configure, when extended mode is used */
+ /* configure write timing, when extended mode is used */
exmc_norsram_init_struct->write_timing->asyn_address_setuptime = 0xFU;
exmc_norsram_init_struct->write_timing->asyn_address_holdtime = 0xFU;
exmc_norsram_init_struct->write_timing->asyn_data_setuptime = 0xFFU;
@@ -198,7 +197,7 @@ void exmc_norsram_struct_para_init(exmc_norsram_parameter_struct* exmc_norsram_i
read_write_timing: struct exmc_norsram_timing_parameter_struct set the time
asyn_access_mode: EXMC_ACCESS_MODE_A, EXMC_ACCESS_MODE_B, EXMC_ACCESS_MODE_C, EXMC_ACCESS_MODE_D
syn_data_latency: EXMC_DATALAT_x_CLK, x=2..17
- syn_clk_division: EXMC_SYN_CLOCK_RATIO_x_CLK, x=2..16
+ syn_clk_division: EXMC_SYN_CLOCK_RATIO_DISABLE, EXMC_SYN_CLOCK_RATIO_x_CLK, x=2..16
bus_latency: 0x0U~0xFU
asyn_data_setuptime: 0x01U~0xFFU
asyn_address_holdtime: 0x1U~0xFU
@@ -214,53 +213,55 @@ void exmc_norsram_struct_para_init(exmc_norsram_parameter_struct* exmc_norsram_i
\param[out] none
\retval none
*/
-void exmc_norsram_init(exmc_norsram_parameter_struct* exmc_norsram_init_struct)
+void exmc_norsram_init(exmc_norsram_parameter_struct *exmc_norsram_init_struct)
{
- uint32_t snctl = 0x00000000U,sntcfg = 0x00000000U,snwtcfg = 0x00000000U;
+ uint32_t snctl = 0x00000000U, sntcfg = 0x00000000U, snwtcfg = 0x00000000U;
/* get the register value */
snctl = EXMC_SNCTL(exmc_norsram_init_struct->norsram_region);
/* clear relative bits */
snctl &= ((uint32_t)~(EXMC_SNCTL_NREN | EXMC_SNCTL_NRTP | EXMC_SNCTL_NRW | EXMC_SNCTL_SBRSTEN |
- EXMC_SNCTL_NRWTPOL | EXMC_SNCTL_WRAPEN | EXMC_SNCTL_NRWTCFG | EXMC_SNCTL_WREN |
- EXMC_SNCTL_NRWTEN | EXMC_SNCTL_EXMODEN | EXMC_SNCTL_ASYNCWAIT | EXMC_SNCTL_SYNCWR |
- EXMC_SNCTL_NRMUX ));
+ EXMC_SNCTL_NRWTPOL | EXMC_SNCTL_WRAPEN | EXMC_SNCTL_NRWTCFG | EXMC_SNCTL_WEN |
+ EXMC_SNCTL_NRWTEN | EXMC_SNCTL_EXMODEN | EXMC_SNCTL_ASYNCWTEN | EXMC_SNCTL_SYNCWR |
+ EXMC_SNCTL_NRMUX));
+ /* configure control bits */
snctl |= (uint32_t)(exmc_norsram_init_struct->address_data_mux << SNCTL_NRMUX_OFFSET) |
- exmc_norsram_init_struct->memory_type |
- exmc_norsram_init_struct->databus_width |
- (exmc_norsram_init_struct->burst_mode << SNCTL_SBRSTEN_OFFSET) |
- exmc_norsram_init_struct->nwait_polarity |
- (exmc_norsram_init_struct->wrap_burst_mode << SNCTL_WRAPEN_OFFSET) |
- exmc_norsram_init_struct->nwait_config |
- (exmc_norsram_init_struct->memory_write << SNCTL_WREN_OFFSET) |
- (exmc_norsram_init_struct->nwait_signal << SNCTL_NRWTEN_OFFSET) |
- (exmc_norsram_init_struct->extended_mode << SNCTL_EXMODEN_OFFSET) |
- (exmc_norsram_init_struct->asyn_wait << SNCTL_ASYNCWAIT_OFFSET) |
- exmc_norsram_init_struct->write_mode;
+ exmc_norsram_init_struct->memory_type |
+ exmc_norsram_init_struct->databus_width |
+ (exmc_norsram_init_struct->burst_mode << SNCTL_SBRSTEN_OFFSET) |
+ exmc_norsram_init_struct->nwait_polarity |
+ (exmc_norsram_init_struct->wrap_burst_mode << SNCTL_WRAPEN_OFFSET) |
+ exmc_norsram_init_struct->nwait_config |
+ (exmc_norsram_init_struct->memory_write << SNCTL_WREN_OFFSET) |
+ (exmc_norsram_init_struct->nwait_signal << SNCTL_NRWTEN_OFFSET) |
+ (exmc_norsram_init_struct->extended_mode << SNCTL_EXMODEN_OFFSET) |
+ (exmc_norsram_init_struct->asyn_wait << SNCTL_ASYNCWAIT_OFFSET) |
+ exmc_norsram_init_struct->write_mode;
+ /* configure timing */
sntcfg = (uint32_t)exmc_norsram_init_struct->read_write_timing->asyn_address_setuptime |
- (exmc_norsram_init_struct->read_write_timing->asyn_address_holdtime << SNTCFG_AHLD_OFFSET) |
- (exmc_norsram_init_struct->read_write_timing->asyn_data_setuptime << SNTCFG_DSET_OFFSET) |
- (exmc_norsram_init_struct->read_write_timing->bus_latency << SNTCFG_BUSLAT_OFFSET) |
- exmc_norsram_init_struct->read_write_timing->syn_clk_division |
- exmc_norsram_init_struct->read_write_timing->syn_data_latency |
- exmc_norsram_init_struct->read_write_timing->asyn_access_mode;
+ (exmc_norsram_init_struct->read_write_timing->asyn_address_holdtime << SNTCFG_AHLD_OFFSET) |
+ (exmc_norsram_init_struct->read_write_timing->asyn_data_setuptime << SNTCFG_DSET_OFFSET) |
+ (exmc_norsram_init_struct->read_write_timing->bus_latency << SNTCFG_BUSLAT_OFFSET) |
+ exmc_norsram_init_struct->read_write_timing->syn_clk_division |
+ exmc_norsram_init_struct->read_write_timing->syn_data_latency |
+ exmc_norsram_init_struct->read_write_timing->asyn_access_mode;
- /* nor flash access enable */
- if(EXMC_MEMORY_TYPE_NOR == exmc_norsram_init_struct->memory_type){
+ /* enable nor flash access */
+ if(EXMC_MEMORY_TYPE_NOR == exmc_norsram_init_struct->memory_type) {
snctl |= (uint32_t)EXMC_SNCTL_NREN;
}
- /* extended mode configure */
- if(ENABLE == exmc_norsram_init_struct->extended_mode){
+ /* configure extended mode */
+ if(ENABLE == exmc_norsram_init_struct->extended_mode) {
snwtcfg = (uint32_t)exmc_norsram_init_struct->write_timing->asyn_address_setuptime |
- (exmc_norsram_init_struct->write_timing->asyn_address_holdtime << SNTCFG_AHLD_OFFSET )|
- (exmc_norsram_init_struct->write_timing->asyn_data_setuptime << SNTCFG_DSET_OFFSET) |
- (exmc_norsram_init_struct->write_timing->bus_latency << SNTCFG_BUSLAT_OFFSET) |
- exmc_norsram_init_struct->write_timing->asyn_access_mode;
- }else{
+ (exmc_norsram_init_struct->write_timing->asyn_address_holdtime << SNTCFG_AHLD_OFFSET) |
+ (exmc_norsram_init_struct->write_timing->asyn_data_setuptime << SNTCFG_DSET_OFFSET) |
+ (exmc_norsram_init_struct->write_timing->bus_latency << SNTCFG_BUSLAT_OFFSET) |
+ exmc_norsram_init_struct->write_timing->asyn_access_mode;
+ } else {
snwtcfg = BANK0_SNWTCFG_RESET;
}
@@ -272,7 +273,7 @@ void exmc_norsram_init(exmc_norsram_parameter_struct* exmc_norsram_init_struct)
/*!
\brief enable EXMC NOR/PSRAM bank region
- \param[in] exmc_norsram_region: specifie the region of NOR/PSRAM bank
+ \param[in] exmc_norsram_region: specify the region of NOR/PSRAM bank
only one parameter can be selected which is shown as below:
\arg EXMC_BANK0_NORSRAM_REGIONx(x=0..3)
\param[out] none
@@ -285,7 +286,7 @@ void exmc_norsram_enable(uint32_t exmc_norsram_region)
/*!
\brief disable EXMC NOR/PSRAM bank region
- \param[in] exmc_norsram_region: specifie the region of NOR/PSRAM Bank
+ \param[in] exmc_norsram_region: specify the region of NOR/PSRAM Bank
only one parameter can be selected which is shown as below:
\arg EXMC_BANK0_NORSRAM_REGIONx(x=0..3)
\param[out] none
@@ -319,7 +320,7 @@ void exmc_nand_deinit(uint32_t exmc_nand_bank)
\param[out] the initialized struct exmc_norsram_parameter_struct pointer
\retval none
*/
-void exmc_nand_struct_para_init(exmc_nand_parameter_struct* exmc_nand_init_struct)
+void exmc_nand_struct_para_init(exmc_nand_parameter_struct *exmc_nand_init_struct)
{
/* configure the structure with default values */
exmc_nand_init_struct->nand_bank = EXMC_BANK1_NAND;
@@ -362,29 +363,29 @@ void exmc_nand_struct_para_init(exmc_nand_parameter_struct* exmc_nand_init_struc
\param[out] none
\retval none
*/
-void exmc_nand_init(exmc_nand_parameter_struct* exmc_nand_init_struct)
+void exmc_nand_init(exmc_nand_parameter_struct *exmc_nand_init_struct)
{
uint32_t npctl = 0x00000000U, npctcfg = 0x00000000U, npatcfg = 0x00000000U;
- npctl = (uint32_t)(exmc_nand_init_struct->wait_feature << NPCTL_NDWTEN_OFFSET)|
- EXMC_NPCTL_NDTP |
- exmc_nand_init_struct->databus_width |
- (exmc_nand_init_struct->ecc_logic << NPCTL_ECCEN_OFFSET)|
- exmc_nand_init_struct->ecc_size |
- exmc_nand_init_struct->ctr_latency |
- exmc_nand_init_struct->atr_latency;
+ npctl = (uint32_t)(exmc_nand_init_struct->wait_feature << NPCTL_NDWTEN_OFFSET) |
+ EXMC_NPCTL_NDTP |
+ exmc_nand_init_struct->databus_width |
+ (exmc_nand_init_struct->ecc_logic << NPCTL_ECCEN_OFFSET) |
+ exmc_nand_init_struct->ecc_size |
+ exmc_nand_init_struct->ctr_latency |
+ exmc_nand_init_struct->atr_latency;
- npctcfg = (uint32_t)((exmc_nand_init_struct->common_space_timing->setuptime - 1U) & EXMC_NPCTCFG_COMSET ) |
- (((exmc_nand_init_struct->common_space_timing->waittime - 1U) << NPCTCFG_COMWAIT_OFFSET) & EXMC_NPCTCFG_COMWAIT ) |
- ((exmc_nand_init_struct->common_space_timing->holdtime << NPCTCFG_COMHLD_OFFSET) & EXMC_NPCTCFG_COMHLD ) |
- (((exmc_nand_init_struct->common_space_timing->databus_hiztime - 1U) << NPCTCFG_COMHIZ_OFFSET) & EXMC_NPCTCFG_COMHIZ );
+ npctcfg = (uint32_t)((exmc_nand_init_struct->common_space_timing->setuptime - 1U) & EXMC_NPCTCFG_COMSET) |
+ (((exmc_nand_init_struct->common_space_timing->waittime - 1U) << NPCTCFG_COMWAIT_OFFSET) & EXMC_NPCTCFG_COMWAIT) |
+ ((exmc_nand_init_struct->common_space_timing->holdtime << NPCTCFG_COMHLD_OFFSET) & EXMC_NPCTCFG_COMHLD) |
+ (((exmc_nand_init_struct->common_space_timing->databus_hiztime - 1U) << NPCTCFG_COMHIZ_OFFSET) & EXMC_NPCTCFG_COMHIZ);
- npatcfg = (uint32_t)((exmc_nand_init_struct->attribute_space_timing->setuptime - 1U) & EXMC_NPATCFG_ATTSET ) |
- (((exmc_nand_init_struct->attribute_space_timing->waittime - 1U) << NPATCFG_ATTWAIT_OFFSET) & EXMC_NPATCFG_ATTWAIT ) |
- ((exmc_nand_init_struct->attribute_space_timing->holdtime << NPATCFG_ATTHLD_OFFSET) & EXMC_NPATCFG_ATTHLD ) |
- ((exmc_nand_init_struct->attribute_space_timing->databus_hiztime << NPATCFG_ATTHIZ_OFFSET) & EXMC_NPATCFG_ATTHIZ );
+ npatcfg = (uint32_t)((exmc_nand_init_struct->attribute_space_timing->setuptime - 1U) & EXMC_NPATCFG_ATTSET) |
+ (((exmc_nand_init_struct->attribute_space_timing->waittime - 1U) << NPATCFG_ATTWAIT_OFFSET) & EXMC_NPATCFG_ATTWAIT) |
+ ((exmc_nand_init_struct->attribute_space_timing->holdtime << NPATCFG_ATTHLD_OFFSET) & EXMC_NPATCFG_ATTHLD) |
+ ((exmc_nand_init_struct->attribute_space_timing->databus_hiztime << NPATCFG_ATTHIZ_OFFSET) & EXMC_NPATCFG_ATTHIZ);
- /* EXMC_BANK1_NAND or EXMC_BANK2_NAND initialize */
+ /* initialize EXMC_BANK1_NAND or EXMC_BANK2_NAND */
EXMC_NPCTL(exmc_nand_init_struct->nand_bank) = npctl;
EXMC_NPCTCFG(exmc_nand_init_struct->nand_bank) = npctcfg;
EXMC_NPATCFG(exmc_nand_init_struct->nand_bank) = npatcfg;
@@ -392,7 +393,7 @@ void exmc_nand_init(exmc_nand_parameter_struct* exmc_nand_init_struct)
/*!
\brief enable NAND bank
- \param[in] exmc_nand_bank: specifie the NAND bank
+ \param[in] exmc_nand_bank: specify the NAND bank
only one parameter can be selected which is shown as below:
\arg EXMC_BANKx_NAND(x=1,2)
\param[out] none
@@ -405,7 +406,7 @@ void exmc_nand_enable(uint32_t exmc_nand_bank)
/*!
\brief disable NAND bank
- \param[in] exmc_nand_bank: specifie the NAND bank
+ \param[in] exmc_nand_bank: specify the NAND bank
only one parameter can be selected which is shown as below:
\arg EXMC_BANKx_NAND(x=1,2)
\param[out] none
@@ -438,7 +439,7 @@ void exmc_pccard_deinit(void)
\param[out] the initialized struct exmc_pccard_parameter_struct pointer
\retval none
*/
-void exmc_pccard_struct_para_init(exmc_pccard_parameter_struct* exmc_pccard_init_struct)
+void exmc_pccard_struct_para_init(exmc_pccard_parameter_struct *exmc_pccard_init_struct)
{
/* configure the structure with default values */
exmc_pccard_init_struct->wait_feature = DISABLE;
@@ -482,31 +483,31 @@ void exmc_pccard_struct_para_init(exmc_pccard_parameter_struct* exmc_pccard_init
\param[out] none
\retval none
*/
-void exmc_pccard_init(exmc_pccard_parameter_struct* exmc_pccard_init_struct)
+void exmc_pccard_init(exmc_pccard_parameter_struct *exmc_pccard_init_struct)
{
/* configure the EXMC bank3 PC card control register */
EXMC_NPCTL3 = (uint32_t)(exmc_pccard_init_struct->wait_feature << NPCTL_NDWTEN_OFFSET) |
- EXMC_NAND_DATABUS_WIDTH_16B |
- exmc_pccard_init_struct->ctr_latency |
- exmc_pccard_init_struct->atr_latency ;
+ EXMC_NAND_DATABUS_WIDTH_16B |
+ exmc_pccard_init_struct->ctr_latency |
+ exmc_pccard_init_struct->atr_latency ;
/* configure the EXMC bank3 PC card common space timing configuration register */
- EXMC_NPCTCFG3 = (uint32_t)((exmc_pccard_init_struct->common_space_timing->setuptime - 1U) & EXMC_NPCTCFG_COMSET ) |
- (((exmc_pccard_init_struct->common_space_timing->waittime - 1U) << NPCTCFG_COMWAIT_OFFSET) & EXMC_NPCTCFG_COMWAIT ) |
- ((exmc_pccard_init_struct->common_space_timing->holdtime << NPCTCFG_COMHLD_OFFSET) & EXMC_NPCTCFG_COMHLD ) |
- (((exmc_pccard_init_struct->common_space_timing->databus_hiztime - 1U) << NPCTCFG_COMHIZ_OFFSET) & EXMC_NPCTCFG_COMHIZ );
+ EXMC_NPCTCFG3 = (uint32_t)((exmc_pccard_init_struct->common_space_timing->setuptime - 1U) & EXMC_NPCTCFG_COMSET) |
+ (((exmc_pccard_init_struct->common_space_timing->waittime - 1U) << NPCTCFG_COMWAIT_OFFSET) & EXMC_NPCTCFG_COMWAIT) |
+ ((exmc_pccard_init_struct->common_space_timing->holdtime << NPCTCFG_COMHLD_OFFSET) & EXMC_NPCTCFG_COMHLD) |
+ (((exmc_pccard_init_struct->common_space_timing->databus_hiztime - 1U) << NPCTCFG_COMHIZ_OFFSET) & EXMC_NPCTCFG_COMHIZ);
/* configure the EXMC bank3 PC card attribute space timing configuration register */
- EXMC_NPATCFG3 = (uint32_t)((exmc_pccard_init_struct->attribute_space_timing->setuptime - 1U) & EXMC_NPATCFG_ATTSET ) |
- (((exmc_pccard_init_struct->attribute_space_timing->waittime - 1U) << NPATCFG_ATTWAIT_OFFSET) & EXMC_NPATCFG_ATTWAIT ) |
- ((exmc_pccard_init_struct->attribute_space_timing->holdtime << NPATCFG_ATTHLD_OFFSET) & EXMC_NPATCFG_ATTHLD ) |
- ((exmc_pccard_init_struct->attribute_space_timing->databus_hiztime << NPATCFG_ATTHIZ_OFFSET) & EXMC_NPATCFG_ATTHIZ);
+ EXMC_NPATCFG3 = (uint32_t)((exmc_pccard_init_struct->attribute_space_timing->setuptime - 1U) & EXMC_NPATCFG_ATTSET) |
+ (((exmc_pccard_init_struct->attribute_space_timing->waittime - 1U) << NPATCFG_ATTWAIT_OFFSET) & EXMC_NPATCFG_ATTWAIT) |
+ ((exmc_pccard_init_struct->attribute_space_timing->holdtime << NPATCFG_ATTHLD_OFFSET) & EXMC_NPATCFG_ATTHLD) |
+ ((exmc_pccard_init_struct->attribute_space_timing->databus_hiztime << NPATCFG_ATTHIZ_OFFSET) & EXMC_NPATCFG_ATTHIZ);
/* configure the EXMC bank3 PC card io space timing configuration register */
- EXMC_PIOTCFG3 = (uint32_t)((exmc_pccard_init_struct->io_space_timing->setuptime - 1U) & EXMC_PIOTCFG3_IOSET ) |
- (((exmc_pccard_init_struct->io_space_timing->waittime - 1U) << PIOTCFG_IOWAIT_OFFSET) & EXMC_PIOTCFG3_IOWAIT ) |
- ((exmc_pccard_init_struct->io_space_timing->holdtime << PIOTCFG_IOHLD_OFFSET) & EXMC_PIOTCFG3_IOHLD ) |
- ((exmc_pccard_init_struct->io_space_timing->databus_hiztime << PIOTCFG_IOHIZ_OFFSET) & EXMC_PIOTCFG3_IOHIZ );
+ EXMC_PIOTCFG3 = (uint32_t)((exmc_pccard_init_struct->io_space_timing->setuptime - 1U) & EXMC_PIOTCFG3_IOSET) |
+ (((exmc_pccard_init_struct->io_space_timing->waittime - 1U) << PIOTCFG_IOWAIT_OFFSET) & EXMC_PIOTCFG3_IOWAIT) |
+ ((exmc_pccard_init_struct->io_space_timing->holdtime << PIOTCFG_IOHLD_OFFSET) & EXMC_PIOTCFG3_IOHLD) |
+ ((exmc_pccard_init_struct->io_space_timing->databus_hiztime << PIOTCFG_IOHIZ_OFFSET) & EXMC_PIOTCFG3_IOHIZ);
}
/*!
@@ -528,7 +529,7 @@ void exmc_pccard_enable(void)
*/
void exmc_pccard_disable(void)
{
- EXMC_NPCTL3 &= ~EXMC_NPCTL_NDBKEN;
+ EXMC_NPCTL3 &= ~EXMC_NPCTL_NDBKEN;
}
/*!
@@ -556,7 +557,7 @@ void exmc_sdram_deinit(uint32_t exmc_sdram_device)
\param[out] the initialized struct exmc_pccard_parameter_struct pointer
\retval none
*/
-void exmc_sdram_struct_para_init(exmc_sdram_parameter_struct* exmc_sdram_init_struct)
+void exmc_sdram_struct_para_init(exmc_sdram_parameter_struct *exmc_sdram_init_struct)
{
/* configure the structure with default values */
exmc_sdram_init_struct->sdram_device = EXMC_SDRAM_DEVICE0;
@@ -567,7 +568,7 @@ void exmc_sdram_struct_para_init(exmc_sdram_parameter_struct* exmc_sdram_init_st
exmc_sdram_init_struct->cas_latency = EXMC_CAS_LATENCY_1_SDCLK;
exmc_sdram_init_struct->write_protection = ENABLE;
exmc_sdram_init_struct->sdclock_config = EXMC_SDCLK_DISABLE;
- exmc_sdram_init_struct->brust_read_switch = DISABLE;
+ exmc_sdram_init_struct->burst_read_switch = DISABLE;
exmc_sdram_init_struct->pipeline_read_delay = EXMC_PIPELINE_DELAY_0_HCLK;
exmc_sdram_init_struct->timing->load_mode_register_delay = 16U;
@@ -584,7 +585,7 @@ void exmc_sdram_struct_para_init(exmc_sdram_parameter_struct* exmc_sdram_init_st
\param[in] exmc_sdram_parameter_struct: configure the EXMC SDRAM parameter
sdram_device: EXMC_SDRAM_DEVICE0,EXMC_SDRAM_DEVICE1
pipeline_read_delay: EXMC_PIPELINE_DELAY_x_HCLK,x=0..2
- brust_read_switch: ENABLE or DISABLE
+ burst_read_switch: ENABLE or DISABLE
sdclock_config: EXMC_SDCLK_DISABLE,EXMC_SDCLK_PERIODS_2_HCLK,EXMC_SDCLK_PERIODS_3_HCLK
write_protection: ENABLE or DISABLE
cas_latency: EXMC_CAS_LATENCY_x_SDCLK,x=1..3
@@ -603,62 +604,62 @@ void exmc_sdram_struct_para_init(exmc_sdram_parameter_struct* exmc_sdram_init_st
\param[out] none
\retval none
*/
-void exmc_sdram_init(exmc_sdram_parameter_struct* exmc_sdram_init_struct)
+void exmc_sdram_init(exmc_sdram_parameter_struct *exmc_sdram_init_struct)
{
uint32_t sdctl0, sdctl1, sdtcfg0, sdtcfg1;
- /* configuration EXMC_SDCTL0 or EXMC_SDCTL1 */
- if(EXMC_SDRAM_DEVICE0 == exmc_sdram_init_struct->sdram_device){
- /* configuration EXMC_SDCTL0 */
- EXMC_SDCTL(EXMC_SDRAM_DEVICE0) = (uint32_t)exmc_sdram_init_struct->column_address_width |
- exmc_sdram_init_struct->row_address_width |
- exmc_sdram_init_struct->data_width |
- exmc_sdram_init_struct->internal_bank_number |
- exmc_sdram_init_struct->cas_latency |
- (exmc_sdram_init_struct->write_protection << SDCTL_WPEN_OFFSET)|
- exmc_sdram_init_struct->sdclock_config |
- (exmc_sdram_init_struct->brust_read_switch << SDCTL_BRSTRD_OFFSET)|
- exmc_sdram_init_struct->pipeline_read_delay;
-
- /* configuration EXMC_SDTCFG0 */
- EXMC_SDTCFG(EXMC_SDRAM_DEVICE0) = (uint32_t)((exmc_sdram_init_struct->timing->load_mode_register_delay)-1U) |
- (((exmc_sdram_init_struct->timing->exit_selfrefresh_delay)-1U) << SDTCFG_XSRD_OFFSET) |
- (((exmc_sdram_init_struct->timing->row_address_select_delay)-1U) << SDTCFG_RASD_OFFSET) |
- (((exmc_sdram_init_struct->timing->auto_refresh_delay)-1U) << SDTCFG_ARFD_OFFSET) |
- (((exmc_sdram_init_struct->timing->write_recovery_delay)-1U) << SDTCFG_WRD_OFFSET) |
- (((exmc_sdram_init_struct->timing->row_precharge_delay)-1U) << SDTCFG_RPD_OFFSET) |
- (((exmc_sdram_init_struct->timing->row_to_column_delay)-1U) << SDTCFG_RCD_OFFSET);
- }else{
- /* configuration EXMC_SDCTL0 and EXMC_SDCTL1 */
+ /* configure EXMC_SDCTL0 or EXMC_SDCTL1 */
+ if(EXMC_SDRAM_DEVICE0 == exmc_sdram_init_struct->sdram_device) {
+ /* configure EXMC_SDCTL0 */
+ EXMC_SDCTL(EXMC_SDRAM_DEVICE0) = (uint32_t)(exmc_sdram_init_struct->column_address_width |
+ exmc_sdram_init_struct->row_address_width |
+ exmc_sdram_init_struct->data_width |
+ exmc_sdram_init_struct->internal_bank_number |
+ exmc_sdram_init_struct->cas_latency |
+ (exmc_sdram_init_struct->write_protection << SDCTL_WPEN_OFFSET) |
+ exmc_sdram_init_struct->sdclock_config |
+ (exmc_sdram_init_struct->burst_read_switch << SDCTL_BRSTRD_OFFSET) |
+ exmc_sdram_init_struct->pipeline_read_delay);
+
+ /* configure EXMC_SDTCFG0 */
+ EXMC_SDTCFG(EXMC_SDRAM_DEVICE0) = (uint32_t)((exmc_sdram_init_struct->timing->load_mode_register_delay) - 1U) |
+ (((exmc_sdram_init_struct->timing->exit_selfrefresh_delay) - 1U) << SDTCFG_XSRD_OFFSET) |
+ (((exmc_sdram_init_struct->timing->row_address_select_delay) - 1U) << SDTCFG_RASD_OFFSET) |
+ (((exmc_sdram_init_struct->timing->auto_refresh_delay) - 1U) << SDTCFG_ARFD_OFFSET) |
+ (((exmc_sdram_init_struct->timing->write_recovery_delay) - 1U) << SDTCFG_WRD_OFFSET) |
+ (((exmc_sdram_init_struct->timing->row_precharge_delay) - 1U) << SDTCFG_RPD_OFFSET) |
+ (((exmc_sdram_init_struct->timing->row_to_column_delay) - 1U) << SDTCFG_RCD_OFFSET);
+ } else {
+ /* configure EXMC_SDCTL0 and EXMC_SDCTL1 */
/* some bits in the EXMC_SDCTL1 register are reserved */
- sdctl0 = EXMC_SDCTL(EXMC_SDRAM_DEVICE0) & (~( EXMC_SDCTL_PIPED | EXMC_SDCTL_BRSTRD | EXMC_SDCTL_SDCLK ));
-
- sdctl0 |= (uint32_t)exmc_sdram_init_struct->sdclock_config |
- exmc_sdram_init_struct->brust_read_switch |
- exmc_sdram_init_struct->pipeline_read_delay;
+ sdctl0 = EXMC_SDCTL(EXMC_SDRAM_DEVICE0) & (~(EXMC_SDCTL_PIPED | EXMC_SDCTL_BRSTRD | EXMC_SDCTL_SDCLK));
- sdctl1 = (uint32_t)exmc_sdram_init_struct->column_address_width |
- exmc_sdram_init_struct->row_address_width |
- exmc_sdram_init_struct->data_width |
- exmc_sdram_init_struct->internal_bank_number |
- exmc_sdram_init_struct->cas_latency |
- exmc_sdram_init_struct->write_protection ;
+ sdctl0 |= (uint32_t)(exmc_sdram_init_struct->sdclock_config |
+ (exmc_sdram_init_struct->burst_read_switch << SDCTL_BRSTRD_OFFSET) |
+ exmc_sdram_init_struct->pipeline_read_delay);
+
+ sdctl1 = (uint32_t)(exmc_sdram_init_struct->column_address_width |
+ exmc_sdram_init_struct->row_address_width |
+ exmc_sdram_init_struct->data_width |
+ exmc_sdram_init_struct->internal_bank_number |
+ exmc_sdram_init_struct->cas_latency |
+ (exmc_sdram_init_struct->write_protection << SDCTL_WPEN_OFFSET));
EXMC_SDCTL(EXMC_SDRAM_DEVICE0) = sdctl0;
EXMC_SDCTL(EXMC_SDRAM_DEVICE1) = sdctl1;
- /* configuration EXMC_SDTCFG0 and EXMC_SDTCFG1 */
+ /* configure EXMC_SDTCFG0 and EXMC_SDTCFG1 */
/* some bits in the EXMC_SDTCFG1 register are reserved */
sdtcfg0 = EXMC_SDTCFG(EXMC_SDRAM_DEVICE0) & (~(EXMC_SDTCFG_RPD | EXMC_SDTCFG_WRD | EXMC_SDTCFG_ARFD));
- sdtcfg0 |= (uint32_t)(((exmc_sdram_init_struct->timing->auto_refresh_delay)-1U) << SDTCFG_ARFD_OFFSET) |
- (((exmc_sdram_init_struct->timing->row_precharge_delay)-1U) << SDTCFG_RPD_OFFSET) |
- (((exmc_sdram_init_struct->timing->write_recovery_delay)-1U) << SDTCFG_WRD_OFFSET);
+ sdtcfg0 |= (uint32_t)((((exmc_sdram_init_struct->timing->auto_refresh_delay) - 1U) << SDTCFG_ARFD_OFFSET) |
+ (((exmc_sdram_init_struct->timing->row_precharge_delay) - 1U) << SDTCFG_RPD_OFFSET) |
+ (((exmc_sdram_init_struct->timing->write_recovery_delay) - 1U) << SDTCFG_WRD_OFFSET));
- sdtcfg1 = (uint32_t)((exmc_sdram_init_struct->timing->load_mode_register_delay)-1U) |
- (((exmc_sdram_init_struct->timing->exit_selfrefresh_delay)-1U) << SDTCFG_XSRD_OFFSET) |
- (((exmc_sdram_init_struct->timing->row_address_select_delay)-1U) << SDTCFG_RASD_OFFSET) |
- (((exmc_sdram_init_struct->timing->row_to_column_delay)-1U) << SDTCFG_RCD_OFFSET);
+ sdtcfg1 = (uint32_t)(((exmc_sdram_init_struct->timing->load_mode_register_delay) - 1U) |
+ (((exmc_sdram_init_struct->timing->exit_selfrefresh_delay) - 1U) << SDTCFG_XSRD_OFFSET) |
+ (((exmc_sdram_init_struct->timing->row_address_select_delay) - 1U) << SDTCFG_RASD_OFFSET) |
+ (((exmc_sdram_init_struct->timing->row_to_column_delay) - 1U) << SDTCFG_RCD_OFFSET));
EXMC_SDTCFG(EXMC_SDRAM_DEVICE0) = sdtcfg0;
EXMC_SDTCFG(EXMC_SDRAM_DEVICE1) = sdtcfg1;
@@ -666,6 +667,21 @@ void exmc_sdram_init(exmc_sdram_parameter_struct* exmc_sdram_init_struct)
}
/*!
+ \brief initialize exmc_sdram_struct_command_para_init with the default values
+ \param[in] none
+ \param[out] the initialized struct exmc_sdram_struct_command_para_init pointer
+ \retval none
+*/
+void exmc_sdram_struct_command_para_init(exmc_sdram_command_parameter_struct *exmc_sdram_command_init_struct)
+{
+ /* configure the structure with default value */
+ exmc_sdram_command_init_struct->mode_register_content = 0U;
+ exmc_sdram_command_init_struct->auto_refresh_number = EXMC_SDRAM_AUTO_REFLESH_1_SDCLK;
+ exmc_sdram_command_init_struct->bank_select = EXMC_SDRAM_DEVICE0_SELECT;
+ exmc_sdram_command_init_struct->command = EXMC_SDRAM_NORMAL_OPERATION;
+}
+
+/*!
\brief deinitialize exmc SQPIPSRAM
\param[in] none
\param[out] none
@@ -687,7 +703,7 @@ void exmc_sqpipsram_deinit(void)
\param[out] none
\retval none
*/
-void exmc_sqpipsram_struct_para_init(exmc_sqpipsram_parameter_struct* exmc_sqpipsram_init_struct)
+void exmc_sqpipsram_struct_para_init(exmc_sqpipsram_parameter_struct *exmc_sqpipsram_init_struct)
{
/* configure the structure with default values */
exmc_sqpipsram_init_struct->sample_polarity = EXMC_SQPIPSRAM_SAMPLE_RISING_EDGE;
@@ -706,18 +722,18 @@ void exmc_sqpipsram_struct_para_init(exmc_sqpipsram_parameter_struct* exmc_sqpip
\param[out] none
\retval none
*/
-void exmc_sqpipsram_init(exmc_sqpipsram_parameter_struct* exmc_sqpipsram_init_struct)
+void exmc_sqpipsram_init(exmc_sqpipsram_parameter_struct *exmc_sqpipsram_init_struct)
{
/* initialize SQPI controller */
EXMC_SINIT = (uint32_t)exmc_sqpipsram_init_struct->sample_polarity |
- exmc_sqpipsram_init_struct->id_length |
- exmc_sqpipsram_init_struct->address_bits |
- exmc_sqpipsram_init_struct->command_bits;
+ exmc_sqpipsram_init_struct->id_length |
+ exmc_sqpipsram_init_struct->address_bits |
+ exmc_sqpipsram_init_struct->command_bits;
}
/*!
\brief configure consecutive clock
- \param[in] clock_mode: specifie when the clock is generated
+ \param[in] clock_mode: specify when the clock is generated
only one parameter can be selected which is shown as below:
\arg EXMC_CLOCK_SYN_MODE: the clock is generated only during synchronous access
\arg EXMC_CLOCK_UNCONDITIONALLY: the clock is generated unconditionally
@@ -726,9 +742,9 @@ void exmc_sqpipsram_init(exmc_sqpipsram_parameter_struct* exmc_sqpipsram_init_st
*/
void exmc_norsram_consecutive_clock_config(uint32_t clock_mode)
{
- if (EXMC_CLOCK_UNCONDITIONALLY == clock_mode){
+ if(EXMC_CLOCK_UNCONDITIONALLY == clock_mode) {
EXMC_SNCTL(EXMC_BANK0_NORSRAM_REGION0) |= EXMC_CLOCK_UNCONDITIONALLY;
- }else{
+ } else {
EXMC_SNCTL(EXMC_BANK0_NORSRAM_REGION0) &= ~EXMC_CLOCK_UNCONDITIONALLY;
}
}
@@ -759,7 +775,7 @@ void exmc_norsram_page_size_config(uint32_t exmc_norsram_region, uint32_t page_s
/*!
\brief enable or disable the EXMC NAND ECC function
- \param[in] exmc_nand_bank: specifie the NAND bank
+ \param[in] exmc_nand_bank: specify the NAND bank
only one parameter can be selected which is shown as below:
\arg EXMC_BANKx_NAND(x=1,2)
\param[in] newvalue: ENABLE or DISABLE
@@ -768,10 +784,10 @@ void exmc_norsram_page_size_config(uint32_t exmc_norsram_region, uint32_t page_s
*/
void exmc_nand_ecc_config(uint32_t exmc_nand_bank, ControlStatus newvalue)
{
- if (ENABLE == newvalue){
+ if(ENABLE == newvalue) {
/* enable the selected NAND bank ECC function */
EXMC_NPCTL(exmc_nand_bank) |= EXMC_NPCTL_ECCEN;
- }else{
+ } else {
/* disable the selected NAND bank ECC function */
EXMC_NPCTL(exmc_nand_bank) &= ~EXMC_NPCTL_ECCEN;
}
@@ -779,7 +795,7 @@ void exmc_nand_ecc_config(uint32_t exmc_nand_bank, ControlStatus newvalue)
/*!
\brief get the EXMC ECC value
- \param[in] exmc_nand_bank: specifie the NAND bank
+ \param[in] exmc_nand_bank: specify the NAND bank
only one parameter can be selected which is shown as below:
\arg EXMC_BANKx_NAND(x=1,2)
\param[out] none
@@ -798,9 +814,9 @@ uint32_t exmc_ecc_get(uint32_t exmc_nand_bank)
*/
void exmc_sdram_readsample_enable(ControlStatus newvalue)
{
- if (ENABLE == newvalue){
+ if(ENABLE == newvalue) {
EXMC_SDRSCTL |= EXMC_SDRSCTL_RSEN;
- }else{
+ } else {
EXMC_SDRSCTL &= (uint32_t)(~EXMC_SDRSCTL_RSEN);
}
}
@@ -823,8 +839,7 @@ void exmc_sdram_readsample_config(uint32_t delay_cell, uint32_t extra_hclk)
/* reset the bits */
sdrsctl = EXMC_SDRSCTL & (~(EXMC_SDRSCTL_SDSC | EXMC_SDRSCTL_SSCR));
/* set the bits */
- sdrsctl |= (uint32_t)(delay_cell & EXMC_SDRSCTL_SDSC) |
- ((extra_hclk << SDRSCTL_SSCR_OFFSET) & EXMC_SDRSCTL_SSCR);
+ sdrsctl |= (uint32_t)(delay_cell | extra_hclk);
EXMC_SDRSCTL = sdrsctl;
}
@@ -840,13 +855,13 @@ void exmc_sdram_readsample_config(uint32_t delay_cell, uint32_t extra_hclk)
\param[out] none
\retval none
*/
-void exmc_sdram_command_config(exmc_sdram_command_parameter_struct* exmc_sdram_command_init_struct)
+void exmc_sdram_command_config(exmc_sdram_command_parameter_struct *exmc_sdram_command_init_struct)
{
/* configure command register */
EXMC_SDCMD = (uint32_t)((exmc_sdram_command_init_struct->command) |
- (exmc_sdram_command_init_struct->bank_select) |
- ((exmc_sdram_command_init_struct->auto_refresh_number)) |
- ((exmc_sdram_command_init_struct->mode_register_content)<<SDCMD_MRC_OFFSET) );
+ (exmc_sdram_command_init_struct->bank_select) |
+ ((exmc_sdram_command_init_struct->auto_refresh_number)) |
+ ((exmc_sdram_command_init_struct->mode_register_content) << SDCMD_MRC_OFFSET));
}
/*!
@@ -876,8 +891,8 @@ void exmc_sdram_autorefresh_number_set(uint32_t exmc_number)
}
/*!
- \brief config the write protection function
- \param[in] exmc_sdram_device: specifie the SDRAM device
+ \brief configure the write protection function
+ \param[in] exmc_sdram_device: specify the SDRAM device
only one parameter can be selected which is shown as below:
\arg EXMC_SDRAM_DEVICEx(x=0,1)
\param[in] newvalue: ENABLE or DISABLE
@@ -886,9 +901,9 @@ void exmc_sdram_autorefresh_number_set(uint32_t exmc_number)
*/
void exmc_sdram_write_protection_config(uint32_t exmc_sdram_device, ControlStatus newvalue)
{
- if (ENABLE == newvalue){
+ if(ENABLE == newvalue) {
EXMC_SDCTL(exmc_sdram_device) |= (uint32_t)EXMC_SDCTL_WPEN;
- }else{
+ } else {
EXMC_SDCTL(exmc_sdram_device) &= ~((uint32_t)EXMC_SDCTL_WPEN);
}
@@ -896,7 +911,7 @@ void exmc_sdram_write_protection_config(uint32_t exmc_sdram_device, ControlStatu
/*!
\brief get the status of SDRAM device0 or device1
- \param[in] exmc_sdram_device: specifie the SDRAM device
+ \param[in] exmc_sdram_device: specify the SDRAM device
only one parameter can be selected which is shown as below:
\arg EXMC_SDRAM_DEVICEx(x=0,1)
\param[out] none
@@ -906,9 +921,9 @@ uint32_t exmc_sdram_bankstatus_get(uint32_t exmc_sdram_device)
{
uint32_t sdstat = 0U;
- if(EXMC_SDRAM_DEVICE0 == exmc_sdram_device){
+ if(EXMC_SDRAM_DEVICE0 == exmc_sdram_device) {
sdstat = ((uint32_t)(EXMC_SDSTAT & EXMC_SDSDAT_STA0) >> SDSTAT_STA0_OFFSET);
- }else{
+ } else {
sdstat = ((uint32_t)(EXMC_SDSTAT & EXMC_SDSDAT_STA1) >> SDSTAT_STA1_OFFSET);
}
@@ -928,13 +943,13 @@ uint32_t exmc_sdram_bankstatus_get(uint32_t exmc_sdram_device)
\param[out] none
\retval none
*/
-void exmc_sqpipsram_read_command_set(uint32_t read_command_mode,uint32_t read_wait_cycle, uint32_t read_command_code)
+void exmc_sqpipsram_read_command_set(uint32_t read_command_mode, uint32_t read_wait_cycle, uint32_t read_command_code)
{
uint32_t srcmd;
srcmd = (uint32_t) read_command_mode |
- ((read_wait_cycle << SRCMD_RWAITCYCLE_OFFSET) & EXMC_SRCMD_RWAITCYCLE) |
- ((read_command_code & EXMC_SRCMD_RCMD));
+ ((read_wait_cycle << SRCMD_RWAITCYCLE_OFFSET) & EXMC_SRCMD_RWAITCYCLE) |
+ ((read_command_code & EXMC_SRCMD_RCMD));
EXMC_SRCMD = srcmd;
}
@@ -951,13 +966,13 @@ void exmc_sqpipsram_read_command_set(uint32_t read_command_mode,uint32_t read_wa
\param[out] none
\retval none
*/
-void exmc_sqpipsram_write_command_set(uint32_t write_command_mode,uint32_t write_wait_cycle, uint32_t write_command_code)
+void exmc_sqpipsram_write_command_set(uint32_t write_command_mode, uint32_t write_wait_cycle, uint32_t write_command_code)
{
uint32_t swcmd;
swcmd = (uint32_t) write_command_mode |
- ((write_wait_cycle << SWCMD_WWAITCYCLE_OFFSET) & EXMC_SWCMD_WWAITCYCLE) |
- ((write_command_code & EXMC_SWCMD_WCMD));
+ ((write_wait_cycle << SWCMD_WWAITCYCLE_OFFSET) & EXMC_SWCMD_WWAITCYCLE) |
+ ((write_command_code & EXMC_SWCMD_WCMD));
EXMC_SWCMD = swcmd;
}
@@ -1018,17 +1033,17 @@ FlagStatus exmc_sqpipsram_send_command_state_get(uint32_t send_command_flag)
{
uint32_t flag = 0x00000000U;
- if(EXMC_SEND_COMMAND_FLAG_RDID == send_command_flag){
+ if(EXMC_SEND_COMMAND_FLAG_RDID == send_command_flag) {
flag = EXMC_SRCMD;
- }else if(EXMC_SEND_COMMAND_FLAG_SC == send_command_flag){
+ } else if(EXMC_SEND_COMMAND_FLAG_SC == send_command_flag) {
flag = EXMC_SWCMD;
- }else{
+ } else {
}
- if (flag & send_command_flag){
+ if(flag & send_command_flag) {
/* flag is set */
return SET;
- }else{
+ } else {
/* flag is reset */
return RESET;
}
@@ -1036,14 +1051,14 @@ FlagStatus exmc_sqpipsram_send_command_state_get(uint32_t send_command_flag)
/*!
\brief enable EXMC interrupt
- \param[in] exmc_bank: specifies the NAND bank,PC card bank or SDRAM device
+ \param[in] exmc_bank: specify the NAND bank,PC card bank or SDRAM device
only one parameter can be selected which is shown as below:
\arg EXMC_BANK1_NAND: the NAND bank1
\arg EXMC_BANK2_NAND: the NAND bank2
\arg EXMC_BANK3_PCCARD: the PC card bank
\arg EXMC_SDRAM_DEVICE0: the SDRAM device0
\arg EXMC_SDRAM_DEVICE1: the SDRAM device1
- \param[in] interrupt: specify get which interrupt flag
+ \param[in] interrupt: specify EXMC interrupt flag
only one parameter can be selected which is shown as below:
\arg EXMC_NAND_PCCARD_INT_FLAG_RISE: rising edge interrupt and flag
\arg EXMC_NAND_PCCARD_INT_FLAG_LEVEL: high-level interrupt and flag
@@ -1054,10 +1069,10 @@ FlagStatus exmc_sqpipsram_send_command_state_get(uint32_t send_command_flag)
*/
void exmc_interrupt_enable(uint32_t exmc_bank, uint32_t interrupt)
{
- if((EXMC_BANK1_NAND == exmc_bank) || (EXMC_BANK2_NAND == exmc_bank) || (EXMC_BANK3_PCCARD == exmc_bank)){
+ if((EXMC_BANK1_NAND == exmc_bank) || (EXMC_BANK2_NAND == exmc_bank) || (EXMC_BANK3_PCCARD == exmc_bank)) {
/* NAND bank1,bank2 or PC card bank3 */
EXMC_NPINTEN(exmc_bank) |= interrupt;
- }else{
+ } else {
/* SDRAM device0 or device1 */
EXMC_SDARI |= EXMC_SDARI_REIE;
}
@@ -1065,14 +1080,14 @@ void exmc_interrupt_enable(uint32_t exmc_bank, uint32_t interrupt)
/*!
\brief disable EXMC interrupt
- \param[in] exmc_bank: specifies the NAND bank , PC card bank or SDRAM device
+ \param[in] exmc_bank: specify the NAND bank , PC card bank or SDRAM device
only one parameter can be selected which is shown as below:
\arg EXMC_BANK1_NAND: the NAND bank1
\arg EXMC_BANK2_NAND: the NAND bank2
\arg EXMC_BANK3_PCCARD: the PC card bank
\arg EXMC_SDRAM_DEVICE0: the SDRAM device0
\arg EXMC_SDRAM_DEVICE1: the SDRAM device1
- \param[in] interrupt: specify get which interrupt flag
+ \param[in] interrupt: specify EXMC interrupt flag
only one parameter can be selected which is shown as below:
\arg EXMC_NAND_PCCARD_INT_FLAG_RISE: rising edge interrupt and flag
\arg EXMC_NAND_PCCARD_INT_FLAG_LEVEL: high-level interrupt and flag
@@ -1083,10 +1098,10 @@ void exmc_interrupt_enable(uint32_t exmc_bank, uint32_t interrupt)
*/
void exmc_interrupt_disable(uint32_t exmc_bank, uint32_t interrupt)
{
- if((EXMC_BANK1_NAND == exmc_bank) || (EXMC_BANK2_NAND == exmc_bank) || (EXMC_BANK3_PCCARD == exmc_bank)){
+ if((EXMC_BANK1_NAND == exmc_bank) || (EXMC_BANK2_NAND == exmc_bank) || (EXMC_BANK3_PCCARD == exmc_bank)) {
/* NAND bank1,bank2 or PC card bank3 */
EXMC_NPINTEN(exmc_bank) &= ~interrupt;
- }else{
+ } else {
/* SDRAM device0 or device1 */
EXMC_SDARI &= ~EXMC_SDARI_REIE;
}
@@ -1094,7 +1109,7 @@ void exmc_interrupt_disable(uint32_t exmc_bank, uint32_t interrupt)
/*!
\brief get EXMC flag status
- \param[in] exmc_bank: specifies the NAND bank , PC card bank or SDRAM device
+ \param[in] exmc_bank: specify the NAND bank , PC card bank or SDRAM device
only one parameter can be selected which is shown as below:
\arg EXMC_BANK1_NAND: the NAND bank1
\arg EXMC_BANK2_NAND: the NAND bank2
@@ -1112,22 +1127,22 @@ void exmc_interrupt_disable(uint32_t exmc_bank, uint32_t interrupt)
\param[out] none
\retval FlagStatus: SET or RESET
*/
-FlagStatus exmc_flag_get(uint32_t exmc_bank,uint32_t flag)
+FlagStatus exmc_flag_get(uint32_t exmc_bank, uint32_t flag)
{
uint32_t status = 0x00000000U;
- if((EXMC_BANK1_NAND == exmc_bank) || (EXMC_BANK2_NAND == exmc_bank) || (EXMC_BANK3_PCCARD == exmc_bank)){
+ if((EXMC_BANK1_NAND == exmc_bank) || (EXMC_BANK2_NAND == exmc_bank) || (EXMC_BANK3_PCCARD == exmc_bank)) {
/* NAND bank1,bank2 or PC card bank3 */
status = EXMC_NPINTEN(exmc_bank);
- }else{
- /* SDRAM device0 or device1 */
+ } else {
+ /* SDRAM device0 or device1 */
status = EXMC_SDSTAT;
}
- if ((status & flag) != (uint32_t)flag ){
+ if((status & flag) != (uint32_t)flag) {
/* flag is reset */
return RESET;
- }else{
+ } else {
/* flag is set */
return SET;
}
@@ -1135,7 +1150,7 @@ FlagStatus exmc_flag_get(uint32_t exmc_bank,uint32_t flag)
/*!
\brief clear EXMC flag status
- \param[in] exmc_bank: specifie the NAND bank , PCCARD bank or SDRAM device
+ \param[in] exmc_bank: specify the NAND bank , PCCARD bank or SDRAM device
only one parameter can be selected which is shown as below:
\arg EXMC_BANK1_NAND: the NAND bank1
\arg EXMC_BANK2_NAND: the NAND bank2
@@ -1155,10 +1170,10 @@ FlagStatus exmc_flag_get(uint32_t exmc_bank,uint32_t flag)
*/
void exmc_flag_clear(uint32_t exmc_bank, uint32_t flag)
{
- if((EXMC_BANK1_NAND == exmc_bank) || (EXMC_BANK2_NAND == exmc_bank) || (EXMC_BANK3_PCCARD == exmc_bank)){
+ if((EXMC_BANK1_NAND == exmc_bank) || (EXMC_BANK2_NAND == exmc_bank) || (EXMC_BANK3_PCCARD == exmc_bank)) {
/* NAND bank1,bank2 or PC card bank3 */
EXMC_NPINTEN(exmc_bank) &= ~flag;
- }else{
+ } else {
/* SDRAM device0 or device1 */
EXMC_SDSTAT &= ~flag;
}
@@ -1166,7 +1181,7 @@ void exmc_flag_clear(uint32_t exmc_bank, uint32_t flag)
/*!
\brief get EXMC interrupt flag
- \param[in] exmc_bank: specifies the NAND bank , PC card bank or SDRAM device
+ \param[in] exmc_bank: specify the NAND bank , PC card bank or SDRAM device
only one parameter can be selected which is shown as below:
\arg EXMC_BANK1_NAND: the NAND bank1
\arg EXMC_BANK2_NAND: the NAND bank2
@@ -1184,24 +1199,24 @@ void exmc_flag_clear(uint32_t exmc_bank, uint32_t flag)
*/
FlagStatus exmc_interrupt_flag_get(uint32_t exmc_bank, uint32_t interrupt)
{
- uint32_t status = 0x00000000U,interrupt_enable = 0x00000000U,interrupt_state = 0x00000000U;
+ uint32_t status = 0x00000000U, interrupt_enable = 0x00000000U, interrupt_state = 0x00000000U;
- if((EXMC_BANK1_NAND == exmc_bank) || (EXMC_BANK2_NAND == exmc_bank) || (EXMC_BANK3_PCCARD == exmc_bank)){
+ if((EXMC_BANK1_NAND == exmc_bank) || (EXMC_BANK2_NAND == exmc_bank) || (EXMC_BANK3_PCCARD == exmc_bank)) {
/* NAND bank1,bank2 or PC card bank3 */
status = EXMC_NPINTEN(exmc_bank);
interrupt_state = (status & (interrupt >> INTEN_INTS_OFFSET));
- }else{
- /* SDRAM device0 or device1 */
+ } else {
+ /* SDRAM device0 or device1 */
status = EXMC_SDARI;
interrupt_state = (EXMC_SDSTAT & EXMC_SDSDAT_REIF);
}
interrupt_enable = (status & interrupt);
- if ((interrupt_enable) && (interrupt_state)){
+ if((interrupt_enable) && (interrupt_state)) {
/* interrupt flag is set */
return SET;
- }else{
+ } else {
/* interrupt flag is reset */
return RESET;
}
@@ -1209,7 +1224,7 @@ FlagStatus exmc_interrupt_flag_get(uint32_t exmc_bank, uint32_t interrupt)
/*!
\brief clear EXMC interrupt flag
- \param[in] exmc_bank: specifies the NAND bank , PC card bank or SDRAM device
+ \param[in] exmc_bank: specify the NAND bank , PC card bank or SDRAM device
only one parameter can be selected which is shown as below:
\arg EXMC_BANK1_NAND: the NAND bank1
\arg EXMC_BANK2_NAND: the NAND bank2
@@ -1227,10 +1242,10 @@ FlagStatus exmc_interrupt_flag_get(uint32_t exmc_bank, uint32_t interrupt)
*/
void exmc_interrupt_flag_clear(uint32_t exmc_bank, uint32_t interrupt)
{
- if((EXMC_BANK1_NAND == exmc_bank) || (EXMC_BANK2_NAND == exmc_bank) || (EXMC_BANK3_PCCARD == exmc_bank)){
+ if((EXMC_BANK1_NAND == exmc_bank) || (EXMC_BANK2_NAND == exmc_bank) || (EXMC_BANK3_PCCARD == exmc_bank)) {
/* NAND bank1,bank2 or PC card bank3 */
EXMC_NPINTEN(exmc_bank) &= ~(interrupt >> INTEN_INTS_OFFSET);
- }else{
+ } else {
/* SDRAM device0 or device1 */
EXMC_SDARI |= EXMC_SDARI_REC;
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_exti.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_exti.c
index a3eacb0202..413dff9338 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_exti.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_exti.c
@@ -1,14 +1,14 @@
/*!
\file gd32f4xx_exti.c
\brief EXTI driver
-
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
- \version 2018-12-12, V2.0.1, firmware for GD32F4xx
+ \version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -36,8 +36,10 @@ OF SUCH DAMAGE.
#include "gd32f4xx_exti.h"
+#define EXTI_REG_RESET_VALUE ((uint32_t)0x00000000U)
+
/*!
- \brief deinitialize the EXTI
+ \brief deinitialize the EXTI
\param[in] none
\param[out] none
\retval none
@@ -45,15 +47,15 @@ OF SUCH DAMAGE.
void exti_deinit(void)
{
/* reset the value of all the EXTI registers */
- EXTI_INTEN = (uint32_t)0x00000000U;
- EXTI_EVEN = (uint32_t)0x00000000U;
- EXTI_RTEN = (uint32_t)0x00000000U;
- EXTI_FTEN = (uint32_t)0x00000000U;
- EXTI_SWIEV = (uint32_t)0x00000000U;
+ EXTI_INTEN = EXTI_REG_RESET_VALUE;
+ EXTI_EVEN = EXTI_REG_RESET_VALUE;
+ EXTI_RTEN = EXTI_REG_RESET_VALUE;
+ EXTI_FTEN = EXTI_REG_RESET_VALUE;
+ EXTI_SWIEV = EXTI_REG_RESET_VALUE;
}
/*!
- \brief initialize the EXTI
+ \brief initialize the EXTI line x
\param[in] linex: EXTI line number, refer to exti_line_enum
only one parameter can be selected which is shown as below:
\arg EXTI_x (x=0..22): EXTI line x
@@ -71,8 +73,8 @@ void exti_deinit(void)
\retval none
*/
void exti_init(exti_line_enum linex, \
- exti_mode_enum mode, \
- exti_trig_type_enum trig_type)
+ exti_mode_enum mode, \
+ exti_trig_type_enum trig_type)
{
/* reset the EXTI line x */
EXTI_INTEN &= ~(uint32_t)linex;
@@ -81,7 +83,7 @@ void exti_init(exti_line_enum linex, \
EXTI_FTEN &= ~(uint32_t)linex;
/* set the EXTI mode and enable the interrupts or events from EXTI line x */
- switch(mode){
+ switch(mode) {
case EXTI_INTERRUPT:
EXTI_INTEN |= (uint32_t)linex;
break;
@@ -93,7 +95,7 @@ void exti_init(exti_line_enum linex, \
}
/* set the EXTI trigger type */
- switch(trig_type){
+ switch(trig_type) {
case EXTI_TRIG_RISING:
EXTI_RTEN |= (uint32_t)linex;
EXTI_FTEN &= ~(uint32_t)linex;
@@ -113,7 +115,7 @@ void exti_init(exti_line_enum linex, \
}
/*!
- \brief enable the interrupts from EXTI line x
+ \brief enable the interrupts from EXTI line x
\param[in] linex: EXTI line number, refer to exti_line_enum
only one parameter can be selected which is shown as below:
\arg EXTI_x (x=0..22): EXTI line x
@@ -126,7 +128,7 @@ void exti_interrupt_enable(exti_line_enum linex)
}
/*!
- \brief disable the interrupt from EXTI line x
+ \brief disable the interrupt from EXTI line x
\param[in] linex: EXTI line number, refer to exti_line_enum
only one parameter can be selected which is shown as below:
\arg EXTI_x (x=0..22): EXTI line x
@@ -139,7 +141,7 @@ void exti_interrupt_disable(exti_line_enum linex)
}
/*!
- \brief enable the events from EXTI line x
+ \brief enable the events from EXTI line x
\param[in] linex: EXTI line number, refer to exti_line_enum
only one parameter can be selected which is shown as below:
\arg EXTI_x (x=0..22): EXTI line x
@@ -152,7 +154,7 @@ void exti_event_enable(exti_line_enum linex)
}
/*!
- \brief disable the events from EXTI line x
+ \brief disable the events from EXTI line x
\param[in] linex: EXTI line number, refer to exti_line_enum
only one parameter can be selected which is shown as below:
\arg EXTI_x (x=0..22): EXTI line x
@@ -165,7 +167,7 @@ void exti_event_disable(exti_line_enum linex)
}
/*!
- \brief enable EXTI software interrupt event
+ \brief enable the software interrupt event from EXTI line x
\param[in] linex: EXTI line number, refer to exti_line_enum
only one parameter can be selected which is shown as below:
\arg EXTI_x (x=0..22): EXTI line x
@@ -178,7 +180,7 @@ void exti_software_interrupt_enable(exti_line_enum linex)
}
/*!
- \brief disable EXTI software interrupt event
+ \brief disable the software interrupt event from EXTI line x
\param[in] linex: EXTI line number, refer to exti_line_enum
only one parameter can be selected which is shown as below:
\arg EXTI_x (x=0..22): EXTI line x
@@ -191,7 +193,7 @@ void exti_software_interrupt_disable(exti_line_enum linex)
}
/*!
- \brief get EXTI lines flag
+ \brief get EXTI line x interrupt pending flag
\param[in] linex: EXTI line number, refer to exti_line_enum
only one parameter can be selected which is shown as below:
\arg EXTI_x (x=0..22): EXTI line x
@@ -200,15 +202,15 @@ void exti_software_interrupt_disable(exti_line_enum linex)
*/
FlagStatus exti_flag_get(exti_line_enum linex)
{
- if(RESET != (EXTI_PD & (uint32_t)linex)){
+ if(RESET != (EXTI_PD & (uint32_t)linex)) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief clear EXTI lines pending flag
+ \brief clear EXTI line x interrupt pending flag
\param[in] linex: EXTI line number, refer to exti_line_enum
only one parameter can be selected which is shown as below:
\arg EXTI_x (x=0..22): EXTI line x
@@ -221,7 +223,7 @@ void exti_flag_clear(exti_line_enum linex)
}
/*!
- \brief get EXTI lines flag when the interrupt flag is set
+ \brief get EXTI line x interrupt pending flag
\param[in] linex: EXTI line number, refer to exti_line_enum
only one parameter can be selected which is shown as below:
\arg EXTI_x (x=0..22): EXTI line x
@@ -230,20 +232,15 @@ void exti_flag_clear(exti_line_enum linex)
*/
FlagStatus exti_interrupt_flag_get(exti_line_enum linex)
{
- uint32_t flag_left, flag_right;
-
- flag_left = EXTI_PD & (uint32_t)linex;
- flag_right = EXTI_INTEN & (uint32_t)linex;
-
- if((RESET != flag_left) && (RESET != flag_right)){
+ if(RESET != (EXTI_PD & (uint32_t)linex)) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief clear EXTI lines pending flag
+ \brief clear EXTI line x interrupt pending flag
\param[in] linex: EXTI line number, refer to exti_line_enum
only one parameter can be selected which is shown as below:
\arg EXTI_x (x=0..22): EXTI line x
@@ -254,4 +251,3 @@ void exti_interrupt_flag_clear(exti_line_enum linex)
{
EXTI_PD = (uint32_t)linex;
}
-
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_fmc.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_fmc.c
index 4e2b0db9a5..9dfa1904f2 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_fmc.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_fmc.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -38,7 +39,7 @@ OF SUCH DAMAGE.
#include "gd32f4xx_fmc.h"
/*!
- \brief set the wait state counter value
+ \brief set the FMC wait state counter
\param[in] wscnt: wait state counter value
only one parameter can be selected which is shown as below:
\arg WS_WSCNT_0: FMC 0 wait
@@ -71,14 +72,14 @@ void fmc_wscnt_set(uint32_t wscnt)
}
/*!
- \brief unlock the main FMC operation
+ \brief unlock the main FMC operation
\param[in] none
\param[out] none
\retval none
*/
void fmc_unlock(void)
{
- if((RESET != (FMC_CTL & FMC_CTL_LK))){
+ if((RESET != (FMC_CTL & FMC_CTL_LK))) {
/* write the FMC key */
FMC_KEY = UNLOCK_KEY0;
FMC_KEY = UNLOCK_KEY1;
@@ -86,7 +87,7 @@ void fmc_unlock(void)
}
/*!
- \brief lock the main FMC operation
+ \brief lock the main FMC operation
\param[in] none
\param[out] none
\retval none
@@ -97,8 +98,54 @@ void fmc_lock(void)
FMC_CTL |= FMC_CTL_LK;
}
+#if defined (GD32F425) || defined (GD32F427) || defined (GD32F470)
+
/*!
- \brief erase sector
+ \brief FMC erase page
+ \param[in] page_addr: the page address to be erased.
+ \param[out] none
+ \retval state of FMC
+ \arg FMC_READY: the operation has been completed
+ \arg FMC_BUSY: the operation is in progress
+ \arg FMC_RDDERR: read D-bus protection error
+ \arg FMC_PGSERR: program sequence error
+ \arg FMC_PGMERR: program size not match error
+ \arg FMC_WPERR: erase/program protection error
+ \arg FMC_OPERR: operation error
+ \arg FMC_TOERR: timeout error
+*/
+fmc_state_enum fmc_page_erase(uint32_t page_addr)
+{
+ fmc_state_enum fmc_state = FMC_READY;
+
+ /* wait for the FMC ready */
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
+
+ if(FMC_READY == fmc_state) {
+ /* unlock page erase operation */
+ FMC_PEKEY = UNLOCK_PE_KEY;
+
+ /* start page erase */
+ FMC_PECFG = FMC_PE_EN | page_addr;
+ FMC_CTL &= ~FMC_CTL_SN;
+ FMC_CTL |= FMC_CTL_SER;
+ FMC_CTL |= FMC_CTL_START;
+
+ /* wait for the FMC ready */
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
+
+ FMC_PECFG &= ~FMC_PE_EN;
+ FMC_CTL &= ~FMC_CTL_SER;
+ }
+
+ /* return the FMC state */
+ return fmc_state;
+}
+
+#endif
+
+/*!
+ \brief FMC erase sector
\param[in] fmc_sector: select the sector to erase
only one parameter can be selected which is shown as below:
\arg CTL_SECTOR_NUMBER_0: sector 0
@@ -138,22 +185,22 @@ void fmc_lock(void)
\arg FMC_PGMERR: program size not match error
\arg FMC_WPERR: erase/program protection error
\arg FMC_OPERR: operation error
- \arg FMC_PGERR: program error
+ \arg FMC_TOERR: timeout error
*/
fmc_state_enum fmc_sector_erase(uint32_t fmc_sector)
{
fmc_state_enum fmc_state = FMC_READY;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
- if(FMC_READY == fmc_state){
+ if(FMC_READY == fmc_state) {
/* start sector erase */
FMC_CTL &= ~FMC_CTL_SN;
FMC_CTL |= (FMC_CTL_SER | fmc_sector);
FMC_CTL |= FMC_CTL_START;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
/* reset the SER bit */
FMC_CTL &= (~FMC_CTL_SER);
@@ -165,7 +212,7 @@ fmc_state_enum fmc_sector_erase(uint32_t fmc_sector)
}
/*!
- \brief erase whole chip
+ \brief FMC erase whole chip
\param[in] none
\param[out] none
\retval state of FMC
@@ -176,21 +223,21 @@ fmc_state_enum fmc_sector_erase(uint32_t fmc_sector)
\arg FMC_PGMERR: program size not match error
\arg FMC_WPERR: erase/program protection error
\arg FMC_OPERR: operation error
- \arg FMC_PGERR: program error
+ \arg FMC_TOERR: timeout error
*/
fmc_state_enum fmc_mass_erase(void)
{
fmc_state_enum fmc_state = FMC_READY;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
- if(FMC_READY == fmc_state){
+ if(FMC_READY == fmc_state) {
/* start whole chip erase */
FMC_CTL |= (FMC_CTL_MER0 | FMC_CTL_MER1);
FMC_CTL |= FMC_CTL_START;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
/* reset the MER bits */
FMC_CTL &= ~(FMC_CTL_MER0 | FMC_CTL_MER1);
@@ -201,7 +248,7 @@ fmc_state_enum fmc_mass_erase(void)
}
/*!
- \brief erase all FMC sectors in bank0
+ \brief FMC erase whole bank0
\param[in] none
\param[out] none
\retval state of FMC
@@ -212,21 +259,21 @@ fmc_state_enum fmc_mass_erase(void)
\arg FMC_PGMERR: program size not match error
\arg FMC_WPERR: erase/program protection error
\arg FMC_OPERR: operation error
- \arg FMC_PGERR: program error
+ \arg FMC_TOERR: timeout error
*/
fmc_state_enum fmc_bank0_erase(void)
{
fmc_state_enum fmc_state = FMC_READY;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
- if(FMC_READY == fmc_state){
+ if(FMC_READY == fmc_state) {
/* start FMC bank0 erase */
FMC_CTL |= FMC_CTL_MER0;
FMC_CTL |= FMC_CTL_START;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
/* reset the MER0 bit */
FMC_CTL &= (~FMC_CTL_MER0);
@@ -237,7 +284,7 @@ fmc_state_enum fmc_bank0_erase(void)
}
/*!
- \brief erase all FMC sectors in bank1
+ \brief FMC erase whole bank1
\param[in] none
\param[out] none
\retval state of FMC
@@ -248,21 +295,21 @@ fmc_state_enum fmc_bank0_erase(void)
\arg FMC_PGMERR: program size not match error
\arg FMC_WPERR: erase/program protection error
\arg FMC_OPERR: operation error
- \arg FMC_PGERR: program error
+ \arg FMC_TOERR: timeout error
*/
fmc_state_enum fmc_bank1_erase(void)
{
fmc_state_enum fmc_state = FMC_READY;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
- if(FMC_READY == fmc_state){
+ if(FMC_READY == fmc_state) {
/* start FMC bank1 erase */
FMC_CTL |= FMC_CTL_MER1;
FMC_CTL |= FMC_CTL_START;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
/* reset the MER1 bit */
FMC_CTL &= (~FMC_CTL_MER1);
@@ -273,7 +320,7 @@ fmc_state_enum fmc_bank1_erase(void)
}
/*!
- \brief program a word at the corresponding address
+ \brief program a word at the corresponding address
\param[in] address: address to program
\param[in] data: word to program(0x00000000 - 0xFFFFFFFF)
\param[out] none
@@ -285,15 +332,15 @@ fmc_state_enum fmc_bank1_erase(void)
\arg FMC_PGMERR: program size not match error
\arg FMC_WPERR: erase/program protection error
\arg FMC_OPERR: operation error
- \arg FMC_PGERR: program error
+ \arg FMC_TOERR: timeout error
*/
fmc_state_enum fmc_word_program(uint32_t address, uint32_t data)
{
fmc_state_enum fmc_state = FMC_READY;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
- if(FMC_READY == fmc_state){
+ if(FMC_READY == fmc_state) {
/* set the PG bit to start program */
FMC_CTL &= ~FMC_CTL_PSZ;
FMC_CTL |= CTL_PSZ_WORD;
@@ -302,7 +349,7 @@ fmc_state_enum fmc_word_program(uint32_t address, uint32_t data)
REG32(address) = data;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
/* reset the PG bit */
FMC_CTL &= ~FMC_CTL_PG;
@@ -313,7 +360,7 @@ fmc_state_enum fmc_word_program(uint32_t address, uint32_t data)
}
/*!
- \brief program a half word at the corresponding address
+ \brief program a half word at the corresponding address
\param[in] address: address to program
\param[in] data: halfword to program(0x0000 - 0xFFFF)
\param[out] none
@@ -325,15 +372,15 @@ fmc_state_enum fmc_word_program(uint32_t address, uint32_t data)
\arg FMC_PGMERR: program size not match error
\arg FMC_WPERR: erase/program protection error
\arg FMC_OPERR: operation error
- \arg FMC_PGERR: program error
+ \arg FMC_TOERR: timeout error
*/
fmc_state_enum fmc_halfword_program(uint32_t address, uint16_t data)
{
fmc_state_enum fmc_state = FMC_READY;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
- if(FMC_READY == fmc_state){
+ if(FMC_READY == fmc_state) {
/* set the PG bit to start program */
FMC_CTL &= ~FMC_CTL_PSZ;
FMC_CTL |= CTL_PSZ_HALF_WORD;
@@ -342,7 +389,7 @@ fmc_state_enum fmc_halfword_program(uint32_t address, uint16_t data)
REG16(address) = data;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
/* reset the PG bit */
FMC_CTL &= ~FMC_CTL_PG;
@@ -353,7 +400,7 @@ fmc_state_enum fmc_halfword_program(uint32_t address, uint16_t data)
}
/*!
- \brief program a byte at the corresponding address
+ \brief program a byte at the corresponding address
\param[in] address: address to program
\param[in] data: byte to program(0x00 - 0xFF)
\param[out] none
@@ -365,15 +412,15 @@ fmc_state_enum fmc_halfword_program(uint32_t address, uint16_t data)
\arg FMC_PGMERR: program size not match error
\arg FMC_WPERR: erase/program protection error
\arg FMC_OPERR: operation error
- \arg FMC_PGERR: program error
+ \arg FMC_TOERR: timeout error
*/
fmc_state_enum fmc_byte_program(uint32_t address, uint8_t data)
{
fmc_state_enum fmc_state = FMC_READY;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
- if(FMC_READY == fmc_state){
+ if(FMC_READY == fmc_state) {
/* set the PG bit to start program */
FMC_CTL &= ~FMC_CTL_PSZ;
FMC_CTL |= CTL_PSZ_BYTE;
@@ -382,7 +429,7 @@ fmc_state_enum fmc_byte_program(uint32_t address, uint8_t data)
REG8(address) = data;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
/* reset the PG bit */
FMC_CTL &= ~FMC_CTL_PG;
@@ -393,14 +440,14 @@ fmc_state_enum fmc_byte_program(uint32_t address, uint8_t data)
}
/*!
- \brief unlock the option byte operation
+ \brief unlock the option byte operation
\param[in] none
\param[out] none
\retval none
*/
void ob_unlock(void)
{
- if(RESET != (FMC_OBCTL0 & FMC_OBCTL0_OB_LK)){
+ if(RESET != (FMC_OBCTL0 & FMC_OBCTL0_OB_LK)) {
/* write the FMC key */
FMC_OBKEY = OB_UNLOCK_KEY0;
FMC_OBKEY = OB_UNLOCK_KEY1;
@@ -408,7 +455,7 @@ void ob_unlock(void)
}
/*!
- \brief lock the option byte operation
+ \brief lock the option byte operation
\param[in] none
\param[out] none
\retval none
@@ -420,25 +467,19 @@ void ob_lock(void)
}
/*!
- \brief send option byte change command
+ \brief send option byte change command
\param[in] none
\param[out] none
\retval none
*/
void ob_start(void)
{
- fmc_state_enum fmc_state = FMC_READY;
/* set the OB_START bit in OBCTL0 register */
FMC_OBCTL0 |= FMC_OBCTL0_OB_START;
- fmc_state = fmc_ready_wait();
- if(FMC_READY != fmc_state){
- while(1){
- }
- }
}
/*!
- \brief erase option byte
+ \brief erase option byte
\param[in] none
\param[out] none
\retval none
@@ -448,11 +489,11 @@ void ob_erase(void)
uint32_t reg, reg1;
fmc_state_enum fmc_state = FMC_READY;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
+ reg = FMC_OBCTL0;
+ reg1 = FMC_OBCTL1;
- if(FMC_READY == fmc_state){
- reg = FMC_OBCTL0;
- reg1 = FMC_OBCTL1;
+ if(FMC_READY == fmc_state) {
/* reset the OB_FWDGT, OB_DEEPSLEEP and OB_STDBY, set according to ob_fwdgt ,ob_deepsleep and ob_stdby */
reg |= (FMC_OBCTL0_NWDG_HW | FMC_OBCTL0_NRST_DPSLP | FMC_OBCTL0_NRST_STDBY);
@@ -476,67 +517,73 @@ void ob_erase(void)
}
/*!
- \brief enable write protection
+ \brief enable write protection
\param[in] ob_wp: specify sector to be write protected
one or more parameters can be selected which are shown as below:
\arg OB_WP_x(x=0..22):sector x(x = 0,1,2...22)
\arg OB_WP_23_27: sector23~27
\arg OB_WP_ALL: all sector
\param[out] none
- \retval none
+ \retval SUCCESS or ERROR
*/
-void ob_write_protection_enable(uint32_t ob_wp)
+ErrStatus ob_write_protection_enable(uint32_t ob_wp)
{
uint32_t reg0 = FMC_OBCTL0;
uint32_t reg1 = FMC_OBCTL1;
fmc_state_enum fmc_state = FMC_READY;
- if(RESET != (FMC_OBCTL0 & FMC_OBCTL0_DRP)){
- while(1){
- }
+ if(RESET != (FMC_OBCTL0 & FMC_OBCTL0_DRP)) {
+ return ERROR;
}
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
- if(FMC_READY == fmc_state){
- reg0 &= (~((uint32_t)ob_wp << 16));
+ if(FMC_READY == fmc_state) {
+ reg0 &= (~((uint32_t)ob_wp << 16U));
reg1 &= (~(ob_wp & 0xFFFF0000U));
FMC_OBCTL0 = reg0;
FMC_OBCTL1 = reg1;
+
+ return SUCCESS;
+ } else {
+ return ERROR;
}
}
/*!
- \brief disable write protection
+ \brief disable write protection
\param[in] ob_wp: specify sector to be write protected
one or more parameters can be selected which are shown as below:
\arg OB_WP_x(x=0..22):sector x(x = 0,1,2...22)
\arg OB_WP_23_27: sector23~27
\arg OB_WP_ALL: all sector
\param[out] none
- \retval none
+ \retval SUCCESS or ERROR
*/
-void ob_write_protection_disable(uint32_t ob_wp)
+ErrStatus ob_write_protection_disable(uint32_t ob_wp)
{
uint32_t reg0 = FMC_OBCTL0;
uint32_t reg1 = FMC_OBCTL1;
fmc_state_enum fmc_state = FMC_READY;
- if(RESET != (FMC_OBCTL0 & FMC_OBCTL0_DRP)){
- while(1){
- }
+ if(RESET != (FMC_OBCTL0 & FMC_OBCTL0_DRP)) {
+ return ERROR;
}
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
- if(FMC_READY == fmc_state){
- reg0 |= ((uint32_t)ob_wp << 16);
+ if(FMC_READY == fmc_state) {
+ reg0 |= ((uint32_t)ob_wp << 16U);
reg1 |= (ob_wp & 0xFFFF0000U);
FMC_OBCTL0 = reg0;
FMC_OBCTL1 = reg1;
+
+ return SUCCESS;
+ } else {
+ return ERROR;
}
}
/*!
- \brief enable erase/program protection and D-bus read protection
+ \brief enable erase/program protection and D-bus read protection
\param[in] ob_drp: enable the WPx bits used as erase/program protection and D-bus read protection of each sector
one or more parameters can be selected which are shown as below:
\arg OB_DRP_x(x=0..22): sector x(x = 0,1,2...22)
@@ -553,55 +600,63 @@ void ob_drp_enable(uint32_t ob_drp)
uint32_t drp_state = FMC_OBCTL0 & FMC_OBCTL0_DRP;
uint32_t wp0_state = FMC_OBCTL0 & FMC_OBCTL0_WP0;
uint32_t wp1_state = FMC_OBCTL1 & FMC_OBCTL1_WP1;
- /*disable write protection before enable D-bus read protection*/
- if((RESET != drp_state) && ((FMC_OBCTL0_WP0 != wp0_state) && (FMC_OBCTL1_WP1 != wp1_state))){
- while(1){
- }
- }
+
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
- if(FMC_READY == fmc_state){
- reg0 &= ~FMC_OBCTL0_WP0;
- reg1 &= ~FMC_OBCTL1_WP1;
- reg0 |= ((uint32_t)ob_drp << 16);
+ if(FMC_READY == fmc_state) {
+ if(RESET == drp_state) {
+ reg0 &= ~FMC_OBCTL0_WP0;
+ reg1 &= ~FMC_OBCTL1_WP1;
+ }
+ reg0 |= ((uint32_t)ob_drp << 16U);
+ reg0 |= FMC_OBCTL0_DRP;
reg1 |= ((uint32_t)ob_drp & 0xFFFF0000U);
+
FMC_OBCTL0 = reg0;
FMC_OBCTL1 = reg1;
- FMC_OBCTL0 |= FMC_OBCTL0_DRP;
}
}
/*!
- \brief disable erase/program protection and D-bus read protection
- \param[in] ob_drp: disable the WPx bits used as erase/program protection and D-bus read protection of each sector
- one or more parameters can be selected which are shown as below:
- \arg OB_DRP_x(x=0..22): sector x(x = 0,1,2...22)
- \arg OB_DRP_23_27: sector23~27
- \arg OB_DRP_ALL: all sector
+ \brief disable erase/program protection and D-bus read protection
+ \param[in] none
\param[out] none
\retval none
*/
-void ob_drp_disable(uint32_t ob_drp)
+void ob_drp_disable(void)
{
uint32_t reg0 = FMC_OBCTL0;
uint32_t reg1 = FMC_OBCTL1;
fmc_state_enum fmc_state = FMC_READY;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
- if(FMC_READY == fmc_state){
+ if(FMC_READY == fmc_state) {
+ if(((uint8_t)(reg0 >> 8U)) == (uint8_t)FMC_NSPC) {
+ /* security protection should be set as low level protection before disable D-BUS read protection */
+ reg0 &= ~FMC_OBCTL0_SPC;
+ reg0 |= ((uint32_t)FMC_LSPC << 8U);
+ FMC_OBCTL0 = reg0;
+ /* set the OB_START bit in OBCTL0 register */
+ FMC_OBCTL0 |= FMC_OBCTL0_OB_START;
+ }
+
+ /* it is necessary to disable the security protection at the same time when D-BUS read protection is disabled */
+ reg0 &= ~FMC_OBCTL0_SPC;
+ reg0 |= ((uint32_t)FMC_NSPC << 8U);
reg0 |= FMC_OBCTL0_WP0;
reg0 &= (~FMC_OBCTL0_DRP);
FMC_OBCTL0 = reg0;
reg1 |= FMC_OBCTL1_WP1;
FMC_OBCTL1 = reg1;
+
}
}
/*!
- \brief configure security protection level
+ \brief configure security protection level
\param[in] ob_spc: specify security protection level
only one parameter can be selected which is shown as below:
\arg FMC_NSPC: no security protection
@@ -614,21 +669,21 @@ void ob_security_protection_config(uint8_t ob_spc)
{
fmc_state_enum fmc_state = FMC_READY;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
- if(FMC_READY == fmc_state){
+ if(FMC_READY == fmc_state) {
uint32_t reg;
reg = FMC_OBCTL0;
/* reset the OBCTL0_SPC, set according to ob_spc */
reg &= ~FMC_OBCTL0_SPC;
- reg |= ((uint32_t)ob_spc << 8);
+ reg |= ((uint32_t)ob_spc << 8U);
FMC_OBCTL0 = reg;
}
}
/*!
- \brief program the FMC user option byte
+ \brief program the FMC user option byte
\param[in] ob_fwdgt: option byte watchdog value
only one parameter can be selected which is shown as below:
\arg OB_FWDGT_SW: software free watchdog
@@ -649,9 +704,9 @@ void ob_user_write(uint32_t ob_fwdgt, uint32_t ob_deepsleep, uint32_t ob_stdby)
fmc_state_enum fmc_state = FMC_READY;
/* wait for the FMC ready */
- fmc_state = fmc_ready_wait();
+ fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
- if(FMC_READY == fmc_state){
+ if(FMC_READY == fmc_state) {
uint32_t reg;
reg = FMC_OBCTL0;
@@ -662,7 +717,7 @@ void ob_user_write(uint32_t ob_fwdgt, uint32_t ob_deepsleep, uint32_t ob_stdby)
}
/*!
- \brief program the option byte BOR threshold value
+ \brief program the option byte BOR threshold value
\param[in] ob_bor_th: user option byte
only one parameter can be selected which is shown as below:
\arg OB_BOR_TH_VALUE3: BOR threshold value 3
@@ -683,7 +738,7 @@ void ob_user_bor_threshold(uint32_t ob_bor_th)
}
/*!
- \brief configure the option byte boot bank value
+ \brief configure the option byte boot bank value
\param[in] boot_mode: specifies the option byte boot bank value
only one parameter can be selected which is shown as below:
\arg OB_BB_DISABLE: boot from bank0
@@ -702,18 +757,18 @@ void ob_boot_mode_config(uint32_t boot_mode)
}
/*!
- \brief get the FMC user option byte
+ \brief get the FMC user option byte
\param[in] none
\param[out] none
\retval the FMC user option byte values: ob_fwdgt(Bit0), ob_deepsleep(Bit1), ob_stdby(Bit2)
*/
uint8_t ob_user_get(void)
{
- return (uint8_t)((uint8_t)(FMC_OBCTL0 >> 5) & (uint8_t)0x07);
+ return (uint8_t)((uint8_t)(FMC_OBCTL0 >> 5U) & 0x07U);
}
/*!
- \brief get the FMC option byte write protection
+ \brief get the FMC option byte write protection
\param[in] none
\param[out] none
\retval the FMC write protection option byte value
@@ -721,11 +776,11 @@ uint8_t ob_user_get(void)
uint16_t ob_write_protection0_get(void)
{
/* return the FMC write protection option byte value */
- return (uint16_t)(((uint16_t)(FMC_OBCTL0 >> 16)) & (uint16_t)0x0FFF);
+ return (uint16_t)(((uint16_t)(FMC_OBCTL0 >> 16U)) & 0x0FFFU);
}
/*!
- \brief get the FMC option byte write protection
+ \brief get the FMC option byte write protection
\param[in] none
\param[out] none
\retval the FMC write protection option byte value
@@ -733,11 +788,11 @@ uint16_t ob_write_protection0_get(void)
uint16_t ob_write_protection1_get(void)
{
/* return the the FMC write protection option byte value */
- return (uint16_t)(((uint16_t)(FMC_OBCTL1 >> 16)) & (uint16_t)0x0FFF);
+ return (uint16_t)(((uint16_t)(FMC_OBCTL1 >> 16U)) & 0x0FFFU);
}
/*!
- \brief get the FMC D-bus read protection protection
+ \brief get the FMC erase/program protection and D-bus read protection option bytes value
\param[in] none
\param[out] none
\retval the FMC erase/program protection and D-bus read protection option bytes value
@@ -745,11 +800,15 @@ uint16_t ob_write_protection1_get(void)
uint16_t ob_drp0_get(void)
{
/* return the FMC erase/program protection and D-bus read protection option bytes value */
- return (uint16_t)(((uint16_t)(FMC_OBCTL0 >> 16)) & (uint16_t)0x0FFF);
+ if(FMC_OBCTL0 & FMC_OBCTL0_DRP) {
+ return (uint16_t)(((uint16_t)(FMC_OBCTL0 >> 16U)) & 0x0FFFU);
+ } else {
+ return 0xF000U;
+ }
}
/*!
- \brief get the FMC D-bus read protection protection
+ \brief get the FMC erase/program protection and D-bus read protection option bytes value
\param[in] none
\param[out] none
\retval the FMC erase/program protection and D-bus read protection option bytes value
@@ -757,11 +816,15 @@ uint16_t ob_drp0_get(void)
uint16_t ob_drp1_get(void)
{
/* return the FMC erase/program protection and D-bus read protection option bytes value */
- return (uint16_t)(((uint16_t)(FMC_OBCTL1 >> 16)) & (uint16_t)0x0FFF);
+ if(FMC_OBCTL0 & FMC_OBCTL0_DRP) {
+ return (uint16_t)(((uint16_t)(FMC_OBCTL1 >> 16U)) & 0x0FFFU);
+ } else {
+ return 0xF000U;
+ }
}
/*!
- \brief get the FMC option byte security protection
+ \brief get option byte security protection code value
\param[in] none
\param[out] none
\retval FlagStatus: SET or RESET
@@ -770,16 +833,16 @@ FlagStatus ob_spc_get(void)
{
FlagStatus spc_state = RESET;
- if (((uint8_t)(FMC_OBCTL0 >> 8)) != (uint8_t)FMC_NSPC){
+ if(((uint8_t)(FMC_OBCTL0 >> 8U)) != FMC_NSPC) {
spc_state = SET;
- }else{
+ } else {
spc_state = RESET;
}
return spc_state;
}
/*!
- \brief get the FMC option byte BOR threshold value
+ \brief get the FMC option byte BOR threshold value
\param[in] none
\param[out] none
\retval the FMC BOR threshold value:OB_BOR_TH_OFF,OB_BOR_TH_VALUE1,OB_BOR_TH_VALUE2,OB_BOR_TH_VALUE3
@@ -787,11 +850,53 @@ FlagStatus ob_spc_get(void)
uint8_t ob_user_bor_threshold_get(void)
{
/* return the FMC BOR threshold value */
- return (uint8_t)((uint8_t)FMC_OBCTL0 & (uint8_t)0x0C);
+ return (uint8_t)((uint8_t)FMC_OBCTL0 & 0x0CU);
+}
+
+/*!
+ \brief get flag set or reset
+ \param[in] fmc_flag: check FMC flag
+ only one parameter can be selected which is shown as below:
+ \arg FMC_FLAG_BUSY: FMC busy flag bit
+ \arg FMC_FLAG_RDDERR: FMC read D-bus protection error flag bit
+ \arg FMC_FLAG_PGSERR: FMC program sequence error flag bit
+ \arg FMC_FLAG_PGMERR: FMC program size not match error flag bit
+ \arg FMC_FLAG_WPERR: FMC Erase/Program protection error flag bit
+ \arg FMC_FLAG_OPERR: FMC operation error flag bit
+ \arg FMC_FLAG_END: FMC end of operation flag bit
+ \param[out] none
+ \retval FlagStatus: SET or RESET
+*/
+FlagStatus fmc_flag_get(uint32_t fmc_flag)
+{
+ if(FMC_STAT & fmc_flag) {
+ return SET;
+ }
+ /* return the state of corresponding FMC flag */
+ return RESET;
+}
+
+/*!
+ \brief clear the FMC pending flag
+ \param[in] FMC_flag: clear FMC flag
+ only one parameter can be selected which is shown as below:
+ \arg FMC_FLAG_RDDERR: FMC read D-bus protection error flag bit
+ \arg FMC_FLAG_PGSERR: FMC program sequence error flag bit
+ \arg FMC_FLAG_PGMERR: FMC program size not match error flag bit
+ \arg FMC_FLAG_WPERR: FMC erase/program protection error flag bit
+ \arg FMC_FLAG_OPERR: FMC operation error flag bit
+ \arg FMC_FLAG_END: FMC end of operation flag bit
+ \param[out] none
+ \retval none
+*/
+void fmc_flag_clear(uint32_t fmc_flag)
+{
+ /* clear the flags */
+ FMC_STAT = fmc_flag;
}
/*!
- \brief enable FMC interrupt
+ \brief enable FMC interrupt
\param[in] fmc_int: the FMC interrupt source
only one parameter can be selected which is shown as below:
\arg FMC_INT_END: enable FMC end of program interrupt
@@ -805,7 +910,7 @@ void fmc_interrupt_enable(uint32_t fmc_int)
}
/*!
- \brief disable FMC interrupt
+ \brief disable FMC interrupt
\param[in] fmc_int: the FMC interrupt source
only one parameter can be selected which is shown as below:
\arg FMC_INT_END: disable FMC end of program interrupt
@@ -819,49 +924,60 @@ void fmc_interrupt_disable(uint32_t fmc_int)
}
/*!
- \brief get flag set or reset
- \param[in] fmc_flag: check FMC flag
+ \brief get FMC interrupt flag set or reset
+ \param[in] fmc_int_flag: FMC interrupt flag
only one parameter can be selected which is shown as below:
- \arg FMC_FLAG_BUSY: FMC busy flag bit
- \arg FMC_FLAG_RDDERR: FMC read D-bus protection error flag bit
- \arg FMC_FLAG_PGSERR: FMC program sequence error flag bit
- \arg FMC_FLAG_PGMERR: FMC program size not match error flag bit
- \arg FMC_FLAG_WPERR: FMC Erase/Program protection error flag bit
- \arg FMC_FLAG_OPERR: FMC operation error flag bit
- \arg FMC_FLAG_END: FMC end of operation flag bit
+ \arg FMC_INT_FLAG_RDDERR: FMC read D-bus protection error interrupt flag
+ \arg FMC_INT_FLAG_PGSERR: FMC program sequence error interrupt flag
+ \arg FMC_INT_FLAG_PGMERR: FMC program size not match error interrupt flag
+ \arg FMC_INT_FLAG_WPERR: FMC Erase/Program protection error interrupt flag
+ \arg FMC_INT_FLAG_OPERR: FMC operation error interrupt flag
+ \arg FMC_INT_FLAG_END: FMC end of operation interrupt flag
\param[out] none
\retval FlagStatus: SET or RESET
*/
-FlagStatus fmc_flag_get(uint32_t fmc_flag)
+FlagStatus fmc_interrupt_flag_get(uint32_t fmc_int_flag)
{
- if(FMC_STAT & fmc_flag){
- return SET;
+ if(FMC_FLAG_END == fmc_int_flag) {
+ /* end of operation interrupt flag */
+ if(FMC_CTL & FMC_CTL_ENDIE) {
+ if(FMC_STAT & fmc_int_flag) {
+ return SET;
+ }
+ }
+ } else {
+ /* error interrupt flags */
+ if(FMC_CTL & FMC_CTL_ERRIE) {
+ if(FMC_STAT & fmc_int_flag) {
+ return SET;
+ }
+ }
}
- /* return the state of corresponding FMC flag */
+
return RESET;
}
/*!
- \brief clear the FMC pending flag
- \param[in] FMC_flag: clear FMC flag
+ \brief clear the FMC interrupt flag
+ \param[in] fmc_int_flag: FMC interrupt flag
only one parameter can be selected which is shown as below:
- \arg FMC_FLAG_RDDERR: FMC read D-bus protection error flag bit
- \arg FMC_FLAG_PGSERR: FMC program sequence error flag bit
- \arg FMC_FLAG_PGMERR: FMC program size not match error flag bit
- \arg FMC_FLAG_WPERR: FMC erase/program protection error flag bit
- \arg FMC_FLAG_OPERR: FMC operation error flag bit
- \arg FMC_FLAG_END: FMC end of operation flag bit
+ \arg FMC_INT_FLAG_RDDERR: FMC read D-bus protection error interrupt flag
+ \arg FMC_INT_FLAG_PGSERR: FMC program sequence error interrupt flag
+ \arg FMC_INT_FLAG_PGMERR: FMC program size not match error interrupt flag
+ \arg FMC_INT_FLAG_WPERR: FMC Erase/Program protection error interrupt flag
+ \arg FMC_INT_FLAG_OPERR: FMC operation error interrupt flag
+ \arg FMC_INT_FLAG_END: FMC end of operation interrupt flag
\param[out] none
\retval none
*/
-void fmc_flag_clear(uint32_t fmc_flag)
+void fmc_interrupt_flag_clear(uint32_t fmc_int_flag)
{
- /* clear the flags */
- FMC_STAT = fmc_flag;
+ /* clear the interrupt flag */
+ FMC_STAT = fmc_int_flag;
}
/*!
- \brief get the FMC state
+ \brief get the FMC state
\param[in] none
\param[out] none
\retval state of FMC
@@ -872,39 +988,34 @@ void fmc_flag_clear(uint32_t fmc_flag)
\arg FMC_PGMERR: program size not match error
\arg FMC_WPERR: erase/program protection error
\arg FMC_OPERR: operation error
- \arg FMC_PGERR: program error
*/
fmc_state_enum fmc_state_get(void)
{
fmc_state_enum fmc_state = FMC_READY;
+ uint32_t temp_val = FMC_STAT;
- if((FMC_STAT & FMC_FLAG_BUSY) == FMC_FLAG_BUSY){
+ if(RESET != (temp_val & FMC_FLAG_BUSY)) {
fmc_state = FMC_BUSY;
- }else{
- if((FMC_STAT & FMC_FLAG_WPERR) != (uint32_t)0x00){
- fmc_state = FMC_WPERR;
- }else{
- if((FMC_STAT & FMC_FLAG_RDDERR) != (uint32_t)0x00){
- fmc_state = FMC_RDDERR;
- }else{
- if((FMC_STAT & (uint32_t)0xEF) != (uint32_t)0x00){
- fmc_state = FMC_PGERR;
- }else{
- if((FMC_STAT & FMC_FLAG_OPERR) != (uint32_t)0x00){
- fmc_state = FMC_OPERR;
- }else{
- fmc_state = FMC_READY;
- }
- }
- }
- }
+ } else if(RESET != (temp_val & FMC_FLAG_RDDERR)) {
+ fmc_state = FMC_RDDERR;
+ } else if(RESET != (temp_val & FMC_FLAG_PGSERR)) {
+ fmc_state = FMC_PGSERR;
+ } else if(RESET != (temp_val & FMC_FLAG_PGMERR)) {
+ fmc_state = FMC_PGMERR;
+ } else if(RESET != (temp_val & FMC_FLAG_WPERR)) {
+ fmc_state = FMC_WPERR;
+ } else if(RESET != (temp_val & FMC_FLAG_OPERR)) {
+ fmc_state = FMC_OPERR;
+ } else {
+ fmc_state = FMC_READY;
}
+
/* return the FMC state */
return fmc_state;
}
/*!
- \brief check whether FMC is ready or not
+ \brief check whether FMC is ready or not
\param[in] none
\param[out] none
\retval state of FMC
@@ -915,17 +1026,22 @@ fmc_state_enum fmc_state_get(void)
\arg FMC_PGMERR: program size not match error
\arg FMC_WPERR: erase/program protection error
\arg FMC_OPERR: operation error
- \arg FMC_PGERR: program error
+ \arg FMC_TOERR: timeout error
*/
-fmc_state_enum fmc_ready_wait(void)
+fmc_state_enum fmc_ready_wait(uint32_t timeout)
{
fmc_state_enum fmc_state = FMC_BUSY;
/* wait for FMC ready */
- do{
+ do {
/* get FMC state */
fmc_state = fmc_state_get();
- }while(FMC_BUSY == fmc_state);
+ timeout--;
+ } while((FMC_BUSY == fmc_state) && (0U != timeout));
+
+ if(0U == timeout) {
+ fmc_state = FMC_TOERR;
+ }
/* return the FMC state */
return fmc_state;
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_fwdgt.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_fwdgt.c
index 04e2c5b99d..4240327bd8 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_fwdgt.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_fwdgt.c
@@ -5,44 +5,40 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#include "gd32f4xx_fwdgt.h"
-/* write value to FWDGT_CTL_CMD bit field */
-#define CTL_CMD(regval) (BITS(0,15) & ((uint32_t)(regval) << 0))
-/* write value to FWDGT_RLD_RLD bit field */
-#define RLD_RLD(regval) (BITS(0,11) & ((uint32_t)(regval) << 0))
-
/*!
- \brief enable write access to FWDGT_PSC and FWDGT_RLD
+ \brief enable write access to FWDGT_PSC and FWDGT_RLD
\param[in] none
\param[out] none
\retval none
@@ -53,7 +49,7 @@ void fwdgt_write_enable(void)
}
/*!
- \brief disable write access to FWDGT_PSC and FWDGT_RLD
+ \brief disable write access to FWDGT_PSC and FWDGT_RLD
\param[in] none
\param[out] none
\retval none
@@ -64,7 +60,7 @@ void fwdgt_write_disable(void)
}
/*!
- \brief start the free watchdog timer counter
+ \brief start the free watchdog timer counter
\param[in] none
\param[out] none
\retval none
@@ -75,7 +71,72 @@ void fwdgt_enable(void)
}
/*!
- \brief reload the counter of FWDGT
+ \brief configure the free watchdog timer counter prescaler value
+ \param[in] prescaler_value: specify prescaler value
+ only one parameter can be selected which is shown as below:
+ \arg FWDGT_PSC_DIV4: FWDGT prescaler set to 4
+ \arg FWDGT_PSC_DIV8: FWDGT prescaler set to 8
+ \arg FWDGT_PSC_DIV16: FWDGT prescaler set to 16
+ \arg FWDGT_PSC_DIV32: FWDGT prescaler set to 32
+ \arg FWDGT_PSC_DIV64: FWDGT prescaler set to 64
+ \arg FWDGT_PSC_DIV128: FWDGT prescaler set to 128
+ \arg FWDGT_PSC_DIV256: FWDGT prescaler set to 256
+ \param[out] none
+ \retval ErrStatus: ERROR or SUCCESS
+*/
+ErrStatus fwdgt_prescaler_value_config(uint16_t prescaler_value)
+{
+ uint32_t timeout = FWDGT_PSC_TIMEOUT;
+ uint32_t flag_status = RESET;
+
+ /* enable write access to FWDGT_PSC */
+ FWDGT_CTL = FWDGT_WRITEACCESS_ENABLE;
+
+ /* wait until the PUD flag to be reset */
+ do{
+ flag_status = FWDGT_STAT & FWDGT_STAT_PUD;
+ }while((--timeout > 0U) && ((uint32_t)RESET != flag_status));
+
+ if ((uint32_t)RESET != flag_status){
+ return ERROR;
+ }
+
+ /* configure FWDGT */
+ FWDGT_PSC = (uint32_t)prescaler_value;
+
+ return SUCCESS;
+}
+
+/*!
+ \brief configure the free watchdog timer counter reload value
+ \param[in] reload_value: specify reload value(0x0000 - 0x0FFF)
+ \param[out] none
+ \retval ErrStatus: ERROR or SUCCESS
+*/
+ErrStatus fwdgt_reload_value_config(uint16_t reload_value)
+{
+ uint32_t timeout = FWDGT_RLD_TIMEOUT;
+ uint32_t flag_status = RESET;
+
+ /* enable write access to FWDGT_RLD */
+ FWDGT_CTL = FWDGT_WRITEACCESS_ENABLE;
+
+ /* wait until the RUD flag to be reset */
+ do{
+ flag_status = FWDGT_STAT & FWDGT_STAT_RUD;
+ }while((--timeout > 0U) && ((uint32_t)RESET != flag_status));
+
+ if ((uint32_t)RESET != flag_status){
+ return ERROR;
+ }
+
+ FWDGT_RLD = RLD_RLD(reload_value);
+
+ return SUCCESS;
+}
+
+/*!
+ \brief reload the counter of FWDGT
\param[in] none
\param[out] none
\retval none
@@ -86,7 +147,7 @@ void fwdgt_counter_reload(void)
}
/*!
- \brief configure counter reload value, and prescaler divider value
+ \brief configure counter reload value, and prescaler divider value
\param[in] reload_value: specify reload value(0x0000 - 0x0FFF)
\param[in] prescaler_div: FWDGT prescaler value
only one parameter can be selected which is shown as below:
@@ -104,15 +165,15 @@ ErrStatus fwdgt_config(uint16_t reload_value, uint8_t prescaler_div)
{
uint32_t timeout = FWDGT_PSC_TIMEOUT;
uint32_t flag_status = RESET;
-
+
/* enable write access to FWDGT_PSC,and FWDGT_RLD */
FWDGT_CTL = FWDGT_WRITEACCESS_ENABLE;
-
+
/* wait until the PUD flag to be reset */
do{
flag_status = FWDGT_STAT & FWDGT_STAT_PUD;
}while((--timeout > 0U) && ((uint32_t)RESET != flag_status));
-
+
if ((uint32_t)RESET != flag_status){
return ERROR;
}
@@ -125,13 +186,13 @@ ErrStatus fwdgt_config(uint16_t reload_value, uint8_t prescaler_div)
do{
flag_status = FWDGT_STAT & FWDGT_STAT_RUD;
}while((--timeout > 0U) && ((uint32_t)RESET != flag_status));
-
+
if ((uint32_t)RESET != flag_status){
return ERROR;
}
-
+
FWDGT_RLD = RLD_RLD(reload_value);
-
+
/* reload the counter */
FWDGT_CTL = FWDGT_KEY_RELOAD;
@@ -139,8 +200,8 @@ ErrStatus fwdgt_config(uint16_t reload_value, uint8_t prescaler_div)
}
/*!
- \brief get flag state of FWDGT
- \param[in] flag: flag to get
+ \brief get flag state of FWDGT
+ \param[in] flag: flag to get
only one parameter can be selected which is shown as below:
\arg FWDGT_STAT_PUD: a write operation to FWDGT_PSC register is on going
\arg FWDGT_STAT_RUD: a write operation to FWDGT_RLD register is on going
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_gpio.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_gpio.c
index d3693abb17..f9dbc4d716 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_gpio.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_gpio.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -46,7 +47,7 @@ OF SUCH DAMAGE.
*/
void gpio_deinit(uint32_t gpio_periph)
{
- switch(gpio_periph){
+ switch(gpio_periph) {
case GPIOA:
/* reset GPIOA */
rcu_periph_reset_enable(RCU_GPIOARST);
@@ -125,8 +126,8 @@ void gpio_mode_set(uint32_t gpio_periph, uint32_t mode, uint32_t pull_up_down, u
ctl = GPIO_CTL(gpio_periph);
pupd = GPIO_PUD(gpio_periph);
- for(i = 0U;i < 16U;i++){
- if((1U << i) & pin){
+ for(i = 0U; i < 16U; i++) {
+ if((1U << i) & pin) {
/* clear the specified pin mode bits */
ctl &= ~GPIO_MODE_MASK(i);
/* set the specified pin mode bits */
@@ -155,7 +156,7 @@ void gpio_mode_set(uint32_t gpio_periph, uint32_t mode, uint32_t pull_up_down, u
\arg GPIO_OSPEED_2MHZ: output max speed 2MHz
\arg GPIO_OSPEED_25MHZ: output max speed 25MHz
\arg GPIO_OSPEED_50MHZ: output max speed 50MHz
- \arg GPIO_OSPEED_200MHZ: output max speed 200MHz
+ \arg GPIO_OSPEED_MAX: output max speed more than 50MHz
\param[in] pin: GPIO pin
one or more parameters can be selected which are shown as below:
\arg GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
@@ -167,28 +168,28 @@ void gpio_output_options_set(uint32_t gpio_periph, uint8_t otype, uint32_t speed
uint16_t i;
uint32_t ospeedr;
- if(GPIO_OTYPE_OD == otype){
+ if(GPIO_OTYPE_OD == otype) {
GPIO_OMODE(gpio_periph) |= (uint32_t)pin;
- }else{
+ } else {
GPIO_OMODE(gpio_periph) &= (uint32_t)(~pin);
}
/* get the specified pin output speed bits value */
ospeedr = GPIO_OSPD(gpio_periph);
- for(i = 0U;i < 16U;i++){
- if((1U << i) & pin){
+ for(i = 0U; i < 16U; i++) {
+ if((1U << i) & pin) {
/* clear the specified pin output speed bits */
ospeedr &= ~GPIO_OSPEED_MASK(i);
/* set the specified pin output speed bits */
- ospeedr |= GPIO_OSPEED_SET(i,speed);
+ ospeedr |= GPIO_OSPEED_SET(i, speed);
}
}
GPIO_OSPD(gpio_periph) = ospeedr;
}
/*!
- \brief set GPIO pin bit
+ \brief set GPIO pin bit
\param[in] gpio_periph: GPIO port
only one parameter can be selected which is shown as below:
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
@@ -235,9 +236,9 @@ void gpio_bit_reset(uint32_t gpio_periph, uint32_t pin)
*/
void gpio_bit_write(uint32_t gpio_periph, uint32_t pin, bit_status bit_value)
{
- if(RESET != bit_value){
+ if(RESET != bit_value) {
GPIO_BOP(gpio_periph) = (uint32_t)pin;
- }else{
+ } else {
GPIO_BC(gpio_periph) = (uint32_t)pin;
}
}
@@ -269,9 +270,9 @@ void gpio_port_write(uint32_t gpio_periph, uint16_t data)
*/
FlagStatus gpio_input_bit_get(uint32_t gpio_periph, uint32_t pin)
{
- if((uint32_t)RESET != (GPIO_ISTAT(gpio_periph)&(pin))){
+ if((uint32_t)RESET != (GPIO_ISTAT(gpio_periph) & (pin))) {
return SET;
- }else{
+ } else {
return RESET;
}
}
@@ -302,15 +303,15 @@ uint16_t gpio_input_port_get(uint32_t gpio_periph)
*/
FlagStatus gpio_output_bit_get(uint32_t gpio_periph, uint32_t pin)
{
- if((uint32_t)RESET !=(GPIO_OCTL(gpio_periph)&(pin))){
+ if((uint32_t)RESET != (GPIO_OCTL(gpio_periph) & (pin))) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief get GPIO all pins output status
+ \brief get GPIO port output status
\param[in] gpio_periph: GPIO port
only one parameter can be selected which is shown as below:
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
@@ -334,10 +335,10 @@ uint16_t gpio_output_port_get(uint32_t gpio_periph)
\arg GPIO_AF_3: TIMER7, TIMER8, TIMER9, TIMER10
\arg GPIO_AF_4: I2C0, I2C1, I2C2
\arg GPIO_AF_5: SPI0, SPI1, SPI2, SPI3, SPI4, SPI5
- \arg GPIO_AF_6: SPI1, SPI2, SAI0
- \arg GPIO_AF_7: USART0, USART1, USART2
+ \arg GPIO_AF_6: SPI2, SPI3, SPI4
+ \arg GPIO_AF_7: USART0, USART1, USART2, SPI1, SPI2
\arg GPIO_AF_8: UART3, UART4, USART5, UART6, UART7
- \arg GPIO_AF_9: CAN0, CAN1, TLI, TIMER11, TIMER12, TIMER13
+ \arg GPIO_AF_9: CAN0, CAN1, TLI, TIMER11, TIMER12, TIMER13, I2C1, I2C2, CTC
\arg GPIO_AF_10: USB_FS, USB_HS
\arg GPIO_AF_11: ENET
\arg GPIO_AF_12: EXMC, SDIO, USB_HS
@@ -358,19 +359,19 @@ void gpio_af_set(uint32_t gpio_periph, uint32_t alt_func_num, uint32_t pin)
afrl = GPIO_AFSEL0(gpio_periph);
afrh = GPIO_AFSEL1(gpio_periph);
- for(i = 0U;i < 8U;i++){
- if((1U << i) & pin){
+ for(i = 0U; i < 8U; i++) {
+ if((1U << i) & pin) {
/* clear the specified pin alternate function bits */
afrl &= ~GPIO_AFR_MASK(i);
- afrl |= GPIO_AFR_SET(i,alt_func_num);
+ afrl |= GPIO_AFR_SET(i, alt_func_num);
}
}
- for(i = 8U;i < 16U;i++){
- if((1U << i) & pin){
+ for(i = 8U; i < 16U; i++) {
+ if((1U << i) & pin) {
/* clear the specified pin alternate function bits */
afrh &= ~GPIO_AFR_MASK(i - 8U);
- afrh |= GPIO_AFR_SET(i - 8U,alt_func_num);
+ afrh |= GPIO_AFR_SET(i - 8U, alt_func_num);
}
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_i2c.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_i2c.c
index c3ac50c178..97988e8c3d 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_i2c.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_i2c.c
@@ -6,10 +6,11 @@
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2019-04-16, V2.0.2, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -38,14 +39,14 @@ OF SUCH DAMAGE.
#include "gd32f4xx_i2c.h"
/* I2C register bit mask */
-#define I2CCLK_MAX ((uint32_t)0x00000032U) /*!< i2cclk maximum value */
+#define I2CCLK_MAX ((uint32_t)0x0000003CU) /*!< i2cclk maximum value */
#define I2CCLK_MIN ((uint32_t)0x00000002U) /*!< i2cclk minimum value */
#define I2C_FLAG_MASK ((uint32_t)0x0000FFFFU) /*!< i2c flag mask */
#define I2C_ADDRESS_MASK ((uint32_t)0x000003FFU) /*!< i2c address mask */
#define I2C_ADDRESS2_MASK ((uint32_t)0x000000FEU) /*!< the second i2c address mask */
/* I2C register bit offset */
-#define STAT1_PECV_OFFSET ((uint32_t)8U) /* bit offset of PECV in I2C_STAT1 */
+#define STAT1_PECV_OFFSET ((uint32_t)0x00000008U) /* bit offset of PECV in I2C_STAT1 */
/*!
\brief reset I2C
@@ -55,7 +56,7 @@ OF SUCH DAMAGE.
*/
void i2c_deinit(uint32_t i2c_periph)
{
- switch(i2c_periph){
+ switch(i2c_periph) {
case I2C0:
/* reset I2C0 */
rcu_periph_reset_enable(RCU_I2C0RST);
@@ -82,8 +83,8 @@ void i2c_deinit(uint32_t i2c_periph)
\param[in] clkspeed: I2C clock speed, supports standard mode (up to 100 kHz), fast mode (up to 400 kHz)
\param[in] dutycyc: duty cycle in fast mode
only one parameter can be selected which is shown as below:
- \arg I2C_DTCY_2: T_low/T_high=2
- \arg I2C_DTCY_16_9: T_low/T_high=16/9
+ \arg I2C_DTCY_2: T_low/T_high = 2 in fast mode
+ \arg I2C_DTCY_16_9: T_low/T_high = 16/9 in fast mode
\param[out] none
\retval none
*/
@@ -94,8 +95,8 @@ void i2c_clock_config(uint32_t i2c_periph, uint32_t clkspeed, uint32_t dutycyc)
pclk1 = rcu_clock_freq_get(CK_APB1);
/* I2C peripheral clock frequency */
- freq = (uint32_t)(pclk1/1000000U);
- if(freq >= I2CCLK_MAX){
+ freq = (uint32_t)(pclk1 / 1000000U);
+ if(freq >= I2CCLK_MAX) {
freq = I2CCLK_MAX;
}
temp = I2C_CTL1(i2c_periph);
@@ -104,41 +105,43 @@ void i2c_clock_config(uint32_t i2c_periph, uint32_t clkspeed, uint32_t dutycyc)
I2C_CTL1(i2c_periph) = temp;
- if(100000U >= clkspeed){
+ if(100000U >= clkspeed) {
/* the maximum SCL rise time is 1000ns in standard mode */
- risetime = (uint32_t)((pclk1/1000000U)+1U);
- if(risetime >= I2CCLK_MAX){
+ risetime = (uint32_t)((pclk1 / 1000000U) + 1U);
+ if(risetime >= I2CCLK_MAX) {
I2C_RT(i2c_periph) = I2CCLK_MAX;
- }else{
+ } else if(risetime <= I2CCLK_MIN) {
+ I2C_RT(i2c_periph) = I2CCLK_MIN;
+ } else {
I2C_RT(i2c_periph) = risetime;
}
- clkc = (uint32_t)(pclk1/(clkspeed*2U));
- if(clkc < 0x04U){
+ clkc = (uint32_t)(pclk1 / (clkspeed * 2U));
+ if(clkc < 0x04U) {
/* the CLKC in standard mode minmum value is 4 */
clkc = 0x04U;
}
I2C_CKCFG(i2c_periph) |= (I2C_CKCFG_CLKC & clkc);
- }else if(400000U >= clkspeed){
+ } else if(400000U >= clkspeed) {
/* the maximum SCL rise time is 300ns in fast mode */
- I2C_RT(i2c_periph) = (uint32_t)(((freq*(uint32_t)300U)/(uint32_t)1000U)+(uint32_t)1U);
- if(I2C_DTCY_2 == dutycyc){
+ I2C_RT(i2c_periph) = (uint32_t)(((freq * (uint32_t)300U) / (uint32_t)1000U) + (uint32_t)1U);
+ if(I2C_DTCY_2 == dutycyc) {
/* I2C duty cycle is 2 */
- clkc = (uint32_t)(pclk1/(clkspeed*3U));
+ clkc = (uint32_t)(pclk1 / (clkspeed * 3U));
I2C_CKCFG(i2c_periph) &= ~I2C_CKCFG_DTCY;
- }else{
+ } else {
/* I2C duty cycle is 16/9 */
- clkc = (uint32_t)(pclk1/(clkspeed*25U));
+ clkc = (uint32_t)(pclk1 / (clkspeed * 25U));
I2C_CKCFG(i2c_periph) |= I2C_CKCFG_DTCY;
}
- if(0U == (clkc & I2C_CKCFG_CLKC)){
+ if(0U == (clkc & I2C_CKCFG_CLKC)) {
/* the CLKC in fast mode minmum value is 1 */
clkc |= 0x0001U;
}
I2C_CKCFG(i2c_periph) |= I2C_CKCFG_FAST;
I2C_CKCFG(i2c_periph) |= clkc;
- }else{
+ } else {
}
}
@@ -151,8 +154,8 @@ void i2c_clock_config(uint32_t i2c_periph, uint32_t clkspeed, uint32_t dutycyc)
\arg I2C_SMBUSMODE_ENABLE: SMBus mode
\param[in] addformat: 7bits or 10bits
only one parameter can be selected which is shown as below:
- \arg I2C_ADDFORMAT_7BITS: 7bits
- \arg I2C_ADDFORMAT_10BITS: 10bits
+ \arg I2C_ADDFORMAT_7BITS: address format is 7 bits
+ \arg I2C_ADDFORMAT_10BITS: address format is 10 bits
\param[in] addr: I2C address
\param[out] none
\retval none
@@ -172,20 +175,20 @@ void i2c_mode_addr_config(uint32_t i2c_periph, uint32_t mode, uint32_t addformat
}
/*!
- \brief SMBus type selection
+ \brief select SMBus type
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[in] type:
only one parameter can be selected which is shown as below:
- \arg I2C_SMBUS_DEVICE: device
- \arg I2C_SMBUS_HOST: host
+ \arg I2C_SMBUS_DEVICE: SMBus mode device type
+ \arg I2C_SMBUS_HOST: SMBus mode host type
\param[out] none
\retval none
*/
void i2c_smbus_type_config(uint32_t i2c_periph, uint32_t type)
{
- if(I2C_SMBUS_HOST == type){
+ if(I2C_SMBUS_HOST == type) {
I2C_CTL0(i2c_periph) |= I2C_CTL0_SMBSEL;
- }else{
+ } else {
I2C_CTL0(i2c_periph) &= ~(I2C_CTL0_SMBSEL);
}
}
@@ -202,11 +205,12 @@ void i2c_smbus_type_config(uint32_t i2c_periph, uint32_t type)
*/
void i2c_ack_config(uint32_t i2c_periph, uint32_t ack)
{
- if(I2C_ACK_ENABLE == ack){
- I2C_CTL0(i2c_periph) |= I2C_CTL0_ACKEN;
- }else{
- I2C_CTL0(i2c_periph) &= ~(I2C_CTL0_ACKEN);
- }
+ uint32_t ctl = 0U;
+
+ ctl = I2C_CTL0(i2c_periph);
+ ctl &= ~(I2C_CTL0_ACKEN);
+ ctl |= ack;
+ I2C_CTL0(i2c_periph) = ctl;
}
/*!
@@ -214,19 +218,19 @@ void i2c_ack_config(uint32_t i2c_periph, uint32_t ack)
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[in] pos:
only one parameter can be selected which is shown as below:
- \arg I2C_ACKPOS_CURRENT: whether to send ACK or not for the current
- \arg I2C_ACKPOS_NEXT: whether to send ACK or not for the next byte
+ \arg I2C_ACKPOS_CURRENT: ACKEN bit decides whether or not to send ACK or not for the current byte
+ \arg I2C_ACKPOS_NEXT: ACKEN bit decides whether or not to send ACK for the next byte
\param[out] none
\retval none
*/
void i2c_ackpos_config(uint32_t i2c_periph, uint32_t pos)
{
+ uint32_t ctl = 0U;
/* configure I2C POAP position */
- if(I2C_ACKPOS_NEXT == pos){
- I2C_CTL0(i2c_periph) |= I2C_CTL0_POAP;
- }else{
- I2C_CTL0(i2c_periph) &= ~(I2C_CTL0_POAP);
- }
+ ctl = I2C_CTL0(i2c_periph);
+ ctl &= ~(I2C_CTL0_POAP);
+ ctl |= pos;
+ I2C_CTL0(i2c_periph) = ctl;
}
/*!
@@ -236,16 +240,16 @@ void i2c_ackpos_config(uint32_t i2c_periph, uint32_t pos)
\param[in] trandirection: transmitter or receiver
only one parameter can be selected which is shown as below:
\arg I2C_TRANSMITTER: transmitter
- \arg I2C_RECEIVER: receiver
+ \arg I2C_RECEIVER: receiver
\param[out] none
\retval none
*/
void i2c_master_addressing(uint32_t i2c_periph, uint32_t addr, uint32_t trandirection)
{
/* master is a transmitter or a receiver */
- if(I2C_TRANSMITTER == trandirection){
+ if(I2C_TRANSMITTER == trandirection) {
addr = addr & I2C_TRANSMITTER;
- }else{
+ } else {
addr = addr | I2C_RECEIVER;
}
/* send slave address */
@@ -345,16 +349,16 @@ uint8_t i2c_data_receive(uint32_t i2c_periph)
}
/*!
- \brief enable I2C DMA mode
+ \brief configure I2C DMA mode
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[in] dmastate:
only one parameter can be selected which is shown as below:
- \arg I2C_DMA_ON: DMA mode enable
- \arg I2C_DMA_OFF: DMA mode disable
+ \arg I2C_DMA_ON: enable DMA mode
+ \arg I2C_DMA_OFF: disable DMA mode
\param[out] none
\retval none
*/
-void i2c_dma_enable(uint32_t i2c_periph, uint32_t dmastate)
+void i2c_dma_config(uint32_t i2c_periph, uint32_t dmastate)
{
/* configure I2C DMA function */
uint32_t ctl = 0U;
@@ -391,14 +395,14 @@ void i2c_dma_last_transfer_config(uint32_t i2c_periph, uint32_t dmalast)
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[in] stretchpara:
only one parameter can be selected which is shown as below:
- \arg I2C_SCLSTRETCH_ENABLE: SCL stretching is enabled
- \arg I2C_SCLSTRETCH_DISABLE: SCL stretching is disabled
+ \arg I2C_SCLSTRETCH_ENABLE: enable SCL stretching
+ \arg I2C_SCLSTRETCH_DISABLE: disable SCL stretching
\param[out] none
\retval none
*/
void i2c_stretch_scl_low_config(uint32_t i2c_periph, uint32_t stretchpara)
{
- /* configure I2C SCL strerching enable or disable */
+ /* configure I2C SCL strerching */
uint32_t ctl = 0U;
ctl = I2C_CTL0(i2c_periph);
@@ -429,7 +433,7 @@ void i2c_slave_response_to_gcall_config(uint32_t i2c_periph, uint32_t gcallpara)
}
/*!
- \brief software reset I2C
+ \brief configure software reset of I2C
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[in] sreset:
only one parameter can be selected which is shown as below:
@@ -450,7 +454,7 @@ void i2c_software_reset_config(uint32_t i2c_periph, uint32_t sreset)
}
/*!
- \brief I2C PEC calculation on or off
+ \brief configure I2C PEC calculation
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[in] pecstate:
only one parameter can be selected which is shown as below:
@@ -459,7 +463,7 @@ void i2c_software_reset_config(uint32_t i2c_periph, uint32_t sreset)
\param[out] none
\retval none
*/
-void i2c_pec_enable(uint32_t i2c_periph, uint32_t pecstate)
+void i2c_pec_config(uint32_t i2c_periph, uint32_t pecstate)
{
/* on/off PEC calculation */
uint32_t ctl = 0U;
@@ -471,16 +475,16 @@ void i2c_pec_enable(uint32_t i2c_periph, uint32_t pecstate)
}
/*!
- \brief I2C whether to transfer PEC value
+ \brief configure whether to transfer PEC value
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[in] pecpara:
only one parameter can be selected which is shown as below:
- \arg I2C_PECTRANS_ENABLE: transfer PEC
- \arg I2C_PECTRANS_DISABLE: not transfer PEC
+ \arg I2C_PECTRANS_ENABLE: transfer PEC value
+ \arg I2C_PECTRANS_DISABLE: not transfer PEC value
\param[out] none
\retval none
*/
-void i2c_pec_transfer_enable(uint32_t i2c_periph, uint32_t pecpara)
+void i2c_pec_transfer_config(uint32_t i2c_periph, uint32_t pecpara)
{
/* whether to transfer PEC */
uint32_t ctl = 0U;
@@ -499,11 +503,11 @@ void i2c_pec_transfer_enable(uint32_t i2c_periph, uint32_t pecpara)
*/
uint8_t i2c_pec_value_get(uint32_t i2c_periph)
{
- return (uint8_t)((I2C_STAT1(i2c_periph) & I2C_STAT1_PECV)>>STAT1_PECV_OFFSET);
+ return (uint8_t)((I2C_STAT1(i2c_periph) & I2C_STAT1_PECV) >> STAT1_PECV_OFFSET);
}
/*!
- \brief I2C issue alert through SMBA pin
+ \brief configure I2C alert through SMBA pin
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[in] smbuspara:
only one parameter can be selected which is shown as below:
@@ -512,9 +516,9 @@ uint8_t i2c_pec_value_get(uint32_t i2c_periph)
\param[out] none
\retval none
*/
-void i2c_smbus_issue_alert(uint32_t i2c_periph, uint32_t smbuspara)
+void i2c_smbus_alert_config(uint32_t i2c_periph, uint32_t smbuspara)
{
- /* issue alert through SMBA pin configure*/
+ /* configure smubus alert through SMBA pin */
uint32_t ctl = 0U;
ctl = I2C_CTL0(i2c_periph);
@@ -524,7 +528,7 @@ void i2c_smbus_issue_alert(uint32_t i2c_periph, uint32_t smbuspara)
}
/*!
- \brief enable or disable I2C ARP protocol in SMBus switch
+ \brief configure I2C ARP protocol in SMBus
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[in] arpstate:
only one parameter can be selected which is shown as below:
@@ -533,7 +537,7 @@ void i2c_smbus_issue_alert(uint32_t i2c_periph, uint32_t smbuspara)
\param[out] none
\retval none
*/
-void i2c_smbus_arp_enable(uint32_t i2c_periph, uint32_t arpstate)
+void i2c_smbus_arp_config(uint32_t i2c_periph, uint32_t arpstate)
{
/* enable or disable I2C ARP protocol*/
uint32_t ctl = 0U;
@@ -545,7 +549,7 @@ void i2c_smbus_arp_enable(uint32_t i2c_periph, uint32_t arpstate)
}
/*!
- \brief analog noise filter disable
+ \brief disable analog noise filter
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[out] none
\retval none
@@ -556,7 +560,7 @@ void i2c_analog_noise_filter_disable(uint32_t i2c_periph)
}
/*!
- \brief analog noise filter enable
+ \brief enable analog noise filter
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[out] none
\retval none
@@ -567,13 +571,30 @@ void i2c_analog_noise_filter_enable(uint32_t i2c_periph)
}
/*!
- \brief digital noise filter configuration
+ \brief configure digital noise filter
\param[in] i2c_periph: I2Cx(x=0,1,2)
- \param[in] dfilterpara: refer to enum i2c_digital_filter_enum
+ \param[in] dfilterpara: refer to i2c_digital_filter_enum
+ only one parameter can be selected which is shown as below:
+ \arg I2C_DF_DISABLE: disable digital noise filter
+ \arg I2C_DF_1PCLK: enable digital noise filter and the maximum filtered spiker's length 1 PCLK1
+ \arg I2C_DF_2PCLK: enable digital noise filter and the maximum filtered spiker's length 2 PCLK1
+ \arg I2C_DF_3PCLK: enable digital noise filter and the maximum filtered spiker's length 3 PCLK1
+ \arg I2C_DF_4PCLK: enable digital noise filter and the maximum filtered spiker's length 4 PCLK1
+ \arg I2C_DF_5PCLK: enable digital noise filter and the maximum filtered spiker's length 5 PCLK1
+ \arg I2C_DF_6PCLK: enable digital noise filter and the maximum filtered spiker's length 6 PCLK1
+ \arg I2C_DF_7PCLK: enable digital noise filter and the maximum filtered spiker's length 7 PCLK1
+ \arg I2C_DF_8PCLK: enable digital noise filter and the maximum filtered spiker's length 8 PCLK1
+ \arg I2C_DF_9PCLK: enable digital noise filter and the maximum filtered spiker's length 9 PCLK1
+ \arg I2C_DF_10PCLK: enable digital noise filter and the maximum filtered spiker's length 10 PCLK1
+ \arg I2C_DF_11CLK: enable digital noise filter and the maximum filtered spiker's length 11 PCLK1
+ \arg I2C_DF_12CLK: enable digital noise filter and the maximum filtered spiker's length 12 PCLK1
+ \arg I2C_DF_13PCLK: enable digital noise filter and the maximum filtered spiker's length 13 PCLK1
+ \arg I2C_DF_14PCLK: enable digital noise filter and the maximum filtered spiker's length 14 PCLK1
+ \arg I2C_DF_15PCLK: enable digital noise filter and the maximum filtered spiker's length 15 PCLK1
\param[out] none
\retval none
*/
-void i2c_digital_noise_filter_config(uint32_t i2c_periph,i2c_digital_filter_enum dfilterpara)
+void i2c_digital_noise_filter_config(uint32_t i2c_periph, i2c_digital_filter_enum dfilterpara)
{
I2C_FCTL(i2c_periph) |= dfilterpara;
}
@@ -623,27 +644,27 @@ void i2c_sam_timeout_disable(uint32_t i2c_periph)
}
/*!
- \brief check I2C flag is set or not
+ \brief get I2C flag status
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[in] flag: I2C flags, refer to i2c_flag_enum
only one parameter can be selected which is shown as below:
- \arg I2C_FLAG_SBSEND: start condition send out
+ \arg I2C_FLAG_SBSEND: start condition sent out in master mode
\arg I2C_FLAG_ADDSEND: address is sent in master mode or received and matches in slave mode
\arg I2C_FLAG_BTC: byte transmission finishes
\arg I2C_FLAG_ADD10SEND: header of 10-bit address is sent in master mode
\arg I2C_FLAG_STPDET: stop condition detected in slave mode
- \arg I2C_FLAG_RBNE: I2C_DATA is not Empty during receiving
+ \arg I2C_FLAG_RBNE: I2C_DATA is not empty during receiving
\arg I2C_FLAG_TBE: I2C_DATA is empty during transmitting
\arg I2C_FLAG_BERR: a bus error occurs indication a unexpected start or stop condition on I2C bus
\arg I2C_FLAG_LOSTARB: arbitration lost in master mode
\arg I2C_FLAG_AERR: acknowledge error
- \arg I2C_FLAG_OUERR: overrun or underrun situation occurs in slave mode
+ \arg I2C_FLAG_OUERR: over-run or under-run situation occurs in slave mode
\arg I2C_FLAG_PECERR: PEC error when receiving data
\arg I2C_FLAG_SMBTO: timeout signal in SMBus mode
\arg I2C_FLAG_SMBALT: SMBus alert status
\arg I2C_FLAG_MASTER: a flag indicating whether I2C block is in master or slave mode
\arg I2C_FLAG_I2CBSY: busy flag
- \arg I2C_FLAG_TRS: whether the I2C is a transmitter or a receiver
+ \arg I2C_FLAG_TR: whether the I2C is a transmitter or a receiver
\arg I2C_FLAG_RXGC: general call address (00h) received
\arg I2C_FLAG_DEFSMB: default address of SMBus device
\arg I2C_FLAG_HSTSMB: SMBus host header detected in slave mode
@@ -657,26 +678,26 @@ void i2c_sam_timeout_disable(uint32_t i2c_periph)
*/
FlagStatus i2c_flag_get(uint32_t i2c_periph, i2c_flag_enum flag)
{
- if(RESET != (I2C_REG_VAL(i2c_periph, flag) & BIT(I2C_BIT_POS(flag)))){
+ if(RESET != (I2C_REG_VAL(i2c_periph, flag) & BIT(I2C_BIT_POS(flag)))) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief clear I2C flag
+ \brief clear I2C flag status
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[in] flag: I2C flags, refer to i2c_flag_enum
only one parameter can be selected which is shown as below:
- \arg I2C_FLAG_SMBALT: SMBus Alert status
+ \arg I2C_FLAG_SMBALT: SMBus alert status
\arg I2C_FLAG_SMBTO: timeout signal in SMBus mode
\arg I2C_FLAG_PECERR: PEC error when receiving data
\arg I2C_FLAG_OUERR: over-run or under-run situation occurs in slave mode
\arg I2C_FLAG_AERR: acknowledge error
\arg I2C_FLAG_LOSTARB: arbitration lost in master mode
- \arg I2C_FLAG_BERR: a bus error
- \arg I2C_FLAG_ADDSEND: cleared by reading I2C_STAT0 and reading I2C_STAT1
+ \arg I2C_FLAG_BERR: a bus error occurs indication a unexpected start or stop condition on I2C bus
+ \arg I2C_FLAG_ADDSEND: address is sent in master mode or received and matches in slave mode
\arg I2C_FLAG_TFF: txframe fall flag
\arg I2C_FLAG_TFR: txframe rise flag
\arg I2C_FLAG_RFF: rxframe fall flag
@@ -686,11 +707,11 @@ FlagStatus i2c_flag_get(uint32_t i2c_periph, i2c_flag_enum flag)
*/
void i2c_flag_clear(uint32_t i2c_periph, i2c_flag_enum flag)
{
- if(I2C_FLAG_ADDSEND == flag){
+ if(I2C_FLAG_ADDSEND == flag) {
/* read I2C_STAT0 and then read I2C_STAT1 to clear ADDSEND */
I2C_STAT0(i2c_periph);
I2C_STAT1(i2c_periph);
- }else{
+ } else {
I2C_REG_VAL(i2c_periph, flag) &= ~BIT(I2C_BIT_POS(flag));
}
}
@@ -700,13 +721,13 @@ void i2c_flag_clear(uint32_t i2c_periph, i2c_flag_enum flag)
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[in] interrupt: I2C interrupts, refer to i2c_interrupt_enum
only one parameter can be selected which is shown as below:
- \arg I2C_INT_ERR: error interrupt enable
- \arg I2C_INT_EV: event interrupt enable
- \arg I2C_INT_BUF: buffer interrupt enable
- \arg I2C_INT_TFF: txframe fall interrupt enable
- \arg I2C_INT_TFR: txframe rise interrupt enable
- \arg I2C_INT_RFF: rxframe fall interrupt enable
- \arg I2C_INT_RFR: rxframe rise interrupt enable
+ \arg I2C_INT_ERR: error interrupt
+ \arg I2C_INT_EV: event interrupt
+ \arg I2C_INT_BUF: buffer interrupt
+ \arg I2C_INT_TFF: txframe fall interrupt
+ \arg I2C_INT_TFR: txframe rise interrupt
+ \arg I2C_INT_RFF: rxframe fall interrupt
+ \arg I2C_INT_RFR: rxframe rise interrupt
\param[out] none
\retval none
*/
@@ -718,15 +739,15 @@ void i2c_interrupt_enable(uint32_t i2c_periph, i2c_interrupt_enum interrupt)
/*!
\brief disable I2C interrupt
\param[in] i2c_periph: I2Cx(x=0,1,2)
- \param[in] interrupt: I2C interrupts, refer to i2c_flag_enum
+ \param[in] interrupt: I2C interrupts, refer to i2c_interrupt_enum
only one parameter can be selected which is shown as below:
- \arg I2C_INT_ERR: error interrupt enable
- \arg I2C_INT_EV: event interrupt enable
- \arg I2C_INT_BUF: buffer interrupt enable
- \arg I2C_INT_TFF: txframe fall interrupt enable
- \arg I2C_INT_TFR: txframe rise interrupt enable
- \arg I2C_INT_RFF: rxframe fall interrupt enable
- \arg I2C_INT_RFR: rxframe rise interrupt enable
+ \arg I2C_INT_ERR: error interrupt
+ \arg I2C_INT_EV: event interrupt
+ \arg I2C_INT_BUF: buffer interrupt
+ \arg I2C_INT_TFF: txframe fall interrupt
+ \arg I2C_INT_TFR: txframe rise interrupt
+ \arg I2C_INT_RFF: rxframe fall interrupt
+ \arg I2C_INT_RFR: rxframe rise interrupt
\param[out] none
\retval none
*/
@@ -736,15 +757,15 @@ void i2c_interrupt_disable(uint32_t i2c_periph, i2c_interrupt_enum interrupt)
}
/*!
- \brief check I2C interrupt flag
+ \brief get I2C interrupt flag status
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[in] int_flag: I2C interrupt flags, refer to i2c_interrupt_flag_enum
only one parameter can be selected which is shown as below:
\arg I2C_INT_FLAG_SBSEND: start condition sent out in master mode interrupt flag
\arg I2C_INT_FLAG_ADDSEND: address is sent in master mode or received and matches in slave mode interrupt flag
- \arg I2C_INT_FLAG_BTC: byte transmission finishes
+ \arg I2C_INT_FLAG_BTC: byte transmission finishes interrupt flag
\arg I2C_INT_FLAG_ADD10SEND: header of 10-bit address is sent in master mode interrupt flag
- \arg I2C_INT_FLAG_STPDET: etop condition detected in slave mode interrupt flag
+ \arg I2C_INT_FLAG_STPDET: stop condition detected in slave mode interrupt flag
\arg I2C_INT_FLAG_RBNE: I2C_DATA is not Empty during receiving interrupt flag
\arg I2C_INT_FLAG_TBE: I2C_DATA is empty during transmitting interrupt flag
\arg I2C_INT_FLAG_BERR: a bus error occurs indication a unexpected start or stop condition on I2C bus interrupt flag
@@ -753,7 +774,7 @@ void i2c_interrupt_disable(uint32_t i2c_periph, i2c_interrupt_enum interrupt)
\arg I2C_INT_FLAG_OUERR: over-run or under-run situation occurs in slave mode interrupt flag
\arg I2C_INT_FLAG_PECERR: PEC error when receiving data interrupt flag
\arg I2C_INT_FLAG_SMBTO: timeout signal in SMBus mode interrupt flag
- \arg I2C_INT_FLAG_SMBALT: SMBus Alert status interrupt flag
+ \arg I2C_INT_FLAG_SMBALT: SMBus alert status interrupt flag
\arg I2C_INT_FLAG_TFF: txframe fall interrupt flag
\arg I2C_INT_FLAG_TFR: txframe rise interrupt flag
\arg I2C_INT_FLAG_RFF: rxframe fall interrupt flag
@@ -773,22 +794,22 @@ FlagStatus i2c_interrupt_flag_get(uint32_t i2c_periph, i2c_interrupt_flag_enum i
/* get the corresponding flag bit status */
flagstatus = (I2C_REG_VAL2(i2c_periph, int_flag) & BIT(I2C_BIT_POS2(int_flag)));
- if((I2C_INT_FLAG_RBNE == int_flag) || (I2C_INT_FLAG_TBE == int_flag)){
- if(intenable && bufie){
+ if((I2C_INT_FLAG_RBNE == int_flag) || (I2C_INT_FLAG_TBE == int_flag)) {
+ if(intenable && bufie) {
intenable = 1U;
- }else{
+ } else {
intenable = 0U;
}
}
- if((0U != flagstatus) && (0U != intenable)){
+ if((0U != flagstatus) && (0U != intenable)) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief clear I2C interrupt flag
+ \brief clear I2C interrupt flag status
\param[in] i2c_periph: I2Cx(x=0,1,2)
\param[in] int_flag: I2C interrupt flags, refer to i2c_interrupt_flag_enum
only one parameter can be selected which is shown as below:
@@ -799,7 +820,7 @@ FlagStatus i2c_interrupt_flag_get(uint32_t i2c_periph, i2c_interrupt_flag_enum i
\arg I2C_INT_FLAG_OUERR: over-run or under-run situation occurs in slave mode interrupt flag
\arg I2C_INT_FLAG_PECERR: PEC error when receiving data interrupt flag
\arg I2C_INT_FLAG_SMBTO: timeout signal in SMBus mode interrupt flag
- \arg I2C_INT_FLAG_SMBALT: SMBus Alert status interrupt flag
+ \arg I2C_INT_FLAG_SMBALT: SMBus alert status interrupt flag
\arg I2C_INT_FLAG_TFF: txframe fall interrupt flag
\arg I2C_INT_FLAG_TFR: txframe rise interrupt flag
\arg I2C_INT_FLAG_RFF: rxframe fall interrupt flag
@@ -809,11 +830,11 @@ FlagStatus i2c_interrupt_flag_get(uint32_t i2c_periph, i2c_interrupt_flag_enum i
*/
void i2c_interrupt_flag_clear(uint32_t i2c_periph, i2c_interrupt_flag_enum int_flag)
{
- if(I2C_INT_FLAG_ADDSEND == int_flag){
+ if(I2C_INT_FLAG_ADDSEND == int_flag) {
/* read I2C_STAT0 and then read I2C_STAT1 to clear ADDSEND */
I2C_STAT0(i2c_periph);
I2C_STAT1(i2c_periph);
- }else{
+ } else {
I2C_REG_VAL2(i2c_periph, int_flag) &= ~BIT(I2C_BIT_POS2(int_flag));
}
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_ipa.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_ipa.c
index 5afcc48e0d..afee8e5947 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_ipa.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_ipa.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -39,7 +40,7 @@ OF SUCH DAMAGE.
#define IPA_DEFAULT_VALUE 0x00000000U
/*!
- \brief deinitialize IPA registers
+ \brief deinitialize IPA registers
\param[in] none
\param[out] none
\retval none
@@ -51,7 +52,7 @@ void ipa_deinit(void)
}
/*!
- \brief enable IPA transfer
+ \brief enable IPA transfer
\param[in] none
\param[out] none
\retval none
@@ -62,7 +63,7 @@ void ipa_transfer_enable(void)
}
/*!
- \brief enable IPA transfer hang up
+ \brief enable IPA transfer hang up
\param[in] none
\param[out] none
\retval none
@@ -73,7 +74,7 @@ void ipa_transfer_hangup_enable(void)
}
/*!
- \brief disable IPA transfer hang up
+ \brief disable IPA transfer hang up
\param[in] none
\param[out] none
\retval none
@@ -84,7 +85,7 @@ void ipa_transfer_hangup_disable(void)
}
/*!
- \brief enable IPA transfer stop
+ \brief enable IPA transfer stop
\param[in] none
\param[out] none
\retval none
@@ -95,7 +96,7 @@ void ipa_transfer_stop_enable(void)
}
/*!
- \brief disable IPA transfer stop
+ \brief disable IPA transfer stop
\param[in] none
\param[out] none
\retval none
@@ -105,7 +106,7 @@ void ipa_transfer_stop_disable(void)
IPA_CTL &= ~(IPA_CTL_TST);
}
/*!
- \brief enable IPA foreground LUT loading
+ \brief enable IPA foreground LUT loading
\param[in] none
\param[out] none
\retval none
@@ -116,7 +117,7 @@ void ipa_foreground_lut_loading_enable(void)
}
/*!
- \brief enable IPA background LUT loading
+ \brief enable IPA background LUT loading
\param[in] none
\param[out] none
\retval none
@@ -127,7 +128,7 @@ void ipa_background_lut_loading_enable(void)
}
/*!
- \brief set pixel format convert mode, the function is invalid when the IPA transfer is enabled
+ \brief set pixel format convert mode, the function is invalid when the IPA transfer is enabled
\param[in] pfcm: pixel format convert mode
only one parameter can be selected which is shown as below:
\arg IPA_FGTODE: foreground memory to destination memory without pixel format convert
@@ -139,11 +140,12 @@ void ipa_background_lut_loading_enable(void)
*/
void ipa_pixel_format_convert_mode_set(uint32_t pfcm)
{
+ IPA_CTL &= ~(IPA_CTL_PFCM);
IPA_CTL |= pfcm;
}
/*!
- \brief initialize the structure of IPA foreground parameter struct with the default values, it is
+ \brief initialize the structure of IPA foreground parameter struct with the default values, it is
suggested that call this function after an ipa_foreground_parameter_struct structure is defined
\param[in] none
\param[out] foreground_struct: the data needed to initialize foreground
@@ -159,7 +161,7 @@ void ipa_pixel_format_convert_mode_set(uint32_t pfcm)
foreground_preblue: foreground pre-defined blue value
\retval none
*/
-void ipa_foreground_struct_para_init(ipa_foreground_parameter_struct* foreground_struct)
+void ipa_foreground_struct_para_init(ipa_foreground_parameter_struct *foreground_struct)
{
/* initialize the struct parameters with default values */
foreground_struct->foreground_memaddr = IPA_DEFAULT_VALUE;
@@ -173,7 +175,7 @@ void ipa_foreground_struct_para_init(ipa_foreground_parameter_struct* foreground
}
/*!
- \brief initialize foreground parameters
+ \brief initialize foreground parameters
\param[in] foreground_struct: the data needed to initialize foreground
foreground_memaddr: foreground memory base address
foreground_lineoff: foreground line offset
@@ -188,10 +190,10 @@ void ipa_foreground_struct_para_init(ipa_foreground_parameter_struct* foreground
\param[out] none
\retval none
*/
-void ipa_foreground_init(ipa_foreground_parameter_struct* foreground_struct)
+void ipa_foreground_init(ipa_foreground_parameter_struct *foreground_struct)
{
FlagStatus tempflag = RESET;
- if(RESET != (IPA_CTL & IPA_CTL_TEN)){
+ if(RESET != (IPA_CTL & IPA_CTL_TEN)) {
tempflag = SET;
/* reset the TEN in order to configure the following bits */
IPA_CTL &= ~IPA_CTL_TEN;
@@ -204,23 +206,23 @@ void ipa_foreground_init(ipa_foreground_parameter_struct* foreground_struct)
IPA_FLOFF &= ~(IPA_FLOFF_FLOFF);
IPA_FLOFF = foreground_struct->foreground_lineoff;
/* foreground pixel format pre-defined alpha, alpha calculation algorithm configuration */
- IPA_FPCTL &= ~(IPA_FPCTL_FPDAV|IPA_FPCTL_FAVCA|IPA_FPCTL_FPF);
- IPA_FPCTL |= (foreground_struct->foreground_prealpha<<24U);
+ IPA_FPCTL &= ~(IPA_FPCTL_FPDAV | IPA_FPCTL_FAVCA | IPA_FPCTL_FPF);
+ IPA_FPCTL |= (foreground_struct->foreground_prealpha << 24U);
IPA_FPCTL |= foreground_struct->foreground_alpha_algorithm;
IPA_FPCTL |= foreground_struct->foreground_pf;
/* foreground pre-defined red green blue configuration */
- IPA_FPV &= ~(IPA_FPV_FPDRV|IPA_FPV_FPDGV|IPA_FPV_FPDBV);
- IPA_FPV |= ((foreground_struct->foreground_prered<<16U)|(foreground_struct->foreground_pregreen<<8U)
- |(foreground_struct->foreground_preblue));
+ IPA_FPV &= ~(IPA_FPV_FPDRV | IPA_FPV_FPDGV | IPA_FPV_FPDBV);
+ IPA_FPV |= ((foreground_struct->foreground_prered << 16U) | (foreground_struct->foreground_pregreen << 8U)
+ | (foreground_struct->foreground_preblue));
- if(SET == tempflag){
+ if(SET == tempflag) {
/* restore the state of TEN */
IPA_CTL |= IPA_CTL_TEN;
}
}
/*!
- \brief initialize the structure of IPA background parameter struct with the default values, it is
+ \brief initialize the structure of IPA background parameter struct with the default values, it is
suggested that call this function after an ipa_background_parameter_struct structure is defined
\param[in] none
\param[out] background_struct: the data needed to initialize background
@@ -236,7 +238,7 @@ void ipa_foreground_init(ipa_foreground_parameter_struct* foreground_struct)
background_preblue: background pre-defined blue value
\retval none
*/
-void ipa_background_struct_para_init(ipa_background_parameter_struct* background_struct)
+void ipa_background_struct_para_init(ipa_background_parameter_struct *background_struct)
{
/* initialize the struct parameters with default values */
background_struct->background_memaddr = IPA_DEFAULT_VALUE;
@@ -250,7 +252,7 @@ void ipa_background_struct_para_init(ipa_background_parameter_struct* background
}
/*!
- \brief initialize background parameters
+ \brief initialize background parameters
\param[in] background_struct: the data needed to initialize background
background_memaddr: background memory base address
background_lineoff: background line offset
@@ -265,10 +267,10 @@ void ipa_background_struct_para_init(ipa_background_parameter_struct* background
\param[out] none
\retval none
*/
-void ipa_background_init(ipa_background_parameter_struct* background_struct)
+void ipa_background_init(ipa_background_parameter_struct *background_struct)
{
FlagStatus tempflag = RESET;
- if(RESET != (IPA_CTL & IPA_CTL_TEN)){
+ if(RESET != (IPA_CTL & IPA_CTL_TEN)) {
tempflag = SET;
/* reset the TEN in order to configure the following bits */
IPA_CTL &= ~IPA_CTL_TEN;
@@ -281,23 +283,23 @@ void ipa_background_init(ipa_background_parameter_struct* background_struct)
IPA_BLOFF &= ~(IPA_BLOFF_BLOFF);
IPA_BLOFF = background_struct->background_lineoff;
/* background pixel format pre-defined alpha, alpha calculation algorithm configuration */
- IPA_BPCTL &= ~(IPA_BPCTL_BPDAV|IPA_BPCTL_BAVCA|IPA_BPCTL_BPF);
- IPA_BPCTL |= (background_struct->background_prealpha<<24U);
+ IPA_BPCTL &= ~(IPA_BPCTL_BPDAV | IPA_BPCTL_BAVCA | IPA_BPCTL_BPF);
+ IPA_BPCTL |= (background_struct->background_prealpha << 24U);
IPA_BPCTL |= background_struct->background_alpha_algorithm;
IPA_BPCTL |= background_struct->background_pf;
/* background pre-defined red green blue configuration */
- IPA_BPV &= ~(IPA_BPV_BPDRV|IPA_BPV_BPDGV|IPA_BPV_BPDBV);
- IPA_BPV |= ((background_struct->background_prered<<16U)|(background_struct->background_pregreen<<8U)
- |(background_struct->background_preblue));
+ IPA_BPV &= ~(IPA_BPV_BPDRV | IPA_BPV_BPDGV | IPA_BPV_BPDBV);
+ IPA_BPV |= ((background_struct->background_prered << 16U) | (background_struct->background_pregreen << 8U)
+ | (background_struct->background_preblue));
- if(SET == tempflag){
+ if(SET == tempflag) {
/* restore the state of TEN */
IPA_CTL |= IPA_CTL_TEN;
}
}
/*!
- \brief initialize the structure of IPA destination parameter struct with the default values, it is
+ \brief initialize the structure of IPA destination parameter struct with the default values, it is
suggested that call this function after an ipa_destination_parameter_struct structure is defined
\param[in] none
\param[out] destination_struct: the data needed to initialize destination parameter
@@ -313,7 +315,7 @@ void ipa_background_init(ipa_background_parameter_struct* background_struct)
image_height: height of the image to be processed
\retval none
*/
-void ipa_destination_struct_para_init(ipa_destination_parameter_struct* destination_struct)
+void ipa_destination_struct_para_init(ipa_destination_parameter_struct *destination_struct)
{
/* initialize the struct parameters with default values */
destination_struct->destination_pf = IPA_DPF_ARGB8888;
@@ -328,7 +330,7 @@ void ipa_destination_struct_para_init(ipa_destination_parameter_struct* destinat
}
/*!
- \brief initialize destination parameters
+ \brief initialize destination parameters
\param[in] destination_struct: the data needed to initialize destination parameters
destination_pf: IPA_DPF_ARGB8888,IPA_DPF_RGB888,IPA_DPF_RGB565,IPA_DPF_ARGB1555,
IPA_DPF_ARGB4444,refer to ipa_dpf_enum
@@ -343,11 +345,11 @@ void ipa_destination_struct_para_init(ipa_destination_parameter_struct* destinat
\param[out] none
\retval none
*/
-void ipa_destination_init(ipa_destination_parameter_struct* destination_struct)
+void ipa_destination_init(ipa_destination_parameter_struct *destination_struct)
{
uint32_t destination_pixelformat;
FlagStatus tempflag = RESET;
- if(RESET != (IPA_CTL & IPA_CTL_TEN)){
+ if(RESET != (IPA_CTL & IPA_CTL_TEN)) {
tempflag = SET;
/* reset the TEN in order to configure the following bits */
IPA_CTL &= ~IPA_CTL_TEN;
@@ -358,38 +360,38 @@ void ipa_destination_init(ipa_destination_parameter_struct* destination_struct)
IPA_DPCTL = destination_struct->destination_pf;
destination_pixelformat = destination_struct->destination_pf;
/* destination pixel format ARGB8888 */
- switch(destination_pixelformat){
+ switch(destination_pixelformat) {
case IPA_DPF_ARGB8888:
- IPA_DPV &= ~(IPA_DPV_DPDBV_0|(IPA_DPV_DPDGV_0)|(IPA_DPV_DPDRV_0)|(IPA_DPV_DPDAV_0));
- IPA_DPV = (destination_struct->destination_preblue|(destination_struct->destination_pregreen<<8U)
- |(destination_struct->destination_prered<<16U)
- |(destination_struct->destination_prealpha<<24U));
+ IPA_DPV &= ~(IPA_DPV_DPDBV_0 | (IPA_DPV_DPDGV_0) | (IPA_DPV_DPDRV_0) | (IPA_DPV_DPDAV_0));
+ IPA_DPV = (destination_struct->destination_preblue | (destination_struct->destination_pregreen << 8U)
+ | (destination_struct->destination_prered << 16U)
+ | (destination_struct->destination_prealpha << 24U));
break;
/* destination pixel format RGB888 */
case IPA_DPF_RGB888:
- IPA_DPV &= ~(IPA_DPV_DPDBV_1|(IPA_DPV_DPDGV_1)|(IPA_DPV_DPDRV_1));
- IPA_DPV = (destination_struct->destination_preblue|(destination_struct->destination_pregreen<<8U)
- |(destination_struct->destination_prered<<16U));
+ IPA_DPV &= ~(IPA_DPV_DPDBV_1 | (IPA_DPV_DPDGV_1) | (IPA_DPV_DPDRV_1));
+ IPA_DPV = (destination_struct->destination_preblue | (destination_struct->destination_pregreen << 8U)
+ | (destination_struct->destination_prered << 16U));
break;
/* destination pixel format RGB565 */
case IPA_DPF_RGB565:
- IPA_DPV &= ~(IPA_DPV_DPDBV_2|(IPA_DPV_DPDGV_2)|(IPA_DPV_DPDRV_2));
- IPA_DPV = (destination_struct->destination_preblue|(destination_struct->destination_pregreen<<5U)
- |(destination_struct->destination_prered<<11U));
+ IPA_DPV &= ~(IPA_DPV_DPDBV_2 | (IPA_DPV_DPDGV_2) | (IPA_DPV_DPDRV_2));
+ IPA_DPV = (destination_struct->destination_preblue | (destination_struct->destination_pregreen << 5U)
+ | (destination_struct->destination_prered << 11U));
break;
/* destination pixel format ARGB1555 */
case IPA_DPF_ARGB1555:
- IPA_DPV &= ~(IPA_DPV_DPDBV_3|(IPA_DPV_DPDGV_3)|(IPA_DPV_DPDRV_3)|(IPA_DPV_DPDAV_3));
- IPA_DPV = (destination_struct->destination_preblue|(destination_struct->destination_pregreen<<5U)
- |(destination_struct->destination_prered<<10U)
- |(destination_struct->destination_prealpha<<15U));
+ IPA_DPV &= ~(IPA_DPV_DPDBV_3 | (IPA_DPV_DPDGV_3) | (IPA_DPV_DPDRV_3) | (IPA_DPV_DPDAV_3));
+ IPA_DPV = (destination_struct->destination_preblue | (destination_struct->destination_pregreen << 5U)
+ | (destination_struct->destination_prered << 10U)
+ | (destination_struct->destination_prealpha << 15U));
break;
/* destination pixel format ARGB4444 */
case IPA_DPF_ARGB4444:
- IPA_DPV &= ~(IPA_DPV_DPDBV_4|(IPA_DPV_DPDGV_4)|(IPA_DPV_DPDRV_4)|(IPA_DPV_DPDAV_4));
- IPA_DPV = (destination_struct->destination_preblue|(destination_struct->destination_pregreen<<4U)
- |(destination_struct->destination_prered<<8U)
- |(destination_struct->destination_prealpha<<12U));
+ IPA_DPV &= ~(IPA_DPV_DPDBV_4 | (IPA_DPV_DPDGV_4) | (IPA_DPV_DPDRV_4) | (IPA_DPV_DPDAV_4));
+ IPA_DPV = (destination_struct->destination_preblue | (destination_struct->destination_pregreen << 4U)
+ | (destination_struct->destination_prered << 8U)
+ | (destination_struct->destination_prealpha << 12U));
break;
default:
break;
@@ -399,19 +401,19 @@ void ipa_destination_init(ipa_destination_parameter_struct* destination_struct)
IPA_DMADDR = destination_struct->destination_memaddr;
/* destination line offset configuration */
IPA_DLOFF &= ~(IPA_DLOFF_DLOFF);
- IPA_DLOFF =destination_struct->destination_lineoff;
+ IPA_DLOFF = destination_struct->destination_lineoff;
/* image size configuration */
- IPA_IMS &= ~(IPA_IMS_HEIGHT|IPA_IMS_WIDTH);
- IPA_IMS |= ((destination_struct->image_width<<16U)|(destination_struct->image_height));
+ IPA_IMS &= ~(IPA_IMS_HEIGHT | IPA_IMS_WIDTH);
+ IPA_IMS |= ((destination_struct->image_width << 16U) | (destination_struct->image_height));
- if(SET == tempflag){
+ if(SET == tempflag) {
/* restore the state of TEN */
IPA_CTL |= IPA_CTL_TEN;
}
}
/*!
- \brief initialize IPA foreground LUT parameters
+ \brief initialize IPA foreground LUT parameters
\param[in] fg_lut_num: foreground LUT number of pixel
\param[in] fg_lut_pf: foreground LUT pixel format(IPA_LUT_PF_ARGB8888, IPA_LUT_PF_RGB888)
\param[in] fg_lut_addr: foreground LUT memory base address
@@ -421,32 +423,32 @@ void ipa_destination_init(ipa_destination_parameter_struct* destination_struct)
void ipa_foreground_lut_init(uint8_t fg_lut_num, uint8_t fg_lut_pf, uint32_t fg_lut_addr)
{
FlagStatus tempflag = RESET;
- if(RESET != (IPA_FPCTL & IPA_FPCTL_FLLEN)){
+ if(RESET != (IPA_FPCTL & IPA_FPCTL_FLLEN)) {
tempflag = SET;
/* reset the FLLEN in order to configure the following bits */
IPA_FPCTL &= ~IPA_FPCTL_FLLEN;
}
/* foreground LUT number of pixel configuration */
- IPA_FPCTL |= ((uint32_t)fg_lut_num<<8U);
+ IPA_FPCTL |= ((uint32_t)fg_lut_num << 8U);
/* foreground LUT pixel format configuration */
- if(IPA_LUT_PF_RGB888 == fg_lut_pf){
+ if(IPA_LUT_PF_RGB888 == fg_lut_pf) {
IPA_FPCTL |= IPA_FPCTL_FLPF;
- }else{
+ } else {
IPA_FPCTL &= ~(IPA_FPCTL_FLPF);
}
/* foreground LUT memory base address configuration */
IPA_FLMADDR &= ~(IPA_FLMADDR_FLMADDR);
IPA_FLMADDR = fg_lut_addr;
- if(SET == tempflag){
+ if(SET == tempflag) {
/* restore the state of FLLEN */
IPA_FPCTL |= IPA_FPCTL_FLLEN;
}
}
/*!
- \brief initialize IPA background LUT parameters
+ \brief initialize IPA background LUT parameters
\param[in] bg_lut_num: background LUT number of pixel
\param[in] bg_lut_pf: background LUT pixel format(IPA_LUT_PF_ARGB8888, IPA_LUT_PF_RGB888)
\param[in] bg_lut_addr: background LUT memory base address
@@ -456,32 +458,32 @@ void ipa_foreground_lut_init(uint8_t fg_lut_num, uint8_t fg_lut_pf, uint32_t fg_
void ipa_background_lut_init(uint8_t bg_lut_num, uint8_t bg_lut_pf, uint32_t bg_lut_addr)
{
FlagStatus tempflag = RESET;
- if(RESET != (IPA_BPCTL & IPA_BPCTL_BLLEN)){
+ if(RESET != (IPA_BPCTL & IPA_BPCTL_BLLEN)) {
tempflag = SET;
/* reset the BLLEN in order to configure the following bits */
IPA_BPCTL &= ~IPA_BPCTL_BLLEN;
}
/* background LUT number of pixel configuration */
- IPA_BPCTL |= ((uint32_t)bg_lut_num<<8U);
+ IPA_BPCTL |= ((uint32_t)bg_lut_num << 8U);
/* background LUT pixel format configuration */
- if(IPA_LUT_PF_RGB888 == bg_lut_pf){
+ if(IPA_LUT_PF_RGB888 == bg_lut_pf) {
IPA_BPCTL |= IPA_BPCTL_BLPF;
- }else{
+ } else {
IPA_BPCTL &= ~(IPA_BPCTL_BLPF);
}
/* background LUT memory base address configuration */
IPA_BLMADDR &= ~(IPA_BLMADDR_BLMADDR);
IPA_BLMADDR = bg_lut_addr;
- if(SET == tempflag){
+ if(SET == tempflag) {
/* restore the state of BLLEN */
IPA_BPCTL |= IPA_BPCTL_BLLEN;
}
}
/*!
- \brief configure IPA line mark
+ \brief configure IPA line mark
\param[in] line_num: line number
\param[out] none
\retval none
@@ -493,22 +495,22 @@ void ipa_line_mark_config(uint16_t line_num)
}
/*!
- \brief inter-timer enable or disable
+ \brief inter-timer enable or disable
\param[in] timer_cfg: IPA_INTER_TIMER_ENABLE,IPA_INTER_TIMER_DISABLE
\param[out] none
\retval none
*/
void ipa_inter_timer_config(uint8_t timer_cfg)
{
- if(IPA_INTER_TIMER_ENABLE == timer_cfg){
+ if(IPA_INTER_TIMER_ENABLE == timer_cfg) {
IPA_ITCTL |= IPA_ITCTL_ITEN;
- }else{
+ } else {
IPA_ITCTL &= ~(IPA_ITCTL_ITEN);
}
}
/*!
- \brief configure the number of clock cycles interval
+ \brief configure the number of clock cycles interval
\param[in] clk_num: the number of clock cycles
\param[out] none
\retval none
@@ -517,11 +519,11 @@ void ipa_interval_clock_num_config(uint8_t clk_num)
{
/* NCCI[7:0] bits have no meaning if ITEN is '0' */
IPA_ITCTL &= ~(IPA_ITCTL_NCCI);
- IPA_ITCTL |= ((uint32_t)clk_num<<8U);
+ IPA_ITCTL |= ((uint32_t)clk_num << 8U);
}
/*!
- \brief get IPA flag status in IPA_INTF register
+ \brief get IPA flag status in IPA_INTF register
\param[in] flag: IPA flags
one or more parameters can be selected which are shown as below:
\arg IPA_FLAG_TAE: transfer access error interrupt flag
@@ -535,15 +537,15 @@ void ipa_interval_clock_num_config(uint8_t clk_num)
*/
FlagStatus ipa_flag_get(uint32_t flag)
{
- if(RESET != (IPA_INTF & flag)){
+ if(RESET != (IPA_INTF & flag)) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief clear IPA flag in IPA_INTF register
+ \brief clear IPA flag in IPA_INTF register
\param[in] flag: IPA flags
one or more parameters can be selected which are shown as below:
\arg IPA_FLAG_TAE: transfer access error interrupt flag
@@ -561,7 +563,7 @@ void ipa_flag_clear(uint32_t flag)
}
/*!
- \brief enable IPA interrupt
+ \brief enable IPA interrupt
\param[in] int_flag: IPA interrupt flags
one or more parameters can be selected which are shown as below:
\arg IPA_INT_TAE: transfer access error interrupt
@@ -579,7 +581,7 @@ void ipa_interrupt_enable(uint32_t int_flag)
}
/*!
- \brief disable IPA interrupt
+ \brief disable IPA interrupt
\param[in] int_flag: IPA interrupt flags
one or more parameters can be selected which are shown as below:
\arg IPA_INT_TAE: transfer access error interrupt
@@ -597,7 +599,7 @@ void ipa_interrupt_disable(uint32_t int_flag)
}
/*!
- \brief get IPA interrupt flag
+ \brief get IPA interrupt flag
\param[in] int_flag: IPA interrupt flag flags
one or more parameters can be selected which are shown as below:
\arg IPA_INT_FLAG_TAE: transfer access error interrupt flag
@@ -611,15 +613,15 @@ void ipa_interrupt_disable(uint32_t int_flag)
*/
FlagStatus ipa_interrupt_flag_get(uint32_t int_flag)
{
- if(0U != (IPA_INTF & int_flag)){
+ if(0U != (IPA_INTF & int_flag)) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief clear IPA interrupt flag
+ \brief clear IPA interrupt flag
\param[in] int_flag: IPA interrupt flag flags
one or more parameters can be selected which are shown as below:
\arg IPA_INT_FLAG_TAE: transfer access error interrupt flag
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_iref.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_iref.c
index 218a070ef4..8702da387a 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_iref.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_iref.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -37,7 +38,7 @@ OF SUCH DAMAGE.
#include "gd32f4xx_iref.h"
/*!
- \brief deinit IREF
+ \brief deinitialize IREF
\param[in] none
\param[out] none
\retval none
@@ -49,7 +50,7 @@ void iref_deinit(void)
}
/*!
- \brief enable IREF
+ \brief enable IREF
\param[in] none
\param[out] none
\retval none
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_misc.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_misc.c
index c826722f13..b35db88d88 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_misc.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_misc.c
@@ -1,14 +1,14 @@
/*!
\file gd32f4xx_misc.c
\brief MISC driver
-
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -37,7 +37,7 @@ OF SUCH DAMAGE.
#include "gd32f4xx_misc.h"
/*!
- \brief set the priority group
+ \brief set the priority group
\param[in] nvic_prigroup: the NVIC priority group
\arg NVIC_PRIGROUP_PRE0_SUB4:0 bits for pre-emption priority 4 bits for subpriority
\arg NVIC_PRIGROUP_PRE1_SUB3:1 bits for pre-emption priority 3 bits for subpriority
@@ -54,7 +54,7 @@ void nvic_priority_group_set(uint32_t nvic_prigroup)
}
/*!
- \brief enable NVIC request
+ \brief enable NVIC request
\param[in] nvic_irq: the NVIC interrupt request, detailed in IRQn_Type
\param[in] nvic_irq_pre_priority: the pre-emption priority needed to set
\param[in] nvic_irq_sub_priority: the subpriority needed to set
@@ -66,29 +66,29 @@ void nvic_irq_enable(uint8_t nvic_irq, uint8_t nvic_irq_pre_priority,
{
uint32_t temp_priority = 0x00U, temp_pre = 0x00U, temp_sub = 0x00U;
/* use the priority group value to get the temp_pre and the temp_sub */
- if(((SCB->AIRCR) & (uint32_t)0x700U)==NVIC_PRIGROUP_PRE0_SUB4){
- temp_pre=0U;
- temp_sub=0x4U;
- }else if(((SCB->AIRCR) & (uint32_t)0x700U)==NVIC_PRIGROUP_PRE1_SUB3){
- temp_pre=1U;
- temp_sub=0x3U;
- }else if(((SCB->AIRCR) & (uint32_t)0x700U)==NVIC_PRIGROUP_PRE2_SUB2){
- temp_pre=2U;
- temp_sub=0x2U;
- }else if(((SCB->AIRCR) & (uint32_t)0x700U)==NVIC_PRIGROUP_PRE3_SUB1){
- temp_pre=3U;
- temp_sub=0x1U;
- }else if(((SCB->AIRCR) & (uint32_t)0x700U)==NVIC_PRIGROUP_PRE4_SUB0){
- temp_pre=4U;
- temp_sub=0x0U;
- }else{
+ if(((SCB->AIRCR) & (uint32_t)0x700U) == NVIC_PRIGROUP_PRE0_SUB4) {
+ temp_pre = 0U;
+ temp_sub = 0x4U;
+ } else if(((SCB->AIRCR) & (uint32_t)0x700U) == NVIC_PRIGROUP_PRE1_SUB3) {
+ temp_pre = 1U;
+ temp_sub = 0x3U;
+ } else if(((SCB->AIRCR) & (uint32_t)0x700U) == NVIC_PRIGROUP_PRE2_SUB2) {
+ temp_pre = 2U;
+ temp_sub = 0x2U;
+ } else if(((SCB->AIRCR) & (uint32_t)0x700U) == NVIC_PRIGROUP_PRE3_SUB1) {
+ temp_pre = 3U;
+ temp_sub = 0x1U;
+ } else if(((SCB->AIRCR) & (uint32_t)0x700U) == NVIC_PRIGROUP_PRE4_SUB0) {
+ temp_pre = 4U;
+ temp_sub = 0x0U;
+ } else {
nvic_priority_group_set(NVIC_PRIGROUP_PRE2_SUB2);
- temp_pre=2U;
- temp_sub=0x2U;
+ temp_pre = 2U;
+ temp_sub = 0x2U;
}
/* get the temp_priority to fill the NVIC->IP register */
temp_priority = (uint32_t)nvic_irq_pre_priority << (0x4U - temp_pre);
- temp_priority |= nvic_irq_sub_priority &(0x0FU >> (0x4U - temp_sub));
+ temp_priority |= nvic_irq_sub_priority & (0x0FU >> (0x4U - temp_sub));
temp_priority = temp_priority << 0x04U;
NVIC->IP[nvic_irq] = (uint8_t)temp_priority;
/* enable the selected IRQ */
@@ -96,7 +96,7 @@ void nvic_irq_enable(uint8_t nvic_irq, uint8_t nvic_irq_pre_priority,
}
/*!
- \brief disable NVIC request
+ \brief disable NVIC request
\param[in] nvic_irq: the NVIC interrupt request, detailed in IRQn_Type
\param[out] none
\retval none
@@ -108,7 +108,7 @@ void nvic_irq_disable(uint8_t nvic_irq)
}
/*!
- \brief set the NVIC vector table base address
+ \brief set the NVIC vector table base address
\param[in] nvic_vict_tab: the RAM or FLASH base address
\arg NVIC_VECTTAB_RAM: RAM base address
\are NVIC_VECTTAB_FLASH: Flash base address
@@ -119,10 +119,11 @@ void nvic_irq_disable(uint8_t nvic_irq)
void nvic_vector_table_set(uint32_t nvic_vict_tab, uint32_t offset)
{
SCB->VTOR = nvic_vict_tab | (offset & NVIC_VECTTAB_OFFSET_MASK);
+ __DSB();
}
/*!
- \brief set the state of the low power mode
+ \brief set the state of the low power mode
\param[in] lowpower_mode: the low power mode state
\arg SCB_LPM_SLEEP_EXIT_ISR: if chose this para, the system always enter low power
mode by exiting from ISR
@@ -138,7 +139,7 @@ void system_lowpower_set(uint8_t lowpower_mode)
}
/*!
- \brief reset the state of the low power mode
+ \brief reset the state of the low power mode
\param[in] lowpower_mode: the low power mode state
\arg SCB_LPM_SLEEP_EXIT_ISR: if chose this para, the system will exit low power
mode by exiting from ISR
@@ -154,7 +155,7 @@ void system_lowpower_reset(uint8_t lowpower_mode)
}
/*!
- \brief set the systick clock source
+ \brief set the systick clock source
\param[in] systick_clksource: the systick clock source needed to choose
\arg SYSTICK_CLKSOURCE_HCLK: systick clock source is from HCLK
\arg SYSTICK_CLKSOURCE_HCLK_DIV8: systick clock source is from HCLK/8
@@ -164,10 +165,10 @@ void system_lowpower_reset(uint8_t lowpower_mode)
void systick_clksource_set(uint32_t systick_clksource)
{
- if(SYSTICK_CLKSOURCE_HCLK == systick_clksource ){
+ if(SYSTICK_CLKSOURCE_HCLK == systick_clksource) {
/* set the systick clock source from HCLK */
SysTick->CTRL |= SYSTICK_CLKSOURCE_HCLK;
- }else{
+ } else {
/* set the systick clock source from HCLK/8 */
SysTick->CTRL &= SYSTICK_CLKSOURCE_HCLK_DIV8;
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_pmu.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_pmu.c
index 05f4cd7c3a..50086e72ca 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_pmu.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_pmu.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -36,8 +37,9 @@ OF SUCH DAMAGE.
#include "gd32f4xx_pmu.h"
#include "core_cm4.h"
+
/*!
- \brief reset PMU register
+ \brief reset PMU registers
\param[in] none
\param[out] none
\retval none
@@ -76,6 +78,18 @@ void pmu_lvd_select(uint32_t lvdt_n)
}
/*!
+ \brief disable PMU lvd
+ \param[in] none
+ \param[out] none
+ \retval none
+*/
+void pmu_lvd_disable(void)
+{
+ /* disable LVD */
+ PMU_CTL &= ~PMU_CTL_LVDEN;
+}
+
+/*!
\brief select LDO output voltage
this bit set by software when the main PLL closed, before closing PLL, change the system clock to IRC16M or HXTAL
\param[in] ldo_output:
@@ -92,17 +106,26 @@ void pmu_ldo_output_select(uint32_t ldo_output)
}
/*!
- \brief enable low-driver mode in deep-sleep mode
- \param[in] lowdr_mode:
- \arg PMU_LOWDRIVER_ENABLE: enable low-driver mode in deep-sleep mode
- \arg PMU_LOWDRIVER_DISABLE: disable low-driver mode in deep-sleep mode
+ \brief enable high-driver mode
+ this bit set by software only when IRC16M or HXTAL used as system clock
+ \param[in] none
\param[out] none
\retval none
*/
-void pmu_low_driver_mode_enable(uint32_t lowdr_mode)
+void pmu_highdriver_mode_enable(void)
{
- PMU_CTL &= ~PMU_CTL_LDEN;
- PMU_CTL |= lowdr_mode;
+ PMU_CTL |= PMU_CTL_HDEN;
+}
+
+/*!
+ \brief disable high-driver mode
+ \param[in] none
+ \param[out] none
+ \retval none
+*/
+void pmu_highdriver_mode_disable(void)
+{
+ PMU_CTL &= ~PMU_CTL_HDEN;
}
/*!
@@ -117,77 +140,64 @@ void pmu_low_driver_mode_enable(uint32_t lowdr_mode)
void pmu_highdriver_switch_select(uint32_t highdr_switch)
{
/* wait for HDRF flag set */
- while(SET != pmu_flag_get(PMU_FLAG_HDRF)){
+ while(SET != pmu_flag_get(PMU_FLAG_HDRF)) {
}
PMU_CTL &= ~PMU_CTL_HDS;
PMU_CTL |= highdr_switch;
}
/*!
- \brief enable high-driver mode
- this bit set by software only when IRC16M or HXTAL used as system clock
- \param[in] none
- \param[out] none
- \retval none
-*/
-void pmu_highdriver_mode_enable(void)
-{
- PMU_CTL |= PMU_CTL_HDEN;
-}
-
-/*!
- \brief disable high-driver mode
+ \brief enable low-driver mode in deep-sleep
\param[in] none
\param[out] none
\retval none
*/
-void pmu_highdriver_mode_disable(void)
+void pmu_lowdriver_mode_enable(void)
{
- PMU_CTL &= ~PMU_CTL_HDEN;
+ PMU_CTL |= PMU_CTL_LDEN;
}
/*!
- \brief disable PMU lvd
+ \brief disable low-driver mode in deep-sleep
\param[in] none
\param[out] none
\retval none
*/
-void pmu_lvd_disable(void)
+void pmu_lowdriver_mode_disable(void)
{
- /* disable LVD */
- PMU_CTL &= ~PMU_CTL_LVDEN;
+ PMU_CTL &= ~PMU_CTL_LDEN;
}
/*!
- \brief low-driver mode when use low power LDO
+ \brief in deep-sleep mode, driver mode when use low power LDO
\param[in] mode:
\arg PMU_NORMALDR_LOWPWR: normal driver when use low power LDO
\arg PMU_LOWDR_LOWPWR: low-driver mode enabled when LDEN is 11 and use low power LDO
\param[out] none
\retval none
*/
-void pmu_lowdriver_lowpower_config(uint32_t mode)
+void pmu_lowpower_driver_config(uint32_t mode)
{
PMU_CTL &= ~PMU_CTL_LDLP;
PMU_CTL |= mode;
}
/*!
- \brief low-driver mode when use normal power LDO
+ \brief in deep-sleep mode, driver mode when use normal power LDO
\param[in] mode:
\arg PMU_NORMALDR_NORMALPWR: normal driver when use normal power LDO
\arg PMU_LOWDR_NORMALPWR: low-driver mode enabled when LDEN is 11 and use normal power LDO
\param[out] none
\retval none
*/
-void pmu_lowdriver_normalpower_config(uint32_t mode)
+void pmu_normalpower_driver_config(uint32_t mode)
{
PMU_CTL &= ~PMU_CTL_LDNP;
PMU_CTL |= mode;
}
/*!
- \brief PMU work at sleep mode
+ \brief PMU work in sleep mode
\param[in] sleepmodecmd:
\arg WFI_CMD: use WFI command
\arg WFE_CMD: use WFE command
@@ -200,154 +210,140 @@ void pmu_to_sleepmode(uint8_t sleepmodecmd)
SCB->SCR &= ~((uint32_t)SCB_SCR_SLEEPDEEP_Msk);
/* select WFI or WFE command to enter sleep mode */
- if(WFI_CMD == sleepmodecmd){
+ if(WFI_CMD == sleepmodecmd) {
__WFI();
- }else{
+ } else {
__WFE();
}
}
/*!
- \brief PMU work at deepsleep mode
+ \brief PMU work in deep-sleep mode
\param[in] ldo
- \arg PMU_LDO_NORMAL: LDO normal work when pmu enter deepsleep mode
- \arg PMU_LDO_LOWPOWER: LDO work at low power mode when pmu enter deepsleep mode
+ \arg PMU_LDO_NORMAL: LDO normal work when pmu enter deep-sleep mode
+ \arg PMU_LDO_LOWPOWER: LDO work at low power mode when pmu enter deep-sleep mode
+ \param[in] lowdrive:
+ only one parameter can be selected which is shown as below:
+ \arg PMU_LOWDRIVER_DISABLE: Low-driver mode disable in deep-sleep mode
+ \arg PMU_LOWDRIVER_ENABLE: Low-driver mode enable in deep-sleep mode
\param[in] deepsleepmodecmd:
\arg WFI_CMD: use WFI command
\arg WFE_CMD: use WFE command
\param[out] none
\retval none
*/
-void pmu_to_deepsleepmode(uint32_t ldo,uint8_t deepsleepmodecmd)
+void pmu_to_deepsleepmode(uint32_t ldo, uint32_t lowdrive, uint8_t deepsleepmodecmd)
{
- static uint32_t reg_snap[ 4 ];
+ static uint32_t reg_snap[4];
/* clear stbmod and ldolp bits */
- PMU_CTL &= ~((uint32_t)(PMU_CTL_STBMOD | PMU_CTL_LDOLP));
+ PMU_CTL &= ~((uint32_t)(PMU_CTL_STBMOD | PMU_CTL_LDOLP | PMU_CTL_LDEN | PMU_CTL_LDNP | PMU_CTL_LDLP));
/* set ldolp bit according to pmu_ldo */
PMU_CTL |= ldo;
+ /* configure low drive mode in deep-sleep mode */
+ if(PMU_LOWDRIVER_ENABLE == lowdrive) {
+ if(PMU_LDO_NORMAL == ldo) {
+ PMU_CTL |= (uint32_t)(PMU_CTL_LDEN | PMU_CTL_LDNP);
+ } else {
+ PMU_CTL |= (uint32_t)(PMU_CTL_LDEN | PMU_CTL_LDLP);
+ }
+ }
/* set sleepdeep bit of Cortex-M4 system control register */
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
- reg_snap[ 0 ] = REG32( 0xE000E010U );
- reg_snap[ 1 ] = REG32( 0xE000E100U );
- reg_snap[ 2 ] = REG32( 0xE000E104U );
- reg_snap[ 3 ] = REG32( 0xE000E108U );
+ reg_snap[0] = REG32(0xE000E010U);
+ reg_snap[1] = REG32(0xE000E100U);
+ reg_snap[2] = REG32(0xE000E104U);
+ reg_snap[3] = REG32(0xE000E108U);
- REG32( 0xE000E010U ) &= 0x00010004U;
- REG32( 0xE000E180U ) = 0XFF7FF831U;
- REG32( 0xE000E184U ) = 0XBFFFF8FFU;
- REG32( 0xE000E188U ) = 0xFFFFEFFFU;
+ REG32(0xE000E010U) &= 0x00010004U;
+ REG32(0xE000E180U) = 0XFF7FF831U;
+ REG32(0xE000E184U) = 0XBFFFF8FFU;
+ REG32(0xE000E188U) = 0xFFFFEFFFU;
- /* select WFI or WFE command to enter deepsleep mode */
- if(WFI_CMD == deepsleepmodecmd){
+ /* select WFI or WFE command to enter deep-sleep mode */
+ if(WFI_CMD == deepsleepmodecmd) {
__WFI();
- }else{
+ } else {
__SEV();
__WFE();
__WFE();
}
- REG32( 0xE000E010U ) = reg_snap[ 0 ] ;
- REG32( 0xE000E100U ) = reg_snap[ 1 ] ;
- REG32( 0xE000E104U ) = reg_snap[ 2 ] ;
- REG32( 0xE000E108U ) = reg_snap[ 3 ] ;
+ REG32(0xE000E010U) = reg_snap[0];
+ REG32(0xE000E100U) = reg_snap[1];
+ REG32(0xE000E104U) = reg_snap[2];
+ REG32(0xE000E108U) = reg_snap[3];
/* reset sleepdeep bit of Cortex-M4 system control register */
SCB->SCR &= ~((uint32_t)SCB_SCR_SLEEPDEEP_Msk);
}
/*!
- \brief pmu work at standby mode
- \param[in] standbymodecmd:
- \arg WFI_CMD: use WFI command
- \arg WFE_CMD: use WFE command
+ \brief pmu work in standby mode
+ \param[in] none
\param[out] none
\retval none
*/
-void pmu_to_standbymode(uint8_t standbymodecmd)
+void pmu_to_standbymode(void)
{
- /* set sleepdeep bit of Cortex-M4 system control register */
- SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
-
/* set stbmod bit */
PMU_CTL |= PMU_CTL_STBMOD;
/* reset wakeup flag */
PMU_CTL |= PMU_CTL_WURST;
- /* select WFI or WFE command to enter standby mode */
- if(WFI_CMD == standbymodecmd){
- __WFI();
- }else{
- __WFE();
- }
+ /* set sleepdeep bit of Cortex-M4 system control register */
+ SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
+
+ REG32(0xE000E010U) &= 0x00010004U;
+ REG32(0xE000E180U) = 0XFFFFFFF7U;
+ REG32(0xE000E184U) = 0XFFFFFDFFU;
+ REG32(0xE000E188U) = 0xFFFFFFFFU;
+
+ /* select WFI command to enter standby mode */
+ __WFI();
}
/*!
- \brief backup SRAM LDO on
- \param[in] bkp_ldo:
- \arg PMU_BLDOON_OFF: backup SRAM LDO closed
- \arg PMU_BLDOON_ON: open the backup SRAM LDO
+ \brief enable PMU wakeup pin
+ \param[in] none
\param[out] none
\retval none
*/
-void pmu_backup_ldo_config(uint32_t bkp_ldo)
+void pmu_wakeup_pin_enable(void)
{
- PMU_CS &= ~PMU_CS_BLDOON;
- PMU_CS |= bkp_ldo;
+ PMU_CS |= PMU_CS_WUPEN;
}
/*!
- \brief reset flag bit
- \param[in] flag_reset:
- \arg PMU_FLAG_RESET_WAKEUP: reset wakeup flag
- \arg PMU_FLAG_RESET_STANDBY: reset standby flag
+ \brief disable PMU wakeup pin
+ \param[in] none
\param[out] none
\retval none
*/
-void pmu_flag_reset(uint32_t flag_reset)
+void pmu_wakeup_pin_disable(void)
{
- switch(flag_reset){
- case PMU_FLAG_RESET_WAKEUP:
- /* reset wakeup flag */
- PMU_CTL |= PMU_CTL_WURST;
- break;
- case PMU_FLAG_RESET_STANDBY:
- /* reset standby flag */
- PMU_CTL |= PMU_CTL_STBRST;
- break;
- default :
- break;
- }
+ PMU_CS &= ~PMU_CS_WUPEN;
}
/*!
- \brief get flag state
- \param[in] pmu_flag:
- \arg PMU_FLAG_WAKEUP: wakeup flag
- \arg PMU_FLAG_STANDBY: standby flag
- \arg PMU_FLAG_LVD: lvd flag
- \arg PMU_FLAG_BLDORF: backup SRAM LDO ready flag
- \arg PMU_FLAG_LDOVSRF: LDO voltage select ready flag
- \arg PMU_FLAG_HDRF: high-driver ready flag
- \arg PMU_FLAG_HDSRF: high-driver switch ready flag
- \arg PMU_FLAG_LDRF: low-driver mode ready flag
+ \brief backup SRAM LDO on
+ \param[in] bkp_ldo:
+ \arg PMU_BLDOON_OFF: backup SRAM LDO closed
+ \arg PMU_BLDOON_ON: open the backup SRAM LDO
\param[out] none
- \retval FlagStatus: SET or RESET
+ \retval none
*/
-FlagStatus pmu_flag_get(uint32_t pmu_flag)
+void pmu_backup_ldo_config(uint32_t bkp_ldo)
{
- if(PMU_CS & pmu_flag){
- return SET;
- }else{
- return RESET;
- }
+ PMU_CS &= ~PMU_CS_BLDOON;
+ PMU_CS |= bkp_ldo;
}
/*!
- \brief enable backup domain write
+ \brief enable write access to the registers in backup domain
\param[in] none
\param[out] none
\retval none
@@ -358,7 +354,7 @@ void pmu_backup_write_enable(void)
}
/*!
- \brief disable backup domain write
+ \brief disable write access to the registers in backup domain
\param[in] none
\param[out] none
\retval none
@@ -369,23 +365,48 @@ void pmu_backup_write_disable(void)
}
/*!
- \brief enable wakeup pin
- \param[in] none
+ \brief get flag state
+ \param[in] flag:
+ \arg PMU_FLAG_WAKEUP: wakeup flag
+ \arg PMU_FLAG_STANDBY: standby flag
+ \arg PMU_FLAG_LVD: lvd flag
+ \arg PMU_FLAG_BLDORF: backup SRAM LDO ready flag
+ \arg PMU_FLAG_LDOVSRF: LDO voltage select ready flag
+ \arg PMU_FLAG_HDRF: high-driver ready flag
+ \arg PMU_FLAG_HDSRF: high-driver switch ready flag
+ \arg PMU_FLAG_LDRF: low-driver mode ready flag
\param[out] none
- \retval none
+ \retval FlagStatus: SET or RESET
*/
-void pmu_wakeup_pin_enable(void)
+FlagStatus pmu_flag_get(uint32_t flag)
{
- PMU_CS |= PMU_CS_WUPEN;
+ if(PMU_CS & flag) {
+ return SET;
+ } else {
+ return RESET;
+ }
}
/*!
- \brief disable wakeup pin
- \param[in] none
+ \brief clear flag bit
+ \param[in] flag:
+ \arg PMU_FLAG_RESET_WAKEUP: reset wakeup flag
+ \arg PMU_FLAG_RESET_STANDBY: reset standby flag
\param[out] none
\retval none
*/
-void pmu_wakeup_pin_disable(void)
+void pmu_flag_clear(uint32_t flag)
{
- PMU_CS &= ~PMU_CS_WUPEN;
+ switch(flag) {
+ case PMU_FLAG_RESET_WAKEUP:
+ /* reset wakeup flag */
+ PMU_CTL |= PMU_CTL_WURST;
+ break;
+ case PMU_FLAG_RESET_STANDBY:
+ /* reset standby flag */
+ PMU_CTL |= PMU_CTL_STBRST;
+ break;
+ default :
+ break;
+ }
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_rcu.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_rcu.c
index aecc895a09..42b8aaec80 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_rcu.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_rcu.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -49,7 +50,7 @@ OF SUCH DAMAGE.
#define RCU_IRC16M_ADJUST_OFFSET ((uint32_t)3U)
/*!
- \brief deinitialize the RCU
+ \brief deinitialize the RCU
\param[in] none
\param[out] none
\retval none
@@ -59,14 +60,16 @@ void rcu_deinit(void)
/* enable IRC16M */
RCU_CTL |= RCU_CTL_IRC16MEN;
rcu_osci_stab_wait(RCU_IRC16M);
- /* reset CFG0 register */
- RCU_CFG0 &= ~(RCU_CFG0_SCS | RCU_CFG0_AHBPSC | RCU_CFG0_APB1PSC | RCU_CFG0_APB2PSC |
- RCU_CFG0_RTCDIV | RCU_CFG0_CKOUT0SEL | RCU_CFG0_I2SSEL | RCU_CFG0_CKOUT0DIV |
- RCU_CFG0_CKOUT1DIV | RCU_CFG0_CKOUT1SEL);
+ RCU_CFG0 &= ~RCU_CFG0_SCS;
+
/* reset CTL register */
RCU_CTL &= ~(RCU_CTL_HXTALEN | RCU_CTL_CKMEN | RCU_CTL_PLLEN | RCU_CTL_PLLI2SEN
| RCU_CTL_PLLSAIEN);
RCU_CTL &= ~(RCU_CTL_HXTALBPS);
+ /* reset CFG0 register */
+ RCU_CFG0 &= ~(RCU_CFG0_SCS | RCU_CFG0_AHBPSC | RCU_CFG0_APB1PSC | RCU_CFG0_APB2PSC |
+ RCU_CFG0_RTCDIV | RCU_CFG0_CKOUT0SEL | RCU_CFG0_I2SSEL | RCU_CFG0_CKOUT0DIV |
+ RCU_CFG0_CKOUT1DIV | RCU_CFG0_CKOUT1SEL);
/* reset PLL register */
RCU_PLL = 0x24003010U;
/* reset PLLI2S register */
@@ -80,10 +83,10 @@ void rcu_deinit(void)
}
/*!
- \brief enable the peripherals clock
+ \brief enable the peripherals clock
\param[in] periph: RCU peripherals, refer to rcu_periph_enum
only one parameter can be selected which is shown as below:
- \arg RCU_GPIOx (x=A,B,C,D,E,F,G,H,I): GPIO ports clock
+ \arg RCU_GPIOx (x = A, B, C, D, E, F, G, H, I): GPIO ports clock
\arg RCU_CRC: CRC clock
\arg RCU_BKPSRAM: BKPSRAM clock
\arg RCU_TCMSRAM: TCMSRAM clock
@@ -99,17 +102,17 @@ void rcu_deinit(void)
\arg RCU_TRNG: TRNG clock
\arg RCU_USBFS: USBFS clock
\arg RCU_EXMC: EXMC clock
- \arg RCU_TIMERx (x=0,1,2,3,4,5,6,7,8,9,10,11,12,13): TIMER clock
+ \arg RCU_TIMERx (x = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13): TIMER clock
\arg RCU_WWDGT: WWDGT clock
- \arg RCU_SPIx (x=0,1,2,3,4,5): SPI clock
- \arg RCU_USARTx (x=0,1,2,5): USART clock
- \arg RCU_UARTx (x=3,4,6,7): UART clock
- \arg RCU_I2Cx (x=0,1,2): I2C clock
- \arg RCU_CANx (x=0,1): CAN clock
+ \arg RCU_SPIx (x = 0, 1, 2, 3, 4, 5): SPI clock
+ \arg RCU_USARTx (x = 0, 1, 2, 5): USART clock
+ \arg RCU_UARTx (x = 3, 4, 6, 7): UART clock
+ \arg RCU_I2Cx (x = 0, 1, 2): I2C clock
+ \arg RCU_CANx (x = 0, 1): CAN clock
\arg RCU_PMU: PMU clock
\arg RCU_DAC: DAC clock
\arg RCU_RTC: RTC clock
- \arg RCU_ADCx (x=0,1,2): ADC clock
+ \arg RCU_ADCx (x = 0, 1, 2): ADC clock
\arg RCU_SDIO: SDIO clock
\arg RCU_SYSCFG: SYSCFG clock
\arg RCU_TLI: TLI clock
@@ -124,10 +127,10 @@ void rcu_periph_clock_enable(rcu_periph_enum periph)
}
/*!
- \brief disable the peripherals clock
+ \brief disable the peripherals clock
\param[in] periph: RCU peripherals, refer to rcu_periph_enum
only one parameter can be selected which is shown as below:
- \arg RCU_GPIOx (x=A,B,C,D,E,F,G,H,I): GPIO ports clock
+ \arg RCU_GPIOx (x = A, B, C, D, E, F, G, H, I): GPIO ports clock
\arg RCU_CRC: CRC clock
\arg RCU_BKPSRAM: BKPSRAM clock
\arg RCU_TCMSRAM: TCMSRAM clock
@@ -143,17 +146,17 @@ void rcu_periph_clock_enable(rcu_periph_enum periph)
\arg RCU_TRNG: TRNG clock
\arg RCU_USBFS: USBFS clock
\arg RCU_EXMC: EXMC clock
- \arg RCU_TIMERx (x=0,1,2,3,4,5,6,7,8,9,10,11,12,13): TIMER clock
+ \arg RCU_TIMERx (x = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13): TIMER clock
\arg RCU_WWDGT: WWDGT clock
- \arg RCU_SPIx (x=0,1,2,3,4,5): SPI clock
- \arg RCU_USARTx (x=0,1,2,5): USART clock
- \arg RCU_UARTx (x=3,4,6,7): UART clock
- \arg RCU_I2Cx (x=0,1,2): I2C clock
- \arg RCU_CANx (x=0,1): CAN clock
+ \arg RCU_SPIx (x = 0, 1, 2, 3, 4, 5): SPI clock
+ \arg RCU_USARTx (x = 0, 1, 2, 5): USART clock
+ \arg RCU_UARTx (x = 3, 4, 6, 7): UART clock
+ \arg RCU_I2Cx (x = 0, 1, 2): I2C clock
+ \arg RCU_CANx (x = 0, 1): CAN clock
\arg RCU_PMU: PMU clock
\arg RCU_DAC: DAC clock
\arg RCU_RTC: RTC clock
- \arg RCU_ADCx (x=0,1,2): ADC clock
+ \arg RCU_ADCx (x = 0, 1, 2): ADC clock
\arg RCU_SDIO: SDIO clock
\arg RCU_SYSCFG: SYSCFG clock
\arg RCU_TLI: TLI clock
@@ -168,10 +171,10 @@ void rcu_periph_clock_disable(rcu_periph_enum periph)
}
/*!
- \brief enable the peripherals clock when sleep mode
+ \brief enable the peripherals clock when sleep mode
\param[in] periph: RCU peripherals, refer to rcu_periph_sleep_enum
only one parameter can be selected which is shown as below:
- \arg RCU_GPIOx_SLP (x=A,B,C,D,E,F,G,H,I): GPIO ports clock
+ \arg RCU_GPIOx_SLP (x = A, B, C, D, E, F, G, H, I): GPIO ports clock
\arg RCU_CRC_SLP: CRC clock
\arg RCU_FMC_SLP: FMC clock
\arg RCU_SRAM0_SLP: SRAM0 clock
@@ -190,17 +193,17 @@ void rcu_periph_clock_disable(rcu_periph_enum periph)
\arg RCU_TRNG_SLP: TRNG clock
\arg RCU_USBFS_SLP: USBFS clock
\arg RCU_EXMC_SLP: EXMC clock
- \arg RCU_TIMERx_SLP (x=0,1,2,3,4,5,6,7,8,9,10,11,12,13): TIMER clock
+ \arg RCU_TIMERx_SLP (x = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13): TIMER clock
\arg RCU_WWDGT_SLP: WWDGT clock
- \arg RCU_SPIx_SLP (x=0,1,2,3,4,5): SPI clock
- \arg RCU_USARTx_SLP (x=0,1,2,5): USART clock
- \arg RCU_UARTx_SLP (x=3,4,6,7): UART clock
- \arg RCU_I2Cx_SLP (x=0,1,2): I2C clock
- \arg RCU_CANx_SLP (x=0,1): CAN clock
+ \arg RCU_SPIx_SLP (x = 0, 1, 2, 3, 4, 5): SPI clock
+ \arg RCU_USARTx_SLP (x = 0, 1, 2, 5): USART clock
+ \arg RCU_UARTx_SLP (x = 3, 4, 6, 7): UART clock
+ \arg RCU_I2Cx_SLP (x = 0, 1, 2): I2C clock
+ \arg RCU_CANx_SLP (x = 0, 1): CAN clock
\arg RCU_PMU_SLP: PMU clock
\arg RCU_DAC_SLP: DAC clock
\arg RCU_RTC_SLP: RTC clock
- \arg RCU_ADCx_SLP (x=0,1,2): ADC clock
+ \arg RCU_ADCx_SLP (x = 0, 1, 2): ADC clock
\arg RCU_SDIO_SLP: SDIO clock
\arg RCU_SYSCFG_SLP: SYSCFG clock
\arg RCU_TLI_SLP: TLI clock
@@ -215,10 +218,10 @@ void rcu_periph_clock_sleep_enable(rcu_periph_sleep_enum periph)
}
/*!
- \brief disable the peripherals clock when sleep mode
+ \brief disable the peripherals clock when sleep mode
\param[in] periph: RCU peripherals, refer to rcu_periph_sleep_enum
only one parameter can be selected which is shown as below:
- \arg RCU_GPIOx_SLP (x=A,B,C,D,E,F,G,H,I): GPIO ports clock
+ \arg RCU_GPIOx_SLP (x = A, B, C, D, E, F, G, H, I): GPIO ports clock
\arg RCU_CRC_SLP: CRC clock
\arg RCU_FMC_SLP: FMC clock
\arg RCU_SRAM0_SLP: SRAM0 clock
@@ -237,17 +240,17 @@ void rcu_periph_clock_sleep_enable(rcu_periph_sleep_enum periph)
\arg RCU_TRNG_SLP: TRNG clock
\arg RCU_USBFS_SLP: USBFS clock
\arg RCU_EXMC_SLP: EXMC clock
- \arg RCU_TIMERx_SLP (x=0,1,2,3,4,5,6,7,8,9,10,11,12,13): TIMER clock
+ \arg RCU_TIMERx_SLP (x = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13): TIMER clock
\arg RCU_WWDGT_SLP: WWDGT clock
- \arg RCU_SPIx_SLP (x=0,1,2,3,4,5): SPI clock
- \arg RCU_USARTx_SLP (x=0,1,2,5): USART clock
- \arg RCU_UARTx_SLP (x=3,4,6,7): UART clock
- \arg RCU_I2Cx_SLP (x=0,1,2): I2C clock
- \arg RCU_CANx_SLP (x=0,1): CAN clock
+ \arg RCU_SPIx_SLP (x = 0, 1, 2, 3, 4, 5): SPI clock
+ \arg RCU_USARTx_SLP (x = 0, 1, 2, 5): USART clock
+ \arg RCU_UARTx_SLP (x = 3, 4, 6, 7): UART clock
+ \arg RCU_I2Cx_SLP (x = 0, 1, 2): I2C clock
+ \arg RCU_CANx_SLP (x = 0, 1): CAN clock
\arg RCU_PMU_SLP: PMU clock
\arg RCU_DAC_SLP: DAC clock
\arg RCU_RTC_SLP: RTC clock
- \arg RCU_ADCx_SLP (x=0,1,2): ADC clock
+ \arg RCU_ADCx_SLP (x = 0, 1, 2): ADC clock
\arg RCU_SDIO_SLP: SDIO clock
\arg RCU_SYSCFG_SLP: SYSCFG clock
\arg RCU_TLI_SLP: TLI clock
@@ -262,10 +265,10 @@ void rcu_periph_clock_sleep_disable(rcu_periph_sleep_enum periph)
}
/*!
- \brief reset the peripherals
+ \brief reset the peripherals
\param[in] periph_reset: RCU peripherals reset, refer to rcu_periph_reset_enum
only one parameter can be selected which is shown as below:
- \arg RCU_GPIOxRST (x=A,B,C,D,E,F,G,H,I): reset GPIO ports
+ \arg RCU_GPIOxRST (x = A, B, C, D, E, F, G, H, I): reset GPIO ports
\arg RCU_CRCRST: reset CRC
\arg RCU_DMAxRST (x=0,1): reset DMA
\arg RCU_IPARST: reset IPA
@@ -275,16 +278,16 @@ void rcu_periph_clock_sleep_disable(rcu_periph_sleep_enum periph)
\arg RCU_TRNGRST: reset TRNG
\arg RCU_USBFSRST: reset USBFS
\arg RCU_EXMCRST: reset EXMC
- \arg RCU_TIMERxRST (x=0,1,2,3,4,5,6,7,8,9,10,11,12,13): reset TIMER
+ \arg RCU_TIMERxRST (x = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13): reset TIMER
\arg RCU_WWDGTRST: reset WWDGT
- \arg RCU_SPIxRST (x=0,1,2,3,4,5): reset SPI
- \arg RCU_USARTxRST (x=0,1,2,5): reset USART
- \arg RCU_UARTxRST (x=3,4,6,7): reset UART
- \arg RCU_I2CxRST (x=0,1,2): reset I2C
- \arg RCU_CANxRST (x=0,1): reset CAN
+ \arg RCU_SPIxRST (x = 0, 1, 2, 3, 4, 5): reset SPI
+ \arg RCU_USARTxRST (x = 0, 1, 2, 5): reset USART
+ \arg RCU_UARTxRST (x = 3, 4, 6, 7): reset UART
+ \arg RCU_I2CxRST (x = 0, 1, 2): reset I2C
+ \arg RCU_CANxRST (x = 0, 1): reset CAN
\arg RCU_PMURST: reset PMU
\arg RCU_DACRST: reset DAC
- \arg RCU_ADCRST (x=0,1,2): reset ADC
+ \arg RCU_ADCRST (x = 0, 1, 2): reset ADC
\arg RCU_SDIORST: reset SDIO
\arg RCU_SYSCFGRST: reset SYSCFG
\arg RCU_TLIRST: reset TLI
@@ -299,10 +302,10 @@ void rcu_periph_reset_enable(rcu_periph_reset_enum periph_reset)
}
/*!
- \brief disable reset the peripheral
+ \brief disable reset the peripheral
\param[in] periph_reset: RCU peripherals reset, refer to rcu_periph_reset_enum
only one parameter can be selected which is shown as below:
- \arg RCU_GPIOxRST (x=A,B,C,D,E,F,G,H,I): reset GPIO ports
+ \arg RCU_GPIOxRST (x = A, B, C, D, E, F, G, H, I): reset GPIO ports
\arg RCU_CRCRST: reset CRC
\arg RCU_DMAxRST (x=0,1): reset DMA
\arg RCU_IPARST: reset IPA
@@ -312,16 +315,16 @@ void rcu_periph_reset_enable(rcu_periph_reset_enum periph_reset)
\arg RCU_TRNGRST: reset TRNG
\arg RCU_USBFSRST: reset USBFS
\arg RCU_EXMCRST: reset EXMC
- \arg RCU_TIMERxRST (x=0,1,2,3,4,5,6,7,8,9,10,11,12,13): reset TIMER
+ \arg RCU_TIMERxRST (x = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13): reset TIMER
\arg RCU_WWDGTRST: reset WWDGT
- \arg RCU_SPIxRST (x=0,1,2,3,4,5): reset SPI
- \arg RCU_USARTxRST (x=0,1,2,5): reset USART
- \arg RCU_UARTxRST (x=3,4,6,7): reset UART
- \arg RCU_I2CxRST (x=0,1,2): reset I2C
- \arg RCU_CANxRST (x=0,1): reset CAN
+ \arg RCU_SPIxRST (x = 0, 1, 2, 3, 4, 5): reset SPI
+ \arg RCU_USARTxRST (x = 0, 1, 2, 5): reset USART
+ \arg RCU_UARTxRST (x = 3, 4, 6, 7): reset UART
+ \arg RCU_I2CxRST (x = 0, 1, 2): reset I2C
+ \arg RCU_CANxRST (x = 0, 1): reset CAN
\arg RCU_PMURST: reset PMU
\arg RCU_DACRST: reset DAC
- \arg RCU_ADCRST (x=0,1,2): reset ADC
+ \arg RCU_ADCRST (x = 0, 1, 2): reset ADC
\arg RCU_SDIORST: reset SDIO
\arg RCU_SYSCFGRST: reset SYSCFG
\arg RCU_TLIRST: reset TLI
@@ -336,7 +339,7 @@ void rcu_periph_reset_disable(rcu_periph_reset_enum periph_reset)
}
/*!
- \brief reset the BKP
+ \brief reset the BKP
\param[in] none
\param[out] none
\retval none
@@ -347,7 +350,7 @@ void rcu_bkp_reset_enable(void)
}
/*!
- \brief disable the BKP reset
+ \brief disable the BKP reset
\param[in] none
\param[out] none
\retval none
@@ -358,7 +361,7 @@ void rcu_bkp_reset_disable(void)
}
/*!
- \brief configure the system clock source
+ \brief configure the system clock source
\param[in] ck_sys: system clock source select
only one parameter can be selected which is shown as below:
\arg RCU_CKSYSSRC_IRC16M: select CK_IRC16M as the CK_SYS source
@@ -378,7 +381,7 @@ void rcu_system_clock_source_config(uint32_t ck_sys)
}
/*!
- \brief get the system clock source
+ \brief get the system clock source
\param[in] none
\param[out] none
\retval which clock is selected as CK_SYS source
@@ -392,10 +395,10 @@ uint32_t rcu_system_clock_source_get(void)
}
/*!
- \brief configure the AHB clock prescaler selection
+ \brief configure the AHB clock prescaler selection
\param[in] ck_ahb: AHB clock prescaler selection
only one parameter can be selected which is shown as below:
- \arg RCU_AHB_CKSYS_DIVx, x=1, 2, 4, 8, 16, 64, 128, 256, 512
+ \arg RCU_AHB_CKSYS_DIVx (x = 1, 2, 4, 8, 16, 64, 128, 256, 512): select CK_SYS / x as CK_AHB
\param[out] none
\retval none
*/
@@ -410,14 +413,14 @@ void rcu_ahb_clock_config(uint32_t ck_ahb)
}
/*!
- \brief configure the APB1 clock prescaler selection
+ \brief configure the APB1 clock prescaler selection
\param[in] ck_apb1: APB1 clock prescaler selection
only one parameter can be selected which is shown as below:
\arg RCU_APB1_CKAHB_DIV1: select CK_AHB as CK_APB1
- \arg RCU_APB1_CKAHB_DIV2: select CK_AHB/2 as CK_APB1
- \arg RCU_APB1_CKAHB_DIV4: select CK_AHB/4 as CK_APB1
- \arg RCU_APB1_CKAHB_DIV8: select CK_AHB/8 as CK_APB1
- \arg RCU_APB1_CKAHB_DIV16: select CK_AHB/16 as CK_APB1
+ \arg RCU_APB1_CKAHB_DIV2: select CK_AHB / 2 as CK_APB1
+ \arg RCU_APB1_CKAHB_DIV4: select CK_AHB / 4 as CK_APB1
+ \arg RCU_APB1_CKAHB_DIV8: select CK_AHB / 8 as CK_APB1
+ \arg RCU_APB1_CKAHB_DIV16: select CK_AHB / 16 as CK_APB1
\param[out] none
\retval none
*/
@@ -432,14 +435,14 @@ void rcu_apb1_clock_config(uint32_t ck_apb1)
}
/*!
- \brief configure the APB2 clock prescaler selection
+ \brief configure the APB2 clock prescaler selection
\param[in] ck_apb2: APB2 clock prescaler selection
only one parameter can be selected which is shown as below:
\arg RCU_APB2_CKAHB_DIV1: select CK_AHB as CK_APB2
- \arg RCU_APB2_CKAHB_DIV2: select CK_AHB/2 as CK_APB2
- \arg RCU_APB2_CKAHB_DIV4: select CK_AHB/4 as CK_APB2
- \arg RCU_APB2_CKAHB_DIV8: select CK_AHB/8 as CK_APB2
- \arg RCU_APB2_CKAHB_DIV16: select CK_AHB/16 as CK_APB2
+ \arg RCU_APB2_CKAHB_DIV2: select CK_AHB / 2 as CK_APB2
+ \arg RCU_APB2_CKAHB_DIV4: select CK_AHB / 4 as CK_APB2
+ \arg RCU_APB2_CKAHB_DIV8: select CK_AHB / 8 as CK_APB2
+ \arg RCU_APB2_CKAHB_DIV16: select CK_AHB / 16 as CK_APB2
\param[out] none
\retval none
*/
@@ -454,7 +457,7 @@ void rcu_apb2_clock_config(uint32_t ck_apb2)
}
/*!
- \brief configure the CK_OUT0 clock source and divider
+ \brief configure the CK_OUT0 clock source and divider
\param[in] ckout0_src: CK_OUT0 clock source selection
only one parameter can be selected which is shown as below:
\arg RCU_CKOUT0SRC_IRC16M: IRC16M selected
@@ -462,7 +465,7 @@ void rcu_apb2_clock_config(uint32_t ck_apb2)
\arg RCU_CKOUT0SRC_HXTAL: HXTAL selected
\arg RCU_CKOUT0SRC_PLLP: PLLP selected
\param[in] ckout0_div: CK_OUT0 divider
- \arg RCU_CKOUT0_DIVx(x=1,2,3,4,5): CK_OUT0 is divided by x
+ \arg RCU_CKOUT0_DIVx(x = 1, 2, 3, 4, 5): CK_OUT0 is divided by x
\param[out] none
\retval none
*/
@@ -472,12 +475,12 @@ void rcu_ckout0_config(uint32_t ckout0_src, uint32_t ckout0_div)
reg = RCU_CFG0;
/* reset the CKOUT0SRC, CKOUT0DIV and set according to ckout0_src and ckout0_div */
- reg &= ~(RCU_CFG0_CKOUT0SEL | RCU_CFG0_CKOUT0DIV );
+ reg &= ~(RCU_CFG0_CKOUT0SEL | RCU_CFG0_CKOUT0DIV);
RCU_CFG0 = (reg | ckout0_src | ckout0_div);
}
/*!
- \brief configure the CK_OUT1 clock source and divider
+ \brief configure the CK_OUT1 clock source and divider
\param[in] ckout1_src: CK_OUT1 clock source selection
only one parameter can be selected which is shown as below:
\arg RCU_CKOUT1SRC_SYSTEMCLOCK: system clock selected
@@ -485,7 +488,7 @@ void rcu_ckout0_config(uint32_t ckout0_src, uint32_t ckout0_div)
\arg RCU_CKOUT1SRC_HXTAL: HXTAL selected
\arg RCU_CKOUT1SRC_PLLP: PLLP selected
\param[in] ckout1_div: CK_OUT1 divider
- \arg RCU_CKOUT1_DIVx(x=1,2,3,4,5): CK_OUT1 is divided by x
+ \arg RCU_CKOUT1_DIVx(x = 1, 2, 3, 4, 5): CK_OUT1 is divided by x
\param[out] none
\retval none
*/
@@ -500,7 +503,7 @@ void rcu_ckout1_config(uint32_t ckout1_src, uint32_t ckout1_div)
}
/*!
- \brief configure the main PLL clock
+ \brief configure the main PLL clock
\param[in] pll_src: PLL clock source selection
\arg RCU_PLLSRC_IRC16M: select IRC16M as PLL source clock
\arg RCU_PLLSRC_HXTAL: select HXTAL as PLL source clock
@@ -524,20 +527,20 @@ ErrStatus rcu_pll_config(uint32_t pll_src, uint32_t pll_psc, uint32_t pll_n, uin
ss_modulation_reg = RCU_PLLSSCTL;
/* calculate the minimum factor of PLLN */
- if((ss_modulation_reg & RCU_PLLSSCTL_SSCGON) == RCU_PLLSSCTL_SSCGON){
- if((ss_modulation_reg & RCU_SS_TYPE_DOWN) == RCU_SS_TYPE_DOWN){
+ if((ss_modulation_reg & RCU_PLLSSCTL_SSCGON) == RCU_PLLSSCTL_SSCGON) {
+ if((ss_modulation_reg & RCU_SS_TYPE_DOWN) == RCU_SS_TYPE_DOWN) {
ss_modulation_inc += RCU_SS_MODULATION_DOWN_INC;
- }else{
+ } else {
ss_modulation_inc += RCU_SS_MODULATION_CENTER_INC;
}
}
/* check the function parameter */
- if(CHECK_PLL_PSC_VALID(pll_psc) && CHECK_PLL_N_VALID(pll_n,ss_modulation_inc) &&
- CHECK_PLL_P_VALID(pll_p) && CHECK_PLL_Q_VALID(pll_q)){
- RCU_PLL = pll_psc | (pll_n << 6) | (((pll_p >> 1) - 1U) << 16) |
- (pll_src) | (pll_q << 24);
- }else{
+ if(CHECK_PLL_PSC_VALID(pll_psc) && CHECK_PLL_N_VALID(pll_n, ss_modulation_inc) &&
+ CHECK_PLL_P_VALID(pll_p) && CHECK_PLL_Q_VALID(pll_q)) {
+ RCU_PLL = pll_psc | (pll_n << 6) | (((pll_p >> 1) - 1U) << 16) |
+ (pll_src) | (pll_q << 24);
+ } else {
/* return status */
return ERROR;
}
@@ -547,7 +550,7 @@ ErrStatus rcu_pll_config(uint32_t pll_src, uint32_t pll_psc, uint32_t pll_n, uin
}
/*!
- \brief configure the PLLI2S clock
+ \brief configure the PLLI2S clock
\param[in] plli2s_n: the PLLI2S VCO clock multi factor
\arg this parameter should be selected between 50 and 500
\param[in] plli2s_r: the PLLI2S R output frequency division factor from PLLI2S VCO clock
@@ -558,9 +561,9 @@ ErrStatus rcu_pll_config(uint32_t pll_src, uint32_t pll_psc, uint32_t pll_n, uin
ErrStatus rcu_plli2s_config(uint32_t plli2s_n, uint32_t plli2s_r)
{
/* check the function parameter */
- if(CHECK_PLLI2S_N_VALID(plli2s_n) && CHECK_PLLI2S_R_VALID(plli2s_r)){
+ if(CHECK_PLLI2S_N_VALID(plli2s_n) && CHECK_PLLI2S_R_VALID(plli2s_r)) {
RCU_PLLI2S = (plli2s_n << 6) | (plli2s_r << 28);
- }else{
+ } else {
/* return status */
return ERROR;
}
@@ -570,7 +573,7 @@ ErrStatus rcu_plli2s_config(uint32_t plli2s_n, uint32_t plli2s_r)
}
/*!
- \brief configure the PLLSAI clock
+ \brief configure the PLLSAI clock
\param[in] pllsai_n: the PLLSAI VCO clock multi factor
\arg this parameter should be selected between 50 and 500
\param[in] pllsai_p: the PLLSAI P output frequency division factor from PLL VCO clock
@@ -583,9 +586,9 @@ ErrStatus rcu_plli2s_config(uint32_t plli2s_n, uint32_t plli2s_r)
ErrStatus rcu_pllsai_config(uint32_t pllsai_n, uint32_t pllsai_p, uint32_t pllsai_r)
{
/* check the function parameter */
- if(CHECK_PLLSAI_N_VALID(pllsai_n) && CHECK_PLLSAI_P_VALID(pllsai_p) && CHECK_PLLSAI_R_VALID(pllsai_r)){
+ if(CHECK_PLLSAI_N_VALID(pllsai_n) && CHECK_PLLSAI_P_VALID(pllsai_p) && CHECK_PLLSAI_R_VALID(pllsai_r)) {
RCU_PLLSAI = (pllsai_n << 6U) | (((pllsai_p >> 1U) - 1U) << 16U) | (pllsai_r << 28U);
- }else{
+ } else {
/* return status */
return ERROR;
}
@@ -595,13 +598,13 @@ ErrStatus rcu_pllsai_config(uint32_t pllsai_n, uint32_t pllsai_p, uint32_t pllsa
}
/*!
- \brief configure the RTC clock source selection
+ \brief configure the RTC clock source selection
\param[in] rtc_clock_source: RTC clock source selection
only one parameter can be selected which is shown as below:
\arg RCU_RTCSRC_NONE: no clock selected
\arg RCU_RTCSRC_LXTAL: CK_LXTAL selected as RTC source clock
\arg RCU_RTCSRC_IRC32K: CK_IRC32K selected as RTC source clock
- \arg RCU_RTCSRC_HXTAL_DIV_RTCDIV: CK_HXTAL/RTCDIV selected as RTC source clock
+ \arg RCU_RTCSRC_HXTAL_DIV_RTCDIV: CK_HXTAL / RTCDIV selected as RTC source clock
\param[out] none
\retval none
*/
@@ -616,11 +619,11 @@ void rcu_rtc_clock_config(uint32_t rtc_clock_source)
}
/*!
- \brief configure the frequency division of RTC clock when HXTAL was selected as its clock source
+ \brief configure the frequency division of RTC clock when HXTAL was selected as its clock source
\param[in] rtc_div: RTC clock frequency division
only one parameter can be selected which is shown as below:
\arg RCU_RTC_HXTAL_NONE: no clock for RTC
- \arg RCU_RTC_HXTAL_DIVx: RTCDIV clock select CK_HXTAL/x, x = 2....31
+ \arg RCU_RTC_HXTAL_DIVx: RTCDIV clock select CK_HXTAL / x, x = 2....31
\param[out] none
\retval none
*/
@@ -636,7 +639,7 @@ void rcu_rtc_div_config(uint32_t rtc_div)
/*!
- \brief configure the I2S clock source selection
+ \brief configure the I2S clock source selection
\param[in] i2s_clock_source: I2S clock source selection
only one parameter can be selected which is shown as below:
\arg RCU_I2SSRC_PLLI2S: CK_PLLI2S selected as I2S source clock
@@ -655,7 +658,7 @@ void rcu_i2s_clock_config(uint32_t i2s_clock_source)
}
/*!
- \brief configure the CK48M clock source selection
+ \brief configure the CK48M clock source selection
\param[in] ck48m_clock_source: CK48M clock source selection
only one parameter can be selected which is shown as below:
\arg RCU_CK48MSRC_PLL48M: CK_PLL48M selected as CK48M source clock
@@ -674,7 +677,7 @@ void rcu_ck48m_clock_config(uint32_t ck48m_clock_source)
}
/*!
- \brief configure the PLL48M clock source selection
+ \brief configure the PLL48M clock source selection
\param[in] pll48m_clock_source: PLL48M clock source selection
only one parameter can be selected which is shown as below:
\arg RCU_PLL48MSRC_PLLQ: CK_PLLQ selected as PLL48M source clock
@@ -693,7 +696,7 @@ void rcu_pll48m_clock_config(uint32_t pll48m_clock_source)
}
/*!
- \brief configure the TIMER clock prescaler selection
+ \brief configure the TIMER clock prescaler selection
\param[in] timer_clock_prescaler: TIMER clock selection
only one parameter can be selected which is shown as below:
\arg RCU_TIMER_PSC_MUL2: if APB1PSC/APB2PSC in RCU_CFG0 register is 0b0xx(CK_APBx = CK_AHB)
@@ -710,15 +713,15 @@ void rcu_pll48m_clock_config(uint32_t pll48m_clock_source)
void rcu_timer_clock_prescaler_config(uint32_t timer_clock_prescaler)
{
/* configure the TIMERSEL bit and select the TIMER clock prescaler */
- if(timer_clock_prescaler == RCU_TIMER_PSC_MUL2){
+ if(timer_clock_prescaler == RCU_TIMER_PSC_MUL2) {
RCU_CFG1 &= timer_clock_prescaler;
- }else{
+ } else {
RCU_CFG1 |= timer_clock_prescaler;
}
}
/*!
- \brief configure the PLLSAIR divider used as input of TLI
+ \brief configure the PLLSAIR divider used as input of TLI
\param[in] pllsai_r_div: PLLSAIR divider used as input of TLI
only one parameter can be selected which is shown as below:
\arg RCU_PLLSAIR_DIVx(x=2,4,8,16): PLLSAIR divided x used as input of TLI
@@ -736,138 +739,7 @@ void rcu_tli_clock_div_config(uint32_t pllsai_r_div)
}
/*!
- \brief get the clock stabilization and periphral reset flags
- \param[in] flag: the clock stabilization and periphral reset flags, refer to rcu_flag_enum
- only one parameter can be selected which is shown as below:
- \arg RCU_FLAG_IRC16MSTB: IRC16M stabilization flag
- \arg RCU_FLAG_HXTALSTB: HXTAL stabilization flag
- \arg RCU_FLAG_PLLSTB: PLL stabilization flag
- \arg RCU_FLAG_PLLI2SSTB: PLLI2S stabilization flag
- \arg RCU_FLAG_PLLSAISTB: PLLSAI stabilization flag
- \arg RCU_FLAG_LXTALSTB: LXTAL stabilization flag
- \arg RCU_FLAG_IRC32KSTB: IRC32K stabilization flag
- \arg RCU_FLAG_IRC48MSTB: IRC48M stabilization flag
- \arg RCU_FLAG_BORRST: BOR reset flags
- \arg RCU_FLAG_EPRST: external PIN reset flag
- \arg RCU_FLAG_PORRST: Power reset flag
- \arg RCU_FLAG_SWRST: software reset flag
- \arg RCU_FLAG_FWDGTRST: free watchdog timer reset flag
- \arg RCU_FLAG_WWDGTRST: window watchdog timer reset flag
- \arg RCU_FLAG_LPRST: low-power reset flag
- \param[out] none
- \retval none
-*/
-FlagStatus rcu_flag_get(rcu_flag_enum flag)
-{
- /* get the rcu flag */
- if(RESET != (RCU_REG_VAL(flag) & BIT(RCU_BIT_POS(flag)))){
- return SET;
- }else{
- return RESET;
- }
-}
-
-/*!
- \brief clear all the reset flag
- \param[in] none
- \param[out] none
- \retval none
-*/
-void rcu_all_reset_flag_clear(void)
-{
- RCU_RSTSCK |= RCU_RSTSCK_RSTFC;
-}
-
-/*!
- \brief get the clock stabilization interrupt and ckm flags
- \param[in] int_flag: interrupt and ckm flags, refer to rcu_int_flag_enum
- only one parameter can be selected which is shown as below:
- \arg RCU_INT_FLAG_IRC32KSTB: IRC32K stabilization interrupt flag
- \arg RCU_INT_FLAG_LXTALSTB: LXTAL stabilization interrupt flag
- \arg RCU_INT_FLAG_IRC16MSTB: IRC16M stabilization interrupt flag
- \arg RCU_INT_FLAG_HXTALSTB: HXTAL stabilization interrupt flag
- \arg RCU_INT_FLAG_PLLSTB: PLL stabilization interrupt flag
- \arg RCU_INT_FLAG_PLLI2SSTB: PLLI2S stabilization interrupt flag
- \arg RCU_INT_FLAG_PLLSAISTB: PLLSAI stabilization interrupt flag
- \arg RCU_INT_FLAG_CKM: HXTAL clock stuck interrupt flag
- \arg RCU_INT_FLAG_IRC48MSTB: IRC48M stabilization interrupt flag
- \param[out] none
- \retval FlagStatus: SET or RESET
-*/
-FlagStatus rcu_interrupt_flag_get(rcu_int_flag_enum int_flag)
-{
- /* get the rcu interrupt flag */
- if(RESET != (RCU_REG_VAL(int_flag) & BIT(RCU_BIT_POS(int_flag)))){
- return SET;
- }else{
- return RESET;
- }
-}
-
-/*!
- \brief clear the interrupt flags
- \param[in] int_flag: clock stabilization and stuck interrupt flags clear, refer to rcu_int_flag_clear_enum
- only one parameter can be selected which is shown as below:
- \arg RCU_INT_FLAG_IRC32KSTB_CLR: IRC32K stabilization interrupt flag clear
- \arg RCU_INT_FLAG_LXTALSTB_CLR: LXTAL stabilization interrupt flag clear
- \arg RCU_INT_FLAG_IRC16MSTB_CLR: IRC16M stabilization interrupt flag clear
- \arg RCU_INT_FLAG_HXTALSTB_CLR: HXTAL stabilization interrupt flag clear
- \arg RCU_INT_FLAG_PLLSTB_CLR: PLL stabilization interrupt flag clear
- \arg RCU_INT_FLAG_PLLI2SSTB_CLR: PLLI2S stabilization interrupt flag clear
- \arg RCU_INT_FLAG_PLLSAISTB_CLR: PLLSAI stabilization interrupt flag clear
- \arg RCU_INT_FLAG_CKM_CLR: clock stuck interrupt flag clear
- \arg RCU_INT_FLAG_IRC48MSTB_CLR: IRC48M stabilization interrupt flag clear
- \param[out] none
- \retval none
-*/
-void rcu_interrupt_flag_clear(rcu_int_flag_clear_enum int_flag)
-{
- RCU_REG_VAL(int_flag) |= BIT(RCU_BIT_POS(int_flag));
-}
-
-/*!
- \brief enable the stabilization interrupt
- \param[in] interrupt: clock stabilization interrupt, refer to rcu_int_enum
- Only one parameter can be selected which is shown as below:
- \arg RCU_INT_IRC32KSTB: IRC32K stabilization interrupt enable
- \arg RCU_INT_LXTALSTB: LXTAL stabilization interrupt enable
- \arg RCU_INT_IRC16MSTB: IRC16M stabilization interrupt enable
- \arg RCU_INT_HXTALSTB: HXTAL stabilization interrupt enable
- \arg RCU_INT_PLLSTB: PLL stabilization interrupt enable
- \arg RCU_INT_PLLI2SSTB: PLLI2S stabilization interrupt enable
- \arg RCU_INT_PLLSAISTB: PLLSAI stabilization interrupt enable
- \arg RCU_INT_IRC48MSTB: IRC48M stabilization interrupt enable
- \param[out] none
- \retval none
-*/
-void rcu_interrupt_enable(rcu_int_enum interrupt)
-{
- RCU_REG_VAL(interrupt) |= BIT(RCU_BIT_POS(interrupt));
-}
-
-
-/*!
- \brief disable the stabilization interrupt
- \param[in] interrupt: clock stabilization interrupt, refer to rcu_int_enum
- only one parameter can be selected which is shown as below:
- \arg RCU_INT_IRC32KSTB: IRC32K stabilization interrupt disable
- \arg RCU_INT_LXTALSTB: LXTAL stabilization interrupt disable
- \arg RCU_INT_IRC16MSTB: IRC16M stabilization interrupt disable
- \arg RCU_INT_HXTALSTB: HXTAL stabilization interrupt disable
- \arg RCU_INT_PLLSTB: PLL stabilization interrupt disable
- \arg RCU_INT_PLLI2SSTB: PLLI2S stabilization interrupt disable
- \arg RCU_INT_PLLSAISTB: PLLSAI stabilization interrupt disable
- \arg RCU_INT_IRC48MSTB: IRC48M stabilization interrupt disable
- \param[out] none
- \retval none
-*/
-void rcu_interrupt_disable(rcu_int_enum interrupt)
-{
- RCU_REG_VAL(interrupt) &= ~BIT(RCU_BIT_POS(interrupt));
-}
-
-/*!
- \brief configure the LXTAL drive capability
+ \brief configure the LXTAL drive capability
\param[in] lxtal_dricap: drive capability of LXTAL
only one parameter can be selected which is shown as below:
\arg RCU_LXTALDRI_LOWER_DRIVE: lower driving capability
@@ -887,7 +759,7 @@ void rcu_lxtal_drive_capability_config(uint32_t lxtal_dricap)
}
/*!
- \brief wait for oscillator stabilization flags is SET or oscillator startup is timeout
+ \brief wait for oscillator stabilization flags is SET or oscillator startup is timeout
\param[in] osci: oscillator types, refer to rcu_osci_type_enum
only one parameter can be selected which is shown as below:
\arg RCU_HXTAL: HXTAL
@@ -907,100 +779,100 @@ ErrStatus rcu_osci_stab_wait(rcu_osci_type_enum osci)
ErrStatus reval = ERROR;
FlagStatus osci_stat = RESET;
- switch(osci){
+ switch(osci) {
/* wait HXTAL stable */
case RCU_HXTAL:
- while((RESET == osci_stat) && (HXTAL_STARTUP_TIMEOUT != stb_cnt)){
+ while((RESET == osci_stat) && (HXTAL_STARTUP_TIMEOUT != stb_cnt)) {
osci_stat = rcu_flag_get(RCU_FLAG_HXTALSTB);
stb_cnt++;
}
/* check whether flag is set */
- if(RESET != rcu_flag_get(RCU_FLAG_HXTALSTB)){
+ if(RESET != rcu_flag_get(RCU_FLAG_HXTALSTB)) {
reval = SUCCESS;
}
break;
/* wait LXTAL stable */
case RCU_LXTAL:
- while((RESET == osci_stat) && (LXTAL_STARTUP_TIMEOUT != stb_cnt)){
+ while((RESET == osci_stat) && (LXTAL_STARTUP_TIMEOUT != stb_cnt)) {
osci_stat = rcu_flag_get(RCU_FLAG_LXTALSTB);
stb_cnt++;
}
/* check whether flag is set */
- if(RESET != rcu_flag_get(RCU_FLAG_LXTALSTB)){
+ if(RESET != rcu_flag_get(RCU_FLAG_LXTALSTB)) {
reval = SUCCESS;
}
break;
/* wait IRC16M stable */
case RCU_IRC16M:
- while((RESET == osci_stat) && (IRC16M_STARTUP_TIMEOUT != stb_cnt)){
+ while((RESET == osci_stat) && (IRC16M_STARTUP_TIMEOUT != stb_cnt)) {
osci_stat = rcu_flag_get(RCU_FLAG_IRC16MSTB);
stb_cnt++;
}
/* check whether flag is set */
- if(RESET != rcu_flag_get(RCU_FLAG_IRC16MSTB)){
+ if(RESET != rcu_flag_get(RCU_FLAG_IRC16MSTB)) {
reval = SUCCESS;
}
break;
/* wait IRC48M stable */
case RCU_IRC48M:
- while((RESET == osci_stat) && (OSC_STARTUP_TIMEOUT != stb_cnt)){
+ while((RESET == osci_stat) && (OSC_STARTUP_TIMEOUT != stb_cnt)) {
osci_stat = rcu_flag_get(RCU_FLAG_IRC48MSTB);
stb_cnt++;
}
/* check whether flag is set */
- if (RESET != rcu_flag_get(RCU_FLAG_IRC48MSTB)){
+ if(RESET != rcu_flag_get(RCU_FLAG_IRC48MSTB)) {
reval = SUCCESS;
}
break;
/* wait IRC32K stable */
case RCU_IRC32K:
- while((RESET == osci_stat) && (OSC_STARTUP_TIMEOUT != stb_cnt)){
+ while((RESET == osci_stat) && (OSC_STARTUP_TIMEOUT != stb_cnt)) {
osci_stat = rcu_flag_get(RCU_FLAG_IRC32KSTB);
stb_cnt++;
}
/* check whether flag is set */
- if(RESET != rcu_flag_get(RCU_FLAG_IRC32KSTB)){
+ if(RESET != rcu_flag_get(RCU_FLAG_IRC32KSTB)) {
reval = SUCCESS;
}
break;
/* wait PLL stable */
case RCU_PLL_CK:
- while((RESET == osci_stat) && (OSC_STARTUP_TIMEOUT != stb_cnt)){
+ while((RESET == osci_stat) && (OSC_STARTUP_TIMEOUT != stb_cnt)) {
osci_stat = rcu_flag_get(RCU_FLAG_PLLSTB);
stb_cnt++;
}
/* check whether flag is set */
- if(RESET != rcu_flag_get(RCU_FLAG_PLLSTB)){
+ if(RESET != rcu_flag_get(RCU_FLAG_PLLSTB)) {
reval = SUCCESS;
}
break;
/* wait PLLI2S stable */
case RCU_PLLI2S_CK:
- while((RESET == osci_stat) && (OSC_STARTUP_TIMEOUT != stb_cnt)){
+ while((RESET == osci_stat) && (OSC_STARTUP_TIMEOUT != stb_cnt)) {
osci_stat = rcu_flag_get(RCU_FLAG_PLLI2SSTB);
stb_cnt++;
}
/* check whether flag is set */
- if(RESET != rcu_flag_get(RCU_FLAG_PLLI2SSTB)){
+ if(RESET != rcu_flag_get(RCU_FLAG_PLLI2SSTB)) {
reval = SUCCESS;
}
break;
/* wait PLLSAI stable */
case RCU_PLLSAI_CK:
- while((RESET == osci_stat) && (OSC_STARTUP_TIMEOUT != stb_cnt)){
+ while((RESET == osci_stat) && (OSC_STARTUP_TIMEOUT != stb_cnt)) {
osci_stat = rcu_flag_get(RCU_FLAG_PLLSAISTB);
stb_cnt++;
}
/* check whether flag is set */
- if(RESET != rcu_flag_get(RCU_FLAG_PLLSAISTB)){
+ if(RESET != rcu_flag_get(RCU_FLAG_PLLSAISTB)) {
reval = SUCCESS;
}
break;
@@ -1014,7 +886,7 @@ ErrStatus rcu_osci_stab_wait(rcu_osci_type_enum osci)
}
/*!
- \brief turn on the oscillator
+ \brief turn on the oscillator
\param[in] osci: oscillator types, refer to rcu_osci_type_enum
only one parameter can be selected which is shown as below:
\arg RCU_HXTAL: HXTAL
@@ -1034,7 +906,7 @@ void rcu_osci_on(rcu_osci_type_enum osci)
}
/*!
- \brief turn off the oscillator
+ \brief turn off the oscillator
\param[in] osci: oscillator types, refer to rcu_osci_type_enum
only one parameter can be selected which is shown as below:
\arg RCU_HXTAL: HXTAL
@@ -1054,7 +926,7 @@ void rcu_osci_off(rcu_osci_type_enum osci)
}
/*!
- \brief enable the oscillator bypass mode, HXTALEN or LXTALEN must be reset before it
+ \brief enable the oscillator bypass mode, HXTALEN or LXTALEN must be reset before it
\param[in] osci: oscillator types, refer to rcu_osci_type_enum
only one parameter can be selected which is shown as below:
\arg RCU_HXTAL: high speed crystal oscillator(HXTAL)
@@ -1066,7 +938,7 @@ void rcu_osci_bypass_mode_enable(rcu_osci_type_enum osci)
{
uint32_t reg;
- switch(osci){
+ switch(osci) {
/* enable HXTAL to bypass mode */
case RCU_HXTAL:
reg = RCU_CTL;
@@ -1092,7 +964,7 @@ void rcu_osci_bypass_mode_enable(rcu_osci_type_enum osci)
}
/*!
- \brief disable the oscillator bypass mode, HXTALEN or LXTALEN must be reset before it
+ \brief disable the oscillator bypass mode, HXTALEN or LXTALEN must be reset before it
\param[in] osci: oscillator types, refer to rcu_osci_type_enum
only one parameter can be selected which is shown as below:
\arg RCU_HXTAL: high speed crystal oscillator(HXTAL)
@@ -1104,7 +976,7 @@ void rcu_osci_bypass_mode_disable(rcu_osci_type_enum osci)
{
uint32_t reg;
- switch(osci){
+ switch(osci) {
/* disable HXTAL to bypass mode */
case RCU_HXTAL:
reg = RCU_CTL;
@@ -1130,119 +1002,119 @@ void rcu_osci_bypass_mode_disable(rcu_osci_type_enum osci)
}
/*!
- \brief enable the HXTAL clock monitor
- \param[in] none
+ \brief set the IRC16M adjust value
+ \param[in] irc16m_adjval: IRC16M adjust value, must be between 0 and 0x1F
+ \arg 0x00 - 0x1F
\param[out] none
\retval none
*/
-
-void rcu_hxtal_clock_monitor_enable(void)
+void rcu_irc16m_adjust_value_set(uint32_t irc16m_adjval)
{
- RCU_CTL |= RCU_CTL_CKMEN;
+ uint32_t reg;
+
+ reg = RCU_CTL;
+ /* reset the IRC16MADJ bits and set according to irc16m_adjval */
+ reg &= ~RCU_CTL_IRC16MADJ;
+ RCU_CTL = (reg | ((irc16m_adjval & RCU_IRC16M_ADJUST_MASK) << RCU_IRC16M_ADJUST_OFFSET));
}
/*!
- \brief disable the HXTAL clock monitor
- \param[in] none
+ \brief configure the spread spectrum modulation for the main PLL clock
+ \param[in] spread_spectrum_type: PLL spread spectrum modulation type select
+ \arg RCU_SS_TYPE_CENTER: center spread type is selected
+ \arg RCU_SS_TYPE_DOWN: down spread type is selected
+ \param[in] modstep: configure PLL spread spectrum modulation profile amplitude and frequency
+ \arg This parameter should be selected between 0 and 7FFF.The following criteria must be met: MODSTEP*MODCNT <=2^15-1
+ \param[in] modcnt: configure PLL spread spectrum modulation profile amplitude and frequency
+ \arg This parameter should be selected between 0 and 1FFF.The following criteria must be met: MODSTEP*MODCNT <=2^15-1
\param[out] none
\retval none
*/
-void rcu_hxtal_clock_monitor_disable(void)
+void rcu_spread_spectrum_config(uint32_t spread_spectrum_type, uint32_t modstep, uint32_t modcnt)
{
- RCU_CTL &= ~RCU_CTL_CKMEN;
+ uint32_t reg;
+
+ reg = RCU_PLLSSCTL;
+ /* reset the RCU_PLLSSCTL register bits */
+ reg &= ~(RCU_PLLSSCTL_MODCNT | RCU_PLLSSCTL_MODSTEP | RCU_PLLSSCTL_SS_TYPE);
+ RCU_PLLSSCTL = (reg | spread_spectrum_type | modstep << 13 | modcnt);
}
/*!
- \brief set the IRC16M adjust value
- \param[in] irc16m_adjval: IRC16M adjust value, must be between 0 and 0x1F
- \arg 0x00 - 0x1F
+ \brief enable the PLL spread spectrum modulation
+ \param[in] none
\param[out] none
\retval none
*/
-void rcu_irc16m_adjust_value_set(uint32_t irc16m_adjval)
+void rcu_spread_spectrum_enable(void)
{
- uint32_t reg;
-
- reg = RCU_CTL;
- /* reset the IRC16MADJ bits and set according to irc16m_adjval */
- reg &= ~RCU_CTL_IRC16MADJ;
- RCU_CTL = (reg | ((irc16m_adjval & RCU_IRC16M_ADJUST_MASK) << RCU_IRC16M_ADJUST_OFFSET));
+ RCU_PLLSSCTL |= RCU_PLLSSCTL_SSCGON;
}
/*!
- \brief unlock the voltage key
+ \brief disable the PLL spread spectrum modulation
\param[in] none
\param[out] none
\retval none
*/
-void rcu_voltage_key_unlock(void)
+void rcu_spread_spectrum_disable(void)
{
- RCU_VKEY = RCU_VKEY_UNLOCK;
+ RCU_PLLSSCTL &= ~RCU_PLLSSCTL_SSCGON;
}
/*!
- \brief deep-sleep mode voltage select
- \param[in] dsvol: deep sleep mode voltage
- only one parameter can be selected which is shown as below:
- \arg RCU_DEEPSLEEP_V_1_2: the core voltage is 1.2V
- \arg RCU_DEEPSLEEP_V_1_1: the core voltage is 1.1V
- \arg RCU_DEEPSLEEP_V_1_0: the core voltage is 1.0V
- \arg RCU_DEEPSLEEP_V_0_9: the core voltage is 0.9V
+ \brief enable the HXTAL clock monitor
+ \param[in] none
\param[out] none
\retval none
*/
-void rcu_deepsleep_voltage_set(uint32_t dsvol)
+
+void rcu_hxtal_clock_monitor_enable(void)
{
- dsvol &= RCU_DSV_DSLPVS;
- RCU_DSV = dsvol;
+ RCU_CTL |= RCU_CTL_CKMEN;
}
/*!
- \brief configure the spread spectrum modulation for the main PLL clock
- \param[in] spread_spectrum_type: PLL spread spectrum modulation type select
- \arg RCU_SS_TYPE_CENTER: center spread type is selected
- \arg RCU_SS_TYPE_DOWN: down spread type is selected
- \param[in] modstep: configure PLL spread spectrum modulation profile amplitude and frequency
- \arg This parameter should be selected between 0 and 7FFF.The following criteria must be met: MODSTEP*MODCNT <=2^15-1
- \param[in] modcnt: configure PLL spread spectrum modulation profile amplitude and frequency
- \arg This parameter should be selected between 0 and 1FFF.The following criteria must be met: MODSTEP*MODCNT <=2^15-1
+ \brief disable the HXTAL clock monitor
+ \param[in] none
\param[out] none
\retval none
*/
-void rcu_spread_spectrum_config(uint32_t spread_spectrum_type, uint32_t modstep, uint32_t modcnt)
+void rcu_hxtal_clock_monitor_disable(void)
{
- uint32_t reg;
-
- reg = RCU_PLLSSCTL;
- /* reset the RCU_PLLSSCTL register bits */
- reg &= ~(RCU_PLLSSCTL_MODCNT | RCU_PLLSSCTL_MODSTEP | RCU_PLLSSCTL_SS_TYPE);
- RCU_PLLSSCTL = (reg | spread_spectrum_type | modstep << 13 | modcnt);
+ RCU_CTL &= ~RCU_CTL_CKMEN;
}
/*!
- \brief enable the PLL spread spectrum modulation
+ \brief unlock the voltage key
\param[in] none
\param[out] none
\retval none
*/
-void rcu_spread_spectrum_enable(void)
+void rcu_voltage_key_unlock(void)
{
- RCU_PLLSSCTL |= RCU_PLLSSCTL_SSCGON;
+ RCU_VKEY = RCU_VKEY_UNLOCK;
}
/*!
- \brief disable the PLL spread spectrum modulation
- \param[in] none
+ \brief deep-sleep mode voltage select
+ \param[in] dsvol: deep sleep mode voltage
+ only one parameter can be selected which is shown as below:
+ \arg RCU_DEEPSLEEP_V_0: the core voltage is default value
+ \arg RCU_DEEPSLEEP_V_1: the core voltage is (default value-0.1)V(customers are not recommended to use it)
+ \arg RCU_DEEPSLEEP_V_2: the core voltage is (default value-0.2)V(customers are not recommended to use it)
+ \arg RCU_DEEPSLEEP_V_3: the core voltage is (default value-0.3)V(customers are not recommended to use it)
\param[out] none
\retval none
*/
-void rcu_spread_spectrum_disable(void)
+void rcu_deepsleep_voltage_set(uint32_t dsvol)
{
- RCU_PLLSSCTL &= ~RCU_PLLSSCTL_SSCGON;
+ dsvol &= RCU_DSV_DSLPVS;
+ RCU_DSV = dsvol;
}
/*!
- \brief get the system clock, bus and peripheral clock frequency
+ \brief get the system clock, bus and peripheral clock frequency
\param[in] clock: the clock frequency which to get
only one parameter can be selected which is shown as below:
\arg CK_SYS: system clock frequency
@@ -1264,7 +1136,7 @@ uint32_t rcu_clock_freq_get(rcu_clock_freq_enum clock)
const uint8_t apb2_exp[8] = {0, 0, 0, 0, 1, 2, 3, 4};
sws = GET_BITS(RCU_CFG0, 2, 3);
- switch(sws){
+ switch(sws) {
/* IRC16M is selected as CK_SYS */
case SEL_IRC16M:
cksys_freq = IRC16M_VALUE;
@@ -1281,12 +1153,12 @@ uint32_t rcu_clock_freq_get(rcu_clock_freq_enum clock)
pllp = (GET_BITS(RCU_PLL, 16U, 17U) + 1U) * 2U;
/* PLL clock source selection, HXTAL or IRC16M/2 */
pllsel = (RCU_PLL & RCU_PLL_PLLSEL);
- if (RCU_PLLSRC_HXTAL == pllsel) {
+ if(RCU_PLLSRC_HXTAL == pllsel) {
ck_src = HXTAL_VALUE;
} else {
ck_src = IRC16M_VALUE;
}
- cksys_freq = ((ck_src / pllpsc) * plln)/pllp;
+ cksys_freq = ((ck_src / pllpsc) * plln) / pllp;
break;
/* IRC16M is selected as CK_SYS */
default:
@@ -1309,7 +1181,7 @@ uint32_t rcu_clock_freq_get(rcu_clock_freq_enum clock)
apb2_freq = ahb_freq >> clk_exp;
/* return the clocks frequency */
- switch(clock){
+ switch(clock) {
case CK_SYS:
ck_freq = cksys_freq;
break;
@@ -1327,3 +1199,134 @@ uint32_t rcu_clock_freq_get(rcu_clock_freq_enum clock)
}
return ck_freq;
}
+
+/*!
+ \brief get the clock stabilization and periphral reset flags
+ \param[in] flag: the clock stabilization and periphral reset flags, refer to rcu_flag_enum
+ only one parameter can be selected which is shown as below:
+ \arg RCU_FLAG_IRC16MSTB: IRC16M stabilization flag
+ \arg RCU_FLAG_HXTALSTB: HXTAL stabilization flag
+ \arg RCU_FLAG_PLLSTB: PLL stabilization flag
+ \arg RCU_FLAG_PLLI2SSTB: PLLI2S stabilization flag
+ \arg RCU_FLAG_PLLSAISTB: PLLSAI stabilization flag
+ \arg RCU_FLAG_LXTALSTB: LXTAL stabilization flag
+ \arg RCU_FLAG_IRC32KSTB: IRC32K stabilization flag
+ \arg RCU_FLAG_IRC48MSTB: IRC48M stabilization flag
+ \arg RCU_FLAG_BORRST: BOR reset flags
+ \arg RCU_FLAG_EPRST: external PIN reset flag
+ \arg RCU_FLAG_PORRST: Power reset flag
+ \arg RCU_FLAG_SWRST: software reset flag
+ \arg RCU_FLAG_FWDGTRST: free watchdog timer reset flag
+ \arg RCU_FLAG_WWDGTRST: window watchdog timer reset flag
+ \arg RCU_FLAG_LPRST: low-power reset flag
+ \param[out] none
+ \retval none
+*/
+FlagStatus rcu_flag_get(rcu_flag_enum flag)
+{
+ /* get the rcu flag */
+ if(RESET != (RCU_REG_VAL(flag) & BIT(RCU_BIT_POS(flag)))) {
+ return SET;
+ } else {
+ return RESET;
+ }
+}
+
+/*!
+ \brief clear all the reset flag
+ \param[in] none
+ \param[out] none
+ \retval none
+*/
+void rcu_all_reset_flag_clear(void)
+{
+ RCU_RSTSCK |= RCU_RSTSCK_RSTFC;
+}
+
+/*!
+ \brief get the clock stabilization interrupt and ckm flags
+ \param[in] int_flag: interrupt and ckm flags, refer to rcu_int_flag_enum
+ only one parameter can be selected which is shown as below:
+ \arg RCU_INT_FLAG_IRC32KSTB: IRC32K stabilization interrupt flag
+ \arg RCU_INT_FLAG_LXTALSTB: LXTAL stabilization interrupt flag
+ \arg RCU_INT_FLAG_IRC16MSTB: IRC16M stabilization interrupt flag
+ \arg RCU_INT_FLAG_HXTALSTB: HXTAL stabilization interrupt flag
+ \arg RCU_INT_FLAG_PLLSTB: PLL stabilization interrupt flag
+ \arg RCU_INT_FLAG_PLLI2SSTB: PLLI2S stabilization interrupt flag
+ \arg RCU_INT_FLAG_PLLSAISTB: PLLSAI stabilization interrupt flag
+ \arg RCU_INT_FLAG_CKM: HXTAL clock stuck interrupt flag
+ \arg RCU_INT_FLAG_IRC48MSTB: IRC48M stabilization interrupt flag
+ \param[out] none
+ \retval FlagStatus: SET or RESET
+*/
+FlagStatus rcu_interrupt_flag_get(rcu_int_flag_enum int_flag)
+{
+ /* get the rcu interrupt flag */
+ if(RESET != (RCU_REG_VAL(int_flag) & BIT(RCU_BIT_POS(int_flag)))) {
+ return SET;
+ } else {
+ return RESET;
+ }
+}
+
+/*!
+ \brief clear the interrupt flags
+ \param[in] int_flag: clock stabilization and stuck interrupt flags clear, refer to rcu_int_flag_clear_enum
+ only one parameter can be selected which is shown as below:
+ \arg RCU_INT_FLAG_IRC32KSTB_CLR: IRC32K stabilization interrupt flag clear
+ \arg RCU_INT_FLAG_LXTALSTB_CLR: LXTAL stabilization interrupt flag clear
+ \arg RCU_INT_FLAG_IRC16MSTB_CLR: IRC16M stabilization interrupt flag clear
+ \arg RCU_INT_FLAG_HXTALSTB_CLR: HXTAL stabilization interrupt flag clear
+ \arg RCU_INT_FLAG_PLLSTB_CLR: PLL stabilization interrupt flag clear
+ \arg RCU_INT_FLAG_PLLI2SSTB_CLR: PLLI2S stabilization interrupt flag clear
+ \arg RCU_INT_FLAG_PLLSAISTB_CLR: PLLSAI stabilization interrupt flag clear
+ \arg RCU_INT_FLAG_CKM_CLR: clock stuck interrupt flag clear
+ \arg RCU_INT_FLAG_IRC48MSTB_CLR: IRC48M stabilization interrupt flag clear
+ \param[out] none
+ \retval none
+*/
+void rcu_interrupt_flag_clear(rcu_int_flag_clear_enum int_flag)
+{
+ RCU_REG_VAL(int_flag) |= BIT(RCU_BIT_POS(int_flag));
+}
+
+/*!
+ \brief enable the stabilization interrupt
+ \param[in] interrupt: clock stabilization interrupt, refer to rcu_int_enum
+ Only one parameter can be selected which is shown as below:
+ \arg RCU_INT_IRC32KSTB: IRC32K stabilization interrupt enable
+ \arg RCU_INT_LXTALSTB: LXTAL stabilization interrupt enable
+ \arg RCU_INT_IRC16MSTB: IRC16M stabilization interrupt enable
+ \arg RCU_INT_HXTALSTB: HXTAL stabilization interrupt enable
+ \arg RCU_INT_PLLSTB: PLL stabilization interrupt enable
+ \arg RCU_INT_PLLI2SSTB: PLLI2S stabilization interrupt enable
+ \arg RCU_INT_PLLSAISTB: PLLSAI stabilization interrupt enable
+ \arg RCU_INT_IRC48MSTB: IRC48M stabilization interrupt enable
+ \param[out] none
+ \retval none
+*/
+void rcu_interrupt_enable(rcu_int_enum interrupt)
+{
+ RCU_REG_VAL(interrupt) |= BIT(RCU_BIT_POS(interrupt));
+}
+
+
+/*!
+ \brief disable the stabilization interrupt
+ \param[in] interrupt: clock stabilization interrupt, refer to rcu_int_enum
+ only one parameter can be selected which is shown as below:
+ \arg RCU_INT_IRC32KSTB: IRC32K stabilization interrupt disable
+ \arg RCU_INT_LXTALSTB: LXTAL stabilization interrupt disable
+ \arg RCU_INT_IRC16MSTB: IRC16M stabilization interrupt disable
+ \arg RCU_INT_HXTALSTB: HXTAL stabilization interrupt disable
+ \arg RCU_INT_PLLSTB: PLL stabilization interrupt disable
+ \arg RCU_INT_PLLI2SSTB: PLLI2S stabilization interrupt disable
+ \arg RCU_INT_PLLSAISTB: PLLSAI stabilization interrupt disable
+ \arg RCU_INT_IRC48MSTB: IRC48M stabilization interrupt disable
+ \param[out] none
+ \retval none
+*/
+void rcu_interrupt_disable(rcu_int_enum interrupt)
+{
+ RCU_REG_VAL(interrupt) &= ~BIT(RCU_BIT_POS(interrupt));
+}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_rtc.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_rtc.c
index 12ee6c3207..8003e92c2d 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_rtc.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_rtc.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -45,9 +46,8 @@ OF SUCH DAMAGE.
#define RTC_SHIFTCTL_TIMEOUT ((uint32_t)0x00001000U) /*!< shift function operation pending flag timeout */
#define RTC_ALRMXWF_TIMEOUT ((uint32_t)0x00008000U) /*!< alarm configuration can be write flag timeout */
-
/*!
- \brief reset most of the RTC registers
+ \brief reset most of the RTC registers
\param[in] none
\param[out] none
\retval ErrStatus: ERROR or SUCCESS
@@ -67,7 +67,7 @@ ErrStatus rtc_deinit(void)
/* enter init mode */
error_status = rtc_init_mode_enter();
- if(ERROR != error_status){
+ if(ERROR != error_status) {
/* reset RTC_CTL register, but RTC_CTL[2��0] */
RTC_CTL &= (RTC_REGISTER_RESET | RTC_CTL_WTCS);
/* before reset RTC_TIME and RTC_DATE, BPSHAD bit in RTC_CTL should be reset as the condition.
@@ -78,13 +78,13 @@ ErrStatus rtc_deinit(void)
RTC_PSC = RTC_PSC_RESET;
/* only when RTC_CTL_WTEN=0 and RTC_STAT_WTWF=1 can write RTC_CTL[2��0] */
/* wait until the WTWF flag to be set */
- do{
- flag_status = RTC_STAT & RTC_STAT_WTWF;
- }while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
+ do {
+ flag_status = RTC_STAT & RTC_STAT_WTWF;
+ } while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
- if ((uint32_t)RESET == flag_status){
+ if((uint32_t)RESET == flag_status) {
error_status = ERROR;
- }else{
+ } else {
RTC_CTL &= RTC_REGISTER_RESET;
RTC_WUT = RTC_WUT_RESET;
RTC_COSC = RTC_REGISTER_RESET;
@@ -110,7 +110,7 @@ ErrStatus rtc_deinit(void)
}
/*!
- \brief initialize RTC registers
+ \brief initialize RTC registers
\param[in] rtc_initpara_struct: pointer to a rtc_parameter_struct structure which contains
parameters for initialization of the rtc peripheral
members of the structure and the member values are shown as below:
@@ -130,7 +130,7 @@ ErrStatus rtc_deinit(void)
\param[out] none
\retval ErrStatus: ERROR or SUCCESS
*/
-ErrStatus rtc_init(rtc_parameter_struct* rtc_initpara_struct)
+ErrStatus rtc_init(rtc_parameter_struct *rtc_initpara_struct)
{
ErrStatus error_status = ERROR;
uint32_t reg_time = 0U, reg_date = 0U;
@@ -140,7 +140,7 @@ ErrStatus rtc_init(rtc_parameter_struct* rtc_initpara_struct)
DATE_MON(rtc_initpara_struct->month) | \
DATE_DAY(rtc_initpara_struct->date));
- reg_time = (rtc_initpara_struct->am_pm| \
+ reg_time = (rtc_initpara_struct->am_pm | \
TIME_HR(rtc_initpara_struct->hour) | \
TIME_MN(rtc_initpara_struct->minute) | \
TIME_SC(rtc_initpara_struct->second));
@@ -152,8 +152,8 @@ ErrStatus rtc_init(rtc_parameter_struct* rtc_initpara_struct)
/* 2nd: enter init mode */
error_status = rtc_init_mode_enter();
- if(ERROR != error_status){
- RTC_PSC = (uint32_t)(PSC_FACTOR_A(rtc_initpara_struct->factor_asyn)| \
+ if(ERROR != error_status) {
+ RTC_PSC = (uint32_t)(PSC_FACTOR_A(rtc_initpara_struct->factor_asyn) | \
PSC_FACTOR_S(rtc_initpara_struct->factor_syn));
RTC_TIME = (uint32_t)reg_time;
@@ -176,7 +176,7 @@ ErrStatus rtc_init(rtc_parameter_struct* rtc_initpara_struct)
}
/*!
- \brief enter RTC init mode
+ \brief enter RTC init mode
\param[in] none
\param[out] none
\retval ErrStatus: ERROR or SUCCESS
@@ -188,25 +188,25 @@ ErrStatus rtc_init_mode_enter(void)
ErrStatus error_status = ERROR;
/* check whether it has been in init mode */
- if ((uint32_t)RESET == (RTC_STAT & RTC_STAT_INITF)){
+ if((uint32_t)RESET == (RTC_STAT & RTC_STAT_INITF)) {
RTC_STAT |= RTC_STAT_INITM;
/* wait until the INITF flag to be set */
- do{
- flag_status = RTC_STAT & RTC_STAT_INITF;
- }while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
+ do {
+ flag_status = RTC_STAT & RTC_STAT_INITF;
+ } while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
- if ((uint32_t)RESET != flag_status){
+ if((uint32_t)RESET != flag_status) {
error_status = SUCCESS;
}
- }else{
+ } else {
error_status = SUCCESS;
}
return error_status;
}
/*!
- \brief exit RTC init mode
+ \brief exit RTC init mode
\param[in] none
\param[out] none
\retval none
@@ -217,7 +217,7 @@ void rtc_init_mode_exit(void)
}
/*!
- \brief wait until RTC_TIME and RTC_DATE registers are synchronized with APB clock, and the shadow
+ \brief wait until RTC_TIME and RTC_DATE registers are synchronized with APB clock, and the shadow
registers are updated
\param[in] none
\param[out] none
@@ -229,7 +229,7 @@ ErrStatus rtc_register_sync_wait(void)
uint32_t flag_status = RESET;
ErrStatus error_status = ERROR;
- if ((uint32_t)RESET == (RTC_CTL & RTC_CTL_BPSHAD)){
+ if((uint32_t)RESET == (RTC_CTL & RTC_CTL_BPSHAD)) {
/* disable the write protection */
RTC_WPK = RTC_UNLOCK_KEY1;
RTC_WPK = RTC_UNLOCK_KEY2;
@@ -238,17 +238,17 @@ ErrStatus rtc_register_sync_wait(void)
RTC_STAT &= (uint32_t)(~RTC_STAT_RSYNF);
/* wait until RSYNF flag to be set */
- do{
+ do {
flag_status = RTC_STAT & RTC_STAT_RSYNF;
- }while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
+ } while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
- if ((uint32_t)RESET != flag_status){
+ if((uint32_t)RESET != flag_status) {
error_status = SUCCESS;
}
/* enable the write protection */
RTC_WPK = RTC_LOCK_KEY;
- }else{
+ } else {
error_status = SUCCESS;
}
@@ -256,7 +256,7 @@ ErrStatus rtc_register_sync_wait(void)
}
/*!
- \brief get current time and date
+ \brief get current time and date
\param[in] none
\param[out] rtc_initpara_struct: pointer to a rtc_parameter_struct structure which contains
parameters for initialization of the rtc peripheral
@@ -276,7 +276,7 @@ ErrStatus rtc_register_sync_wait(void)
display_format: RTC_24HOUR, RTC_12HOUR
\retval none
*/
-void rtc_current_time_get(rtc_parameter_struct* rtc_initpara_struct)
+void rtc_current_time_get(rtc_parameter_struct *rtc_initpara_struct)
{
uint32_t temp_tr = 0U, temp_dr = 0U, temp_pscr = 0U, temp_ctlr = 0U;
@@ -295,12 +295,12 @@ void rtc_current_time_get(rtc_parameter_struct* rtc_initpara_struct)
rtc_initpara_struct->second = (uint8_t)GET_TIME_SC(temp_tr);
rtc_initpara_struct->factor_asyn = (uint16_t)GET_PSC_FACTOR_A(temp_pscr);
rtc_initpara_struct->factor_syn = (uint16_t)GET_PSC_FACTOR_S(temp_pscr);
- rtc_initpara_struct->am_pm = (uint32_t)(temp_pscr & RTC_TIME_PM);
+ rtc_initpara_struct->am_pm = (uint32_t)(temp_tr & RTC_TIME_PM);
rtc_initpara_struct->display_format = (uint32_t)(temp_ctlr & RTC_CTL_CS);
}
/*!
- \brief get current subsecond value
+ \brief get current subsecond value
\param[in] none
\param[out] none
\retval current subsecond value
@@ -311,13 +311,13 @@ uint32_t rtc_subsecond_get(void)
/* if BPSHAD bit is reset, reading RTC_SS will lock RTC_TIME and RTC_DATE automatically */
reg = (uint32_t)RTC_SS;
/* read RTC_DATE to unlock the 3 shadow registers */
- (void) (RTC_DATE);
+ (void)(RTC_DATE);
return reg;
}
/*!
- \brief configure RTC alarm
+ \brief configure RTC alarm
\param[in] rtc_alarm: RTC_ALARM0 or RTC_ALARM1
\param[in] rtc_alarm_time: pointer to a rtc_alarm_struct structure which contains
parameters for RTC alarm configuration
@@ -335,26 +335,26 @@ uint32_t rtc_subsecond_get(void)
\param[out] none
\retval none
*/
-void rtc_alarm_config(uint8_t rtc_alarm, rtc_alarm_struct* rtc_alarm_time)
+void rtc_alarm_config(uint8_t rtc_alarm, rtc_alarm_struct *rtc_alarm_time)
{
uint32_t reg_alrmtd = 0U;
- reg_alrmtd =(rtc_alarm_time->alarm_mask | \
- rtc_alarm_time->weekday_or_date | \
- rtc_alarm_time->am_pm | \
- ALRMTD_DAY(rtc_alarm_time->alarm_day) | \
- ALRMTD_HR(rtc_alarm_time->alarm_hour) | \
- ALRMTD_MN(rtc_alarm_time->alarm_minute) | \
- ALRMTD_SC(rtc_alarm_time->alarm_second));
+ reg_alrmtd = (rtc_alarm_time->alarm_mask | \
+ rtc_alarm_time->weekday_or_date | \
+ rtc_alarm_time->am_pm | \
+ ALRMTD_DAY(rtc_alarm_time->alarm_day) | \
+ ALRMTD_HR(rtc_alarm_time->alarm_hour) | \
+ ALRMTD_MN(rtc_alarm_time->alarm_minute) | \
+ ALRMTD_SC(rtc_alarm_time->alarm_second));
/* disable the write protection */
RTC_WPK = RTC_UNLOCK_KEY1;
RTC_WPK = RTC_UNLOCK_KEY2;
- if(RTC_ALARM0 == rtc_alarm){
+ if(RTC_ALARM0 == rtc_alarm) {
RTC_ALRM0TD = (uint32_t)reg_alrmtd;
- }else{
+ } else {
RTC_ALRM1TD = (uint32_t)reg_alrmtd;
}
/* enable the write protection */
@@ -362,7 +362,7 @@ void rtc_alarm_config(uint8_t rtc_alarm, rtc_alarm_struct* rtc_alarm_time)
}
/*!
- \brief configure subsecond of RTC alarm
+ \brief configure subsecond of RTC alarm
\param[in] rtc_alarm: RTC_ALARM0 or RTC_ALARM1
\param[in] mask_subsecond: alarm subsecond mask
\arg RTC_MASKSSC_0_14: mask alarm subsecond configuration
@@ -391,9 +391,9 @@ void rtc_alarm_subsecond_config(uint8_t rtc_alarm, uint32_t mask_subsecond, uint
RTC_WPK = RTC_UNLOCK_KEY1;
RTC_WPK = RTC_UNLOCK_KEY2;
- if(RTC_ALARM0 == rtc_alarm){
+ if(RTC_ALARM0 == rtc_alarm) {
RTC_ALRM0SS = mask_subsecond | subsecond;
- }else{
+ } else {
RTC_ALRM1SS = mask_subsecond | subsecond;
}
/* enable the write protection */
@@ -401,7 +401,7 @@ void rtc_alarm_subsecond_config(uint8_t rtc_alarm, uint32_t mask_subsecond, uint
}
/*!
- \brief get RTC alarm
+ \brief get RTC alarm
\param[in] rtc_alarm: RTC_ALARM0 or RTC_ALARM1
\param[out] rtc_alarm_time: pointer to a rtc_alarm_struct structure which contains
parameters for RTC alarm configuration
@@ -418,14 +418,14 @@ void rtc_alarm_subsecond_config(uint8_t rtc_alarm, uint32_t mask_subsecond, uint
am_pm: RTC_AM, RTC_PM
\retval none
*/
-void rtc_alarm_get(uint8_t rtc_alarm, rtc_alarm_struct* rtc_alarm_time)
+void rtc_alarm_get(uint8_t rtc_alarm, rtc_alarm_struct *rtc_alarm_time)
{
uint32_t reg_alrmtd = 0U;
/* get the value of RTC_ALRM0TD register */
- if(RTC_ALARM0 == rtc_alarm){
+ if(RTC_ALARM0 == rtc_alarm) {
reg_alrmtd = RTC_ALRM0TD;
- }else{
+ } else {
reg_alrmtd = RTC_ALRM1TD;
}
/* get alarm parameters and construct the rtc_alarm_struct structure */
@@ -439,22 +439,22 @@ void rtc_alarm_get(uint8_t rtc_alarm, rtc_alarm_struct* rtc_alarm_time)
}
/*!
- \brief get RTC alarm subsecond
+ \brief get RTC alarm subsecond
\param[in] rtc_alarm: RTC_ALARM0 or RTC_ALARM1
\param[out] none
\retval RTC alarm subsecond value
*/
uint32_t rtc_alarm_subsecond_get(uint8_t rtc_alarm)
{
- if(RTC_ALARM0 == rtc_alarm){
+ if(RTC_ALARM0 == rtc_alarm) {
return ((uint32_t)(RTC_ALRM0SS & RTC_ALRM0SS_SSC));
- }else{
+ } else {
return ((uint32_t)(RTC_ALRM1SS & RTC_ALRM1SS_SSC));
}
}
/*!
- \brief enable RTC alarm
+ \brief enable RTC alarm
\param[in] rtc_alarm: RTC_ALARM0 or RTC_ALARM1
\param[out] none
\retval none
@@ -465,9 +465,9 @@ void rtc_alarm_enable(uint8_t rtc_alarm)
RTC_WPK = RTC_UNLOCK_KEY1;
RTC_WPK = RTC_UNLOCK_KEY2;
- if(RTC_ALARM0 == rtc_alarm){
+ if(RTC_ALARM0 == rtc_alarm) {
RTC_CTL |= RTC_CTL_ALRM0EN;
- }else{
+ } else {
RTC_CTL |= RTC_CTL_ALRM1EN;
}
/* enable the write protection */
@@ -475,7 +475,7 @@ void rtc_alarm_enable(uint8_t rtc_alarm)
}
/*!
- \brief disable RTC alarm
+ \brief disable RTC alarm
\param[in] rtc_alarm: RTC_ALARM0 or RTC_ALARM1
\param[out] none
\retval ErrStatus: ERROR or SUCCESS
@@ -491,21 +491,21 @@ ErrStatus rtc_alarm_disable(uint8_t rtc_alarm)
RTC_WPK = RTC_UNLOCK_KEY2;
/* clear the state of alarm */
- if(RTC_ALARM0 == rtc_alarm){
+ if(RTC_ALARM0 == rtc_alarm) {
RTC_CTL &= (uint32_t)(~RTC_CTL_ALRM0EN);
/* wait until ALRM0WF flag to be set after the alarm is disabled */
- do{
+ do {
flag_status = RTC_STAT & RTC_STAT_ALRM0WF;
- }while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
- }else{
+ } while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
+ } else {
RTC_CTL &= (uint32_t)(~RTC_CTL_ALRM1EN);
/* wait until ALRM1WF flag to be set after the alarm is disabled */
- do{
+ do {
flag_status = RTC_STAT & RTC_STAT_ALRM1WF;
- }while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
+ } while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
}
- if ((uint32_t)RESET != flag_status){
+ if((uint32_t)RESET != flag_status) {
error_status = SUCCESS;
}
@@ -516,7 +516,7 @@ ErrStatus rtc_alarm_disable(uint8_t rtc_alarm)
}
/*!
- \brief enable RTC time-stamp
+ \brief enable RTC time-stamp
\param[in] edge: specify which edge to detect of time-stamp
\arg RTC_TIMESTAMP_RISING_EDGE: rising edge is valid event edge for timestamp event
\arg RTC_TIMESTAMP_FALLING_EDGE: falling edge is valid event edge for timestamp event
@@ -544,7 +544,7 @@ void rtc_timestamp_enable(uint32_t edge)
}
/*!
- \brief disable RTC time-stamp
+ \brief disable RTC time-stamp
\param[in] none
\param[out] none
\retval none
@@ -563,7 +563,7 @@ void rtc_timestamp_disable(void)
}
/*!
- \brief get RTC timestamp time and date
+ \brief get RTC timestamp time and date
\param[in] none
\param[out] rtc_timestamp: pointer to a rtc_timestamp_struct structure which contains
parameters for RTC time-stamp configuration
@@ -579,7 +579,7 @@ void rtc_timestamp_disable(void)
am_pm: RTC_AM, RTC_PM
\retval none
*/
-void rtc_timestamp_get(rtc_timestamp_struct* rtc_timestamp)
+void rtc_timestamp_get(rtc_timestamp_struct *rtc_timestamp)
{
uint32_t temp_tts = 0U, temp_dts = 0U;
@@ -598,7 +598,7 @@ void rtc_timestamp_get(rtc_timestamp_struct* rtc_timestamp)
}
/*!
- \brief get RTC time-stamp subsecond
+ \brief get RTC time-stamp subsecond
\param[in] none
\param[out] none
\retval RTC time-stamp subsecond value
@@ -609,7 +609,7 @@ uint32_t rtc_timestamp_subsecond_get(void)
}
/*!
- \brief RTC time-stamp mapping
+ \brief RTC time-stamp mapping
\param[in] rtc_af:
\arg RTC_AF0_TIMESTAMP: RTC_AF0 use for timestamp
\arg RTC_AF1_TIMESTAMP: RTC_AF1 use for timestamp
@@ -623,7 +623,7 @@ void rtc_timestamp_pin_map(uint32_t rtc_af)
}
/*!
- \brief enable RTC tamper
+ \brief enable RTC tamper
\param[in] rtc_tamper: pointer to a rtc_tamper_struct structure which contains
parameters for RTC tamper configuration
members of the structure and the member values are shown as below:
@@ -646,7 +646,7 @@ void rtc_timestamp_pin_map(uint32_t rtc_af)
\param[out] none
\retval none
*/
-void rtc_tamper_enable(rtc_tamper_struct* rtc_tamper)
+void rtc_tamper_enable(rtc_tamper_struct *rtc_tamper)
{
/* disable tamper */
RTC_TAMP &= (uint32_t)~(rtc_tamper->tamper_source);
@@ -655,13 +655,13 @@ void rtc_tamper_enable(rtc_tamper_struct* rtc_tamper)
RTC_TAMP &= (uint32_t)~RTC_TAMP_FLT;
/* the tamper source is voltage level detection */
- if((uint32_t)(rtc_tamper->tamper_filter) != RTC_FLT_EDGE ){
+ if((uint32_t)(rtc_tamper->tamper_filter) != RTC_FLT_EDGE) {
RTC_TAMP &= (uint32_t)~(RTC_TAMP_DISPU | RTC_TAMP_PRCH | RTC_TAMP_FREQ | RTC_TAMP_FLT);
/* check if the tamper pin need precharge, if need, then configure the precharge time */
- if(DISABLE == rtc_tamper->tamper_precharge_enable){
- RTC_TAMP |= (uint32_t)RTC_TAMP_DISPU;
- }else{
+ if(DISABLE == rtc_tamper->tamper_precharge_enable) {
+ RTC_TAMP |= (uint32_t)RTC_TAMP_DISPU;
+ } else {
RTC_TAMP |= (uint32_t)(rtc_tamper->tamper_precharge_time);
}
@@ -670,29 +670,29 @@ void rtc_tamper_enable(rtc_tamper_struct* rtc_tamper)
/* configure the tamper trigger */
RTC_TAMP &= ((uint32_t)~((rtc_tamper->tamper_source) << RTC_TAMPER_TRIGGER_POS));
- if(RTC_TAMPER_TRIGGER_LEVEL_LOW != rtc_tamper->tamper_trigger){
- RTC_TAMP |= (uint32_t)((rtc_tamper->tamper_source)<< RTC_TAMPER_TRIGGER_POS);
+ if(RTC_TAMPER_TRIGGER_LEVEL_LOW != rtc_tamper->tamper_trigger) {
+ RTC_TAMP |= (uint32_t)((rtc_tamper->tamper_source) << RTC_TAMPER_TRIGGER_POS);
}
- }else{
+ } else {
/* configure the tamper trigger */
RTC_TAMP &= ((uint32_t)~((rtc_tamper->tamper_source) << RTC_TAMPER_TRIGGER_POS));
- if(RTC_TAMPER_TRIGGER_EDGE_RISING != rtc_tamper->tamper_trigger){
- RTC_TAMP |= (uint32_t)((rtc_tamper->tamper_source)<< RTC_TAMPER_TRIGGER_POS);
+ if(RTC_TAMPER_TRIGGER_EDGE_RISING != rtc_tamper->tamper_trigger) {
+ RTC_TAMP |= (uint32_t)((rtc_tamper->tamper_source) << RTC_TAMPER_TRIGGER_POS);
}
}
RTC_TAMP &= (uint32_t)~RTC_TAMP_TPTS;
- if(DISABLE != rtc_tamper->tamper_with_timestamp){
+ if(DISABLE != rtc_tamper->tamper_with_timestamp) {
/* the tamper event also cause a time-stamp event */
RTC_TAMP |= (uint32_t)RTC_TAMP_TPTS;
}
/* enable tamper */
- RTC_TAMP |= (uint32_t)(rtc_tamper->tamper_source);
+ RTC_TAMP |= (uint32_t)(rtc_tamper->tamper_source);
}
/*!
- \brief disable RTC tamper
+ \brief disable RTC tamper
\param[in] source: specify which tamper source to be disabled
\arg RTC_TAMPER0
\arg RTC_TAMPER1
@@ -707,7 +707,7 @@ void rtc_tamper_disable(uint32_t source)
}
/*!
- \brief RTC tamper0 mapping
+ \brief RTC tamper0 mapping
\param[in] rtc_af:
\arg RTC_AF0_TAMPER0: RTC_AF0 use for tamper0
\arg RTC_AF1_TAMPER0: RTC_AF1 use for tamper0
@@ -721,7 +721,7 @@ void rtc_tamper0_pin_map(uint32_t rtc_af)
}
/*!
- \brief enable specified RTC interrupt
+ \brief enable specified RTC interrupt
\param[in] interrupt: specify which interrupt source to be enabled
\arg RTC_INT_TIMESTAMP: timestamp interrupt
\arg RTC_INT_ALARM0: alarm0 interrupt
@@ -747,7 +747,7 @@ void rtc_interrupt_enable(uint32_t interrupt)
}
/*!
- \brief disble specified RTC interrupt
+ \brief disble specified RTC interrupt
\param[in] interrupt: specify which interrupt source to be disabled
\arg RTC_INT_TIMESTAMP: timestamp interrupt
\arg RTC_INT_ALARM0: alarm interrupt
@@ -773,15 +773,15 @@ void rtc_interrupt_disable(uint32_t interrupt)
}
/*!
- \brief check specified flag
+ \brief check specified flag
\param[in] flag: specify which flag to check
\arg RTC_STAT_SCP: smooth calibration pending flag
\arg RTC_FLAG_TP1: RTC tamper 1 detected flag
\arg RTC_FLAG_TP0: RTC tamper 0 detected flag
\arg RTC_FLAG_TSOVR: time-stamp overflow flag
\arg RTC_FLAG_TS: time-stamp flag
- \arg RTC_FLAG_ALARM0: alarm0 occurs flag
- \arg RTC_FLAG_ALARM1: alarm1 occurs flag
+ \arg RTC_FLAG_ALRM0: alarm0 occurs flag
+ \arg RTC_FLAG_ALRM1: alarm1 occurs flag
\arg RTC_FLAG_WT: wakeup timer occurs flag
\arg RTC_FLAG_INIT: initialization state flag
\arg RTC_FLAG_RSYN: register synchronization flag
@@ -797,14 +797,14 @@ FlagStatus rtc_flag_get(uint32_t flag)
{
FlagStatus flag_state = RESET;
- if ((uint32_t)RESET != (RTC_STAT & flag)){
+ if((uint32_t)RESET != (RTC_STAT & flag)) {
flag_state = SET;
}
return flag_state;
}
/*!
- \brief clear specified flag
+ \brief clear specified flag
\arg RTC_FLAG_TP1: RTC tamper 1 detected flag
\arg RTC_FLAG_TP0: RTC tamper 0 detected flag
\arg RTC_FLAG_TSOVR: time-stamp overflow flag
@@ -822,7 +822,7 @@ void rtc_flag_clear(uint32_t flag)
}
/*!
- \brief configure rtc alarm output source
+ \brief configure rtc alarm output source
\param[in] source: specify signal to output
\arg RTC_ALARM0_HIGH: when the alarm0 flag is set, the output pin is high
\arg RTC_ALARM0_LOW: when the alarm0 flag is set, the output pin is low
@@ -854,7 +854,7 @@ void rtc_alarm_output_config(uint32_t source, uint32_t mode)
}
/*!
- \brief configure rtc calibration output source
+ \brief configure rtc calibration output source
\param[in] source: specify signal to output
\arg RTC_CALIBRATION_512HZ: when the LSE freqency is 32768Hz and the RTC_PSC
is the default value, output 512Hz signal
@@ -876,9 +876,8 @@ void rtc_calibration_output_config(uint32_t source)
RTC_WPK = RTC_LOCK_KEY;
}
-
/*!
- \brief adjust the daylight saving time by adding or substracting one hour from the current time
+ \brief adjust the daylight saving time by adding or substracting one hour from the current time
\param[in] operation: hour adjustment operation
\arg RTC_CTL_A1H: add one hour
\arg RTC_CTL_S1H: substract one hour
@@ -898,7 +897,7 @@ void rtc_hour_adjust(uint32_t operation)
}
/*!
- \brief adjust RTC second or subsecond value of current time
+ \brief adjust RTC second or subsecond value of current time
\param[in] add: add 1s to current time or not
\arg RTC_SHIFT_ADD1S_RESET: no effect
\arg RTC_SHIFT_ADD1S_SET: add 1s to current time
@@ -911,19 +910,19 @@ ErrStatus rtc_second_adjust(uint32_t add, uint32_t minus)
volatile uint32_t time_index = RTC_SHIFTCTL_TIMEOUT;
ErrStatus error_status = ERROR;
uint32_t flag_status = RESET;
- uint32_t temp=0U;
+ uint32_t temp = 0U;
/* disable the write protection */
RTC_WPK = RTC_UNLOCK_KEY1;
RTC_WPK = RTC_UNLOCK_KEY2;
/* check if a shift operation is ongoing */
- do{
+ do {
flag_status = RTC_STAT & RTC_STAT_SOPF;
- }while((--time_index > 0U) && ((uint32_t)RESET != flag_status));
+ } while((--time_index > 0U) && ((uint32_t)RESET != flag_status));
/* check if the function of reference clock detection is disabled */
temp = RTC_CTL & RTC_CTL_REFEN;
- if((RESET == flag_status) && (RESET == temp)){
+ if((RESET == flag_status) && (RESET == temp)) {
RTC_SHIFTCTL = (uint32_t)(add | SHIFTCTL_SFS(minus));
error_status = rtc_register_sync_wait();
}
@@ -935,7 +934,7 @@ ErrStatus rtc_second_adjust(uint32_t add, uint32_t minus)
}
/*!
- \brief enable RTC bypass shadow registers function
+ \brief enable RTC bypass shadow registers function
\param[in] none
\param[out] none
\retval none
@@ -953,7 +952,7 @@ void rtc_bypass_shadow_enable(void)
}
/*!
- \brief disable RTC bypass shadow registers function
+ \brief disable RTC bypass shadow registers function
\param[in] none
\param[out] none
\retval none
@@ -971,7 +970,7 @@ void rtc_bypass_shadow_disable(void)
}
/*!
- \brief enable RTC reference clock detection function
+ \brief enable RTC reference clock detection function
\param[in] none
\param[out] none
\retval ErrStatus: ERROR or SUCCESS
@@ -987,7 +986,7 @@ ErrStatus rtc_refclock_detection_enable(void)
/* enter init mode */
error_status = rtc_init_mode_enter();
- if(ERROR != error_status){
+ if(ERROR != error_status) {
RTC_CTL |= (uint32_t)RTC_CTL_REFEN;
/* exit init mode */
rtc_init_mode_exit();
@@ -1000,7 +999,7 @@ ErrStatus rtc_refclock_detection_enable(void)
}
/*!
- \brief disable RTC reference clock detection function
+ \brief disable RTC reference clock detection function
\param[in] none
\param[out] none
\retval ErrStatus: ERROR or SUCCESS
@@ -1016,7 +1015,7 @@ ErrStatus rtc_refclock_detection_disable(void)
/* enter init mode */
error_status = rtc_init_mode_enter();
- if(ERROR != error_status){
+ if(ERROR != error_status) {
RTC_CTL &= (uint32_t)~RTC_CTL_REFEN;
/* exit init mode */
rtc_init_mode_exit();
@@ -1029,7 +1028,7 @@ ErrStatus rtc_refclock_detection_disable(void)
}
/*!
- \brief enable RTC auto wakeup function
+ \brief enable RTC auto wakeup function
\param[in] none
\param[out] none
\retval none
@@ -1047,7 +1046,7 @@ void rtc_wakeup_enable(void)
}
/*!
- \brief disable RTC auto wakeup function
+ \brief disable RTC auto wakeup function
\param[in] none
\param[out] none
\retval ErrStatus: ERROR or SUCCESS
@@ -1062,13 +1061,13 @@ ErrStatus rtc_wakeup_disable(void)
RTC_WPK = RTC_UNLOCK_KEY2;
RTC_CTL &= ~RTC_CTL_WTEN;
/* wait until the WTWF flag to be set */
- do{
+ do {
flag_status = RTC_STAT & RTC_STAT_WTWF;
- }while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
+ } while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
- if ((uint32_t)RESET == flag_status){
+ if((uint32_t)RESET == flag_status) {
error_status = ERROR;
- }else{
+ } else {
error_status = SUCCESS;
}
/* enable the write protection */
@@ -1077,7 +1076,7 @@ ErrStatus rtc_wakeup_disable(void)
}
/*!
- \brief set RTC auto wakeup timer clock
+ \brief set RTC auto wakeup timer clock
\param[in] wakeup_clock:
\arg WAKEUP_RTCCK_DIV16: RTC auto wakeup timer clock is RTC clock divided by 16
\arg WAKEUP_RTCCK_DIV8: RTC auto wakeup timer clock is RTC clock divided by 8
@@ -1098,13 +1097,13 @@ ErrStatus rtc_wakeup_clock_set(uint8_t wakeup_clock)
RTC_WPK = RTC_UNLOCK_KEY2;
/* only when RTC_CTL_WTEN=0 and RTC_STAT_WTWF=1 can write RTC_CTL[2��0] */
/* wait until the WTWF flag to be set */
- do{
+ do {
flag_status = RTC_STAT & RTC_STAT_WTWF;
- }while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
+ } while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
- if ((uint32_t)RESET == flag_status){
+ if((uint32_t)RESET == flag_status) {
error_status = ERROR;
- }else{
+ } else {
RTC_CTL &= (uint32_t)~ RTC_CTL_WTCS;
RTC_CTL |= (uint32_t)wakeup_clock;
error_status = SUCCESS;
@@ -1116,7 +1115,7 @@ ErrStatus rtc_wakeup_clock_set(uint8_t wakeup_clock)
}
/*!
- \brief set wakeup timer value
+ \brief set wakeup timer value
\param[in] wakeup_timer: 0x0000-0xffff
\param[out] none
\retval ErrStatus: ERROR or SUCCESS
@@ -1130,13 +1129,13 @@ ErrStatus rtc_wakeup_timer_set(uint16_t wakeup_timer)
RTC_WPK = RTC_UNLOCK_KEY1;
RTC_WPK = RTC_UNLOCK_KEY2;
/* wait until the WTWF flag to be set */
- do{
+ do {
flag_status = RTC_STAT & RTC_STAT_WTWF;
- }while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
+ } while((--time_index > 0U) && ((uint32_t)RESET == flag_status));
- if ((uint32_t)RESET == flag_status){
+ if((uint32_t)RESET == flag_status) {
error_status = ERROR;
- }else{
+ } else {
RTC_WUT = (uint32_t)wakeup_timer;
error_status = SUCCESS;
}
@@ -1146,18 +1145,18 @@ ErrStatus rtc_wakeup_timer_set(uint16_t wakeup_timer)
}
/*!
- \brief get wakeup timer value
+ \brief get wakeup timer value
\param[in] none
\param[out] none
\retval wakeup timer value
*/
- uint16_t rtc_wakeup_timer_get(void)
+uint16_t rtc_wakeup_timer_get(void)
{
return (uint16_t)RTC_WUT;
}
/*!
- \brief configure RTC smooth calibration
+ \brief configure RTC smooth calibration
\param[in] window: select calibration window
\arg RTC_CALIBRATION_WINDOW_32S: 2exp20 RTCCLK cycles, 32s if RTCCLK = 32768 Hz
\arg RTC_CALIBRATION_WINDOW_16S: 2exp19 RTCCLK cycles, 16s if RTCCLK = 32768 Hz
@@ -1180,11 +1179,11 @@ ErrStatus rtc_smooth_calibration_config(uint32_t window, uint32_t plus, uint32_t
RTC_WPK = RTC_UNLOCK_KEY2;
/* check if a smooth calibration operation is ongoing */
- do{
+ do {
flag_status = RTC_STAT & RTC_STAT_SCPF;
- }while((--time_index > 0U) && ((uint32_t)RESET != flag_status));
+ } while((--time_index > 0U) && ((uint32_t)RESET != flag_status));
- if((uint32_t)RESET == flag_status){
+ if((uint32_t)RESET == flag_status) {
RTC_HRFC = (uint32_t)(window | plus | HRFC_CMSK(minus));
error_status = SUCCESS;
}
@@ -1196,7 +1195,7 @@ ErrStatus rtc_smooth_calibration_config(uint32_t window, uint32_t plus, uint32_t
}
/*!
- \brief enable RTC coarse calibration
+ \brief enable RTC coarse calibration
\param[in] none
\param[out] none
\retval ErrStatus: ERROR or SUCCESS
@@ -1210,7 +1209,7 @@ ErrStatus rtc_coarse_calibration_enable(void)
/* enter init mode */
error_status = rtc_init_mode_enter();
- if(ERROR != error_status){
+ if(ERROR != error_status) {
RTC_CTL |= (uint32_t)RTC_CTL_CCEN;
/* exit init mode */
rtc_init_mode_exit();
@@ -1222,7 +1221,7 @@ ErrStatus rtc_coarse_calibration_enable(void)
}
/*!
- \brief disable RTC coarse calibration
+ \brief disable RTC coarse calibration
\param[in] none
\param[out] none
\retval ErrStatus: ERROR or SUCCESS
@@ -1236,7 +1235,7 @@ ErrStatus rtc_coarse_calibration_disable(void)
/* enter init mode */
error_status = rtc_init_mode_enter();
- if(ERROR != error_status){
+ if(ERROR != error_status) {
RTC_CTL &= (uint32_t)~RTC_CTL_CCEN;
/* exit init mode */
rtc_init_mode_exit();
@@ -1248,7 +1247,7 @@ ErrStatus rtc_coarse_calibration_disable(void)
}
/*!
- \brief config coarse calibration direction and step
+ \brief config coarse calibration direction and step
\param[in] direction: CALIB_INCREASE or CALIB_DECREASE
\param[in] step: 0x00-0x1F
COSD=0:
@@ -1276,10 +1275,10 @@ ErrStatus rtc_coarse_calibration_config(uint8_t direction, uint8_t step)
/* enter init mode */
error_status = rtc_init_mode_enter();
- if(ERROR != error_status){
- if(CALIB_DECREASE == direction){
+ if(ERROR != error_status) {
+ if(CALIB_DECREASE == direction) {
RTC_COSC |= (uint32_t)RTC_COSC_COSD;
- }else{
+ } else {
RTC_COSC &= (uint32_t)~RTC_COSC_COSD;
}
RTC_COSC &= ~RTC_COSC_COSS;
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_sdio.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_sdio.c
index d1d0a0be32..17b4ea96fe 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_sdio.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_sdio.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.1, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -37,7 +38,7 @@ OF SUCH DAMAGE.
#include "gd32f4xx_sdio.h"
/*!
- \brief deinitialize the SDIO
+ \brief deinitialize the SDIO
\param[in] none
\param[out] none
\retval none
@@ -49,7 +50,7 @@ void sdio_deinit(void)
}
/*!
- \brief configure the SDIO clock
+ \brief configure the SDIO clock
\param[in] clock_edge: SDIO_CLK clock edge
only one parameter can be selected which is shown as below:
\arg SDIO_SDIOCLKEDGE_RISING: select the rising edge of the SDIOCLK to generate SDIO_CLK
@@ -73,7 +74,7 @@ void sdio_clock_config(uint32_t clock_edge, uint32_t clock_bypass, uint32_t cloc
/* reset the CLKEDGE, CLKBYP, CLKPWRSAV, DIV */
clock_config &= ~(SDIO_CLKCTL_CLKEDGE | SDIO_CLKCTL_CLKBYP | SDIO_CLKCTL_CLKPWRSAV | SDIO_CLKCTL_DIV8 | SDIO_CLKCTL_DIV);
/* if the clock division is greater or equal to 256, set the DIV[8] */
- if(clock_division >= 256U){
+ if(clock_division >= 256U) {
clock_config |= SDIO_CLKCTL_DIV8;
clock_division -= 256U;
}
@@ -83,7 +84,7 @@ void sdio_clock_config(uint32_t clock_edge, uint32_t clock_bypass, uint32_t cloc
}
/*!
- \brief enable hardware clock control
+ \brief enable hardware clock control
\param[in] none
\param[out] none
\retval none
@@ -94,7 +95,7 @@ void sdio_hardware_clock_enable(void)
}
/*!
- \brief disable hardware clock control
+ \brief disable hardware clock control
\param[in] none
\param[out] none
\retval none
@@ -105,7 +106,7 @@ void sdio_hardware_clock_disable(void)
}
/*!
- \brief set different SDIO card bus mode
+ \brief set different SDIO card bus mode
\param[in] bus_mode: SDIO card bus mode
only one parameter can be selected which is shown as below:
\arg SDIO_BUSMODE_1BIT: 1-bit SDIO card bus mode
@@ -122,7 +123,7 @@ void sdio_bus_mode_set(uint32_t bus_mode)
}
/*!
- \brief set the SDIO power state
+ \brief set the SDIO power state
\param[in] power_state: SDIO power state
only one parameter can be selected which is shown as below:
\arg SDIO_POWER_ON: SDIO power on
@@ -136,7 +137,7 @@ void sdio_power_state_set(uint32_t power_state)
}
/*!
- \brief get the SDIO power state
+ \brief get the SDIO power state
\param[in] none
\param[out] none
\retval SDIO power state
@@ -149,7 +150,7 @@ uint32_t sdio_power_state_get(void)
}
/*!
- \brief enable SDIO_CLK clock output
+ \brief enable SDIO_CLK clock output
\param[in] none
\param[out] none
\retval none
@@ -160,7 +161,7 @@ void sdio_clock_enable(void)
}
/*!
- \brief disable SDIO_CLK clock output
+ \brief disable SDIO_CLK clock output
\param[in] none
\param[out] none
\retval none
@@ -171,7 +172,7 @@ void sdio_clock_disable(void)
}
/*!
- \brief configure the command and response
+ \brief configure the command and response
\param[in] cmd_index: command index, refer to the related specifications
\param[in] cmd_argument: command argument, refer to the related specifications
\param[in] response_type: response type
@@ -198,7 +199,7 @@ void sdio_command_response_config(uint32_t cmd_index, uint32_t cmd_argument, uin
}
/*!
- \brief set the command state machine wait type
+ \brief set the command state machine wait type
\param[in] wait_type: wait type
only one parameter can be selected which is shown as below:
\arg SDIO_WAITTYPE_NO: not wait interrupt
@@ -216,7 +217,7 @@ void sdio_wait_type_set(uint32_t wait_type)
}
/*!
- \brief enable the CSM(command state machine)
+ \brief enable the CSM(command state machine)
\param[in] none
\param[out] none
\retval none
@@ -227,7 +228,7 @@ void sdio_csm_enable(void)
}
/*!
- \brief disable the CSM(command state machine)
+ \brief disable the CSM(command state machine)
\param[in] none
\param[out] none
\retval none
@@ -238,7 +239,7 @@ void sdio_csm_disable(void)
}
/*!
- \brief get the last response command index
+ \brief get the last response command index
\param[in] none
\param[out] none
\retval last response command index
@@ -249,7 +250,7 @@ uint8_t sdio_command_index_get(void)
}
/*!
- \brief get the response for the last received command
+ \brief get the response for the last received command
\param[in] sdio_responsex: SDIO response
only one parameter can be selected which is shown as below:
\arg SDIO_RESPONSE0: card response[31:0]/card response[127:96]
@@ -262,7 +263,7 @@ uint8_t sdio_command_index_get(void)
uint32_t sdio_response_get(uint32_t sdio_responsex)
{
uint32_t resp_content = 0U;
- switch(sdio_responsex){
+ switch(sdio_responsex) {
case SDIO_RESPONSE0:
resp_content = SDIO_RESP0;
break;
@@ -282,7 +283,7 @@ uint32_t sdio_response_get(uint32_t sdio_responsex)
}
/*!
- \brief configure the data timeout, data length and data block size
+ \brief configure the data timeout, data length and data block size
\param[in] data_timeout: data timeout period in card bus clock periods
\param[in] data_length: number of data bytes to be transferred
\param[in] data_blocksize: size of data block for block transfer
@@ -318,7 +319,7 @@ void sdio_data_config(uint32_t data_timeout, uint32_t data_length, uint32_t data
}
/*!
- \brief configure the data transfer mode and direction
+ \brief configure the data transfer mode and direction
\param[in] transfer_mode: mode of data transfer
only one parameter can be selected which is shown as below:
\arg SDIO_TRANSMODE_BLOCK: block transfer
@@ -341,7 +342,7 @@ void sdio_data_transfer_config(uint32_t transfer_mode, uint32_t transfer_directi
}
/*!
- \brief enable the DSM(data state machine) for data transfer
+ \brief enable the DSM(data state machine) for data transfer
\param[in] none
\param[out] none
\retval none
@@ -352,7 +353,7 @@ void sdio_dsm_enable(void)
}
/*!
- \brief disable the DSM(data state machine)
+ \brief disable the DSM(data state machine)
\param[in] none
\param[out] none
\retval none
@@ -363,7 +364,7 @@ void sdio_dsm_disable(void)
}
/*!
- \brief write data(one word) to the transmit FIFO
+ \brief write data(one word) to the transmit FIFO
\param[in] data: 32-bit data write to card
\param[out] none
\retval none
@@ -374,7 +375,7 @@ void sdio_data_write(uint32_t data)
}
/*!
- \brief read data(one word) from the receive FIFO
+ \brief read data(one word) from the receive FIFO
\param[in] none
\param[out] none
\retval received data
@@ -385,7 +386,7 @@ uint32_t sdio_data_read(void)
}
/*!
- \brief get the number of remaining data bytes to be transferred to card
+ \brief get the number of remaining data bytes to be transferred to card
\param[in] none
\param[out] none
\retval number of remaining data bytes to be transferred
@@ -396,7 +397,7 @@ uint32_t sdio_data_counter_get(void)
}
/*!
- \brief get the number of words remaining to be written or read from FIFO
+ \brief get the number of words remaining to be written or read from FIFO
\param[in] none
\param[out] none
\retval remaining number of words
@@ -407,7 +408,7 @@ uint32_t sdio_fifo_counter_get(void)
}
/*!
- \brief enable the DMA request for SDIO
+ \brief enable the DMA request for SDIO
\param[in] none
\param[out] none
\retval none
@@ -418,7 +419,7 @@ void sdio_dma_enable(void)
}
/*!
- \brief disable the DMA request for SDIO
+ \brief disable the DMA request for SDIO
\param[in] none
\param[out] none
\retval none
@@ -429,7 +430,7 @@ void sdio_dma_disable(void)
}
/*!
- \brief get the flags state of SDIO
+ \brief get the flags state of SDIO
\param[in] flag: flags state of SDIO
one or more parameters can be selected which are shown as below:
\arg SDIO_FLAG_CCRCERR: command response received (CRC check failed) flag
@@ -462,14 +463,14 @@ void sdio_dma_disable(void)
FlagStatus sdio_flag_get(uint32_t flag)
{
FlagStatus temp_flag = RESET;
- if(RESET != (SDIO_STAT & flag)){
+ if(RESET != (SDIO_STAT & flag)) {
temp_flag = SET;
}
return temp_flag;
}
/*!
- \brief clear the pending flags of SDIO
+ \brief clear the pending flags of SDIO
\param[in] flag: flags state of SDIO
one or more parameters can be selected which are shown as below:
\arg SDIO_FLAG_CCRCERR: command response received (CRC check failed) flag
@@ -494,7 +495,7 @@ void sdio_flag_clear(uint32_t flag)
}
/*!
- \brief enable the SDIO interrupt
+ \brief enable the SDIO interrupt
\param[in] int_flag: interrupt flags state of SDIO
one or more parameters can be selected which are shown as below:
\arg SDIO_INT_CCRCERR: SDIO CCRCERR interrupt
@@ -530,7 +531,7 @@ void sdio_interrupt_enable(uint32_t int_flag)
}
/*!
- \brief disable the SDIO interrupt
+ \brief disable the SDIO interrupt
\param[in] int_flag: interrupt flags state of SDIO
one or more parameters can be selected which are shown as below:
\arg SDIO_INT_CCRCERR: SDIO CCRCERR interrupt
@@ -566,7 +567,7 @@ void sdio_interrupt_disable(uint32_t int_flag)
}
/*!
- \brief get the interrupt flags state of SDIO
+ \brief get the interrupt flags state of SDIO
\param[in] int_flag: interrupt flags state of SDIO
one or more parameters can be selected which are shown as below:
\arg SDIO_INT_FLAG_CCRCERR: SDIO CCRCERR interrupt flag
@@ -599,14 +600,14 @@ void sdio_interrupt_disable(uint32_t int_flag)
FlagStatus sdio_interrupt_flag_get(uint32_t int_flag)
{
FlagStatus temp_flag = RESET;
- if(RESET != (SDIO_STAT & int_flag)){
+ if(RESET != (SDIO_STAT & int_flag)) {
temp_flag = SET;
}
return temp_flag;
}
/*!
- \brief clear the interrupt pending flags of SDIO
+ \brief clear the interrupt pending flags of SDIO
\param[in] int_flag: interrupt flags state of SDIO
one or more parameters can be selected which are shown as below:
\arg SDIO_INT_FLAG_CCRCERR: command response received (CRC check failed) flag
@@ -631,7 +632,7 @@ void sdio_interrupt_flag_clear(uint32_t int_flag)
}
/*!
- \brief enable the read wait mode(SD I/O only)
+ \brief enable the read wait mode(SD I/O only)
\param[in] none
\param[out] none
\retval none
@@ -642,7 +643,7 @@ void sdio_readwait_enable(void)
}
/*!
- \brief disable the read wait mode(SD I/O only)
+ \brief disable the read wait mode(SD I/O only)
\param[in] none
\param[out] none
\retval none
@@ -653,7 +654,7 @@ void sdio_readwait_disable(void)
}
/*!
- \brief enable the function that stop the read wait process(SD I/O only)
+ \brief enable the function that stop the read wait process(SD I/O only)
\param[in] none
\param[out] none
\retval none
@@ -664,7 +665,7 @@ void sdio_stop_readwait_enable(void)
}
/*!
- \brief disable the function that stop the read wait process(SD I/O only)
+ \brief disable the function that stop the read wait process(SD I/O only)
\param[in] none
\param[out] none
\retval none
@@ -675,7 +676,7 @@ void sdio_stop_readwait_disable(void)
}
/*!
- \brief set the read wait type(SD I/O only)
+ \brief set the read wait type(SD I/O only)
\param[in] readwait_type: SD I/O read wait type
only one parameter can be selected which is shown as below:
\arg SDIO_READWAITTYPE_CLK: read wait control by stopping SDIO_CLK
@@ -685,15 +686,15 @@ void sdio_stop_readwait_disable(void)
*/
void sdio_readwait_type_set(uint32_t readwait_type)
{
- if(SDIO_READWAITTYPE_CLK == readwait_type){
+ if(SDIO_READWAITTYPE_CLK == readwait_type) {
SDIO_DATACTL |= SDIO_DATACTL_RWTYPE;
- }else{
+ } else {
SDIO_DATACTL &= ~SDIO_DATACTL_RWTYPE;
}
}
/*!
- \brief enable the SD I/O mode specific operation(SD I/O only)
+ \brief enable the SD I/O mode specific operation(SD I/O only)
\param[in] none
\param[out] none
\retval none
@@ -704,7 +705,7 @@ void sdio_operation_enable(void)
}
/*!
- \brief disable the SD I/O mode specific operation(SD I/O only)
+ \brief disable the SD I/O mode specific operation(SD I/O only)
\param[in] none
\param[out] none
\retval none
@@ -715,7 +716,7 @@ void sdio_operation_disable(void)
}
/*!
- \brief enable the SD I/O suspend operation(SD I/O only)
+ \brief enable the SD I/O suspend operation(SD I/O only)
\param[in] none
\param[out] none
\retval none
@@ -726,7 +727,7 @@ void sdio_suspend_enable(void)
}
/*!
- \brief disable the SD I/O suspend operation(SD I/O only)
+ \brief disable the SD I/O suspend operation(SD I/O only)
\param[in] none
\param[out] none
\retval none
@@ -737,7 +738,7 @@ void sdio_suspend_disable(void)
}
/*!
- \brief enable the CE-ATA command(CE-ATA only)
+ \brief enable the CE-ATA command(CE-ATA only)
\param[in] none
\param[out] none
\retval none
@@ -748,7 +749,7 @@ void sdio_ceata_command_enable(void)
}
/*!
- \brief disable the CE-ATA command(CE-ATA only)
+ \brief disable the CE-ATA command(CE-ATA only)
\param[in] none
\param[out] none
\retval none
@@ -759,7 +760,7 @@ void sdio_ceata_command_disable(void)
}
/*!
- \brief enable the CE-ATA interrupt(CE-ATA only)
+ \brief enable the CE-ATA interrupt(CE-ATA only)
\param[in] none
\param[out] none
\retval none
@@ -770,7 +771,7 @@ void sdio_ceata_interrupt_enable(void)
}
/*!
- \brief disable the CE-ATA interrupt(CE-ATA only)
+ \brief disable the CE-ATA interrupt(CE-ATA only)
\param[in] none
\param[out] none
\retval none
@@ -781,7 +782,7 @@ void sdio_ceata_interrupt_disable(void)
}
/*!
- \brief enable the CE-ATA command completion signal(CE-ATA only)
+ \brief enable the CE-ATA command completion signal(CE-ATA only)
\param[in] none
\param[out] none
\retval none
@@ -792,7 +793,7 @@ void sdio_ceata_command_completion_enable(void)
}
/*!
- \brief disable the CE-ATA command completion signal(CE-ATA only)
+ \brief disable the CE-ATA command completion signal(CE-ATA only)
\param[in] none
\param[out] none
\retval none
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_spi.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_spi.c
index 3f842251fc..c2fe7c1c07 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_spi.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_spi.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -54,7 +55,7 @@ OF SUCH DAMAGE.
*/
void spi_i2s_deinit(uint32_t spi_periph)
{
- switch(spi_periph){
+ switch(spi_periph) {
case SPI0:
/* reset SPI0 */
rcu_periph_reset_enable(RCU_SPI0RST);
@@ -124,7 +125,7 @@ void spi_struct_para_init(spi_parameter_struct *spi_struct)
\param[out] none
\retval none
*/
-void spi_init(uint32_t spi_periph, spi_parameter_struct* spi_struct)
+void spi_init(uint32_t spi_periph, spi_parameter_struct *spi_struct)
{
uint32_t reg = 0U;
reg = SPI_CTL0(spi_periph);
@@ -198,7 +199,7 @@ void spi_disable(uint32_t spi_periph)
*/
void i2s_init(uint32_t spi_periph, uint32_t i2s_mode, uint32_t i2s_standard, uint32_t i2s_ckpl)
{
- uint32_t reg= 0U;
+ uint32_t reg = 0U;
reg = SPI_I2SCTL(spi_periph);
reg &= I2S_INIT_MASK;
@@ -249,7 +250,7 @@ void i2s_psc_config(uint32_t spi_periph, uint32_t i2s_audiosample, uint32_t i2s_
uint32_t i2sclock = 0U;
#ifndef I2S_EXTERNAL_CLOCK_IN
- uint32_t plli2sm = 0U, plli2sn = 0U, plli2sr = 0U;
+ uint32_t plli2sm = 0U, plli2sn = 0U, plli2sr = 0U;
#endif /* I2S_EXTERNAL_CLOCK_IN */
/* deinit SPI_I2SPSC register */
@@ -280,25 +281,23 @@ void i2s_psc_config(uint32_t spi_periph, uint32_t i2s_audiosample, uint32_t i2s_
/* get the RCU_PLLI2S_PLLI2SR value */
plli2sr = (uint32_t)((RCU_PLLI2S & RCU_PLLI2S_PLLI2SR) >> 28);
- if((RCU_PLL & RCU_PLL_PLLSEL) == RCU_PLLSRC_HXTAL)
- {
- /* get the I2S source clock value */
- i2sclock = (uint32_t)(((HXTAL_VALUE / plli2sm) * plli2sn) / plli2sr);
- }
- else
- { /* get the I2S source clock value */
- i2sclock = (uint32_t)(((IRC16M_VALUE / plli2sm) * plli2sn) / plli2sr);
+ if((RCU_PLL & RCU_PLL_PLLSEL) == RCU_PLLSRC_HXTAL) {
+ /* get the I2S source clock value */
+ i2sclock = (uint32_t)(((HXTAL_VALUE / plli2sm) * plli2sn) / plli2sr);
+ } else {
+ /* get the I2S source clock value */
+ i2sclock = (uint32_t)(((IRC16M_VALUE / plli2sm) * plli2sn) / plli2sr);
}
#endif /* I2S_EXTERNAL_CLOCK_IN */
/* config the prescaler depending on the mclk output state, the frame format and audio sample rate */
- if(I2S_MCKOUT_ENABLE == i2s_mckout){
+ if(I2S_MCKOUT_ENABLE == i2s_mckout) {
clks = (uint32_t)(((i2sclock / 256U) * 10U) / i2s_audiosample);
- }else{
- if(I2S_FRAMEFORMAT_DT16B_CH16B == i2s_frameformat){
- clks = (uint32_t)(((i2sclock / 32U) *10U ) / i2s_audiosample);
- }else{
- clks = (uint32_t)(((i2sclock / 64U) *10U ) / i2s_audiosample);
+ } else {
+ if(I2S_FRAMEFORMAT_DT16B_CH16B == i2s_frameformat) {
+ clks = (uint32_t)(((i2sclock / 32U) * 10U) / i2s_audiosample);
+ } else {
+ clks = (uint32_t)(((i2sclock / 64U) * 10U) / i2s_audiosample);
}
}
/* remove the floating point */
@@ -308,7 +307,7 @@ void i2s_psc_config(uint32_t spi_periph, uint32_t i2s_audiosample, uint32_t i2s_
i2sof = (i2sof << 8U);
/* set the default values */
- if((i2sdiv< 2U) || (i2sdiv > 255U)){
+ if((i2sdiv < 2U) || (i2sdiv > 255U)) {
i2sdiv = 2U;
i2sof = 0U;
}
@@ -317,7 +316,7 @@ void i2s_psc_config(uint32_t spi_periph, uint32_t i2s_audiosample, uint32_t i2s_
SPI_I2SPSC(spi_periph) = (uint32_t)(i2sdiv | i2sof | i2s_mckout);
/* clear SPI_I2SCTL_DTLEN and SPI_I2SCTL_CHLEN bits */
- SPI_I2SCTL(spi_periph) &= (uint32_t)(~(SPI_I2SCTL_DTLEN|SPI_I2SCTL_CHLEN));
+ SPI_I2SCTL(spi_periph) &= (uint32_t)(~(SPI_I2SCTL_DTLEN | SPI_I2SCTL_CHLEN));
/* configure data frame format */
SPI_I2SCTL(spi_periph) |= (uint32_t)i2s_frameformat;
}
@@ -400,9 +399,9 @@ void spi_nss_internal_low(uint32_t spi_periph)
*/
void spi_dma_enable(uint32_t spi_periph, uint8_t spi_dma)
{
- if(SPI_DMA_TRANSMIT == spi_dma){
+ if(SPI_DMA_TRANSMIT == spi_dma) {
SPI_CTL1(spi_periph) |= (uint32_t)SPI_CTL1_DMATEN;
- }else{
+ } else {
SPI_CTL1(spi_periph) |= (uint32_t)SPI_CTL1_DMAREN;
}
}
@@ -419,9 +418,9 @@ void spi_dma_enable(uint32_t spi_periph, uint8_t spi_dma)
*/
void spi_dma_disable(uint32_t spi_periph, uint8_t spi_dma)
{
- if(SPI_DMA_TRANSMIT == spi_dma){
+ if(SPI_DMA_TRANSMIT == spi_dma) {
SPI_CTL1(spi_periph) &= (uint32_t)(~SPI_CTL1_DMATEN);
- }else{
+ } else {
SPI_CTL1(spi_periph) &= (uint32_t)(~SPI_CTL1_DMAREN);
}
}
@@ -478,27 +477,93 @@ uint16_t spi_i2s_data_receive(uint32_t spi_periph)
*/
void spi_bidirectional_transfer_config(uint32_t spi_periph, uint32_t transfer_direction)
{
- if(SPI_BIDIRECTIONAL_TRANSMIT == transfer_direction){
+ if(SPI_BIDIRECTIONAL_TRANSMIT == transfer_direction) {
/* set the transmit only mode */
SPI_CTL0(spi_periph) |= (uint32_t)SPI_BIDIRECTIONAL_TRANSMIT;
- }else{
+ } else {
/* set the receive only mode */
SPI_CTL0(spi_periph) &= SPI_BIDIRECTIONAL_RECEIVE;
}
}
/*!
+ \brief configure i2s full duplex mode
+ \param[in] i2s_add_periph: I2Sx_ADD(x=1,2)
+ \param[in] i2s_mode:
+ \arg I2S_MODE_SLAVETX : I2S slave transmit mode
+ \arg I2S_MODE_SLAVERX : I2S slave receive mode
+ \arg I2S_MODE_MASTERTX : I2S master transmit mode
+ \arg I2S_MODE_MASTERRX : I2S master receive mode
+ \param[in] i2s_standard:
+ \arg I2S_STD_PHILLIPS : I2S phillips standard
+ \arg I2S_STD_MSB : I2S MSB standard
+ \arg I2S_STD_LSB : I2S LSB standard
+ \arg I2S_STD_PCMSHORT : I2S PCM short standard
+ \arg I2S_STD_PCMLONG : I2S PCM long standard
+ \param[in] i2s_ckpl:
+ \arg I2S_CKPL_LOW : I2S clock polarity low level
+ \arg I2S_CKPL_HIGH : I2S clock polarity high level
+ \param[in] i2s_frameformat:
+ \arg I2S_FRAMEFORMAT_DT16B_CH16B: I2S data length is 16 bit and channel length is 16 bit
+ \arg I2S_FRAMEFORMAT_DT16B_CH32B: I2S data length is 16 bit and channel length is 32 bit
+ \arg I2S_FRAMEFORMAT_DT24B_CH32B: I2S data length is 24 bit and channel length is 32 bit
+ \arg I2S_FRAMEFORMAT_DT32B_CH32B: I2S data length is 32 bit and channel length is 32 bit
+ \param[out] none
+ \retval none
+*/
+void i2s_full_duplex_mode_config(uint32_t i2s_add_periph, uint32_t i2s_mode, uint32_t i2s_standard,
+ uint32_t i2s_ckpl, uint32_t i2s_frameformat)
+{
+ uint32_t reg = 0U, tmp = 0U;
+
+ reg = I2S_ADD_I2SCTL(i2s_add_periph);
+ reg &= I2S_FULL_DUPLEX_MASK;
+
+ /* get the mode of the extra I2S module I2Sx_ADD */
+ if((I2S_MODE_MASTERTX == i2s_mode) || (I2S_MODE_SLAVETX == i2s_mode)) {
+ tmp = I2S_MODE_SLAVERX;
+ } else {
+ tmp = I2S_MODE_SLAVETX;
+ }
+
+ /* enable I2S mode */
+ reg |= (uint32_t)SPI_I2SCTL_I2SSEL;
+ /* select I2S mode */
+ reg |= (uint32_t)tmp;
+ /* select I2S standard */
+ reg |= (uint32_t)i2s_standard;
+ /* select I2S polarity */
+ reg |= (uint32_t)i2s_ckpl;
+ /* configure data frame format */
+ reg |= (uint32_t)i2s_frameformat;
+
+ /* write to SPI_I2SCTL register */
+ I2S_ADD_I2SCTL(i2s_add_periph) = (uint32_t)reg;
+}
+
+/*!
+ \brief clear SPI/I2S format error flag status
+ \param[in] spi_periph: SPIx(x=0,1,2,3,4,5)
+ \param[in] flag: SPI/I2S frame format error flag
+ \arg SPI_FLAG_FERR: only for SPI work in TI mode
+ \arg I2S_FLAG_FERR: for I2S
+ \param[out] none
+ \retval none
+*/
+void spi_i2s_format_error_clear(uint32_t spi_periph, uint32_t flag)
+{
+ SPI_STAT(spi_periph) = (uint32_t)(~flag);
+}
+
+/*!
\brief set SPI CRC polynomial
\param[in] spi_periph: SPIx(x=0,1,2,3,4,5)
\param[in] crc_poly: CRC polynomial value
\param[out] none
\retval none
*/
-void spi_crc_polynomial_set(uint32_t spi_periph,uint16_t crc_poly)
+void spi_crc_polynomial_set(uint32_t spi_periph, uint16_t crc_poly)
{
- /* enable SPI CRC */
- SPI_CTL0(spi_periph) |= (uint32_t)SPI_CTL0_CRCEN;
-
/* set SPI CRC polynomial */
SPI_CRCPOLY(spi_periph) = (uint32_t)crc_poly;
}
@@ -515,7 +580,7 @@ uint16_t spi_crc_polynomial_get(uint32_t spi_periph)
}
/*!
- \brief turn on CRC function
+ \brief turn on SPI CRC function
\param[in] spi_periph: SPIx(x=0,1,2,3,4,5)
\param[out] none
\retval none
@@ -526,7 +591,7 @@ void spi_crc_on(uint32_t spi_periph)
}
/*!
- \brief turn off CRC function
+ \brief turn off SPI CRC function
\param[in] spi_periph: SPIx(x=0,1,2,3,4,5)
\param[out] none
\retval none
@@ -557,90 +622,46 @@ void spi_crc_next(uint32_t spi_periph)
\param[out] none
\retval 16-bit CRC value
*/
-uint16_t spi_crc_get(uint32_t spi_periph,uint8_t spi_crc)
+uint16_t spi_crc_get(uint32_t spi_periph, uint8_t spi_crc)
{
- if(SPI_CRC_TX == spi_crc){
+ if(SPI_CRC_TX == spi_crc) {
return ((uint16_t)(SPI_TCRC(spi_periph)));
- }else{
+ } else {
return ((uint16_t)(SPI_RCRC(spi_periph)));
}
}
/*!
- \brief enable SPI TI mode
+ \brief clear SPI CRC error flag status
\param[in] spi_periph: SPIx(x=0,1,2,3,4,5)
\param[out] none
\retval none
*/
-void spi_ti_mode_enable(uint32_t spi_periph)
+void spi_crc_error_clear(uint32_t spi_periph)
{
- SPI_CTL1(spi_periph) |= (uint32_t)SPI_CTL1_TMOD;
+ SPI_STAT(spi_periph) = (uint32_t)(~SPI_FLAG_CRCERR);
}
/*!
- \brief disable SPI TI mode
+ \brief enable SPI TI mode
\param[in] spi_periph: SPIx(x=0,1,2,3,4,5)
\param[out] none
\retval none
*/
-void spi_ti_mode_disable(uint32_t spi_periph)
+void spi_ti_mode_enable(uint32_t spi_periph)
{
- SPI_CTL1(spi_periph) &= (uint32_t)(~SPI_CTL1_TMOD);
+ SPI_CTL1(spi_periph) |= (uint32_t)SPI_CTL1_TMOD;
}
/*!
- \brief configure i2s full duplex mode
- \param[in] i2s_add_periph: I2Sx_ADD(x=1,2)
- \param[in] i2s_mode:
- \arg I2S_MODE_SLAVETX : I2S slave transmit mode
- \arg I2S_MODE_SLAVERX : I2S slave receive mode
- \arg I2S_MODE_MASTERTX : I2S master transmit mode
- \arg I2S_MODE_MASTERRX : I2S master receive mode
- \param[in] i2s_standard:
- \arg I2S_STD_PHILLIPS : I2S phillips standard
- \arg I2S_STD_MSB : I2S MSB standard
- \arg I2S_STD_LSB : I2S LSB standard
- \arg I2S_STD_PCMSHORT : I2S PCM short standard
- \arg I2S_STD_PCMLONG : I2S PCM long standard
- \param[in] i2s_ckpl:
- \arg I2S_CKPL_LOW : I2S clock polarity low level
- \arg I2S_CKPL_HIGH : I2S clock polarity high level
- \param[in] i2s_frameformat:
- \arg I2S_FRAMEFORMAT_DT16B_CH16B: I2S data length is 16 bit and channel length is 16 bit
- \arg I2S_FRAMEFORMAT_DT16B_CH32B: I2S data length is 16 bit and channel length is 32 bit
- \arg I2S_FRAMEFORMAT_DT24B_CH32B: I2S data length is 24 bit and channel length is 32 bit
- \arg I2S_FRAMEFORMAT_DT32B_CH32B: I2S data length is 32 bit and channel length is 32 bit
+ \brief disable SPI TI mode
+ \param[in] spi_periph: SPIx(x=0,1,2,3,4,5)
\param[out] none
\retval none
*/
-void i2s_full_duplex_mode_config(uint32_t i2s_add_periph, uint32_t i2s_mode, uint32_t i2s_standard,
- uint32_t i2s_ckpl, uint32_t i2s_frameformat)
+void spi_ti_mode_disable(uint32_t spi_periph)
{
- uint32_t reg = 0U, tmp = 0U;
-
- reg = I2S_ADD_I2SCTL(i2s_add_periph);
- reg &= I2S_FULL_DUPLEX_MASK;
-
- /* get the mode of the extra I2S module I2Sx_ADD */
- if((I2S_MODE_MASTERTX == i2s_mode) || (I2S_MODE_SLAVETX == i2s_mode)){
- tmp = I2S_MODE_SLAVERX;
- }else{
- tmp = I2S_MODE_SLAVETX;
- }
-
- /* enable I2S mode */
- reg |= (uint32_t)SPI_I2SCTL_I2SSEL;
- /* select I2S mode */
- reg |= (uint32_t)tmp;
- /* select I2S standard */
- reg |= (uint32_t)i2s_standard;
- /* select I2S polarity */
- reg |= (uint32_t)i2s_ckpl;
- /* configure data frame format */
- reg |= (uint32_t)i2s_frameformat;
-
- /* write to SPI_I2SCTL register */
- I2S_ADD_I2SCTL(i2s_add_periph) = (uint32_t)reg;
+ SPI_CTL1(spi_periph) &= (uint32_t)(~SPI_CTL1_TMOD);
}
/*!
@@ -649,7 +670,7 @@ void i2s_full_duplex_mode_config(uint32_t i2s_add_periph, uint32_t i2s_mode, uin
\param[out] none
\retval none
*/
-void qspi_enable(uint32_t spi_periph)
+void spi_quad_enable(uint32_t spi_periph)
{
SPI_QCTL(spi_periph) |= (uint32_t)SPI_QCTL_QMOD;
}
@@ -660,7 +681,7 @@ void qspi_enable(uint32_t spi_periph)
\param[out] none
\retval none
*/
-void qspi_disable(uint32_t spi_periph)
+void spi_quad_disable(uint32_t spi_periph)
{
SPI_QCTL(spi_periph) &= (uint32_t)(~SPI_QCTL_QMOD);
}
@@ -671,7 +692,7 @@ void qspi_disable(uint32_t spi_periph)
\param[out] none
\retval none
*/
-void qspi_write_enable(uint32_t spi_periph)
+void spi_quad_write_enable(uint32_t spi_periph)
{
SPI_QCTL(spi_periph) &= (uint32_t)(~SPI_QCTL_QRD);
}
@@ -682,7 +703,7 @@ void qspi_write_enable(uint32_t spi_periph)
\param[out] none
\retval none
*/
-void qspi_read_enable(uint32_t spi_periph)
+void spi_quad_read_enable(uint32_t spi_periph)
{
SPI_QCTL(spi_periph) |= (uint32_t)SPI_QCTL_QRD;
}
@@ -693,23 +714,54 @@ void qspi_read_enable(uint32_t spi_periph)
\param[out] none
\retval none
*/
-void qspi_io23_output_enable(uint32_t spi_periph)
+void spi_quad_io23_output_enable(uint32_t spi_periph)
{
SPI_QCTL(spi_periph) |= (uint32_t)SPI_QCTL_IO23_DRV;
}
- /*!
- \brief disable SPI_IO2 and SPI_IO3 pin output
- \param[in] spi_periph: SPIx(only x=5)
- \param[out] none
- \retval none
+/*!
+ \brief disable SPI_IO2 and SPI_IO3 pin output
+ \param[in] spi_periph: SPIx(only x=5)
+ \param[out] none
+ \retval none
*/
- void qspi_io23_output_disable(uint32_t spi_periph)
+void spi_quad_io23_output_disable(uint32_t spi_periph)
{
SPI_QCTL(spi_periph) &= (uint32_t)(~SPI_QCTL_IO23_DRV);
}
/*!
+ \brief get SPI and I2S flag status
+ \param[in] spi_periph: SPIx(x=0,1,2,3,4,5)
+ \param[in] spi_i2s_flag: SPI/I2S flag status
+ only one parameter can be selected which are shown as below:
+ \arg SPI_FLAG_TBE: transmit buffer empty flag
+ \arg SPI_FLAG_RBNE: receive buffer not empty flag
+ \arg SPI_FLAG_TRANS: transmit on-going flag
+ \arg SPI_FLAG_RXORERR: receive overrun error flag
+ \arg SPI_FLAG_CONFERR: mode config error flag
+ \arg SPI_FLAG_CRCERR: CRC error flag
+ \arg SPI_FLAG_FERR: format error flag
+ \arg I2S_FLAG_TBE: transmit buffer empty flag
+ \arg I2S_FLAG_RBNE: receive buffer not empty flag
+ \arg I2S_FLAG_TRANS: transmit on-going flag
+ \arg I2S_FLAG_RXORERR: overrun error flag
+ \arg I2S_FLAG_TXURERR: underrun error flag
+ \arg I2S_FLAG_CH: channel side flag
+ \arg I2S_FLAG_FERR: format error flag
+ \param[out] none
+ \retval FlagStatus: SET or RESET
+*/
+FlagStatus spi_i2s_flag_get(uint32_t spi_periph, uint32_t flag)
+{
+ if(SPI_STAT(spi_periph) & flag) {
+ return SET;
+ } else {
+ return RESET;
+ }
+}
+
+/*!
\brief enable SPI and I2S interrupt
\param[in] spi_periph: SPIx(x=0,1,2,3,4,5)
\param[in] spi_i2s_int: SPI/I2S interrupt
@@ -721,9 +773,9 @@ void qspi_io23_output_enable(uint32_t spi_periph)
\param[out] none
\retval none
*/
-void spi_i2s_interrupt_enable(uint32_t spi_periph, uint8_t spi_i2s_int)
+void spi_i2s_interrupt_enable(uint32_t spi_periph, uint8_t interrupt)
{
- switch(spi_i2s_int){
+ switch(interrupt) {
/* SPI/I2S transmit buffer empty interrupt */
case SPI_I2S_INT_TBE:
SPI_CTL1(spi_periph) |= (uint32_t)SPI_CTL1_TBEIE;
@@ -753,9 +805,9 @@ void spi_i2s_interrupt_enable(uint32_t spi_periph, uint8_t spi_i2s_int)
\param[out] none
\retval none
*/
-void spi_i2s_interrupt_disable(uint32_t spi_periph, uint8_t spi_i2s_int)
+void spi_i2s_interrupt_disable(uint32_t spi_periph, uint8_t interrupt)
{
- switch(spi_i2s_int){
+ switch(interrupt) {
/* SPI/I2S transmit buffer empty interrupt */
case SPI_I2S_INT_TBE :
SPI_CTL1(spi_periph) &= (uint32_t)(~SPI_CTL1_TBEIE);
@@ -777,6 +829,7 @@ void spi_i2s_interrupt_disable(uint32_t spi_periph, uint8_t spi_i2s_int)
\brief get SPI and I2S interrupt flag status
\param[in] spi_periph: SPIx(x=0,1,2,3,4,5)
\param[in] spi_i2s_int: SPI/I2S interrupt flag status
+ only one parameter can be selected which are shown as below:
\arg SPI_I2S_INT_FLAG_TBE: transmit buffer empty interrupt flag
\arg SPI_I2S_INT_FLAG_RBNE: receive buffer not empty interrupt flag
\arg SPI_I2S_INT_FLAG_RXORERR: overrun interrupt flag
@@ -787,12 +840,12 @@ void spi_i2s_interrupt_disable(uint32_t spi_periph, uint8_t spi_i2s_int)
\param[out] none
\retval FlagStatus: SET or RESET
*/
-FlagStatus spi_i2s_interrupt_flag_get(uint32_t spi_periph, uint8_t spi_i2s_int)
+FlagStatus spi_i2s_interrupt_flag_get(uint32_t spi_periph, uint8_t interrupt)
{
uint32_t reg1 = SPI_STAT(spi_periph);
uint32_t reg2 = SPI_CTL1(spi_periph);
- switch(spi_i2s_int){
+ switch(interrupt) {
/* SPI/I2S transmit buffer empty interrupt */
case SPI_I2S_INT_FLAG_TBE :
reg1 = reg1 & SPI_STAT_TBE;
@@ -832,51 +885,9 @@ FlagStatus spi_i2s_interrupt_flag_get(uint32_t spi_periph, uint8_t spi_i2s_int)
break;
}
/*get SPI/I2S interrupt flag status */
- if(reg1 && reg2){
- return SET;
- }else{
- return RESET;
- }
-}
-
-/*!
- \brief get SPI and I2S flag status
- \param[in] spi_periph: SPIx(x=0,1,2,3,4,5)
- \param[in] spi_i2s_flag: SPI/I2S flag status
- \arg SPI_FLAG_TBE: transmit buffer empty flag
- \arg SPI_FLAG_RBNE: receive buffer not empty flag
- \arg SPI_FLAG_TRANS: transmit on-going flag
- \arg SPI_FLAG_RXORERR: receive overrun error flag
- \arg SPI_FLAG_CONFERR: mode config error flag
- \arg SPI_FLAG_CRCERR: CRC error flag
- \arg SPI_FLAG_FERR: format error flag
- \arg I2S_FLAG_TBE: transmit buffer empty flag
- \arg I2S_FLAG_RBNE: receive buffer not empty flag
- \arg I2S_FLAG_TRANS: transmit on-going flag
- \arg I2S_FLAG_RXORERR: overrun error flag
- \arg I2S_FLAG_TXURERR: underrun error flag
- \arg I2S_FLAG_CH: channel side flag
- \arg I2S_FLAG_FERR: format error flag
- \param[out] none
- \retval FlagStatus: SET or RESET
-*/
-FlagStatus spi_i2s_flag_get(uint32_t spi_periph, uint32_t spi_i2s_flag)
-{
- if(SPI_STAT(spi_periph) & spi_i2s_flag){
+ if(reg1 && reg2) {
return SET;
- }else{
+ } else {
return RESET;
}
}
-
-/*!
- \brief clear SPI CRC error flag status
- \param[in] spi_periph: SPIx(x=0,1,2,3,4,5)
- \param[out] none
- \retval none
-*/
-void spi_crc_error_clear(uint32_t spi_periph)
-{
- SPI_STAT(spi_periph) &= (uint32_t)(~SPI_FLAG_CRCERR);
-}
-
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_syscfg.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_syscfg.c
index 6fa0a776d0..3c13fcd8bc 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_syscfg.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_syscfg.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -37,7 +38,7 @@ OF SUCH DAMAGE.
#include "gd32f4xx_syscfg.h"
/*!
- \brief reset the SYSCFG registers
+ \brief reset the SYSCFG registers
\param[in] none
\param[out] none
\retval none
@@ -49,7 +50,7 @@ void syscfg_deinit(void)
}
/*!
- \brief configure the boot mode
+ \brief configure the boot mode
\param[in] syscfg_bootmode: selects the memory remapping
only one parameter can be selected which is shown as below:
\arg SYSCFG_BOOTMODE_FLASH: main flash memory (0x08000000~0x083BFFFF) is mapped at address 0x00000000
@@ -68,7 +69,7 @@ void syscfg_bootmode_config(uint8_t syscfg_bootmode)
}
/*!
- \brief FMC memory mapping swap
+ \brief FMC memory mapping swap
\param[in] syscfg_fmc_swap: selects the interal flash bank swapping
only one parameter can be selected which is shown as below:
\arg SYSCFG_FMC_SWP_BANK0: bank 0 is mapped at address 0x08000000 and bank 1 is mapped at address 0x08100000
@@ -86,7 +87,7 @@ void syscfg_fmc_swap_config(uint32_t syscfg_fmc_swap)
}
/*!
- \brief EXMC memory mapping swap
+ \brief EXMC memory mapping swap
\param[in] syscfg_exmc_swap: selects the memories in EXMC swapping
only one parameter can be selected which is shown as below:
\arg SYSCFG_EXMC_SWP_ENABLE: SDRAM bank 0 and bank 1 are swapped with NAND bank 1 and PC card
@@ -105,7 +106,7 @@ void syscfg_exmc_swap_config(uint32_t syscfg_exmc_swap)
}
/*!
- \brief configure the GPIO pin as EXTI Line
+ \brief configure the GPIO pin as EXTI Line
\param[in] exti_port: specify the GPIO port used in EXTI
only one parameter can be selected which is shown as below:
\arg EXTI_SOURCE_GPIOx(x = A,B,C,D,E,F,G,H,I): EXTI GPIO port
@@ -120,7 +121,7 @@ void syscfg_exti_line_config(uint8_t exti_port, uint8_t exti_pin)
uint32_t clear_exti_mask = ~((uint32_t)EXTI_SS_MASK << (EXTI_SS_MSTEP(exti_pin)));
uint32_t config_exti_mask = ((uint32_t)exti_port) << (EXTI_SS_MSTEP(exti_pin));
- switch(exti_pin/EXTI_SS_JSTEP){
+ switch(exti_pin / EXTI_SS_JSTEP) {
case EXTISS0:
/* clear EXTI source line(0..3) */
SYSCFG_EXTISS0 &= clear_exti_mask;
@@ -151,7 +152,7 @@ void syscfg_exti_line_config(uint8_t exti_port, uint8_t exti_pin)
}
/*!
- \brief configure the PHY interface for the ethernet MAC
+ \brief configure the PHY interface for the ethernet MAC
\param[in] syscfg_enet_phy_interface: specifies the media interface mode.
only one parameter can be selected which is shown as below:
\arg SYSCFG_ENET_PHY_MII: MII mode is selected
@@ -170,7 +171,7 @@ void syscfg_enet_phy_interface_config(uint32_t syscfg_enet_phy_interface)
}
/*!
- \brief configure the I/O compensation cell
+ \brief configure the I/O compensation cell
\param[in] syscfg_compensation: specifies the I/O compensation cell mode
only one parameter can be selected which is shown as below:
\arg SYSCFG_COMPENSATION_ENABLE: I/O compensation cell is enabled
@@ -189,16 +190,16 @@ void syscfg_compensation_config(uint32_t syscfg_compensation)
}
/*!
- \brief checks whether the I/O compensation cell ready flag is set or not
+ \brief checks whether the I/O compensation cell ready flag is set or not
\param[in] none
\param[out] none
\retval FlagStatus: SET or RESET
*/
FlagStatus syscfg_flag_get(void)
{
- if(((uint32_t)RESET) != (SYSCFG_CPSCTL & SYSCFG_CPSCTL_CPS_RDY)){
+ if(((uint32_t)RESET) != (SYSCFG_CPSCTL & SYSCFG_CPSCTL_CPS_RDY)) {
return SET;
- }else{
+ } else {
return RESET;
}
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_timer.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_timer.c
index e312680222..0fc34e3e05 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_timer.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_timer.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -45,7 +46,7 @@ OF SUCH DAMAGE.
*/
void timer_deinit(uint32_t timer_periph)
{
- switch(timer_periph){
+ switch(timer_periph) {
case TIMER0:
/* reset TIMER0 */
rcu_periph_reset_enable(RCU_TIMER0RST);
@@ -127,7 +128,7 @@ void timer_deinit(uint32_t timer_periph)
\param[out] none
\retval none
*/
-void timer_struct_para_init(timer_parameter_struct* initpara)
+void timer_struct_para_init(timer_parameter_struct *initpara)
{
/* initialize the init parameter struct member with the default value */
initpara->prescaler = 0U;
@@ -151,15 +152,15 @@ void timer_struct_para_init(timer_parameter_struct* initpara)
\param[out] none
\retval none
*/
-void timer_init(uint32_t timer_periph, timer_parameter_struct* initpara)
+void timer_init(uint32_t timer_periph, timer_parameter_struct *initpara)
{
/* configure the counter prescaler value */
TIMER_PSC(timer_periph) = (uint16_t)initpara->prescaler;
/* configure the counter direction and aligned mode */
if((TIMER0 == timer_periph) || (TIMER1 == timer_periph) || (TIMER2 == timer_periph)
- || (TIMER3 == timer_periph) || (TIMER4 == timer_periph) || (TIMER7 == timer_periph)){
- TIMER_CTL0(timer_periph) &= ~(uint32_t)(TIMER_CTL0_DIR|TIMER_CTL0_CAM);
+ || (TIMER3 == timer_periph) || (TIMER4 == timer_periph) || (TIMER7 == timer_periph)) {
+ TIMER_CTL0(timer_periph) &= ~(uint32_t)(TIMER_CTL0_DIR | TIMER_CTL0_CAM);
TIMER_CTL0(timer_periph) |= (uint32_t)initpara->alignedmode;
TIMER_CTL0(timer_periph) |= (uint32_t)initpara->counterdirection;
}
@@ -167,13 +168,13 @@ void timer_init(uint32_t timer_periph, timer_parameter_struct* initpara)
/* configure the autoreload value */
TIMER_CAR(timer_periph) = (uint32_t)initpara->period;
- if((TIMER5 != timer_periph) && (TIMER6 != timer_periph)){
+ if((TIMER5 != timer_periph) && (TIMER6 != timer_periph)) {
/* reset the CKDIV bit */
TIMER_CTL0(timer_periph) &= ~(uint32_t)TIMER_CTL0_CKDIV;
TIMER_CTL0(timer_periph) |= (uint32_t)initpara->clockdivision;
}
- if((TIMER0 == timer_periph) || (TIMER7 == timer_periph)){
+ if((TIMER0 == timer_periph) || (TIMER7 == timer_periph)) {
/* configure the repetition counter value */
TIMER_CREP(timer_periph) = (uint32_t)initpara->repetitioncounter;
}
@@ -303,7 +304,7 @@ void timer_prescaler_config(uint32_t timer_periph, uint16_t prescaler, uint8_t p
{
TIMER_PSC(timer_periph) = (uint32_t)prescaler;
- if(TIMER_PSC_RELOAD_NOW == pscreload){
+ if(TIMER_PSC_RELOAD_NOW == pscreload) {
TIMER_SWEVG(timer_periph) |= (uint32_t)TIMER_SWEVG_UPG;
}
}
@@ -327,7 +328,7 @@ void timer_repetition_value_config(uint32_t timer_periph, uint16_t repetition)
\param[out] none
\retval none
*/
-void timer_autoreload_value_config(uint32_t timer_periph,uint32_t autoreload)
+void timer_autoreload_value_config(uint32_t timer_periph, uint32_t autoreload)
{
TIMER_CAR(timer_periph) = (uint32_t)autoreload;
}
@@ -339,7 +340,7 @@ void timer_autoreload_value_config(uint32_t timer_periph,uint32_t autoreload)
\param[out] none
\retval none
*/
-void timer_counter_value_config(uint32_t timer_periph , uint32_t counter)
+void timer_counter_value_config(uint32_t timer_periph, uint32_t counter)
{
TIMER_CNT(timer_periph) = (uint32_t)counter;
}
@@ -382,11 +383,11 @@ uint16_t timer_prescaler_read(uint32_t timer_periph)
*/
void timer_single_pulse_mode_config(uint32_t timer_periph, uint32_t spmode)
{
- if(TIMER_SP_MODE_SINGLE == spmode){
+ if(TIMER_SP_MODE_SINGLE == spmode) {
TIMER_CTL0(timer_periph) |= (uint32_t)TIMER_CTL0_SPM;
- }else if(TIMER_SP_MODE_REPETITIVE == spmode){
+ } else if(TIMER_SP_MODE_REPETITIVE == spmode) {
TIMER_CTL0(timer_periph) &= ~((uint32_t)TIMER_CTL0_SPM);
- }else{
+ } else {
/* illegal parameters */
}
}
@@ -403,160 +404,16 @@ void timer_single_pulse_mode_config(uint32_t timer_periph, uint32_t spmode)
*/
void timer_update_source_config(uint32_t timer_periph, uint32_t update)
{
- if(TIMER_UPDATE_SRC_REGULAR == update){
+ if(TIMER_UPDATE_SRC_REGULAR == update) {
TIMER_CTL0(timer_periph) |= (uint32_t)TIMER_CTL0_UPS;
- }else if(TIMER_UPDATE_SRC_GLOBAL == update){
+ } else if(TIMER_UPDATE_SRC_GLOBAL == update) {
TIMER_CTL0(timer_periph) &= ~(uint32_t)TIMER_CTL0_UPS;
- }else{
+ } else {
/* illegal parameters */
}
}
/*!
- \brief enable the TIMER interrupt
- \param[in] timer_periph: please refer to the following parameters
- \param[in] interrupt: timer interrupt enable source
- only one parameter can be selected which is shown as below:
- \arg TIMER_INT_UP: update interrupt enable, TIMERx(x=0..13)
- \arg TIMER_INT_CH0: channel 0 interrupt enable, TIMERx(x=0..4,7..13)
- \arg TIMER_INT_CH1: channel 1 interrupt enable, TIMERx(x=0..4,7,8,11)
- \arg TIMER_INT_CH2: channel 2 interrupt enable, TIMERx(x=0..4,7)
- \arg TIMER_INT_CH3: channel 3 interrupt enable , TIMERx(x=0..4,7)
- \arg TIMER_INT_CMT: commutation interrupt enable, TIMERx(x=0,7)
- \arg TIMER_INT_TRG: trigger interrupt enable, TIMERx(x=0..4,7,8,11)
- \arg TIMER_INT_BRK: break interrupt enable, TIMERx(x=0,7)
- \param[out] none
- \retval none
-*/
-void timer_interrupt_enable(uint32_t timer_periph, uint32_t interrupt)
-{
- TIMER_DMAINTEN(timer_periph) |= (uint32_t) interrupt;
-}
-
-/*!
- \brief disable the TIMER interrupt
- \param[in] timer_periph: please refer to the following parameters
- \param[in] interrupt: timer interrupt source enable
- only one parameter can be selected which is shown as below:
- \arg TIMER_INT_UP: update interrupt enable, TIMERx(x=0..13)
- \arg TIMER_INT_CH0: channel 0 interrupt enable, TIMERx(x=0..4,7..13)
- \arg TIMER_INT_CH1: channel 1 interrupt enable, TIMERx(x=0..4,7,8,11)
- \arg TIMER_INT_CH2: channel 2 interrupt enable, TIMERx(x=0..4,7)
- \arg TIMER_INT_CH3: channel 3 interrupt enable , TIMERx(x=0..4,7)
- \arg TIMER_INT_CMT: commutation interrupt enable, TIMERx(x=0,7)
- \arg TIMER_INT_TRG: trigger interrupt enable, TIMERx(x=0..4,7,8,11)
- \arg TIMER_INT_BRK: break interrupt enable, TIMERx(x=0,7)
- \param[out] none
- \retval none
-*/
-void timer_interrupt_disable(uint32_t timer_periph, uint32_t interrupt)
-{
- TIMER_DMAINTEN(timer_periph) &= (~(uint32_t)interrupt);
-}
-
-/*!
- \brief get timer interrupt flag
- \param[in] timer_periph: please refer to the following parameters
- \param[in] interrupt: the timer interrupt bits
- only one parameter can be selected which is shown as below:
- \arg TIMER_INT_FLAG_UP: update interrupt flag,TIMERx(x=0..13)
- \arg TIMER_INT_FLAG_CH0: channel 0 interrupt flag,TIMERx(x=0..4,7..13)
- \arg TIMER_INT_FLAG_CH1: channel 1 interrupt flag,TIMERx(x=0..4,7,8,11)
- \arg TIMER_INT_FLAG_CH2: channel 2 interrupt flag,TIMERx(x=0..4,7)
- \arg TIMER_INT_FLAG_CH3: channel 3 interrupt flag,TIMERx(x=0..4,7)
- \arg TIMER_INT_FLAG_CMT: channel commutation interrupt flag,TIMERx(x=0,7)
- \arg TIMER_INT_FLAG_TRG: trigger interrupt flag,TIMERx(x=0,7,8,11)
- \arg TIMER_INT_FLAG_BRK: break interrupt flag,TIMERx(x=0,7)
- \param[out] none
- \retval FlagStatus: SET or RESET
-*/
-FlagStatus timer_interrupt_flag_get(uint32_t timer_periph, uint32_t interrupt)
-{
- uint32_t val;
- val = (TIMER_DMAINTEN(timer_periph) & interrupt);
- if((RESET != (TIMER_INTF(timer_periph) & interrupt) ) && (RESET != val)){
- return SET;
- }else{
- return RESET;
- }
-}
-
-/*!
- \brief clear TIMER interrupt flag
- \param[in] timer_periph: please refer to the following parameters
- \param[in] interrupt: the timer interrupt bits
- only one parameter can be selected which is shown as below:
- \arg TIMER_INT_FLAG_UP: update interrupt flag,TIMERx(x=0..13)
- \arg TIMER_INT_FLAG_CH0: channel 0 interrupt flag,TIMERx(x=0..4,7..13)
- \arg TIMER_INT_FLAG_CH1: channel 1 interrupt flag,TIMERx(x=0..4,7,8,11)
- \arg TIMER_INT_FLAG_CH2: channel 2 interrupt flag,TIMERx(x=0..4,7)
- \arg TIMER_INT_FLAG_CH3: channel 3 interrupt flag,TIMERx(x=0..4,7)
- \arg TIMER_INT_FLAG_CMT: channel commutation interrupt flag,TIMERx(x=0,7)
- \arg TIMER_INT_FLAG_TRG: trigger interrupt flag,TIMERx(x=0,7,8,11)
- \arg TIMER_INT_FLAG_BRK: break interrupt flag,TIMERx(x=0,7)
- \param[out] none
- \retval none
-*/
-void timer_interrupt_flag_clear(uint32_t timer_periph, uint32_t interrupt)
-{
- TIMER_INTF(timer_periph) = (~(uint32_t)interrupt);
-}
-
-/*!
- \brief get TIMER flags
- \param[in] timer_periph: please refer to the following parameters
- \param[in] flag: the timer interrupt flags
- only one parameter can be selected which is shown as below:
- \arg TIMER_FLAG_UP: update flag,TIMERx(x=0..13)
- \arg TIMER_FLAG_CH0: channel 0 flag,TIMERx(x=0..4,7..13)
- \arg TIMER_FLAG_CH1: channel 1 flag,TIMERx(x=0..4,7,8,11)
- \arg TIMER_FLAG_CH2: channel 2 flag,TIMERx(x=0..4,7)
- \arg TIMER_FLAG_CH3: channel 3 flag,TIMERx(x=0..4,7)
- \arg TIMER_FLAG_CMT: channel control update flag,TIMERx(x=0,7)
- \arg TIMER_FLAG_TRG: trigger flag,TIMERx(x=0,7,8,11)
- \arg TIMER_FLAG_BRK: break flag,TIMERx(x=0,7)
- \arg TIMER_FLAG_CH0OF: channel 0 overcapture flag,TIMERx(x=0..4,7..11)
- \arg TIMER_FLAG_CH1OF: channel 1 overcapture flag,TIMERx(x=0..4,7,8,11)
- \arg TIMER_FLAG_CH2OF: channel 2 overcapture flag,TIMERx(x=0..4,7)
- \arg TIMER_FLAG_CH3OF: channel 3 overcapture flag,TIMERx(x=0..4,7)
- \param[out] none
- \retval FlagStatus: SET or RESET
-*/
-FlagStatus timer_flag_get(uint32_t timer_periph, uint32_t flag)
-{
- if(RESET != (TIMER_INTF(timer_periph) & flag)){
- return SET;
- }else{
- return RESET;
- }
-}
-
-/*!
- \brief clear TIMER flags
- \param[in] timer_periph: please refer to the following parameters
- \param[in] flag: the timer interrupt flags
- only one parameter can be selected which is shown as below:
- \arg TIMER_FLAG_UP: update flag,TIMERx(x=0..13)
- \arg TIMER_FLAG_CH0: channel 0 flag,TIMERx(x=0..4,7..13)
- \arg TIMER_FLAG_CH1: channel 1 flag,TIMERx(x=0..4,7,8,11)
- \arg TIMER_FLAG_CH2: channel 2 flag,TIMERx(x=0..4,7)
- \arg TIMER_FLAG_CH3: channel 3 flag,TIMERx(x=0..4,7)
- \arg TIMER_FLAG_CMT: channel control update flag,TIMERx(x=0,7)
- \arg TIMER_FLAG_TRG: trigger flag,TIMERx(x=0,7,8,11)
- \arg TIMER_FLAG_BRK: break flag,TIMERx(x=0,7)
- \arg TIMER_FLAG_CH0OF: channel 0 overcapture flag,TIMERx(x=0..4,7..11)
- \arg TIMER_FLAG_CH1OF: channel 1 overcapture flag,TIMERx(x=0..4,7,8,11)
- \arg TIMER_FLAG_CH2OF: channel 2 overcapture flag,TIMERx(x=0..4,7)
- \arg TIMER_FLAG_CH3OF: channel 3 overcapture flag,TIMERx(x=0..4,7)
- \param[out] none
- \retval none
-*/
-void timer_flag_clear(uint32_t timer_periph, uint32_t flag)
-{
- TIMER_INTF(timer_periph) = (~(uint32_t)flag);
-}
-
-/*!
\brief enable the TIMER DMA
\param[in] timer_periph: please refer to the following parameters
\param[in] dma: specify which DMA to enable
@@ -608,11 +465,11 @@ void timer_dma_disable(uint32_t timer_periph, uint16_t dma)
*/
void timer_channel_dma_request_source_select(uint32_t timer_periph, uint8_t dma_request)
{
- if(TIMER_DMAREQUEST_UPDATEEVENT == dma_request){
+ if(TIMER_DMAREQUEST_UPDATEEVENT == dma_request) {
TIMER_CTL1(timer_periph) |= (uint32_t)TIMER_CTL1_DMAS;
- }else if(TIMER_DMAREQUEST_CHANNELEVENT == dma_request){
+ } else if(TIMER_DMAREQUEST_CHANNELEVENT == dma_request) {
TIMER_CTL1(timer_periph) &= ~(uint32_t)TIMER_CTL1_DMAS;
- }else{
+ } else {
/* illegal parameters */
}
}
@@ -676,12 +533,12 @@ void timer_event_software_generate(uint32_t timer_periph, uint16_t event)
}
/*!
- \brief initialize TIMER break parameter struct with a default value
+ \brief initialize TIMER break parameter struct
\param[in] breakpara: TIMER break parameter struct
\param[out] none
\retval none
*/
-void timer_break_struct_para_init(timer_break_parameter_struct* breakpara)
+void timer_break_struct_para_init(timer_break_parameter_struct *breakpara)
{
/* initialize the break parameter struct member with the default value */
breakpara->runoffstate = TIMER_ROS_STATE_DISABLE;
@@ -707,14 +564,14 @@ void timer_break_struct_para_init(timer_break_parameter_struct* breakpara)
\param[out] none
\retval none
*/
-void timer_break_config(uint32_t timer_periph, timer_break_parameter_struct* breakpara)
+void timer_break_config(uint32_t timer_periph, timer_break_parameter_struct *breakpara)
{
- TIMER_CCHP(timer_periph) = (uint32_t)(((uint32_t)(breakpara->runoffstate))|
- ((uint32_t)(breakpara->ideloffstate))|
- ((uint32_t)(breakpara->deadtime))|
- ((uint32_t)(breakpara->breakpolarity))|
+ TIMER_CCHP(timer_periph) = (uint32_t)(((uint32_t)(breakpara->runoffstate)) |
+ ((uint32_t)(breakpara->ideloffstate)) |
+ ((uint32_t)(breakpara->deadtime)) |
+ ((uint32_t)(breakpara->breakpolarity)) |
((uint32_t)(breakpara->outputautostate)) |
- ((uint32_t)(breakpara->protectmode))|
+ ((uint32_t)(breakpara->protectmode)) |
((uint32_t)(breakpara->breakstate))) ;
}
@@ -771,9 +628,9 @@ void timer_automatic_output_disable(uint32_t timer_periph)
*/
void timer_primary_output_config(uint32_t timer_periph, ControlStatus newvalue)
{
- if(ENABLE == newvalue){
+ if(ENABLE == newvalue) {
TIMER_CCHP(timer_periph) |= (uint32_t)TIMER_CCHP_POEN;
- }else{
+ } else {
TIMER_CCHP(timer_periph) &= (~(uint32_t)TIMER_CCHP_POEN);
}
}
@@ -787,9 +644,9 @@ void timer_primary_output_config(uint32_t timer_periph, ControlStatus newvalue)
*/
void timer_channel_control_shadow_config(uint32_t timer_periph, ControlStatus newvalue)
{
- if(ENABLE == newvalue){
+ if(ENABLE == newvalue) {
TIMER_CTL1(timer_periph) |= (uint32_t)TIMER_CTL1_CCSE;
- }else{
+ } else {
TIMER_CTL1(timer_periph) &= (~(uint32_t)TIMER_CTL1_CCSE);
}
}
@@ -806,11 +663,11 @@ void timer_channel_control_shadow_config(uint32_t timer_periph, ControlStatus ne
*/
void timer_channel_control_shadow_update_config(uint32_t timer_periph, uint8_t ccuctl)
{
- if(TIMER_UPDATECTL_CCU == ccuctl){
+ if(TIMER_UPDATECTL_CCU == ccuctl) {
TIMER_CTL1(timer_periph) &= (~(uint32_t)TIMER_CTL1_CCUC);
- }else if(TIMER_UPDATECTL_CCUTRI == ccuctl){
+ } else if(TIMER_UPDATECTL_CCUTRI == ccuctl) {
TIMER_CTL1(timer_periph) |= (uint32_t)TIMER_CTL1_CCUC;
- }else{
+ } else {
/* illegal parameters */
}
}
@@ -821,7 +678,7 @@ void timer_channel_control_shadow_update_config(uint32_t timer_periph, uint8_t c
\param[out] none
\retval none
*/
-void timer_channel_output_struct_para_init(timer_oc_parameter_struct* ocpara)
+void timer_channel_output_struct_para_init(timer_oc_parameter_struct *ocpara)
{
/* initialize the channel output parameter struct member with the default value */
ocpara->outputstate = (uint16_t)TIMER_CCX_DISABLE;
@@ -851,9 +708,9 @@ void timer_channel_output_struct_para_init(timer_oc_parameter_struct* ocpara)
\param[out] none
\retval none
*/
-void timer_channel_output_config(uint32_t timer_periph, uint16_t channel, timer_oc_parameter_struct* ocpara)
+void timer_channel_output_config(uint32_t timer_periph, uint16_t channel, timer_oc_parameter_struct *ocpara)
{
- switch(channel){
+ switch(channel) {
/* configure TIMER_CH_0 */
case TIMER_CH_0:
/* reset the CH0EN bit */
@@ -866,7 +723,7 @@ void timer_channel_output_config(uint32_t timer_periph, uint16_t channel, timer_
/* set the CH0P bit */
TIMER_CHCTL2(timer_periph) |= (uint32_t)ocpara->ocpolarity;
- if((TIMER0 == timer_periph) || (TIMER7 == timer_periph)){
+ if((TIMER0 == timer_periph) || (TIMER7 == timer_periph)) {
/* reset the CH0NEN bit */
TIMER_CHCTL2(timer_periph) &= (~(uint32_t)TIMER_CHCTL2_CH0NEN);
/* set the CH0NEN bit */
@@ -897,7 +754,7 @@ void timer_channel_output_config(uint32_t timer_periph, uint16_t channel, timer_
/* set the CH1P bit */
TIMER_CHCTL2(timer_periph) |= (uint32_t)((uint32_t)(ocpara->ocpolarity) << 4U);
- if((TIMER0 == timer_periph) || (TIMER7 == timer_periph)){
+ if((TIMER0 == timer_periph) || (TIMER7 == timer_periph)) {
/* reset the CH1NEN bit */
TIMER_CHCTL2(timer_periph) &= (~(uint32_t)TIMER_CHCTL2_CH1NEN);
/* set the CH1NEN bit */
@@ -928,7 +785,7 @@ void timer_channel_output_config(uint32_t timer_periph, uint16_t channel, timer_
/* set the CH2P bit */
TIMER_CHCTL2(timer_periph) |= (uint32_t)((uint32_t)(ocpara->ocpolarity) << 8U);
- if((TIMER0 == timer_periph) || (TIMER7 == timer_periph)){
+ if((TIMER0 == timer_periph) || (TIMER7 == timer_periph)) {
/* reset the CH2NEN bit */
TIMER_CHCTL2(timer_periph) &= (~(uint32_t)TIMER_CHCTL2_CH2NEN);
/* set the CH2NEN bit */
@@ -950,7 +807,7 @@ void timer_channel_output_config(uint32_t timer_periph, uint16_t channel, timer_
/* configure TIMER_CH_3 */
case TIMER_CH_3:
/* reset the CH3EN bit */
- TIMER_CHCTL2(timer_periph) &=(~(uint32_t)TIMER_CHCTL2_CH3EN);
+ TIMER_CHCTL2(timer_periph) &= (~(uint32_t)TIMER_CHCTL2_CH3EN);
TIMER_CHCTL1(timer_periph) &= ~(uint32_t)TIMER_CHCTL1_CH3MS;
/* set the CH3EN bit */
TIMER_CHCTL2(timer_periph) |= (uint32_t)((uint32_t)ocpara->outputstate << 12U);
@@ -959,7 +816,7 @@ void timer_channel_output_config(uint32_t timer_periph, uint16_t channel, timer_
/* set the CH3P bit */
TIMER_CHCTL2(timer_periph) |= (uint32_t)((uint32_t)(ocpara->ocpolarity) << 12U);
- if((TIMER0 == timer_periph) || (TIMER7 == timer_periph)){
+ if((TIMER0 == timer_periph) || (TIMER7 == timer_periph)) {
/* reset the ISO3 bit */
TIMER_CTL1(timer_periph) &= (~(uint32_t)TIMER_CTL1_ISO3);
/* set the ISO3 bit */
@@ -995,7 +852,7 @@ void timer_channel_output_config(uint32_t timer_periph, uint16_t channel, timer_
*/
void timer_channel_output_mode_config(uint32_t timer_periph, uint16_t channel, uint16_t ocmode)
{
- switch(channel){
+ switch(channel) {
/* configure TIMER_CH_0 */
case TIMER_CH_0:
TIMER_CHCTL0(timer_periph) &= (~(uint32_t)TIMER_CHCTL0_CH0COMCTL);
@@ -1036,7 +893,7 @@ void timer_channel_output_mode_config(uint32_t timer_periph, uint16_t channel, u
*/
void timer_channel_output_pulse_value_config(uint32_t timer_periph, uint16_t channel, uint32_t pulse)
{
- switch(channel){
+ switch(channel) {
/* configure TIMER_CH_0 */
case TIMER_CH_0:
TIMER_CH0CV(timer_periph) = (uint32_t)pulse;
@@ -1051,7 +908,7 @@ void timer_channel_output_pulse_value_config(uint32_t timer_periph, uint16_t cha
break;
/* configure TIMER_CH_3 */
case TIMER_CH_3:
- TIMER_CH3CV(timer_periph) = (uint32_t)pulse;
+ TIMER_CH3CV(timer_periph) = (uint32_t)pulse;
break;
default:
break;
@@ -1076,7 +933,7 @@ void timer_channel_output_pulse_value_config(uint32_t timer_periph, uint16_t cha
*/
void timer_channel_output_shadow_config(uint32_t timer_periph, uint16_t channel, uint16_t ocshadow)
{
- switch(channel){
+ switch(channel) {
/* configure TIMER_CH_0 */
case TIMER_CH_0:
TIMER_CHCTL0(timer_periph) &= (~(uint32_t)TIMER_CHCTL0_CH0COMSEN);
@@ -1120,7 +977,7 @@ void timer_channel_output_shadow_config(uint32_t timer_periph, uint16_t channel,
*/
void timer_channel_output_fast_config(uint32_t timer_periph, uint16_t channel, uint16_t ocfast)
{
- switch(channel){
+ switch(channel) {
/* configure TIMER_CH_0 */
case TIMER_CH_0:
TIMER_CHCTL0(timer_periph) &= (~(uint32_t)TIMER_CHCTL0_CH0COMFEN);
@@ -1164,7 +1021,7 @@ void timer_channel_output_fast_config(uint32_t timer_periph, uint16_t channel, u
*/
void timer_channel_output_clear_config(uint32_t timer_periph, uint16_t channel, uint16_t occlear)
{
- switch(channel){
+ switch(channel) {
/* configure TIMER_CH_0 */
case TIMER_CH_0:
TIMER_CHCTL0(timer_periph) &= (~(uint32_t)TIMER_CHCTL0_CH0COMCEN);
@@ -1208,7 +1065,7 @@ void timer_channel_output_clear_config(uint32_t timer_periph, uint16_t channel,
*/
void timer_channel_output_polarity_config(uint32_t timer_periph, uint16_t channel, uint16_t ocpolarity)
{
- switch(channel){
+ switch(channel) {
/* configure TIMER_CH_0 */
case TIMER_CH_0:
TIMER_CHCTL2(timer_periph) &= (~(uint32_t)TIMER_CHCTL2_CH0P);
@@ -1251,7 +1108,7 @@ void timer_channel_output_polarity_config(uint32_t timer_periph, uint16_t channe
*/
void timer_channel_complementary_output_polarity_config(uint32_t timer_periph, uint16_t channel, uint16_t ocnpolarity)
{
- switch(channel){
+ switch(channel) {
/* configure TIMER_CH_0 */
case TIMER_CH_0:
TIMER_CHCTL2(timer_periph) &= (~(uint32_t)TIMER_CHCTL2_CH0NP);
@@ -1290,7 +1147,7 @@ void timer_channel_complementary_output_polarity_config(uint32_t timer_periph, u
*/
void timer_channel_output_state_config(uint32_t timer_periph, uint16_t channel, uint32_t state)
{
- switch(channel){
+ switch(channel) {
/* configure TIMER_CH_0 */
case TIMER_CH_0:
TIMER_CHCTL2(timer_periph) &= (~(uint32_t)TIMER_CHCTL2_CH0EN);
@@ -1333,7 +1190,7 @@ void timer_channel_output_state_config(uint32_t timer_periph, uint16_t channel,
*/
void timer_channel_complementary_output_state_config(uint32_t timer_periph, uint16_t channel, uint16_t ocnstate)
{
- switch(channel){
+ switch(channel) {
/* configure TIMER_CH_0 */
case TIMER_CH_0:
TIMER_CHCTL2(timer_periph) &= (~(uint32_t)TIMER_CHCTL2_CH0NEN);
@@ -1355,12 +1212,12 @@ void timer_channel_complementary_output_state_config(uint32_t timer_periph, uint
}
/*!
- \brief initialize TIMER channel input parameter struct with a default value
+ \brief initialize TIMER channel input parameter struct
\param[in] icpara: TIMER channel intput parameter struct
\param[out] none
\retval none
*/
-void timer_channel_input_struct_para_init(timer_ic_parameter_struct* icpara)
+void timer_channel_input_struct_para_init(timer_ic_parameter_struct *icpara)
{
/* initialize the channel input parameter struct member with the default value */
icpara->icpolarity = TIMER_IC_POLARITY_RISING;
@@ -1386,9 +1243,9 @@ void timer_channel_input_struct_para_init(timer_ic_parameter_struct* icpara)
\param[out] none
\retval none
*/
-void timer_input_capture_config(uint32_t timer_periph,uint16_t channel, timer_ic_parameter_struct* icpara)
+void timer_input_capture_config(uint32_t timer_periph, uint16_t channel, timer_ic_parameter_struct *icpara)
{
- switch(channel){
+ switch(channel) {
/* configure TIMER_CH_0 */
case TIMER_CH_0:
/* reset the CH0EN bit */
@@ -1432,7 +1289,7 @@ void timer_input_capture_config(uint32_t timer_periph,uint16_t channel, timer_ic
TIMER_CHCTL2(timer_periph) &= (~(uint32_t)TIMER_CHCTL2_CH2EN);
/* reset the CH2P and CH2NP bits */
- TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH2P|TIMER_CHCTL2_CH2NP));
+ TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH2P | TIMER_CHCTL2_CH2NP));
TIMER_CHCTL2(timer_periph) |= (uint32_t)((uint32_t)(icpara->icpolarity) << 8U);
/* reset the CH2MS bit */
@@ -1493,7 +1350,7 @@ void timer_input_capture_config(uint32_t timer_periph,uint16_t channel, timer_ic
*/
void timer_channel_input_capture_prescaler_config(uint32_t timer_periph, uint16_t channel, uint16_t prescaler)
{
- switch(channel){
+ switch(channel) {
/* configure TIMER_CH_0 */
case TIMER_CH_0:
TIMER_CHCTL0(timer_periph) &= (~(uint32_t)TIMER_CHCTL0_CH0CAPPSC);
@@ -1535,7 +1392,7 @@ uint32_t timer_channel_capture_value_register_read(uint32_t timer_periph, uint16
{
uint32_t count_value = 0U;
- switch(channel){
+ switch(channel) {
/* read TIMER channel 0 capture compare register value */
case TIMER_CH_0:
count_value = TIMER_CH0CV(timer_periph);
@@ -1573,30 +1430,30 @@ uint32_t timer_channel_capture_value_register_read(uint32_t timer_periph, uint16
\param[out] none
\retval none
*/
-void timer_input_pwm_capture_config(uint32_t timer_periph, uint16_t channel, timer_ic_parameter_struct* icpwm)
+void timer_input_pwm_capture_config(uint32_t timer_periph, uint16_t channel, timer_ic_parameter_struct *icpwm)
{
uint16_t icpolarity = 0x0U;
uint16_t icselection = 0x0U;
/* Set channel input polarity */
- if(TIMER_IC_POLARITY_RISING == icpwm->icpolarity){
+ if(TIMER_IC_POLARITY_RISING == icpwm->icpolarity) {
icpolarity = TIMER_IC_POLARITY_FALLING;
- }else{
+ } else {
icpolarity = TIMER_IC_POLARITY_RISING;
}
/* Set channel input mode selection */
- if(TIMER_IC_SELECTION_DIRECTTI == icpwm->icselection){
+ if(TIMER_IC_SELECTION_DIRECTTI == icpwm->icselection) {
icselection = TIMER_IC_SELECTION_INDIRECTTI;
- }else{
+ } else {
icselection = TIMER_IC_SELECTION_DIRECTTI;
}
- if(TIMER_CH_0 == channel){
+ if(TIMER_CH_0 == channel) {
/* reset the CH0EN bit */
TIMER_CHCTL2(timer_periph) &= (~(uint32_t)TIMER_CHCTL2_CH0EN);
/* reset the CH0P and CH0NP bits */
- TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH0P|TIMER_CHCTL2_CH0NP));
+ TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH0P | TIMER_CHCTL2_CH0NP));
/* set the CH0P and CH0NP bits */
TIMER_CHCTL2(timer_periph) |= (uint32_t)(icpwm->icpolarity);
/* reset the CH0MS bit */
@@ -1610,12 +1467,12 @@ void timer_input_pwm_capture_config(uint32_t timer_periph, uint16_t channel, tim
/* set the CH0EN bit */
TIMER_CHCTL2(timer_periph) |= (uint32_t)TIMER_CHCTL2_CH0EN;
/* configure TIMER channel input capture prescaler value */
- timer_channel_input_capture_prescaler_config(timer_periph,TIMER_CH_0,(uint16_t)(icpwm->icprescaler));
+ timer_channel_input_capture_prescaler_config(timer_periph, TIMER_CH_0, (uint16_t)(icpwm->icprescaler));
/* reset the CH1EN bit */
TIMER_CHCTL2(timer_periph) &= (~(uint32_t)TIMER_CHCTL2_CH1EN);
/* reset the CH1P and CH1NP bits */
- TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH1P|TIMER_CHCTL2_CH1NP));
+ TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH1P | TIMER_CHCTL2_CH1NP));
/* set the CH1P and CH1NP bits */
TIMER_CHCTL2(timer_periph) |= (uint32_t)((uint32_t)icpolarity << 4U);
/* reset the CH1MS bit */
@@ -1629,12 +1486,12 @@ void timer_input_pwm_capture_config(uint32_t timer_periph, uint16_t channel, tim
/* set the CH1EN bit */
TIMER_CHCTL2(timer_periph) |= (uint32_t)TIMER_CHCTL2_CH1EN;
/* configure TIMER channel input capture prescaler value */
- timer_channel_input_capture_prescaler_config(timer_periph,TIMER_CH_1,(uint16_t)(icpwm->icprescaler));
- }else{
+ timer_channel_input_capture_prescaler_config(timer_periph, TIMER_CH_1, (uint16_t)(icpwm->icprescaler));
+ } else {
/* reset the CH1EN bit */
TIMER_CHCTL2(timer_periph) &= (~(uint32_t)TIMER_CHCTL2_CH1EN);
/* reset the CH1P and CH1NP bits */
- TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH1P|TIMER_CHCTL2_CH1NP));
+ TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH1P | TIMER_CHCTL2_CH1NP));
/* set the CH1P and CH1NP bits */
TIMER_CHCTL2(timer_periph) |= (uint32_t)((uint32_t)(icpwm->icpolarity) << 4U);
/* reset the CH1MS bit */
@@ -1653,7 +1510,7 @@ void timer_input_pwm_capture_config(uint32_t timer_periph, uint16_t channel, tim
/* reset the CH0EN bit */
TIMER_CHCTL2(timer_periph) &= (~(uint32_t)TIMER_CHCTL2_CH0EN);
/* reset the CH0P and CH0NP bits */
- TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH0P|TIMER_CHCTL2_CH0NP));
+ TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH0P | TIMER_CHCTL2_CH0NP));
/* set the CH0P and CH0NP bits */
TIMER_CHCTL2(timer_periph) |= (uint32_t)icpolarity;
/* reset the CH0MS bit */
@@ -1683,11 +1540,11 @@ void timer_input_pwm_capture_config(uint32_t timer_periph, uint16_t channel, tim
*/
void timer_hall_mode_config(uint32_t timer_periph, uint32_t hallmode)
{
- if(TIMER_HALLINTERFACE_ENABLE == hallmode){
+ if(TIMER_HALLINTERFACE_ENABLE == hallmode) {
TIMER_CTL1(timer_periph) |= (uint32_t)TIMER_CTL1_TI0S;
- }else if(TIMER_HALLINTERFACE_DISABLE == hallmode){
+ } else if(TIMER_HALLINTERFACE_DISABLE == hallmode) {
TIMER_CTL1(timer_periph) &= ~(uint32_t)TIMER_CTL1_TI0S;
- }else{
+ } else {
/* illegal parameters */
}
}
@@ -1742,9 +1599,9 @@ void timer_master_output_trigger_source_select(uint32_t timer_periph, uint32_t o
\param[in] slavemode:
only one parameter can be selected which is shown as below:
\arg TIMER_SLAVE_MODE_DISABLE: slave mode disable(TIMERx(x=0..4,7,8,11))
- \arg TIMER_ENCODER_MODE0: encoder mode 0(TIMERx(x=0..4,7))
- \arg TIMER_ENCODER_MODE1: encoder mode 1(TIMERx(x=0..4,7))
- \arg TIMER_ENCODER_MODE2: encoder mode 2(TIMERx(x=0..4,7))
+ \arg TIMER_QUAD_DECODER_MODE0: quadrature decoder mode 0(TIMERx(x=0..4,7))
+ \arg TIMER_QUAD_DECODER_MODE1: quadrature decoder mode 1(TIMERx(x=0..4,7))
+ \arg TIMER_QUAD_DECODER_MODE2: quadrature decoder mode 2(TIMERx(x=0..4,7))
\arg TIMER_SLAVE_MODE_RESTART: restart mode(TIMERx(x=0..4,7,8,11))
\arg TIMER_SLAVE_MODE_PAUSE: pause mode(TIMERx(x=0..4,7,8,11))
\arg TIMER_SLAVE_MODE_EVENT: event mode(TIMERx(x=0..4,7,8,11))
@@ -1772,11 +1629,11 @@ void timer_slave_mode_select(uint32_t timer_periph, uint32_t slavemode)
*/
void timer_master_slave_mode_config(uint32_t timer_periph, uint32_t masterslave)
{
- if(TIMER_MASTER_SLAVE_MODE_ENABLE == masterslave){
+ if(TIMER_MASTER_SLAVE_MODE_ENABLE == masterslave) {
TIMER_SMCFG(timer_periph) |= (uint32_t)TIMER_SMCFG_MSM;
- }else if(TIMER_MASTER_SLAVE_MODE_DISABLE == masterslave){
+ } else if(TIMER_MASTER_SLAVE_MODE_DISABLE == masterslave) {
TIMER_SMCFG(timer_periph) &= ~(uint32_t)TIMER_SMCFG_MSM;
- }else{
+ } else {
/* illegal parameters */
}
}
@@ -1808,12 +1665,12 @@ void timer_external_trigger_config(uint32_t timer_periph, uint32_t extprescaler,
/*!
\brief configure TIMER quadrature decoder mode
- \param[in] timer_periph: TIMERx(x=0..4,7,8,11)
+ \param[in] timer_periph: TIMERx(x=0..4,7)
\param[in] decomode:
only one parameter can be selected which is shown as below:
- \arg TIMER_ENCODER_MODE0: counter counts on CI0FE0 edge depending on CI1FE1 level
- \arg TIMER_ENCODER_MODE1: counter counts on CI1FE1 edge depending on CI0FE0 level
- \arg TIMER_ENCODER_MODE2: counter counts on both CI0FE0 and CI1FE1 edges depending on the level of the other input
+ \arg TIMER_QUAD_DECODER_MODE0: counter counts on CI0FE0 edge depending on CI1FE1 level
+ \arg TIMER_QUAD_DECODER_MODE1: counter counts on CI1FE1 edge depending on CI0FE0 level
+ \arg TIMER_QUAD_DECODER_MODE2: counter counts on both CI0FE0 and CI1FE1 edges depending on the level of the other input
\param[in] ic0polarity:
only one parameter can be selected which is shown as below:
\arg TIMER_IC_POLARITY_RISING: capture rising edge
@@ -1826,17 +1683,17 @@ void timer_external_trigger_config(uint32_t timer_periph, uint32_t extprescaler,
\retval none
*/
void timer_quadrature_decoder_mode_config(uint32_t timer_periph, uint32_t decomode,
- uint16_t ic0polarity, uint16_t ic1polarity)
+ uint16_t ic0polarity, uint16_t ic1polarity)
{
TIMER_SMCFG(timer_periph) &= (~(uint32_t)TIMER_SMCFG_SMC);
TIMER_SMCFG(timer_periph) |= (uint32_t)decomode;
- TIMER_CHCTL0(timer_periph) &= (uint32_t)(((~(uint32_t)TIMER_CHCTL0_CH0MS))&((~(uint32_t)TIMER_CHCTL0_CH1MS)));
- TIMER_CHCTL0(timer_periph) |= (uint32_t)(TIMER_IC_SELECTION_DIRECTTI|((uint32_t)TIMER_IC_SELECTION_DIRECTTI << 8U));
+ TIMER_CHCTL0(timer_periph) &= (uint32_t)(((~(uint32_t)TIMER_CHCTL0_CH0MS)) & ((~(uint32_t)TIMER_CHCTL0_CH1MS)));
+ TIMER_CHCTL0(timer_periph) |= (uint32_t)(TIMER_IC_SELECTION_DIRECTTI | ((uint32_t)TIMER_IC_SELECTION_DIRECTTI << 8U));
- TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH0P|TIMER_CHCTL2_CH0NP));
- TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH1P|TIMER_CHCTL2_CH1NP));
- TIMER_CHCTL2(timer_periph) |= ((uint32_t)ic0polarity|((uint32_t)ic1polarity << 4U));
+ TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH0P | TIMER_CHCTL2_CH0NP));
+ TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH1P | TIMER_CHCTL2_CH1NP));
+ TIMER_CHCTL2(timer_periph) |= ((uint32_t)ic0polarity | ((uint32_t)ic1polarity << 4U));
}
/*!
@@ -1886,13 +1743,13 @@ void timer_internal_trigger_as_external_clock_config(uint32_t timer_periph, uint
\retval none
*/
void timer_external_trigger_as_external_clock_config(uint32_t timer_periph, uint32_t extrigger,
- uint16_t extpolarity, uint32_t extfilter)
+ uint16_t extpolarity, uint32_t extfilter)
{
- if(TIMER_SMCFG_TRGSEL_CI1FE1 == extrigger){
+ if(TIMER_SMCFG_TRGSEL_CI1FE1 == extrigger) {
/* reset the CH1EN bit */
TIMER_CHCTL2(timer_periph) &= (~(uint32_t)TIMER_CHCTL2_CH1EN);
/* reset the CH1NP bit */
- TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH1P|TIMER_CHCTL2_CH1NP));
+ TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH1P | TIMER_CHCTL2_CH1NP));
/* set the CH1NP bit */
TIMER_CHCTL2(timer_periph) |= (uint32_t)((uint32_t)extpolarity << 4U);
/* reset the CH1MS bit */
@@ -1905,11 +1762,11 @@ void timer_external_trigger_as_external_clock_config(uint32_t timer_periph, uint
TIMER_CHCTL0(timer_periph) |= (uint32_t)(extfilter << 12U);
/* set the CH1EN bit */
TIMER_CHCTL2(timer_periph) |= (uint32_t)TIMER_CHCTL2_CH1EN;
- }else{
+ } else {
/* reset the CH0EN bit */
TIMER_CHCTL2(timer_periph) &= (~(uint32_t)TIMER_CHCTL2_CH0EN);
/* reset the CH0P and CH0NP bits */
- TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH0P|TIMER_CHCTL2_CH0NP));
+ TIMER_CHCTL2(timer_periph) &= (~(uint32_t)(TIMER_CHCTL2_CH0P | TIMER_CHCTL2_CH0NP));
/* set the CH0P and CH0NP bits */
TIMER_CHCTL2(timer_periph) |= (uint32_t)extpolarity;
/* reset the CH0MS bit */
@@ -1924,7 +1781,7 @@ void timer_external_trigger_as_external_clock_config(uint32_t timer_periph, uint
TIMER_CHCTL2(timer_periph) |= (uint32_t)TIMER_CHCTL2_CH0EN;
}
/* select TIMER input trigger source */
- timer_input_trigger_source_select(timer_periph,extrigger);
+ timer_input_trigger_source_select(timer_periph, extrigger);
/* reset the SMC bit */
TIMER_SMCFG(timer_periph) &= (~(uint32_t)TIMER_SMCFG_SMC);
/* set the SMC bit */
@@ -2032,11 +1889,11 @@ void timer_channel_remap_config(uint32_t timer_periph, uint32_t remap)
*/
void timer_write_chxval_register_config(uint32_t timer_periph, uint16_t ccsel)
{
- if(TIMER_CHVSEL_ENABLE == ccsel){
+ if(TIMER_CHVSEL_ENABLE == ccsel) {
TIMER_CFG(timer_periph) |= (uint32_t)TIMER_CFG_CHVSEL;
- }else if(TIMER_CHVSEL_DISABLE == ccsel){
+ } else if(TIMER_CHVSEL_DISABLE == ccsel) {
TIMER_CFG(timer_periph) &= ~(uint32_t)TIMER_CFG_CHVSEL;
- }else{
+ } else {
/* illegal parameters */
}
}
@@ -2053,11 +1910,155 @@ void timer_write_chxval_register_config(uint32_t timer_periph, uint16_t ccsel)
*/
void timer_output_value_selection_config(uint32_t timer_periph, uint16_t outsel)
{
- if(TIMER_OUTSEL_ENABLE == outsel){
+ if(TIMER_OUTSEL_ENABLE == outsel) {
TIMER_CFG(timer_periph) |= (uint32_t)TIMER_CFG_OUTSEL;
- }else if(TIMER_OUTSEL_DISABLE == outsel){
+ } else if(TIMER_OUTSEL_DISABLE == outsel) {
TIMER_CFG(timer_periph) &= ~(uint32_t)TIMER_CFG_OUTSEL;
- }else{
+ } else {
/* illegal parameters */
}
}
+
+/*!
+ \brief get TIMER flags
+ \param[in] timer_periph: please refer to the following parameters
+ \param[in] flag: the timer interrupt flags
+ only one parameter can be selected which is shown as below:
+ \arg TIMER_FLAG_UP: update flag,TIMERx(x=0..13)
+ \arg TIMER_FLAG_CH0: channel 0 flag,TIMERx(x=0..4,7..13)
+ \arg TIMER_FLAG_CH1: channel 1 flag,TIMERx(x=0..4,7,8,11)
+ \arg TIMER_FLAG_CH2: channel 2 flag,TIMERx(x=0..4,7)
+ \arg TIMER_FLAG_CH3: channel 3 flag,TIMERx(x=0..4,7)
+ \arg TIMER_FLAG_CMT: channel control update flag,TIMERx(x=0,7)
+ \arg TIMER_FLAG_TRG: trigger flag,TIMERx(x=0,7,8,11)
+ \arg TIMER_FLAG_BRK: break flag,TIMERx(x=0,7)
+ \arg TIMER_FLAG_CH0O: channel 0 overcapture flag,TIMERx(x=0..4,7..11)
+ \arg TIMER_FLAG_CH1O: channel 1 overcapture flag,TIMERx(x=0..4,7,8,11)
+ \arg TIMER_FLAG_CH2O: channel 2 overcapture flag,TIMERx(x=0..4,7)
+ \arg TIMER_FLAG_CH3O: channel 3 overcapture flag,TIMERx(x=0..4,7)
+ \param[out] none
+ \retval FlagStatus: SET or RESET
+*/
+FlagStatus timer_flag_get(uint32_t timer_periph, uint32_t flag)
+{
+ if(RESET != (TIMER_INTF(timer_periph) & flag)) {
+ return SET;
+ } else {
+ return RESET;
+ }
+}
+
+/*!
+ \brief clear TIMER flags
+ \param[in] timer_periph: please refer to the following parameters
+ \param[in] flag: the timer interrupt flags
+ only one parameter can be selected which is shown as below:
+ \arg TIMER_FLAG_UP: update flag,TIMERx(x=0..13)
+ \arg TIMER_FLAG_CH0: channel 0 flag,TIMERx(x=0..4,7..13)
+ \arg TIMER_FLAG_CH1: channel 1 flag,TIMERx(x=0..4,7,8,11)
+ \arg TIMER_FLAG_CH2: channel 2 flag,TIMERx(x=0..4,7)
+ \arg TIMER_FLAG_CH3: channel 3 flag,TIMERx(x=0..4,7)
+ \arg TIMER_FLAG_CMT: channel control update flag,TIMERx(x=0,7)
+ \arg TIMER_FLAG_TRG: trigger flag,TIMERx(x=0,7,8,11)
+ \arg TIMER_FLAG_BRK: break flag,TIMERx(x=0,7)
+ \arg TIMER_FLAG_CH0O: channel 0 overcapture flag,TIMERx(x=0..4,7..11)
+ \arg TIMER_FLAG_CH1O: channel 1 overcapture flag,TIMERx(x=0..4,7,8,11)
+ \arg TIMER_FLAG_CH2O: channel 2 overcapture flag,TIMERx(x=0..4,7)
+ \arg TIMER_FLAG_CH3O: channel 3 overcapture flag,TIMERx(x=0..4,7)
+ \param[out] none
+ \retval none
+*/
+void timer_flag_clear(uint32_t timer_periph, uint32_t flag)
+{
+ TIMER_INTF(timer_periph) = (~(uint32_t)flag);
+}
+
+/*!
+ \brief enable the TIMER interrupt
+ \param[in] timer_periph: please refer to the following parameters
+ \param[in] interrupt: timer interrupt enable source
+ only one parameter can be selected which is shown as below:
+ \arg TIMER_INT_UP: update interrupt enable, TIMERx(x=0..13)
+ \arg TIMER_INT_CH0: channel 0 interrupt enable, TIMERx(x=0..4,7..13)
+ \arg TIMER_INT_CH1: channel 1 interrupt enable, TIMERx(x=0..4,7,8,11)
+ \arg TIMER_INT_CH2: channel 2 interrupt enable, TIMERx(x=0..4,7)
+ \arg TIMER_INT_CH3: channel 3 interrupt enable , TIMERx(x=0..4,7)
+ \arg TIMER_INT_CMT: commutation interrupt enable, TIMERx(x=0,7)
+ \arg TIMER_INT_TRG: trigger interrupt enable, TIMERx(x=0..4,7,8,11)
+ \arg TIMER_INT_BRK: break interrupt enable, TIMERx(x=0,7)
+ \param[out] none
+ \retval none
+*/
+void timer_interrupt_enable(uint32_t timer_periph, uint32_t interrupt)
+{
+ TIMER_DMAINTEN(timer_periph) |= (uint32_t) interrupt;
+}
+
+/*!
+ \brief disable the TIMER interrupt
+ \param[in] timer_periph: please refer to the following parameters
+ \param[in] interrupt: timer interrupt source enable
+ only one parameter can be selected which is shown as below:
+ \arg TIMER_INT_UP: update interrupt enable, TIMERx(x=0..13)
+ \arg TIMER_INT_CH0: channel 0 interrupt enable, TIMERx(x=0..4,7..13)
+ \arg TIMER_INT_CH1: channel 1 interrupt enable, TIMERx(x=0..4,7,8,11)
+ \arg TIMER_INT_CH2: channel 2 interrupt enable, TIMERx(x=0..4,7)
+ \arg TIMER_INT_CH3: channel 3 interrupt enable , TIMERx(x=0..4,7)
+ \arg TIMER_INT_CMT: commutation interrupt enable, TIMERx(x=0,7)
+ \arg TIMER_INT_TRG: trigger interrupt enable, TIMERx(x=0..4,7,8,11)
+ \arg TIMER_INT_BRK: break interrupt enable, TIMERx(x=0,7)
+ \param[out] none
+ \retval none
+*/
+void timer_interrupt_disable(uint32_t timer_periph, uint32_t interrupt)
+{
+ TIMER_DMAINTEN(timer_periph) &= (~(uint32_t)interrupt);
+}
+
+/*!
+ \brief get timer interrupt flag
+ \param[in] timer_periph: please refer to the following parameters
+ \param[in] interrupt: the timer interrupt bits
+ only one parameter can be selected which is shown as below:
+ \arg TIMER_INT_FLAG_UP: update interrupt flag,TIMERx(x=0..13)
+ \arg TIMER_INT_FLAG_CH0: channel 0 interrupt flag,TIMERx(x=0..4,7..13)
+ \arg TIMER_INT_FLAG_CH1: channel 1 interrupt flag,TIMERx(x=0..4,7,8,11)
+ \arg TIMER_INT_FLAG_CH2: channel 2 interrupt flag,TIMERx(x=0..4,7)
+ \arg TIMER_INT_FLAG_CH3: channel 3 interrupt flag,TIMERx(x=0..4,7)
+ \arg TIMER_INT_FLAG_CMT: channel commutation interrupt flag,TIMERx(x=0,7)
+ \arg TIMER_INT_FLAG_TRG: trigger interrupt flag,TIMERx(x=0,7,8,11)
+ \arg TIMER_INT_FLAG_BRK: break interrupt flag,TIMERx(x=0,7)
+ \param[out] none
+ \retval FlagStatus: SET or RESET
+*/
+FlagStatus timer_interrupt_flag_get(uint32_t timer_periph, uint32_t interrupt)
+{
+ uint32_t val;
+ val = (TIMER_DMAINTEN(timer_periph) & interrupt);
+ if((RESET != (TIMER_INTF(timer_periph) & interrupt)) && (RESET != val)) {
+ return SET;
+ } else {
+ return RESET;
+ }
+}
+
+/*!
+ \brief clear TIMER interrupt flag
+ \param[in] timer_periph: please refer to the following parameters
+ \param[in] interrupt: the timer interrupt bits
+ only one parameter can be selected which is shown as below:
+ \arg TIMER_INT_FLAG_UP: update interrupt flag,TIMERx(x=0..13)
+ \arg TIMER_INT_FLAG_CH0: channel 0 interrupt flag,TIMERx(x=0..4,7..13)
+ \arg TIMER_INT_FLAG_CH1: channel 1 interrupt flag,TIMERx(x=0..4,7,8,11)
+ \arg TIMER_INT_FLAG_CH2: channel 2 interrupt flag,TIMERx(x=0..4,7)
+ \arg TIMER_INT_FLAG_CH3: channel 3 interrupt flag,TIMERx(x=0..4,7)
+ \arg TIMER_INT_FLAG_CMT: channel commutation interrupt flag,TIMERx(x=0,7)
+ \arg TIMER_INT_FLAG_TRG: trigger interrupt flag,TIMERx(x=0,7,8,11)
+ \arg TIMER_INT_FLAG_BRK: break interrupt flag,TIMERx(x=0,7)
+ \param[out] none
+ \retval none
+*/
+void timer_interrupt_flag_clear(uint32_t timer_periph, uint32_t interrupt)
+{
+ TIMER_INTF(timer_periph) = (~(uint32_t)interrupt);
+}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_tli.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_tli.c
index 9d719bb29b..2e4fad1fc4 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_tli.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_tli.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -40,7 +41,7 @@ OF SUCH DAMAGE.
#define TLI_OPAQUE_VALUE 0x000000FFU
/*!
- \brief deinitialize TLI registers
+ \brief deinitialize TLI registers
\param[in] none
\param[out] none
\retval none
@@ -52,7 +53,7 @@ void tli_deinit(void)
}
/*!
- \brief initialize the parameters of TLI parameter structure with the default values, it is suggested
+ \brief initialize the parameters of TLI parameter structure with the default values, it is suggested
that call this function after a tli_parameter_struct structure is defined
\param[in] none
\param[out] tli_struct: the data needed to initialize TLI
@@ -94,7 +95,7 @@ void tli_struct_para_init(tli_parameter_struct *tli_struct)
}
/*!
- \brief initialize TLI display timing parameters
+ \brief initialize TLI display timing parameters
\param[in] tli_struct: the data needed to initialize TLI
synpsz_vpsz: size of the vertical synchronous pulse
synpsz_hpsz: size of the horizontal synchronous pulse
@@ -117,28 +118,28 @@ void tli_struct_para_init(tli_parameter_struct *tli_struct)
void tli_init(tli_parameter_struct *tli_struct)
{
/* synchronous pulse size configuration */
- TLI_SPSZ &= ~(TLI_SPSZ_VPSZ|TLI_SPSZ_HPSZ);
- TLI_SPSZ = (uint32_t)((uint32_t)tli_struct->synpsz_vpsz|((uint32_t)tli_struct->synpsz_hpsz<<16U));
+ TLI_SPSZ &= ~(TLI_SPSZ_VPSZ | TLI_SPSZ_HPSZ);
+ TLI_SPSZ = (uint32_t)((uint32_t)tli_struct->synpsz_vpsz | ((uint32_t)tli_struct->synpsz_hpsz << 16U));
/* back-porch size configuration */
- TLI_BPSZ &= ~(TLI_BPSZ_VBPSZ|TLI_BPSZ_HBPSZ);
- TLI_BPSZ = (uint32_t)((uint32_t)tli_struct->backpsz_vbpsz|((uint32_t)tli_struct->backpsz_hbpsz<<16U));
+ TLI_BPSZ &= ~(TLI_BPSZ_VBPSZ | TLI_BPSZ_HBPSZ);
+ TLI_BPSZ = (uint32_t)((uint32_t)tli_struct->backpsz_vbpsz | ((uint32_t)tli_struct->backpsz_hbpsz << 16U));
/* active size configuration */
- TLI_ASZ &= ~(TLI_ASZ_VASZ|TLI_ASZ_HASZ);
- TLI_ASZ = (tli_struct->activesz_vasz|(tli_struct->activesz_hasz<<16U));
+ TLI_ASZ &= ~(TLI_ASZ_VASZ | TLI_ASZ_HASZ);
+ TLI_ASZ = (tli_struct->activesz_vasz | (tli_struct->activesz_hasz << 16U));
/* total size configuration */
- TLI_TSZ &= ~(TLI_TSZ_VTSZ|TLI_TSZ_HTSZ);
- TLI_TSZ = (tli_struct->totalsz_vtsz|(tli_struct->totalsz_htsz<<16U));
+ TLI_TSZ &= ~(TLI_TSZ_VTSZ | TLI_TSZ_HTSZ);
+ TLI_TSZ = (tli_struct->totalsz_vtsz | (tli_struct->totalsz_htsz << 16U));
/* background color configuration */
- TLI_BGC &= ~(TLI_BGC_BVB|(TLI_BGC_BVG)|(TLI_BGC_BVR));
- TLI_BGC = (tli_struct->backcolor_blue|(tli_struct->backcolor_green<<8U)|(tli_struct->backcolor_red<<16U));
- TLI_CTL &= ~(TLI_CTL_HPPS|TLI_CTL_VPPS|TLI_CTL_DEPS|TLI_CTL_CLKPS);
- TLI_CTL |= (tli_struct->signalpolarity_hs|tli_struct->signalpolarity_vs|\
- tli_struct->signalpolarity_de|tli_struct->signalpolarity_pixelck);
+ TLI_BGC &= ~(TLI_BGC_BVB | (TLI_BGC_BVG) | (TLI_BGC_BVR));
+ TLI_BGC = (tli_struct->backcolor_blue | (tli_struct->backcolor_green << 8U) | (tli_struct->backcolor_red << 16U));
+ TLI_CTL &= ~(TLI_CTL_HPPS | TLI_CTL_VPPS | TLI_CTL_DEPS | TLI_CTL_CLKPS);
+ TLI_CTL |= (tli_struct->signalpolarity_hs | tli_struct->signalpolarity_vs | \
+ tli_struct->signalpolarity_de | tli_struct->signalpolarity_pixelck);
}
/*!
- \brief configure TLI dither function
+ \brief configure TLI dither function
\param[in] dither_stat
only one parameter can be selected which is shown as below:
\arg TLI_DITHER_ENABLE
@@ -148,15 +149,15 @@ void tli_init(tli_parameter_struct *tli_struct)
*/
void tli_dither_config(uint8_t dither_stat)
{
- if(TLI_DITHER_ENABLE == dither_stat){
+ if(TLI_DITHER_ENABLE == dither_stat) {
TLI_CTL |= TLI_CTL_DFEN;
- }else{
+ } else {
TLI_CTL &= ~(TLI_CTL_DFEN);
}
}
/*!
- \brief enable TLI
+ \brief enable TLI
\param[in] none
\param[out] none
\retval none
@@ -167,7 +168,7 @@ void tli_enable(void)
}
/*!
- \brief disable TLI
+ \brief disable TLI
\param[in] none
\param[out] none
\retval none
@@ -178,7 +179,7 @@ void tli_disable(void)
}
/*!
- \brief configure TLI reload mode
+ \brief configure TLI reload mode
\param[in] reload_mod
only one parameter can be selected which is shown as below:
\arg TLI_FRAME_BLANK_RELOAD_EN
@@ -188,17 +189,17 @@ void tli_disable(void)
*/
void tli_reload_config(uint8_t reload_mod)
{
- if(TLI_FRAME_BLANK_RELOAD_EN == reload_mod){
+ if(TLI_FRAME_BLANK_RELOAD_EN == reload_mod) {
/* the layer configuration will be reloaded at frame blank */
TLI_RL |= TLI_RL_FBR;
- }else{
+ } else {
/* the layer configuration will be reloaded after this bit sets */
TLI_RL |= TLI_RL_RQR;
}
}
/*!
- \brief initialize the parameters of TLI layer structure with the default values, it is suggested
+ \brief initialize the parameters of TLI layer structure with the default values, it is suggested
that call this function after a tli_layer_parameter_struct structure is defined
\param[in] none
\param[out] layer_struct: TLI Layer parameter struct
@@ -244,7 +245,7 @@ void tli_layer_struct_para_init(tli_layer_parameter_struct *layer_struct)
}
/*!
- \brief initialize TLI layer
+ \brief initialize TLI layer
\param[in] layerx: LAYERx(x=0,1)
\param[in] layer_struct: TLI Layer parameter struct
layer_window_rightpos: window right position
@@ -268,14 +269,14 @@ void tli_layer_struct_para_init(tli_layer_parameter_struct *layer_struct)
\param[out] none
\retval none
*/
-void tli_layer_init(uint32_t layerx,tli_layer_parameter_struct *layer_struct)
+void tli_layer_init(uint32_t layerx, tli_layer_parameter_struct *layer_struct)
{
/* configure layer window horizontal position */
- TLI_LxHPOS(layerx) &= ~(TLI_LxHPOS_WLP|(TLI_LxHPOS_WRP));
- TLI_LxHPOS(layerx) = (uint32_t)((uint32_t)layer_struct->layer_window_leftpos|((uint32_t)layer_struct->layer_window_rightpos<<16U));
+ TLI_LxHPOS(layerx) &= ~(TLI_LxHPOS_WLP | (TLI_LxHPOS_WRP));
+ TLI_LxHPOS(layerx) = (uint32_t)((uint32_t)layer_struct->layer_window_leftpos | ((uint32_t)layer_struct->layer_window_rightpos << 16U));
/* configure layer window vertical position */
- TLI_LxVPOS(layerx) &= ~(TLI_LxVPOS_WTP|(TLI_LxVPOS_WBP));
- TLI_LxVPOS(layerx) = (uint32_t)((uint32_t)layer_struct->layer_window_toppos|((uint32_t)layer_struct->layer_window_bottompos<<16U));
+ TLI_LxVPOS(layerx) &= ~(TLI_LxVPOS_WTP | (TLI_LxVPOS_WBP));
+ TLI_LxVPOS(layerx) = (uint32_t)((uint32_t)layer_struct->layer_window_toppos | ((uint32_t)layer_struct->layer_window_bottompos << 16U));
/* configure layer packeted pixel format */
TLI_LxPPF(layerx) &= ~(TLI_LxPPF_PPF);
TLI_LxPPF(layerx) = layer_struct->layer_ppf;
@@ -283,20 +284,20 @@ void tli_layer_init(uint32_t layerx,tli_layer_parameter_struct *layer_struct)
TLI_LxSA(layerx) &= ~(TLI_LxSA_SA);
TLI_LxSA(layerx) = layer_struct->layer_sa;
/* configure layer default color */
- TLI_LxDC(layerx) &= ~(TLI_LxDC_DCB|(TLI_LxDC_DCG)|(TLI_LxDC_DCR)|(TLI_LxDC_DCA));
- TLI_LxDC(layerx) = (uint32_t)((uint32_t)layer_struct->layer_default_blue|((uint32_t)layer_struct->layer_default_green<<8U)
- |((uint32_t)layer_struct->layer_default_red<<16U)
- |((uint32_t)layer_struct->layer_default_alpha<<24U));
+ TLI_LxDC(layerx) &= ~(TLI_LxDC_DCB | (TLI_LxDC_DCG) | (TLI_LxDC_DCR) | (TLI_LxDC_DCA));
+ TLI_LxDC(layerx) = (uint32_t)((uint32_t)layer_struct->layer_default_blue | ((uint32_t)layer_struct->layer_default_green << 8U)
+ | ((uint32_t)layer_struct->layer_default_red << 16U)
+ | ((uint32_t)layer_struct->layer_default_alpha << 24U));
/* configure layer alpha calculation factors */
- TLI_LxBLEND(layerx) &= ~(TLI_LxBLEND_ACF2|(TLI_LxBLEND_ACF1));
- TLI_LxBLEND(layerx) = ((layer_struct->layer_acf2)|(layer_struct->layer_acf1));
+ TLI_LxBLEND(layerx) &= ~(TLI_LxBLEND_ACF2 | (TLI_LxBLEND_ACF1));
+ TLI_LxBLEND(layerx) = ((layer_struct->layer_acf2) | (layer_struct->layer_acf1));
/* configure layer frame buffer base address */
TLI_LxFBADDR(layerx) &= ~(TLI_LxFBADDR_FBADD);
TLI_LxFBADDR(layerx) = (layer_struct->layer_frame_bufaddr);
/* configure layer frame line length */
- TLI_LxFLLEN(layerx) &= ~(TLI_LxFLLEN_FLL|(TLI_LxFLLEN_STDOFF));
- TLI_LxFLLEN(layerx) = (uint32_t)((uint32_t)layer_struct->layer_frame_line_length|((uint32_t)layer_struct->layer_frame_buf_stride_offset<<16U));
+ TLI_LxFLLEN(layerx) &= ~(TLI_LxFLLEN_FLL | (TLI_LxFLLEN_STDOFF));
+ TLI_LxFLLEN(layerx) = (uint32_t)((uint32_t)layer_struct->layer_frame_line_length | ((uint32_t)layer_struct->layer_frame_buf_stride_offset << 16U));
/* configure layer frame total line number */
TLI_LxFTLN(layerx) &= ~(TLI_LxFTLN_FTLN);
TLI_LxFTLN(layerx) = (uint32_t)(layer_struct->layer_frame_total_line_number);
@@ -304,56 +305,56 @@ void tli_layer_init(uint32_t layerx,tli_layer_parameter_struct *layer_struct)
}
/*!
- \brief reconfigure window position
+ \brief reconfigure window position
\param[in] layerx: LAYERx(x=0,1)
\param[in] offset_x: new horizontal offset
\param[in] offset_y: new vertical offset
\param[out] none
\retval none
*/
-void tli_layer_window_offset_modify(uint32_t layerx,uint16_t offset_x,uint16_t offset_y)
+void tli_layer_window_offset_modify(uint32_t layerx, uint16_t offset_x, uint16_t offset_y)
{
/* configure window start position */
uint32_t layer_ppf, line_num, hstart, vstart;
uint32_t line_length = 0U;
- TLI_LxHPOS(layerx) &= ~(TLI_LxHPOS_WLP|(TLI_LxHPOS_WRP));
- TLI_LxVPOS(layerx) &= ~(TLI_LxVPOS_WTP|(TLI_LxVPOS_WBP));
- hstart = (uint32_t)offset_x+(((TLI_BPSZ & TLI_BPSZ_HBPSZ)>>16U)+1U);
- vstart = (uint32_t)offset_y+((TLI_BPSZ & TLI_BPSZ_VBPSZ)+1U);
+ TLI_LxHPOS(layerx) &= ~(TLI_LxHPOS_WLP | (TLI_LxHPOS_WRP));
+ TLI_LxVPOS(layerx) &= ~(TLI_LxVPOS_WTP | (TLI_LxVPOS_WBP));
+ hstart = (uint32_t)offset_x + (((TLI_BPSZ & TLI_BPSZ_HBPSZ) >> 16U) + 1U);
+ vstart = (uint32_t)offset_y + ((TLI_BPSZ & TLI_BPSZ_VBPSZ) + 1U);
line_num = (TLI_LxFTLN(layerx) & TLI_LxFTLN_FTLN);
layer_ppf = (TLI_LxPPF(layerx) & TLI_LxPPF_PPF);
/* the bytes of a line equal TLI_LxFLLEN_FLL bits value minus 3 */
- switch(layer_ppf){
+ switch(layer_ppf) {
case LAYER_PPF_ARGB8888:
/* each pixel includes 4bytes, when pixel format is ARGB8888 */
- line_length = (((TLI_LxFLLEN(layerx) & TLI_LxFLLEN_FLL)-3U)/4U);
+ line_length = (((TLI_LxFLLEN(layerx) & TLI_LxFLLEN_FLL) - 3U) / 4U);
break;
case LAYER_PPF_RGB888:
/* each pixel includes 3bytes, when pixel format is RGB888 */
- line_length = (((TLI_LxFLLEN(layerx) & TLI_LxFLLEN_FLL)-3U)/3U);
+ line_length = (((TLI_LxFLLEN(layerx) & TLI_LxFLLEN_FLL) - 3U) / 3U);
break;
case LAYER_PPF_RGB565:
case LAYER_PPF_ARGB1555:
case LAYER_PPF_ARGB4444:
case LAYER_PPF_AL88:
/* each pixel includes 2bytes, when pixel format is RGB565,ARG1555,ARGB4444 or AL88 */
- line_length = (((TLI_LxFLLEN(layerx) & TLI_LxFLLEN_FLL)-3U)/2U);
+ line_length = (((TLI_LxFLLEN(layerx) & TLI_LxFLLEN_FLL) - 3U) / 2U);
break;
case LAYER_PPF_L8:
case LAYER_PPF_AL44:
/* each pixel includes 1byte, when pixel format is L8 or AL44 */
- line_length = (((TLI_LxFLLEN(layerx) & TLI_LxFLLEN_FLL)-3U));
+ line_length = (((TLI_LxFLLEN(layerx) & TLI_LxFLLEN_FLL) - 3U));
break;
default:
break;
}
/* reconfigure window position */
- TLI_LxHPOS(layerx) = (hstart|((hstart+line_length-1U)<<16U));
- TLI_LxVPOS(layerx) = (vstart|((vstart+line_num-1U)<<16U));
+ TLI_LxHPOS(layerx) = (hstart | ((hstart + line_length - 1U) << 16U));
+ TLI_LxVPOS(layerx) = (vstart | ((vstart + line_num - 1U) << 16U));
}
/*!
- \brief initialize the parameters of TLI layer LUT structure with the default values, it is suggested
+ \brief initialize the parameters of TLI layer LUT structure with the default values, it is suggested
that call this function after a tli_layer_lut_parameter_struct structure is defined
\param[in] none
\param[out] lut_struct: TLI layer LUT parameter struct
@@ -373,7 +374,7 @@ void tli_lut_struct_para_init(tli_layer_lut_parameter_struct *lut_struct)
}
/*!
- \brief initialize TLI layer LUT
+ \brief initialize TLI layer LUT
\param[in] layerx: LAYERx(x=0,1)
\param[in] lut_struct: TLI layer LUT parameter struct
layer_table_addr: look up table write address
@@ -383,16 +384,15 @@ void tli_lut_struct_para_init(tli_layer_lut_parameter_struct *lut_struct)
\param[out] none
\retval none
*/
-void tli_lut_init(uint32_t layerx,tli_layer_lut_parameter_struct *lut_struct)
+void tli_lut_init(uint32_t layerx, tli_layer_lut_parameter_struct *lut_struct)
{
- TLI_LxLUT(layerx) &= ~(TLI_LxLUT_TB|TLI_LxLUT_TG|TLI_LxLUT_TR|TLI_LxLUT_TADD);
- TLI_LxLUT(layerx) = (uint32_t)(((uint32_t)lut_struct->layer_lut_channel_blue)|((uint32_t)lut_struct->layer_lut_channel_green<<8U)
- |((uint32_t)lut_struct->layer_lut_channel_red<<16U
- |((uint32_t)lut_struct->layer_table_addr<<24U)));
+ TLI_LxLUT(layerx) = (uint32_t)(((uint32_t)lut_struct->layer_lut_channel_blue) | ((uint32_t)lut_struct->layer_lut_channel_green << 8U)
+ | ((uint32_t)lut_struct->layer_lut_channel_red << 16U
+ | ((uint32_t)lut_struct->layer_table_addr << 24U)));
}
/*!
- \brief initialize TLI layer color key
+ \brief initialize TLI layer color key
\param[in] layerx: LAYERx(x=0,1)
\param[in] redkey: color key red
\param[in] greenkey: color key green
@@ -400,13 +400,13 @@ void tli_lut_init(uint32_t layerx,tli_layer_lut_parameter_struct *lut_struct)
\param[out] none
\retval none
*/
-void tli_color_key_init(uint32_t layerx,uint8_t redkey,uint8_t greenkey,uint8_t bluekey)
+void tli_color_key_init(uint32_t layerx, uint8_t redkey, uint8_t greenkey, uint8_t bluekey)
{
- TLI_LxCKEY(layerx) = (((uint32_t)bluekey)|((uint32_t)greenkey<<8U)|((uint32_t)redkey<<16U));
+ TLI_LxCKEY(layerx) = (((uint32_t)bluekey) | ((uint32_t)greenkey << 8U) | ((uint32_t)redkey << 16U));
}
/*!
- \brief enable TLI layer
+ \brief enable TLI layer
\param[in] layerx: LAYERx(x=0,1)
\param[out] none
\retval none
@@ -417,7 +417,7 @@ void tli_layer_enable(uint32_t layerx)
}
/*!
- \brief disable TLI layer
+ \brief disable TLI layer
\param[in] layerx: LAYERx(x=0,1)
\param[out] none
\retval none
@@ -428,7 +428,7 @@ void tli_layer_disable(uint32_t layerx)
}
/*!
- \brief enable TLI layer color keying
+ \brief enable TLI layer color keying
\param[in] layerx: LAYERx(x=0,1)
\param[out] none
\retval none
@@ -439,7 +439,7 @@ void tli_color_key_enable(uint32_t layerx)
}
/*!
- \brief disable TLI layer color keying
+ \brief disable TLI layer color keying
\param[in] layerx: LAYERx(x=0,1)
\param[out] none
\retval none
@@ -450,7 +450,7 @@ void tli_color_key_disable(uint32_t layerx)
}
/*!
- \brief enable TLI layer LUT
+ \brief enable TLI layer LUT
\param[in] layerx: LAYERx(x=0,1)
\param[out] none
\retval none
@@ -461,7 +461,7 @@ void tli_lut_enable(uint32_t layerx)
}
/*!
- \brief disable TLI layer LUT
+ \brief disable TLI layer LUT
\param[in] layerx: LAYERx(x=0,1)
\param[out] none
\retval none
@@ -472,7 +472,7 @@ void tli_lut_disable(uint32_t layerx)
}
/*!
- \brief set line mark value
+ \brief set line mark value
\param[in] line_num: line number
\param[out] none
\retval none
@@ -484,7 +484,7 @@ void tli_line_mark_set(uint16_t line_num)
}
/*!
- \brief get current displayed position
+ \brief get current displayed position
\param[in] none
\param[out] none
\retval position of current pixel
@@ -495,7 +495,7 @@ uint32_t tli_current_pos_get(void)
}
/*!
- \brief enable TLI interrupt
+ \brief enable TLI interrupt
\param[in] int_flag: TLI interrupt flags
one or more parameters can be selected which are shown as below:
\arg TLI_INT_LM: line mark interrupt
@@ -511,7 +511,7 @@ void tli_interrupt_enable(uint32_t int_flag)
}
/*!
- \brief disable TLI interrupt
+ \brief disable TLI interrupt
\param[in] int_flag: TLI interrupt flags
one or more parameters can be selected which are shown as below:
\arg TLI_INT_LM: line mark interrupt
@@ -527,7 +527,7 @@ void tli_interrupt_disable(uint32_t int_flag)
}
/*!
- \brief get TLI interrupt flag
+ \brief get TLI interrupt flag
\param[in] int_flag: TLI interrupt flags
one or more parameters can be selected which are shown as below:
\arg TLI_INT_FLAG_LM: line mark interrupt flag
@@ -541,9 +541,9 @@ FlagStatus tli_interrupt_flag_get(uint32_t int_flag)
{
uint32_t state;
state = TLI_INTF;
- if(state & int_flag){
+ if(state & int_flag) {
state = TLI_INTEN;
- if(state & int_flag){
+ if(state & int_flag) {
return SET;
}
}
@@ -551,7 +551,7 @@ FlagStatus tli_interrupt_flag_get(uint32_t int_flag)
}
/*!
- \brief clear TLI interrupt flag
+ \brief clear TLI interrupt flag
\param[in] int_flag: TLI interrupt flags
one or more parameters can be selected which are shown as below:
\arg TLI_INT_FLAG_LM: line mark interrupt flag
@@ -567,7 +567,7 @@ void tli_interrupt_flag_clear(uint32_t int_flag)
}
/*!
- \brief get TLI flag or state in TLI_INTF register or TLI_STAT register
+ \brief get TLI flag or state in TLI_INTF register or TLI_STAT register
\param[in] flag: TLI flags or states
only one parameter can be selected which is shown as below:
\arg TLI_FLAG_VDE: current VDE state
@@ -585,14 +585,14 @@ FlagStatus tli_flag_get(uint32_t flag)
{
uint32_t stat;
/* choose which register to get flag or state */
- if(flag >> 31U){
+ if(flag >> 31U) {
stat = TLI_INTF;
- }else{
+ } else {
stat = TLI_STAT;
}
- if(flag & stat){
+ if(flag & stat) {
return SET;
- }else{
+ } else {
return RESET;
}
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_trng.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_trng.c
index 8c86bb832e..862432ca4e 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_trng.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_trng.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -37,7 +38,7 @@ OF SUCH DAMAGE.
#include "gd32f4xx_trng.h"
/*!
- \brief deinitialize the TRNG
+ \brief reset TRNG
\param[in] none
\param[out] none
\retval none
@@ -49,7 +50,7 @@ void trng_deinit(void)
}
/*!
- \brief enable the TRNG interface
+ \brief enable TRNG
\param[in] none
\param[out] none
\retval none
@@ -60,7 +61,7 @@ void trng_enable(void)
}
/*!
- \brief disable the TRNG interface
+ \brief disable TRNG
\param[in] none
\param[out] none
\retval none
@@ -74,7 +75,7 @@ void trng_disable(void)
\brief get the true random data
\param[in] none
\param[out] none
- \retval the generated random data
+ \retval uint32_t: 0x0-0xFFFFFFFF
*/
uint32_t trng_get_true_random_data(void)
{
@@ -82,70 +83,70 @@ uint32_t trng_get_true_random_data(void)
}
/*!
- \brief enable the TRNG interrupt
+ \brief enable TRNG interrupt
\param[in] none
\param[out] none
\retval none
*/
void trng_interrupt_enable(void)
{
- TRNG_CTL |= TRNG_CTL_IE;
+ TRNG_CTL |= TRNG_CTL_TRNGIE;
}
/*!
- \brief disable the TRNG interrupt
+ \brief disable TRNG interrupt
\param[in] none
\param[out] none
\retval none
*/
void trng_interrupt_disable(void)
{
- TRNG_CTL &= ~TRNG_CTL_IE;
+ TRNG_CTL &= ~TRNG_CTL_TRNGIE;
}
/*!
- \brief get the trng status flags
- \param[in] flag: trng status flag, refer to trng_flag_enum
+ \brief get TRNG flag status
+ \param[in] flag: TRNG flag
only one parameter can be selected which is shown as below:
- \arg TRNG_FLAG_DRDY: Random Data ready status
- \arg TRNG_FLAG_CECS: Clock error current status
- \arg TRNG_FLAG_SECS: Seed error current status
+ \arg TRNG_FLAG_DRDY: random Data ready status
+ \arg TRNG_FLAG_CECS: clock error current status
+ \arg TRNG_FLAG_SECS: seed error current status
\param[out] none
\retval FlagStatus: SET or RESET
*/
FlagStatus trng_flag_get(trng_flag_enum flag)
{
- if(RESET != (TRNG_STAT & flag)){
+ if(RESET != (TRNG_STAT & flag)) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief get the trng interrupt flags
- \param[in] int_flag: trng interrupt flag, refer to trng_int_flag_enum
+ \brief get TRNG interrupt flag status
+ \param[in] int_flag: TRNG interrupt flag
only one parameter can be selected which is shown as below:
\arg TRNG_INT_FLAG_CEIF: clock error interrupt flag
- \arg TRNG_INT_FLAG_SEIF: Seed error interrupt flag
+ \arg TRNG_INT_FLAG_SEIF: seed error interrupt flag
\param[out] none
\retval FlagStatus: SET or RESET
*/
FlagStatus trng_interrupt_flag_get(trng_int_flag_enum int_flag)
{
- if(RESET != (TRNG_STAT & int_flag)){
+ if(RESET != (TRNG_STAT & int_flag)) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief clear the trng interrupt flags
- \param[in] int_flag: trng interrupt flag, refer to trng_int_flag_enum
+ \brief clear TRNG interrupt flag status
+ \param[in] int_flag: TRNG interrupt flag
only one parameter can be selected which is shown as below:
\arg TRNG_INT_FLAG_CEIF: clock error interrupt flag
- \arg TRNG_INT_FLAG_SEIF: Seed error interrupt flag
+ \arg TRNG_INT_FLAG_SEIF: seed error interrupt flag
\param[out] none
\retval none
*/
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_usart.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_usart.c
index 1b864e3b96..e54929d941 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_usart.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_usart.c
@@ -5,10 +5,11 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -34,7 +35,6 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
OF SUCH DAMAGE.
*/
-
#include "gd32f4xx_usart.h"
/* USART register bit offset */
@@ -43,14 +43,14 @@ OF SUCH DAMAGE.
#define RT_BL_OFFSET ((uint32_t)24U) /* bit offset of BL in USART_RT */
/*!
- \brief reset USART/UART
+ \brief reset USART/UART
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[out] none
\retval none
*/
void usart_deinit(uint32_t usart_periph)
{
- switch(usart_periph){
+ switch(usart_periph) {
case USART0:
rcu_periph_reset_enable(RCU_USART0RST);
rcu_periph_reset_disable(RCU_USART0RST);
@@ -89,7 +89,7 @@ void usart_deinit(uint32_t usart_periph)
}
/*!
- \brief configure USART baud rate value
+ \brief configure USART baud rate value
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] baudval: baud rate value
\param[out] none
@@ -97,45 +97,45 @@ void usart_deinit(uint32_t usart_periph)
*/
void usart_baudrate_set(uint32_t usart_periph, uint32_t baudval)
{
- uint32_t uclk=0U, intdiv=0U, fradiv=0U, udiv=0U;
- switch(usart_periph){
- /* get clock frequency */
+ uint32_t uclk = 0U, intdiv = 0U, fradiv = 0U, udiv = 0U;
+ switch(usart_periph) {
+ /* get clock frequency */
case USART0:
- uclk=rcu_clock_freq_get(CK_APB2);
- break;
+ uclk = rcu_clock_freq_get(CK_APB2);
+ break;
case USART5:
- uclk=rcu_clock_freq_get(CK_APB2);
- break;
+ uclk = rcu_clock_freq_get(CK_APB2);
+ break;
case USART1:
- uclk=rcu_clock_freq_get(CK_APB1);
- break;
+ uclk = rcu_clock_freq_get(CK_APB1);
+ break;
case USART2:
- uclk=rcu_clock_freq_get(CK_APB1);
- break;
+ uclk = rcu_clock_freq_get(CK_APB1);
+ break;
case UART3:
- uclk=rcu_clock_freq_get(CK_APB1);
- break;
+ uclk = rcu_clock_freq_get(CK_APB1);
+ break;
case UART4:
- uclk=rcu_clock_freq_get(CK_APB1);
- break;
+ uclk = rcu_clock_freq_get(CK_APB1);
+ break;
case UART6:
- uclk=rcu_clock_freq_get(CK_APB1);
- break;
+ uclk = rcu_clock_freq_get(CK_APB1);
+ break;
case UART7:
- uclk=rcu_clock_freq_get(CK_APB1);
- break;
+ uclk = rcu_clock_freq_get(CK_APB1);
+ break;
default:
- break;
+ break;
}
- if(USART_CTL0(usart_periph) & USART_CTL0_OVSMOD){
+ if(USART_CTL0(usart_periph) & USART_CTL0_OVSMOD) {
/* when oversampling by 8, configure the value of USART_BAUD */
- udiv = ((2U*uclk) + baudval/2U)/baudval;
+ udiv = ((2U * uclk) + baudval / 2U) / baudval;
intdiv = udiv & 0xfff0U;
- fradiv = (udiv>>1U) & 0x7U;
+ fradiv = (udiv >> 1U) & 0x7U;
USART_BAUD(usart_periph) = ((USART_BAUD_FRADIV | USART_BAUD_INTDIV) & (intdiv | fradiv));
- }else{
+ } else {
/* when oversampling by 16, configure the value of USART_BAUD */
- udiv = (uclk+baudval/2U)/baudval;
+ udiv = (uclk + baudval / 2U) / baudval;
intdiv = udiv & 0xfff0U;
fradiv = udiv & 0xfU;
USART_BAUD(usart_periph) = ((USART_BAUD_FRADIV | USART_BAUD_INTDIV) & (intdiv | fradiv));
@@ -143,7 +143,7 @@ void usart_baudrate_set(uint32_t usart_periph, uint32_t baudval)
}
/*!
- \brief configure USART parity function
+ \brief configure USART parity function
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] paritycfg: configure USART parity
only one parameter can be selected which is shown as below:
@@ -157,12 +157,12 @@ void usart_parity_config(uint32_t usart_periph, uint32_t paritycfg)
{
/* clear USART_CTL0 PM,PCEN Bits */
USART_CTL0(usart_periph) &= ~(USART_CTL0_PM | USART_CTL0_PCEN);
- /* configure USART parity mode */
+ /* configure USART parity mode */
USART_CTL0(usart_periph) |= paritycfg ;
}
/*!
- \brief configure USART word length
+ \brief configure USART word length
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] wlen: USART word length configure
only one parameter can be selected which is shown as below:
@@ -180,7 +180,7 @@ void usart_word_length_set(uint32_t usart_periph, uint32_t wlen)
}
/*!
- \brief configure USART stop bit length
+ \brief configure USART stop bit length
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] stblen: USART stop bit configure
only one parameter can be selected which is shown as below:
@@ -199,7 +199,7 @@ void usart_stop_bit_set(uint32_t usart_periph, uint32_t stblen)
USART_CTL1(usart_periph) |= stblen;
}
/*!
- \brief enable USART
+ \brief enable USART
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[out] none
\retval none
@@ -210,7 +210,7 @@ void usart_enable(uint32_t usart_periph)
}
/*!
- \brief disable USART
+ \brief disable USART
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[out] none
\retval none
@@ -221,7 +221,7 @@ void usart_disable(uint32_t usart_periph)
}
/*!
- \brief configure USART transmitter
+ \brief configure USART transmitter
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] txconfig: enable or disable USART transmitter
only one parameter can be selected which is shown as below:
@@ -242,7 +242,7 @@ void usart_transmit_config(uint32_t usart_periph, uint32_t txconfig)
}
/*!
- \brief configure USART receiver
+ \brief configure USART receiver
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] rxconfig: enable or disable USART receiver
only one parameter can be selected which is shown as below:
@@ -263,7 +263,7 @@ void usart_receive_config(uint32_t usart_periph, uint32_t rxconfig)
}
/*!
- \brief data is transmitted/received with the LSB/MSB first
+ \brief data is transmitted/received with the LSB/MSB first
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[in] msbf: LSB/MSB
only one parameter can be selected which is shown as below:
@@ -284,7 +284,7 @@ void usart_data_first_config(uint32_t usart_periph, uint32_t msbf)
}
/*!
- \brief configure USART inversion
+ \brief configure USART inversion
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[in] invertpara: refer to enum USART_INVERT_CONFIG
only one parameter can be selected which is shown as below:
@@ -300,7 +300,7 @@ void usart_data_first_config(uint32_t usart_periph, uint32_t msbf)
void usart_invert_config(uint32_t usart_periph, usart_invert_enum invertpara)
{
/* inverted or not the specified siginal */
- switch(invertpara){
+ switch(invertpara) {
case USART_DINV_ENABLE:
USART_CTL3(usart_periph) |= USART_CTL3_DINV;
break;
@@ -325,7 +325,7 @@ void usart_invert_config(uint32_t usart_periph, usart_invert_enum invertpara)
}
/*!
- \brief configure the USART oversample mode
+ \brief configure the USART oversample mode
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] oversamp: oversample value
only one parameter can be selected which is shown as below:
@@ -342,7 +342,7 @@ void usart_oversample_config(uint32_t usart_periph, uint32_t oversamp)
}
/*!
- \brief configure sample bit method
+ \brief configure sample bit method
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] obsm: sample bit
only one parameter can be selected which is shown as below:
@@ -358,7 +358,7 @@ void usart_sample_bit_config(uint32_t usart_periph, uint32_t obsm)
}
/*!
- \brief enable receiver timeout of USART
+ \brief enable receiver timeout of USART
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[out] none
\retval none
@@ -369,7 +369,7 @@ void usart_receiver_timeout_enable(uint32_t usart_periph)
}
/*!
- \brief disable receiver timeout of USART
+ \brief disable receiver timeout of USART
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[out] none
\retval none
@@ -380,7 +380,7 @@ void usart_receiver_timeout_disable(uint32_t usart_periph)
}
/*!
- \brief set the receiver timeout threshold of USART
+ \brief set the receiver timeout threshold of USART
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[in] rtimeout: 0-0x00FFFFFF
\param[out] none
@@ -393,19 +393,19 @@ void usart_receiver_timeout_threshold_config(uint32_t usart_periph, uint32_t rti
}
/*!
- \brief USART transmit data function
+ \brief USART transmit data function
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] data: data of transmission
\param[out] none
\retval none
*/
-void usart_data_transmit(uint32_t usart_periph, uint32_t data)
+void usart_data_transmit(uint32_t usart_periph, uint16_t data)
{
- USART_DATA(usart_periph) = ((uint16_t)USART_DATA_DATA & data);
+ USART_DATA(usart_periph) = USART_DATA_DATA & (uint32_t)data;
}
/*!
- \brief USART receive data function
+ \brief USART receive data function
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[out] none
\retval data of received
@@ -416,7 +416,7 @@ uint16_t usart_data_receive(uint32_t usart_periph)
}
/*!
- \brief configure the address of the USART in wake up by address match mode
+ \brief configure the address of the USART in wake up by address match mode
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] addr: address of USART/UART
\param[out] none
@@ -425,11 +425,11 @@ uint16_t usart_data_receive(uint32_t usart_periph)
void usart_address_config(uint32_t usart_periph, uint8_t addr)
{
USART_CTL1(usart_periph) &= ~(USART_CTL1_ADDR);
- USART_CTL1(usart_periph) |= (USART_CTL1_ADDR & addr);
+ USART_CTL1(usart_periph) |= (USART_CTL1_ADDR & (uint32_t)addr);
}
/*!
- \brief enable mute mode
+ \brief enable mute mode
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[out] none
\retval none
@@ -440,7 +440,7 @@ void usart_mute_mode_enable(uint32_t usart_periph)
}
/*!
- \brief disable mute mode
+ \brief disable mute mode
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[out] none
\retval none
@@ -451,7 +451,7 @@ void usart_mute_mode_disable(uint32_t usart_periph)
}
/*!
- \brief configure wakeup method in mute mode
+ \brief configure wakeup method in mute mode
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] wmehtod: two method be used to enter or exit the mute mode
only one parameter can be selected which is shown as below:
@@ -467,7 +467,7 @@ void usart_mute_mode_wakeup_config(uint32_t usart_periph, uint32_t wmehtod)
}
/*!
- \brief enable LIN mode
+ \brief enable LIN mode
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[out] none
\retval none
@@ -478,7 +478,7 @@ void usart_lin_mode_enable(uint32_t usart_periph)
}
/*!
- \brief disable LIN mode
+ \brief disable LIN mode
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[out] none
\retval none
@@ -489,7 +489,7 @@ void usart_lin_mode_disable(uint32_t usart_periph)
}
/*!
- \brief configure lin break frame length
+ \brief configure lin break frame length
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] lblen: lin break frame length
only one parameter can be selected which is shown as below:
@@ -505,7 +505,7 @@ void usart_lin_break_detection_length_config(uint32_t usart_periph, uint32_t lbl
}
/*!
- \brief send break frame
+ \brief send break frame
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[out] none
\retval none
@@ -516,7 +516,7 @@ void usart_send_break(uint32_t usart_periph)
}
/*!
- \brief enable half duplex mode
+ \brief enable half duplex mode
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[out] none
\retval none
@@ -527,7 +527,7 @@ void usart_halfduplex_enable(uint32_t usart_periph)
}
/*!
- \brief disable half duplex mode
+ \brief disable half duplex mode
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[out] none
\retval none
@@ -538,7 +538,7 @@ void usart_halfduplex_disable(uint32_t usart_periph)
}
/*!
- \brief enable CK pin in synchronous mode
+ \brief enable CK pin in synchronous mode
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[out] none
\retval none
@@ -549,7 +549,7 @@ void usart_synchronous_clock_enable(uint32_t usart_periph)
}
/*!
- \brief disable CK pin in synchronous mode
+ \brief disable CK pin in synchronous mode
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[out] none
\retval none
@@ -560,7 +560,7 @@ void usart_synchronous_clock_disable(uint32_t usart_periph)
}
/*!
- \brief configure USART synchronous mode parameters
+ \brief configure USART synchronous mode parameters
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[in] clen: CK length
only one parameter can be selected which is shown as below:
@@ -579,32 +579,25 @@ void usart_synchronous_clock_disable(uint32_t usart_periph)
*/
void usart_synchronous_clock_config(uint32_t usart_periph, uint32_t clen, uint32_t cph, uint32_t cpl)
{
- uint32_t ctl = 0U;
-
- /* read USART_CTL1 register */
- ctl = USART_CTL1(usart_periph);
- ctl &= ~(USART_CTL1_CLEN | USART_CTL1_CPH | USART_CTL1_CPL);
- /* set CK length, CK phase, CK polarity */
- ctl |= (USART_CTL1_CLEN & clen) | (USART_CTL1_CPH & cph) | (USART_CTL1_CPL & cpl);
-
- USART_CTL1(usart_periph) = ctl;
+ USART_CTL1(usart_periph) &= ~(USART_CTL1_CLEN | USART_CTL1_CPH | USART_CTL1_CPL);
+ USART_CTL1(usart_periph) = (USART_CTL1_CLEN & clen) | (USART_CTL1_CPH & cph) | (USART_CTL1_CPL & cpl);
}
/*!
- \brief configure guard time value in smartcard mode
+ \brief configure guard time value in smartcard mode
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[in] guat: guard time value, 0-0xFF
\param[out] none
\retval none
*/
-void usart_guard_time_config(uint32_t usart_periph,uint32_t guat)
+void usart_guard_time_config(uint32_t usart_periph, uint8_t guat)
{
USART_GP(usart_periph) &= ~(USART_GP_GUAT);
- USART_GP(usart_periph) |= (USART_GP_GUAT & ((guat)<<GP_GUAT_OFFSET));
+ USART_GP(usart_periph) |= (USART_GP_GUAT & ((uint32_t)guat << GP_GUAT_OFFSET));
}
/*!
- \brief enable smartcard mode
+ \brief enable smartcard mode
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[out] none
\retval none
@@ -615,7 +608,7 @@ void usart_smartcard_mode_enable(uint32_t usart_periph)
}
/*!
- \brief disable smartcard mode
+ \brief disable smartcard mode
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[out] none
\retval none
@@ -626,7 +619,7 @@ void usart_smartcard_mode_disable(uint32_t usart_periph)
}
/*!
- \brief enable NACK in smartcard mode
+ \brief enable NACK in smartcard mode
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[out] none
\retval none
@@ -637,7 +630,7 @@ void usart_smartcard_mode_nack_enable(uint32_t usart_periph)
}
/*!
- \brief disable NACK in smartcard mode
+ \brief disable NACK in smartcard mode
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[out] none
\retval none
@@ -648,33 +641,33 @@ void usart_smartcard_mode_nack_disable(uint32_t usart_periph)
}
/*!
- \brief configure smartcard auto-retry number
+ \brief configure smartcard auto-retry number
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[in] scrtnum: smartcard auto-retry number
\param[out] none
\retval none
*/
-void usart_smartcard_autoretry_config(uint32_t usart_periph, uint32_t scrtnum)
+void usart_smartcard_autoretry_config(uint32_t usart_periph, uint8_t scrtnum)
{
USART_CTL3(usart_periph) &= ~(USART_CTL3_SCRTNUM);
- USART_CTL3(usart_periph) |= (USART_CTL3_SCRTNUM & ((scrtnum)<<CTL3_SCRTNUM_OFFSET));
+ USART_CTL3(usart_periph) |= (USART_CTL3_SCRTNUM & ((uint32_t)scrtnum << CTL3_SCRTNUM_OFFSET));
}
/*!
- \brief configure block length in Smartcard T=1 reception
+ \brief configure block length in Smartcard T=1 reception
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[in] bl: block length
\param[out] none
\retval none
*/
-void usart_block_length_config(uint32_t usart_periph, uint32_t bl)
+void usart_block_length_config(uint32_t usart_periph, uint8_t bl)
{
USART_RT(usart_periph) &= ~(USART_RT_BL);
- USART_RT(usart_periph) |= (USART_RT_BL & ((bl)<<RT_BL_OFFSET));
+ USART_RT(usart_periph) |= (USART_RT_BL & ((uint32_t)bl << RT_BL_OFFSET));
}
/*!
- \brief enable IrDA mode
+ \brief enable IrDA mode
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[out] none
\retval none
@@ -685,7 +678,7 @@ void usart_irda_mode_enable(uint32_t usart_periph)
}
/*!
- \brief disable IrDA mode
+ \brief disable IrDA mode
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[out] none
\retval none
@@ -696,7 +689,7 @@ void usart_irda_mode_disable(uint32_t usart_periph)
}
/*!
- \brief configure the peripheral clock prescaler in USART IrDA low-power mode
+ \brief configure the peripheral clock prescaler in USART IrDA low-power mode
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] psc: 0-0xFF
\param[out] none
@@ -705,11 +698,11 @@ void usart_irda_mode_disable(uint32_t usart_periph)
void usart_prescaler_config(uint32_t usart_periph, uint8_t psc)
{
USART_GP(usart_periph) &= ~(USART_GP_PSC);
- USART_GP(usart_periph) |= psc;
+ USART_GP(usart_periph) |= (uint32_t)psc;
}
/*!
- \brief configure IrDA low-power
+ \brief configure IrDA low-power
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] irlp: IrDA low-power or normal
only one parameter can be selected which is shown as below:
@@ -725,7 +718,7 @@ void usart_irda_lowpower_config(uint32_t usart_periph, uint32_t irlp)
}
/*!
- \brief configure hardware flow control RTS
+ \brief configure hardware flow control RTS
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[in] rtsconfig: enable or disable RTS
only one parameter can be selected which is shown as below:
@@ -736,17 +729,11 @@ void usart_irda_lowpower_config(uint32_t usart_periph, uint32_t irlp)
*/
void usart_hardware_flow_rts_config(uint32_t usart_periph, uint32_t rtsconfig)
{
- uint32_t ctl = 0U;
-
- ctl = USART_CTL2(usart_periph);
- ctl &= ~USART_CTL2_RTSEN;
- ctl |= rtsconfig;
- /* configure RTS */
- USART_CTL2(usart_periph) = ctl;
+ USART_CTL2(usart_periph) &= ~(USART_CTL2_RTSEN);
+ USART_CTL2(usart_periph) |= (USART_CTL2_RTSEN & rtsconfig);
}
-
/*!
- \brief configure hardware flow control CTS
+ \brief configure hardware flow control CTS
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[in] ctsconfig: enable or disable CTS
only one parameter can be selected which is shown as below:
@@ -757,17 +744,12 @@ void usart_hardware_flow_rts_config(uint32_t usart_periph, uint32_t rtsconfig)
*/
void usart_hardware_flow_cts_config(uint32_t usart_periph, uint32_t ctsconfig)
{
- uint32_t ctl = 0U;
-
- ctl = USART_CTL2(usart_periph);
- ctl &= ~USART_CTL2_CTSEN;
- ctl |= ctsconfig;
- /* configure CTS */
- USART_CTL2(usart_periph) = ctl;
+ USART_CTL2(usart_periph) &= ~(USART_CTL2_CTSEN);
+ USART_CTL2(usart_periph) |= (USART_CTL2_CTSEN & ctsconfig);
}
/*!
- \brief configure break frame coherence mode
+ \brief configure break frame coherence mode
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[in] bcm:
only one parameter can be selected which is shown as below:
@@ -783,7 +765,7 @@ void usart_break_frame_coherence_config(uint32_t usart_periph, uint32_t bcm)
}
/*!
- \brief configure parity check coherence mode
+ \brief configure parity check coherence mode
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] pcm:
only one parameter can be selected which is shown as below:
@@ -799,7 +781,7 @@ void usart_parity_check_coherence_config(uint32_t usart_periph, uint32_t pcm)
}
/*!
- \brief configure hardware flow control coherence mode
+ \brief configure hardware flow control coherence mode
\param[in] usart_periph: USARTx(x=0,1,2,5)
\param[in] hcm:
only one parameter can be selected which is shown as below:
@@ -815,49 +797,39 @@ void usart_hardware_flow_coherence_config(uint32_t usart_periph, uint32_t hcm)
}
/*!
- \brief configure USART DMA reception
+ \brief configure USART DMA reception
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] dmacmd: enable or disable DMA for reception
only one parameter can be selected which is shown as below:
- \arg USART_DENR_ENABLE: DMA enable for reception
- \arg USART_DENR_DISABLE: DMA disable for reception
+ \arg USART_RECEIVE_DMA_ENABLE: DMA enable for reception
+ \arg USART_RECEIVE_DMA_DISABLE: DMA disable for reception
\param[out] none
\retval none
*/
void usart_dma_receive_config(uint32_t usart_periph, uint32_t dmacmd)
{
- uint32_t ctl = 0U;
-
- ctl = USART_CTL2(usart_periph);
- ctl &= ~USART_CTL2_DENR;
- ctl |= dmacmd;
- /* configure DMA reception */
- USART_CTL2(usart_periph) = ctl;
+ USART_CTL2(usart_periph) &= ~(USART_CTL2_DENR);
+ USART_CTL2(usart_periph) |= (USART_CTL2_DENR & dmacmd);
}
/*!
- \brief configure USART DMA transmission
+ \brief configure USART DMA transmission
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] dmacmd: enable or disable DMA for transmission
only one parameter can be selected which is shown as below:
- \arg USART_DENT_ENABLE: DMA enable for transmission
- \arg USART_DENT_DISABLE: DMA disable for transmission
+ \arg USART_TRANSMIT_DMA_ENABLE: DMA enable for transmission
+ \arg USART_TRANSMIT_DMA_DISABLE: DMA disable for transmission
\param[out] none
\retval none
*/
void usart_dma_transmit_config(uint32_t usart_periph, uint32_t dmacmd)
{
- uint32_t ctl = 0U;
-
- ctl = USART_CTL2(usart_periph);
- ctl &= ~USART_CTL2_DENT;
- ctl |= dmacmd;
- /* configure DMA transmission */
- USART_CTL2(usart_periph) = ctl;
+ USART_CTL2(usart_periph) &= ~(USART_CTL2_DENT);
+ USART_CTL2(usart_periph) |= (USART_CTL2_DENT & dmacmd);
}
/*!
- \brief get flag in STAT0/STAT1/CHC register
+ \brief get flag in STAT0/STAT1/CHC register
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] flag: USART flags, refer to usart_flag_enum
only one parameter can be selected which is shown as below:
@@ -880,15 +852,15 @@ void usart_dma_transmit_config(uint32_t usart_periph, uint32_t dmacmd)
*/
FlagStatus usart_flag_get(uint32_t usart_periph, usart_flag_enum flag)
{
- if(RESET != (USART_REG_VAL(usart_periph, flag) & BIT(USART_BIT_POS(flag)))){
+ if(RESET != (USART_REG_VAL(usart_periph, flag) & BIT(USART_BIT_POS(flag)))) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief clear flag in STAT0/STAT1/CHC register
+ \brief clear flag in STAT0/STAT1/CHC register
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] flag: USART flags, refer to usart_flag_enum
only one parameter can be selected which is shown as below:
@@ -908,7 +880,7 @@ void usart_flag_clear(uint32_t usart_periph, usart_flag_enum flag)
}
/*!
- \brief enable USART interrupt
+ \brief enable USART interrupt
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] interrupt: USART interrupts, refer to usart_interrupt_enum
only one parameter can be selected which is shown as below:
@@ -931,7 +903,7 @@ void usart_interrupt_enable(uint32_t usart_periph, usart_interrupt_enum interrup
}
/*!
- \brief disable USART interrupt
+ \brief disable USART interrupt
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] interrupt: USART interrupts, refer to usart_interrupt_enum
only one parameter can be selected which is shown as below:
@@ -954,7 +926,7 @@ void usart_interrupt_disable(uint32_t usart_periph, usart_interrupt_enum interru
}
/*!
- \brief get USART interrupt and flag status
+ \brief get USART interrupt and flag status
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] int_flag: USART interrupt flags, refer to usart_interrupt_flag_enum
only one parameter can be selected which is shown as below:
@@ -982,15 +954,15 @@ FlagStatus usart_interrupt_flag_get(uint32_t usart_periph, usart_interrupt_flag_
/* get the corresponding flag bit status */
flagstatus = (USART_REG_VAL2(usart_periph, int_flag) & BIT(USART_BIT_POS2(int_flag)));
- if((0U != flagstatus) && (0U != intenable)){
+ if((0U != flagstatus) && (0U != intenable)) {
return SET;
- }else{
+ } else {
return RESET;
}
}
/*!
- \brief clear USART interrupt flag in STAT0/STAT1 register
+ \brief clear USART interrupt flag in STAT0/STAT1 register
\param[in] usart_periph: USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7)
\param[in] int_flag: USART interrupt flags, refer to usart_interrupt_flag_enum
only one parameter can be selected which is shown as below:
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_wwdgt.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_wwdgt.c
index e788c26614..6362865980 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_wwdgt.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_standard_peripheral/Source/gd32f4xx_wwdgt.c
@@ -5,44 +5,40 @@
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.0.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#include "gd32f4xx_wwdgt.h"
-/* write value to WWDGT_CTL_CNT bit field */
-#define CTL_CNT(regval) (BITS(0,6) & ((uint32_t)(regval) << 0))
-/* write value to WWDGT_CFG_WIN bit field */
-#define CFG_WIN(regval) (BITS(0,6) & ((uint32_t)(regval) << 0))
-
/*!
- \brief reset the window watchdog timer configuration
+ \brief reset the window watchdog timer configuration
\param[in] none
\param[out] none
\retval none
@@ -54,7 +50,7 @@ void wwdgt_deinit(void)
}
/*!
- \brief start the window watchdog timer counter
+ \brief start the window watchdog timer counter
\param[in] none
\param[out] none
\retval none
@@ -65,24 +61,19 @@ void wwdgt_enable(void)
}
/*!
- \brief configure the window watchdog timer counter value
+ \brief configure the window watchdog timer counter value
\param[in] counter_value: 0x00 - 0x7F
\param[out] none
\retval none
*/
void wwdgt_counter_update(uint16_t counter_value)
{
- uint32_t reg = 0U;
-
- reg = (WWDGT_CTL & (~WWDGT_CTL_CNT));
- reg |= CTL_CNT(counter_value);
-
- WWDGT_CTL = reg;
+ WWDGT_CTL = (uint32_t)(CTL_CNT(counter_value));
}
/*!
- \brief configure counter value, window value, and prescaler divider value
- \param[in] counter: 0x00 - 0x7F
+ \brief configure counter value, window value, and prescaler divider value
+ \param[in] counter: 0x00 - 0x7F
\param[in] window: 0x00 - 0x7F
\param[in] prescaler: wwdgt prescaler value
only one parameter can be selected which is shown as below:
@@ -95,34 +86,13 @@ void wwdgt_counter_update(uint16_t counter_value)
*/
void wwdgt_config(uint16_t counter, uint16_t window, uint32_t prescaler)
{
- uint32_t reg_cfg = 0U, reg_ctl = 0U;
-
- /* clear WIN and PSC bits, clear CNT bit */
- reg_cfg = (WWDGT_CFG &(~(WWDGT_CFG_WIN|WWDGT_CFG_PSC)));
- reg_ctl = (WWDGT_CTL &(~WWDGT_CTL_CNT));
-
/* configure WIN and PSC bits, configure CNT bit */
- reg_cfg |= CFG_WIN(window);
- reg_cfg |= prescaler;
- reg_ctl |= CTL_CNT(counter);
-
- WWDGT_CTL = reg_ctl;
- WWDGT_CFG = reg_cfg;
-}
-
-/*!
- \brief enable early wakeup interrupt of WWDGT
- \param[in] none
- \param[out] none
- \retval none
-*/
-void wwdgt_interrupt_enable(void)
-{
- WWDGT_CFG |= WWDGT_CFG_EWIE;
+ WWDGT_CTL = (uint32_t)(CTL_CNT(counter));
+ WWDGT_CFG = (uint32_t)(CFG_WIN(window) | prescaler);
}
/*!
- \brief check early wakeup interrupt state of WWDGT
+ \brief check early wakeup interrupt state of WWDGT
\param[in] none
\param[out] none
\retval FlagStatus: SET or RESET
@@ -137,12 +107,23 @@ FlagStatus wwdgt_flag_get(void)
}
/*!
- \brief clear early wakeup interrupt state of WWDGT
+ \brief clear early wakeup interrupt state of WWDGT
\param[in] none
\param[out] none
\retval none
*/
void wwdgt_flag_clear(void)
{
- WWDGT_STAT &= (~WWDGT_STAT_EWIF);
+ WWDGT_STAT = (uint32_t)(RESET);
+}
+
+/*!
+ \brief enable early wakeup interrupt of WWDGT
+ \param[in] none
+ \param[out] none
+ \retval none
+*/
+void wwdgt_interrupt_enable(void)
+{
+ WWDGT_CFG |= WWDGT_CFG_EWIE;
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Include/audio_core.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Include/audio_core.h
index 66e224d03a..fa4ae7773a 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Include/audio_core.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Include/audio_core.h
@@ -3,32 +3,34 @@
\brief the header file of USB audio device class core functions
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -37,96 +39,97 @@ OF SUCH DAMAGE.
#include "usbd_enum.h"
-#define FORMAT_24BIT(x) (uint8_t)(x);(uint8_t)(x >> 8U);(uint8_t)(x >> 16U)
+#define FORMAT_24BIT(x) (uint8_t)(x);(uint8_t)((x) >> 8U);(uint8_t)((x) >> 16U)
/* number of sub-packets in the audio transfer buffer. you can modify this value but always make sure
that it is an even number and higher than 3 */
-#define OUT_PACKET_NUM 4U
+#define OUT_PACKET_NUM 200U
/* total size of the audio transfer buffer */
-#define OUT_BUF_MARGIN 4U
-#define TOTAL_OUT_BUF_SIZE ((uint32_t)((SPEAKER_OUT_PACKET + OUT_BUF_MARGIN) * OUT_PACKET_NUM))
+#define OUT_BUF_MARGIN 0U
+#define TOTAL_OUT_BUF_SIZE ((uint32_t)((SPEAKER_OUT_PACKET + OUT_BUF_MARGIN) * OUT_PACKET_NUM))
-#define AUDIO_CONFIG_DESC_SET_LEN (sizeof(usb_desc_config_set))
-#define AUDIO_INTERFACE_DESC_SIZE 9U
+#define AD_CONFIG_DESC_SET_LEN (sizeof(usb_desc_config_set))
+#define AD_INTERFACE_DESC_SIZE 9U
-#define USB_AUDIO_DESC_SIZ 0x09U
-#define AUDIO_STANDARD_EP_DESC_SIZE 0x09U
-#define AUDIO_STREAMING_EP_DESC_SIZE 0x07U
+#define USB_AD_DESC_SIZ 0x09U
+#define AD_STANDARD_EP_DESC_SIZE 0x09U
+#define AD_STREAMING_EP_DESC_SIZE 0x07U
/* audio interface class code */
-#define USB_CLASS_AUDIO 0x01U
+#define USB_CLASS_AUDIO 0x01U
/* audio interface subclass codes */
-#define AUDIO_SUBCLASS_CONTROL 0x01U
-#define AUDIO_SUBCLASS_AUDIOSTREAMING 0x02U
-#define AUDIO_SUBCLASS_MIDISTREAMING 0x03U
+#define AD_SUBCLASS_CONTROL 0x01U
+#define AD_SUBCLASS_AUDIOSTREAMING 0x02U
+#define AD_SUBCLASS_MIDISTREAMING 0x03U
/* audio interface protocol codes */
-#define AUDIO_PROTOCOL_UNDEFINED 0x00U
-#define AUDIO_STREAMING_GENERAL 0x01U
-#define AUDIO_STREAMING_FORMAT_TYPE 0x02U
+#define AD_PROTOCOL_UNDEFINED 0x00U
+#define AD_STREAMING_GENERAL 0x01U
+#define AD_STREAMING_FORMAT_TYPE 0x02U
/* audio class-specific descriptor types */
-#define AUDIO_DESCTYPE_UNDEFINED 0x20U
-#define AUDIO_DESCTYPE_DEVICE 0x21U
-#define AUDIO_DESCTYPE_CONFIGURATION 0x22U
-#define AUDIO_DESCTYPE_STRING 0x23U
-#define AUDIO_DESCTYPE_INTERFACE 0x24U
-#define AUDIO_DESCTYPE_ENDPOINT 0x25U
+#define AD_DESCTYPE_UNDEFINED 0x20U
+#define AD_DESCTYPE_DEVICE 0x21U
+#define AD_DESCTYPE_CONFIGURATION 0x22U
+#define AD_DESCTYPE_STRING 0x23U
+#define AD_DESCTYPE_INTERFACE 0x24U
+#define AD_DESCTYPE_ENDPOINT 0x25U
/* audio control interface descriptor subtypes */
-#define AUDIO_CONTROL_HEADER 0x01U
-#define AUDIO_CONTROL_INPUT_TERMINAL 0x02U
-#define AUDIO_CONTROL_OUTPUT_TERMINAL 0x03U
-#define AUDIO_CONTROL_MIXER_UNIT 0x04U
-#define AUDIO_CONTROL_SELECTOR_UNIT 0x05U
-#define AUDIO_CONTROL_FEATURE_UNIT 0x06U
-#define AUDIO_CONTROL_PROCESSING_UNIT 0x07U
-#define AUDIO_CONTROL_EXTENSION_UNIT 0x08U
+#define AD_CONTROL_HEADER 0x01U
+#define AD_CONTROL_INPUT_TERMINAL 0x02U
+#define AD_CONTROL_OUTPUT_TERMINAL 0x03U
+#define AD_CONTROL_MIXER_UNIT 0x04U
+#define AD_CONTROL_SELECTOR_UNIT 0x05U
+#define AD_CONTROL_FEATURE_UNIT 0x06U
+#define AD_CONTROL_PROCESSING_UNIT 0x07U
+#define AD_CONTROL_EXTENSION_UNIT 0x08U
-#define AUDIO_INPUT_TERMINAL_DESC_SIZE 0x0CU
-#define AUDIO_OUTPUT_TERMINAL_DESC_SIZE 0x09U
-#define AUDIO_STREAMING_INTERFACE_DESC_SIZE 0x07U
+#define AD_INPUT_TERMINAL_DESC_SIZE 0x0CU
+#define AD_OUTPUT_TERMINAL_DESC_SIZE 0x09U
+#define AD_STREAMING_INTERFACE_DESC_SIZE 0x07U
-#define AUDIO_CONTROL_MUTE 0x01U
-#define AUDIO_CONTROL_VOLUME 0x02U
+#define AD_CONTROL_MUTE 0x01U
+#define AD_CONTROL_VOLUME 0x02U
-#define AUDIO_FORMAT_TYPE_I 0x01U
-#define AUDIO_FORMAT_TYPE_III 0x03U
+#define AD_FORMAT_TYPE_I 0x01U
+#define AD_FORMAT_TYPE_III 0x03U
-#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01U
-#define AUDIO_ENDPOINT_GENERAL 0x01U
+#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01U
+#define AD_ENDPOINT_GENERAL 0x01U
-#define AUDIO_REQ_UNDEFINED 0x00U
-#define AUDIO_REQ_SET_CUR 0x01U
-#define AUDIO_REQ_GET_CUR 0x81U
-#define AUDIO_REQ_SET_MIN 0x02U
-#define AUDIO_REQ_GET_MIN 0x82U
-#define AUDIO_REQ_SET_MAX 0x03U
-#define AUDIO_REQ_GET_MAX 0x83U
-#define AUDIO_REQ_SET_RES 0x04U
-#define AUDIO_REQ_GET_RES 0x84U
-#define AUDIO_REQ_SET_MEM 0x05U
-#define AUDIO_REQ_GET_MEM 0x85U
-#define AUDIO_REQ_GET_STAT 0xFFU
+#define AD_REQ_UNDEFINED 0x00U
+#define AD_REQ_SET_CUR 0x01U
+#define AD_REQ_GET_CUR 0x81U
+#define AD_REQ_SET_MIN 0x02U
+#define AD_REQ_GET_MIN 0x82U
+#define AD_REQ_SET_MAX 0x03U
+#define AD_REQ_GET_MAX 0x83U
+#define AD_REQ_SET_RES 0x04U
+#define AD_REQ_GET_RES 0x84U
+#define AD_REQ_SET_MEM 0x05U
+#define AD_REQ_GET_MEM 0x85U
+#define AD_REQ_GET_STAT 0xFFU
-#define AUDIO_OUT_STREAMING_CTRL 0x05U
-#define AUDIO_IN_STREAMING_CTRL 0x02U
+#define AD_OUT_STREAMING_CTRL 0x05U
+#define AD_IN_STREAMING_CTRL 0x02U
/* audio stream interface number */
enum
{
-#ifdef USE_USB_AUDIO_MICPHONE
+#ifdef USE_USB_AD_MICPHONE
MIC_INTERFACE_COUNT,
-#endif
-#ifdef USE_USB_AUDIO_SPEAKER
+#endif /* USE_USB_AD_MICPHONE */
+
+#ifdef USE_USB_AD_SPEAKER
SPEAK_INTERFACE_COUNT,
-#endif
+#endif /* USE_USB_AD_SPEAKER */
CONFIG_DESC_AS_ITF_COUNT,
};
-#define AC_ITF_TOTAL_LEN (sizeof(usb_desc_AC_itf) + CONFIG_DESC_AS_ITF_COUNT*(sizeof(usb_desc_input_terminal) + \
+#define AC_ITF_TOTAL_LEN (sizeof(usb_desc_AC_itf) + CONFIG_DESC_AS_ITF_COUNT*(sizeof(usb_desc_input_terminal) + \
sizeof(usb_desc_mono_feature_unit) + sizeof(usb_desc_output_terminal)))
#pragma pack(1)
@@ -138,13 +141,13 @@ typedef struct
uint16_t bcdADC; /*!< audio device class specification release number in binary-coded decimal */
uint16_t wTotalLength; /*!< total number of bytes */
uint8_t bInCollection; /*!< the number of the streaming interfaces */
-#ifdef USE_USB_AUDIO_MICPHONE
+#ifdef USE_USB_AD_MICPHONE
uint8_t baInterfaceNr0; /*!< interface number of the streaming interfaces */
-#endif
+#endif /* USE_USB_AD_MICPHONE */
-#ifdef USE_USB_AUDIO_SPEAKER
+#ifdef USE_USB_AD_SPEAKER
uint8_t baInterfaceNr1; /*!< interface number of the streaming interfaces */
-#endif
+#endif /* USE_USB_AD_SPEAKER */
} usb_desc_AC_itf;
typedef struct
@@ -237,64 +240,83 @@ typedef struct
uint16_t wLockDelay; /*!< indicates the time it takes this endpoint to reliably lock its internal clock recovery circuitry */
} usb_desc_AS_ep;
+typedef struct
+{
+ usb_desc_header header; /*!< descriptor header, including type and size */
+ uint8_t bEndpointAddress; /*!< EP_GENERAL descriptor subtype */
+ uint8_t bmAttributes; /*!< transfer type and synchronization type */
+ uint16_t wMaxPacketSize; /*!< maximum packet size this endpoint is capable of sending or receiving */
+ uint8_t bInterval; /*!< polling interval in milliseconds for the endpoint if it is an INTERRUPT or ISOCHRONOUS type */
+ uint8_t Refresh; /*!< bRefresh 1~9, power of 2 */
+ uint8_t bSynchAddress; /* bSynchAddress */
+} usb_desc_FeedBack_ep;
+
#pragma pack()
/* USB configuration descriptor structure */
typedef struct
{
- usb_desc_config config;
- usb_desc_itf std_itf;
- usb_desc_AC_itf ac_itf;
+ usb_desc_config config;
+ usb_desc_itf std_itf;
+ usb_desc_AC_itf ac_itf;
-#ifdef USE_USB_AUDIO_MICPHONE
- usb_desc_input_terminal mic_in_terminal;
- usb_desc_mono_feature_unit mic_feature_unit;
- usb_desc_output_terminal mic_out_terminal;
+#ifdef USE_USB_AD_MICPHONE
+ usb_desc_input_terminal mic_in_terminal;
+ usb_desc_mono_feature_unit mic_feature_unit;
+ usb_desc_output_terminal mic_out_terminal;
#endif
-#ifdef USE_USB_AUDIO_SPEAKER
+#ifdef USE_USB_AD_SPEAKER
usb_desc_input_terminal speak_in_terminal;
usb_desc_mono_feature_unit speak_feature_unit;
usb_desc_output_terminal speak_out_terminal;
-#endif
+#endif /* USE_USB_AD_SPEAKER */
-#ifdef USE_USB_AUDIO_MICPHONE
- usb_desc_itf mic_std_as_itf_zeroband;
- usb_desc_itf mic_std_as_itf_opera;
- usb_desc_AS_itf mic_as_itf;
- usb_desc_format_type mic_format_typeI;
- usb_desc_std_ep mic_std_endpoint;
- usb_desc_AS_ep mic_as_endpoint;
-#endif
+#ifdef USE_USB_AD_MICPHONE
+ usb_desc_itf mic_std_as_itf_zeroband;
+ usb_desc_itf mic_std_as_itf_opera;
+ usb_desc_AS_itf mic_as_itf;
+ usb_desc_format_type mic_format_typeI;
+ usb_desc_std_ep mic_std_endpoint;
+ usb_desc_AS_ep mic_as_endpoint;
+#endif /* USE_USB_AD_MICPHONE */
-#ifdef USE_USB_AUDIO_SPEAKER
+#ifdef USE_USB_AD_SPEAKER
usb_desc_itf speak_std_as_itf_zeroband;
usb_desc_itf speak_std_as_itf_opera;
usb_desc_AS_itf speak_as_itf;
usb_desc_format_type speak_format_typeI;
usb_desc_std_ep speak_std_endpoint;
usb_desc_AS_ep speak_as_endpoint;
-#endif
+ usb_desc_FeedBack_ep speak_feedback_endpoint;
+#endif /* USE_USB_AD_SPEAKER */
} usb_desc_config_set;
typedef struct
{
/* main buffer for audio data out transfers and its relative pointers */
- uint8_t isoc_out_buff[TOTAL_OUT_BUF_SIZE * 2U];
+ uint8_t isoc_out_buff[TOTAL_OUT_BUF_SIZE];
uint8_t* isoc_out_wrptr;
uint8_t* isoc_out_rdptr;
+ uint16_t buf_free_size;
+ uint16_t dam_tx_len;
+
+ __IO uint32_t actual_freq;
+ __IO uint8_t play_flag;
+ uint8_t feedback_freq[3];
+ uint32_t cur_sam_freq;
+
+ /* usb receive buffer */
+ uint8_t usb_rx_buffer[SPEAKER_OUT_MAX_PACKET];
/* main buffer for audio control requests transfers and its relative variables */
uint8_t audioctl[64];
uint8_t audioctl_unit;
uint32_t audioctl_len;
-
-#ifdef USE_USB_AUDIO_SPEAKER
- uint32_t play_flag;
-#endif /* USE_USB_AUDIO_SPEAKER */
} usbd_audio_handler;
extern usb_desc audio_desc;
extern usb_class_core usbd_audio_cb;
+extern usbd_audio_handler audio_handler;
#endif /* __AUDIO_CORE_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Include/audio_out_itf.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Include/audio_out_itf.h
index b143c5fa44..f4bfc56b10 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Include/audio_out_itf.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Include/audio_out_itf.h
@@ -3,32 +3,34 @@
\brief audio OUT (playback) interface header file
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -36,39 +38,12 @@ OF SUCH DAMAGE.
#define __AUDIO_OUT_ITF_H
#include "usbd_conf.h"
-
-/* audio commands enumeration */
-typedef enum
-{
- AUDIO_CMD_PLAY = 1U,
- AUDIO_CMD_PAUSE,
- AUDIO_CMD_STOP,
-}audio_cmd_enum;
-
-/* mute commands */
-#define AUDIO_MUTE 0x01U
-#define AUDIO_UNMUTE 0x00U
-
-/* functions return value */
-#define AUDIO_OK 0x00U
-#define AUDIO_FAIL 0xFFU
-
-/* audio machine states */
-#define AUDIO_STATE_INACTIVE 0x00U
-#define AUDIO_STATE_ACTIVE 0x01U
-#define AUDIO_STATE_PLAYING 0x02U
-#define AUDIO_STATE_PAUSED 0x03U
-#define AUDIO_STATE_STOPPED 0x04U
-#define AUDIO_STATE_ERROR 0x05U
+#include "string.h"
typedef struct {
- uint8_t (*audio_init) (uint32_t audio_freq, uint32_t volume, uint32_t options);
- uint8_t (*audio_deinit) (uint32_t options);
+ uint8_t (*audio_init) (uint32_t audio_freq, uint32_t volume);
+ uint8_t (*audio_deinit) (void);
uint8_t (*audio_cmd) (uint8_t* pbuf, uint32_t size, uint8_t cmd);
- uint8_t (*audio_volume_ctl) (uint8_t vol);
- uint8_t (*audio_mute_ctl) (uint8_t cmd);
- uint8_t (*audio_periodic_tc) (uint8_t cmd);
- uint8_t (*audio_state_get) (void);
} audio_fops_struct;
extern audio_fops_struct audio_out_fops;
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Source/audio_core.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Source/audio_core.c
index 6f686aec70..92f6861b47 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Source/audio_core.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Source/audio_core.c
@@ -3,77 +3,92 @@
\brief USB audio device class core functions
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#include "audio_out_itf.h"
#include "audio_core.h"
#include <string.h>
+#include <math.h>
#define USBD_VID 0x28E9U
#define USBD_PID 0x9574U
-#ifdef USE_USB_AUDIO_MICPHONE
+#define VOL_MIN 0U /* volume Minimum Value */
+#define VOL_MAX 100U /* volume Maximum Value */
+#define VOL_RES 1U /* volume Resolution */
+#define VOL_0dB 70U /* 0dB is in the middle of VOL_MIN and VOL_MAX */
+
+#ifdef USE_USB_AD_MICPHONE
extern volatile uint32_t count_data;
extern const char wavetestdata[];
#define LENGTH_DATA (1747 * 32)
-#endif
+#endif /* USE_USB_AD_MICPHONE */
+
+__ALIGN_BEGIN usbd_audio_handler audio_handler __ALIGN_END;
/* local function prototypes ('static') */
static uint8_t audio_init (usb_dev *udev, uint8_t config_index);
static uint8_t audio_deinit (usb_dev *udev, uint8_t config_index);
static uint8_t audio_req_handler (usb_dev *udev, usb_req *req);
+static uint8_t audio_set_intf (usb_dev *udev, usb_req *req);
+static uint8_t audio_ctlx_out (usb_dev *udev);
static uint8_t audio_data_in (usb_dev *udev, uint8_t ep_num);
static uint8_t audio_data_out (usb_dev *udev, uint8_t ep_num);
-static uint8_t usbd_audio_sof (usb_dev *udev);
+static uint8_t audio_sof (usb_dev *udev);
+static uint8_t audio_iso_in_incomplete (usb_dev *udev);
+static uint8_t audio_iso_out_incomplete (usb_dev *udev);
+static uint32_t usbd_audio_spk_get_feedback(usb_dev *udev);
+static void get_feedback_fs_rate(uint32_t rate, uint8_t *buf);
usb_class_core usbd_audio_cb = {
.init = audio_init,
.deinit = audio_deinit,
.req_proc = audio_req_handler,
+ .set_intf = audio_set_intf,
+ .ctlx_out = audio_ctlx_out,
.data_in = audio_data_in,
.data_out = audio_data_out,
- .SOF = usbd_audio_sof
+ .SOF = audio_sof,
+ .incomplete_isoc_in = audio_iso_in_incomplete,
+ .incomplete_isoc_out = audio_iso_out_incomplete
};
-#define VOL_MIN 0U /* volume Minimum Value */
-#define VOL_MAX 100U /* volume Maximum Value */
-#define VOL_RES 1U /* volume Resolution */
-#define VOL_0dB 70U /* 0dB is in the middle of VOL_MIN and VOL_MAX */
-
/* note:it should use the c99 standard when compiling the below codes */
/* USB standard device descriptor */
__ALIGN_BEGIN const usb_desc_dev audio_dev_desc __ALIGN_END =
{
- .header =
+ .header =
{
- .bLength = USB_DEV_DESC_LEN,
+ .bLength = USB_DEV_DESC_LEN,
.bDescriptorType = USB_DESCTYPE_DEV
},
.bcdUSB = 0x0200U,
@@ -91,16 +106,16 @@ __ALIGN_BEGIN const usb_desc_dev audio_dev_desc __ALIGN_END =
};
/* USB device configuration descriptor */
-__ALIGN_BEGIN const usb_desc_config_set audio_config_set __ALIGN_END =
+__ALIGN_BEGIN const usb_desc_config_set audio_config_set __ALIGN_END =
{
- .config =
+ .config =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_config),
- .bDescriptorType = USB_DESCTYPE_CONFIG
+ .bLength = sizeof(usb_desc_config),
+ .bDescriptorType = USB_DESCTYPE_CONFIG
},
- .wTotalLength = AUDIO_CONFIG_DESC_SET_LEN,
+ .wTotalLength = AD_CONFIG_DESC_SET_LEN,
.bNumInterfaces = 0x01U + CONFIG_DESC_AS_ITF_COUNT,
.bConfigurationValue = 0x01U,
.iConfiguration = 0x00U,
@@ -108,48 +123,49 @@ __ALIGN_BEGIN const usb_desc_config_set audio_config_set __ALIGN_END =
.bMaxPower = 0x32U
},
- .std_itf =
+ .std_itf =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_itf),
- .bDescriptorType = USB_DESCTYPE_ITF
+ .bLength = sizeof(usb_desc_itf),
+ .bDescriptorType = USB_DESCTYPE_ITF
},
.bInterfaceNumber = 0x00U,
.bAlternateSetting = 0x00U,
.bNumEndpoints = 0x00U,
.bInterfaceClass = USB_CLASS_AUDIO,
- .bInterfaceSubClass = AUDIO_SUBCLASS_CONTROL,
- .bInterfaceProtocol = AUDIO_PROTOCOL_UNDEFINED,
+ .bInterfaceSubClass = AD_SUBCLASS_CONTROL,
+ .bInterfaceProtocol = AD_PROTOCOL_UNDEFINED,
.iInterface = 0x00U
},
- .ac_itf =
+ .ac_itf =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_AC_itf),
- .bDescriptorType = AUDIO_DESCTYPE_INTERFACE
+ .bLength = sizeof(usb_desc_AC_itf),
+ .bDescriptorType = AD_DESCTYPE_INTERFACE
},
.bDescriptorSubtype = 0x01U,
.bcdADC = 0x0100U,
.wTotalLength = AC_ITF_TOTAL_LEN,
.bInCollection = CONFIG_DESC_AS_ITF_COUNT,
-#ifdef USE_USB_AUDIO_MICPHONE
+#ifdef USE_USB_AD_MICPHONE
.baInterfaceNr0 = 0x01U,
-#endif
-#ifdef USE_USB_AUDIO_SPEAKER
+#endif /* USE_USB_AD_MICPHONE */
+
+#ifdef USE_USB_AD_SPEAKER
.baInterfaceNr1 = 0x02U
-#endif
+#endif /* USE_USB_AD_SPEAKER */
},
-#ifdef USE_USB_AUDIO_MICPHONE
- .mic_in_terminal =
+#ifdef USE_USB_AD_MICPHONE
+ .mic_in_terminal =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_input_terminal),
- .bDescriptorType = AUDIO_DESCTYPE_INTERFACE
+ .bLength = sizeof(usb_desc_input_terminal),
+ .bDescriptorType = AD_DESCTYPE_INTERFACE
},
.bDescriptorSubtype = 0x02U,
.bTerminalID = 0x01U,
@@ -161,47 +177,47 @@ __ALIGN_BEGIN const usb_desc_config_set audio_config_set __ALIGN_END =
.iTerminal = 0x00U
},
- .mic_feature_unit =
+ .mic_feature_unit =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_mono_feature_unit),
- .bDescriptorType = AUDIO_DESCTYPE_INTERFACE
+ .bLength = sizeof(usb_desc_mono_feature_unit),
+ .bDescriptorType = AD_DESCTYPE_INTERFACE
},
- .bDescriptorSubtype = AUDIO_CONTROL_FEATURE_UNIT,
- .bUnitID = AUDIO_IN_STREAMING_CTRL,
+ .bDescriptorSubtype = AD_CONTROL_FEATURE_UNIT,
+ .bUnitID = AD_IN_STREAMING_CTRL,
.bSourceID = 0x01U,
.bControlSize = 0x01U,
- .bmaControls0 = AUDIO_CONTROL_MUTE,
- .bmaControls1 = AUDIO_CONTROL_VOLUME,
+ .bmaControls0 = AD_CONTROL_MUTE | AD_CONTROL_VOLUME,
+ .bmaControls1 = 0x00U,
.iFeature = 0x00U
},
- .mic_out_terminal =
+ .mic_out_terminal =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_output_terminal),
- .bDescriptorType = AUDIO_DESCTYPE_INTERFACE
+ .bLength = sizeof(usb_desc_output_terminal),
+ .bDescriptorType = AD_DESCTYPE_INTERFACE
},
- .bDescriptorSubtype = AUDIO_CONTROL_OUTPUT_TERMINAL,
+ .bDescriptorSubtype = AD_CONTROL_OUTPUT_TERMINAL,
.bTerminalID = 0x03U,
.wTerminalType = 0x0101U,
.bAssocTerminal = 0x00U,
.bSourceID = 0x02U,
.iTerminal = 0x00U
},
-#endif
+#endif /* USE_USB_AD_MICPHONE */
-#ifdef USE_USB_AUDIO_SPEAKER
- .speak_in_terminal =
+#ifdef USE_USB_AD_SPEAKER
+ .speak_in_terminal =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_input_terminal),
- .bDescriptorType = AUDIO_DESCTYPE_INTERFACE
+ .bLength = sizeof(usb_desc_input_terminal),
+ .bDescriptorType = AD_DESCTYPE_INTERFACE
},
- .bDescriptorSubtype = AUDIO_CONTROL_INPUT_TERMINAL,
+ .bDescriptorSubtype = AD_CONTROL_INPUT_TERMINAL,
.bTerminalID = 0x04U,
.wTerminalType = 0x0101U,
.bAssocTerminal = 0x00U,
@@ -211,93 +227,93 @@ __ALIGN_BEGIN const usb_desc_config_set audio_config_set __ALIGN_END =
.iTerminal = 0x00U
},
- .speak_feature_unit =
+ .speak_feature_unit =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_mono_feature_unit),
- .bDescriptorType = AUDIO_DESCTYPE_INTERFACE
+ .bLength = sizeof(usb_desc_mono_feature_unit),
+ .bDescriptorType = AD_DESCTYPE_INTERFACE
},
- .bDescriptorSubtype = AUDIO_CONTROL_FEATURE_UNIT,
- .bUnitID = AUDIO_OUT_STREAMING_CTRL,
+ .bDescriptorSubtype = AD_CONTROL_FEATURE_UNIT,
+ .bUnitID = AD_OUT_STREAMING_CTRL,
.bSourceID = 0x04U,
.bControlSize = 0x01U,
- .bmaControls0 = AUDIO_CONTROL_MUTE,
- .bmaControls1 = AUDIO_CONTROL_VOLUME,
+ .bmaControls0 = AD_CONTROL_MUTE | AD_CONTROL_VOLUME,
+ .bmaControls1 = 0x00U,
.iFeature = 0x00U
},
- .speak_out_terminal =
+ .speak_out_terminal =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_output_terminal),
- .bDescriptorType = AUDIO_DESCTYPE_INTERFACE
+ .bLength = sizeof(usb_desc_output_terminal),
+ .bDescriptorType = AD_DESCTYPE_INTERFACE
},
- .bDescriptorSubtype = AUDIO_CONTROL_OUTPUT_TERMINAL,
+ .bDescriptorSubtype = AD_CONTROL_OUTPUT_TERMINAL,
.bTerminalID = 0x06U,
.wTerminalType = 0x0301U,
.bAssocTerminal = 0x00U,
.bSourceID = 0x05U,
.iTerminal = 0x00U
},
-#endif
+#endif /* USE_USB_AD_SPEAKER */
-#ifdef USE_USB_AUDIO_MICPHONE
- .mic_std_as_itf_zeroband =
+#ifdef USE_USB_AD_MICPHONE
+ .mic_std_as_itf_zeroband =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_itf),
- .bDescriptorType = USB_DESCTYPE_ITF
+ .bLength = sizeof(usb_desc_itf),
+ .bDescriptorType = USB_DESCTYPE_ITF
},
.bInterfaceNumber = 0x01U,
.bAlternateSetting = 0x00U,
.bNumEndpoints = 0x00U,
.bInterfaceClass = USB_CLASS_AUDIO,
- .bInterfaceSubClass = AUDIO_SUBCLASS_AUDIOSTREAMING,
- .bInterfaceProtocol = AUDIO_PROTOCOL_UNDEFINED,
+ .bInterfaceSubClass = AD_SUBCLASS_AUDIOSTREAMING,
+ .bInterfaceProtocol = AD_PROTOCOL_UNDEFINED,
.iInterface = 0x00U
},
- .mic_std_as_itf_opera =
+ .mic_std_as_itf_opera =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_itf),
- .bDescriptorType = USB_DESCTYPE_ITF
+ .bLength = sizeof(usb_desc_itf),
+ .bDescriptorType = USB_DESCTYPE_ITF
},
.bInterfaceNumber = 0x01U,
.bAlternateSetting = 0x01U,
.bNumEndpoints = 0x01U,
.bInterfaceClass = USB_CLASS_AUDIO,
- .bInterfaceSubClass = AUDIO_SUBCLASS_AUDIOSTREAMING,
- .bInterfaceProtocol = AUDIO_PROTOCOL_UNDEFINED,
+ .bInterfaceSubClass = AD_SUBCLASS_AUDIOSTREAMING,
+ .bInterfaceProtocol = AD_PROTOCOL_UNDEFINED,
.iInterface = 0x00U
},
- .mic_as_itf =
+ .mic_as_itf =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_AS_itf),
- .bDescriptorType = AUDIO_DESCTYPE_INTERFACE
+ .bLength = sizeof(usb_desc_AS_itf),
+ .bDescriptorType = AD_DESCTYPE_INTERFACE
},
- .bDescriptorSubtype = AUDIO_STREAMING_GENERAL,
+ .bDescriptorSubtype = AD_STREAMING_GENERAL,
.bTerminalLink = 0x03U,
.bDelay = 0x01U,
.wFormatTag = 0x0001U,
},
- .mic_format_typeI =
+ .mic_format_typeI =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_format_type),
- .bDescriptorType = AUDIO_DESCTYPE_INTERFACE
+ .bLength = sizeof(usb_desc_format_type),
+ .bDescriptorType = AD_DESCTYPE_INTERFACE
},
- .bDescriptorSubtype = AUDIO_STREAMING_FORMAT_TYPE,
- .bFormatType = AUDIO_FORMAT_TYPE_I,
+ .bDescriptorSubtype = AD_STREAMING_FORMAT_TYPE,
+ .bFormatType = AD_FORMAT_TYPE_I,
.bNrChannels = MIC_IN_CHANNEL_NBR,
.bSubFrameSize = 0x02U,
.bBitResolution = MIC_IN_BIT_RESOLUTION,
@@ -307,14 +323,14 @@ __ALIGN_BEGIN const usb_desc_config_set audio_config_set __ALIGN_END =
.bSamFreq[2] = USBD_MIC_FREQ >> 16U
},
- .mic_std_endpoint =
+ .mic_std_endpoint =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_std_ep),
- .bDescriptorType = USB_DESCTYPE_EP
+ .bLength = sizeof(usb_desc_std_ep),
+ .bDescriptorType = USB_DESCTYPE_EP
},
- .bEndpointAddress = AUDIO_IN_EP,
+ .bEndpointAddress = AD_IN_EP,
.bmAttributes = USB_ENDPOINT_TYPE_ISOCHRONOUS,
.wMaxPacketSize = MIC_IN_PACKET,
.bInterval = 0x01U,
@@ -322,75 +338,75 @@ __ALIGN_BEGIN const usb_desc_config_set audio_config_set __ALIGN_END =
.bSynchAddress = 0x00U
},
- .mic_as_endpoint =
+ .mic_as_endpoint =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_AS_ep),
- .bDescriptorType = AUDIO_DESCTYPE_ENDPOINT
+ .bLength = sizeof(usb_desc_AS_ep),
+ .bDescriptorType = AD_DESCTYPE_ENDPOINT
},
- .bDescriptorSubtype = AUDIO_ENDPOINT_GENERAL,
+ .bDescriptorSubtype = AD_ENDPOINT_GENERAL,
.bmAttributes = 0x00U,
.bLockDelayUnits = 0x00U,
.wLockDelay = 0x0000U,
},
-#endif
+#endif /* USE_USB_AD_MICPHONE */
-#ifdef USE_USB_AUDIO_SPEAKER
- .speak_std_as_itf_zeroband =
+#ifdef USE_USB_AD_SPEAKER
+ .speak_std_as_itf_zeroband =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_itf),
- .bDescriptorType = USB_DESCTYPE_ITF
+ .bLength = sizeof(usb_desc_itf),
+ .bDescriptorType = USB_DESCTYPE_ITF
},
.bInterfaceNumber = 0x02U,
.bAlternateSetting = 0x00U,
.bNumEndpoints = 0x00U,
.bInterfaceClass = USB_CLASS_AUDIO,
- .bInterfaceSubClass = AUDIO_SUBCLASS_AUDIOSTREAMING,
- .bInterfaceProtocol = AUDIO_PROTOCOL_UNDEFINED,
+ .bInterfaceSubClass = AD_SUBCLASS_AUDIOSTREAMING,
+ .bInterfaceProtocol = AD_PROTOCOL_UNDEFINED,
.iInterface = 0x00U
},
- .speak_std_as_itf_opera =
+ .speak_std_as_itf_opera =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_itf),
- .bDescriptorType = USB_DESCTYPE_ITF
+ .bLength = sizeof(usb_desc_itf),
+ .bDescriptorType = USB_DESCTYPE_ITF
},
.bInterfaceNumber = 0x02U,
.bAlternateSetting = 0x01U,
- .bNumEndpoints = 0x01U,
+ .bNumEndpoints = 0x02U,
.bInterfaceClass = USB_CLASS_AUDIO,
- .bInterfaceSubClass = AUDIO_SUBCLASS_AUDIOSTREAMING,
- .bInterfaceProtocol = AUDIO_PROTOCOL_UNDEFINED,
+ .bInterfaceSubClass = AD_SUBCLASS_AUDIOSTREAMING,
+ .bInterfaceProtocol = AD_PROTOCOL_UNDEFINED,
.iInterface = 0x00U
},
- .speak_as_itf =
+ .speak_as_itf =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_AS_itf),
- .bDescriptorType = AUDIO_DESCTYPE_INTERFACE
+ .bLength = sizeof(usb_desc_AS_itf),
+ .bDescriptorType = AD_DESCTYPE_INTERFACE
},
- .bDescriptorSubtype = AUDIO_STREAMING_GENERAL,
+ .bDescriptorSubtype = AD_STREAMING_GENERAL,
.bTerminalLink = 0x04U,
.bDelay = 0x01U,
.wFormatTag = 0x0001U,
},
- .speak_format_typeI =
+ .speak_format_typeI =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_format_type),
- .bDescriptorType = AUDIO_DESCTYPE_INTERFACE
+ .bLength = sizeof(usb_desc_format_type),
+ .bDescriptorType = AD_DESCTYPE_INTERFACE
},
- .bDescriptorSubtype = AUDIO_STREAMING_FORMAT_TYPE,
- .bFormatType = AUDIO_FORMAT_TYPE_I,
+ .bDescriptorSubtype = AD_STREAMING_FORMAT_TYPE,
+ .bFormatType = AD_FORMAT_TYPE_I,
.bNrChannels = SPEAKER_OUT_CHANNEL_NBR,
.bSubFrameSize = 0x02U,
.bBitResolution = SPEAKER_OUT_BIT_RESOLUTION,
@@ -400,42 +416,57 @@ __ALIGN_BEGIN const usb_desc_config_set audio_config_set __ALIGN_END =
.bSamFreq[2] = USBD_SPEAKER_FREQ >> 16U
},
- .speak_std_endpoint =
+ .speak_std_endpoint =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_std_ep),
- .bDescriptorType = USB_DESCTYPE_EP
+ .bLength = sizeof(usb_desc_std_ep),
+ .bDescriptorType = USB_DESCTYPE_EP
},
- .bEndpointAddress = AUDIO_OUT_EP,
- .bmAttributes = USB_ENDPOINT_TYPE_ISOCHRONOUS,
+ .bEndpointAddress = AD_OUT_EP,
+ .bmAttributes = USB_EP_ATTR_ISO | USB_EP_ATTR_ASYNC,
.wMaxPacketSize = SPEAKER_OUT_PACKET,
.bInterval = 0x01U,
.bRefresh = 0x00U,
- .bSynchAddress = 0x00U
+ .bSynchAddress = AD_FEEDBACK_IN_EP,
},
- .speak_as_endpoint =
+ .speak_as_endpoint =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_AS_ep),
- .bDescriptorType = AUDIO_DESCTYPE_ENDPOINT
+ .bLength = sizeof(usb_desc_AS_ep),
+ .bDescriptorType = AD_DESCTYPE_ENDPOINT
},
- .bDescriptorSubtype = AUDIO_ENDPOINT_GENERAL,
+ .bDescriptorSubtype = AD_ENDPOINT_GENERAL,
.bmAttributes = 0x00U,
.bLockDelayUnits = 0x00U,
.wLockDelay = 0x0000U,
- }
-#endif
+ },
+
+ .speak_feedback_endpoint =
+ {
+ .header =
+ {
+ .bLength = sizeof(usb_desc_FeedBack_ep),
+ .bDescriptorType = USB_DESCTYPE_EP
+ },
+ .bEndpointAddress = AD_FEEDBACK_IN_EP,
+ .bmAttributes = USB_EP_ATTR_ISO | USB_EP_ATTR_ASYNC | USB_EP_ATTR_FEEDBACK,
+ .wMaxPacketSize = FEEDBACK_IN_PACKET,
+ .bInterval = 0x01U,
+ .Refresh = FEEDBACK_IN_INTERVAL, /* refresh every 32(2^5) ms */
+ .bSynchAddress = 0x00U,
+ },
+#endif /* USE_USB_AD_SPEAKER */
};
/* USB language ID descriptor */
-static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_LANGID),
+ .bLength = sizeof(usb_desc_LANGID),
.bDescriptorType = USB_DESCTYPE_STR
},
@@ -443,39 +474,39 @@ static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
};
/* USB manufacture string */
-static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
{
- .header =
+ .header =
{
- .bLength = USB_STRING_LEN(10),
+ .bLength = USB_STRING_LEN(10),
.bDescriptorType = USB_DESCTYPE_STR,
},
.unicode_string = {'G', 'i', 'g', 'a', 'D', 'e', 'v', 'i', 'c', 'e'}
};
/* USB product string */
-static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
{
- .header =
+ .header =
{
- .bLength = USB_STRING_LEN(14),
+ .bLength = USB_STRING_LEN(14),
.bDescriptorType = USB_DESCTYPE_STR,
},
.unicode_string = {'G', 'D', '3', '2', '-', 'U', 'S', 'B', '_', 'A', 'u', 'd', 'i', 'o'}
};
/* USBD serial string */
-static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
+static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
{
- .header =
+ .header =
{
- .bLength = USB_STRING_LEN(12),
+ .bLength = USB_STRING_LEN(12),
.bDescriptorType = USB_DESCTYPE_STR,
}
};
/* USB string descriptor */
-void *const usbd_audio_strings[] =
+void *const usbd_audio_strings[] =
{
[STR_IDX_LANGID] = (uint8_t *)&usbd_language_id_desc,
[STR_IDX_MFC] = (uint8_t *)&manufacturer_string,
@@ -483,6 +514,7 @@ void *const usbd_audio_strings[] =
[STR_IDX_SERIAL] = (uint8_t *)&serial_string
};
+/* USB descriptor configure */
usb_desc audio_desc = {
.dev_desc = (uint8_t *)&audio_dev_desc,
.config_desc = (uint8_t *)&audio_config_set,
@@ -498,11 +530,9 @@ usb_desc audio_desc = {
*/
static uint8_t audio_init (usb_dev *udev, uint8_t config_index)
{
- static __ALIGN_BEGIN usbd_audio_handler audio_handler __ALIGN_END;
-
memset((void *)&audio_handler, 0, sizeof(usbd_audio_handler));
-#ifdef USE_USB_AUDIO_MICPHONE
+#ifdef USE_USB_AD_MICPHONE
{
usb_desc_std_ep std_ep = audio_config_set.mic_std_endpoint;
@@ -511,43 +541,54 @@ static uint8_t audio_init (usb_dev *udev, uint8_t config_index)
.bEndpointAddress = std_ep.bEndpointAddress,
.bmAttributes = std_ep.bmAttributes,
.wMaxPacketSize = std_ep.wMaxPacketSize,
- .bInterval = std_ep.bInterval
+ .bInterval = std_ep.bInterval
};
/* initialize TX endpoint */
usbd_ep_setup (udev, &ep);
}
-#endif
+#endif /* USE_USB_AD_MICPHONE */
-#ifdef USE_USB_AUDIO_SPEAKER
+#ifdef USE_USB_AD_SPEAKER
{
audio_handler.isoc_out_rdptr = audio_handler.isoc_out_buff;
audio_handler.isoc_out_wrptr = audio_handler.isoc_out_buff;
usb_desc_std_ep std_ep = audio_config_set.speak_std_endpoint;
- usb_desc_ep ep = {
+ usb_desc_ep ep1 = {
.header = std_ep.header,
.bEndpointAddress = std_ep.bEndpointAddress,
.bmAttributes = std_ep.bmAttributes,
- .wMaxPacketSize = std_ep.wMaxPacketSize,
- .bInterval = std_ep.bInterval
+ .wMaxPacketSize = SPEAKER_OUT_MAX_PACKET,
+ .bInterval = std_ep.bInterval
};
/* initialize RX endpoint */
- usbd_ep_setup (udev, &ep);
+ usbd_ep_setup (udev, &ep1);
+
+ /* prepare out endpoint to receive next audio packet */
+ usbd_ep_recev (udev, AD_OUT_EP, audio_handler.usb_rx_buffer, SPEAKER_OUT_MAX_PACKET);
/* initialize the audio output hardware layer */
- if (USBD_OK != audio_out_fops.audio_init(USBD_AUDIO_FREQ_16K, DEFAULT_VOLUME, 0U)) {
+ if (USBD_OK != audio_out_fops.audio_init(USBD_SPEAKER_FREQ, DEFAULT_VOLUME)) {
return USBD_FAIL;
}
- /* prepare OUT endpoint to receive audio data */
- usbd_ep_recev (udev, AUDIO_OUT_EP, (uint8_t*)audio_handler.isoc_out_buff, SPEAKER_OUT_PACKET);
-}
-#endif
+ usb_desc_FeedBack_ep feedback_ep = audio_config_set.speak_feedback_endpoint;
- udev->dev.class_data[USBD_AUDIO_INTERFACE] = (void *)&audio_handler;
+ usb_desc_ep ep2 = {
+ .header = feedback_ep.header,
+ .bEndpointAddress = feedback_ep.bEndpointAddress,
+ .bmAttributes = feedback_ep.bmAttributes,
+ .wMaxPacketSize = feedback_ep.wMaxPacketSize,
+ .bInterval = feedback_ep.bInterval
+ };
+
+ /* initialize Tx endpoint */
+ usbd_ep_setup (udev, &ep2);
+}
+#endif /* USE_USB_AD_SPEAKER */
return USBD_OK;
}
@@ -561,20 +602,23 @@ static uint8_t audio_init (usb_dev *udev, uint8_t config_index)
*/
static uint8_t audio_deinit (usb_dev *udev, uint8_t config_index)
{
-#ifdef USE_USB_AUDIO_MICPHONE
+#ifdef USE_USB_AD_MICPHONE
/* deinitialize AUDIO endpoints */
- usbd_ep_clear(udev, AUDIO_IN_EP);
-#endif
+ usbd_ep_clear(udev, AD_IN_EP);
+#endif /* USE_USB_AD_MICPHONE */
-#ifdef USE_USB_AUDIO_SPEAKER
+#ifdef USE_USB_AD_SPEAKER
/* deinitialize AUDIO endpoints */
- usbd_ep_clear(udev, AUDIO_OUT_EP);
+ usbd_ep_clear(udev, AD_OUT_EP);
/* deinitialize the audio output hardware layer */
- if (USBD_OK != audio_out_fops.audio_deinit(0U)) {
+ if (USBD_OK != audio_out_fops.audio_deinit()) {
return USBD_FAIL;
}
-#endif
+
+ /* deinitialize AUDIO endpoints */
+ usbd_ep_clear(udev, AD_FEEDBACK_IN_EP);
+#endif /* USE_USB_AD_SPEAKER */
return USBD_OK;
}
@@ -590,50 +634,48 @@ static uint8_t audio_req_handler (usb_dev *udev, usb_req *req)
{
uint8_t status = REQ_NOTSUPP;
- usbd_audio_handler *audio = (usbd_audio_handler *)udev->dev.class_data[USBD_AUDIO_INTERFACE];
-
usb_transc *transc_in = &udev->dev.transc_in[0];
usb_transc *transc_out = &udev->dev.transc_out[0];
switch (req->bRequest) {
- case AUDIO_REQ_GET_CUR:
- transc_in->xfer_buf = audio->audioctl;
+ case AD_REQ_GET_CUR:
+ transc_in->xfer_buf = audio_handler.audioctl;
transc_in->remain_len = req->wLength;
status = REQ_SUPP;
break;
- case AUDIO_REQ_SET_CUR:
+ case AD_REQ_SET_CUR:
if (req->wLength) {
- transc_out->xfer_buf = audio->audioctl;
+ transc_out->xfer_buf = audio_handler.audioctl;
transc_out->remain_len = req->wLength;
- udev->dev.class_core->command = AUDIO_REQ_SET_CUR;
+ udev->dev.class_core->command = AD_REQ_SET_CUR;
- audio->audioctl_len = req->wLength;
- audio->audioctl_unit = BYTE_HIGH(req->wIndex);
+ audio_handler.audioctl_len = req->wLength;
+ audio_handler.audioctl_unit = BYTE_HIGH(req->wIndex);
status = REQ_SUPP;
}
break;
- case AUDIO_REQ_GET_MIN:
- *((uint16_t *)audio->audioctl) = VOL_MIN;
- transc_in->xfer_buf = audio->audioctl;
+ case AD_REQ_GET_MIN:
+ *((uint16_t *)audio_handler.audioctl) = VOL_MIN;
+ transc_in->xfer_buf = audio_handler.audioctl;
transc_in->remain_len = req->wLength;
status = REQ_SUPP;
break;
- case AUDIO_REQ_GET_MAX:
- *((uint16_t *)audio->audioctl) = VOL_MAX;
- transc_in->xfer_buf = audio->audioctl;
+ case AD_REQ_GET_MAX:
+ *((uint16_t *)audio_handler.audioctl) = VOL_MAX;
+ transc_in->xfer_buf = audio_handler.audioctl;
transc_in->remain_len = req->wLength;
status = REQ_SUPP;
break;
- case AUDIO_REQ_GET_RES:
- *((uint16_t *)audio->audioctl) = VOL_RES;
- transc_in->xfer_buf = audio->audioctl;
+ case AD_REQ_GET_RES:
+ *((uint16_t *)audio_handler.audioctl) = VOL_RES;
+ transc_in->xfer_buf = audio_handler.audioctl;
transc_in->remain_len = req->wLength;
status = REQ_SUPP;
break;
@@ -646,6 +688,78 @@ static uint8_t audio_req_handler (usb_dev *udev, usb_req *req)
}
/*!
+ \brief handle the AUDIO set interface requests
+ \param[in] udev: pointer to USB device instance
+ \param[in] req: device class-specific request
+ \param[out] none
+ \retval USB device operation status
+*/
+static uint8_t audio_set_intf(usb_dev *udev, usb_req *req)
+{
+ udev->dev.class_core->alter_set = req->wValue;
+
+ if(0xFF != req->wValue){
+ if (req->wValue != 0){
+ /* deinit audio handler */
+ memset((void *)&audio_handler, 0, sizeof(usbd_audio_handler));
+
+ audio_handler.play_flag = 0;
+ audio_handler.isoc_out_rdptr = audio_handler.isoc_out_buff;
+ audio_handler.isoc_out_wrptr = audio_handler.isoc_out_buff;
+
+ /* feedback calculate sample freq */
+ audio_handler.actual_freq = I2S_ACTUAL_SAM_FREQ(USBD_SPEAKER_FREQ);
+ get_feedback_fs_rate(audio_handler.actual_freq, audio_handler.feedback_freq);
+
+ /* send feedback data of estimated frequence*/
+ usbd_ep_send(udev, AD_FEEDBACK_IN_EP, audio_handler.feedback_freq, FEEDBACK_IN_PACKET);
+ } else {
+ /* stop audio output */
+ audio_out_fops.audio_cmd(audio_handler.isoc_out_rdptr, SPEAKER_OUT_PACKET/2, AD_CMD_STOP);
+
+ audio_handler.play_flag = 0;
+ audio_handler.isoc_out_rdptr = audio_handler.isoc_out_buff;
+ audio_handler.isoc_out_wrptr = audio_handler.isoc_out_buff;
+
+ usbd_fifo_flush (udev, AD_IN_EP);
+ usbd_fifo_flush (udev, AD_FEEDBACK_IN_EP);
+ usbd_fifo_flush (udev, AD_OUT_EP);
+ }
+ }
+
+ return 0;
+}
+
+/*!
+ \brief handles the control transfer OUT callback
+ \param[in] udev: pointer to USB device instance
+ \param[out] none
+ \retval USB device operation status
+*/
+static uint8_t audio_ctlx_out (usb_dev *udev)
+{
+#ifdef USE_USB_AD_SPEAKER
+ /* handles audio control requests data */
+ /* check if an audio_control request has been issued */
+ if (AD_REQ_SET_CUR == udev->dev.class_core->command) {
+ /* in this driver, to simplify code, only SET_CUR request is managed */
+
+ /* check for which addressed unit the audio_control request has been issued */
+ if (AD_OUT_STREAMING_CTRL == audio_handler.audioctl_unit) {
+ /* in this driver, to simplify code, only one unit is manage */
+
+ /* reset the audioctl_cmd variable to prevent re-entering this function */
+ udev->dev.class_core->command = 0U;
+
+ audio_handler.audioctl_len = 0U;
+ }
+ }
+#endif /* USE_USB_AD_SPEAKER */
+
+ return USBD_OK;
+}
+
+/*!
\brief handles the audio IN data stage
\param[in] udev: pointer to USB device instance
\param[in] ep_num: endpoint number
@@ -654,16 +768,28 @@ static uint8_t audio_req_handler (usb_dev *udev, usb_req *req)
*/
static uint8_t audio_data_in (usb_dev *udev, uint8_t ep_num)
{
-#ifdef USE_USB_AUDIO_MICPHONE
+#ifdef USE_USB_AD_MICPHONE
+ if(ep_num == EP_ID(AD_IN_EP)){
if(count_data < LENGTH_DATA){
/* Prepare next buffer to be sent: dummy data */
- usbd_ep_send(udev, AUDIO_IN_EP,(uint8_t*)&wavetestdata[count_data],MIC_IN_PACKET);
+ usbd_ep_send(udev, AD_IN_EP,(uint8_t*)&wavetestdata[count_data],MIC_IN_PACKET);
count_data += MIC_IN_PACKET;
} else {
- usbd_ep_send(udev, AUDIO_IN_EP,(uint8_t*)wavetestdata,MIC_IN_PACKET);
+ usbd_ep_send(udev, AD_IN_EP,(uint8_t*)wavetestdata,MIC_IN_PACKET);
count_data = MIC_IN_PACKET;
}
-#endif
+ }
+#endif /* USE_USB_AD_MICPHONE */
+
+#ifdef USE_USB_AD_SPEAKER
+ if(ep_num == EP_ID(AD_FEEDBACK_IN_EP)){
+ /* calculate feedback actual freq */
+ audio_handler.actual_freq = usbd_audio_spk_get_feedback(udev);
+ get_feedback_fs_rate(audio_handler.actual_freq, audio_handler.feedback_freq);
+
+ usbd_ep_send(udev, AD_FEEDBACK_IN_EP, audio_handler.feedback_freq, FEEDBACK_IN_PACKET);
+ }
+#endif /* USE_USB_AD_SPEAKER */
return USBD_OK;
}
@@ -677,52 +803,73 @@ static uint8_t audio_data_in (usb_dev *udev, uint8_t ep_num)
*/
static uint8_t audio_data_out (usb_dev *udev, uint8_t ep_num)
{
-#ifdef USE_USB_AUDIO_SPEAKER
- usbd_audio_handler *audio = (usbd_audio_handler *)udev->dev.class_data[USBD_AUDIO_INTERFACE];
+ uint16_t usb_rx_length, tail_len;
- if (AUDIO_OUT_EP == ep_num) {
- /* increment the Buffer pointer or roll it back when all buffers are full */
- if (audio->isoc_out_wrptr >= (audio->isoc_out_buff + (SPEAKER_OUT_PACKET * OUT_PACKET_NUM))) {
- /* all buffers are full: roll back */
- audio->isoc_out_wrptr = audio->isoc_out_buff;
- } else {
- /* increment the buffer pointer */
- audio->isoc_out_wrptr += SPEAKER_OUT_PACKET;
- }
+ /* get receive length */
+ usb_rx_length = ((usb_core_driver *)udev)->dev.transc_out[ep_num].xfer_count;
- /* Toggle the frame index */
- udev->dev.transc_out[ep_num].frame_num =
- (udev->dev.transc_out[ep_num].frame_num)? 0U:1U;
+ if(audio_handler.isoc_out_wrptr >= audio_handler.isoc_out_rdptr){
+ audio_handler.buf_free_size = TOTAL_OUT_BUF_SIZE + audio_handler.isoc_out_rdptr - audio_handler.isoc_out_wrptr;
+ }else{
+ audio_handler.buf_free_size = audio_handler.isoc_out_rdptr - audio_handler.isoc_out_wrptr;
+ }
+
+ /* free buffer enough to save rx data */
+ if(audio_handler.buf_free_size > usb_rx_length){
+ if(audio_handler.isoc_out_wrptr >= audio_handler.isoc_out_rdptr){
+ tail_len = audio_handler.isoc_out_buff + TOTAL_OUT_BUF_SIZE - audio_handler.isoc_out_wrptr;
+
+ if(tail_len >= usb_rx_length){
+ memcpy(audio_handler.isoc_out_wrptr, audio_handler.usb_rx_buffer, usb_rx_length);
+
+ /* increment the buffer pointer */
+ audio_handler.isoc_out_wrptr += usb_rx_length;
- /* prepare out endpoint to receive next audio packet */
- usbd_ep_recev (udev, AUDIO_OUT_EP, (uint8_t*)(audio->isoc_out_wrptr), SPEAKER_OUT_PACKET);
+ /* increment the Buffer pointer or roll it back when all buffers are full */
+ if(audio_handler.isoc_out_wrptr >= (audio_handler.isoc_out_buff + TOTAL_OUT_BUF_SIZE)){
+ /* all buffers are full: roll back */
+ audio_handler.isoc_out_wrptr = audio_handler.isoc_out_buff;
+ }
+ }else{
+ memcpy(audio_handler.isoc_out_wrptr, audio_handler.usb_rx_buffer, tail_len);
+ /* adjust write pointer */
+ audio_handler.isoc_out_wrptr = audio_handler.isoc_out_buff;
- /* trigger the start of streaming only when half buffer is full */
- if ((0U == audio->play_flag) && (audio->isoc_out_wrptr >= (audio->isoc_out_buff + ((SPEAKER_OUT_PACKET * OUT_PACKET_NUM) / 2U)))) {
- /* enable start of streaming */
- audio->play_flag = 1U;
+ memcpy(audio_handler.isoc_out_wrptr, &audio_handler.usb_rx_buffer[tail_len], usb_rx_length - tail_len);
+ /* adjust write pointer */
+ audio_handler.isoc_out_wrptr += usb_rx_length - tail_len;
+ }
+ }else{
+ memcpy(audio_handler.isoc_out_wrptr, audio_handler.usb_rx_buffer, usb_rx_length);
+
+ /* increment the buffer pointer */
+ audio_handler.isoc_out_wrptr += usb_rx_length;
}
- } else {
- /* handles audio control requests data */
- /* check if an audio_control request has been issued */
- if (AUDIO_REQ_SET_CUR == udev->dev.class_core->command) {
- /* in this driver, to simplify code, only SET_CUR request is managed */
+ }
+
+ /* Toggle the frame index */
+ udev->dev.transc_out[ep_num].frame_num = (udev->dev.transc_out[ep_num].frame_num)? 0U:1U;
- /* check for which addressed unit the audio_control request has been issued */
- if (AUDIO_OUT_STREAMING_CTRL == audio->audioctl_unit) {
- /* in this driver, to simplify code, only one unit is manage */
+ /* prepare out endpoint to receive next audio packet */
+ usbd_ep_recev (udev, AD_OUT_EP, audio_handler.usb_rx_buffer, SPEAKER_OUT_MAX_PACKET);
- /* call the audio interface mute function */
- audio_out_fops.audio_mute_ctl(audio->audioctl[0]);
+ if(audio_handler.isoc_out_wrptr >= audio_handler.isoc_out_rdptr){
+ audio_handler.buf_free_size = TOTAL_OUT_BUF_SIZE + audio_handler.isoc_out_rdptr - audio_handler.isoc_out_wrptr;
+ }else{
+ audio_handler.buf_free_size = audio_handler.isoc_out_rdptr - audio_handler.isoc_out_wrptr;
+ }
- /* reset the audioctl_cmd variable to prevent re-entering this function */
- udev->dev.class_core->command = 0U;
+ if ((0U == audio_handler.play_flag) && (audio_handler.buf_free_size < TOTAL_OUT_BUF_SIZE/2)) {
+ /* enable start of streaming */
+ audio_handler.play_flag = 1U;
- audio->audioctl_len = 0U;
- }
+ /* initialize the audio output hardware layer */
+ if (USBD_OK != audio_out_fops.audio_cmd(audio_handler.isoc_out_rdptr, SPEAKER_OUT_MAX_PACKET/2, AD_CMD_PLAY)) {
+ return USBD_FAIL;
}
+
+ audio_handler.dam_tx_len = SPEAKER_OUT_MAX_PACKET;
}
-#endif
return USBD_OK;
}
@@ -733,45 +880,82 @@ static uint8_t audio_data_out (usb_dev *udev, uint8_t ep_num)
\param[out] none
\retval USB device operation status
*/
-static uint8_t usbd_audio_sof (usb_dev *udev)
+static uint8_t audio_sof (usb_dev *udev)
{
-#ifdef USE_USB_AUDIO_SPEAKER
- usbd_audio_handler *audio = (usbd_audio_handler *)udev->dev.class_data[USBD_AUDIO_INTERFACE];
+ return USBD_OK;
+}
- /* check if there are available data in stream buffer.
- in this function, a single variable (play_flag) is used to avoid software delays.
- the play operation must be executed as soon as possible after the SOF detection. */
- if (audio->play_flag) {
- /* start playing received packet */
- audio_out_fops.audio_cmd((uint8_t*)(audio->isoc_out_rdptr), /* samples buffer pointer */
- SPEAKER_OUT_PACKET, /* number of samples in Bytes */
- AUDIO_CMD_PLAY); /* command to be processed */
+/*!
+ \brief handles the audio ISO IN Incomplete event
+ \param[in] udev: pointer to USB device instance
+ \param[out] none
+ \retval USB device operation status
+*/
+static uint8_t audio_iso_in_incomplete (usb_dev *udev)
+{
+ (void)usb_txfifo_flush (&udev->regs, EP_ID(AD_FEEDBACK_IN_EP));
- /* increment the Buffer pointer or roll it back when all buffers all full */
- if (audio->isoc_out_rdptr >= (audio->isoc_out_buff + (SPEAKER_OUT_PACKET * OUT_PACKET_NUM))) {
- /* roll back to the start of buffer */
- audio->isoc_out_rdptr = audio->isoc_out_buff;
- } else {
- /* increment to the next sub-buffer */
- audio->isoc_out_rdptr += SPEAKER_OUT_PACKET;
- }
+ audio_handler.actual_freq = usbd_audio_spk_get_feedback(udev);
+ get_feedback_fs_rate(audio_handler.actual_freq, audio_handler.feedback_freq);
- /* if all available buffers have been consumed, stop playing */
- if (audio->isoc_out_rdptr == audio->isoc_out_wrptr) {
- /* Pause the audio stream */
- audio_out_fops.audio_cmd((uint8_t*)(audio->isoc_out_buff), /* samples buffer pointer */
- SPEAKER_OUT_PACKET, /* number of samples in Bytes */
- AUDIO_CMD_PAUSE); /* command to be processed */
+ /* send feedback data of estimated frequence*/
+ usbd_ep_send(udev, AD_FEEDBACK_IN_EP, audio_handler.feedback_freq, FEEDBACK_IN_PACKET);
- /* stop entering play loop */
- audio->play_flag = 0U;
+ return USBD_OK;
+}
- /* reset buffer pointers */
- audio->isoc_out_rdptr = audio->isoc_out_buff;
- audio->isoc_out_wrptr = audio->isoc_out_buff;
- }
+/*!
+ \brief handles the audio ISO OUT Incomplete event
+ \param[in] udev: pointer to USB device instance
+ \param[out] none
+ \retval USB device operation status
+*/
+static uint8_t audio_iso_out_incomplete (usb_dev *udev)
+{
+ return USBD_OK;
+}
+
+/*!
+ \brief calculate feedback sample frequency
+ \param[in] udev: pointer to USB device instance
+ \param[out] none
+ \retval feedback frequency value
+*/
+static uint32_t usbd_audio_spk_get_feedback(usb_dev *udev)
+{
+ static uint32_t fb_freq;
+
+ /* calculate buffer free size */
+ if(audio_handler.isoc_out_wrptr >= audio_handler.isoc_out_rdptr){
+ audio_handler.buf_free_size = TOTAL_OUT_BUF_SIZE + audio_handler.isoc_out_rdptr - audio_handler.isoc_out_wrptr;
+ }else{
+ audio_handler.buf_free_size = audio_handler.isoc_out_rdptr - audio_handler.isoc_out_wrptr;
}
-#endif
- return USBD_OK;
+ /* calculate feedback frequency */
+ if(audio_handler.buf_free_size <= (TOTAL_OUT_BUF_SIZE/4)){
+ fb_freq = I2S_ACTUAL_SAM_FREQ(USBD_SPEAKER_FREQ) - FEEDBACK_FREQ_OFFSET;
+ }else if(audio_handler.buf_free_size >= (TOTAL_OUT_BUF_SIZE*3/4)){
+ fb_freq = I2S_ACTUAL_SAM_FREQ(USBD_SPEAKER_FREQ) + FEEDBACK_FREQ_OFFSET;
+ }else{
+ fb_freq = I2S_ACTUAL_SAM_FREQ(USBD_SPEAKER_FREQ);
+ }
+
+ return fb_freq;
+}
+
+/*!
+ \brief get feedback value from rate in USB full speed
+ \param[in] rate: sample frequence
+ \param[in] buf: pointer to result buffer
+ \param[out] none
+ \retval USB device operation status
+*/
+static void get_feedback_fs_rate(uint32_t rate, uint8_t *buf)
+{
+ rate = ((rate / 1000) << 14) | ((rate % 1000) << 4);
+
+ buf[0] = rate;
+ buf[1] = rate >> 8;
+ buf[2] = rate >> 16;
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Source/audio_out_itf.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Source/audio_out_itf.c
index fbe56d907b..cfbc580ca3 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Source/audio_out_itf.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/audio/Source/audio_out_itf.c
@@ -3,102 +3,99 @@
\brief audio OUT (playback) interface functions
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#include "audio_core.h"
#include "audio_out_itf.h"
-static uint8_t init (uint32_t audiofreq, uint32_t volume, uint32_t options);
-static uint8_t deinit (uint32_t options);
-static uint8_t audio_cmd (uint8_t* pbuf, uint32_t size, uint8_t cmd);
-static uint8_t volume_ctl (uint8_t vol);
-static uint8_t mute_ctl (uint8_t cmd);
-static uint8_t periodic_tc (uint8_t cmd);
-static uint8_t get_state (void);
+/* local function prototypes ('static') */
+static uint8_t init (uint32_t audio_freq, uint32_t volume);
+static uint8_t deinit (void);
+static uint8_t audio_cmd (uint8_t* pbuf, uint32_t size, uint8_t cmd);
-audio_fops_struct audio_out_fops =
+/* local variable defines */
+static uint8_t audio_state = AD_STATE_INACTIVE;
+
+audio_fops_struct audio_out_fops =
{
- init,
- deinit,
- audio_cmd,
- volume_ctl,
- mute_ctl,
- periodic_tc,
- get_state
+ .audio_init = init,
+ .audio_deinit = deinit,
+ .audio_cmd = audio_cmd,
};
-static uint8_t audio_state = AUDIO_STATE_INACTIVE;
-
/*!
- \brief initialize and configures all required resources for audio play function
+ \brief initialize and configures all required resources
\param[in] audio_freq: statrt_up audio frequency
\param[in] volume: start_up volume to be set
- \param[in] options: specific options passed to low layer function
\param[out] none
- \retval AUDIO_OK if all operations succeed, AUDIO_FAIL else
+ \retval AD_OK if all operations succeed, otherwise, AD_FAIL.
*/
-static uint8_t init (uint32_t audio_freq, uint32_t volume, uint32_t options)
+static uint8_t init (uint32_t audio_freq, uint32_t volume)
{
static uint32_t initialized = 0U;
/* check if the low layer has already been initialized */
if (0U == initialized) {
- /* call low layer function */
- if (0U != eval_audio_init(OUTPUT_DEVICE_AUTO, (uint8_t)volume, audio_freq)) {
- audio_state = AUDIO_STATE_ERROR;
+ /* initialize GPIO */
+ codec_gpio_init();
- return AUDIO_FAIL;
- }
+ /* initialize i2s */
+ codec_audio_interface_init(audio_freq);
- /* set the initialization flag to prevent reinitializing the interface again */
+ /* initialize DMA */
+ codec_i2s_dma_init();
+
+ /* prevent reinitializing the interface again */
initialized = 1U;
}
/* update the audio state machine */
- audio_state = AUDIO_STATE_ACTIVE;
+ audio_state = AD_STATE_ACTIVE;
- return AUDIO_OK;
+ return AD_OK;
}
/*!
\brief free all resources used by low layer and stops audio-play function
- \param[in] options: specific options passed to low layer function
+ \param[in] none
\param[out] none
- \retval AUDIO_OK if all operations succeed, AUDIO_FAIL else
+ \retval AD_OK if all operations succeed, otherwise, AD_FAIL.
*/
-static uint8_t deinit (uint32_t options)
+static uint8_t deinit (void)
{
/* update the audio state machine */
- audio_state = AUDIO_STATE_INACTIVE;
+ audio_state = AD_STATE_INACTIVE;
- return AUDIO_OK;
+ return AD_OK;
}
/*!
@@ -106,123 +103,68 @@ static uint8_t deinit (uint32_t options)
\param[in] pbuf: address from which file should be played
\param[in] size: size of the current buffer/file
\param[in] cmd: command to be executed, can be:
- \arg AUDIO_CMD_PLAY
- \arg AUDIO_CMD_PAUSE
- \arg AUDIO_CMD_RESUME
- \arg AUDIO_CMD_STOP
+ \arg AD_CMD_PLAY
+ \arg AD_CMD_PAUSE
+ \arg AD_CMD_RESUME
+ \arg AD_CMD_STOP
\param[out] none
- \retval AUDIO_OK if all operations succeed, AUDIO_FAIL else
+ \retval AD_OK if all operations succeed, otherwise, AD_FAIL.
*/
static uint8_t audio_cmd (uint8_t* pbuf, uint32_t size, uint8_t cmd)
{
/* check the current state */
- if ((AUDIO_STATE_INACTIVE == audio_state) || (AUDIO_STATE_ERROR == audio_state)) {
- audio_state = AUDIO_STATE_ERROR;
+ if ((AD_STATE_INACTIVE == audio_state) || (AD_STATE_ERROR == audio_state)) {
+ audio_state = AD_STATE_ERROR;
- return AUDIO_FAIL;
+ return AD_FAIL;
}
switch (cmd) {
/* process the play command */
- case AUDIO_CMD_PLAY:
+ case AD_CMD_PLAY:
/* if current state is active or stopped */
- if ((AUDIO_STATE_ACTIVE == audio_state) || \
- (AUDIO_STATE_STOPPED == audio_state) || \
- (AUDIO_STATE_PLAYING == audio_state)) {
- audio_mal_play((uint32_t)pbuf, size);
- audio_state = AUDIO_STATE_PLAYING;
+ if ((AD_STATE_ACTIVE == audio_state) || \
+ (AD_STATE_STOPPED == audio_state) || \
+ (AD_STATE_PLAYING == audio_state)) {
+ audio_play((uint32_t)pbuf, size);
+ audio_state = AD_STATE_PLAYING;
- return AUDIO_OK;
- } else if (AUDIO_STATE_PAUSED == audio_state) {
- if (eval_audio_pause_resume(AUDIO_RESUME, (uint32_t)pbuf, (size / 2U))) {
- audio_state = AUDIO_STATE_ERROR;
+ return AD_OK;
+ } else if (AD_STATE_PAUSED == audio_state) {
+ audio_pause_resume(AD_RESUME, (uint32_t)pbuf, (size/2));
+ audio_state = AD_STATE_PLAYING;
- return AUDIO_FAIL;
- } else {
- audio_state = AUDIO_STATE_PLAYING;
-
- return AUDIO_OK;
- }
+ return AD_OK;
} else {
- return AUDIO_FAIL;
+ return AD_FAIL;
}
/* process the stop command */
- case AUDIO_CMD_STOP:
- if (AUDIO_STATE_PLAYING != audio_state) {
+ case AD_CMD_STOP:
+ if (AD_STATE_PLAYING != audio_state) {
/* unsupported command */
- return AUDIO_FAIL;
- } else if (eval_audio_stop(CODEC_PDWN_SW)) {
- audio_state = AUDIO_STATE_ERROR;
-
- return AUDIO_FAIL;
+ return AD_FAIL;
} else {
- audio_state = AUDIO_STATE_STOPPED;
+ audio_stop();
+ audio_state = AD_STATE_STOPPED;
- return AUDIO_OK;
+ return AD_OK;
}
/* process the pause command */
- case AUDIO_CMD_PAUSE:
- if (AUDIO_STATE_PLAYING != audio_state) {
+ case AD_CMD_PAUSE:
+ if (AD_STATE_PLAYING != audio_state) {
/* unsupported command */
- return AUDIO_FAIL;
- } else if (eval_audio_pause_resume(AUDIO_PAUSE, (uint32_t)pbuf, (size / 2U))) {
- audio_state = AUDIO_STATE_ERROR;
-
- return AUDIO_FAIL;
+ return AD_FAIL;
} else {
- audio_state = AUDIO_STATE_PAUSED;
+ audio_pause_resume(AD_PAUSE, (uint32_t)pbuf, (size/2));
+ audio_state = AD_STATE_PAUSED;
- return AUDIO_OK;
+ return AD_OK;
}
/* unsupported command */
default:
- return AUDIO_FAIL;
+ return AD_FAIL;
}
}
-
-/*!
- \brief set the volume level
- \param[in] vol: volume level to be set in % (from 0% to 100%)
- \param[out] none
- \retval AUDIO_OK if all operations succeed, AUDIO_FAIL else
-*/
-static uint8_t volume_ctl (uint8_t vol)
-{
- return AUDIO_OK;
-}
-
-/*!
- \brief mute or unmute the audio current output
- \param[in] cmd: can be 0 to unmute, or 1 to mute
- \param[out] none
- \retval AUDIO_OK if all operations succeed, AUDIO_FAIL else
-*/
-static uint8_t mute_ctl (uint8_t cmd)
-{
- return AUDIO_OK;
-}
-
-/*!
- \brief periodic transfer control
- \param[in] cmd: command
- \param[out] none
- \retval AUDIO_OK if all operations succeed, AUDIO_FAIL else
-*/
-static uint8_t periodic_tc (uint8_t cmd)
-{
- return AUDIO_OK;
-}
-
-/*!
- \brief return the current state of the audio machine
- \param[in] none
- \param[out] none
- \retval AUDIO_OK if all operations succeed, AUDIO_FAIL else
-*/
-static uint8_t get_state (void)
-{
- return audio_state;
-}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/cdc/Include/cdc_acm_core.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/cdc/Include/cdc_acm_core.h
index c1a2bc8f80..3c967f5f1d 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/cdc/Include/cdc_acm_core.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/cdc/Include/cdc_acm_core.h
@@ -3,32 +3,34 @@
\brief the header file of cdc acm driver
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -38,15 +40,15 @@ OF SUCH DAMAGE.
#include "usbd_enum.h"
#include "usb_cdc.h"
-#define USB_CDC_RX_LEN 64
+#define USB_CDC_RX_LEN USB_CDC_DATA_PACKET_SIZE
typedef struct {
- uint8_t data[USB_CDC_RX_LEN];
- uint8_t cmd[USB_CDC_CMD_PACKET_SIZE];
-
uint8_t packet_sent;
uint8_t packet_receive;
+ uint8_t data[USB_CDC_RX_LEN];
+ uint8_t cmd[USB_CDC_CMD_PACKET_SIZE];
+
uint32_t receive_length;
acm_line line_coding;
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/cdc/Source/cdc_acm_core.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/cdc/Source/cdc_acm_core.c
index a950c091c8..7049467550 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/cdc/Source/cdc_acm_core.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/cdc/Source/cdc_acm_core.c
@@ -3,32 +3,34 @@
\brief CDC ACM driver
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -41,9 +43,9 @@ OF SUCH DAMAGE.
/* USB standard device descriptor */
__ALIGN_BEGIN const usb_desc_dev cdc_dev_desc __ALIGN_END =
{
- .header =
+ .header =
{
- .bLength = USB_DEV_DESC_LEN,
+ .bLength = USB_DEV_DESC_LEN,
.bDescriptorType = USB_DESCTYPE_DEV,
},
.bcdUSB = 0x0200U,
@@ -61,15 +63,15 @@ __ALIGN_BEGIN const usb_desc_dev cdc_dev_desc __ALIGN_END =
};
/* USB device configuration descriptor */
-__ALIGN_BEGIN const usb_cdc_desc_config_set cdc_config_desc __ALIGN_END =
+__ALIGN_BEGIN const usb_cdc_desc_config_set cdc_config_desc __ALIGN_END =
{
- .config =
+ .config =
{
.header =
- {
- .bLength = sizeof(usb_desc_config),
- .bDescriptorType = USB_DESCTYPE_CONFIG,
- },
+ {
+ .bLength = sizeof(usb_desc_config),
+ .bDescriptorType = USB_DESCTYPE_CONFIG,
+ },
.wTotalLength = USB_CDC_ACM_CONFIG_DESC_SIZE,
.bNumInterfaces = 0x02U,
.bConfigurationValue = 0x01U,
@@ -78,13 +80,13 @@ __ALIGN_BEGIN const usb_cdc_desc_config_set cdc_config_desc __ALIGN_END =
.bMaxPower = 0x32U
},
- .cmd_itf =
+ .cmd_itf =
{
.header =
- {
- .bLength = sizeof(usb_desc_itf),
- .bDescriptorType = USB_DESCTYPE_ITF
- },
+ {
+ .bLength = sizeof(usb_desc_itf),
+ .bDescriptorType = USB_DESCTYPE_ITF
+ },
.bInterfaceNumber = 0x00U,
.bAlternateSetting = 0x00U,
.bNumEndpoints = 0x01U,
@@ -97,10 +99,10 @@ __ALIGN_BEGIN const usb_cdc_desc_config_set cdc_config_desc __ALIGN_END =
.cdc_header =
{
.header =
- {
+ {
.bLength = sizeof(usb_desc_header_func),
.bDescriptorType = USB_DESCTYPE_CS_INTERFACE
- },
+ },
.bDescriptorSubtype = 0x00U,
.bcdCDC = 0x0110U
},
@@ -108,10 +110,10 @@ __ALIGN_BEGIN const usb_cdc_desc_config_set cdc_config_desc __ALIGN_END =
.cdc_call_managment =
{
.header =
- {
+ {
.bLength = sizeof(usb_desc_call_managment_func),
.bDescriptorType = USB_DESCTYPE_CS_INTERFACE
- },
+ },
.bDescriptorSubtype = 0x01U,
.bmCapabilities = 0x00U,
.bDataInterface = 0x01U
@@ -120,10 +122,10 @@ __ALIGN_BEGIN const usb_cdc_desc_config_set cdc_config_desc __ALIGN_END =
.cdc_acm =
{
.header =
- {
+ {
.bLength = sizeof(usb_desc_acm_func),
.bDescriptorType = USB_DESCTYPE_CS_INTERFACE
- },
+ },
.bDescriptorSubtype = 0x02U,
.bmCapabilities = 0x02U,
},
@@ -131,10 +133,10 @@ __ALIGN_BEGIN const usb_cdc_desc_config_set cdc_config_desc __ALIGN_END =
.cdc_union =
{
.header =
- {
+ {
.bLength = sizeof(usb_desc_union_func),
.bDescriptorType = USB_DESCTYPE_CS_INTERFACE
- },
+ },
.bDescriptorSubtype = 0x06U,
.bMasterInterface = 0x00U,
.bSlaveInterface0 = 0x01U,
@@ -143,10 +145,10 @@ __ALIGN_BEGIN const usb_cdc_desc_config_set cdc_config_desc __ALIGN_END =
.cdc_cmd_endpoint =
{
.header =
- {
+ {
.bLength = sizeof(usb_desc_ep),
.bDescriptorType = USB_DESCTYPE_EP,
- },
+ },
.bEndpointAddress = CDC_CMD_EP,
.bmAttributes = USB_EP_ATTR_INT,
.wMaxPacketSize = USB_CDC_CMD_PACKET_SIZE,
@@ -156,10 +158,10 @@ __ALIGN_BEGIN const usb_cdc_desc_config_set cdc_config_desc __ALIGN_END =
.cdc_data_interface =
{
.header =
- {
+ {
.bLength = sizeof(usb_desc_itf),
.bDescriptorType = USB_DESCTYPE_ITF,
- },
+ },
.bInterfaceNumber = 0x01U,
.bAlternateSetting = 0x00U,
.bNumEndpoints = 0x02U,
@@ -172,10 +174,10 @@ __ALIGN_BEGIN const usb_cdc_desc_config_set cdc_config_desc __ALIGN_END =
.cdc_out_endpoint =
{
.header =
- {
- .bLength = sizeof(usb_desc_ep),
- .bDescriptorType = USB_DESCTYPE_EP,
- },
+ {
+ .bLength = sizeof(usb_desc_ep),
+ .bDescriptorType = USB_DESCTYPE_EP,
+ },
.bEndpointAddress = CDC_DATA_OUT_EP,
.bmAttributes = USB_EP_ATTR_BULK,
.wMaxPacketSize = USB_CDC_DATA_PACKET_SIZE,
@@ -185,10 +187,10 @@ __ALIGN_BEGIN const usb_cdc_desc_config_set cdc_config_desc __ALIGN_END =
.cdc_in_endpoint =
{
.header =
- {
- .bLength = sizeof(usb_desc_ep),
- .bDescriptorType = USB_DESCTYPE_EP
- },
+ {
+ .bLength = sizeof(usb_desc_ep),
+ .bDescriptorType = USB_DESCTYPE_EP
+ },
.bEndpointAddress = CDC_DATA_IN_EP,
.bmAttributes = USB_EP_ATTR_BULK,
.wMaxPacketSize = USB_CDC_DATA_PACKET_SIZE,
@@ -197,70 +199,71 @@ __ALIGN_BEGIN const usb_cdc_desc_config_set cdc_config_desc __ALIGN_END =
};
/* USB language ID Descriptor */
-static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
{
.header =
- {
- .bLength = sizeof(usb_desc_LANGID),
- .bDescriptorType = USB_DESCTYPE_STR,
- },
+ {
+ .bLength = sizeof(usb_desc_LANGID),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
.wLANGID = ENG_LANGID
};
/* USB manufacture string */
-static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
{
.header =
- {
- .bLength = USB_STRING_LEN(10),
- .bDescriptorType = USB_DESCTYPE_STR,
- },
+ {
+ .bLength = USB_STRING_LEN(10),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
.unicode_string = {'G', 'i', 'g', 'a', 'D', 'e', 'v', 'i', 'c', 'e'}
};
/* USB product string */
-static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
{
.header =
- {
- .bLength = USB_STRING_LEN(12),
- .bDescriptorType = USB_DESCTYPE_STR,
- },
+ {
+ .bLength = USB_STRING_LEN(12),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
.unicode_string = {'G', 'D', '3', '2', '-', 'C', 'D', 'C', '_', 'A', 'C', 'M'}
};
/* USBD serial string */
-static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
+static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
{
.header =
- {
- .bLength = USB_STRING_LEN(12),
- .bDescriptorType = USB_DESCTYPE_STR,
- }
+ {
+ .bLength = USB_STRING_LEN(12),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ }
};
/* USB string descriptor set */
-void *const usbd_cdc_strings[] =
+void *const usbd_cdc_strings[] =
{
- [STR_IDX_LANGID] = (uint8_t *)&usbd_language_id_desc,
- [STR_IDX_MFC] = (uint8_t *)&manufacturer_string,
- [STR_IDX_PRODUCT] = (uint8_t *)&product_string,
- [STR_IDX_SERIAL] = (uint8_t *)&serial_string
+ [STR_IDX_LANGID] = (uint8_t *) &usbd_language_id_desc,
+ [STR_IDX_MFC] = (uint8_t *) &manufacturer_string,
+ [STR_IDX_PRODUCT] = (uint8_t *) &product_string,
+ [STR_IDX_SERIAL] = (uint8_t *) &serial_string
};
-usb_desc cdc_desc =
+usb_desc cdc_desc =
{
- .dev_desc = (uint8_t *)&cdc_dev_desc,
- .config_desc = (uint8_t *)&cdc_config_desc,
+ .dev_desc = (uint8_t *) &cdc_dev_desc,
+ .config_desc = (uint8_t *) &cdc_config_desc,
.strings = usbd_cdc_strings
};
/* local function prototypes ('static') */
-static uint8_t cdc_acm_init (usb_dev *udev, uint8_t config_index);
-static uint8_t cdc_acm_deinit (usb_dev *udev, uint8_t config_index);
-static uint8_t cdc_acm_req (usb_dev *udev, usb_req *req);
-static uint8_t cdc_acm_in (usb_dev *udev, uint8_t ep_num);
-static uint8_t cdc_acm_out (usb_dev *udev, uint8_t ep_num);
+static uint8_t cdc_acm_init (usb_dev *udev, uint8_t config_index);
+static uint8_t cdc_acm_deinit (usb_dev *udev, uint8_t config_index);
+static uint8_t cdc_acm_req (usb_dev *udev, usb_req *req);
+static uint8_t cdc_acm_ctlx_out (usb_dev *udev);
+static uint8_t cdc_acm_in (usb_dev *udev, uint8_t ep_num);
+static uint8_t cdc_acm_out (usb_dev *udev, uint8_t ep_num);
/* USB CDC device class callbacks structure */
usb_class_core cdc_class =
@@ -270,9 +273,8 @@ usb_class_core cdc_class =
.init = cdc_acm_init,
.deinit = cdc_acm_deinit,
-
.req_proc = cdc_acm_req,
-
+ .ctlx_out = cdc_acm_ctlx_out,
.data_in = cdc_acm_in,
.data_out = cdc_acm_out
};
@@ -328,7 +330,7 @@ void cdc_acm_data_receive (usb_dev *udev)
cdc->packet_receive = 0U;
cdc->packet_sent = 0U;
- usbd_ep_recev(udev, CDC_DATA_OUT_EP, (uint8_t*)(cdc->data), USB_CDC_DATA_PACKET_SIZE);
+ usbd_ep_recev (udev, CDC_DATA_OUT_EP, (uint8_t*)(cdc->data), USB_CDC_DATA_PACKET_SIZE);
}
/*!
@@ -342,13 +344,13 @@ static uint8_t cdc_acm_init (usb_dev *udev, uint8_t config_index)
{
static __ALIGN_BEGIN usb_cdc_handler cdc_handler __ALIGN_END;
- /* initialize the data TX endpoint */
+ /* initialize the data Tx endpoint */
usbd_ep_setup (udev, &(cdc_config_desc.cdc_in_endpoint));
- /* initialize the data RX endpoint */
+ /* initialize the data Rx endpoint */
usbd_ep_setup (udev, &(cdc_config_desc.cdc_out_endpoint));
- /* initialize the command TX endpoint */
+ /* initialize the command Tx endpoint */
usbd_ep_setup (udev, &(cdc_config_desc.cdc_cmd_endpoint));
/* initialize CDC handler structure */
@@ -357,10 +359,10 @@ static uint8_t cdc_acm_init (usb_dev *udev, uint8_t config_index)
cdc_handler.receive_length = 0U;
cdc_handler.line_coding = (acm_line){
- .dwDTERate = 115200,
- .bCharFormat = 0,
- .bParityType = 0,
- .bDataBits = 0x08
+ .dwDTERate = 115200U,
+ .bCharFormat = 0U,
+ .bParityType = 0U,
+ .bDataBits = 0x08U
};
udev->dev.class_data[CDC_COM_INTERFACE] = (void *)&cdc_handler;
@@ -369,7 +371,7 @@ static uint8_t cdc_acm_init (usb_dev *udev, uint8_t config_index)
}
/*!
- \brief de-initialize the CDC ACM device
+ \brief deinitialize the CDC ACM device
\param[in] udev: pointer to USB device instance
\param[in] config_index: configuration index
\param[out] none
@@ -377,11 +379,11 @@ static uint8_t cdc_acm_init (usb_dev *udev, uint8_t config_index)
*/
static uint8_t cdc_acm_deinit (usb_dev *udev, uint8_t config_index)
{
- /* deinitialize the data TX/RX endpoint */
+ /* deinitialize the data Tx/Rx endpoint */
usbd_ep_clear (udev, CDC_DATA_IN_EP);
usbd_ep_clear (udev, CDC_DATA_OUT_EP);
- /* deinitialize the command TX endpoint */
+ /* deinitialize the command Tx endpoint */
usbd_ep_clear (udev, CDC_CMD_EP);
return USBD_OK;
@@ -398,7 +400,7 @@ static uint8_t cdc_acm_req (usb_dev *udev, usb_req *req)
{
usb_cdc_handler *cdc = (usb_cdc_handler *)udev->dev.class_data[CDC_COM_INTERFACE];
- usb_transc *transc = &udev->dev.transc_in[0];
+ usb_transc *transc = NULL;
switch (req->bRequest) {
case SEND_ENCAPSULATED_COMMAND:
@@ -422,6 +424,8 @@ static uint8_t cdc_acm_req (usb_dev *udev, usb_req *req)
break;
case SET_LINE_CODING:
+ transc = &udev->dev.transc_out[0];
+
/* set the value of the current command to be processed */
udev->dev.class_core->alter_set = req->bRequest;
@@ -431,6 +435,8 @@ static uint8_t cdc_acm_req (usb_dev *udev, usb_req *req)
break;
case GET_LINE_CODING:
+ transc = &udev->dev.transc_in[0];
+
cdc->cmd[0] = (uint8_t)(cdc->line_coding.dwDTERate);
cdc->cmd[1] = (uint8_t)(cdc->line_coding.dwDTERate >> 8);
cdc->cmd[2] = (uint8_t)(cdc->line_coding.dwDTERate >> 16);
@@ -459,7 +465,34 @@ static uint8_t cdc_acm_req (usb_dev *udev, usb_req *req)
}
/*!
- \brief handle CDC ACM data
+ \brief command data received on control endpoint
+ \param[in] udev: pointer to USB device instance
+ \param[out] none
+ \retval USB device operation status
+*/
+static uint8_t cdc_acm_ctlx_out (usb_dev *udev)
+{
+ usb_cdc_handler *cdc = (usb_cdc_handler *)udev->dev.class_data[CDC_COM_INTERFACE];
+
+ if (udev->dev.class_core->alter_set != NO_CMD) {
+ /* process the command data */
+ cdc->line_coding.dwDTERate = (uint32_t)((uint32_t)cdc->cmd[0] |
+ ((uint32_t)cdc->cmd[1] << 8U) |
+ ((uint32_t)cdc->cmd[2] << 16U) |
+ ((uint32_t)cdc->cmd[3] << 24U));
+
+ cdc->line_coding.bCharFormat = cdc->cmd[4];
+ cdc->line_coding.bParityType = cdc->cmd[5];
+ cdc->line_coding.bDataBits = cdc->cmd[6];
+
+ udev->dev.class_core->alter_set = NO_CMD;
+ }
+
+ return USBD_OK;
+}
+
+/*!
+ \brief handle CDC ACM data in
\param[in] udev: pointer to USB device instance
\param[in] ep_num: endpoint identifier
\param[out] none
@@ -481,7 +514,7 @@ static uint8_t cdc_acm_in (usb_dev *udev, uint8_t ep_num)
}
/*!
- \brief handle CDC ACM data
+ \brief handle CDC ACM data out
\param[in] udev: pointer to USB device instance
\param[in] ep_num: endpoint identifier
\param[out] none
@@ -491,25 +524,8 @@ static uint8_t cdc_acm_out (usb_dev *udev, uint8_t ep_num)
{
usb_cdc_handler *cdc = (usb_cdc_handler *)udev->dev.class_data[CDC_COM_INTERFACE];
- if (0U == ep_num) {
- if (udev->dev.class_core->alter_set != NO_CMD)
- {
- /* process the command data */
- cdc->line_coding.dwDTERate = (uint32_t)((uint32_t)cdc->cmd[0] |
- ((uint32_t)cdc->cmd[1] << 8U) |
- ((uint32_t)cdc->cmd[2] << 16U) |
- ((uint32_t)cdc->cmd[3] << 24U));
-
- cdc->line_coding.bCharFormat = cdc->cmd[4];
- cdc->line_coding.bParityType = cdc->cmd[5];
- cdc->line_coding.bDataBits = cdc->cmd[6];
-
- udev->dev.class_core->alter_set = NO_CMD;
- }
- } else {
- cdc->packet_receive = 1U;
- cdc->receive_length = ((usb_core_driver *)udev)->dev.transc_out[ep_num].xfer_count;
- }
+ cdc->packet_receive = 1U;
+ cdc->receive_length = ((usb_core_driver *)udev)->dev.transc_out[ep_num].xfer_count;
return USBD_OK;
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Include/dfu_core.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Include/dfu_core.h
index e62dd75cf2..9b9c3c090d 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Include/dfu_core.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Include/dfu_core.h
@@ -3,32 +3,34 @@
\brief the header file of USB DFU device class core functions
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -76,10 +78,6 @@ OF SUCH DAMAGE.
/* bit detach capable = bit 3 in bmAttributes field */
#define DFU_DETACH_MASK (uint8_t)(0x10U)
-#define USB_SERIAL_STR_LEN 0x06U
-
-#define USB_DFU_CONFIG_DESC_SIZE 27U
-
#define DFU_DESC_TYPE 0x21U
/* DFU device state defines */
@@ -136,9 +134,9 @@ typedef struct
{
usb_desc_header header; /*!< descriptor header, including type and size */
uint8_t bmAttributes; /*!< DFU attributes */
- uint16_t wDetachTimeOut; /*!< time, in milliseconds, that the device will wait after receipt of the DFU_DETACH request. If */
+ uint16_t wDetachTimeOut; /*!< time, in milliseconds, that the device will wait after receipt of the DFU_DETACH request. If */
uint16_t wTransferSize; /*!< maximum number of bytes that the device can accept per control-write transaction */
- uint16_t bcdDFUVersion; /*!< numeric expression identifying the version of the DFU Specification release. */
+ uint16_t bcdDFUVersion; /*!< numeric expression identifying the version of the DFU specification release. */
} usb_desc_dfu_func;
#pragma pack()
@@ -147,10 +145,13 @@ typedef struct
typedef struct
{
usb_desc_config config;
- usb_desc_itf dfu_itf;
+ usb_desc_itf dfu_itf0;
+ usb_desc_itf dfu_itf1;
+ usb_desc_itf dfu_itf2;
usb_desc_dfu_func dfu_func;
} usb_dfu_desc_config_set;
+/* USB DFU handler structure */
typedef struct
{
uint8_t bStatus;
@@ -173,4 +174,4 @@ typedef void (*app_func) (void);
extern usb_desc dfu_desc;
extern usb_class_core dfu_class;
-#endif /* DFU_CORE_H */
+#endif /* DFU_CORE_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Include/dfu_mem.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Include/dfu_mem.h
new file mode 100644
index 0000000000..3f74af9a5e
--- /dev/null
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Include/dfu_mem.h
@@ -0,0 +1,85 @@
+/*!
+ \file dfu_mem.h
+ \brief USB DFU device media access layer header file
+
+ \version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
+*/
+
+/*
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
+
+ Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+#ifndef __DFU_MEM_H
+#define __DFU_MEM_H
+
+#include "usb_conf.h"
+
+typedef struct _dfu_mem_prop
+{
+ const uint8_t* pstr_desc;
+
+ uint8_t (*mem_init) (void);
+ uint8_t (*mem_deinit) (void);
+ uint8_t (*mem_erase) (uint32_t addr);
+ uint8_t (*mem_write) (uint8_t *buf, uint32_t addr, uint32_t len);
+ uint8_t* (*mem_read) (uint8_t *buf, uint32_t addr, uint32_t len);
+ uint8_t (*mem_checkaddr) (uint32_t addr);
+
+ const uint32_t erase_timeout;
+ const uint32_t write_timeout;
+} dfu_mem_prop;
+
+typedef enum
+{
+ MEM_OK = 0,
+ MEM_FAIL
+} mem_status;
+
+#define _1ST_BYTE(x) (uint8_t)((x) & 0xFF) /*!< addressing cycle 1st byte */
+#define _2ND_BYTE(x) (uint8_t)(((x) & 0xFF00) >> 8) /*!< addressing cycle 2nd byte */
+#define _3RD_BYTE(x) (uint8_t)(((x) & 0xFF0000) >> 16) /*!< addressing cycle 3rd byte */
+
+#define POLLING_TIMEOUT_SET(x) buffer[0] = _1ST_BYTE(x);\
+ buffer[1] = _2ND_BYTE(x);\
+ buffer[2] = _3RD_BYTE(x);
+
+/* function declarations */
+/* initialize the memory media on the GD32 */
+uint8_t dfu_mem_init(void);
+/* deinitialize the memory media on the GD32 */
+uint8_t dfu_mem_deinit(void);
+/* erase a memory sector */
+uint8_t dfu_mem_erase(uint32_t addr);
+/* write data to sectors of memory */
+uint8_t dfu_mem_write(uint8_t *buf, uint32_t addr, uint32_t len);
+/* read data from sectors of memory */
+uint8_t* dfu_mem_read(uint8_t *buf, uint32_t addr, uint32_t len);
+/* get the status of a given memory and store in buffer */
+uint8_t dfu_mem_getstatus(uint32_t addr, uint8_t cmd, uint8_t *buffer);
+
+#endif /* __DFU_MEM_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Source/dfu_core.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Source/dfu_core.c
index 676a8cda78..8786e0e154 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Source/dfu_core.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Source/dfu_core.c
@@ -3,39 +3,40 @@
\brief USB DFU device class core functions
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#include "dfu_core.h"
+#include "dfu_mem.h"
#include "drv_usb_hw.h"
-#include "dfu_mal.h"
-#include "flash_if.h"
#include <string.h>
#define USBD_VID 0x28E9U
@@ -45,7 +46,12 @@ OF SUCH DAMAGE.
static uint8_t dfu_init(usb_dev *udev, uint8_t config_index);
static uint8_t dfu_deinit(usb_dev *udev, uint8_t config_index);
static uint8_t dfu_req_handler(usb_dev *udev, usb_req *req);
-static uint8_t dfu_data_in(usb_dev *udev, uint8_t ep_num);
+static uint8_t dfu_ctlx_in(usb_dev *udev);
+
+static void dfu_mode_leave(usb_dev *udev);
+static uint8_t dfu_getstatus_complete (usb_dev *udev);
+
+/* DFU requests management functions */
static void dfu_detach(usb_dev *udev, usb_req *req);
static void dfu_dnload(usb_dev *udev, usb_req *req);
static void dfu_upload(usb_dev *udev, usb_req *req);
@@ -53,10 +59,10 @@ static void dfu_getstatus(usb_dev *udev, usb_req *req);
static void dfu_clrstatus(usb_dev *udev, usb_req *req);
static void dfu_getstate(usb_dev *udev, usb_req *req);
static void dfu_abort(usb_dev *udev, usb_req *req);
-static void dfu_mode_leave(usb_dev *udev);
-static uint8_t dfu_getstatus_complete (usb_dev *udev);
-static void (*dfu_request_process[])(usb_dev *udev, usb_req *req) =
+static void string_to_unicode (uint8_t *str, uint16_t *pbuf);
+
+static void (*dfu_request_process[])(usb_dev *udev, usb_req *req) =
{
[DFU_DETACH] = dfu_detach,
[DFU_DNLOAD] = dfu_dnload,
@@ -71,9 +77,9 @@ static void (*dfu_request_process[])(usb_dev *udev, usb_req *req) =
/* USB standard device descriptor */
__ALIGN_BEGIN const usb_desc_dev dfu_dev_desc __ALIGN_END =
{
- .header =
+ .header =
{
- .bLength = USB_DEV_DESC_LEN,
+ .bLength = USB_DEV_DESC_LEN,
.bDescriptorType = USB_DESCTYPE_DEV
},
.bcdUSB = 0x0200U,
@@ -91,16 +97,16 @@ __ALIGN_BEGIN const usb_desc_dev dfu_dev_desc __ALIGN_END =
};
/* USB device configuration descriptor */
-__ALIGN_BEGIN const usb_dfu_desc_config_set dfu_config_desc __ALIGN_END =
+__ALIGN_BEGIN const usb_dfu_desc_config_set dfu_config_desc __ALIGN_END =
{
- .config =
+ .config =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_config),
- .bDescriptorType = USB_DESCTYPE_CONFIG
+ .bLength = sizeof(usb_desc_config),
+ .bDescriptorType = USB_DESCTYPE_CONFIG
},
- .wTotalLength = USB_DFU_CONFIG_DESC_SIZE,
+ .wTotalLength = sizeof(usb_dfu_desc_config_set),
.bNumInterfaces = 0x01U,
.bConfigurationValue = 0x01U,
.iConfiguration = 0x00U,
@@ -108,12 +114,12 @@ __ALIGN_BEGIN const usb_dfu_desc_config_set dfu_config_desc __ALIGN_END =
.bMaxPower = 0x32U
},
- .dfu_itf =
+ .dfu_itf0 =
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_itf),
- .bDescriptorType = USB_DESCTYPE_ITF
+ .bLength = sizeof(usb_desc_itf),
+ .bDescriptorType = USB_DESCTYPE_ITF
},
.bInterfaceNumber = 0x00U,
.bAlternateSetting = 0x00U,
@@ -121,95 +127,149 @@ __ALIGN_BEGIN const usb_dfu_desc_config_set dfu_config_desc __ALIGN_END =
.bInterfaceClass = USB_DFU_CLASS,
.bInterfaceSubClass = USB_DFU_SUBCLASS_UPGRADE,
.bInterfaceProtocol = USB_DFU_PROTOCL_DFU,
- .iInterface = 0x05U
+ .iInterface = STR_IDX_ALT_ITF0
+ },
+
+ .dfu_itf1 =
+ {
+ .header =
+ {
+ .bLength = sizeof(usb_desc_itf),
+ .bDescriptorType = USB_DESCTYPE_ITF
+ },
+ .bInterfaceNumber = 0x00U,
+ .bAlternateSetting = 0x01U,
+ .bNumEndpoints = 0x00U,
+ .bInterfaceClass = USB_DFU_CLASS,
+ .bInterfaceSubClass = USB_DFU_SUBCLASS_UPGRADE,
+ .bInterfaceProtocol = USB_DFU_PROTOCL_DFU,
+ .iInterface = STR_IDX_ALT_ITF1
+ },
+
+ .dfu_itf2 =
+ {
+ .header =
+ {
+ .bLength = sizeof(usb_desc_itf),
+ .bDescriptorType = USB_DESCTYPE_ITF
+ },
+ .bInterfaceNumber = 0x00U,
+ .bAlternateSetting = 0x02U,
+ .bNumEndpoints = 0x00U,
+ .bInterfaceClass = USB_DFU_CLASS,
+ .bInterfaceSubClass = USB_DFU_SUBCLASS_UPGRADE,
+ .bInterfaceProtocol = USB_DFU_PROTOCL_DFU,
+ .iInterface = STR_IDX_ALT_ITF2
},
- .dfu_func =
+ .dfu_func=
{
- .header =
+ .header =
{
- .bLength = sizeof(usb_desc_dfu_func),
- .bDescriptorType = DFU_DESC_TYPE
+ .bLength = sizeof(usb_desc_dfu_func),
+ .bDescriptorType = DFU_DESC_TYPE
},
.bmAttributes = USB_DFU_CAN_DOWNLOAD | USB_DFU_CAN_UPLOAD | USB_DFU_WILL_DETACH,
.wDetachTimeOut = 0x00FFU,
.wTransferSize = TRANSFER_SIZE,
- .bcdDFUVersion = 0x011AU,
+ .bcdDFUVersion = 0x0110U,
},
};
-/* USB language ID Descriptor */
-static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
+/* USB language ID descriptor */
+static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
{
- .header = {
- .bLength = sizeof(usb_desc_LANGID),
+ .header =
+ {
+ .bLength = sizeof(usb_desc_LANGID),
.bDescriptorType = USB_DESCTYPE_STR
- },
+ },
.wLANGID = ENG_LANGID
};
/* USB manufacture string */
-static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
{
- .header =
- {
- .bLength = USB_STRING_LEN(10U),
+ .header =
+ {
+ .bLength = USB_STRING_LEN(10U),
.bDescriptorType = USB_DESCTYPE_STR,
},
.unicode_string = {'G', 'i', 'g', 'a', 'D', 'e', 'v', 'i', 'c', 'e'}
};
/* USB product string */
-static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
{
- .header =
- {
- .bLength = USB_STRING_LEN(12U),
+ .header =
+ {
+ .bLength = USB_STRING_LEN(12U),
.bDescriptorType = USB_DESCTYPE_STR,
- },
+ },
.unicode_string = {'G', 'D', '3', '2', '-', 'U', 'S', 'B', '_', 'D', 'F', 'U'}
};
-/* USBD serial string */
-static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
+/* USB serial string */
+static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
{
- .header =
- {
- .bLength = USB_STRING_LEN(2U),
+ .header =
+ {
+ .bLength = USB_STRING_LEN(2U),
.bDescriptorType = USB_DESCTYPE_STR,
- }
+ }
};
/* USB configure string */
-static __ALIGN_BEGIN const usb_desc_str config_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str config_string __ALIGN_END =
{
- .header =
- {
- .bLength = USB_STRING_LEN(15U),
+ .header =
+ {
+ .bLength = USB_STRING_LEN(15U),
.bDescriptorType = USB_DESCTYPE_STR,
- },
+ },
.unicode_string = {'G', 'D', '3', '2', ' ', 'U', 'S', 'B', ' ', 'C', 'O', 'N', 'F', 'I', 'G'}
};
-static __ALIGN_BEGIN const usb_desc_str interface_string __ALIGN_END =
+/* alternate interface 0 string */
+static __ALIGN_BEGIN usb_desc_str interface_string0 __ALIGN_END =
{
- .header =
- {
- .bLength = USB_STRING_LEN(44U),
+ .header =
+ {
+ .bLength = USB_STRING_LEN(2U),
.bDescriptorType = USB_DESCTYPE_STR,
- },
- .unicode_string = {'@', 'I', 'n', 't', 'e', 'r', 'n', 'a', 'l', 'F', 'l', 'a', 's', 'h', ' ', '/', '0', 'x', '0', '8', '0', '0',
- '0', '0', '0', '0', '/', '1', '6', '*', '0', '0', '1', 'K', 'a', ',', '4', '8', '*', '0', '0', '1', 'K', 'g'}
+ },
};
-void *const usbd_dfu_strings[] =
+/* alternate interface 1 string */
+static __ALIGN_BEGIN usb_desc_str interface_string1 __ALIGN_END =
{
- [STR_IDX_LANGID] = (uint8_t *)&usbd_language_id_desc,
- [STR_IDX_MFC] = (uint8_t *)&manufacturer_string,
- [STR_IDX_PRODUCT] = (uint8_t *)&product_string,
- [STR_IDX_SERIAL] = (uint8_t *)&serial_string,
- [STR_IDX_CONFIG] = (uint8_t *)&config_string,
- [STR_IDX_ITF] = (uint8_t *)&interface_string
+ .header =
+ {
+ .bLength = USB_STRING_LEN(2U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
+};
+
+/* alternate interface 2 string */
+static __ALIGN_BEGIN usb_desc_str interface_string2 __ALIGN_END =
+{
+ .header =
+ {
+ .bLength = USB_STRING_LEN(2U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
+};
+
+void *const usbd_dfu_strings[] =
+{
+ [STR_IDX_LANGID] = (uint8_t *)&usbd_language_id_desc,
+ [STR_IDX_MFC] = (uint8_t *)&manufacturer_string,
+ [STR_IDX_PRODUCT] = (uint8_t *)&product_string,
+ [STR_IDX_SERIAL] = (uint8_t *)&serial_string,
+ [STR_IDX_CONFIG] = (uint8_t *)&config_string,
+ [STR_IDX_ALT_ITF0] = (uint8_t *)&interface_string0,
+ [STR_IDX_ALT_ITF1] = (uint8_t *)&interface_string1,
+ [STR_IDX_ALT_ITF2] = (uint8_t *)&interface_string2,
};
usb_desc dfu_desc = {
@@ -222,7 +282,7 @@ usb_class_core dfu_class = {
.init = dfu_init,
.deinit = dfu_deinit,
.req_proc = dfu_req_handler,
- .data_in = dfu_data_in
+ .ctlx_in = dfu_ctlx_in
};
/*!
@@ -237,22 +297,26 @@ static uint8_t dfu_init (usb_dev *udev, uint8_t config_index)
static __ALIGN_BEGIN usbd_dfu_handler dfu_handler __ALIGN_END;
/* unlock the internal flash */
- dfu_mal_init();
+ dfu_mem_init();
memset((void *)&dfu_handler, 0, sizeof(usbd_dfu_handler));
- dfu_handler.base_addr = APP_LOADED_ADDR;
dfu_handler.manifest_state = MANIFEST_COMPLETE;
dfu_handler.bState = STATE_DFU_IDLE;
dfu_handler.bStatus = STATUS_OK;
udev->dev.class_data[USBD_DFU_INTERFACE] = (void *)&dfu_handler;
+ /* create interface string */
+ string_to_unicode((uint8_t *)dfu_inter_flash_cb.pstr_desc, udev->dev.desc->strings[STR_IDX_ALT_ITF0]);
+ string_to_unicode((uint8_t *)dfu_nor_flash_cb.pstr_desc, udev->dev.desc->strings[STR_IDX_ALT_ITF1]);
+ string_to_unicode((uint8_t *)dfu_nand_flash_cb.pstr_desc, udev->dev.desc->strings[STR_IDX_ALT_ITF2]);
+
return USBD_OK;
}
/*!
- \brief de-initialize the DFU device
+ \brief deinitialize the DFU device
\param[in] udev: pointer to USB device instance
\param[in] config_index: configuration index
\param[out] none
@@ -268,8 +332,8 @@ static uint8_t dfu_deinit (usb_dev *udev, uint8_t config_index)
dfu->bState = STATE_DFU_IDLE;
dfu->bStatus = STATUS_OK;
- /* lock the internal flash */
- dfu_mal_deinit();
+ /* deinit the memory */
+ dfu_mem_deinit();
return USBD_OK;
}
@@ -293,17 +357,14 @@ static uint8_t dfu_req_handler (usb_dev *udev, usb_req *req)
}
/*!
- \brief handle data Stage
+ \brief handle data stage
\param[in] udev: pointer to USB device instance
- \param[in] ep_num: the endpoint number
\param[out] none
\retval USB device operation status
*/
-static uint8_t dfu_data_in (usb_dev *udev, uint8_t ep_num)
+static uint8_t dfu_ctlx_in (usb_dev *udev)
{
- if (0U == ep_num) {
- dfu_getstatus_complete(udev);
- }
+ dfu_getstatus_complete(udev);
return USBD_OK;
}
@@ -325,8 +386,8 @@ static void dfu_mode_leave (usb_dev *udev)
} else {
dfu->bState = STATE_DFU_MANIFEST_WAIT_RESET;
- /* lock the internal flash */
- dfu_mal_deinit();
+ /* deinit the memory */
+ dfu_mem_deinit();
/* generate system reset to allow jumping to the user code */
NVIC_SystemReset();
@@ -359,7 +420,7 @@ static uint8_t dfu_getstatus_complete (usb_dev *udev)
} else if (ERASE == dfu->buf[0]) {
dfu->base_addr = *(uint32_t *)(dfu->buf + 1U);
- dfu_mal_erase(dfu->base_addr);
+ dfu_mem_erase(dfu->base_addr);
} else {
/* no operation */
}
@@ -370,7 +431,7 @@ static uint8_t dfu_getstatus_complete (usb_dev *udev)
/* decode the required address */
addr = (dfu->block_num - 2U) * TRANSFER_SIZE + dfu->base_addr;
- dfu_mal_write (dfu->buf, addr, dfu->data_len);
+ dfu_mem_write (dfu->buf, addr, dfu->data_len);
dfu->block_num = 0U;
} else {
@@ -417,7 +478,7 @@ static void dfu_detach(usb_dev *udev, usb_req *req)
dfu->block_num = 0U;
dfu->data_len = 0U;
break;
-
+
default:
break;
}
@@ -515,7 +576,7 @@ static void dfu_upload (usb_dev *udev, usb_req *req)
addr = (dfu->block_num - 2U) * TRANSFER_SIZE + dfu->base_addr;
/* return the physical address where data are stored */
- phy_addr = dfu_mal_read (dfu->buf, addr, dfu->data_len);
+ phy_addr = dfu_mem_read (dfu->buf, addr, dfu->data_len);
/* send the status data over EP0 */
transc->xfer_buf = phy_addr;
@@ -539,11 +600,10 @@ static void dfu_upload (usb_dev *udev, usb_req *req)
\param[out] none
\retval none
*/
-static void dfu_getstatus (usb_dev *udev, usb_req *req)
+static void dfu_getstatus (usb_dev *udev, usb_req *req)
{
- usbd_dfu_handler *dfu = (usbd_dfu_handler *)udev->dev.class_data[USBD_DFU_INTERFACE];
-
usb_transc *transc = &udev->dev.transc_in[0];
+ usbd_dfu_handler *dfu = (usbd_dfu_handler *)udev->dev.class_data[USBD_DFU_INTERFACE];
switch (dfu->bState) {
case STATE_DFU_DNLOAD_SYNC:
@@ -552,9 +612,9 @@ static void dfu_getstatus (usb_dev *udev, usb_req *req)
if (0U == dfu->block_num) {
if (ERASE == dfu->buf[0]) {
- dfu_mal_getstatus (dfu->base_addr, CMD_ERASE, (uint8_t *)&dfu->bwPollTimeout0);
+ dfu_mem_getstatus (dfu->base_addr, CMD_ERASE, (uint8_t *)&dfu->bwPollTimeout0);
} else {
- dfu_mal_getstatus (dfu->base_addr, CMD_WRITE, (uint8_t *)&dfu->bwPollTimeout0);
+ dfu_mem_getstatus (dfu->base_addr, CMD_WRITE, (uint8_t *)&dfu->bwPollTimeout0);
}
}
} else {
@@ -586,7 +646,8 @@ static void dfu_getstatus (usb_dev *udev, usb_req *req)
/*!
\brief handle the DFU_CLRSTATUS request
- \param udev: pointer to USB device instance
+ \param[in] udev: pointer to USB device instance
+ \param[in] req: DFU class request
\param[out] none
\retval none
*/
@@ -609,14 +670,14 @@ static void dfu_clrstatus (usb_dev *udev, usb_req *req)
/*!
\brief handle the DFU_GETSTATE request
\param[in] udev: pointer to USB device instance
+ \param[in] req: DFU class request
\param[out] none
\retval none
*/
static void dfu_getstate (usb_dev *udev, usb_req *req)
{
- usbd_dfu_handler *dfu = (usbd_dfu_handler *)udev->dev.class_data[USBD_DFU_INTERFACE];
-
usb_transc *transc = &udev->dev.transc_in[0];
+ usbd_dfu_handler *dfu = (usbd_dfu_handler *)udev->dev.class_data[USBD_DFU_INTERFACE];
/* send the current state of the DFU interface to host */
transc->xfer_buf = &(dfu->bState);
@@ -626,6 +687,7 @@ static void dfu_getstate (usb_dev *udev, usb_req *req)
/*!
\brief handle the DFU_ABORT request
\param[in] udev: pointer to USB device instance
+ \param[in] req: DFU class request
\param[out] none
\retval none
*/
@@ -651,3 +713,23 @@ static void dfu_abort (usb_dev *udev, usb_req *req)
break;
}
}
+
+/*!
+ \brief convert string value into unicode char
+ \param[in] str: pointer to plain string
+ \param[in] pbuf: buffer pointer to store unicode char
+ \param[out] none
+ \retval none
+*/
+static void string_to_unicode (uint8_t *str, uint16_t *pbuf)
+{
+ uint8_t index = 0;
+
+ if (str != NULL) {
+ pbuf[index++] = ((strlen((const char *)str) * 2U + 2U) & 0x00FFU) | ((USB_DESCTYPE_STR << 8U) & 0xFF00);
+
+ while (*str != '\0') {
+ pbuf[index++] = *str++;
+ }
+ }
+}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Source/dfu_mem.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Source/dfu_mem.c
new file mode 100644
index 0000000000..b5c1a040ce
--- /dev/null
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/dfu/Source/dfu_mem.c
@@ -0,0 +1,245 @@
+/*!
+ \file dfu_mem.c
+ \brief USB DFU device media access layer functions
+
+ \version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
+*/
+
+/*
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
+
+ Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+#include "dfu_mem.h"
+#include "drv_usb_hw.h"
+#include "usbd_transc.h"
+
+extern usb_core_driver usb_dfu_dev;
+
+extern struct {
+ uint8_t buf[TRANSFER_SIZE];
+ uint16_t data_len;
+ uint16_t block_num;
+ uint32_t base_addr;
+} prog;
+
+dfu_mem_prop* mem_tab[MAX_USED_MEMORY_MEDIA] = {
+ &dfu_inter_flash_cb,
+ &dfu_nor_flash_cb,
+ &dfu_nand_flash_cb,
+};
+
+/* The list of memory interface string descriptor pointers. This list
+ can be updated whenever a memory has to be added or removed */
+const uint8_t* USBD_DFU_StringDesc[MAX_USED_MEMORY_MEDIA] =
+{
+ (const uint8_t *)INTER_FLASH_IF_STR,
+ (const uint8_t *)NOR_FLASH_IF_STR,
+ (const uint8_t *)NAND_FLASH_IF_STR
+};
+
+static uint8_t dfu_mem_checkaddr (uint32_t addr);
+
+/*!
+ \brief initialize the memory media on the GD32
+ \param[in] none
+ \param[out] none
+ \retval MEM_OK
+*/
+uint8_t dfu_mem_init (void)
+{
+ uint32_t mem_index = 0U;
+
+ /* initialize all supported memory medias */
+ for (mem_index = 0U; mem_index < MAX_USED_MEMORY_MEDIA; mem_index++) {
+ /* check if the memory media exists */
+ if (NULL != mem_tab[mem_index]->mem_init) {
+ mem_tab[mem_index]->mem_init();
+ }
+ }
+
+ return MEM_OK;
+}
+
+/*!
+ \brief deinitialize the memory media on the GD32
+ \param[in] none
+ \param[out] none
+ \retval MEM_OK
+*/
+uint8_t dfu_mem_deinit (void)
+{
+ uint32_t mem_index = 0U;
+
+ /* deinitialize all supported memory medias */
+ for (mem_index = 0U; mem_index < MAX_USED_MEMORY_MEDIA; mem_index++) {
+ /* check if the memory media exists */
+ if (NULL != mem_tab[mem_index]->mem_deinit) {
+ mem_tab[mem_index]->mem_deinit();
+ }
+ }
+
+ return MEM_OK;
+}
+
+/*!
+ \brief erase a memory sector
+ \param[in] addr: memory sector address/code
+ \param[out] none
+ \retval MEM_OK
+*/
+uint8_t dfu_mem_erase (uint32_t addr)
+{
+ uint32_t mem_index = dfu_mem_checkaddr(addr);
+
+ /* check if the address is in protected area */
+ if (IS_PROTECTED_AREA(addr)) {
+ return MEM_FAIL;
+ }
+
+ if (mem_index < MAX_USED_MEMORY_MEDIA) {
+ /* check if the operation is supported */
+ if (NULL != mem_tab[mem_index]->mem_erase) {
+ return mem_tab[mem_index]->mem_erase(addr);
+ } else {
+ return MEM_FAIL;
+ }
+ } else {
+ return MEM_FAIL;
+ }
+}
+
+/*!
+ \brief write data to sectors of memory
+ \param[in] buf: the data buffer to be write
+ \param[in] addr: memory sector address/code
+ \param[in] len: data length
+ \param[out] none
+ \retval MEM_OK
+*/
+uint8_t dfu_mem_write (uint8_t *buf, uint32_t addr, uint32_t len)
+{
+ uint32_t mem_index = dfu_mem_checkaddr(addr);
+
+ /* check if the address is in protected area */
+ if (IS_PROTECTED_AREA(addr)) {
+ return MEM_FAIL;
+ }
+
+ if ((addr & MAL_MASK_OB) == OB_RDPT0) {
+ option_byte_write(addr, buf);
+ NVIC_SystemReset();
+
+ return MEM_OK;
+ }
+
+ if (mem_index < MAX_USED_MEMORY_MEDIA) {
+ /* check if the operation is supported */
+ if (NULL != mem_tab[mem_index]->mem_write) {
+ return mem_tab[mem_index]->mem_write(buf, addr, len);
+ } else {
+ return MEM_FAIL;
+ }
+ } else {
+ return MEM_FAIL;
+ }
+}
+
+/*!
+ \brief read data from sectors of memory
+ \param[in] buf: the data buffer to be write
+ \param[in] addr: memory sector address/code
+ \param[in] len: data length
+ \param[out] none
+ \retval pointer to buffer
+*/
+uint8_t* dfu_mem_read (uint8_t *buf, uint32_t addr, uint32_t len)
+{
+ uint32_t mem_index = 0U;
+
+ if ((OB_RDPT0 != addr) && (OB_RDPT1 != addr)) {
+ mem_index = dfu_mem_checkaddr(addr);
+ }
+
+ if (mem_index < MAX_USED_MEMORY_MEDIA) {
+ /* check if the operation is supported */
+ if (NULL != mem_tab[mem_index]->mem_read) {
+ return mem_tab[mem_index]->mem_read(buf, addr, len);
+ } else {
+ return buf;
+ }
+ } else {
+ return buf;
+ }
+}
+
+/*!
+ \brief get the status of a given memory and store in buffer
+ \param[in] addr: memory sector address/code
+ \param[in] cmd: 0 for erase and 1 for write
+ \param[in] buffer: pointer to the buffer where the status data will be stored
+ \param[out] none
+ \retval MEM_OK if all operations are OK, MEM_FAIL else
+*/
+uint8_t dfu_mem_getstatus (uint32_t addr, uint8_t cmd, uint8_t *buffer)
+{
+ uint32_t mem_index = dfu_mem_checkaddr(addr);
+
+ if (mem_index < MAX_USED_MEMORY_MEDIA) {
+ if (cmd & 0x01U) {
+ POLLING_TIMEOUT_SET(mem_tab[mem_index]->write_timeout);
+ } else {
+ POLLING_TIMEOUT_SET(mem_tab[mem_index]->erase_timeout);
+ }
+
+ return MEM_OK;
+ } else {
+ return MEM_FAIL;
+ }
+}
+
+/*!
+ \brief check the address is supported
+ \param[in] addr: memory sector address/code
+ \param[out] none
+ \retval index of the addressed memory
+*/
+static uint8_t dfu_mem_checkaddr (uint32_t addr)
+{
+ uint8_t mem_index = 0U;
+
+ /* check with all supported memories */
+ for (mem_index = 0U; mem_index < MAX_USED_MEMORY_MEDIA; mem_index++) {
+ /* if the check address is supported, return the memory index */
+ if (MEM_OK == mem_tab[mem_index]->mem_checkaddr(addr)) {
+ return mem_index;
+ }
+ }
+
+ /* if there is no memory found, return MAX_USED_MEMORY_MEDIA */
+ return (MAX_USED_MEMORY_MEDIA);
+}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Include/custom_hid_core.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Include/custom_hid_core.h
index f320f77e40..aa0f207663 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Include/custom_hid_core.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Include/custom_hid_core.h
@@ -3,32 +3,34 @@
\brief definitions for HID core
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Include/standard_hid_core.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Include/standard_hid_core.h
index 773470d67f..8f83cf99db 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Include/standard_hid_core.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Include/standard_hid_core.h
@@ -3,32 +3,34 @@
\brief definitions for HID core
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -39,7 +41,7 @@ OF SUCH DAMAGE.
#include "usb_hid.h"
#define USB_HID_CONFIG_DESC_LEN 0x22U
-#define USB_HID_REPORT_DESC_LEN 0x29U
+#define USB_HID_REPORT_DESC_LEN 0x2EU
#define NO_CMD 0xFFU
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Source/custom_hid_core.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Source/custom_hid_core.c
index fd4c9ccca7..13b9ac51de 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Source/custom_hid_core.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Source/custom_hid_core.c
@@ -3,32 +3,34 @@
\brief custom HID class driver
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -44,10 +46,10 @@ OF SUCH DAMAGE.
__ALIGN_BEGIN const usb_desc_dev custom_hid_dev_desc __ALIGN_END =
{
.header =
- {
- .bLength = USB_DEV_DESC_LEN,
- .bDescriptorType = USB_DESCTYPE_DEV,
- },
+ {
+ .bLength = USB_DEV_DESC_LEN,
+ .bDescriptorType = USB_DESCTYPE_DEV,
+ },
.bcdUSB = 0x0200U,
.bDeviceClass = 0x00U,
.bDeviceSubClass = 0x00U,
@@ -63,15 +65,15 @@ __ALIGN_BEGIN const usb_desc_dev custom_hid_dev_desc __ALIGN_END =
};
/* USB device configuration descriptor */
-__ALIGN_BEGIN const usb_hid_desc_config_set custom_hid_config_desc __ALIGN_END =
+__ALIGN_BEGIN const usb_hid_desc_config_set custom_hid_config_desc __ALIGN_END =
{
.config =
{
.header =
- {
- .bLength = sizeof(usb_desc_config),
- .bDescriptorType = USB_DESCTYPE_CONFIG
- },
+ {
+ .bLength = sizeof(usb_desc_config),
+ .bDescriptorType = USB_DESCTYPE_CONFIG
+ },
.wTotalLength = DESC_LEN_CONFIG,
.bNumInterfaces = 0x01U,
.bConfigurationValue = 0x01U,
@@ -83,10 +85,10 @@ __ALIGN_BEGIN const usb_hid_desc_config_set custom_hid_config_desc __ALIGN_END =
.hid_itf =
{
.header =
- {
- .bLength = sizeof(usb_desc_itf),
- .bDescriptorType = USB_DESCTYPE_ITF
- },
+ {
+ .bLength = sizeof(usb_desc_itf),
+ .bDescriptorType = USB_DESCTYPE_ITF
+ },
.bInterfaceNumber = 0x00U,
.bAlternateSetting = 0x00U,
.bNumEndpoints = 0x02U,
@@ -99,10 +101,10 @@ __ALIGN_BEGIN const usb_hid_desc_config_set custom_hid_config_desc __ALIGN_END =
.hid_vendor =
{
.header =
- {
- .bLength = sizeof(usb_desc_hid),
- .bDescriptorType = USB_DESCTYPE_HID
- },
+ {
+ .bLength = sizeof(usb_desc_hid),
+ .bDescriptorType = USB_DESCTYPE_HID
+ },
.bcdHID = 0x0111U,
.bCountryCode = 0x00U,
.bNumDescriptors = 0x01U,
@@ -113,10 +115,10 @@ __ALIGN_BEGIN const usb_hid_desc_config_set custom_hid_config_desc __ALIGN_END =
.hid_epin =
{
.header =
- {
- .bLength = sizeof(usb_desc_ep),
- .bDescriptorType = USB_DESCTYPE_EP
- },
+ {
+ .bLength = sizeof(usb_desc_ep),
+ .bDescriptorType = USB_DESCTYPE_EP
+ },
.bEndpointAddress = CUSTOMHID_IN_EP,
.bmAttributes = USB_EP_ATTR_INT,
.wMaxPacketSize = CUSTOMHID_IN_PACKET,
@@ -126,10 +128,10 @@ __ALIGN_BEGIN const usb_hid_desc_config_set custom_hid_config_desc __ALIGN_END =
.hid_epout =
{
.header =
- {
- .bLength = sizeof(usb_desc_ep),
- .bDescriptorType = USB_DESCTYPE_EP
- },
+ {
+ .bLength = sizeof(usb_desc_ep),
+ .bDescriptorType = USB_DESCTYPE_EP
+ },
.bEndpointAddress = CUSTOMHID_OUT_EP,
.bmAttributes = USB_EP_ATTR_INT,
.wMaxPacketSize = CUSTOMHID_OUT_PACKET,
@@ -138,50 +140,50 @@ __ALIGN_BEGIN const usb_hid_desc_config_set custom_hid_config_desc __ALIGN_END =
};
/* USB language ID descriptor */
-static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
{
.header =
- {
- .bLength = sizeof(usb_desc_LANGID),
- .bDescriptorType = USB_DESCTYPE_STR
- },
+ {
+ .bLength = sizeof(usb_desc_LANGID),
+ .bDescriptorType = USB_DESCTYPE_STR
+ },
.wLANGID = ENG_LANGID
};
/* USB manufacture string */
-static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
{
.header =
- {
- .bLength = USB_STRING_LEN(10U),
- .bDescriptorType = USB_DESCTYPE_STR,
- },
+ {
+ .bLength = USB_STRING_LEN(10U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
.unicode_string = {'G', 'i', 'g', 'a', 'D', 'e', 'v', 'i', 'c', 'e'}
};
/* USB product string */
-static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
{
.header =
- {
- .bLength = USB_STRING_LEN(14U),
- .bDescriptorType = USB_DESCTYPE_STR,
- },
+ {
+ .bLength = USB_STRING_LEN(14U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
.unicode_string = {'G', 'D', '3', '2', '-', 'C', 'u', 's', 't', 'o', 'm', 'H', 'I', 'D'}
};
/* USBD serial string */
-static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
+static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
{
.header =
- {
- .bLength = USB_STRING_LEN(12U),
- .bDescriptorType = USB_DESCTYPE_STR,
- }
+ {
+ .bLength = USB_STRING_LEN(12U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ }
};
/* USB string descriptor set */
-void *const usbd_hid_strings[] =
+void *const usbd_hid_strings[] =
{
[STR_IDX_LANGID] = (uint8_t *)&usbd_language_id_desc,
[STR_IDX_MFC] = (uint8_t *)&manufacturer_string,
@@ -270,7 +272,7 @@ static uint8_t custom_hid_req_handler (usb_dev *udev, usb_req *req);
static uint8_t custom_hid_data_in (usb_dev *udev, uint8_t ep_num);
static uint8_t custom_hid_data_out (usb_dev *udev, uint8_t ep_num);
-usb_class_core usbd_custom_hid_cb =
+usb_class_core usbd_custom_hid_cb =
{
.command = NO_CMD,
.alter_set = 0U,
@@ -330,10 +332,10 @@ static uint8_t custom_hid_init (usb_dev *udev, uint8_t config_index)
memset((void *)&hid_handler, 0U, sizeof(custom_hid_handler));
- /* initialize the data TX endpoint */
+ /* initialize the data Tx endpoint */
usbd_ep_setup (udev, &(custom_hid_config_desc.hid_epin));
- /* Initialize the data RX endpoint */
+ /* initialize the data Rx endpoint */
usbd_ep_setup (udev, &(custom_hid_config_desc.hid_epout));
/* prepare receive data */
@@ -353,7 +355,7 @@ static uint8_t custom_hid_init (usb_dev *udev, uint8_t config_index)
}
/*!
- \brief de-initialize the HID device
+ \brief deinitialize the HID device
\param[in] udev: pointer to USB device instance
\param[in] config_index: configuration index
\param[out] none
@@ -444,43 +446,40 @@ static uint8_t custom_hid_data_out (usb_dev *udev, uint8_t ep_num)
{
custom_hid_handler *hid = (custom_hid_handler *)udev->dev.class_data[CUSTOM_HID_INTERFACE];
- if ((CUSTOMHID_OUT_EP & 0x7FU) == ep_num) {
- switch (hid->data[0]){
- case 0x11U:
- if (RESET != hid->data[1]) {
- gd_eval_led_on(LED1);
- } else {
- gd_eval_led_off(LED1);
- }
- break;
-
- case 0x12U:
- if (RESET != hid->data[1]) {
- gd_eval_led_on(LED2);
- } else {
- gd_eval_led_off(LED2);
- }
- break;
-
- case 0x13U:
- if (RESET != hid->data[1]) {
- gd_eval_led_on(LED3);
- } else {
- gd_eval_led_off(LED3);
- }
- break;
+ /* light the LED */
+ switch (hid->data[0]){
+ case 0x11U:
+ if (RESET != hid->data[1]) {
+ gd_eval_led_on(LED1);
+ } else {
+ gd_eval_led_off(LED1);
+ }
+ break;
- case 0x14U:
- break;
+ case 0x12U:
+ if (RESET != hid->data[1]) {
+ gd_eval_led_on(LED2);
+ } else {
+ gd_eval_led_off(LED2);
+ }
+ break;
- default:
- break;
+ case 0x13U:
+ if (RESET != hid->data[1]) {
+ gd_eval_led_on(LED3);
+ } else {
+ gd_eval_led_off(LED3);
}
+ break;
- usbd_ep_recev (udev, CUSTOMHID_IN_EP, hid->data, 2U);
+ case 0x14U:
+ break;
- return USBD_OK;
- }
+ default:
+ break;
+ }
+
+ usbd_ep_recev (udev, CUSTOMHID_OUT_EP, hid->data, 2U);
- return USBD_FAIL;
+ return USBD_OK;
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Source/standard_hid_core.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Source/standard_hid_core.c
index 8252e33e97..e3b498143a 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Source/standard_hid_core.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/hid/Source/standard_hid_core.c
@@ -3,32 +3,34 @@
\brief HID class driver
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -43,10 +45,10 @@ OF SUCH DAMAGE.
__ALIGN_BEGIN const usb_desc_dev hid_dev_desc __ALIGN_END =
{
.header =
- {
- .bLength = USB_DEV_DESC_LEN,
- .bDescriptorType = USB_DESCTYPE_DEV
- },
+ {
+ .bLength = USB_DEV_DESC_LEN,
+ .bDescriptorType = USB_DESCTYPE_DEV
+ },
.bcdUSB = 0x0200U,
.bDeviceClass = 0x00U,
.bDeviceSubClass = 0x00U,
@@ -61,15 +63,15 @@ __ALIGN_BEGIN const usb_desc_dev hid_dev_desc __ALIGN_END =
.bNumberConfigurations = USBD_CFG_MAX_NUM
};
-__ALIGN_BEGIN const usb_hid_desc_config_set hid_config_desc __ALIGN_END =
+__ALIGN_BEGIN const usb_hid_desc_config_set hid_config_desc __ALIGN_END =
{
.config =
{
.header =
- {
- .bLength = sizeof(usb_desc_config),
- .bDescriptorType = USB_DESCTYPE_CONFIG
- },
+ {
+ .bLength = sizeof(usb_desc_config),
+ .bDescriptorType = USB_DESCTYPE_CONFIG
+ },
.wTotalLength = USB_HID_CONFIG_DESC_LEN,
.bNumInterfaces = 0x01U,
.bConfigurationValue = 0x01U,
@@ -81,10 +83,10 @@ __ALIGN_BEGIN const usb_hid_desc_config_set hid_config_desc __ALIGN_END =
.hid_itf =
{
.header =
- {
- .bLength = sizeof(usb_desc_itf),
- .bDescriptorType = USB_DESCTYPE_ITF
- },
+ {
+ .bLength = sizeof(usb_desc_itf),
+ .bDescriptorType = USB_DESCTYPE_ITF
+ },
.bInterfaceNumber = 0x00U,
.bAlternateSetting = 0x00U,
.bNumEndpoints = 0x01U,
@@ -97,10 +99,10 @@ __ALIGN_BEGIN const usb_hid_desc_config_set hid_config_desc __ALIGN_END =
.hid_vendor =
{
.header =
- {
- .bLength = sizeof(usb_desc_hid),
- .bDescriptorType = USB_DESCTYPE_HID
- },
+ {
+ .bLength = sizeof(usb_desc_hid),
+ .bDescriptorType = USB_DESCTYPE_HID
+ },
.bcdHID = 0x0111U,
.bCountryCode = 0x00U,
.bNumDescriptors = 0x01U,
@@ -111,10 +113,71 @@ __ALIGN_BEGIN const usb_hid_desc_config_set hid_config_desc __ALIGN_END =
.hid_epin =
{
.header =
- {
- .bLength = sizeof(usb_desc_ep),
- .bDescriptorType = USB_DESCTYPE_EP
- },
+ {
+ .bLength = sizeof(usb_desc_ep),
+ .bDescriptorType = USB_DESCTYPE_EP
+ },
+ .bEndpointAddress = HID_IN_EP,
+ .bmAttributes = USB_EP_ATTR_INT,
+ .wMaxPacketSize = HID_IN_PACKET,
+ .bInterval = 0x10U
+ }
+};
+
+__ALIGN_BEGIN const usb_hid_desc_config_set other_speed_hid_config_desc __ALIGN_END =
+{
+ .config =
+ {
+ .header =
+ {
+ .bLength = sizeof(usb_desc_config),
+ .bDescriptorType = USB_DESCTYPE_OTHER_SPD_CONFIG
+ },
+ .wTotalLength = USB_HID_CONFIG_DESC_LEN,
+ .bNumInterfaces = 0x01U,
+ .bConfigurationValue = 0x01U,
+ .iConfiguration = 0x00U,
+ .bmAttributes = 0xA0U,
+ .bMaxPower = 0x32U
+ },
+
+ .hid_itf =
+ {
+ .header =
+ {
+ .bLength = sizeof(usb_desc_itf),
+ .bDescriptorType = USB_DESCTYPE_ITF
+ },
+ .bInterfaceNumber = 0x00U,
+ .bAlternateSetting = 0x00U,
+ .bNumEndpoints = 0x01U,
+ .bInterfaceClass = USB_HID_CLASS,
+ .bInterfaceSubClass = USB_HID_SUBCLASS_BOOT_ITF,
+ .bInterfaceProtocol = USB_HID_PROTOCOL_KEYBOARD,
+ .iInterface = 0x00U
+ },
+
+ .hid_vendor =
+ {
+ .header =
+ {
+ .bLength = sizeof(usb_desc_hid),
+ .bDescriptorType = USB_DESCTYPE_HID
+ },
+ .bcdHID = 0x0111U,
+ .bCountryCode = 0x00U,
+ .bNumDescriptors = 0x01U,
+ .bDescriptorType = USB_DESCTYPE_REPORT,
+ .wDescriptorLength = USB_HID_REPORT_DESC_LEN,
+ },
+
+ .hid_epin =
+ {
+ .header =
+ {
+ .bLength = sizeof(usb_desc_ep),
+ .bDescriptorType = USB_DESCTYPE_EP
+ },
.bEndpointAddress = HID_IN_EP,
.bmAttributes = USB_EP_ATTR_INT,
.wMaxPacketSize = HID_IN_PACKET,
@@ -122,50 +185,64 @@ __ALIGN_BEGIN const usb_hid_desc_config_set hid_config_desc __ALIGN_END =
}
};
+__ALIGN_BEGIN const uint8_t usbd_qualifier_desc[10] __ALIGN_END =
+{
+ 0x0A,
+ 0x06,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x40,
+ 0x01,
+ 0x00
+};
+
/* USB language ID Descriptor */
-static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
{
.header =
- {
- .bLength = sizeof(usb_desc_LANGID),
- .bDescriptorType = USB_DESCTYPE_STR
- },
+ {
+ .bLength = sizeof(usb_desc_LANGID),
+ .bDescriptorType = USB_DESCTYPE_STR
+ },
.wLANGID = ENG_LANGID
};
/* USB manufacture string */
-static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
{
.header =
- {
- .bLength = USB_STRING_LEN(10U),
- .bDescriptorType = USB_DESCTYPE_STR,
- },
+ {
+ .bLength = USB_STRING_LEN(10U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
.unicode_string = {'G', 'i', 'g', 'a', 'D', 'e', 'v', 'i', 'c', 'e'}
};
/* USB product string */
-static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
{
.header =
- {
- .bLength = USB_STRING_LEN(17U),
- .bDescriptorType = USB_DESCTYPE_STR,
- },
- .unicode_string = {'G', 'D', '3', '2', '-','U', 'S', 'B', '_', 'K', 'e', 'y', 'b', 'o', 'a', 'r', 'd'}
+ {
+ .bLength = USB_STRING_LEN(17U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
+ .unicode_string = {'G', 'D', '3', '2', '-', 'U', 'S', 'B', '_', 'K', 'e', 'y', 'b', 'o', 'a', 'r', 'd'}
};
/* USBD serial string */
-static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
+static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
{
.header =
- {
- .bLength = USB_STRING_LEN(12U),
- .bDescriptorType = USB_DESCTYPE_STR,
- }
+ {
+ .bLength = USB_STRING_LEN(12U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ }
};
-void *const usbd_hid_strings[] =
+void *const usbd_hid_strings[] =
{
[STR_IDX_LANGID] = (uint8_t *)&usbd_language_id_desc,
[STR_IDX_MFC] = (uint8_t *)&manufacturer_string,
@@ -176,6 +253,10 @@ void *const usbd_hid_strings[] =
usb_desc hid_desc = {
.dev_desc = (uint8_t *)&hid_dev_desc,
.config_desc = (uint8_t *)&hid_config_desc,
+#if defined(USE_USB_HS) && defined(USE_ULPI_PHY)
+ .other_speed_config_desc = (uint8_t *)&other_speed_hid_config_desc,
+ .qualifier_desc = (uint8_t *)&usbd_qualifier_desc,
+#endif
.strings = usbd_hid_strings
};
@@ -200,7 +281,9 @@ __ALIGN_BEGIN const uint8_t hid_report_desc[USB_HID_REPORT_DESC_LEN] __ALIGN_END
0x95, 0x06, /* REPORT_COUNT (6) */
0x75, 0x08, /* REPORT_SIZE (8) */
- 0x25, 0xFF, /* LOGICAL_MAXIMUM (255) */
+ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */
+ 0x26, 0xFF, 0x00, /* LOGICAL_MAXIMUM (255) */
+ 0x05, 0x07, /* USAGE_PAGE (Keyboard/Keypad) */
0x19, 0x00, /* USAGE_MINIMUM (Reserved (no event indicated)) */
0x29, 0x65, /* USAGE_MAXIMUM (Keyboard Application) */
0x81, 0x00, /* INPUT (Data,Ary,Abs) */
@@ -289,7 +372,7 @@ static uint8_t hid_init (usb_dev *udev, uint8_t config_index)
}
/*!
- \brief de-initialize the HID device
+ \brief deinitialize the HID device
\param[in] udev: pointer to USB device instance
\param[in] config_index: configuration index
\param[out] none
@@ -351,6 +434,9 @@ static uint8_t hid_req (usb_dev *udev, usb_req *req)
transc->xfer_buf = (uint8_t *)hid_report_desc;
return REQ_SUPP;
+ } else if (USB_DESCTYPE_HID == (req->wValue >> 8U)) {
+ transc->remain_len = USB_MIN(9U, req->wLength);
+ transc->xfer_buf = (uint8_t *)(&(hid_config_desc.hid_vendor));
}
break;
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/iap/Include/usb_iap_core.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/iap/Include/usb_iap_core.h
index a84dc4a255..21696a93ca 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/iap/Include/usb_iap_core.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/iap/Include/usb_iap_core.h
@@ -3,32 +3,34 @@
\brief the header file of IAP driver
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -43,7 +45,11 @@ OF SUCH DAMAGE.
#ifdef USE_USB_FS
#define USB_DESC_LEN_IAP_REPORT 35U
#elif defined(USE_USB_HS)
- #define USB_DESC_LEN_IAP_REPORT 36U
+ #ifdef USE_ULPI_PHY
+ #define USB_DESC_LEN_IAP_REPORT 36U
+ #else
+ #define USB_DESC_LEN_IAP_REPORT 35U
+ #endif
#else
#error "please select 'USE_USB_FS' or 'USE_USB_HS'"
#endif
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/iap/Source/usb_iap_core.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/iap/Source/usb_iap_core.c
index 6dced66ab8..3761a89c6c 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/iap/Source/usb_iap_core.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/iap/Source/usb_iap_core.c
@@ -3,32 +3,34 @@
\brief IAP driver
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -44,10 +46,10 @@ OF SUCH DAMAGE.
__ALIGN_BEGIN const usb_desc_dev iap_dev_desc __ALIGN_END =
{
.header =
- {
- .bLength = USB_DEV_DESC_LEN,
- .bDescriptorType = USB_DESCTYPE_DEV
- },
+ {
+ .bLength = USB_DEV_DESC_LEN,
+ .bDescriptorType = USB_DESCTYPE_DEV
+ },
.bcdUSB = 0x0200U,
.bDeviceClass = 0x00U,
.bDeviceSubClass = 0x00U,
@@ -62,15 +64,15 @@ __ALIGN_BEGIN const usb_desc_dev iap_dev_desc __ALIGN_END =
.bNumberConfigurations = USBD_CFG_MAX_NUM
};
-__ALIGN_BEGIN const usb_hid_desc_config_set iap_config_desc __ALIGN_END =
+__ALIGN_BEGIN const usb_hid_desc_config_set iap_config_desc __ALIGN_END =
{
.config =
{
.header =
- {
- .bLength = sizeof(usb_desc_config),
- .bDescriptorType = USB_DESCTYPE_CONFIG
- },
+ {
+ .bLength = sizeof(usb_desc_config),
+ .bDescriptorType = USB_DESCTYPE_CONFIG
+ },
.wTotalLength = USB_DESC_LEN_IAP_CONFIG_SET,
.bNumInterfaces = 0x01U,
.bConfigurationValue = 0x01U,
@@ -82,10 +84,10 @@ __ALIGN_BEGIN const usb_hid_desc_config_set iap_config_desc __ALIGN_END =
.hid_itf =
{
.header =
- {
- .bLength = sizeof(usb_desc_itf),
- .bDescriptorType = USB_DESCTYPE_ITF
- },
+ {
+ .bLength = sizeof(usb_desc_itf),
+ .bDescriptorType = USB_DESCTYPE_ITF
+ },
.bInterfaceNumber = 0x00U,
.bAlternateSetting = 0x00U,
.bNumEndpoints = 0x02U,
@@ -98,10 +100,10 @@ __ALIGN_BEGIN const usb_hid_desc_config_set iap_config_desc __ALIGN_END =
.hid_vendor =
{
.header =
- {
- .bLength = sizeof(usb_desc_hid),
- .bDescriptorType = USB_DESCTYPE_HID
- },
+ {
+ .bLength = sizeof(usb_desc_hid),
+ .bDescriptorType = USB_DESCTYPE_HID
+ },
.bcdHID = 0x0111U,
.bCountryCode = 0x00U,
.bNumDescriptors = 0x01U,
@@ -112,10 +114,10 @@ __ALIGN_BEGIN const usb_hid_desc_config_set iap_config_desc __ALIGN_END =
.hid_epin =
{
.header =
- {
- .bLength = sizeof(usb_desc_ep),
- .bDescriptorType = USB_DESCTYPE_EP
- },
+ {
+ .bLength = sizeof(usb_desc_ep),
+ .bDescriptorType = USB_DESCTYPE_EP
+ },
.bEndpointAddress = IAP_IN_EP,
.bmAttributes = USB_EP_ATTR_INT,
.wMaxPacketSize = IAP_IN_PACKET,
@@ -125,10 +127,10 @@ __ALIGN_BEGIN const usb_hid_desc_config_set iap_config_desc __ALIGN_END =
.hid_epout =
{
.header =
- {
- .bLength = sizeof(usb_desc_ep),
- .bDescriptorType = USB_DESCTYPE_EP
- },
+ {
+ .bLength = sizeof(usb_desc_ep),
+ .bDescriptorType = USB_DESCTYPE_EP
+ },
.bEndpointAddress = IAP_OUT_EP,
.bmAttributes = USB_EP_ATTR_INT,
.wMaxPacketSize = IAP_OUT_PACKET,
@@ -137,49 +139,49 @@ __ALIGN_BEGIN const usb_hid_desc_config_set iap_config_desc __ALIGN_END =
};
/* USB language ID Descriptor */
-static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
{
.header =
- {
- .bLength = sizeof(usb_desc_LANGID),
- .bDescriptorType = USB_DESCTYPE_STR
- },
+ {
+ .bLength = sizeof(usb_desc_LANGID),
+ .bDescriptorType = USB_DESCTYPE_STR
+ },
.wLANGID = ENG_LANGID
};
/* USB manufacture string */
-static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
{
.header =
- {
- .bLength = USB_STRING_LEN(10U),
- .bDescriptorType = USB_DESCTYPE_STR,
- },
+ {
+ .bLength = USB_STRING_LEN(10U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
.unicode_string = {'G', 'i', 'g', 'a', 'D', 'e', 'v', 'i', 'c', 'e'}
};
/* USB product string */
-static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
{
.header =
- {
- .bLength = USB_STRING_LEN(12U),
- .bDescriptorType = USB_DESCTYPE_STR,
- },
+ {
+ .bLength = USB_STRING_LEN(12U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
.unicode_string = {'G', 'D', '3', '2', '-', 'U', 'S', 'B', '_', 'I', 'A', 'P'}
};
/* USBD serial string */
-static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
+static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
{
.header =
- {
- .bLength = USB_STRING_LEN(2U),
- .bDescriptorType = USB_DESCTYPE_STR,
- }
+ {
+ .bLength = USB_STRING_LEN(2U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ }
};
-void *const usbd_iap_strings[] =
+void *const usbd_iap_strings[] =
{
[STR_IDX_LANGID] = (uint8_t *)&usbd_language_id_desc,
[STR_IDX_MFC] = (uint8_t *)&manufacturer_string,
@@ -194,17 +196,17 @@ usb_desc iap_desc = {
};
/* local function prototypes ('static') */
-static uint8_t iap_init (usb_dev *udev, uint8_t config_index);
-static uint8_t iap_deinit (usb_dev *udev, uint8_t config_index);
-static uint8_t iap_req_handler (usb_dev *udev, usb_req *req);
-static uint8_t iap_data_out (usb_dev *udev, uint8_t ep_num);
+static uint8_t iap_init (usb_dev *udev, uint8_t config_index);
+static uint8_t iap_deinit (usb_dev *udev, uint8_t config_index);
+static uint8_t iap_req_handler (usb_dev *udev, usb_req *req);
+static uint8_t iap_data_out (usb_dev *udev, uint8_t ep_num);
/* IAP requests management functions */
-static void iap_req_erase (usb_dev *udev);
-static void iap_req_dnload (usb_dev *udev);
-static void iap_req_optionbyte(usb_dev *udev, uint8_t option_num);
-static void iap_req_leave (usb_dev *udev);
-static void iap_address_send (usb_dev *udev);
+static void iap_req_erase (usb_dev *udev);
+static void iap_req_dnload (usb_dev *udev);
+static void iap_req_optionbyte (usb_dev *udev, uint8_t option_num);
+static void iap_req_leave (usb_dev *udev);
+static void iap_address_send (usb_dev *udev);
usb_class_core iap_class = {
.init = iap_init,
@@ -275,10 +277,10 @@ static uint8_t iap_init (usb_dev *udev, uint8_t config_index)
{
static __ALIGN_BEGIN usbd_iap_handler iap_handler __ALIGN_END;
- /* initialize TX endpoint */
+ /* initialize Tx endpoint */
usbd_ep_setup(udev, &(iap_config_desc.hid_epin));
- /* initialize RX endpoint */
+ /* initialize Rx endpoint */
usbd_ep_setup(udev, &(iap_config_desc.hid_epout));
/* unlock the internal flash */
@@ -380,47 +382,45 @@ static uint8_t iap_data_out (usb_dev *udev ,uint8_t ep_num)
{
usbd_iap_handler *iap = (usbd_iap_handler *)udev->dev.class_data[USBD_IAP_INTERFACE];
- if ((IAP_OUT_EP & 0x7FU) == ep_num) {
- if (0x01U == iap->report_buf[0]) {
- switch (iap->report_buf[1]) {
- case IAP_DNLOAD:
- iap_req_dnload(udev);
- break;
+ if (0x01U == iap->report_buf[0]) {
+ switch (iap->report_buf[1]) {
+ case IAP_DNLOAD:
+ iap_req_dnload(udev);
+ break;
- case IAP_ERASE:
- iap_req_erase(udev);
- break;
+ case IAP_ERASE:
+ iap_req_erase(udev);
+ break;
- case IAP_OPTION_BYTE1:
- iap_req_optionbyte(udev, 0x01U);
- break;
+ case IAP_OPTION_BYTE1:
+ iap_req_optionbyte(udev, 0x01U);
+ break;
- case IAP_LEAVE:
- iap_req_leave(udev);
- break;
+ case IAP_LEAVE:
+ iap_req_leave(udev);
+ break;
- case IAP_GETBIN_ADDRESS:
- iap_address_send(udev);
- break;
+ case IAP_GETBIN_ADDRESS:
+ iap_address_send(udev);
+ break;
- case IAP_OPTION_BYTE2:
- iap_req_optionbyte(udev, 0x02U);
- break;
+ case IAP_OPTION_BYTE2:
+ iap_req_optionbyte(udev, 0x02U);
+ break;
- default:
- break;
- }
+ default:
+ break;
}
-
- usbd_ep_recev(udev, IAP_OUT_EP, iap->report_buf, IAP_OUT_PACKET);
}
+ usbd_ep_recev(udev, IAP_OUT_EP, iap->report_buf, IAP_OUT_PACKET);
+
return USBD_OK;
}
/*!
\brief handle the IAP_DNLOAD request
- \param[in] udev: pointer to USB device instance
+ \param[in] udev: pointer to usb device instance
\param[out] none
\retval none
*/
@@ -452,7 +452,7 @@ static void iap_req_dnload(usb_dev *udev)
/*!
\brief handle the IAP_ERASE request
- \param[in] udev: pointer to USB device instance
+ \param[in] udev: pointer to usb device instance
\param[out] none
\retval none
*/
@@ -515,7 +515,7 @@ static void iap_req_optionbyte(usb_dev *udev, uint8_t option_num)
usbd_iap_handler *iap = (usbd_iap_handler *)udev->dev.class_data[USBD_IAP_INTERFACE];
- iap->option_byte[0]= 0x02U;
+ iap->option_byte[0] = 0x02U;
if (0x01U == option_num) {
address = OPT_BYTE_ADDR1;
@@ -537,7 +537,7 @@ static void iap_req_optionbyte(usb_dev *udev, uint8_t option_num)
/*!
\brief handle the IAP_LEAVE request
- \param[in] udev: pointer to USB device instance
+ \param[in] udev: pointer to usb device instance
\param[out] none
\retval none
*/
@@ -552,7 +552,7 @@ static void iap_req_leave(usb_dev *udev)
/*!
\brief handle the IAP_SEND_ADDRESS request
- \param[in] udev: pointer to USB device instance
+ \param[in] udev: pointer to usb device instance
\param[out] none
\retval none
*/
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_bbb.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_bbb.h
index 266b932d7a..d855d878f2 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_bbb.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_bbb.h
@@ -1,34 +1,36 @@
/*!
\file usbd_msc_bbb.h
- \brief the header file of the usbd_msc_bot.c file
+ \brief the header file of the usbd_msc_bbb.c file
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -83,7 +85,7 @@ typedef struct
} usbd_msc_handler;
/* function declarations */
-/* initialize the bbb process */
+/* initialize the BBB process */
void msc_bbb_init (usb_core_driver *udev);
/* reset the BBB machine */
void msc_bbb_reset (usb_core_driver *udev);
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_core.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_core.h
index a67b539746..8782c5d3f8 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_core.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_core.h
@@ -3,32 +3,34 @@
\brief the header file of USB MSC device class core functions
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_mem.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_mem.h
index c39778fcf6..aa8c9ccf99 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_mem.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_mem.h
@@ -3,32 +3,34 @@
\brief header file for storage memory
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -52,7 +54,7 @@ typedef struct
uint8_t *mem_inquiry_data[MEM_LUN_NUM];
uint32_t mem_block_size[MEM_LUN_NUM];
uint32_t mem_block_len[MEM_LUN_NUM];
-}usbd_mem_cb;
+} usbd_mem_cb;
extern usbd_mem_cb *usbd_mem_fops;
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_scsi.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_scsi.h
index 188e592ced..828eab1364 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_scsi.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Include/usbd_msc_scsi.h
@@ -3,44 +3,54 @@
\brief the header file of the usbd_msc_scsi.c file
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#ifndef __USBD_MSC_SCSI_H
#define __USBD_MSC_SCSI_H
-#include "usbd_msc_data.h"
#include "usbd_msc_bbb.h"
#include "msc_scsi.h"
#define SENSE_LIST_DEEPTH 4U
+#define MODE_SENSE6_LENGTH 8U
+#define MODE_SENSE10_LENGTH 8U
+#define INQUIRY_PAGE00_LENGTH 96U
+#define FORMAT_CAPACITIES_LENGTH 20U
+
+extern const uint8_t msc_page00_inquiry_data[];
+extern const uint8_t msc_mode_sense6_data[];
+extern const uint8_t msc_mode_sense10_data[];
+
/* function declarations */
/* process SCSI commands */
int8_t scsi_process_cmd (usb_core_driver *udev, uint8_t lun, uint8_t *cmd);
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Source/usbd_msc_bbb.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Source/usbd_msc_bbb.c
index d9a74d5d5d..cbd5e62c84 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Source/usbd_msc_bbb.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Source/usbd_msc_bbb.c
@@ -4,32 +4,34 @@
\note BBB means Bulk-only transport protocol for USB MSC
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -38,11 +40,11 @@ OF SUCH DAMAGE.
/* local function prototypes ('static') */
static void msc_bbb_cbw_decode (usb_core_driver *udev);
-static void msc_bbb_data_send (usb_core_driver *udev, uint8_t *pbuf, uint32_t Len);
-static void msc_bbb_abort (usb_core_driver *udev);
+static void msc_bbb_data_send (usb_core_driver *udev, uint8_t *pbuf, uint32_t Len);
+static void msc_bbb_abort (usb_core_driver *udev);
/*!
- \brief initialize the bbb process
+ \brief initialize the BBB process
\param[in] udev: pointer to USB device instance
\param[out] none
\retval none
@@ -61,10 +63,10 @@ void msc_bbb_init (usb_core_driver *udev)
usbd_mem_fops->mem_init(lun_num);
}
- /* flush the RX FIFO */
+ /* flush the Rx FIFO */
usbd_fifo_flush (udev, MSC_OUT_EP);
- /* flush the TX FIFO */
+ /* flush the Tx FIFO */
usbd_fifo_flush (udev, MSC_IN_EP);
/* prepare endpoint to receive the first BBB CBW */
@@ -89,7 +91,7 @@ void msc_bbb_reset (usb_core_driver *udev)
}
/*!
- \brief de-initialize the BBB machine
+ \brief deinitialize the BBB machine
\param[in] udev: pointer to USB device instance
\param[out] none
\retval none
@@ -188,7 +190,7 @@ void msc_bbb_clrfeature (usb_core_driver *udev, uint8_t ep_num)
{
usbd_msc_handler *msc = (usbd_msc_handler *)udev->dev.class_data[USBD_MSC_INTERFACE];
- if (msc->bbb_status == BBB_STATUS_ERROR)/* bad CBW signature */ {
+ if (msc->bbb_status == BBB_STATUS_ERROR) { /* bad CBW signature */
usbd_ep_stall(udev, MSC_IN_EP);
msc->bbb_status = BBB_STATUS_NORMAL;
@@ -212,11 +214,11 @@ static void msc_bbb_cbw_decode (usb_core_driver *udev)
msc->bbb_csw.dCSWTag = msc->bbb_cbw.dCBWTag;
msc->bbb_csw.dCSWDataResidue = msc->bbb_cbw.dCBWDataTransferLength;
- if ((BBB_CBW_LENGTH != usbd_rxcount_get (udev, MSC_OUT_EP)) ||
- (BBB_CBW_SIGNATURE != msc->bbb_cbw.dCBWSignature)||
- (msc->bbb_cbw.bCBWLUN > 1U) ||
- (msc->bbb_cbw.bCBWCBLength < 1U) ||
- (msc->bbb_cbw.bCBWCBLength > 16U)) {
+ if((BBB_CBW_LENGTH != usbd_rxcount_get(udev, MSC_OUT_EP)) ||
+ (BBB_CBW_SIGNATURE != msc->bbb_cbw.dCBWSignature) ||
+ (msc->bbb_cbw.bCBWLUN > 1U) ||
+ (msc->bbb_cbw.bCBWCBLength < 1U) ||
+ (msc->bbb_cbw.bCBWCBLength > 16U)) {
/* illegal command handler */
scsi_sense_code (udev, msc->bbb_cbw.bCBWLUN, ILLEGAL_REQUEST, INVALID_CDB);
@@ -226,7 +228,7 @@ static void msc_bbb_cbw_decode (usb_core_driver *udev)
} else {
if (scsi_process_cmd (udev, msc->bbb_cbw.bCBWLUN, &msc->bbb_cbw.CBWCB[0]) < 0) {
msc_bbb_abort (udev);
- } else if ((BBB_DATA_IN != msc->bbb_state) &&
+ } else if ((BBB_DATA_IN != msc->bbb_state) &&
(BBB_DATA_OUT != msc->bbb_state) &&
(BBB_LAST_DATA_IN != msc->bbb_state)) { /* burst xfer handled internally */
if (msc->bbb_datalen > 0U) {
@@ -273,9 +275,9 @@ static void msc_bbb_abort (usb_core_driver *udev)
{
usbd_msc_handler *msc = (usbd_msc_handler *)udev->dev.class_data[USBD_MSC_INTERFACE];
- if ((0U == msc->bbb_cbw.bmCBWFlags) &&
- (0U != msc->bbb_cbw.dCBWDataTransferLength) &&
- (BBB_STATUS_NORMAL == msc->bbb_status)) {
+ if ((0U == msc->bbb_cbw.bmCBWFlags) &&
+ (0U != msc->bbb_cbw.dCBWDataTransferLength) &&
+ (BBB_STATUS_NORMAL == msc->bbb_status)) {
usbd_ep_stall(udev, MSC_OUT_EP);
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Source/usbd_msc_core.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Source/usbd_msc_core.c
index 9c6e9f0857..1c9d4fc7dc 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Source/usbd_msc_core.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Source/usbd_msc_core.c
@@ -3,32 +3,34 @@
\brief USB MSC device class core functions
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -47,7 +49,7 @@ static uint8_t msc_core_req (usb_dev *udev, usb_req *req);
static uint8_t msc_core_in (usb_dev *udev, uint8_t ep_num);
static uint8_t msc_core_out (usb_dev *udev, uint8_t ep_num);
-usb_class_core msc_class =
+usb_class_core msc_class =
{
.init = msc_core_init,
.deinit = msc_core_deinit,
@@ -62,8 +64,9 @@ usb_class_core msc_class =
/* USB standard device descriptor */
__ALIGN_BEGIN const usb_desc_dev msc_dev_desc __ALIGN_END =
{
- .header = {
- .bLength = USB_DEV_DESC_LEN,
+ .header =
+ {
+ .bLength = USB_DEV_DESC_LEN,
.bDescriptorType = USB_DESCTYPE_DEV
},
.bcdUSB = 0x0200U,
@@ -81,12 +84,13 @@ __ALIGN_BEGIN const usb_desc_dev msc_dev_desc __ALIGN_END =
};
/* USB device configuration descriptor */
-__ALIGN_BEGIN const usb_desc_config_set msc_config_desc __ALIGN_END =
+__ALIGN_BEGIN const usb_desc_config_set msc_config_desc __ALIGN_END =
{
- .config =
+ .config =
{
- .header = {
- .bLength = sizeof(usb_desc_config),
+ .header =
+ {
+ .bLength = sizeof(usb_desc_config),
.bDescriptorType = USB_DESCTYPE_CONFIG
},
.wTotalLength = USB_MSC_CONFIG_DESC_SIZE,
@@ -97,10 +101,11 @@ __ALIGN_BEGIN const usb_desc_config_set msc_config_desc __ALIGN_END =
.bMaxPower = 0x32U
},
- .msc_itf =
+ .msc_itf =
{
- .header = {
- .bLength = sizeof(usb_desc_itf),
+ .header =
+ {
+ .bLength = sizeof(usb_desc_itf),
.bDescriptorType = USB_DESCTYPE_ITF
},
.bInterfaceNumber = 0x00U,
@@ -112,10 +117,11 @@ __ALIGN_BEGIN const usb_desc_config_set msc_config_desc __ALIGN_END =
.iInterface = 0x00U
},
- .msc_epin =
+ .msc_epin =
{
- .header = {
- .bLength = sizeof(usb_desc_ep),
+ .header =
+ {
+ .bLength = sizeof(usb_desc_ep),
.bDescriptorType = USB_DESCTYPE_EP
},
.bEndpointAddress = MSC_IN_EP,
@@ -124,10 +130,11 @@ __ALIGN_BEGIN const usb_desc_config_set msc_config_desc __ALIGN_END =
.bInterval = 0x00U
},
- .msc_epout =
+ .msc_epout =
{
- .header = {
- .bLength = sizeof(usb_desc_ep),
+ .header =
+ {
+ .bLength = sizeof(usb_desc_ep),
.bDescriptorType = USB_DESCTYPE_EP
},
.bEndpointAddress = MSC_OUT_EP,
@@ -137,51 +144,126 @@ __ALIGN_BEGIN const usb_desc_config_set msc_config_desc __ALIGN_END =
}
};
+/* USB device configuration descriptor */
+__ALIGN_BEGIN const usb_desc_config_set other_speed_msc_config_desc __ALIGN_END =
+{
+ .config =
+ {
+ .header =
+ {
+ .bLength = sizeof(usb_desc_config),
+ .bDescriptorType = USB_DESCTYPE_OTHER_SPD_CONFIG
+ },
+ .wTotalLength = USB_MSC_CONFIG_DESC_SIZE,
+ .bNumInterfaces = 0x01U,
+ .bConfigurationValue = 0x01U,
+ .iConfiguration = 0x00U,
+ .bmAttributes = 0xC0U,
+ .bMaxPower = 0x32U
+ },
+
+ .msc_itf =
+ {
+ .header =
+ {
+ .bLength = sizeof(usb_desc_itf),
+ .bDescriptorType = USB_DESCTYPE_ITF
+ },
+ .bInterfaceNumber = 0x00U,
+ .bAlternateSetting = 0x00U,
+ .bNumEndpoints = 0x02U,
+ .bInterfaceClass = USB_CLASS_MSC,
+ .bInterfaceSubClass = USB_MSC_SUBCLASS_SCSI,
+ .bInterfaceProtocol = USB_MSC_PROTOCOL_BBB,
+ .iInterface = 0x00U
+ },
+
+ .msc_epin =
+ {
+ .header =
+ {
+ .bLength = sizeof(usb_desc_ep),
+ .bDescriptorType = USB_DESCTYPE_EP
+ },
+ .bEndpointAddress = MSC_IN_EP,
+ .bmAttributes = USB_EP_ATTR_BULK,
+ .wMaxPacketSize = 64U,
+ .bInterval = 0x00U
+ },
+
+ .msc_epout =
+ {
+ .header =
+ {
+ .bLength = sizeof(usb_desc_ep),
+ .bDescriptorType = USB_DESCTYPE_EP
+ },
+ .bEndpointAddress = MSC_OUT_EP,
+ .bmAttributes = USB_EP_ATTR_BULK,
+ .wMaxPacketSize = 64U,
+ .bInterval = 0x00U
+ }
+};
+
+__ALIGN_BEGIN const uint8_t usbd_qualifier_desc[10] __ALIGN_END =
+{
+ 0x0A,
+ 0x06,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x40,
+ 0x01,
+ 0x00
+};
+
/* USB language ID descriptor */
-static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
{
- .header =
- {
- .bLength = sizeof(usb_desc_LANGID),
- .bDescriptorType = USB_DESCTYPE_STR
- },
+ .header =
+ {
+ .bLength = sizeof(usb_desc_LANGID),
+ .bDescriptorType = USB_DESCTYPE_STR
+ },
.wLANGID = ENG_LANGID
};
/* USB manufacture string */
-static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
{
.header =
- {
- .bLength = USB_STRING_LEN(10U),
- .bDescriptorType = USB_DESCTYPE_STR,
- },
+ {
+ .bLength = USB_STRING_LEN(10U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
.unicode_string = {'G', 'i', 'g', 'a', 'D', 'e', 'v', 'i', 'c', 'e'}
};
/* USB product string */
-static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
{
.header =
- {
- .bLength = USB_STRING_LEN(12U),
- .bDescriptorType = USB_DESCTYPE_STR,
- },
+ {
+ .bLength = USB_STRING_LEN(12U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
.unicode_string = {'G', 'D', '3', '2', '-', 'U', 'S', 'B', '_', 'M', 'S', 'C'}
};
/* USBD serial string */
-static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
+static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
{
.header =
- {
- .bLength = USB_STRING_LEN(12U),
- .bDescriptorType = USB_DESCTYPE_STR,
- }
+ {
+ .bLength = USB_STRING_LEN(12U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ }
};
/* USB string descriptor */
-static void *const usbd_msc_strings[] =
+static void *const usbd_msc_strings[] =
{
[STR_IDX_LANGID] = (uint8_t *)&usbd_language_id_desc,
[STR_IDX_MFC] = (uint8_t *)&manufacturer_string,
@@ -192,6 +274,12 @@ static void *const usbd_msc_strings[] =
usb_desc msc_desc = {
.dev_desc = (uint8_t *)&msc_dev_desc,
.config_desc = (uint8_t *)&msc_config_desc,
+
+#if defined(USE_USB_HS) && defined(USE_ULPI_PHY)
+ .other_speed_config_desc = (uint8_t *)&other_speed_msc_config_desc,
+ .qualifier_desc = (uint8_t *)&usbd_qualifier_desc,
+#endif /* USE_USB_HS && USE_ULPI_PHY */
+
.strings = usbd_msc_strings
};
@@ -212,10 +300,10 @@ static uint8_t msc_core_init (usb_dev *udev, uint8_t config_index)
udev->dev.class_data[USBD_MSC_INTERFACE] = (void *)&msc_handler;
- /* configure MSC TX endpoint */
+ /* configure MSC Tx endpoint */
usbd_ep_setup (udev, &(msc_config_desc.msc_epin));
- /* configure MSC RX endpoint */
+ /* configure MSC Rx endpoint */
usbd_ep_setup (udev, &(msc_config_desc.msc_epout));
/* initialize the BBB layer */
@@ -225,7 +313,7 @@ static uint8_t msc_core_init (usb_dev *udev, uint8_t config_index)
}
/*!
- \brief de-initialize the MSC device
+ \brief deinitialize the MSC device
\param[in] udev: pointer to USB device instance
\param[in] config_index: configuration index
\param[out] none
@@ -256,7 +344,7 @@ static uint8_t msc_core_req (usb_dev *udev, usb_req *req)
switch (req->bRequest) {
case BBB_GET_MAX_LUN :
- if((0U == req->wValue) &&
+ if((0U == req->wValue) &&
(1U == req->wLength) &&
(0x80U == (req->bmRequestType & 0x80U))) {
usbd_msc_maxlun = (uint8_t)usbd_mem_fops->mem_maxlun();
@@ -269,7 +357,7 @@ static uint8_t msc_core_req (usb_dev *udev, usb_req *req)
break;
case BBB_RESET :
- if((0U == req->wValue) &&
+ if((0U == req->wValue) &&
(0U == req->wLength) &&
(0x80U != (req->bmRequestType & 0x80U))) {
msc_bbb_reset(udev);
@@ -298,9 +386,7 @@ static uint8_t msc_core_req (usb_dev *udev, usb_req *req)
*/
static uint8_t msc_core_in (usb_dev *udev, uint8_t ep_num)
{
- if ((MSC_IN_EP & 0x7FU) == ep_num) {
- msc_bbb_data_in(udev, ep_num);
- }
+ msc_bbb_data_in (udev, ep_num);
return USBD_OK;
}
@@ -314,9 +400,7 @@ static uint8_t msc_core_in (usb_dev *udev, uint8_t ep_num)
*/
static uint8_t msc_core_out (usb_dev *udev, uint8_t ep_num)
{
- if (MSC_OUT_EP == ep_num) {
- msc_bbb_data_out (udev, ep_num);
- }
+ msc_bbb_data_out (udev, ep_num);
return USBD_OK;
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Source/usbd_msc_scsi.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Source/usbd_msc_scsi.c
index 7afae6fa30..870c3a6399 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Source/usbd_msc_scsi.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/msc/Source/usbd_msc_scsi.c
@@ -3,41 +3,83 @@
\brief USB SCSI layer functions
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
+
#include "usbd_enum.h"
#include "usbd_msc_bbb.h"
#include "usbd_msc_scsi.h"
-#include "usbd_msc_data.h"
+
+/* USB mass storage page 0 inquiry data */
+const uint8_t msc_page00_inquiry_data[] =
+{
+ 0x00U,
+ 0x00U,
+ 0x00U,
+ 0x00U,
+ (INQUIRY_PAGE00_LENGTH - 4U),
+ 0x80U,
+ 0x83U,
+};
+
+/* USB mass storage sense 6 data */
+const uint8_t msc_mode_sense6_data[] =
+{
+ 0x00U,
+ 0x00U,
+ 0x00U,
+ 0x00U,
+ 0x00U,
+ 0x00U,
+ 0x00U,
+ 0x00U
+};
+
+/* USB mass storage sense 10 data */
+const uint8_t msc_mode_sense10_data[] =
+{
+ 0x00U,
+ 0x06U,
+ 0x00U,
+ 0x00U,
+ 0x00U,
+ 0x00U,
+ 0x00U,
+ 0x00U
+};
/* local function prototypes ('static') */
static int8_t scsi_test_unit_ready (usb_core_driver *udev, uint8_t lun, uint8_t *params);
+static int8_t scsi_mode_select6 (usb_core_driver *udev, uint8_t lun, uint8_t *params);
+static int8_t scsi_mode_select10 (usb_core_driver *udev, uint8_t lun, uint8_t *params);
static int8_t scsi_inquiry (usb_core_driver *udev, uint8_t lun, uint8_t *params);
static int8_t scsi_read_format_capacity (usb_core_driver *udev, uint8_t lun, uint8_t *params);
static int8_t scsi_read_capacity10 (usb_core_driver *udev, uint8_t lun, uint8_t *params);
@@ -96,7 +138,7 @@ int8_t scsi_process_cmd(usb_core_driver *udev, uint8_t lun, uint8_t *params)
return scsi_read_capacity10 (udev, lun, params);
case SCSI_READ10:
- return scsi_read10 (udev, lun, params);
+ return scsi_read10 (udev, lun, params);
case SCSI_WRITE10:
return scsi_write10 (udev, lun, params);
@@ -110,6 +152,12 @@ int8_t scsi_process_cmd(usb_core_driver *udev, uint8_t lun, uint8_t *params)
case SCSI_READ_TOC_DATA:
return scsi_toc_cmd_read (udev, lun, params);
+ case SCSI_MODE_SELECT6:
+ return scsi_mode_select6 (udev, lun, params);
+
+ case SCSI_MODE_SELECT10:
+ return scsi_mode_select10 (udev, lun, params);
+
default:
scsi_sense_code (udev, lun, ILLEGAL_REQUEST, INVALID_CDB);
return -1;
@@ -130,7 +178,7 @@ void scsi_sense_code (usb_core_driver *udev, uint8_t lun, uint8_t skey, uint8_t
usbd_msc_handler *msc = (usbd_msc_handler *)udev->dev.class_data[USBD_MSC_INTERFACE];
msc->scsi_sense[msc->scsi_sense_tail].SenseKey = skey;
- msc->scsi_sense[msc->scsi_sense_tail].ASC = asc << 8U;
+ msc->scsi_sense[msc->scsi_sense_tail].ASC = asc;
msc->scsi_sense_tail++;
if (SENSE_LIST_DEEPTH == msc->scsi_sense_tail) {
@@ -163,9 +211,39 @@ static int8_t scsi_test_unit_ready (usb_core_driver *udev, uint8_t lun, uint8_t
return -1;
}
- if (1U == msc->scsi_disk_pop) {
- usbd_disconnect (udev);
- }
+ msc->bbb_datalen = 0U;
+
+ return 0;
+}
+
+/*!
+ \brief process Inquiry command
+ \param[in] udev: pointer to USB device instance
+ \param[in] lun: logical unit number
+ \param[in] params: command parameters
+ \param[out] none
+ \retval status
+*/
+static int8_t scsi_mode_select6 (usb_core_driver *udev, uint8_t lun, uint8_t *params)
+{
+ usbd_msc_handler *msc = (usbd_msc_handler *)udev->dev.class_data[USBD_MSC_INTERFACE];
+
+ msc->bbb_datalen = 0U;
+
+ return 0;
+}
+
+/*!
+ \brief process Inquiry command
+ \param[in] udev: pointer to USB device instance
+ \param[in] lun: logical unit number
+ \param[in] params: command parameters
+ \param[out] none
+ \retval status
+*/
+static int8_t scsi_mode_select10 (usb_core_driver *udev, uint8_t lun, uint8_t *params)
+{
+ usbd_msc_handler *msc = (usbd_msc_handler *)udev->dev.class_data[USBD_MSC_INTERFACE];
msc->bbb_datalen = 0U;
@@ -347,8 +425,8 @@ static int8_t scsi_request_sense (usb_core_driver *udev, uint8_t lun, uint8_t *p
if ((msc->scsi_sense_head != msc->scsi_sense_tail)) {
msc->bbb_data[2] = msc->scsi_sense[msc->scsi_sense_head].SenseKey;
- msc->bbb_data[12] = msc->scsi_sense[msc->scsi_sense_head].ASCQ;
- msc->bbb_data[13] = msc->scsi_sense[msc->scsi_sense_head].ASC;
+ msc->bbb_data[12] = msc->scsi_sense[msc->scsi_sense_head].ASC;
+ msc->bbb_data[13] = msc->scsi_sense[msc->scsi_sense_head].ASCQ;
msc->scsi_sense_head++;
if (msc->scsi_sense_head == SENSE_LIST_DEEPTH) {
@@ -506,9 +584,9 @@ static int8_t scsi_write10 (usb_core_driver *udev, uint8_t lun, uint8_t *params)
/* prepare endpoint to receive first data packet */
msc->bbb_state = BBB_DATA_OUT;
- usbd_ep_recev (udev,
- MSC_OUT_EP,
- msc->bbb_data,
+ usbd_ep_recev (udev,
+ MSC_OUT_EP,
+ msc->bbb_data,
USB_MIN (msc->scsi_blk_len, MSC_MEDIA_PACKET_SIZE));
} else { /* write process ongoing */
return scsi_process_write (udev, lun);
@@ -580,12 +658,12 @@ static int8_t scsi_process_read (usb_core_driver *udev, uint8_t lun)
uint32_t len = USB_MIN(msc->scsi_blk_len, MSC_MEDIA_PACKET_SIZE);
if (usbd_mem_fops->mem_read(lun,
- msc->bbb_data,
- msc->scsi_blk_addr,
+ msc->bbb_data,
+ msc->scsi_blk_addr,
(uint16_t)(len / msc->scsi_blk_size[lun])) < 0) {
scsi_sense_code(udev, lun, HARDWARE_ERROR, UNRECOVERED_READ_ERROR);
- return -1;
+ return -1;
}
usbd_ep_send (udev, MSC_IN_EP, msc->bbb_data, len);
@@ -617,8 +695,8 @@ static int8_t scsi_process_write (usb_core_driver *udev, uint8_t lun)
uint32_t len = USB_MIN(msc->scsi_blk_len, MSC_MEDIA_PACKET_SIZE);
if (usbd_mem_fops->mem_write (lun,
- msc->bbb_data,
- msc->scsi_blk_addr,
+ msc->bbb_data,
+ msc->scsi_blk_addr,
(uint16_t)(len / msc->scsi_blk_size[lun])) < 0) {
scsi_sense_code(udev, lun, HARDWARE_ERROR, WRITE_FAULT);
@@ -635,9 +713,9 @@ static int8_t scsi_process_write (usb_core_driver *udev, uint8_t lun)
msc_bbb_csw_send (udev, CSW_CMD_PASSED);
} else {
/* prepare endpoint to receive next packet */
- usbd_ep_recev (udev,
- MSC_OUT_EP,
- msc->bbb_data,
+ usbd_ep_recev (udev,
+ MSC_OUT_EP,
+ msc->bbb_data,
USB_MIN (msc->scsi_blk_len, MSC_MEDIA_PACKET_SIZE));
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/printer/Include/printer_core.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/printer/Include/printer_core.h
index 88c933ac94..da83a69f0b 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/printer/Include/printer_core.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/printer/Include/printer_core.h
@@ -3,32 +3,34 @@
\brief the header file of USB printer device class core functions
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/printer/Source/printer_core.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/printer/Source/printer_core.c
index 71818f03b9..67e49f18ff 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/printer/Source/printer_core.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/class/printer/Source/printer_core.c
@@ -3,32 +3,34 @@
\brief USB printer device class core functions
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -61,10 +63,10 @@ __ALIGN_BEGIN uint8_t PRINTER_DEVICE_ID[DEVICE_ID_LEN] __ALIGN_END =
__ALIGN_BEGIN const usb_desc_dev printer_dev_desc __ALIGN_END =
{
.header =
- {
- .bLength = USB_DEV_DESC_LEN,
- .bDescriptorType = USB_DESCTYPE_DEV,
- },
+ {
+ .bLength = USB_DEV_DESC_LEN,
+ .bDescriptorType = USB_DESCTYPE_DEV,
+ },
.bcdUSB = 0x0200U,
.bDeviceClass = 0x00U,
.bDeviceSubClass = 0x00U,
@@ -80,15 +82,15 @@ __ALIGN_BEGIN const usb_desc_dev printer_dev_desc __ALIGN_END =
};
/* USB device configuration descriptor */
-__ALIGN_BEGIN const usb_printer_desc_config_set printer_config_desc __ALIGN_END =
+__ALIGN_BEGIN const usb_printer_desc_config_set printer_config_desc __ALIGN_END =
{
- .config =
+ .config =
{
.header =
- {
- .bLength = sizeof(usb_desc_config),
- .bDescriptorType = USB_DESCTYPE_CONFIG
- },
+ {
+ .bLength = sizeof(usb_desc_config),
+ .bDescriptorType = USB_DESCTYPE_CONFIG
+ },
.wTotalLength = USB_PRINTER_CONFIG_DESC_LEN,
.bNumInterfaces = 0x01U,
.bConfigurationValue = 0x01U,
@@ -100,10 +102,10 @@ __ALIGN_BEGIN const usb_printer_desc_config_set printer_config_desc __ALIGN_END
.printer_itf =
{
.header =
- {
- .bLength = sizeof(usb_desc_itf),
- .bDescriptorType = USB_DESCTYPE_ITF
- },
+ {
+ .bLength = sizeof(usb_desc_itf),
+ .bDescriptorType = USB_DESCTYPE_ITF
+ },
.bInterfaceNumber = 0x00U,
.bAlternateSetting = 0x00U,
.bNumEndpoints = 0x02U,
@@ -116,10 +118,10 @@ __ALIGN_BEGIN const usb_printer_desc_config_set printer_config_desc __ALIGN_END
.printer_epin =
{
.header =
- {
- .bLength = sizeof(usb_desc_ep),
- .bDescriptorType = USB_DESCTYPE_EP
- },
+ {
+ .bLength = sizeof(usb_desc_ep),
+ .bDescriptorType = USB_DESCTYPE_EP
+ },
.bEndpointAddress = PRINTER_IN_EP,
.bmAttributes = USB_EP_ATTR_BULK,
.wMaxPacketSize = PRINTER_IN_PACKET,
@@ -129,10 +131,10 @@ __ALIGN_BEGIN const usb_printer_desc_config_set printer_config_desc __ALIGN_END
.printer_epout =
{
.header =
- {
- .bLength = sizeof(usb_desc_ep),
- .bDescriptorType = USB_DESCTYPE_EP
- },
+ {
+ .bLength = sizeof(usb_desc_ep),
+ .bDescriptorType = USB_DESCTYPE_EP
+ },
.bEndpointAddress = PRINTER_OUT_EP,
.bmAttributes = USB_EP_ATTR_BULK,
.wMaxPacketSize = PRINTER_OUT_PACKET,
@@ -141,50 +143,50 @@ __ALIGN_BEGIN const usb_printer_desc_config_set printer_config_desc __ALIGN_END
};
/* USB language ID Descriptor */
-static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_LANGID usbd_language_id_desc __ALIGN_END =
{
- .header =
- {
- .bLength = sizeof(usb_desc_LANGID),
- .bDescriptorType = USB_DESCTYPE_STR,
- },
+ .header =
+ {
+ .bLength = sizeof(usb_desc_LANGID),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
.wLANGID = ENG_LANGID
};
/* USB manufacture string */
-static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str manufacturer_string __ALIGN_END =
{
- .header =
- {
- .bLength = USB_STRING_LEN(10U),
- .bDescriptorType = USB_DESCTYPE_STR,
- },
+ .header =
+ {
+ .bLength = USB_STRING_LEN(10U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
.unicode_string = {'G', 'i', 'g', 'a', 'D', 'e', 'v', 'i', 'c', 'e'}
};
/* USB product string */
-static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
+static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END =
{
- .header =
- {
- .bLength = USB_STRING_LEN(16U),
- .bDescriptorType = USB_DESCTYPE_STR,
- },
+ .header =
+ {
+ .bLength = USB_STRING_LEN(16U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ },
.unicode_string = {'G', 'D', '3', '2', '-', 'U', 'S', 'B', '_', 'P', 'r', 'i', 'n', 't', 'e', 'r'}
};
/* USBD serial string */
-static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
+static __ALIGN_BEGIN usb_desc_str serial_string __ALIGN_END =
{
- .header =
- {
- .bLength = USB_STRING_LEN(12U),
- .bDescriptorType = USB_DESCTYPE_STR,
- }
+ .header =
+ {
+ .bLength = USB_STRING_LEN(12U),
+ .bDescriptorType = USB_DESCTYPE_STR,
+ }
};
/* USB string descriptor */
-static void *const usbd_msc_strings[] =
+static void *const usbd_msc_strings[] =
{
[STR_IDX_LANGID] = (uint8_t *)&usbd_language_id_desc,
[STR_IDX_MFC] = (uint8_t *)&manufacturer_string,
@@ -217,17 +219,17 @@ usb_class_core usbd_printer_cb = {
/*!
\brief initialize the printer device
- \param[in] udev: pointer to USB device instance
+ \param[in] udev: pointer to usb device instance
\param[in] config_index: configuration index
\param[out] none
- \retval USB device operation status
+ \retval usb device operation status
*/
static uint8_t printer_init (usb_dev *udev, uint8_t config_index)
{
- /* initialize the data TX endpoint */
+ /* initialize the data Tx endpoint */
usbd_ep_setup (udev, &(printer_config_desc.printer_epin));
- /* initialize the data RX endpoint */
+ /* initialize the data Rx endpoint */
usbd_ep_setup (udev, &(printer_config_desc.printer_epout));
/* prepare to receive data */
@@ -238,14 +240,14 @@ static uint8_t printer_init (usb_dev *udev, uint8_t config_index)
/*!
\brief deinitialize the printer device
- \param[in] udev: pointer to USB device instance
+ \param[in] udev: pointer to usb device instance
\param[in] config_index: configuration index
\param[out] none
- \retval USB device operation status
+ \retval usb device operation status
*/
static uint8_t printer_deinit (usb_dev *udev, uint8_t config_index)
{
- /* deinitialize the data TX/RX endpoint */
+ /* deinitialize the data Tx/Rx endpoint */
usbd_ep_clear (udev, PRINTER_IN_EP);
usbd_ep_clear (udev, PRINTER_OUT_EP);
@@ -254,10 +256,10 @@ static uint8_t printer_deinit (usb_dev *udev, uint8_t config_index)
/*!
\brief handle the printer class-specific requests
- \param[in] udev: pointer to USB device instance
+ \param[in] udev: pointer to usb device instance
\param[in] req: device class-specific request
\param[out] none
- \retval USB device operation status
+ \retval usb device operation status
*/
static uint8_t printer_req(usb_dev *udev, usb_req *req)
{
@@ -292,9 +294,9 @@ static uint8_t printer_req(usb_dev *udev, usb_req *req)
\param[out] none
\retval USB device operation status
*/
-static uint8_t printer_in (usb_dev *udev, uint8_t ep_num)
+static uint8_t printer_in (usb_dev *udev, uint8_t ep_num)
{
- return USBD_OK;
+ return USBD_OK;
}
/*!
@@ -304,7 +306,7 @@ static uint8_t printer_in (usb_dev *udev, uint8_t ep_num)
\param[out] none
\retval USB device operation status
*/
-static uint8_t printer_out (usb_dev *udev, uint8_t ep_num)
+static uint8_t printer_out (usb_dev *udev, uint8_t ep_num)
{
- return USBD_OK;
+ return USBD_OK;
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Include/usbd_core.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Include/usbd_core.h
index 8446487b1d..d037bdc310 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Include/usbd_core.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Include/usbd_core.h
@@ -1,34 +1,36 @@
/*!
\file usbd_core.h
- \brief USB device mode core functions protype
+ \brief USB device mode core functions prototype
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -42,7 +44,7 @@ typedef enum
{
USBD_OK = 0U, /*!< status OK */
USBD_BUSY, /*!< status busy */
- USBD_FAIL, /*!< status fail */
+ USBD_FAIL /*!< status fail */
} usbd_status;
enum _usbd_status {
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Include/usbd_enum.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Include/usbd_enum.h
index ffa7f0ca93..d3bf1fa712 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Include/usbd_enum.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Include/usbd_enum.h
@@ -3,32 +3,34 @@
\brief USB enumeration definitions
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -57,11 +59,7 @@ enum _str_index
STR_IDX_SERIAL = 0x3U, /* serial string index */
STR_IDX_CONFIG = 0x4U, /* configuration string index */
STR_IDX_ITF = 0x5U, /* interface string index */
-#ifndef WINUSB_EXEMPT_DRIVER
- STR_IDX_MAX = 0x6U, /* string maximum index */
-#else
STR_IDX_MAX = 0xEFU, /* string maximum index */
-#endif /* WINUSB_EXEMPT_DRIVER */
};
typedef enum _usb_pwrsta {
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Include/usbd_transc.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Include/usbd_transc.h
index 014ea34aee..9c620ff77f 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Include/usbd_transc.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Include/usbd_transc.h
@@ -3,32 +3,34 @@
\brief USB transaction core functions prototype
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Source/usbd_core.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Source/usbd_core.c
index 065dd3ad15..823f8a7990 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Source/usbd_core.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Source/usbd_core.c
@@ -3,32 +3,34 @@
\brief USB device mode core functions
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -76,7 +78,7 @@ void usbd_init (usb_core_driver *udev, usb_core_enum core, usb_desc *desc, usb_c
#ifndef USE_OTG_MODE
usb_curmode_set(&udev->regs, DEVICE_MODE);
-#endif
+#endif /* USE_OTG_MODE */
/* initializes device mode */
(void)usb_devcore_init (udev);
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Source/usbd_enum.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Source/usbd_enum.c
index 21094d5df4..3358149a69 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Source/usbd_enum.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Source/usbd_enum.c
@@ -3,32 +3,34 @@
\brief USB enumeration function
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -42,22 +44,26 @@ extern usbd_status usbd_OEM_req(usb_dev *udev, usb_req *req);
#endif /* WINUSB_EXEMPT_DRIVER */
/* local function prototypes ('static') */
-static usb_reqsta _usb_std_reserved (usb_core_driver *udev, usb_req *req);
-static uint8_t* _usb_dev_desc_get (usb_core_driver *udev, uint8_t index, uint16_t *len);
-static uint8_t* _usb_config_desc_get (usb_core_driver *udev, uint8_t index, uint16_t *len);
-static uint8_t* _usb_bos_desc_get (usb_core_driver *udev, uint8_t index, uint16_t *len);
-static uint8_t* _usb_str_desc_get (usb_core_driver *udev, uint8_t index, uint16_t *len);
-static usb_reqsta _usb_std_getstatus (usb_core_driver *udev, usb_req *req);
-static usb_reqsta _usb_std_clearfeature (usb_core_driver *udev, usb_req *req);
-static usb_reqsta _usb_std_setfeature (usb_core_driver *udev, usb_req *req);
-static usb_reqsta _usb_std_setaddress (usb_core_driver *udev, usb_req *req);
-static usb_reqsta _usb_std_getdescriptor (usb_core_driver *udev, usb_req *req);
-static usb_reqsta _usb_std_setdescriptor (usb_core_driver *udev, usb_req *req);
-static usb_reqsta _usb_std_getconfiguration (usb_core_driver *udev, usb_req *req);
-static usb_reqsta _usb_std_setconfiguration (usb_core_driver *udev, usb_req *req);
-static usb_reqsta _usb_std_getinterface (usb_core_driver *udev, usb_req *req);
-static usb_reqsta _usb_std_setinterface (usb_core_driver *udev, usb_req *req);
-static usb_reqsta _usb_std_synchframe (usb_core_driver *udev, usb_req *req);
+static usb_reqsta _usb_std_reserved (usb_core_driver *udev, usb_req *req);
+static uint8_t* _usb_dev_desc_get (usb_core_driver *udev, uint8_t index, uint16_t *len);
+static uint8_t* _usb_config_desc_get (usb_core_driver *udev, uint8_t index, uint16_t *len);
+#if defined(USE_USB_HS) && defined(USE_ULPI_PHY)
+static uint8_t* _usb_other_speed_config_desc_get (usb_core_driver *udev, uint8_t index, uint16_t *len);
+static uint8_t* _usb_qualifier_desc_get (usb_core_driver *udev, uint8_t index, uint16_t *len);
+#endif
+static uint8_t* _usb_bos_desc_get (usb_core_driver *udev, uint8_t index, uint16_t *len);
+static uint8_t* _usb_str_desc_get (usb_core_driver *udev, uint8_t index, uint16_t *len);
+static usb_reqsta _usb_std_getstatus (usb_core_driver *udev, usb_req *req);
+static usb_reqsta _usb_std_clearfeature (usb_core_driver *udev, usb_req *req);
+static usb_reqsta _usb_std_setfeature (usb_core_driver *udev, usb_req *req);
+static usb_reqsta _usb_std_setaddress (usb_core_driver *udev, usb_req *req);
+static usb_reqsta _usb_std_getdescriptor (usb_core_driver *udev, usb_req *req);
+static usb_reqsta _usb_std_setdescriptor (usb_core_driver *udev, usb_req *req);
+static usb_reqsta _usb_std_getconfiguration (usb_core_driver *udev, usb_req *req);
+static usb_reqsta _usb_std_setconfiguration (usb_core_driver *udev, usb_req *req);
+static usb_reqsta _usb_std_getinterface (usb_core_driver *udev, usb_req *req);
+static usb_reqsta _usb_std_setinterface (usb_core_driver *udev, usb_req *req);
+static usb_reqsta _usb_std_synchframe (usb_core_driver *udev, usb_req *req);
static usb_reqsta (*_std_dev_req[])(usb_core_driver *udev, usb_req *req) =
{
@@ -78,9 +84,13 @@ static usb_reqsta (*_std_dev_req[])(usb_core_driver *udev, usb_req *req) =
/* get standard descriptor handler */
static uint8_t* (*std_desc_get[])(usb_core_driver *udev, uint8_t index, uint16_t *len) = {
- [(uint8_t)USB_DESCTYPE_DEV - 1U] = _usb_dev_desc_get,
- [(uint8_t)USB_DESCTYPE_CONFIG - 1U] = _usb_config_desc_get,
- [(uint8_t)USB_DESCTYPE_STR - 1U] = _usb_str_desc_get
+ [(uint8_t)USB_DESCTYPE_DEV - 1U] = _usb_dev_desc_get,
+ [(uint8_t)USB_DESCTYPE_CONFIG - 1U] = _usb_config_desc_get,
+ [(uint8_t)USB_DESCTYPE_STR - 1U] = _usb_str_desc_get,
+#if defined(USE_USB_HS) && defined(USE_ULPI_PHY)
+ [(uint8_t)USB_DESCTYPE_DEV_QUALIFIER - 3U] = _usb_qualifier_desc_get,
+ [(uint8_t)USB_DESCTYPE_OTHER_SPD_CONFIG - 3U] = _usb_other_speed_config_desc_get,
+#endif
};
/*!
@@ -167,7 +177,7 @@ void int_to_unicode (uint32_t value, uint8_t *pbuf, uint8_t len)
if ((value >> 28U) < 0x0AU) {
pbuf[2U * index] = (uint8_t)((value >> 28U) + '0');
} else {
- pbuf[2U * index] = (uint8_t)((value >> 28U) + 'A' - 10U);
+ pbuf[2U * index] = (uint8_t)((value >> 28U) + 'A' - 10U);
}
value = value << 4U;
@@ -252,11 +262,47 @@ static uint8_t* _usb_config_desc_get (usb_core_driver *udev, uint8_t index, uint
{
(void)index;
- *len = udev->dev.desc->config_desc[2];
+ *len = udev->dev.desc->config_desc[2] | (udev->dev.desc->config_desc[3]<< 8U);
return udev->dev.desc->config_desc;
}
+#if defined(USE_USB_HS) && defined(USE_ULPI_PHY)
+
+/*!
+ \brief get the other speed configuration descriptor
+ \brief[in] udev: pointer to USB device instance
+ \brief[in] index: no use
+ \param[out] len: data length pointer
+ \retval descriptor buffer pointer
+*/
+static uint8_t* _usb_other_speed_config_desc_get (usb_core_driver *udev, uint8_t index, uint16_t *len)
+{
+ (void)index;
+
+ *len = udev->dev.desc->other_speed_config_desc[2];
+
+ return udev->dev.desc->other_speed_config_desc;
+}
+
+/*!
+ \brief get the other speed configuration descriptor
+ \brief[in] udev: pointer to USB device instance
+ \brief[in] index: no use
+ \param[out] len: data length pointer
+ \retval descriptor buffer pointer
+*/
+static uint8_t* _usb_qualifier_desc_get (usb_core_driver *udev, uint8_t index, uint16_t *len)
+{
+ (void)index;
+
+ *len = udev->dev.desc->qualifier_desc[0];
+
+ return udev->dev.desc->qualifier_desc;
+}
+
+#endif /* USE_USB_HS && USE_ULPI_PHY */
+
/*!
\brief get the BOS descriptor
\brief[in] udev: pointer to USB device instance
@@ -525,8 +571,18 @@ static usb_reqsta _usb_std_getdescriptor (usb_core_driver *udev, usb_req *req)
case USB_DESCTYPE_ITF:
case USB_DESCTYPE_EP:
+ break;
+
+#if defined(USE_USB_HS) && defined(USE_ULPI_PHY)
case USB_DESCTYPE_DEV_QUALIFIER:
+ transc->xfer_buf = std_desc_get[desc_type - 3U](udev, desc_index, (uint16_t *)&(transc->remain_len));
+ break;
+
case USB_DESCTYPE_OTHER_SPD_CONFIG:
+ transc->xfer_buf = std_desc_get[desc_type - 3U](udev, desc_index, (uint16_t *)&(transc->remain_len));
+ break;
+#endif
+
case USB_DESCTYPE_ITF_POWER:
break;
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Source/usbd_transc.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Source/usbd_transc.c
index a4349ee3a1..a076977308 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Source/usbd_transc.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/device/core/Source/usbd_transc.c
@@ -3,32 +3,34 @@
\brief USB transaction core functions
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -186,8 +188,8 @@ uint8_t usbd_out_transc (usb_core_driver *udev, uint8_t ep_num)
case USB_CTL_LAST_DATA_OUT:
if (udev->dev.cur_status == (uint8_t)USBD_CONFIGURED) {
- if (udev->dev.class_core->data_out != NULL) {
- (void)udev->dev.class_core->data_out (udev, 0U);
+ if (udev->dev.class_core->ctlx_out != NULL) {
+ (void)udev->dev.class_core->ctlx_out (udev);
}
}
@@ -240,8 +242,8 @@ uint8_t usbd_in_transc (usb_core_driver *udev, uint8_t ep_num)
udev->dev.control.ctl_zlp = 0U;
} else {
if (udev->dev.cur_status == (uint8_t)USBD_CONFIGURED) {
- if (udev->dev.class_core->data_in != NULL) {
- (void)udev->dev.class_core->data_in (udev, 0U);
+ if (udev->dev.class_core->ctlx_in != NULL) {
+ (void)udev->dev.class_core->ctlx_in (udev);
}
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_core.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_core.h
index daefca3de5..65c3dbf81e 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_core.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_core.h
@@ -3,32 +3,34 @@
\brief USB core low level driver header file
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -105,6 +107,11 @@ typedef struct _usb_desc {
uint8_t *config_desc; /*!< configure descriptor */
uint8_t *bos_desc; /*!< BOS descriptor */
+#if defined(USE_USB_HS) && defined(USE_ULPI_PHY)
+ uint8_t *other_speed_config_desc; /*!< other speed configuration descriptor */
+ uint8_t *qualifier_desc; /*!< qualifier descriptor */
+#endif
+
void* const *strings; /*!< string descriptor */
} usb_desc;
@@ -162,6 +169,9 @@ typedef struct _usb_class_core
uint8_t (*set_intf) (usb_dev *udev, usb_req *req); /*!< device set interface callback */
+ uint8_t (*ctlx_in) (usb_dev *udev); /*!< device contrl in callback */
+ uint8_t (*ctlx_out) (usb_dev *udev);
+
uint8_t (*data_in) (usb_dev *udev, uint8_t ep_num); /*!< device data in handler */
uint8_t (*data_out) (usb_dev *udev, uint8_t ep_num); /*!< device data out handler */
@@ -232,8 +242,9 @@ typedef struct _usb_pipe
uint16_t mps;
} ep;
- uint8_t ping;
- uint32_t DPID;
+ __IO uint8_t supp_ping;
+ __IO uint8_t do_ping;
+ __IO uint32_t DPID;
uint8_t *xfer_buf;
uint32_t xfer_len;
@@ -251,7 +262,7 @@ typedef struct _usb_host_drv
{
__IO uint32_t connect_status;
__IO uint32_t port_enabled;
- __IO uint32_t backup_xfercount[USBFS_MAX_TX_FIFOS];
+ uint32_t backup_xfercount[USBFS_MAX_TX_FIFOS];
usb_pipe pipe[USBFS_MAX_TX_FIFOS];
void *data;
@@ -283,7 +294,11 @@ typedef struct _usb_core_driver
*/
__STATIC_INLINE uint32_t usb_coreintr_get(usb_core_regs *usb_regs)
{
- return usb_regs->gr->GINTEN & usb_regs->gr->GINTF;
+ uint32_t reg_data = usb_regs->gr->GINTEN;
+
+ reg_data &= usb_regs->gr->GINTF;
+
+ return reg_data;
}
/*!
@@ -327,13 +342,13 @@ __STATIC_INLINE void usb_globalint_disable(usb_core_regs *usb_regs)
usb_status usb_basic_init (usb_core_basic *usb_basic, usb_core_regs *usb_regs, usb_core_enum usb_core);
/* initializes the USB controller registers and prepares the core device mode or host mode operation */
usb_status usb_core_init (usb_core_basic usb_basic, usb_core_regs *usb_regs);
-/* write a packet into the TX FIFO associated with the endpoint */
+/* write a packet into the Tx FIFO associated with the endpoint */
usb_status usb_txfifo_write (usb_core_regs *usb_regs, uint8_t *src_buf, uint8_t fifo_num, uint16_t byte_count);
-/* read a packet from the RX FIFO associated with the endpoint */
+/* read a packet from the Rx FIFO associated with the endpoint */
void *usb_rxfifo_read (usb_core_regs *usb_regs, uint8_t *dest_buf, uint16_t byte_count);
-/* flush a TX FIFO or all TX FIFOs */
+/* flush a Tx FIFO or all Tx FIFOs */
usb_status usb_txfifo_flush (usb_core_regs *usb_regs, uint8_t fifo_num);
-/* flush the entire RX FIFO */
+/* flush the entire Rx FIFO */
usb_status usb_rxfifo_flush (usb_core_regs *usb_regs);
/* set endpoint or channel TX FIFO size */
void usb_set_txfifo(usb_core_regs *usb_regs, uint8_t fifo, uint16_t size);
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_dev.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_dev.h
index 8c0431bc1f..c187e8693f 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_dev.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_dev.h
@@ -3,32 +3,34 @@
\brief USB device low level driver header file
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -130,7 +132,7 @@ __STATIC_INLINE uint32_t usb_iepintnum_read (usb_core_driver *udev)
uint32_t value = udev->regs.dr->DAEPINT;
value &= udev->regs.dr->DAEPINTEN;
-
+
return value & DAEPINT_IEPITB;
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_host.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_host.h
index 55ac908d52..53c5183eef 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_host.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_host.h
@@ -3,32 +3,34 @@
\brief USB host mode low level driver header file
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -120,4 +122,4 @@ usb_status usb_pipe_ping (usb_core_driver *udev, uint8_t pipe_num);
/* stop the USB host and clean up FIFO */
void usb_host_stop (usb_core_driver *udev);
-#endif /* __DRV_USB_HOST_H */
+#endif /* __DRV_USB_HOST_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_hw.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_hw.h
index 725a8d48b0..ff65e2bd9c 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_hw.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_hw.h
@@ -3,32 +3,34 @@
\brief usb hardware configuration header file
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -52,20 +54,11 @@ void usb_udelay (const uint32_t usec);
void usb_mdelay (const uint32_t msec);
/* configures system clock after wakeup from STOP mode */
void system_clk_config_stop(void);
-
-/* configure the CTC peripheral */
-#ifdef USE_IRC48M
- void ctc_config(void);
-#endif /* USE_IRC48M */
-
#ifdef USE_HOST_MODE
- void systick_config(void);
-
- /* configure USB VBus */
- void usb_vbus_config (void);
-
- /* drive USB VBus */
- void usb_vbus_drive (uint8_t State);
+/* configure USB VBus */
+void usb_vbus_config (void);
+/* drive USB VBus */
+void usb_vbus_drive (uint8_t State);
#endif /* USE_HOST_MODE */
#endif /* __DRV_USB_HW_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_regs.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_regs.h
index 9620357a5a..ae93df8185 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_regs.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usb_regs.h
@@ -3,32 +3,34 @@
\brief USB cell registers definition and handle macros
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -302,9 +304,7 @@ typedef struct _usb_regs
#define HNPTFLEN_HNPTXFD BITS(16, 31) /*!< non-periodic Tx FIFO depth */
#define HNPTFLEN_HNPTXRSAR BITS(0, 15) /*!< non-periodic Tx RAM start address */
-/**
- * @brief USB IN endpoint 0 transmit FIFO length register bits definitions
- */
+/* USB IN endpoint 0 transmit FIFO length register bits definitions */
#define DIEP0TFLEN_IEP0TXFD BITS(16, 31) /*!< IN Endpoint 0 Tx FIFO depth */
#define DIEP0TFLEN_IEP0TXRSAR BITS(0, 15) /*!< IN Endpoint 0 TX RAM start address */
@@ -356,7 +356,6 @@ typedef struct _usb_regs
#define HPTFQSTAT_TYPE BITS(25, 26) /*!< token type */
#define HPTFQSTAT_TMF BIT(24) /*!< terminate flag */
-
#define TFQSTAT_TXFS BITS(0, 15)
#define TFQSTAT_CNUM BITS(27, 30)
@@ -432,12 +431,11 @@ typedef struct _usb_regs
/* host channel-x DMA address register bits definitions */
#define HCHDMAADDR_DMAADDR BITS(0, 31) /*!< DMA address */
+#define PORT_SPEED(x) (((uint32_t)(x) << 17) & HPCS_PS) /*!< Port speed */
-#define PORT_SPEED(x) (((uint32_t)(x) << 17) & HPCS_PS) /*!< Port speed */
-
-#define PORT_SPEED_HIGH PORT_SPEED(0U) /*!< high speed */
-#define PORT_SPEED_FULL PORT_SPEED(1U) /*!< full speed */
-#define PORT_SPEED_LOW PORT_SPEED(2U) /*!< low speed */
+#define PORT_SPEED_HIGH PORT_SPEED(0U) /*!< high speed */
+#define PORT_SPEED_FULL PORT_SPEED(1U) /*!< full speed */
+#define PORT_SPEED_LOW PORT_SPEED(2U) /*!< low speed */
#define PIPE_CTL_DAR(x) (((uint32_t)(x) << 22) & HCHCTL_DAR) /*!< device address */
#define PIPE_CTL_EPTYPE(x) (((uint32_t)(x) << 18) & HCHCTL_EPTYPE) /*!< endpoint type */
@@ -621,13 +619,13 @@ extern const uint32_t PIPE_DPID[2];
#define FRAME_INTERVAL_90 DCFG_PFRI(2U) /*!< 90% of the frame time */
#define FRAME_INTERVAL_95 DCFG_PFRI(3U) /*!< 95% of the frame time */
-#define DCFG_DEVSPEED(regval) (DCFG_DS & ((regval) << 0)) /*!< device speed configuration */
+#define DCFG_DEVSPEED(regval) (DCFG_DS & ((regval) << 0)) /*!< device speed configuration */
#define USB_SPEED_EXP_HIGH DCFG_DEVSPEED(0U) /*!< device external PHY high speed */
#define USB_SPEED_EXP_FULL DCFG_DEVSPEED(1U) /*!< device external PHY full speed */
#define USB_SPEED_INP_FULL DCFG_DEVSPEED(3U) /*!< device internal PHY full speed */
-#define DEP0_MPL(regval) (DEP0CTL_MPL & ((regval) << 0)) /*!< maximum packet length configuration */
+#define DEP0_MPL(regval) (DEP0CTL_MPL & ((regval) << 0)) /*!< maximum packet length configuration */
#define EP0MPL_64 DEP0_MPL(0U) /*!< maximum packet length 64 bytes */
#define EP0MPL_32 DEP0_MPL(1U) /*!< maximum packet length 32 bytes */
@@ -658,5 +656,9 @@ extern const uint32_t PIPE_DPID[2];
#define EP2_IN ((uint8_t)0x82) /*!< endpoint in 2 */
#define EP3_OUT ((uint8_t)0x03) /*!< endpoint out 3 */
#define EP3_IN ((uint8_t)0x83) /*!< endpoint in 3 */
+#define EP4_OUT ((uint8_t)0x04) /*!< endpoint out 4 */
+#define EP4_IN ((uint8_t)0x84) /*!< endpoint in 4 */
+#define EP5_OUT ((uint8_t)0x05) /*!< endpoint out 5 */
+#define EP5_IN ((uint8_t)0x85) /*!< endpoint in 5 */
#endif /* __DRV_USB_REGS_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usbd_int.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usbd_int.h
index dc4a70cc8d..eb79e15d27 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usbd_int.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usbd_int.h
@@ -3,32 +3,34 @@
\brief USB device mode interrupt header file
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usbh_int.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usbh_int.h
index d42146e46d..99a606dad7 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usbh_int.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Include/drv_usbh_int.h
@@ -3,32 +3,34 @@
\brief USB host mode interrupt management header file
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -38,16 +40,14 @@ OF SUCH DAMAGE.
#include "drv_usb_host.h"
#include "usbh_core.h"
-typedef struct _usbh_int_cb
+typedef struct _usbh_ev_cb
{
uint8_t (*connect) (usbh_host *uhost);
uint8_t (*disconnect) (usbh_host *uhost);
- uint8_t (*port_enabled) (usbh_host *uhost);
- uint8_t (*port_disabled) (usbh_host *uhost);
uint8_t (*SOF) (usbh_host *uhost);
-} usbh_int_cb;
+} usbh_ev_cb;
-extern usbh_int_cb *usbh_int_fop;
+extern usbh_ev_cb *usbh_int_fop;
/* function declarations */
/* handle global host interrupt */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usb_core.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usb_core.c
index 50c1544214..ba9ee199b2 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usb_core.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usb_core.c
@@ -3,32 +3,34 @@
\brief USB core driver which can operate in host and device mode
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -39,15 +41,15 @@ OF SUCH DAMAGE.
static void usb_core_reset (usb_core_regs *usb_regs);
/*!
- \brief configure USB core basic
+ \brief configure USB core basic
\param[in] usb_basic: pointer to USB capabilities
\param[in] usb_regs: USB core registers
\param[in] usb_core: USB core
\param[out] none
\retval operation status
*/
-usb_status usb_basic_init (usb_core_basic *usb_basic,
- usb_core_regs *usb_regs,
+usb_status usb_basic_init (usb_core_basic *usb_basic,
+ usb_core_regs *usb_regs,
usb_core_enum usb_core)
{
/* configure USB default transfer mode as FIFO mode */
@@ -77,6 +79,12 @@ usb_status usb_basic_init (usb_core_basic *usb_basic,
#ifdef USB_HS_INTERNAL_DMA_ENABLED
usb_basic->transfer_mode = USB_USE_DMA;
#endif /* USB_HS_INTERNAL_DMA_ENABLED */
+
+#ifdef USB_HS_CORE
+ /* configure the SOF output and the low power support */
+ usb_basic->sof_enable = USBHS_SOF_OUTPUT;
+ usb_basic->low_power = USBHS_LOW_POWER;
+#endif /* USB_HS_CORE */
break;
case USB_CORE_ENUM_FS:
@@ -90,15 +98,18 @@ usb_status usb_basic_init (usb_core_basic *usb_basic,
/* USBFS core use embedded physical layer */
usb_basic->phy_itf = USB_EMBEDDED_PHY;
+
+#ifdef USB_FS_CORE
+ /* configure the SOF output and the low power support */
+ usb_basic->sof_enable = USBFS_SOF_OUTPUT;
+ usb_basic->low_power = USBFS_LOW_POWER;
+#endif /* USB_FS_CORE */
break;
default:
return USB_FAIL;
}
- usb_basic->sof_enable = USB_SOF_OUTPUT;
- usb_basic->low_power = USB_LOW_POWER;
-
/* assign main registers address */
*usb_regs = (usb_core_regs) {
.gr = (usb_gr*) (usb_basic->base_reg + USB_REG_OFFSET_CORE),
@@ -131,7 +142,7 @@ usb_status usb_basic_init (usb_core_basic *usb_basic,
}
/*!
- \brief initializes the USB controller registers and
+ \brief initializes the USB controller registers and
prepares the core device mode or host mode operation
\param[in] usb_basic: pointer to USB capabilities
\param[in] usb_regs: pointer to USB core registers
@@ -195,7 +206,7 @@ usb_status usb_core_init (usb_core_basic usb_basic, usb_core_regs *usb_regs)
usb_regs->gr->GINTF = 0xBFFFFFFFU;
usb_regs->gr->GINTEN = GINTEN_WKUPIE | GINTEN_SPIE | \
- GINTEN_OTGIE | GINTEN_SESIE | GINTEN_CIDPSCIE;
+ GINTEN_OTGIE | GINTEN_SESIE | GINTEN_CIDPSCIE;
#endif /* USE_OTG_MODE */
@@ -203,17 +214,17 @@ usb_status usb_core_init (usb_core_basic usb_basic, usb_core_regs *usb_regs)
}
/*!
- \brief write a packet into the TX FIFO associated with the endpoint
+ \brief write a packet into the Tx FIFO associated with the endpoint
\param[in] usb_regs: pointer to USB core registers
\param[in] src_buf: pointer to source buffer
- \param[in] fifo_num: FIFO number which is in (0..3)
+ \param[in] fifo_num: FIFO number which is in (0..3 or 0..5)
\param[in] byte_count: packet byte count
\param[out] none
\retval operation status
*/
-usb_status usb_txfifo_write (usb_core_regs *usb_regs,
- uint8_t *src_buf,
- uint8_t fifo_num,
+usb_status usb_txfifo_write (usb_core_regs *usb_regs,
+ uint8_t *src_buf,
+ uint8_t fifo_num,
uint16_t byte_count)
{
uint32_t word_count = (byte_count + 3U) / 4U;
@@ -253,9 +264,9 @@ void *usb_rxfifo_read (usb_core_regs *usb_regs, uint8_t *dest_buf, uint16_t byte
}
/*!
- \brief flush a TX FIFO or all TX FIFOs
+ \brief flush a Tx FIFO or all Tx FIFOs
\param[in] usb_regs: pointer to USB core registers
- \param[in] fifo_num: FIFO number which is in (0..3)
+ \param[in] fifo_num: FIFO number which is in (0..3 or 0..5)
\param[out] none
\retval operation status
*/
@@ -263,7 +274,7 @@ usb_status usb_txfifo_flush (usb_core_regs *usb_regs, uint8_t fifo_num)
{
usb_regs->gr->GRSTCTL = ((uint32_t)fifo_num << 6U) | GRSTCTL_TXFF;
- /* wait for TX FIFO flush bit is set */
+ /* wait for Tx FIFO flush bit is set */
while (usb_regs->gr->GRSTCTL & GRSTCTL_TXFF) {
/* no operation */
}
@@ -284,7 +295,7 @@ usb_status usb_rxfifo_flush (usb_core_regs *usb_regs)
{
usb_regs->gr->GRSTCTL = GRSTCTL_RXFF;
- /* wait for RX FIFO flush bit is set */
+ /* wait for Rx FIFO flush bit is set */
while (usb_regs->gr->GRSTCTL & GRSTCTL_RXFF) {
/* no operation */
}
@@ -309,7 +320,7 @@ void usb_set_txfifo(usb_core_regs *usb_regs, uint8_t fifo, uint16_t size)
tx_offset = usb_regs->gr->GRFLEN;
- if (fifo == 0U) {
+ if(0U == fifo) {
usb_regs->gr->DIEP0TFLEN_HNPTFLEN = ((uint32_t)size << 16) | tx_offset;
} else {
tx_offset += (usb_regs->gr->DIEP0TFLEN_HNPTFLEN) >> 16;
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usb_dev.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usb_dev.c
index 3f6a52a3c4..11bfab7e58 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usb_dev.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usb_dev.c
@@ -3,32 +3,34 @@
\brief USB device mode low level driver
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -47,7 +49,7 @@ static const uint8_t EP0_MAXLEN[4] = {
#ifdef USB_FS_CORE
/* USB endpoint Tx FIFO size */
-static uint16_t USBFS_TX_FIFO_SIZE[USBFS_MAX_EP_COUNT] =
+static uint16_t USBFS_TX_FIFO_SIZE[USBFS_MAX_EP_COUNT] =
{
(uint16_t)TX0_FIFO_FS_SIZE,
(uint16_t)TX1_FIFO_FS_SIZE,
@@ -59,7 +61,7 @@ static uint16_t USBFS_TX_FIFO_SIZE[USBFS_MAX_EP_COUNT] =
#ifdef USB_HS_CORE
-uint16_t USBHS_TX_FIFO_SIZE[USBHS_MAX_EP_COUNT] =
+uint16_t USBHS_TX_FIFO_SIZE[USBHS_MAX_EP_COUNT] =
{
(uint16_t)TX0_FIFO_HS_SIZE,
(uint16_t)TX1_FIFO_HS_SIZE,
@@ -98,7 +100,7 @@ usb_status usb_devcore_init (usb_core_driver *udev)
/* set Rx FIFO size */
usb_set_rxfifo(&udev->regs, RX_FIFO_FS_SIZE);
- /* set endpoint 0 to 3's TX FIFO length and RAM address */
+ /* set endpoint 0 to 3's Tx FIFO length and RAM address */
for (i = 0U; i < USBFS_MAX_EP_COUNT; i++) {
usb_set_txfifo(&udev->regs, i, USBFS_TX_FIFO_SIZE[i]);
}
@@ -125,10 +127,10 @@ usb_status usb_devcore_init (usb_core_driver *udev)
/* make sure all FIFOs are flushed */
- /* flush all TX FIFOs */
+ /* flush all Tx FIFOs */
(void)usb_txfifo_flush (&udev->regs, 0x10U);
- /* flush entire RX FIFO */
+ /* flush entire Rx FIFO */
(void)usb_rxfifo_flush (&udev->regs);
/* clear all pending device interrupts */
@@ -213,6 +215,8 @@ usb_status usb_devint_enable (usb_core_driver *udev)
usb_status usb_transc0_active (usb_core_driver *udev, usb_transc *transc)
{
__IO uint32_t *reg_addr = NULL;
+
+ uint8_t enum_speed = udev->regs.dr->DSTAT & DSTAT_ES;
/* get the endpoint number */
uint8_t ep_num = transc->ep_addr.num;
@@ -229,11 +233,10 @@ usb_status usb_transc0_active (usb_core_driver *udev, usb_transc *transc)
}
/* endpoint 0 is activated after USB clock is enabled */
-
*reg_addr &= ~(DEPCTL_MPL | DEPCTL_EPTYPE | DIEPCTL_TXFNUM);
/* set endpoint 0 maximum packet length */
- *reg_addr |= EP0_MAXLEN[udev->regs.dr->DSTAT & DSTAT_ES];
+ *reg_addr |= EP0_MAXLEN[enum_speed];
/* activate endpoint */
*reg_addr |= ((uint32_t)transc->ep_type << 18U) | ((uint32_t)ep_num << 22U) | DEPCTL_SD0PID | DEPCTL_EPACT;
@@ -251,7 +254,8 @@ usb_status usb_transc0_active (usb_core_driver *udev, usb_transc *transc)
usb_status usb_transc_active (usb_core_driver *udev, usb_transc *transc)
{
__IO uint32_t *reg_addr = NULL;
- __IO uint32_t epinten = 0U;
+ uint32_t epinten = 0U;
+ uint8_t enum_speed = udev->regs.dr->DSTAT & DSTAT_ES;
/* get the endpoint number */
uint8_t ep_num = transc->ep_addr.num;
@@ -273,7 +277,7 @@ usb_status usb_transc_active (usb_core_driver *udev, usb_transc *transc)
/* set endpoint maximum packet length */
if (0U == ep_num) {
- *reg_addr |= EP0_MAXLEN[udev->regs.dr->DSTAT & DSTAT_ES];
+ *reg_addr |= EP0_MAXLEN[enum_speed];
} else {
*reg_addr |= transc->max_len;
}
@@ -394,10 +398,8 @@ usb_status usb_transc_inxfer (usb_core_driver *udev, usb_transc *transc)
udev->regs.er_in[ep_num]->DIEPCTL = epctl;
if ((uint8_t)USB_USE_FIFO == udev->bp.transfer_mode) {
- udev->regs.er_in[ep_num]->DIEPCTL = epctl;
-
if (transc->ep_type != (uint8_t)USB_EPTYPE_ISOC) {
- /* enable the TX FIFO empty interrupt for this endpoint */
+ /* enable the Tx FIFO empty interrupt for this endpoint */
if (transc->xfer_len > 0U) {
udev->regs.dr->DIEPFEINTEN |= 1U << ep_num;
}
@@ -631,7 +633,7 @@ void usb_dev_suspend (usb_core_driver *udev)
*udev->regs.PWRCLKCTL |= PWRCLKCTL_SHCLK;
/* enter DEEP_SLEEP mode with LDO in low power mode */
- pmu_to_deepsleepmode(PMU_LDO_LOWPOWER, WFI_CMD);
+ pmu_to_deepsleepmode (PMU_LDO_LOWPOWER,PMU_LOWDRIVER_DISABLE,WFI_CMD);
}
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usb_host.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usb_host.c
index c47abac6c7..ab82a5ff03 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usb_host.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usb_host.c
@@ -3,32 +3,34 @@
\brief USB host mode low level driver
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -59,7 +61,7 @@ usb_status usb_host_init (usb_core_driver *udev)
/* initialize host configuration register */
if (USB_ULPI_PHY == udev->bp.phy_itf) {
- usb_phyclock_config (udev, HCTL_30_60MHZ);
+ usb_phyclock_config (udev, HCTL_30_60MHZ);
} else {
usb_phyclock_config (udev, HCTL_48MHZ);
}
@@ -73,12 +75,12 @@ usb_status usb_host_init (usb_core_driver *udev)
/* set Rx FIFO size */
udev->regs.gr->GRFLEN = USB_RX_FIFO_FS_SIZE;
- /* set non-periodic TX FIFO size and address */
+ /* set non-periodic Tx FIFO size and address */
nptxfifolen |= USB_RX_FIFO_FS_SIZE;
nptxfifolen |= USB_HTX_NPFIFO_FS_SIZE << 16U;
udev->regs.gr->DIEP0TFLEN_HNPTFLEN = nptxfifolen;
- /* set periodic TX FIFO size and address */
+ /* set periodic Tx FIFO size and address */
ptxfifolen |= USB_RX_FIFO_FS_SIZE + USB_HTX_NPFIFO_FS_SIZE;
ptxfifolen |= USB_HTX_PFIFO_FS_SIZE << 16U;
udev->regs.gr->HPTFLEN = ptxfifolen;
@@ -111,7 +113,7 @@ usb_status usb_host_init (usb_core_driver *udev)
/* make sure the FIFOs are flushed */
- /* flush all TX FIFOs in device or host mode */
+ /* flush all Tx FIFOs in device or host mode */
usb_txfifo_flush (&udev->regs, 0x10U);
/* flush the entire Rx FIFO */
@@ -240,9 +242,8 @@ usb_status usb_pipe_init (usb_core_driver *udev, uint8_t pipe_num)
| HCHINTEN_DTERIE | HCHINTEN_NAKIE;
if (!pp->ep.dir) {
- pp_inten |= HCHINTEN_NYETIE;
-
- if (pp->ping) {
+ if (PORT_SPEED_HIGH == pp->dev_speed) {
+ pp_inten |= HCHINTEN_NYETIE;
pp_inten |= HCHINTEN_ACKIE;
}
}
@@ -376,7 +377,7 @@ usb_status usb_pipe_xfer (usb_core_driver *udev, uint8_t pipe_num)
break;
}
- /* write packet into the TX fifo. */
+ /* write packet into the Tx fifo. */
usb_txfifo_write (&udev->regs, pp->xfer_buf, pipe_num, (uint16_t)pp->xfer_len);
}
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usbd_int.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usbd_int.c
index 04844af1aa..f22e79507e 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usbd_int.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usbd_int.c
@@ -3,32 +3,34 @@
\brief USB device mode interrupt routines
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -36,13 +38,13 @@ OF SUCH DAMAGE.
#include "drv_usbd_int.h"
#include "usbd_transc.h"
+/* local function prototypes ('static') */
static uint32_t usbd_int_epout (usb_core_driver *udev);
static uint32_t usbd_int_epin (usb_core_driver *udev);
static uint32_t usbd_int_rxfifo (usb_core_driver *udev);
static uint32_t usbd_int_reset (usb_core_driver *udev);
static uint32_t usbd_int_enumfinish (usb_core_driver *udev);
static uint32_t usbd_int_suspend (usb_core_driver *udev);
-
static uint32_t usbd_emptytxfifo_write (usb_core_driver *udev, uint32_t ep_num);
static const uint8_t USB_SPEED[4] = {
@@ -61,7 +63,8 @@ static const uint8_t USB_SPEED[4] = {
void usbd_isr (usb_core_driver *udev)
{
if (HOST_MODE != (udev->regs.gr->GINTF & GINTF_COPM)) {
- uint32_t intr = udev->regs.gr->GINTF & udev->regs.gr->GINTEN;
+ uint32_t intr = udev->regs.gr->GINTF;
+ intr &= udev->regs.gr->GINTEN;
/* there are no interrupts, avoid spurious interrupt */
if (!intr) {
@@ -228,7 +231,7 @@ uint32_t usbd_int_dedicated_ep1in (usb_core_driver *udev)
return 1;
}
-#endif
+#endif /* USB_HS_DEDICATED_EP1_ENABLED */
/*!
\brief indicates that an OUT endpoint has a pending interrupt
@@ -347,20 +350,20 @@ static uint32_t usbd_int_rxfifo (usb_core_driver *udev)
bcount = (devrxstat & GRSTATRP_BCOUNT) >> 4U;
data_PID = (uint8_t)((devrxstat & GRSTATRP_DPID) >> 15U);
-#ifdef USE_USB_HS
+#if defined(USE_USB_HS) && defined(USE_ULPI_PHY)
#ifndef USE_450Z_EVAL
- /* ensure no-DMA mode can work */
- if ((1U == ep_num) && (0U == (udev->regs.er_out[ep_num]->DOEPLEN & DEPLEN_PCNT))) {
- uint32_t devepctl = udev->regs.er_out[ep_num]->DOEPCTL;
+ /* ensure no-DMA mode can work */
+ if (0U == (udev->regs.er_out[ep_num]->DOEPLEN & DEPLEN_PCNT)) {
+ uint32_t devepctl = udev->regs.er_out[ep_num]->DOEPCTL;
- devepctl |= DEPCTL_SNAK;
- devepctl &= ~DEPCTL_EPEN;
- devepctl &= ~DEPCTL_EPD;
+ devepctl |= DEPCTL_SNAK;
+ devepctl &= ~DEPCTL_EPEN;
+ devepctl &= ~DEPCTL_EPD;
- udev->regs.er_out[ep_num]->DOEPCTL = devepctl;
- }
+ udev->regs.er_out[ep_num]->DOEPCTL = devepctl;
+ }
#endif /* USE_450Z_EVAL */
-#endif /* USE_USB_HS */
+#endif /* USE_USB_HS && USE_ULPI_PHY */
switch ((devrxstat & GRSTATRP_RPCKST) >> 17U) {
case RSTAT_GOUT_NAK:
@@ -415,7 +418,7 @@ static uint32_t usbd_int_reset (usb_core_driver *udev)
/* clear the remote wakeup signaling */
udev->regs.dr->DCTL &= ~DCTL_RWKUP;
- /* flush the TX FIFO */
+ /* flush the Tx FIFO */
(void)usb_txfifo_flush (&udev->regs, 0U);
for (i = 0U; i < udev->bp.num_ep; i++) {
@@ -434,14 +437,14 @@ static uint32_t usbd_int_reset (usb_core_driver *udev)
#ifdef USB_HS_DEDICATED_EP1_ENABLED
udev->regs.dr->DOEP1INTEN = DOEPINTEN_STPFEN | DOEPINTEN_TFEN;
-#endif
+#endif /* USB_HS_DEDICATED_EP1_ENABLED */
/* enable IN endpoint interrupts */
udev->regs.dr->DIEPINTEN = DIEPINTEN_TFEN;
#ifdef USB_HS_DEDICATED_EP1_ENABLED
udev->regs.dr->DIEP1INTEN = DIEPINTEN_TFEN;
-#endif
+#endif /* USB_HS_DEDICATED_EP1_ENABLED */
/* reset device address */
udev->regs.dr->DCFG &= ~DCFG_DAR;
@@ -518,7 +521,7 @@ static uint32_t usbd_int_suspend (usb_core_driver *udev)
{
__IO uint8_t low_power = udev->bp.low_power;
__IO uint8_t suspend = (uint8_t)(udev->regs.dr->DSTAT & DSTAT_SPST);
- __IO uint8_t is_configured = (udev->dev.cur_status == (uint8_t)USBD_CONFIGURED)? 1U : 0U;
+ __IO uint8_t is_configured = (udev->dev.cur_status == (uint8_t)USBD_CONFIGURED) ? 1U : 0U;
udev->dev.backup_status = udev->dev.cur_status;
udev->dev.cur_status = (uint8_t)USBD_SUSPENDED;
@@ -528,7 +531,7 @@ static uint32_t usbd_int_suspend (usb_core_driver *udev)
*udev->regs.PWRCLKCTL |= PWRCLKCTL_SUCLK | PWRCLKCTL_SHCLK;
/* enter DEEP_SLEEP mode with LDO in low power mode */
- pmu_to_deepsleepmode(PMU_LDO_LOWPOWER, WFI_CMD);
+ pmu_to_deepsleepmode (PMU_LDO_LOWPOWER, PMU_LOWDRIVER_DISABLE, WFI_CMD);
}
/* clear interrupt */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usbh_int.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usbh_int.c
index 2bde1469a0..b4358ea9bc 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usbh_int.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/driver/Source/drv_usbh_int.c
@@ -3,45 +3,44 @@
\brief USB host mode interrupt handler file
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
-#include "drv_usb_core.h"
-#include "drv_usb_host.h"
#include "drv_usbh_int.h"
-#include "usbh_core.h"
#if defined (__CC_ARM) /*!< ARM compiler */
#pragma O0
#elif defined (__GNUC__) /*!< GNU compiler */
#pragma GCC optimize ("O0")
-#elif defined (__TASKING__) /*!< TASKING compiler */
+#elif defined (__TASKING__) /*!< TASKING compiler */
#pragma optimize=0
#endif /* __CC_ARM */
@@ -138,8 +137,8 @@ uint32_t usbh_isr (usb_core_driver *udev)
\param[out] none
\retval none
*/
-static inline void usb_pp_halt (usb_core_driver *udev,
- uint8_t pp_num,
+static inline void usb_pp_halt (usb_core_driver *udev,
+ uint8_t pp_num,
uint32_t pp_int,
usb_pipe_staus pp_status)
{
@@ -206,20 +205,22 @@ static uint32_t usbh_int_port (usb_core_driver *udev)
udev->regs.hr->HFT = 48000U;
if (HCTL_48MHZ != clock_type) {
- usb_phyclock_config (udev, HCTL_48MHZ);
- }
+ if (USB_EMBEDDED_PHY == udev->bp.phy_itf) {
+ usb_phyclock_config (udev, HCTL_48MHZ);
+ }
- port_reset = 1U;
+ port_reset = 1U;
+ }
} else {
/* for high speed device and others */
port_reset = 1U;
}
- usbh_int_fop->port_enabled(udev->host.data);
+ udev->host.port_enabled = 1;
udev->regs.gr->GINTEN |= GINTEN_DISCIE | GINTEN_SOFIE;
} else {
- usbh_int_fop->port_disabled(udev->host.data);
+ udev->host.port_enabled = 0;
}
}
@@ -273,7 +274,8 @@ static uint32_t usbh_int_pipe_in (usb_core_driver *udev, uint32_t pp_num)
usb_pipe *pp = &udev->host.pipe[pp_num];
- __IO uint32_t intr_pp = pp_reg->HCHINTF & pp_reg->HCHINTEN;
+ uint32_t intr_pp = pp_reg->HCHINTF;
+ intr_pp &= pp_reg->HCHINTEN;
uint8_t ep_type = (uint8_t)((pp_reg->HCHCTL & HCHCTL_EPTYPE) >> 18U);
@@ -400,16 +402,17 @@ static uint32_t usbh_int_pipe_in (usb_core_driver *udev, uint32_t pp_num)
#endif /* __ICCARM */
static uint32_t usbh_int_pipe_out (usb_core_driver *udev, uint32_t pp_num)
{
+ usbh_host *uhost = udev->host.data;
usb_pr *pp_reg = udev->regs.pr[pp_num];
-
usb_pipe *pp = &udev->host.pipe[pp_num];
-
- uint32_t intr_pp = pp_reg->HCHINTF & pp_reg->HCHINTEN;
+ uint32_t intr_pp = pp_reg->HCHINTF;
+ intr_pp &= pp_reg->HCHINTEN;
if (intr_pp & HCHINTF_ACK) {
- if (URB_PING == pp->urb_state) {
+ if (1U == udev->host.pipe[pp_num].do_ping) {
+ udev->host.pipe[pp_num].do_ping = 0;
pp->err_count = 0U;
- usb_pp_halt (udev, (uint8_t)pp_num, HCHINTF_TF, PIPE_XF);
+ usb_pp_halt (udev, (uint8_t)pp_num, HCHINTF_ACK, pp->pp_status);
}
pp_reg->HCHINTF = HCHINTF_ACK;
@@ -424,14 +427,31 @@ static uint32_t usbh_int_pipe_out (usb_core_driver *udev, uint32_t pp_num)
pp->err_count = 0U;
usb_pp_halt (udev, (uint8_t)pp_num, HCHINTF_TF, PIPE_XF);
} else if (intr_pp & HCHINTF_NAK) {
+ if (0U == udev->host.pipe[pp_num].do_ping) {
+ if (1U == udev->host.pipe[pp_num].supp_ping) {
+ udev->host.pipe[pp_num].do_ping = 1;
+ }
+ }
+
pp->err_count = 0U;
usb_pp_halt (udev, (uint8_t)pp_num, HCHINTF_NAK, PIPE_NAK);
} else if (intr_pp & HCHINTF_USBER) {
pp->err_count++;
usb_pp_halt (udev, (uint8_t)pp_num, HCHINTF_USBER, PIPE_TRACERR);
} else if (intr_pp & HCHINTF_NYET) {
+ if (CTL_STATUS_OUT != uhost->control.ctl_state) {
+ if (0U == udev->host.pipe[pp_num].do_ping) {
+ if (1U == udev->host.pipe[pp_num].supp_ping) {
+ udev->host.pipe[pp_num].do_ping = 1;
+ }
+ }
+
+ usb_pp_halt (udev, (uint8_t)pp_num, HCHINTF_NYET, PIPE_NYET);
+ } else {
+ usb_pp_halt (udev, (uint8_t)pp_num, HCHINTF_NYET, PIPE_XF);
+ }
+
pp->err_count = 0U;
- usb_pp_halt (udev, (uint8_t)pp_num, HCHINTF_NYET, PIPE_NYET);
} else if (intr_pp & HCHINTF_CH) {
udev->regs.pr[pp_num]->HCHINTEN &= ~HCHINTEN_CHIE;
@@ -440,27 +460,13 @@ static uint32_t usbh_int_pipe_out (usb_core_driver *udev, uint32_t pp_num)
pp->urb_state = URB_DONE;
if ((uint8_t)USB_EPTYPE_BULK == ((pp_reg->HCHCTL & HCHCTL_EPTYPE) >> 18U)) {
- pp->data_toggle_out ^= 1U;
+ pp->data_toggle_out ^= 1U;
}
break;
case PIPE_NAK:
-
- if (URB_PING == pp->urb_state) {
- (void)usb_pipe_ping (udev, (uint8_t)pp_num);
- } else {
- pp->urb_state = URB_NOTREADY;
- }
- break;
-
case PIPE_NYET:
- if (1U == udev->host.pipe[pp_num].ping) {
- (void)usb_pipe_ping (udev, (uint8_t)pp_num);
- pp->urb_state = URB_PING;
- }
- else {
- pp->urb_state = URB_NOTREADY;
- }
+ pp->urb_state = URB_NOTREADY;
break;
case PIPE_STALL:
@@ -502,7 +508,7 @@ static uint32_t usbh_int_pipe_out (usb_core_driver *udev, uint32_t pp_num)
#endif /* __ICCARM */
static uint32_t usbh_int_rxfifonoempty (usb_core_driver *udev)
{
- uint32_t count = 0U;
+ uint32_t count = 0U, xfer_count = 0U;
__IO uint8_t pp_num = 0U;
__IO uint32_t rx_stat = 0U;
@@ -524,12 +530,14 @@ static uint32_t usbh_int_rxfifonoempty (usb_core_driver *udev)
/* manage multiple transfer packet */
udev->host.pipe[pp_num].xfer_buf += count;
udev->host.pipe[pp_num].xfer_count += count;
+
+ xfer_count = udev->host.pipe[pp_num].xfer_count;
- udev->host.backup_xfercount[pp_num] = udev->host.pipe[pp_num].xfer_count;
+ udev->host.backup_xfercount[pp_num] = xfer_count;
if (udev->regs.pr[pp_num]->HCHLEN & HCHLEN_PCNT) {
/* re-activate the channel when more packets are expected */
- __IO uint32_t pp_ctl = udev->regs.pr[pp_num]->HCHCTL;
+ uint32_t pp_ctl = udev->regs.pr[pp_num]->HCHCTL;
pp_ctl |= HCHCTL_CEN;
pp_ctl &= ~HCHCTL_CDIS;
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Include/usbh_hid_core.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Include/usbh_hid_core.h
index 610af2e0c5..c386f7c8f9 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Include/usbh_hid_core.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Include/usbh_hid_core.h
@@ -3,32 +3,34 @@
\brief header file for the usbh_hid_core.c
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -41,47 +43,8 @@ OF SUCH DAMAGE.
#define HID_MIN_POLL 10U
#define HID_REPORT_SIZE 16U
-#define HID_MAX_USAGE 10U
-#define HID_MAX_NBR_REPORT_FMT 10U
#define HID_QUEUE_SIZE 10U
-#define HID_ITEM_LONG 0xFEU
-
-#define HID_ITEM_TYPE_MAIN 0x00U
-#define HID_ITEM_TYPE_GLOBAL 0x01U
-#define HID_ITEM_TYPE_LOCAL 0x02U
-#define HID_ITEM_TYPE_RESERVED 0x03U
-
-#define HID_MAIN_ITEM_TAG_INPUT 0x08U
-#define HID_MAIN_ITEM_TAG_OUTPUT 0x09U
-#define HID_MAIN_ITEM_TAG_COLLECTION 0x0AU
-#define HID_MAIN_ITEM_TAG_FEATURE 0x0BU
-#define HID_MAIN_ITEM_TAG_ENDCOLLECTION 0x0CU
-
-#define HID_GLOBAL_ITEM_TAG_USAGE_PAGE 0x00U
-#define HID_GLOBAL_ITEM_TAG_LOG_MIN 0x01U
-#define HID_GLOBAL_ITEM_TAG_LOG_MAX 0x02U
-#define HID_GLOBAL_ITEM_TAG_PHY_MIN 0x03U
-#define HID_GLOBAL_ITEM_TAG_PHY_MAX 0x04U
-#define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT 0x05U
-#define HID_GLOBAL_ITEM_TAG_UNIT 0x06U
-#define HID_GLOBAL_ITEM_TAG_REPORT_SIZE 0x07U
-#define HID_GLOBAL_ITEM_TAG_REPORT_ID 0x08U
-#define HID_GLOBAL_ITEM_TAG_REPORT_COUNT 0x09U
-#define HID_GLOBAL_ITEM_TAG_PUSH 0x0AU
-#define HID_GLOBAL_ITEM_TAG_POP 0x0BU
-
-#define HID_LOCAL_ITEM_TAG_USAGE 0x00U
-#define HID_LOCAL_ITEM_TAG_USAGE_MIN 0x01U
-#define HID_LOCAL_ITEM_TAG_USAGE_MAX 0x02U
-#define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX 0x03U
-#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MIN 0x04U
-#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAX 0x05U
-#define HID_LOCAL_ITEM_TAG_STRING_INDEX 0x07U
-#define HID_LOCAL_ITEM_TAG_STRING_MIN 0x08U
-#define HID_LOCAL_ITEM_TAG_STRING_MAX 0x09U
-#define HID_LOCAL_ITEM_TAG_DELIMITER 0x0AU
-
#define USB_HID_DESC_SIZE 9U
/* states for HID state machine */
@@ -113,51 +76,6 @@ typedef enum
HID_UNKNOWN = 0xFFU,
} hid_type;
-typedef struct _hid_report_data
-{
- uint8_t ReportID;
- uint8_t ReportType;
- uint16_t UsagePage;
- uint32_t Usage[HID_MAX_USAGE];
- uint32_t NbrUsage;
- uint32_t UsageMin;
- uint32_t UsageMax;
- int32_t LogMin;
- int32_t LogMax;
- int32_t PhyMin;
- int32_t PhyMax;
- int32_t UnitExp;
- uint32_t Unit;
- uint32_t ReportSize;
- uint32_t ReportCnt;
- uint32_t Flag;
- uint32_t PhyUsage;
- uint32_t AppUsage;
- uint32_t LogUsage;
-} hid_report_data;
-
-typedef struct _hid_report_ID
-{
- uint8_t size; /*!< report size return by the device ID */
- uint8_t reportID; /*!< report ID */
- uint8_t type; /*!< report type (INPUT/OUTPUT/FEATURE) */
-} hid_report_ID;
-
-typedef struct _hid_collection
-{
- uint32_t usage;
- uint8_t type;
- struct _hid_collection *next_ptr;
-} hid_collection;
-
-typedef struct _hid_appcollection
-{
- uint32_t usage;
- uint8_t type;
- uint8_t nbr_report_fmt;
- hid_report_data report_data[HID_MAX_NBR_REPORT_FMT];
-} hid_appcollection;
-
typedef struct
{
uint8_t *buf;
@@ -175,21 +93,19 @@ typedef struct _hid_process
uint8_t ep_addr;
uint8_t ep_in;
uint8_t ep_out;
- __IO uint8_t data_ready;
uint8_t *pdata;
+ __IO uint8_t data_ready;
uint16_t len;
uint16_t poll;
__IO uint32_t timer;
-
- data_fifo fifo;
usb_desc_hid hid_desc;
- hid_report_data hid_report;
hid_state state;
hid_ctlstate ctl_state;
+
usbh_status (*init)(usb_core_driver *udev, usbh_host *uhost);
- void (*machine)(usb_core_driver *udev, usbh_host *uhost);
+ usbh_status (*decode)(uint8_t *data);
} usbh_hid_handler;
extern usbh_class usbh_hid;
@@ -202,11 +118,5 @@ usbh_status usbh_set_report (usb_core_driver *udev,
uint8_t report_ID,
uint8_t report_len,
uint8_t *report_buf);
-/* read data from FIFO */
-uint16_t usbh_hid_fifo_read (data_fifo *fifo, void *buf, uint16_t nbytes);
-/* write data to FIFO */
-uint16_t usbh_hid_fifo_write (data_fifo *fifo, void *buf, uint16_t nbytes);
-/* initialize FIFO */
-void usbh_hid_fifo_init (data_fifo *fifo, uint8_t *buf, uint16_t size);
#endif /* __USBH_HID_CORE_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Include/usbh_standard_hid.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Include/usbh_standard_hid.h
new file mode 100644
index 0000000000..a676c7f8a8
--- /dev/null
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Include/usbh_standard_hid.h
@@ -0,0 +1,101 @@
+/*!
+ \file usbh_standard_hid.h
+ \brief header file for usbh_standard_hid.c
+
+ \version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
+*/
+
+/*
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
+
+ Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+#ifndef __USBH_STANDARD_HID_H
+#define __USBH_STANDARD_HID_H
+
+#include "usb_conf.h"
+#include "usbh_hid_core.h"
+
+//#define AZERTY_KEYBOARD
+#define QWERTY_KEYBOARD
+
+#define MOUSE_BUTTON_1 0x01U
+#define MOUSE_BUTTON_2 0x02U
+#define MOUSE_BUTTON_3 0x04U
+
+#define KBD_LEFT_CTRL 0x01U
+#define KBD_LEFT_SHIFT 0x02U
+#define KBD_LEFT_ALT 0x04U
+#define KBD_LEFT_GUI 0x08U
+#define KBD_RIGHT_CTRL 0x10U
+#define KBD_RIGHT_SHIFT 0x20U
+#define KBD_RIGHT_ALT 0x40U
+#define KBD_RIGHT_GUI 0x80U
+
+#define KBD_PRESSED_MAX_NUM 6U
+
+typedef struct _hid_mouse_info
+{
+ uint8_t x;
+ uint8_t y;
+ uint8_t buttons[3];
+} hid_mouse_info;
+
+typedef struct
+{
+ uint8_t state;
+ uint8_t lctrl;
+ uint8_t lshift;
+ uint8_t lalt;
+ uint8_t lgui;
+ uint8_t rctrl;
+ uint8_t rshift;
+ uint8_t ralt;
+ uint8_t rgui;
+ uint8_t keys[6];
+} hid_keybd_info;
+
+/* function declarations */
+/* initialize mouse */
+void usr_mouse_init (void);
+/* process mouse data */
+void usr_mouse_process_data (hid_mouse_info *data);
+/* initialize mouse function */
+usbh_status usbh_hid_mouse_init (usb_core_driver *udev, usbh_host *uhost);
+/* decode mouse information */
+usbh_status usbh_hid_mouse_decode(uint8_t *data);
+
+/* initialize keyboard */
+void usr_keybrd_init (void);
+/* process keyboard data */
+void usr_keybrd_process_data (uint8_t pbuf);
+/* initialize the keyboard function */
+usbh_status usbh_hid_keybrd_init (usb_core_driver *udev, usbh_host *uhost);
+/* decode keyboard information */
+usbh_status usbh_hid_keybrd_decode (uint8_t *data);
+
+#endif /* __USBH_STANDARD_HID_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Source/usbh_hid_core.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Source/usbh_hid_core.c
index 75e89959fe..473a58d855 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Source/usbh_hid_core.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Source/usbh_hid_core.c
@@ -3,43 +3,44 @@
\brief USB host HID class driver
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
-#include "usbh_pipe.h"
-#include "usbh_hid_core.h"
-#include "usbh_hid_mouse.h"
-#include "usbh_hid_keybd.h"
-
#include <string.h>
#include <stdbool.h>
+#include "usbh_pipe.h"
+#include "usbh_hid_core.h"
+#include "usbh_standard_hid.h"
+/* local function prototypes ('static') */
static void usbh_hiddesc_parse (usb_desc_hid *hid_desc, uint8_t *buf);
static void usbh_hid_itf_deinit (usbh_host *uhost);
static usbh_status usbh_hid_itf_init (usbh_host *uhost);
@@ -51,7 +52,7 @@ static usbh_status usbh_hid_desc_get (usbh_host *uhost, uint16_t len);
static usbh_status usbh_set_idle (usbh_host *uhost, uint8_t duration, uint8_t report_ID);
static usbh_status usbh_set_protocol (usbh_host *uhost, uint8_t protocol);
-usbh_class usbh_hid =
+usbh_class usbh_hid =
{
USB_HID_CLASS,
usbh_hid_itf_init,
@@ -107,7 +108,7 @@ usbh_status usbh_get_report (usbh_host *uhost,
\param[out] none
\retval operation status
*/
-usbh_status usbh_set_report (usb_core_driver *udev,
+usbh_status usbh_set_report (usb_core_driver *udev,
usbh_host *uhost,
uint8_t report_type,
uint8_t report_ID,
@@ -200,7 +201,7 @@ uint8_t usbh_hid_poll_interval_get (usb_core_driver *udev, usbh_host *uhost)
if ((HOST_CLASS_ENUM == uhost->cur_state) ||
(HOST_USER_INPUT == uhost->cur_state) ||
- (HOST_CHECK_CLASS == uhost->cur_state) ||
+ (HOST_CLASS_CHECK == uhost->cur_state) ||
(HOST_CLASS_HANDLER == uhost->cur_state)) {
return (uint8_t)(hid->poll);
} else {
@@ -209,98 +210,6 @@ uint8_t usbh_hid_poll_interval_get (usb_core_driver *udev, usbh_host *uhost)
}
/*!
- \brief read from FIFO
- \param[in] fifo: fifo address
- \param[in] buf: read buffer
- \param[in] nbytes: number of item to read
- \param[out] none
- \retval number of read items
-*/
-uint16_t usbh_hid_fifo_read (data_fifo *fifo, void *buf, uint16_t nbytes)
-{
- uint16_t i = 0U;
- uint8_t *p = (uint8_t*) buf;
-
- if (0U == fifo->lock) {
- fifo->lock = 1U;
-
- for (i = 0U; i < nbytes; i++) {
- if (fifo->tail != fifo->head) {
- *p++ = fifo->buf[fifo->tail];
- fifo->tail++;
-
- if (fifo->tail == fifo->size) {
- fifo->tail = 0U;
- }
- } else {
- fifo->lock = 0U;
-
- return i;
- }
- }
- }
-
- fifo->lock = 0U;
-
- return nbytes;
-}
-
-/*!
- \brief write to FIFO
- \param[in] fifo: fifo address
- \param[in] buf: read buffer
- \param[in] nbytes: number of item to read
- \param[out] none
- \retval number of write items
-*/
-uint16_t usbh_hid_fifo_write (data_fifo *fifo, void *buf, uint16_t nbytes)
-{
- uint16_t i = 0U;
- uint8_t *p = (uint8_t*) buf;
-
- if (0U == fifo->lock) {
- fifo->lock = 1U;
-
- for (i = 0U; i < nbytes; i++) {
- if ((fifo->head + 1U == fifo->tail) ||
- ((fifo->head + 1U == fifo->size) && (0U == fifo->tail))) {
- fifo->lock = 0U;
-
- return i;
- } else {
- fifo->buf[fifo->head] = *p++;
- fifo->head++;
-
- if (fifo->head == fifo->size) {
- fifo->head = 0U;
- }
- }
- }
- }
-
- fifo->lock = 0U;
-
- return nbytes;
-}
-
-/*!
- \brief initialize FIFO
- \param[in] fifo: fifo address
- \param[in] buf: read buffer
- \param[in] size: size of FIFO
- \param[out] none
- \retval none
-*/
-void usbh_hid_fifo_init (data_fifo *fifo, uint8_t *buf, uint16_t size)
-{
- fifo->head = 0U;
- fifo->tail = 0U;
- fifo->lock = 0U;
- fifo->size = size;
- fifo->buf = buf;
-}
-
-/*!
\brief initialize the hid class
\param[in] uhost: pointer to USB host
\param[out] none
@@ -328,11 +237,11 @@ static usbh_status usbh_hid_itf_init (usbh_host *uhost)
uint8_t itf_protocol = uhost->dev_prop.cfg_desc_set.itf_desc_set[uhost->dev_prop.cur_itf][0].itf_desc.bInterfaceProtocol;
if (USB_HID_PROTOCOL_KEYBOARD == itf_protocol) {
- hid_handler.init = usbh_hid_keybd_init;
- hid_handler.machine = usbh_hid_keybrd_machine;
+ hid_handler.init = usbh_hid_keybrd_init;
+ hid_handler.decode = usbh_hid_keybrd_decode;
} else if (USB_HID_PROTOCOL_MOUSE == itf_protocol) {
hid_handler.init = usbh_hid_mouse_init;
- hid_handler.machine = usbh_hid_mouse_machine;
+ hid_handler.decode = usbh_hid_mouse_decode;
} else {
status = USBH_FAIL;
}
@@ -347,7 +256,7 @@ static usbh_status usbh_hid_itf_init (usbh_host *uhost)
hid_handler.poll = HID_MIN_POLL;
}
- /* check fifo available number of endpoints */
+ /* check for available number of endpoints */
/* find the number of endpoints in the interface descriptor */
/* choose the lower number in order not to overrun the buffer allocated */
ep_num = USB_MIN(uhost->dev_prop.cfg_desc_set.itf_desc_set[uhost->dev_prop.cur_itf][0].itf_desc.bNumEndpoints, USBH_MAX_EP_NUM);
@@ -364,7 +273,7 @@ static usbh_status usbh_hid_itf_init (usbh_host *uhost)
/* open channel for IN endpoint */
usbh_pipe_create (uhost->data,
- &uhost->dev_prop,
+ &uhost->dev_prop,
hid_handler.pipe_in,
USB_EPTYPE_INTR,
hid_handler.len);
@@ -410,7 +319,7 @@ static usbh_status usbh_hid_class_req (usbh_host *uhost)
switch (hid->ctl_state) {
case HID_REQ_INIT:
case HID_REQ_GET_HID_DESC:
- /* get HID descriptor */
+ /* get HID descriptor */
if (USBH_OK == usbh_hid_desc_get (uhost, USB_HID_DESC_SIZE)) {
usbh_hiddesc_parse(&hid->hid_desc, uhost->dev_prop.data);
@@ -419,7 +328,7 @@ static usbh_status usbh_hid_class_req (usbh_host *uhost)
break;
case HID_REQ_GET_REPORT_DESC:
- /* get report descriptor */
+ /* get report descriptor */
if (USBH_OK == usbh_hid_reportdesc_get(uhost, hid->hid_desc.wDescriptorLength)) {
hid->ctl_state = HID_REQ_SET_IDLE;
}
@@ -436,7 +345,7 @@ static usbh_status usbh_hid_class_req (usbh_host *uhost)
hid->ctl_state = HID_REQ_SET_PROTOCOL;
}
}
- break;
+ break;
case HID_REQ_SET_PROTOCOL:
/* set protocol */
@@ -495,15 +404,15 @@ static usbh_status usbh_hid_handle (usbh_host *uhost)
case HID_POLL:
if (URB_DONE == usbh_urbstate_get (uhost->data, hid->pipe_in)) {
- if (0U == hid->data_ready) { /* handle data once */
- usbh_hid_fifo_write(&hid->fifo, hid->pdata, hid->len);
+ if (0U == hid->data_ready) {
hid->data_ready = 1U;
- hid->machine(uhost->data, uhost);
+ hid->decode(hid->pdata);
}
} else {
- if (URB_STALL == usbh_urbstate_get (uhost->data, hid->pipe_in)) { /* IN endpoint stalled */
- /* issue clear feature on interrupt in endpoint */
+ /* check IN endpoint stall status */
+ if (URB_STALL == usbh_urbstate_get (uhost->data, hid->pipe_in)) {
+ /* issue clear feature on interrupt in endpoint */
if (USBH_OK == (usbh_clrfeature (uhost, hid->ep_addr, hid->pipe_in))) {
/* change state to issue next in token */
hid->state = HID_GET_DATA;
@@ -663,7 +572,7 @@ static usbh_status usbh_set_protocol (usbh_host *uhost, uint8_t protocol)
\param[out] none
\retval none
*/
-static void usbh_hiddesc_parse (usb_desc_hid *hid_desc, uint8_t *buf)
+static void usbh_hiddesc_parse (usb_desc_hid *hid_desc, uint8_t *buf)
{
hid_desc->header.bLength = *(uint8_t *)(buf + 0U);
hid_desc->header.bDescriptorType = *(uint8_t *)(buf + 1U);
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Source/usbh_standard_hid.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Source/usbh_standard_hid.c
new file mode 100644
index 0000000000..5c9172b97b
--- /dev/null
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/hid/Source/usbh_standard_hid.c
@@ -0,0 +1,276 @@
+/*!
+ \file usbh_standard_hid.c
+ \brief USB host HID keyboard and mouse driver
+
+ \version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
+*/
+
+/*
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
+
+ Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+#include "usbh_standard_hid.h"
+#include <stdbool.h>
+
+hid_mouse_info mouse_info;
+hid_keybd_info keybd_info;
+
+__ALIGN_BEGIN uint8_t mouse_report_data[4] __ALIGN_END = {0U};
+__ALIGN_BEGIN uint32_t keybd_report_data[2] __ALIGN_END;
+
+/* local constants */
+static const uint8_t kbd_codes[] =
+{
+ 0, 0, 0, 0, 31, 50, 48, 33,
+ 19, 34, 35, 36, 24, 37, 38, 39, /* 0x00 - 0x0F */
+ 52, 51, 25, 26, 17, 20, 32, 21,
+ 23, 49, 18, 47, 22, 46, 2, 3, /* 0x10 - 0x1F */
+ 4, 5, 6, 7, 8, 9, 10, 11,
+ 43, 110, 15, 16, 61, 12, 13, 27, /* 0x20 - 0x2F */
+ 28, 29, 42, 40, 41, 1, 53, 54,
+ 55, 30, 112, 113, 114, 115, 116, 117, /* 0x30 - 0x3F */
+ 118, 119, 120, 121, 122, 123, 124, 125,
+ 126, 75, 80, 85, 76, 81, 86, 89, /* 0x40 - 0x4F */
+ 79, 84, 83, 90, 95, 100, 105, 106,
+ 108, 93, 98, 103, 92, 97, 102, 91, /* 0x50 - 0x5F */
+ 96, 101, 99, 104, 45, 129, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x6F */
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x7F */
+ 0, 0, 0, 0, 0, 107, 0, 56,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 - 0x8F */
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 - 0x9F */
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0xA0 - 0xAF */
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0xB0 - 0xBF */
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0xC0 - 0xCF */
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0xD0 - 0xDF */
+ 58, 44, 60, 127, 64, 57, 62, 128 /* 0xE0 - 0xE7 */
+};
+
+#ifdef QWERTY_KEYBOARD
+
+static const int8_t kbd_key[] =
+{
+ '\0', '`', '1', '2', '3', '4', '5', '6',
+ '7', '8', '9', '0', '-', '=', '\0', '\r',
+ '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u',
+ 'i', 'o', 'p', '[', ']', '\\',
+ '\0', 'a', 's', 'd', 'f', 'g', 'h', 'j',
+ 'k', 'l', ';', '\'', '\0', '\n',
+ '\0', '\0', 'z', 'x', 'c', 'v', 'b', 'n',
+ 'm', ',', '.', '/', '\0', '\0',
+ '\0', '\0', '\0', ' ', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\r', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '7', '4', '1',
+ '\0', '/', '8', '5', '2',
+ '0', '*', '9', '6', '3',
+ '.', '-', '+', '\0', '\n', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0'
+};
+
+static const int8_t kbd_key_shift[] = {
+ '\0', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
+ '_', '+', '\0', '\0', '\0', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U',
+ 'I', 'O', 'P', '{', '}', '|', '\0', 'A', 'S', 'D', 'F', 'G',
+ 'H', 'J', 'K', 'L', ':', '"', '\0', '\n', '\0', '\0', 'Z', 'X',
+ 'C', 'V', 'B', 'N', 'M', '<', '>', '?', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'
+};
+
+#else
+
+static const int8_t kbd_key[] = {
+ '\0', '`', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
+ '-', '=', '\0', '\r', '\t', 'a', 'z', 'e', 'r', 't', 'y', 'u',
+ 'i', 'o', 'p', '[', ']', '\\', '\0', 'q', 's', 'd', 'f', 'g',
+ 'h', 'j', 'k', 'l', 'm', '\0', '\0', '\n', '\0', '\0', 'w', 'x',
+ 'c', 'v', 'b', 'n', ',', ';', ':', '!', '\0', '\0', '\0', '\0',
+ '\0', ' ', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\r', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '7', '4', '1', '\0', '/',
+ '8', '5', '2', '0', '*', '9', '6', '3', '.', '-', '+', '\0',
+ '\n', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'
+};
+
+static const int8_t kbd_key_shift[] = {
+ '\0', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_',
+ '+', '\0', '\0', '\0', 'A', 'Z', 'E', 'R', 'T', 'Y', 'U', 'I', 'O',
+ 'P', '{', '}', '*', '\0', 'Q', 'S', 'D', 'F', 'G', 'H', 'J', 'K',
+ 'L', 'M', '%', '\0', '\n', '\0', '\0', 'W', 'X', 'C', 'V', 'B', 'N',
+ '?', '.', '/', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'
+};
+
+#endif /* QWERTY_KEYBOARD */
+
+/*!
+ \brief initialize the mouse function
+ \param[in] udev: pointer to USB core instance
+ \param[in] uhost: pointer to USB host
+ \param[out] none
+ \retval none
+*/
+usbh_status usbh_hid_mouse_init (usb_core_driver *udev, usbh_host *uhost)
+{
+ usbh_hid_handler *hid = (usbh_hid_handler *)uhost->active_class->class_data;
+
+ mouse_info.x = 0U;
+ mouse_info.y = 0U;
+ mouse_info.buttons[0] = 0U;
+ mouse_info.buttons[1] = 0U;
+ mouse_info.buttons[2] = 0U;
+
+ if(hid->len > sizeof(mouse_report_data)) {
+ hid->len = sizeof(mouse_report_data);
+ }
+
+ hid->pdata = (uint8_t *)(void *)mouse_report_data;
+
+ usr_mouse_init();
+
+ return USBH_OK;
+}
+
+/*!
+ \brief decode mouse information
+ \param[in] udev: pointer to USB core instance
+ \param[in] uhost: pointer to USB host
+ \param[out] none
+ \retval operation status
+*/
+usbh_status usbh_hid_mouse_decode(uint8_t *data)
+{
+ mouse_info.buttons[0] = data[0] & MOUSE_BUTTON_1;
+ mouse_info.buttons[1] = data[0] & MOUSE_BUTTON_2;
+ mouse_info.buttons[2] = data[0] & MOUSE_BUTTON_3;
+
+ mouse_info.x = data[1];
+ mouse_info.y = data[2];
+
+ /* handle mouse data position */
+ usr_mouse_process_data(&mouse_info);
+
+ return USBH_FAIL;
+}
+
+/*!
+ \brief initialize the keyboard function
+ \param[in] udev: pointer to USB core instance
+ \param[in] uhost: pointer to USB host
+ \param[out] none
+ \retval operation status
+*/
+usbh_status usbh_hid_keybrd_init (usb_core_driver *udev, usbh_host *uhost)
+{
+ usbh_hid_handler *hid = (usbh_hid_handler *)uhost->active_class->class_data;
+
+ keybd_info.lctrl = keybd_info.lshift = 0U;
+ keybd_info.lalt = keybd_info.lgui = 0U;
+ keybd_info.rctrl = keybd_info.rshift = 0U;
+ keybd_info.ralt = keybd_info.rgui = 0U;
+
+ for (uint32_t x = 0U; x < (sizeof(keybd_report_data) / sizeof(uint32_t)); x++) {
+ keybd_report_data[x] = 0U;
+ }
+
+ if (hid->len > (sizeof(keybd_report_data) / sizeof(uint32_t))) {
+ hid->len = (sizeof(keybd_report_data) / sizeof(uint32_t));
+ }
+
+ hid->pdata = (uint8_t*)(void *)keybd_report_data;
+
+ /* call user initialization*/
+ usr_keybrd_init();
+
+ return USBH_OK;
+}
+
+/*!
+ \brief get ascii code
+ \param[in] info: keyboard information
+ \param[out] none
+ \retval output
+*/
+uint8_t usbh_hid_ascii_code_get (hid_keybd_info *info)
+{
+ uint8_t output;
+ if ((1U == info->lshift) || (info->rshift)) {
+ output = kbd_key_shift[kbd_codes[info->keys[0]]];
+ } else {
+ output = kbd_key[kbd_codes[info->keys[0]]];
+ }
+
+ return output;
+}
+
+/*!
+ \brief decode keyboard information
+ \param[in] udev: pointer to USB core instance
+ \param[in] uhost: pointer to USB host
+ \param[out] none
+ \retval operation status
+*/
+usbh_status usbh_hid_keybrd_decode (uint8_t *data)
+{
+ uint8_t output;
+
+ keybd_info.lshift = data[0] & KBD_LEFT_SHIFT;
+ keybd_info.rshift = data[0] & KBD_RIGHT_SHIFT;
+
+ keybd_info.keys[0] = data[2];
+
+ if (keybd_info.lshift || keybd_info.rshift) {
+ output = kbd_key_shift[kbd_codes[keybd_info.keys[0]]];
+ } else {
+ output = kbd_key[kbd_codes[keybd_info.keys[0]]];
+ }
+
+ if (0U != output) {
+ usr_keybrd_process_data(output);
+ }
+
+ return USBH_OK;
+}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Include/usbh_msc_bbb.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Include/usbh_msc_bbb.h
index da71b743ae..5a786dd1f7 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Include/usbh_msc_bbb.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Include/usbh_msc_bbb.h
@@ -3,32 +3,34 @@
\brief header file for usbh_msc_bbb.c
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -42,23 +44,23 @@ typedef union {
msc_bbb_cbw field;
uint8_t CBWArray[31];
-}usbh_cbw_pkt;
+} usbh_cbw_pkt;
typedef union {
msc_bbb_csw field;
uint8_t CSWArray[13];
-}usbh_csw_pkt;
+} usbh_csw_pkt;
enum usbh_msc_state {
- USBH_MSC_BOT_INIT_STATE = 0U,
- USBH_MSC_BOT_RESET,
+ USBH_MSC_BBB_INIT_STATE = 0U,
+ USBH_MSC_BBB_RESET,
USBH_MSC_GET_MAX_LUN,
USBH_MSC_TEST_UNIT_READY,
USBH_MSC_READ_CAPACITY10,
USBH_MSC_MODE_SENSE6,
USBH_MSC_REQUEST_SENSE,
- USBH_MSC_BOT_USB_TRANSFERS,
+ USBH_MSC_BBB_USB_TRANSFERS,
USBH_MSC_DEFAULT_APPLI_STATE,
USBH_MSC_CTRL_ERROR_STATE,
USBH_MSC_UNRECOVERED_STATE
@@ -66,54 +68,54 @@ enum usbh_msc_state {
typedef enum
{
- BOT_OK = 0U,
- BOT_FAIL,
- BOT_PHASE_ERROR,
- BOT_BUSY
-} bot_status;
+ BBB_OK = 0U,
+ BBB_FAIL,
+ BBB_PHASE_ERROR,
+ BBB_BUSY
+} bbb_status;
typedef enum
{
- BOT_CMD_IDLE = 0U,
- BOT_CMD_SEND,
- BOT_CMD_WAIT,
-} bot_cmd_state;
+ BBB_CMD_IDLE = 0U,
+ BBB_CMD_SEND,
+ BBB_CMD_WAIT
+} bbb_cmd_state;
/* csw status definitions */
typedef enum
{
- BOT_CSW_CMD_PASSED = 0U,
- BOT_CSW_CMD_FAILED,
- BOT_CSW_PHASE_ERROR,
-} bot_csw_status;
+ BBB_CSW_CMD_PASSED = 0U,
+ BBB_CSW_CMD_FAILED,
+ BBB_CSW_PHASE_ERROR
+} bbb_csw_status;
typedef enum
{
- BOT_SEND_CBW = 1U,
- BOT_SEND_CBW_WAIT,
- BOT_DATA_IN,
- BOT_DATA_IN_WAIT,
- BOT_DATA_OUT,
- BOT_DATA_OUT_WAIT,
- BOT_RECEIVE_CSW,
- BOT_RECEIVE_CSW_WAIT,
- BOT_ERROR_IN,
- BOT_ERROR_OUT,
- BOT_UNRECOVERED_ERROR
-} bot_state;
+ BBB_SEND_CBW = 1U,
+ BBB_SEND_CBW_WAIT,
+ BBB_DATA_IN,
+ BBB_DATA_IN_WAIT,
+ BBB_DATA_OUT,
+ BBB_DATA_OUT_WAIT,
+ BBB_RECEIVE_CSW,
+ BBB_RECEIVE_CSW_WAIT,
+ BBB_ERROR_IN,
+ BBB_ERROR_OUT,
+ BBB_UNRECOVERED_ERROR
+} bbb_state;
typedef struct
{
uint8_t *pbuf;
uint32_t data[16];
- bot_state state;
- bot_state prev_state;
- bot_cmd_state cmd_state;
+ bbb_state state;
+ bbb_state prev_state;
+ bbb_cmd_state cmd_state;
usbh_cbw_pkt cbw;
usbh_csw_pkt csw;
-} bot_handle;
+} bbb_handle;
-#define USBH_MSC_BOT_CBW_TAG 0x20304050U
+#define USBH_MSC_BBB_CBW_TAG 0x20304050U
#define USBH_MSC_CSW_MAX_LENGTH 63U
@@ -130,21 +132,21 @@ typedef struct
#define CBW_LENGTH 10U
#define CBW_LENGTH_TEST_UNIT_READY 0U
-#define MAX_BULK_STALL_COUNT_LIMIT 0x04U /*!< If STALL is seen on Bulk
- Endpoint continously, this means
+#define MAX_BULK_STALL_COUNT_LIMIT 0x04U /*!< If STALL is seen on Bulk
+ Endpoint continously, this means
that device and Host has phase error
Hence a Reset is needed */
/* function declarations */
/* initialize the mass storage parameters */
-void usbh_msc_bot_init (usbh_host *uhost);
-/* manage the different states of BOT transfer and updates the status to upper layer */
-usbh_status usbh_msc_bot_process (usbh_host *uhost, uint8_t lun);
+void usbh_msc_bbb_init (usbh_host *uhost);
+/* manage the different states of BBB transfer and updates the status to upper layer */
+usbh_status usbh_msc_bbb_process (usbh_host *uhost, uint8_t lun);
/* manages the different error handling for stall */
-usbh_status usbh_msc_bot_abort (usbh_host *uhost, uint8_t direction);
-/* reset MSC bot request structure */
-usbh_status usbh_msc_bot_reset (usbh_host *uhost);
+usbh_status usbh_msc_bbb_abort (usbh_host *uhost, uint8_t direction);
+/* reset MSC BBB request structure */
+usbh_status usbh_msc_bbb_reset (usbh_host *uhost);
/* decode the CSW received by the device and updates the same to upper layer */
-bot_csw_status usbh_msc_csw_decode (usbh_host *uhost);
+bbb_csw_status usbh_msc_csw_decode (usbh_host *uhost);
#endif /* __USBH_MSC_BBB_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Include/usbh_msc_core.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Include/usbh_msc_core.h
index 6f32ddcf86..3f6380db26 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Include/usbh_msc_core.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Include/usbh_msc_core.h
@@ -3,32 +3,34 @@
\brief header file for the usbh_core.c
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -70,7 +72,7 @@ typedef enum
MSC_REQ_ERROR,
} msc_req_state;
-/* Structure for LUN */
+/* structure for LUN */
typedef struct
{
msc_state state;
@@ -82,7 +84,7 @@ typedef struct
uint8_t state_changed;
} msc_lun;
-/* structure for MSC process */
+/* structure for msc process */
typedef struct _msc_process
{
uint8_t pipe_in;
@@ -98,7 +100,7 @@ typedef struct _msc_process
msc_error error;
msc_req_state req_state;
msc_req_state prev_req_state;
- bot_handle bot;
+ bbb_handle bbb;
msc_lun unit[MSC_MAX_SUPPORTED_LUN];
uint32_t timer;
} usbh_msc_handler;
@@ -121,4 +123,4 @@ usbh_status usbh_msc_write (usbh_host *uhost,
uint8_t *pbuf,
uint32_t length);
-#endif /* __USBH_MSC_CORE_H */
+#endif /* __USBH_MSC_CORE_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Include/usbh_msc_scsi.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Include/usbh_msc_scsi.h
index 85cd3c65a1..013265cc2c 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Include/usbh_msc_scsi.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Include/usbh_msc_scsi.h
@@ -3,32 +3,34 @@
\brief header file for usbh_msc_scsi.c
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -62,7 +64,7 @@ typedef struct
uint32_t msc_sense_key;
uint16_t msc_page_len;
uint8_t msc_write_protect;
-}usbh_msc_parameter;
+} usbh_msc_parameter;
#define DESC_REQUEST_SENSE 0x00U
#define ALLOCATION_LENGTH_REQUEST_SENSE 63U
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_bbb.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_bbb.c
index b5129d8e74..6224d56c53 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_bbb.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_bbb.c
@@ -3,32 +3,34 @@
\brief USB MSC BBB protocol related functions
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -45,202 +47,202 @@ OF SUCH DAMAGE.
\param[out] none
\retval none
*/
-void usbh_msc_bot_init (usbh_host *uhost)
+void usbh_msc_bbb_init (usbh_host *uhost)
{
usbh_msc_handler *msc = (usbh_msc_handler *)uhost->active_class->class_data;
- msc->bot.cbw.field.dCBWSignature = BBB_CBW_SIGNATURE;
- msc->bot.cbw.field.dCBWTag = USBH_MSC_BOT_CBW_TAG;
- msc->bot.state = BOT_SEND_CBW;
- msc->bot.cmd_state = BOT_CMD_SEND;
+ msc->bbb.cbw.field.dCBWSignature = BBB_CBW_SIGNATURE;
+ msc->bbb.cbw.field.dCBWTag = USBH_MSC_BBB_CBW_TAG;
+ msc->bbb.state = BBB_SEND_CBW;
+ msc->bbb.cmd_state = BBB_CMD_SEND;
}
/*!
- \brief manage the different states of BOT transfer and updates the status to upper layer
- \param[in] uhost: pointer to usb host handler
+ \brief manage the different states of BBB transfer and updates the status to upper layer
+ \param[in] uhost: pointer to USB host handler
\param[in] lun: logic unit number
\param[out] none
\retval operation status
*/
-usbh_status usbh_msc_bot_process (usbh_host *uhost, uint8_t lun)
+usbh_status usbh_msc_bbb_process (usbh_host *uhost, uint8_t lun)
{
- bot_csw_status csw_status = BOT_CSW_CMD_FAILED;
+ bbb_csw_status csw_status = BBB_CSW_CMD_FAILED;
usbh_status status = USBH_BUSY;
usbh_status error = USBH_BUSY;
usb_urb_state urb_status = URB_IDLE;
usbh_msc_handler *msc = (usbh_msc_handler *)uhost->active_class->class_data;
- switch (msc->bot.state) {
- case BOT_SEND_CBW:
- msc->bot.cbw.field.bCBWLUN = lun;
- msc->bot.state = BOT_SEND_CBW_WAIT;
+ switch (msc->bbb.state) {
+ case BBB_SEND_CBW:
+ msc->bbb.cbw.field.bCBWLUN = lun;
+ msc->bbb.state = BBB_SEND_CBW_WAIT;
/* send CBW */
usbh_data_send (uhost->data,
- msc->bot.cbw.CBWArray,
- msc->pipe_out,
+ msc->bbb.cbw.CBWArray,
+ msc->pipe_out,
BBB_CBW_LENGTH);
break;
- case BOT_SEND_CBW_WAIT:
+ case BBB_SEND_CBW_WAIT:
urb_status = usbh_urbstate_get(uhost->data, msc->pipe_out);
if (URB_DONE == urb_status) {
- if (0U != msc->bot.cbw.field.dCBWDataTransferLength) {
- if (USB_TRX_IN == (msc->bot.cbw.field.bmCBWFlags & USB_TRX_MASK)) {
- msc->bot.state = BOT_DATA_IN;
+ if (0U != msc->bbb.cbw.field.dCBWDataTransferLength) {
+ if (USB_TRX_IN == (msc->bbb.cbw.field.bmCBWFlags & USB_TRX_MASK)) {
+ msc->bbb.state = BBB_DATA_IN;
} else {
- msc->bot.state = BOT_DATA_OUT;
+ msc->bbb.state = BBB_DATA_OUT;
}
} else {
- msc->bot.state = BOT_RECEIVE_CSW;
+ msc->bbb.state = BBB_RECEIVE_CSW;
}
} else if (URB_NOTREADY == urb_status) {
- msc->bot.state = BOT_SEND_CBW;
+ msc->bbb.state = BBB_SEND_CBW;
} else {
if (URB_STALL == urb_status) {
- msc->bot.state = BOT_ERROR_OUT;
+ msc->bbb.state = BBB_ERROR_OUT;
}
}
break;
- case BOT_DATA_IN:
- usbh_data_recev (uhost->data,
- msc->bot.pbuf,
- msc->pipe_in,
+ case BBB_DATA_IN:
+ usbh_data_recev (uhost->data,
+ msc->bbb.pbuf,
+ msc->pipe_in,
msc->ep_size_in);
- msc->bot.state = BOT_DATA_IN_WAIT;
+ msc->bbb.state = BBB_DATA_IN_WAIT;
break;
- case BOT_DATA_IN_WAIT:
+ case BBB_DATA_IN_WAIT:
urb_status = usbh_urbstate_get(uhost->data, msc->pipe_in);
- /* BOT DATA IN stage */
+ /* BBB DATA IN stage */
if (URB_DONE == urb_status) {
- if (msc->bot.cbw.field.dCBWDataTransferLength > msc->ep_size_in) {
- msc->bot.pbuf += msc->ep_size_in;
- msc->bot.cbw.field.dCBWDataTransferLength -= msc->ep_size_in;
+ if (msc->bbb.cbw.field.dCBWDataTransferLength > msc->ep_size_in) {
+ msc->bbb.pbuf += msc->ep_size_in;
+ msc->bbb.cbw.field.dCBWDataTransferLength -= msc->ep_size_in;
} else {
- msc->bot.cbw.field.dCBWDataTransferLength = 0U;
+ msc->bbb.cbw.field.dCBWDataTransferLength = 0U;
}
- if (msc->bot.cbw.field.dCBWDataTransferLength > 0U) {
- usbh_data_recev (uhost->data,
- msc->bot.pbuf,
- msc->pipe_in,
+ if (msc->bbb.cbw.field.dCBWDataTransferLength > 0U) {
+ usbh_data_recev (uhost->data,
+ msc->bbb.pbuf,
+ msc->pipe_in,
msc->ep_size_in);
} else {
- msc->bot.state = BOT_RECEIVE_CSW;
+ msc->bbb.state = BBB_RECEIVE_CSW;
}
} else if(URB_STALL == urb_status) {
/* this is data stage stall condition */
- msc->bot.state = BOT_ERROR_IN;
+ msc->bbb.state = BBB_ERROR_IN;
} else {
/* no operation */
}
break;
- case BOT_DATA_OUT:
+ case BBB_DATA_OUT:
usbh_data_send (uhost->data,
- msc->bot.pbuf,
- msc->pipe_out,
+ msc->bbb.pbuf,
+ msc->pipe_out,
msc->ep_size_out);
- msc->bot.state = BOT_DATA_OUT_WAIT;
+ msc->bbb.state = BBB_DATA_OUT_WAIT;
break;
- case BOT_DATA_OUT_WAIT:
- /* BOT DATA OUT stage */
+ case BBB_DATA_OUT_WAIT:
+ /* BBB DATA OUT stage */
urb_status = usbh_urbstate_get(uhost->data, msc->pipe_out);
if (URB_DONE == urb_status) {
- if (msc->bot.cbw.field.dCBWDataTransferLength > msc->ep_size_out) {
- msc->bot.pbuf += msc->ep_size_out;
- msc->bot.cbw.field.dCBWDataTransferLength -= msc->ep_size_out;
+ if (msc->bbb.cbw.field.dCBWDataTransferLength > msc->ep_size_out) {
+ msc->bbb.pbuf += msc->ep_size_out;
+ msc->bbb.cbw.field.dCBWDataTransferLength -= msc->ep_size_out;
} else {
- msc->bot.cbw.field.dCBWDataTransferLength = 0; /* reset this value and keep in same state */
+ msc->bbb.cbw.field.dCBWDataTransferLength = 0; /* reset this value and keep in same state */
}
- if (msc->bot.cbw.field.dCBWDataTransferLength > 0) {
+ if (msc->bbb.cbw.field.dCBWDataTransferLength > 0) {
usbh_data_send (uhost->data,
- msc->bot.pbuf,
- msc->pipe_out,
+ msc->bbb.pbuf,
+ msc->pipe_out,
msc->ep_size_out);
} else {
- msc->bot.state = BOT_RECEIVE_CSW;
+ msc->bbb.state = BBB_RECEIVE_CSW;
}
} else if (URB_NOTREADY == urb_status) {
- msc->bot.state = BOT_DATA_OUT;
+ msc->bbb.state = BBB_DATA_OUT;
} else if (URB_STALL == urb_status) {
- msc->bot.state = BOT_ERROR_OUT;
+ msc->bbb.state = BBB_ERROR_OUT;
} else {
/* no operation */
}
break;
- case BOT_RECEIVE_CSW:
- /* BOT CSW stage */
+ case BBB_RECEIVE_CSW:
+ /* BBB CSW stage */
usbh_data_recev (uhost->data,
- msc->bot.csw.CSWArray,
- msc->pipe_in,
+ msc->bbb.csw.CSWArray,
+ msc->pipe_in,
BBB_CSW_LENGTH);
- msc->bot.state = BOT_RECEIVE_CSW_WAIT;
+ msc->bbb.state = BBB_RECEIVE_CSW_WAIT;
break;
- case BOT_RECEIVE_CSW_WAIT:
+ case BBB_RECEIVE_CSW_WAIT:
urb_status = usbh_urbstate_get(uhost->data, msc->pipe_in);
/* decode CSW */
if (URB_DONE == urb_status) {
- msc->bot.state = BOT_SEND_CBW;
- msc->bot.cmd_state = BOT_CMD_SEND;
+ msc->bbb.state = BBB_SEND_CBW;
+ msc->bbb.cmd_state = BBB_CMD_SEND;
csw_status = usbh_msc_csw_decode(uhost);
- if (BOT_CSW_CMD_PASSED == csw_status) {
+ if (BBB_CSW_CMD_PASSED == csw_status) {
status = USBH_OK;
} else {
status = USBH_FAIL;
}
} else if (URB_STALL == urb_status) {
- msc->bot.state = BOT_ERROR_IN;
+ msc->bbb.state = BBB_ERROR_IN;
} else {
/* no operation */
}
break;
- case BOT_ERROR_IN:
- error = usbh_msc_bot_abort(uhost, USBH_MSC_DIR_IN);
+ case BBB_ERROR_IN:
+ error = usbh_msc_bbb_abort(uhost, USBH_MSC_DIR_IN);
if (USBH_OK == error) {
- msc->bot.state = BOT_RECEIVE_CSW;
+ msc->bbb.state = BBB_RECEIVE_CSW;
} else if (USBH_UNRECOVERED_ERROR == status) {
/* this means that there is a stall error limit, do reset recovery */
- msc->bot.state = BOT_UNRECOVERED_ERROR;
+ msc->bbb.state = BBB_UNRECOVERED_ERROR;
} else {
/* no operation */
}
break;
- case BOT_ERROR_OUT:
- status = usbh_msc_bot_abort (uhost, USBH_MSC_DIR_OUT);
+ case BBB_ERROR_OUT:
+ status = usbh_msc_bbb_abort (uhost, USBH_MSC_DIR_OUT);
if (USBH_OK == status) {
uint8_t toggle = usbh_pipe_toggle_get(uhost->data, msc->pipe_out);
usbh_pipe_toggle_set(uhost->data, msc->pipe_out, 1U - toggle);
usbh_pipe_toggle_set(uhost->data, msc->pipe_in, 0U);
- msc->bot.state = BOT_ERROR_IN;
+ msc->bbb.state = BBB_ERROR_IN;
} else {
if (USBH_UNRECOVERED_ERROR == status) {
- msc->bot.state = BOT_UNRECOVERED_ERROR;
+ msc->bbb.state = BBB_UNRECOVERED_ERROR;
}
}
break;
- case BOT_UNRECOVERED_ERROR:
- status = usbh_msc_bot_reset(uhost);
+ case BBB_UNRECOVERED_ERROR:
+ status = usbh_msc_bbb_reset(uhost);
if (USBH_OK == status) {
- msc->bot.state = BOT_SEND_CBW;
+ msc->bbb.state = BBB_SEND_CBW;
}
break;
@@ -258,21 +260,21 @@ usbh_status usbh_msc_bot_process (usbh_host *uhost, uint8_t lun)
\param[out] none
\retval operation status
*/
-usbh_status usbh_msc_bot_abort (usbh_host *uhost, uint8_t direction)
+usbh_status usbh_msc_bbb_abort (usbh_host *uhost, uint8_t direction)
{
usbh_status status = USBH_BUSY;
usbh_msc_handler *msc = (usbh_msc_handler *)uhost->active_class->class_data;
switch (direction) {
case USBH_MSC_DIR_IN :
- /* send clear feature command on bulk IN endpoint */
+ /* send clrfeature command on bulk IN endpoint */
status = usbh_clrfeature(uhost,
msc->ep_in,
msc->pipe_in);
break;
case USBH_MSC_DIR_OUT :
- /*send clear feature command on bulk OUT endpoint */
+ /*send clrfeature command on bulk OUT endpoint */
status = usbh_clrfeature(uhost,
msc->ep_out,
msc->pipe_out);
@@ -286,12 +288,12 @@ usbh_status usbh_msc_bot_abort (usbh_host *uhost, uint8_t direction)
}
/*!
- \brief reset MSC bot transfer
+ \brief reset msc bbb transfer
\param[in] uhost: pointer to USB host handler
\param[out] none
\retval operation status
*/
-usbh_status usbh_msc_bot_reset (usbh_host *uhost)
+usbh_status usbh_msc_bbb_reset (usbh_host *uhost)
{
usbh_status status = USBH_BUSY;
@@ -305,7 +307,7 @@ usbh_status usbh_msc_bot_reset (usbh_host *uhost)
};
usbh_ctlstate_config (uhost, NULL, 0U);
- }
+ }
status = usbh_ctl_handler (uhost);
@@ -318,43 +320,43 @@ usbh_status usbh_msc_bot_reset (usbh_host *uhost)
\param[out] none
\retval on success USBH_MSC_OK, on failure USBH_MSC_FAIL
\notes
- Refer to USB Mass-Storage Class: BOT (www.usb.org)
+ Refer to USB Mass-Storage Class: BBB (www.usb.org)
6.3.1 Valid CSW Conditions :
The host shall consider the CSW valid when:
1. dCSWSignature is equal to 53425355h
2. the CSW is 13 (Dh) bytes in length,
3. dCSWTag matches the dCBWTag from the corresponding CBW.
*/
-bot_csw_status usbh_msc_csw_decode (usbh_host *uhost)
+bbb_csw_status usbh_msc_csw_decode (usbh_host *uhost)
{
- bot_csw_status status = BOT_CSW_CMD_FAILED;
+ bbb_csw_status status = BBB_CSW_CMD_FAILED;
usbh_msc_handler *msc = (usbh_msc_handler *)uhost->active_class->class_data;
/* checking if the transfer length is different than 13 */
if (BBB_CSW_LENGTH != usbh_xfercount_get (uhost->data, msc->pipe_in)) {
- status = BOT_CSW_PHASE_ERROR;
+ status = BBB_CSW_PHASE_ERROR;
} else {
/* CSW length is correct */
/* check validity of the CSW Signature and CSWStatus */
- if (BBB_CSW_SIGNATURE == msc->bot.csw.field.dCSWSignature) {
+ if (BBB_CSW_SIGNATURE == msc->bbb.csw.field.dCSWSignature) {
/* check condition 1. dCSWSignature is equal to 53425355h */
- if (msc->bot.csw.field.dCSWTag == msc->bot.cbw.field.dCBWTag) {
+ if (msc->bbb.csw.field.dCSWTag == msc->bbb.cbw.field.dCBWTag) {
/* check condition 3. dCSWTag matches the dCBWTag from the corresponding CBW */
- if (0U == msc->bot.csw.field.bCSWStatus) {
- status = BOT_CSW_CMD_PASSED;
- } else if (1U == msc->bot.csw.field.bCSWStatus) {
- status = BOT_CSW_CMD_FAILED;
- } else if (2U == msc->bot.csw.field.bCSWStatus) {
- status = BOT_CSW_PHASE_ERROR;
+ if (0U == msc->bbb.csw.field.bCSWStatus) {
+ status = BBB_CSW_CMD_PASSED;
+ } else if (1U == msc->bbb.csw.field.bCSWStatus) {
+ status = BBB_CSW_CMD_FAILED;
+ } else if (2U == msc->bbb.csw.field.bCSWStatus) {
+ status = BBB_CSW_PHASE_ERROR;
} else {
/* no operation */
}
}
} else {
- /* If the CSW signature is not valid, we shall return the phase error to
+ /* if the CSW signature is not valid, we shall return the phase error to
upper layers for reset recovery */
- status = BOT_CSW_PHASE_ERROR;
+ status = BBB_CSW_PHASE_ERROR;
}
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_core.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_core.c
index afb992b017..81da24411b 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_core.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_core.c
@@ -3,32 +3,34 @@
\brief USB MSC(mass storage device) class driver
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -48,7 +50,7 @@ static usbh_status usbh_msc_handle (usbh_host *uhost);
static usbh_status usbh_msc_maxlun_get (usbh_host *uhost, uint8_t *maxlun);
static usbh_status usbh_msc_rdwr_process(usbh_host *uhost, uint8_t lun);
-usbh_class usbh_msc =
+usbh_class usbh_msc =
{
USB_CLASS_MSC,
usbh_msc_itf_init,
@@ -59,7 +61,7 @@ usbh_class usbh_msc =
/*!
\brief interface initialization for MSC class
- \param[in] uhost: pointer to usb host
+ \param[in] uhost: pointer to USB host
\param[out] none
\retval operation status
*/
@@ -74,65 +76,65 @@ static usbh_status usbh_msc_itf_init (usbh_host *uhost)
status = USBH_FAIL;
} else {
- uhost->active_class->class_data = (usbh_msc_handler *)malloc(sizeof(usbh_msc_handler));
-
- usbh_msc_handler *msc = (usbh_msc_handler *)uhost->active_class->class_data;
+ static usbh_msc_handler msc_handler;
- memset(msc, 0U, sizeof(usbh_msc_handler));
+ memset((void*)&msc_handler, 0U, sizeof(usbh_msc_handler));
+
+ uhost->active_class->class_data = (void *)&msc_handler;
usbh_interface_select(&uhost->dev_prop, interface);
usb_desc_ep *ep_desc = &uhost->dev_prop.cfg_desc_set.itf_desc_set[interface][0].ep_desc[0];
- if (ep_desc->bEndpointAddress & 0x80) {
- msc->ep_in = ep_desc->bEndpointAddress;
- msc->ep_size_in = ep_desc->wMaxPacketSize;
+ if (ep_desc->bEndpointAddress & 0x80U) {
+ msc_handler.ep_in = ep_desc->bEndpointAddress;
+ msc_handler.ep_size_in = ep_desc->wMaxPacketSize;
} else {
- msc->ep_out = ep_desc->bEndpointAddress;
- msc->ep_size_out = ep_desc->wMaxPacketSize;
+ msc_handler.ep_out = ep_desc->bEndpointAddress;
+ msc_handler.ep_size_out = ep_desc->wMaxPacketSize;
}
ep_desc = &uhost->dev_prop.cfg_desc_set.itf_desc_set[interface][0].ep_desc[1];
- if (ep_desc->bEndpointAddress & 0x80) {
- msc->ep_in = ep_desc->bEndpointAddress;
- msc->ep_size_in = ep_desc->wMaxPacketSize;
+ if (ep_desc->bEndpointAddress & 0x80U) {
+ msc_handler.ep_in = ep_desc->bEndpointAddress;
+ msc_handler.ep_size_in = ep_desc->wMaxPacketSize;
} else {
- msc->ep_out = ep_desc->bEndpointAddress;
- msc->ep_size_out = ep_desc->wMaxPacketSize;
+ msc_handler.ep_out = ep_desc->bEndpointAddress;
+ msc_handler.ep_size_out = ep_desc->wMaxPacketSize;
}
- msc->state = MSC_INIT;
- msc->error = MSC_OK;
- msc->req_state = MSC_REQ_IDLE;
- msc->pipe_out = usbh_pipe_allocate(uhost->data, msc->ep_out);
- msc->pipe_in = usbh_pipe_allocate(uhost->data, msc->ep_in);
+ msc_handler.state = MSC_INIT;
+ msc_handler.error = MSC_OK;
+ msc_handler.req_state = MSC_REQ_IDLE;
+ msc_handler.pipe_out = usbh_pipe_allocate(uhost->data, msc_handler.ep_out);
+ msc_handler.pipe_in = usbh_pipe_allocate(uhost->data, msc_handler.ep_in);
- usbh_msc_bot_init(uhost);
+ usbh_msc_bbb_init(uhost);
/* open the new channels */
usbh_pipe_create (uhost->data,
&uhost->dev_prop,
- msc->pipe_out,
+ msc_handler.pipe_out,
USB_EPTYPE_BULK,
- msc->ep_size_out);
+ msc_handler.ep_size_out);
usbh_pipe_create (uhost->data,
&uhost->dev_prop,
- msc->pipe_in,
+ msc_handler.pipe_in,
USB_EPTYPE_BULK,
- msc->ep_size_in);
+ msc_handler.ep_size_in);
- usbh_pipe_toggle_set (uhost->data, msc->pipe_out, 0U);
- usbh_pipe_toggle_set (uhost->data, msc->pipe_in, 0U);
+ usbh_pipe_toggle_set (uhost->data, msc_handler.pipe_out, 0U);
+ usbh_pipe_toggle_set (uhost->data, msc_handler.pipe_in, 0U);
}
return status;
}
/*!
- \brief de-initialize interface by freeing host channels allocated to interface
- \param[in] uhost: pointer to usb host
+ \brief deinitialize interface by freeing host channels allocated to interface
+ \param[in] uhost: pointer to USB host
\param[out] none
\retval operation status
*/
@@ -157,7 +159,7 @@ void usbh_msc_itf_deinit (usbh_host *uhost)
/*!
\brief initialize the MSC state machine
- \param[in] uhost: pointer to usb host
+ \param[in] uhost: pointer to USB host
\param[out] none
\retval operation status
*/
@@ -188,7 +190,7 @@ static usbh_status usbh_msc_req (usbh_host *uhost)
break;
case MSC_REQ_ERROR:
- /* issue clear feature request */
+ /* issue clearfeature request */
if (USBH_OK == usbh_clrfeature(uhost, 0x00U, uhost->control.pipe_out_num)) {
msc->req_state = msc->prev_req_state;
}
@@ -203,7 +205,7 @@ static usbh_status usbh_msc_req (usbh_host *uhost)
/*!
\brief MSC state machine handler
- \param[in] uhost: pointer to usb host
+ \param[in] uhost: pointer to USB host
\param[out] none
\retval operation status
*/
@@ -221,107 +223,108 @@ static usbh_status usbh_msc_handle (usbh_host *uhost)
msc->unit[msc->cur_lun].error = MSC_NOT_READY;
switch (msc->unit[msc->cur_lun].state) {
- case MSC_INIT:
- msc->unit[msc->cur_lun].state = MSC_READ_INQUIRY;
- msc->timer = uhost->control.timer;
- break;
+ case MSC_INIT:
+ msc->unit[msc->cur_lun].state = MSC_READ_INQUIRY;
+ msc->timer = uhost->control.timer;
+ break;
- case MSC_READ_INQUIRY:
- scsi_status = usbh_msc_scsi_inquiry(uhost, msc->cur_lun, &msc->unit[msc->cur_lun].inquiry);
+ case MSC_READ_INQUIRY:
+ scsi_status = usbh_msc_scsi_inquiry (uhost, msc->cur_lun, &msc->unit[msc->cur_lun].inquiry);
- if (USBH_OK == scsi_status) {
- msc->unit[msc->cur_lun].state = MSC_TEST_UNIT_READY;
- } else if (scsi_status == USBH_FAIL) {
- msc->unit[msc->cur_lun].state = MSC_REQUEST_SENSE;
- } else {
- if (scsi_status == USBH_UNRECOVERED_ERROR) {
- msc->unit[msc->cur_lun].state = MSC_IDLE;
- msc->unit[msc->cur_lun].error = MSC_ERROR;
- }
+ if (USBH_OK == scsi_status) {
+ msc->unit[msc->cur_lun].state = MSC_TEST_UNIT_READY;
+ } else if (scsi_status == USBH_FAIL) {
+ msc->unit[msc->cur_lun].state = MSC_REQUEST_SENSE;
+ } else {
+ if (scsi_status == USBH_UNRECOVERED_ERROR) {
+ msc->unit[msc->cur_lun].state = MSC_IDLE;
+ msc->unit[msc->cur_lun].error = MSC_ERROR;
}
- break;
+ }
+ break;
- case MSC_TEST_UNIT_READY:
- /* issue SCSI command TestUnitReady */
- ready_status = usbh_msc_test_unitready(uhost, msc->cur_lun);
+ case MSC_TEST_UNIT_READY:
+ /* issue SCSI command TestUnitReady */
+ ready_status = usbh_msc_test_unitready (uhost, msc->cur_lun);
- if (USBH_OK == ready_status) {
- if (USBH_OK != msc->unit[msc->cur_lun].prev_ready_state) {
- msc->unit[msc->cur_lun].state_changed = 1U;
- } else {
- msc->unit[msc->cur_lun].state_changed = 0U;
- }
-
- msc->unit[msc->cur_lun].state = MSC_READ_CAPACITY10;
- msc->unit[msc->cur_lun].error = MSC_OK;
- msc->unit[msc->cur_lun].prev_ready_state = USBH_OK;
- } else if (USBH_FAIL == ready_status) {
- if (USBH_FAIL != msc->unit[msc->cur_lun].prev_ready_state) {
- msc->unit[msc->cur_lun].state_changed = 1U;
- } else {
- msc->unit[msc->cur_lun].state_changed = 0U;
- }
+ if (USBH_OK == ready_status) {
+ if (USBH_OK != msc->unit[msc->cur_lun].prev_ready_state) {
+ msc->unit[msc->cur_lun].state_changed = 1U;
+ } else {
+ msc->unit[msc->cur_lun].state_changed = 0U;
+ }
- msc->unit[msc->cur_lun].state = MSC_REQUEST_SENSE;
- msc->unit[msc->cur_lun].error = MSC_NOT_READY;
- msc->unit[msc->cur_lun].prev_ready_state = USBH_FAIL;
+ msc->unit[msc->cur_lun].state = MSC_READ_CAPACITY10;
+ msc->unit[msc->cur_lun].error = MSC_OK;
+ msc->unit[msc->cur_lun].prev_ready_state = USBH_OK;
+ } else if (USBH_FAIL == ready_status) {
+ if (USBH_FAIL != msc->unit[msc->cur_lun].prev_ready_state) {
+ msc->unit[msc->cur_lun].state_changed = 1U;
} else {
- if (USBH_UNRECOVERED_ERROR == ready_status) {
- msc->unit[msc->cur_lun].state = MSC_IDLE;
- msc->unit[msc->cur_lun].error = MSC_ERROR;
- }
+ msc->unit[msc->cur_lun].state_changed = 0U;
}
- break;
- case MSC_READ_CAPACITY10:
- /* issue READ_CAPACITY10 SCSI command */
- scsi_status = usbh_msc_read_capacity10(uhost, msc->cur_lun, &msc->unit[msc->cur_lun].capacity);
+ msc->unit[msc->cur_lun].state = MSC_REQUEST_SENSE;
+ msc->unit[msc->cur_lun].error = MSC_NOT_READY;
+ msc->unit[msc->cur_lun].prev_ready_state = USBH_FAIL;
+ } else {
+ if (USBH_UNRECOVERED_ERROR == ready_status) {
+ msc->unit[msc->cur_lun].state = MSC_IDLE;
+ msc->unit[msc->cur_lun].error = MSC_ERROR;
+ }
+ }
+ break;
- if (USBH_OK == scsi_status) {
- if (1U == msc->unit[msc->cur_lun].state_changed) {
- }
+ case MSC_READ_CAPACITY10:
+ /* issue READ_CAPACITY10 SCSI command */
+ scsi_status = usbh_msc_read_capacity10 (uhost, msc->cur_lun, &msc->unit[msc->cur_lun].capacity);
+
+ if (USBH_OK == scsi_status) {
+ if (1U == msc->unit[msc->cur_lun].state_changed) {
+ }
+ msc->unit[msc->cur_lun].state = MSC_IDLE;
+ msc->unit[msc->cur_lun].error = MSC_OK;
+ msc->cur_lun ++;
+ } else if (USBH_FAIL == scsi_status) {
+ msc->unit[msc->cur_lun].state = MSC_REQUEST_SENSE;
+ } else {
+ if (USBH_UNRECOVERED_ERROR == scsi_status) {
msc->unit[msc->cur_lun].state = MSC_IDLE;
- msc->unit[msc->cur_lun].error = MSC_OK;
- msc->cur_lun ++;
- } else if (USBH_FAIL == scsi_status) {
- msc->unit[msc->cur_lun].state = MSC_REQUEST_SENSE;
- } else {
- if (USBH_UNRECOVERED_ERROR == scsi_status) {
- msc->unit[msc->cur_lun].state = MSC_IDLE;
- msc->unit[msc->cur_lun].error = MSC_ERROR;
- }
+ msc->unit[msc->cur_lun].error = MSC_ERROR;
}
- break;
+ }
+ break;
- case MSC_REQUEST_SENSE:
- /* issue RequestSense SCSI command for receiving error code */
- scsi_status = usbh_msc_request_sense (uhost, msc->cur_lun, &msc->unit[msc->cur_lun].sense);
- if (USBH_OK == scsi_status) {
- if ((msc->unit[msc->cur_lun].sense.SenseKey == UNIT_ATTENTION) || (msc->unit[msc->cur_lun].sense.SenseKey == NOT_READY)) {
- if ((uhost->control.timer - msc->timer) < 10000U) {
- msc->unit[msc->cur_lun].state = MSC_TEST_UNIT_READY;
- break;
- }
+ case MSC_REQUEST_SENSE:
+ /* issue RequestSense SCSI command for retrieving error code */
+ scsi_status = usbh_msc_request_sense (uhost, msc->cur_lun, &msc->unit[msc->cur_lun].sense);
+ if (USBH_OK == scsi_status) {
+ if ((msc->unit[msc->cur_lun].sense.SenseKey == UNIT_ATTENTION) || (msc->unit[msc->cur_lun].sense.SenseKey == NOT_READY)) {
+ if (((uhost->control.timer > msc->timer) && ((uhost->control.timer - msc->timer) < 10000U)) \
+ || ((uhost->control.timer < msc->timer) && ((uhost->control.timer + 0x3FFFU - msc->timer) < 10000U))) {
+ msc->unit[msc->cur_lun].state = MSC_TEST_UNIT_READY;
+ break;
}
+ }
+ msc->unit[msc->cur_lun].state = MSC_IDLE;
+ msc->cur_lun++;
+ } else if (USBH_FAIL == scsi_status) {
+ msc->unit[msc->cur_lun].state = MSC_UNRECOVERED_ERROR;
+ } else {
+ if (MSC_UNRECOVERED_ERROR == scsi_status) {
msc->unit[msc->cur_lun].state = MSC_IDLE;
- msc->cur_lun++;
- } else if (USBH_FAIL == scsi_status) {
- msc->unit[msc->cur_lun].state = MSC_UNRECOVERED_ERROR;
- } else {
- if (MSC_UNRECOVERED_ERROR == scsi_status) {
- msc->unit[msc->cur_lun].state = MSC_IDLE;
- msc->unit[msc->cur_lun].error = MSC_ERROR;
- }
+ msc->unit[msc->cur_lun].error = MSC_ERROR;
}
- break;
+ }
+ break;
- case MSC_UNRECOVERED_ERROR:
- msc->cur_lun ++;
- break;
+ case MSC_UNRECOVERED_ERROR:
+ msc->cur_lun++;
+ break;
- default:
- break;
+ default:
+ break;
}
} else {
msc->cur_lun = 0U;
@@ -362,7 +365,7 @@ static usbh_status usbh_msc_maxlun_get (usbh_host *uhost, uint8_t *maxlun)
};
usbh_ctlstate_config (uhost, maxlun, 1U);
- }
+ }
status = usbh_ctl_handler (uhost);
@@ -406,7 +409,7 @@ static usbh_status usbh_msc_rdwr_process(usbh_host *uhost, uint8_t lun)
if (USBH_OK == scsi_status) {
msc->unit[lun].state = MSC_IDLE;
error = USBH_OK;
- } else if(USBH_FAIL == scsi_status) {
+ } else if (USBH_FAIL == scsi_status) {
msc->unit[lun].state = MSC_REQUEST_SENSE;
} else {
if (USBH_UNRECOVERED_ERROR == scsi_status) {
@@ -425,7 +428,7 @@ static usbh_status usbh_msc_rdwr_process(usbh_host *uhost, uint8_t lun)
error = USBH_FAIL;
}
-
+
if (USBH_FAIL == scsi_status) {
} else {
if (USBH_UNRECOVERED_ERROR == scsi_status) {
@@ -483,8 +486,8 @@ usbh_status usbh_msc_read (usbh_host *uhost,
usbh_msc_handler *msc = (usbh_msc_handler *)uhost->active_class->class_data;
usb_core_driver *udev = (usb_core_driver *)uhost->data;
- if ((0U == udev->host.connect_status) ||
- (HOST_CLASS_HANDLER != uhost->cur_state) ||
+ if ((0U == udev->host.connect_status) ||
+ (HOST_CLASS_HANDLER != uhost->cur_state) ||
(MSC_IDLE != msc->unit[lun].state)) {
return USBH_FAIL;
}
@@ -498,7 +501,9 @@ usbh_status usbh_msc_read (usbh_host *uhost,
timeout = uhost->control.timer;
while (USBH_BUSY == usbh_msc_rdwr_process(uhost, lun)) {
- if (((uhost->control.timer - timeout) > (1000U * length)) || (0U == udev->host.connect_status)) {
+ if (((uhost->control.timer > timeout) && ((uhost->control.timer - timeout) > (10000U * length))) \
+ || ((uhost->control.timer < timeout) && ((uhost->control.timer + 0x3FFFU - timeout) > (10000U * length))) \
+ || (0U == udev->host.connect_status)){
msc->state = MSC_IDLE;
return USBH_FAIL;
}
@@ -529,8 +534,8 @@ usbh_status usbh_msc_write (usbh_host *uhost,
usb_core_driver *udev = (usb_core_driver *)uhost->data;
usbh_msc_handler *msc = (usbh_msc_handler *)uhost->active_class->class_data;
- if ((0U == udev->host.connect_status) ||
- (HOST_CLASS_HANDLER != uhost->cur_state) ||
+ if ((0U == udev->host.connect_status) ||
+ (HOST_CLASS_HANDLER != uhost->cur_state) ||
(MSC_IDLE != msc->unit[lun].state)) {
return USBH_FAIL;
}
@@ -544,7 +549,9 @@ usbh_status usbh_msc_write (usbh_host *uhost,
timeout = uhost->control.timer;
while (USBH_BUSY == usbh_msc_rdwr_process(uhost, lun)) {
- if (((uhost->control.timer - timeout) > (1000U * length)) || (0U == udev->host.connect_status)) {
+ if (((uhost->control.timer > timeout) && ((uhost->control.timer - timeout) > (10000U * length))) \
+ || ((uhost->control.timer < timeout) && ((uhost->control.timer + 0x3FFFU - timeout) > (10000U * length))) \
+ || (0U == udev->host.connect_status)){
msc->state = MSC_IDLE;
return USBH_FAIL;
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_fatfs.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_fatfs.c
index f89d7d740a..4a8f723935 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_fatfs.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_fatfs.c
@@ -3,32 +3,34 @@
\brief USB MSC host FATFS related functions
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -205,7 +207,7 @@ DRESULT disk_ioctl (BYTE drv, BYTE ctrl, void *buff)
/* get erase block size in unit of sector (dword) */
case GET_BLOCK_SIZE:
- *(DWORD*)buff = 512;
+ *(DWORD *)buff = 512U;
break;
default:
@@ -222,12 +224,12 @@ DRESULT disk_ioctl (BYTE drv, BYTE ctrl, void *buff)
\param[out] none
\retval time value
*/
-DWORD get_fattime(void) {
-
- return ((DWORD)(2019U - 1980U) << 25U) /* year 2019 */
- | ((DWORD)1U << 21U) /* month 1 */
- | ((DWORD)1U << 16U) /* day 1 */
- | ((DWORD)0U << 11U) /* hour 0 */
- | ((DWORD)0U << 5U) /* min 0 */
- | ((DWORD)0U >> 1U); /* sec 0 */
+DWORD get_fattime (void)
+{
+ return ((DWORD)(2019U - 1980U) << 25U) /* year 2019 */
+ | ((DWORD)1U << 21U) /* month 1 */
+ | ((DWORD)1U << 16U) /* day 1 */
+ | ((DWORD)0U << 11U) /* hour 0 */
+ | ((DWORD)0U << 5U) /* min 0 */
+ | ((DWORD)0U >> 1U); /* sec 0 */
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_scsi.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_scsi.c
index e9566af405..b7a9b593a7 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_scsi.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/class/msc/Source/usbh_msc_scsi.c
@@ -1,34 +1,36 @@
/*!
\file usbh_msc_scsi.c
- \brief USB MSC SCSI commands implementing
+ \brief USB MSC SCSI commands implemention
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -51,44 +53,44 @@ usbh_status usbh_msc_scsi_inquiry (usbh_host *uhost, uint8_t lun, scsi_std_inqui
usbh_status error = USBH_FAIL;
usbh_msc_handler *msc = (usbh_msc_handler *)uhost->active_class->class_data;
- switch (msc->bot.cmd_state) {
- case BOT_CMD_SEND:
- /* prepare the CBW and relevant field*/
- msc->bot.cbw.field.dCBWDataTransferLength = STANDARD_INQUIRY_DATA_LEN;
- msc->bot.cbw.field.bmCBWFlags = USB_TRX_IN;
- msc->bot.cbw.field.bCBWCBLength = CBW_LENGTH;
+ switch (msc->bbb.cmd_state) {
+ case BBB_CMD_SEND:
+ /* prepare the cbw and relevant field*/
+ msc->bbb.cbw.field.dCBWDataTransferLength = STANDARD_INQUIRY_DATA_LEN;
+ msc->bbb.cbw.field.bmCBWFlags = USB_TRX_IN;
+ msc->bbb.cbw.field.bCBWCBLength = CBW_LENGTH;
- memset(msc->bot.cbw.field.CBWCB, 0U, CBW_LENGTH);
+ memset(msc->bbb.cbw.field.CBWCB, 0U, CBW_LENGTH);
- msc->bot.cbw.field.CBWCB[0] = SCSI_INQUIRY;
- msc->bot.cbw.field.CBWCB[1] = (lun << 5U);
- msc->bot.cbw.field.CBWCB[4] = 0x24U;
+ msc->bbb.cbw.field.CBWCB[0] = SCSI_INQUIRY;
+ msc->bbb.cbw.field.CBWCB[1] = (lun << 5U);
+ msc->bbb.cbw.field.CBWCB[4] = 0x24U;
- msc->bot.state = BOT_SEND_CBW;
- msc->bot.cmd_state = BOT_CMD_WAIT;
- msc->bot.pbuf = (uint8_t *)(void *)msc->bot.data;
+ msc->bbb.state = BBB_SEND_CBW;
+ msc->bbb.cmd_state = BBB_CMD_WAIT;
+ msc->bbb.pbuf = (uint8_t *)(void *)msc->bbb.data;
error = USBH_BUSY;
break;
- case BOT_CMD_WAIT:
- error = usbh_msc_bot_process(uhost, lun);
+ case BBB_CMD_WAIT:
+ error = usbh_msc_bbb_process(uhost, lun);
if (USBH_OK == error) {
memset(inquiry, 0U, sizeof(scsi_std_inquiry_data));
/* assign inquiry data */
- inquiry->device_type = msc->bot.pbuf[0] & 0x1FU;
- inquiry->peripheral_qualifier = msc->bot.pbuf[0] >> 5U;
+ inquiry->device_type = msc->bbb.pbuf[0] & 0x1FU;
+ inquiry->peripheral_qualifier = msc->bbb.pbuf[0] >> 5U;
- if (0x80U == ((uint32_t)msc->bot.pbuf[1] & 0x80U)) {
+ if (0x80U == ((uint32_t)msc->bbb.pbuf[1] & 0x80U)) {
inquiry->removable_media = 1U;
} else {
inquiry->removable_media = 0U;
}
- memcpy (inquiry->vendor_id, &msc->bot.pbuf[8], 8U);
- memcpy (inquiry->product_id, &msc->bot.pbuf[16], 16U);
- memcpy (inquiry->revision_id, &msc->bot.pbuf[32], 4U);
+ memcpy (inquiry->vendor_id, &msc->bbb.pbuf[8], 8U);
+ memcpy (inquiry->product_id, &msc->bbb.pbuf[16], 16U);
+ memcpy (inquiry->revision_id, &msc->bbb.pbuf[32], 4U);
}
break;
@@ -112,24 +114,24 @@ usbh_status usbh_msc_test_unitready (usbh_host *uhost, uint8_t lun)
usbh_msc_handler *msc = (usbh_msc_handler *)uhost->active_class->class_data;
- switch (msc->bot.cmd_state) {
- case BOT_CMD_SEND:
+ switch (msc->bbb.cmd_state) {
+ case BBB_CMD_SEND:
/* prepare the CBW and relevant field */
- msc->bot.cbw.field.dCBWDataTransferLength = CBW_LENGTH_TEST_UNIT_READY;
- msc->bot.cbw.field.bmCBWFlags = USB_TRX_OUT;
- msc->bot.cbw.field.bCBWCBLength = CBW_LENGTH;
+ msc->bbb.cbw.field.dCBWDataTransferLength = CBW_LENGTH_TEST_UNIT_READY;
+ msc->bbb.cbw.field.bmCBWFlags = USB_TRX_OUT;
+ msc->bbb.cbw.field.bCBWCBLength = CBW_LENGTH;
- memset(msc->bot.cbw.field.CBWCB, 0U, CBW_CB_LENGTH);
+ memset(msc->bbb.cbw.field.CBWCB, 0U, CBW_CB_LENGTH);
- msc->bot.cbw.field.CBWCB[0] = SCSI_TEST_UNIT_READY;
- msc->bot.state = BOT_SEND_CBW;
- msc->bot.cmd_state = BOT_CMD_WAIT;
+ msc->bbb.cbw.field.CBWCB[0] = SCSI_TEST_UNIT_READY;
+ msc->bbb.state = BBB_SEND_CBW;
+ msc->bbb.cmd_state = BBB_CMD_WAIT;
status = USBH_BUSY;
break;
- case BOT_CMD_WAIT:
- status = usbh_msc_bot_process(uhost, lun);
+ case BBB_CMD_WAIT:
+ status = usbh_msc_bbb_process(uhost, lun);
break;
default:
@@ -152,33 +154,33 @@ usbh_status usbh_msc_read_capacity10 (usbh_host *uhost, uint8_t lun, scsi_capaci
usbh_status status = USBH_FAIL;
usbh_msc_handler *msc = (usbh_msc_handler *)uhost->active_class->class_data;
- switch (msc->bot.cmd_state) {
- case BOT_CMD_SEND:
+ switch (msc->bbb.cmd_state) {
+ case BBB_CMD_SEND:
/* prepare the CBW and relevant field */
- msc->bot.cbw.field.dCBWDataTransferLength = READ_CAPACITY10_DATA_LEN;
- msc->bot.cbw.field.bmCBWFlags = USB_TRX_IN;
- msc->bot.cbw.field.bCBWCBLength = CBW_LENGTH;
+ msc->bbb.cbw.field.dCBWDataTransferLength = READ_CAPACITY10_DATA_LEN;
+ msc->bbb.cbw.field.bmCBWFlags = USB_TRX_IN;
+ msc->bbb.cbw.field.bCBWCBLength = CBW_LENGTH;
- memset(msc->bot.cbw.field.CBWCB, 0U, CBW_CB_LENGTH);
+ memset(msc->bbb.cbw.field.CBWCB, 0U, CBW_CB_LENGTH);
- msc->bot.cbw.field.CBWCB[0] = SCSI_READ_CAPACITY10;
- msc->bot.state = BOT_SEND_CBW;
- msc->bot.cmd_state = BOT_CMD_WAIT;
- msc->bot.pbuf = (uint8_t *)(void *)msc->bot.data;
+ msc->bbb.cbw.field.CBWCB[0] = SCSI_READ_CAPACITY10;
+ msc->bbb.state = BBB_SEND_CBW;
+ msc->bbb.cmd_state = BBB_CMD_WAIT;
+ msc->bbb.pbuf = (uint8_t *)(void *)msc->bbb.data;
status = USBH_BUSY;
break;
- case BOT_CMD_WAIT:
- status = usbh_msc_bot_process(uhost, lun);
+ case BBB_CMD_WAIT:
+ status = usbh_msc_bbb_process(uhost, lun);
if (USBH_OK == status) {
- capacity->block_nbr = msc->bot.pbuf[3] | \
- ((uint32_t)msc->bot.pbuf[2] << 8U) | \
- ((uint32_t)msc->bot.pbuf[1] << 16U) | \
- ((uint32_t)msc->bot.pbuf[0] << 24U);
+ capacity->block_nbr = msc->bbb.pbuf[3] | \
+ ((uint32_t)msc->bbb.pbuf[2] << 8U) | \
+ ((uint32_t)msc->bbb.pbuf[1] << 16U) | \
+ ((uint32_t)msc->bbb.pbuf[0] << 24U);
- capacity->block_size = (uint16_t)(msc->bot.pbuf[7] | ((uint32_t)msc->bot.pbuf[6] << 8U));
+ capacity->block_size = (uint16_t)(msc->bbb.pbuf[7] | ((uint32_t)msc->bbb.pbuf[6] << 8U));
}
break;
@@ -202,30 +204,30 @@ usbh_status usbh_msc_mode_sense6 (usbh_host *uhost, uint8_t lun)
usbh_msc_handler *msc = (usbh_msc_handler *)uhost->active_class->class_data;
- switch (msc->bot.cmd_state) {
- case BOT_CMD_SEND:
+ switch (msc->bbb.cmd_state) {
+ case BBB_CMD_SEND:
/* prepare the CBW and relevant field */
- msc->bot.cbw.field.dCBWDataTransferLength = XFER_LEN_MODE_SENSE6;
- msc->bot.cbw.field.bmCBWFlags = USB_TRX_IN;
- msc->bot.cbw.field.bCBWCBLength = CBW_LENGTH;
+ msc->bbb.cbw.field.dCBWDataTransferLength = XFER_LEN_MODE_SENSE6;
+ msc->bbb.cbw.field.bmCBWFlags = USB_TRX_IN;
+ msc->bbb.cbw.field.bCBWCBLength = CBW_LENGTH;
- memset(msc->bot.cbw.field.CBWCB, 0U, CBW_CB_LENGTH);
+ memset(msc->bbb.cbw.field.CBWCB, 0U, CBW_CB_LENGTH);
- msc->bot.cbw.field.CBWCB[0] = SCSI_MODE_SENSE6;
- msc->bot.cbw.field.CBWCB[2] = MODE_SENSE_PAGE_CONTROL_FIELD | MODE_SENSE_PAGE_CODE;
- msc->bot.cbw.field.CBWCB[4] = XFER_LEN_MODE_SENSE6;
- msc->bot.state = BOT_SEND_CBW;
- msc->bot.cmd_state = BOT_CMD_WAIT;
- msc->bot.pbuf = (uint8_t *)(void *)msc->bot.data;
+ msc->bbb.cbw.field.CBWCB[0] = SCSI_MODE_SENSE6;
+ msc->bbb.cbw.field.CBWCB[2] = MODE_SENSE_PAGE_CONTROL_FIELD | MODE_SENSE_PAGE_CODE;
+ msc->bbb.cbw.field.CBWCB[4] = XFER_LEN_MODE_SENSE6;
+ msc->bbb.state = BBB_SEND_CBW;
+ msc->bbb.cmd_state = BBB_CMD_WAIT;
+ msc->bbb.pbuf = (uint8_t *)(void *)msc->bbb.data;
status = USBH_BUSY;
break;
- case BOT_CMD_WAIT:
- status = usbh_msc_bot_process(uhost, lun);
+ case BBB_CMD_WAIT:
+ status = usbh_msc_bbb_process(uhost, lun);
if (USBH_OK == status) {
- if (msc->bot.data[2] & MASK_MODE_SENSE_WRITE_PROTECT) {
+ if (msc->bbb.data[2] & MASK_MODE_SENSE_WRITE_PROTECT) {
} else {
@@ -254,34 +256,34 @@ usbh_status usbh_msc_request_sense (usbh_host *uhost, uint8_t lun, msc_scsi_sens
usbh_status status = USBH_FAIL;
usbh_msc_handler *msc = (usbh_msc_handler *)uhost->active_class->class_data;
- switch (msc->bot.cmd_state) {
- case BOT_CMD_SEND:
- /* prepare the CBW and relevant field */
- msc->bot.cbw.field.dCBWDataTransferLength = ALLOCATION_LENGTH_REQUEST_SENSE;
- msc->bot.cbw.field.bmCBWFlags = USB_TRX_IN;
- msc->bot.cbw.field.bCBWCBLength = CBW_LENGTH;
+ switch (msc->bbb.cmd_state) {
+ case BBB_CMD_SEND:
+ /* prepare the cbw and relevant field */
+ msc->bbb.cbw.field.dCBWDataTransferLength = ALLOCATION_LENGTH_REQUEST_SENSE;
+ msc->bbb.cbw.field.bmCBWFlags = USB_TRX_IN;
+ msc->bbb.cbw.field.bCBWCBLength = CBW_LENGTH;
- memset(msc->bot.cbw.field.CBWCB, 0U, CBW_CB_LENGTH);
+ memset(msc->bbb.cbw.field.CBWCB, 0U, CBW_CB_LENGTH);
- msc->bot.cbw.field.CBWCB[0] = SCSI_REQUEST_SENSE;
- msc->bot.cbw.field.CBWCB[1] = (lun << 5U);
- msc->bot.cbw.field.CBWCB[4] = ALLOCATION_LENGTH_REQUEST_SENSE;
+ msc->bbb.cbw.field.CBWCB[0] = SCSI_REQUEST_SENSE;
+ msc->bbb.cbw.field.CBWCB[1] = (lun << 5U);
+ msc->bbb.cbw.field.CBWCB[4] = ALLOCATION_LENGTH_REQUEST_SENSE;
- msc->bot.state = BOT_SEND_CBW;
- msc->bot.cmd_state = BOT_CMD_WAIT;
- msc->bot.pbuf = (uint8_t *)(void *)msc->bot.data;
+ msc->bbb.state = BBB_SEND_CBW;
+ msc->bbb.cmd_state = BBB_CMD_WAIT;
+ msc->bbb.pbuf = (uint8_t *)(void *)msc->bbb.data;
status = USBH_BUSY;
break;
- case BOT_CMD_WAIT:
- status = usbh_msc_bot_process(uhost, lun);
+ case BBB_CMD_WAIT:
+ status = usbh_msc_bbb_process(uhost, lun);
if (status == USBH_OK) {
/* get sense data */
- sense_data->SenseKey = msc->bot.pbuf[2] & 0x0FU;
- sense_data->ASC = msc->bot.pbuf[12];
- sense_data->ASCQ = msc->bot.pbuf[13];
+ sense_data->SenseKey = msc->bbb.pbuf[2] & 0x0FU;
+ sense_data->ASC = msc->bbb.pbuf[12];
+ sense_data->ASCQ = msc->bbb.pbuf[13];
}
break;
@@ -307,35 +309,35 @@ usbh_status usbh_msc_write10 (usbh_host *uhost, uint8_t lun, uint8_t *data_buf,
usbh_status status = USBH_FAIL;
usbh_msc_handler *msc = (usbh_msc_handler *)uhost->active_class->class_data;
- switch (msc->bot.cmd_state) {
- case BOT_CMD_SEND:
- msc->bot.cbw.field.dCBWDataTransferLength = sector_num * msc->unit[lun].capacity.block_size;
- msc->bot.cbw.field.bmCBWFlags = USB_TRX_OUT;
- msc->bot.cbw.field.bCBWCBLength = CBW_LENGTH;
+ switch (msc->bbb.cmd_state) {
+ case BBB_CMD_SEND:
+ msc->bbb.cbw.field.dCBWDataTransferLength = sector_num * msc->unit[lun].capacity.block_size;
+ msc->bbb.cbw.field.bmCBWFlags = USB_TRX_OUT;
+ msc->bbb.cbw.field.bCBWCBLength = CBW_LENGTH;
- memset(msc->bot.cbw.field.CBWCB, 0U, CBW_CB_LENGTH);
+ memset(msc->bbb.cbw.field.CBWCB, 0U, CBW_CB_LENGTH);
- msc->bot.cbw.field.CBWCB[0] = SCSI_WRITE10;
+ msc->bbb.cbw.field.CBWCB[0] = SCSI_WRITE10;
/* logical block address */
- msc->bot.cbw.field.CBWCB[2] = (((uint8_t*)&addr)[3]);
- msc->bot.cbw.field.CBWCB[3] = (((uint8_t*)&addr)[2]);
- msc->bot.cbw.field.CBWCB[4] = (((uint8_t*)&addr)[1]);
- msc->bot.cbw.field.CBWCB[5] = (((uint8_t*)&addr)[0]);
+ msc->bbb.cbw.field.CBWCB[2] = (((uint8_t*)&addr)[3]);
+ msc->bbb.cbw.field.CBWCB[3] = (((uint8_t*)&addr)[2]);
+ msc->bbb.cbw.field.CBWCB[4] = (((uint8_t*)&addr)[1]);
+ msc->bbb.cbw.field.CBWCB[5] = (((uint8_t*)&addr)[0]);
/* transfer length */
- msc->bot.cbw.field.CBWCB[7] = (((uint8_t *)&sector_num)[1]);
- msc->bot.cbw.field.CBWCB[8] = (((uint8_t *)&sector_num)[0]);
+ msc->bbb.cbw.field.CBWCB[7] = (((uint8_t *)&sector_num)[1]);
+ msc->bbb.cbw.field.CBWCB[8] = (((uint8_t *)&sector_num)[0]);
- msc->bot.state = BOT_SEND_CBW;
- msc->bot.cmd_state = BOT_CMD_WAIT;
- msc->bot.pbuf = data_buf;
+ msc->bbb.state = BBB_SEND_CBW;
+ msc->bbb.cmd_state = BBB_CMD_WAIT;
+ msc->bbb.pbuf = data_buf;
status = USBH_BUSY;
break;
- case BOT_CMD_WAIT:
- status = usbh_msc_bot_process(uhost, lun);
+ case BBB_CMD_WAIT:
+ status = usbh_msc_bbb_process(uhost, lun);
break;
default:
@@ -360,36 +362,36 @@ usbh_status usbh_msc_read10 (usbh_host *uhost, uint8_t lun, uint8_t *data_buf, u
usbh_status status = USBH_FAIL;
usbh_msc_handler *msc = (usbh_msc_handler *)uhost->active_class->class_data;
- switch (msc->bot.cmd_state) {
- case BOT_CMD_SEND:
+ switch (msc->bbb.cmd_state) {
+ case BBB_CMD_SEND:
/* prepare the CBW and relevant field */
- msc->bot.cbw.field.dCBWDataTransferLength = sector_num * msc->unit[lun].capacity.block_size;
- msc->bot.cbw.field.bmCBWFlags = USB_TRX_IN;
- msc->bot.cbw.field.bCBWCBLength = CBW_LENGTH;
+ msc->bbb.cbw.field.dCBWDataTransferLength = sector_num * msc->unit[lun].capacity.block_size;
+ msc->bbb.cbw.field.bmCBWFlags = USB_TRX_IN;
+ msc->bbb.cbw.field.bCBWCBLength = CBW_LENGTH;
- memset(msc->bot.cbw.field.CBWCB, 0U, CBW_CB_LENGTH);
+ memset(msc->bbb.cbw.field.CBWCB, 0U, CBW_CB_LENGTH);
- msc->bot.cbw.field.CBWCB[0] = SCSI_READ10;
+ msc->bbb.cbw.field.CBWCB[0] = SCSI_READ10;
/* logical block address */
- msc->bot.cbw.field.CBWCB[2] = (((uint8_t*)&addr)[3]);
- msc->bot.cbw.field.CBWCB[3] = (((uint8_t*)&addr)[2]);
- msc->bot.cbw.field.CBWCB[4] = (((uint8_t*)&addr)[1]);
- msc->bot.cbw.field.CBWCB[5] = (((uint8_t*)&addr)[0]);
+ msc->bbb.cbw.field.CBWCB[2] = (((uint8_t*)&addr)[3]);
+ msc->bbb.cbw.field.CBWCB[3] = (((uint8_t*)&addr)[2]);
+ msc->bbb.cbw.field.CBWCB[4] = (((uint8_t*)&addr)[1]);
+ msc->bbb.cbw.field.CBWCB[5] = (((uint8_t*)&addr)[0]);
/* transfer length */
- msc->bot.cbw.field.CBWCB[7] = (((uint8_t *)&sector_num)[1]);
- msc->bot.cbw.field.CBWCB[8] = (((uint8_t *)&sector_num)[0]);
+ msc->bbb.cbw.field.CBWCB[7] = (((uint8_t *)&sector_num)[1]);
+ msc->bbb.cbw.field.CBWCB[8] = (((uint8_t *)&sector_num)[0]);
- msc->bot.state = BOT_SEND_CBW;
- msc->bot.cmd_state = BOT_CMD_WAIT;
- msc->bot.pbuf = data_buf;
+ msc->bbb.state = BBB_SEND_CBW;
+ msc->bbb.cmd_state = BBB_CMD_WAIT;
+ msc->bbb.pbuf = data_buf;
status = USBH_BUSY;
break;
- case BOT_CMD_WAIT:
- status = usbh_msc_bot_process(uhost, lun);
+ case BBB_CMD_WAIT:
+ status = usbh_msc_bbb_process(uhost, lun);
break;
default:
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_core.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_core.h
index c8e7ca1e7c..3eca1de8d5 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_core.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_core.h
@@ -3,32 +3,34 @@
\brief USB host core state machine header file
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -64,15 +66,15 @@ typedef enum
{
HOST_DEFAULT = 0U,
HOST_DETECT_DEV_SPEED,
- HOST_DEV_ATTACHED,
+ HOST_DEV_CONNECT,
HOST_DEV_DETACHED,
- HOST_ENUM,
- HOST_SET_WAKEUP_FEATURE,
- HOST_CHECK_CLASS,
+ HOST_DEV_ENUM,
+ HOST_PWR_FEATURE_SET,
+ HOST_CLASS_CHECK,
HOST_CLASS_ENUM,
HOST_CLASS_HANDLER,
HOST_USER_INPUT,
- HOST_SUSPENDED,
+ HOST_SUSPEND,
HOST_WAKEUP,
HOST_ERROR
} usb_host_state;
@@ -94,7 +96,7 @@ typedef enum
} usbh_enum_state;
/* USB host control transfer state */
-typedef enum
+typedef enum
{
CTL_IDLE = 0U,
CTL_SETUP,
@@ -114,18 +116,17 @@ typedef enum
/* user action state */
typedef enum
{
- USBH_USER_NO_RESP = 0U,
- USBH_USER_RESP_OK = 1U,
+ USR_IN_NO_RESP = 0U,
+ USR_IN_RESP_OK = 1U,
} usbh_user_status;
+/* USB host wakeup mode */
typedef enum
{
- USBH_PORT_EVENT = 1U,
- USBH_URB_EVENT,
- USBH_CONTROL_EVENT,
- USBH_CLASS_EVENT,
- USBH_STATE_CHANGED_EVENT,
-}usbh_os_event;
+ NORMAL_WORK = 0U,
+ GENERAL_WAKEUP = 1U,
+ REMOTE_WAKEUP = 2,
+} usbh_wakeup_mode;
/* control transfer information */
typedef struct _usbh_control
@@ -169,9 +170,9 @@ typedef struct
usb_desc_dev dev_desc;
usb_desc_cfg_set cfg_desc_set;
-#if (USBH_KEEP_CFG_DESCRIPTOR == 1U)
+#if (USBH_CFG_DESC_KEEP == 1U)
uint8_t cfgdesc_rawdata[USBH_CFGSET_MAX_LEN];
-#endif /* (USBH_KEEP_CFG_DESCRIPTOR == 1U) */
+#endif /* (USBH_CFG_DESC_KEEP == 1U) */
} usb_dev_prop;
struct _usbh_host;
@@ -179,7 +180,7 @@ struct _usbh_host;
/* device class callbacks */
typedef struct
{
- uint8_t class_code; /*!< USB class type */
+ uint8_t class_code; /*!< USB class type */
usbh_status (*class_init) (struct _usbh_host *phost);
void (*class_deinit) (struct _usbh_host *phost);
@@ -203,7 +204,7 @@ typedef struct
void (*dev_devdesc_assigned) (void *dev_desc);
void (*dev_address_set) (void);
- void (*dev_cfgdesc_assigned) (usb_desc_config *cfg_desc,
+ void (*dev_cfgdesc_assigned) (usb_desc_config *cfg_desc,
usb_desc_itf *itf_desc,
usb_desc_ep *ep_desc);
@@ -234,9 +235,9 @@ typedef struct _usbh_host
void *data; /*!< used for... */
-#ifdef USB_LOW_PWR_ENABLE
- uint8_t suspend_flag;
-#endif /* USB_LOW_PWR_ENABLE*/
+ uint8_t suspend_flag; /*!< host suspend flag */
+ uint8_t dev_supp_remote_wkup; /*!< record device remote wakeup function */
+ usbh_wakeup_mode wakeup_mode; /*!< record wakeup mode */
} usbh_host;
/*!
@@ -274,9 +275,5 @@ usbh_status usbh_deinit (usbh_host *uhost);
void usbh_core_task (usbh_host *uhost);
/* handle the error on USB host side */
void usbh_error_handler (usbh_host *uhost, usbh_status err_type);
-#ifdef USB_LOW_PWR_ENABLE
-/* handles the USB resume from suspend mode */
-void usb_hwp_resume(usb_core_driver *udev);
-#endif /* USB_LOW_PWR_ENABLE */
#endif /* __USBH_CORE_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_enum.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_enum.h
index 3112d1a998..43127e6f0f 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_enum.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_enum.h
@@ -3,39 +3,40 @@
\brief USB host mode USB enumeration header file
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#ifndef __USBH_ENUM_H
#define __USBH_ENUM_H
-#include "usb_conf.h"
#include "usbh_core.h"
/* function declarations */
@@ -58,7 +59,7 @@ usbh_status usbh_setdevfeature (usbh_host *uhost, uint8_t feature_selector, uint
/* clear or disable a specific device feature */
usbh_status usbh_clrdevfeature (usbh_host *uhost, uint8_t feature_selector, uint16_t windex);
/* clear or disable a specific feature */
-usbh_status usbh_clrfeature (usbh_host *uhost, uint8_t ep_addr, uint8_t pp_num);
+usbh_status usbh_clrfeature (usbh_host *uhost, uint8_t ep_addr, uint8_t pp_num);
/* get the next descriptor header */
usb_desc_header *usbh_nextdesc_get (uint8_t *pbuf, uint16_t *ptr);
/* select an interface */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_pipe.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_pipe.h
index e89c5fe22f..58e51ea593 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_pipe.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_pipe.h
@@ -3,32 +3,34 @@
\brief USB host mode pipe header file
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -37,12 +39,14 @@ OF SUCH DAMAGE.
#include "usbh_core.h"
-#define HC_MAX 8U
+/* host pipe maximum */
+#define HP_MAX 8U
-#define HC_OK 0x0000U
-#define HC_USED 0x8000U
-#define HC_ERROR 0xFFFFU
-#define HC_USED_MASK 0x7FFFU
+/* host pipe status */
+#define HP_OK 0x0000U
+#define HP_USED 0x8000U
+#define HP_ERROR 0xFFFFU
+#define HP_USED_MASK 0x7FFFU
/*!
\brief set toggle for a pipe
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_transc.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_transc.h
index 65f4328c55..ea2f8d239f 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_transc.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Include/usbh_transc.h
@@ -3,39 +3,40 @@
\brief USB host mode transactions header file
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#ifndef __USBH_TRANSC_H
#define __USBH_TRANSC_H
-#include "usb_conf.h"
#include "usbh_core.h"
/* function declarations */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_core.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_core.c
index 8cb32af254..480b3aa19f 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_core.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_core.c
@@ -3,32 +3,34 @@
\brief USB host core state machine driver
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -40,37 +42,39 @@ OF SUCH DAMAGE.
#include <string.h>
/* local function prototypes ('static') */
-static uint8_t usbh_sof (usbh_host *uhost);
-static uint8_t usbh_connect (usbh_host *uhost);
-static uint8_t usbh_disconnect (usbh_host *uhost);
-static uint8_t usbh_port_enabled (usbh_host *uhost);
-static uint8_t usbh_port_disabled (usbh_host *uhost);
-static usbh_status usbh_enum_task (usbh_host *uhost);
+static uint8_t usb_ev_sof (usbh_host *uhost);
+static uint8_t usb_ev_connect (usbh_host *uhost);
+static uint8_t usb_ev_disconnect (usbh_host *uhost);
+static usbh_status usbh_enum_task (usbh_host *uhost);
+#if USBFS_LOW_POWER || USBHS_LOW_POWER
+static void usb_hwp_suspend (usb_core_driver *udev);
+static void usb_hwp_resume (usb_core_driver *udev);
+#endif /* USBFS_LOW_POWER || USBHS_LOW_POWER */
-#ifdef USB_LOW_PWR_ENABLE
-static void usb_hwp_suspend(usb_core_driver *udev);
-#endif
-
-usbh_int_cb usbh_int_op =
+usbh_ev_cb usbh_int_op =
{
- usbh_connect,
- usbh_disconnect,
- usbh_port_enabled,
- usbh_port_disabled,
- usbh_sof
+ usb_ev_connect,
+ usb_ev_disconnect,
+ usb_ev_sof,
};
-usbh_int_cb *usbh_int_fop = &usbh_int_op;
+usbh_ev_cb *usbh_int_fop = &usbh_int_op;
/*!
\brief USB host stack initializations
\param[in] uhost: pointer to USB host
+ \param[in] udev: pointer to USB device instance
+ \param[in] usb_core: USB core type
\param[in] user_cb: pointer to user callback
\param[out] none
\retval none
*/
void usbh_init (usbh_host *uhost, usb_core_driver *udev, usb_core_enum usb_core, usbh_user_cb *user_cb)
{
+ /* link driver to the stack */
+ udev->host.data = (void *)uhost;
+ uhost->data = (void *)udev;
+
/* host deinitialization */
usbh_deinit(uhost);
@@ -102,10 +106,6 @@ void usbh_init (usbh_host *uhost, usb_core_driver *udev, usb_core_enum usb_core,
usb_globalint_enable(&udev->regs);
#endif /* DUAL_ROLE_MODE_ENABLED */
- /* link driver to the stack */
- udev->host.data = (void *)uhost;
- uhost->data = (void *)udev;
-
/* upon initialize call usr call back */
uhost->usr_cb->dev_init();
}
@@ -135,7 +135,7 @@ usbh_status usbh_class_register (usbh_host *uhost, usbh_class *puclass)
}
/*!
- \brief de-initialize USB host
+ \brief deinitialize USB host
\param[in] uhost: pointer to USB host
\param[out] none
\retval operation status
@@ -195,7 +195,7 @@ void usbh_core_task (usbh_host *uhost)
case HOST_DETECT_DEV_SPEED:
if (udev->host.port_enabled) {
- uhost->cur_state = HOST_DEV_ATTACHED;
+ uhost->cur_state = HOST_DEV_CONNECT;
uhost->dev_prop.speed = usb_curspeed_get (udev);
@@ -205,7 +205,7 @@ void usbh_core_task (usbh_host *uhost)
}
break;
- case HOST_DEV_ATTACHED:
+ case HOST_DEV_CONNECT:
uhost->usr_cb->dev_attach();
uhost->control.pipe_out_num = usbh_pipe_allocate(udev, 0x00U);
uhost->control.pipe_in_num = usbh_pipe_allocate(udev, 0x80U);
@@ -224,10 +224,10 @@ void usbh_core_task (usbh_host *uhost)
USB_EPTYPE_CTRL,
(uint16_t)uhost->control.max_len);
- uhost->cur_state = HOST_ENUM;
+ uhost->cur_state = HOST_DEV_ENUM;
break;
- case HOST_ENUM:
+ case HOST_DEV_ENUM:
/* check for enumeration status */
if (USBH_OK == usbh_enum_task (uhost)) {
/* the function shall return USBH_OK when full enumeration is complete */
@@ -235,25 +235,32 @@ void usbh_core_task (usbh_host *uhost)
/* user callback for end of device basic enumeration */
uhost->usr_cb->dev_enumerated();
-#ifdef USB_LOW_PWR_ENABLE
- uhost->cur_state = HOST_SUSPENDED;
+#if USBFS_LOW_POWER || USBHS_LOW_POWER
+ uhost->cur_state = HOST_SUSPEND;
+
+ /* judge device remote wakeup function */
+ if ((uhost->dev_prop.cfg_desc_set.cfg_desc.bmAttributes) & (1U << 5)) {
+ uhost->dev_supp_remote_wkup = 1;
+ }else{
+ uhost->dev_supp_remote_wkup = 0;
+ }
#else
- uhost->cur_state = HOST_SET_WAKEUP_FEATURE;
-#endif
+ uhost->cur_state = HOST_PWR_FEATURE_SET;
+#endif /* USBFS_LOW_POWER || USBHS_LOW_POWER */
}
break;
- case HOST_SET_WAKEUP_FEATURE:
+ case HOST_PWR_FEATURE_SET:
if ((uhost->dev_prop.cfg_desc_set.cfg_desc.bmAttributes) & (1U << 5)) {
if (usbh_setdevfeature(uhost, FEATURE_SELECTOR_REMOTEWAKEUP, 0U) == USBH_OK) {
- uhost->cur_state = HOST_CHECK_CLASS;
+ uhost->cur_state = HOST_CLASS_CHECK;
}
} else {
- uhost->cur_state = HOST_CHECK_CLASS;
+ uhost->cur_state = HOST_CLASS_CHECK;
}
break;
- case HOST_CHECK_CLASS:
+ case HOST_CLASS_CHECK:
if (0U == uhost->class_num) {
uhost->cur_state = HOST_ERROR;
} else {
@@ -277,33 +284,61 @@ void usbh_core_task (usbh_host *uhost)
case HOST_USER_INPUT:
/* the function should return user response true to move to class state */
- if (USBH_USER_RESP_OK == uhost->usr_cb->dev_user_input()) {
+ if (USR_IN_RESP_OK == uhost->usr_cb->dev_user_input()) {
if ((USBH_OK == uhost->active_class->class_init(uhost))) {
uhost->cur_state = HOST_CLASS_ENUM;
}
}
break;
-#ifdef USB_LOW_PWR_ENABLE
- case HOST_SUSPENDED:
- if (USBH_OK == usbh_setdevfeature(uhost, FEATURE_SELECTOR_DEV, 0U)) {
- uhost->suspend_flag = 1;
- usb_hwp_suspend(uhost->data);
- uhost->usr_cb->dev_user_input();
- pmu_to_deepsleepmode(PMU_LDO_LOWPOWER, WFI_CMD);
- uhost->cur_state = HOST_WAKEUP;
+#if USBFS_LOW_POWER || USBHS_LOW_POWER
+ case HOST_SUSPEND:
+ if(uhost->dev_supp_remote_wkup){
+ /* send set feature command*/
+ if (USBH_OK == usbh_setdevfeature (uhost, FEATURE_SELECTOR_REMOTEWAKEUP, 0U)) {
+
+ usb_hwp_suspend (udev);
+
+ usb_mdelay (20U);
+ uhost->suspend_flag = 1;
+ uhost->usr_cb->dev_user_input();
+
+ /* MCU enter deep-sleep*/
+ pmu_to_deepsleepmode (PMU_LDO_LOWPOWER, PMU_LOWDRIVER_DISABLE, WFI_CMD);
+ uhost->cur_state = HOST_WAKEUP;
+ }
+ } else {
+ /* host suspend */
+ usb_hwp_suspend (udev);
+
+ usb_mdelay(20U);
+ uhost->suspend_flag = 1U;
+ uhost->usr_cb->dev_user_input();
+
+ /* MCU enter deep-sleep */
+ pmu_to_deepsleepmode (PMU_LDO_LOWPOWER, PMU_LOWDRIVER_DISABLE, WFI_CMD);
+ uhost->cur_state = HOST_WAKEUP;
}
break;
case HOST_WAKEUP:
- if (USBH_OK == usbh_clrdevfeature(uhost, FEATURE_SELECTOR_DEV, 0U)) {
- /* user callback for initialization */
- uhost->usr_cb->dev_init();
-
- uhost->cur_state = HOST_CHECK_CLASS;
+ /* judge suspend status */
+ if (0U == uhost->suspend_flag) {
+ usb_hwp_resume(udev);
+ usb_mdelay(500U);
+
+ if (uhost->dev_supp_remote_wkup) {
+ if (USBH_OK == usbh_clrdevfeature (uhost, FEATURE_SELECTOR_DEV, 0U)) {
+ /* user callback for initialization */
+ uhost->usr_cb->dev_init();
+ uhost->cur_state = HOST_CLASS_CHECK;
+ }
+ } else {
+ uhost->cur_state = HOST_CLASS_CHECK;
+ }
}
break;
-#endif
+#endif /* USBFS_LOW_POWER || USBHS_LOW_POWER */
case HOST_CLASS_ENUM:
/* process class standard control requests state machine */
@@ -324,7 +359,7 @@ void usbh_core_task (usbh_host *uhost)
break;
case HOST_ERROR:
- /* initialize host for new enumeration */
+ /* deinitialize host for new enumeration */
usbh_deinit (uhost);
uhost->usr_cb->dev_deinit();
uhost->active_class->class_deinit(uhost);
@@ -335,7 +370,7 @@ void usbh_core_task (usbh_host *uhost)
uhost->usr_cb->dev_detach();
/* re-initialize host for new enumeration */
- usbh_deinit(uhost);
+ usbh_deinit (uhost);
uhost->usr_cb->dev_deinit();
uhost->active_class->class_deinit(uhost);
usbh_pipe_delete(udev);
@@ -372,12 +407,12 @@ void usbh_error_handler (usbh_host *uhost, usbh_status err_type)
}
/*!
- \brief USB SOF callback function from the interrupt
+ \brief USB SOF event function from the interrupt
\param[in] uhost: pointer to USB host
\param[out] none
\retval operation status
*/
-static uint8_t usbh_sof (usbh_host *uhost)
+static uint8_t usb_ev_sof (usbh_host *uhost)
{
usb_core_driver *udev = (usb_core_driver *)uhost->data;
@@ -394,12 +429,12 @@ static uint8_t usbh_sof (usbh_host *uhost)
}
/*!
- \brief USB connect callback function from the interrupt
+ \brief USB connect event function from the interrupt
\param[in] uhost: pointer to USB host
\param[out] none
\retval operation status
*/
-static uint8_t usbh_connect (usbh_host *uhost)
+static uint8_t usb_ev_connect (usbh_host *uhost)
{
usb_core_driver *udev = (usb_core_driver *)uhost->data;
udev->host.connect_status = 1U;
@@ -408,12 +443,12 @@ static uint8_t usbh_connect (usbh_host *uhost)
}
/*!
- \brief USB disconnect callback function from the interrupt
+ \brief USB disconnect event function from the interrupt
\param[in] uhost: pointer to USB host
\param[out] none
\retval operation status
*/
-static uint8_t usbh_disconnect (usbh_host *uhost)
+static uint8_t usb_ev_disconnect (usbh_host *uhost)
{
usb_core_driver *udev = (usb_core_driver *)uhost->data;
udev->host.connect_status = 0U;
@@ -422,34 +457,6 @@ static uint8_t usbh_disconnect (usbh_host *uhost)
}
/*!
- \brief USB port enable callback function from the interrupt
- \param[in] uhost: pointer to USB host
- \param[out] none
- \retval operation status
-*/
-static uint8_t usbh_port_enabled (usbh_host *uhost)
-{
- usb_core_driver *udev = (usb_core_driver *)uhost->data;
- udev->host.port_enabled = 1U;
-
- return 0U;
-}
-
-/*!
- \brief USB port disabled callback function from the interrupt
- \param[in] uhost: pointer to USB host
- \param[out] none
- \retval operation status
-*/
-static uint8_t usbh_port_disabled (usbh_host *uhost)
-{
- usb_core_driver *udev = (usb_core_driver *)uhost->data;
- udev->host.port_enabled = 0U;
-
- return 0U;
-}
-
-/*!
\brief handle the USB enumeration task
\param[in] uhost: pointer to host
\param[out] none
@@ -457,7 +464,7 @@ static uint8_t usbh_port_disabled (usbh_host *uhost)
*/
static usbh_status usbh_enum_task (usbh_host *uhost)
{
- uint8_t str_buf[64];
+ uint8_t str_buf[512];
usbh_status status = USBH_BUSY;
usb_core_driver *udev = (usb_core_driver *)uhost->data;
@@ -497,7 +504,7 @@ static usbh_status usbh_enum_task (usbh_host *uhost)
}
break;
- case ENUM_SET_ADDR:
+ case ENUM_SET_ADDR:
/* set address */
if (USBH_OK == usbh_setaddress (uhost, USBH_DEV_ADDR)) {
usb_mdelay (2U);
@@ -543,8 +550,8 @@ static usbh_status usbh_enum_task (usbh_host *uhost)
case ENUM_GET_STR_DESC:
if (index_mfc_str) {
- if (USBH_OK == usbh_strdesc_get (uhost,
- uhost->dev_prop.dev_desc.iManufacturer,
+ if (USBH_OK == usbh_strdesc_get (uhost,
+ uhost->dev_prop.dev_desc.iManufacturer,
str_buf,
0xFFU)) {
/* user callback for manufacturing string */
@@ -555,9 +562,9 @@ static usbh_status usbh_enum_task (usbh_host *uhost)
} else {
if (index_prod_str) {
/* check that product string is available */
- if (USBH_OK == usbh_strdesc_get (uhost,
- uhost->dev_prop.dev_desc.iProduct,
- str_buf,
+ if (USBH_OK == usbh_strdesc_get (uhost,
+ uhost->dev_prop.dev_desc.iProduct,
+ str_buf,
0xFFU)) {
uhost->usr_cb->dev_prod_str(str_buf);
@@ -565,9 +572,9 @@ static usbh_status usbh_enum_task (usbh_host *uhost)
}
} else {
if (index_serial_str) {
- if (USBH_OK == usbh_strdesc_get (uhost,
+ if (USBH_OK == usbh_strdesc_get (uhost,
uhost->dev_prop.dev_desc.iSerialNumber,
- str_buf,
+ str_buf,
0xFFU)) {
uhost->usr_cb->dev_seral_str(str_buf);
uhost->enum_state = ENUM_SET_CONFIGURATION;
@@ -597,7 +604,7 @@ static usbh_status usbh_enum_task (usbh_host *uhost)
return status;
}
-#ifdef USB_LOW_PWR_ENABLE
+#if USBFS_LOW_POWER || USBHS_LOW_POWER
/*!
\brief handles the USB resume from suspend mode
@@ -605,7 +612,7 @@ static usbh_status usbh_enum_task (usbh_host *uhost)
\param[out] none
\retval none
*/
-void usb_hwp_resume(usb_core_driver *udev)
+static void usb_hwp_resume(usb_core_driver *udev)
{
__IO uint32_t hprt = 0U;
@@ -650,4 +657,4 @@ static void usb_hwp_suspend(usb_core_driver *udev)
*udev->regs.PWRCLKCTL |= PWRCLKCTL_SHCLK;
}
-#endif /* USB_LOW_PWR_ENABLE */
+#endif /* USBFS_LOW_POWER || USBHS_LOW_POWER */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_enum.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_enum.c
index 7966d8a9ac..361acdb3c9 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_enum.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_enum.c
@@ -3,32 +3,34 @@
\brief USB host mode enumeration driver
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -111,11 +113,11 @@ usbh_status usbh_cfgdesc_get (usbh_host *uhost, uint16_t len)
usbh_control *usb_ctl = &uhost->control;
-#if (USBH_KEEP_CFG_DESCRIPTOR == 1U)
+#if (USBH_CFG_DESC_KEEP == 1U)
pdata = uhost->dev_prop.cfgdesc_rawdata;
#else
pdata = uhost->dev_prop.data;
-#endif
+#endif /* (USBH_CFG_DESC_KEEP == 1U) */
if (CTL_IDLE == usb_ctl->ctl_state) {
usb_ctl->setup.req = (usb_req) {
@@ -152,8 +154,8 @@ usbh_status usbh_cfgdesc_get (usbh_host *uhost, uint16_t len)
\retval operation status
*/
usbh_status usbh_strdesc_get (usbh_host *uhost,
- uint8_t str_index,
- uint8_t *buf,
+ uint8_t str_index,
+ uint8_t *buf,
uint16_t len)
{
usbh_status status = USBH_BUSY;
@@ -297,7 +299,7 @@ usbh_status usbh_setdevfeature (usbh_host *uhost, uint8_t feature_selector, uint
};
usbh_ctlstate_config (uhost, NULL, 0U);
- }
+ }
status = usbh_ctl_handler (uhost);
@@ -328,7 +330,7 @@ usbh_status usbh_clrdevfeature (usbh_host *uhost, uint8_t feature_selector, uint
};
usbh_ctlstate_config (uhost, NULL, 0U);
- }
+ }
status = usbh_ctl_handler (uhost);
@@ -343,7 +345,7 @@ usbh_status usbh_clrdevfeature (usbh_host *uhost, uint8_t feature_selector, uint
\param[out] none
\retval operation status
*/
-usbh_status usbh_clrfeature (usbh_host *uhost, uint8_t ep_addr, uint8_t pp_num)
+usbh_status usbh_clrfeature (usbh_host *uhost, uint8_t ep_addr, uint8_t pp_num)
{
usbh_status status = USBH_BUSY;
usbh_control *usb_ctl = &uhost->control;
@@ -365,7 +367,7 @@ usbh_status usbh_clrfeature (usbh_host *uhost, uint8_t ep_addr, uint8_t pp_num)
}
usbh_ctlstate_config (uhost, NULL, 0U);
- }
+ }
status = usbh_ctl_handler (uhost);
@@ -676,13 +678,13 @@ static void usbh_strdesc_parse (uint8_t *psrc, uint8_t *pdest, uint16_t len)
if (USB_DESCTYPE_STR == psrc[1]) {
/* make sure the descriptor is string type */
- /* psrc[0] contains Size of Descriptor, subtract 2 to get the length of string */
+ /* psrc[0] contains size of descriptor, subtract 2 to get the length of string */
str_len = USB_MIN((uint16_t)psrc[0] - 2U, len);
- psrc += 2U; /* adjust the offset ignoring the string len and descriptor type */
+ psrc += 2U; /* adjust the offset ignoring the string length and descriptor type */
- for (index = 0U; index < str_len; index += 2U) {
- /* copy only the string and ignore the unicode id, hence add the src */
+ for(index = 0U; index < str_len; index += 2U) {
+ /* copy only the string and ignore the unicode id, hence add the source */
*pdest = psrc[index];
pdest++;
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_pipe.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_pipe.c
index 7d00be8d2a..a3d6253dc2 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_pipe.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_pipe.c
@@ -3,32 +3,34 @@
\brief USB host mode pipe operation driver
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -59,11 +61,14 @@ uint8_t usbh_pipe_create (usb_core_driver *udev,
pp->dev_speed = dev->speed;
pp->ep.type = ep_type;
pp->ep.mps = ep_mpl;
- pp->ping = (uint8_t)(dev->speed == PORT_SPEED_HIGH);
+
+ if ((USB_USE_DMA != udev->bp.transfer_mode) && ((USB_EPTYPE_BULK == pp->ep.type) || (USB_EPTYPE_CTRL == pp->ep.type))) {
+ pp->supp_ping = (uint8_t)(pp->dev_speed == PORT_SPEED_HIGH);
+ }
usb_pipe_init (udev, pp_num);
- return HC_OK;
+ return HP_OK;
}
/*!
@@ -90,15 +95,19 @@ uint8_t usbh_pipe_update (usb_core_driver *udev,
if ((pp->dev_speed != dev_speed) && (dev_speed)) {
pp->dev_speed = dev_speed;
+
+ if ((USB_USE_DMA != udev->bp.transfer_mode) && ((USB_EPTYPE_BULK == pp->ep.type) || (USB_EPTYPE_CTRL == pp->ep.type))) {
+ pp->supp_ping = (uint8_t)(pp->dev_speed == PORT_SPEED_HIGH);
+ }
}
if ((pp->ep.mps != ep_mpl) && (ep_mpl)) {
- pp->ep.mps = ep_mpl;
+ pp->ep.mps = ep_mpl;
}
usb_pipe_init (udev, pp_num);
- return HC_OK;
+ return HP_OK;
}
/*!
@@ -112,7 +121,7 @@ uint8_t usbh_pipe_allocate (usb_core_driver *udev, uint8_t ep_addr)
{
uint16_t pp_num = usbh_freepipe_get (udev);
- if (HC_ERROR != pp_num) {
+ if (HP_ERROR != pp_num) {
udev->host.pipe[pp_num].in_used = 1U;
udev->host.pipe[pp_num].ep.dir = EP_DIR(ep_addr);
udev->host.pipe[pp_num].ep.num = EP_ID(ep_addr);
@@ -130,7 +139,7 @@ uint8_t usbh_pipe_allocate (usb_core_driver *udev, uint8_t ep_addr)
*/
uint8_t usbh_pipe_free (usb_core_driver *udev, uint8_t pp_num)
{
- if (pp_num < HC_MAX) {
+ if (pp_num < HP_MAX) {
udev->host.pipe[pp_num].in_used = 0U;
}
@@ -147,7 +156,7 @@ uint8_t usbh_pipe_delete (usb_core_driver *udev)
{
uint8_t pp_num = 0U;
- for (pp_num = 2U; pp_num < HC_MAX; pp_num++) {
+ for (pp_num = 2U; pp_num < HP_MAX; pp_num++) {
udev->host.pipe[pp_num] = (usb_pipe) {0};
}
@@ -164,11 +173,11 @@ static uint16_t usbh_freepipe_get (usb_core_driver *udev)
{
uint8_t pp_num = 0U;
- for (pp_num = 0U; pp_num < HC_MAX; pp_num++) {
+ for (pp_num = 0U; pp_num < HP_MAX; pp_num++) {
if (0U == udev->host.pipe[pp_num].in_used) {
return (uint16_t)pp_num;
}
}
- return HC_ERROR;
+ return HP_ERROR;
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_transc.c b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_transc.c
index 63d6121350..7ceeac6e25 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_transc.c
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/host/core/Source/usbh_transc.c
@@ -3,32 +3,34 @@
\brief USB host mode transactions driver
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -37,12 +39,12 @@ OF SUCH DAMAGE.
#include "usbh_transc.h"
/* local function prototypes ('static') */
-static usb_urb_state usbh_urb_wait (usbh_host *uhost, uint8_t pp_num, uint32_t wait_time);
-static void usbh_setup_transc (usbh_host *uhost);
-static void usbh_data_in_transc (usbh_host *uhost);
-static void usbh_data_out_transc (usbh_host *uhost);
-static void usbh_status_in_transc (usbh_host *uhost);
-static void usbh_status_out_transc (usbh_host *uhost);
+static usb_urb_state usbh_urb_wait (usbh_host *uhost, uint8_t pp_num, uint32_t wait_time);
+static void usbh_setup_transc (usbh_host *uhost);
+static void usbh_data_in_transc (usbh_host *uhost);
+static void usbh_data_out_transc (usbh_host *uhost);
+static void usbh_status_in_transc (usbh_host *uhost);
+static void usbh_status_out_transc (usbh_host *uhost);
static uint32_t usbh_request_submit (usb_core_driver *udev, uint8_t pp_num);
/*!
@@ -136,7 +138,7 @@ usbh_status usbh_data_recev (usb_core_driver *udev, uint8_t *buf, uint8_t pp_num
case USB_EPTYPE_INTR:
pp->DPID = PIPE_DPID[pp->data_toggle_in];
- /* Toggle DATA PID */
+ /* toggle DATA PID */
pp->data_toggle_in ^= 1U;
break;
@@ -220,7 +222,9 @@ usbh_status usbh_ctl_handler (usbh_host *uhost)
*/
static usb_urb_state usbh_urb_wait (usbh_host *uhost, uint8_t pp_num, uint32_t wait_time)
{
+ uint32_t timeout = 0U;
usb_urb_state urb_status = URB_IDLE;
+ timeout = uhost->control.timer;
while (URB_DONE != (urb_status = usbh_urbstate_get(uhost->data, pp_num))) {
if (URB_NOTREADY == urb_status) {
@@ -231,7 +235,8 @@ static usb_urb_state usbh_urb_wait (usbh_host *uhost, uint8_t pp_num, uint32_t w
} else if (URB_ERROR == urb_status) {
uhost->control.ctl_state = CTL_ERROR;
break;
- } else if ((wait_time > 0U) && ((usb_curframe_get(uhost->data)- uhost->control.timer) > wait_time)) {
+ } else if ((wait_time > 0U) && (((usb_curframe_get(uhost->data) > timeout) && ((usb_curframe_get(uhost->data) - timeout) > wait_time)) \
+ || ((usb_curframe_get(uhost->data) < timeout) && ((usb_curframe_get(uhost->data) + 0x3FFFU - timeout) > wait_time)))){
/* timeout for in transfer */
uhost->control.ctl_state = CTL_ERROR;
break;
@@ -252,8 +257,8 @@ static usb_urb_state usbh_urb_wait (usbh_host *uhost, uint8_t pp_num, uint32_t w
static void usbh_setup_transc (usbh_host *uhost)
{
/* send a SETUP packet */
- usbh_ctlsetup_send (uhost->data,
- uhost->control.setup.data,
+ usbh_ctlsetup_send (uhost->data,
+ uhost->control.setup.data,
uhost->control.pipe_out_num);
if (URB_DONE == usbh_urb_wait (uhost, uhost->control.pipe_out_num, 0U)) {
@@ -294,7 +299,6 @@ static void usbh_data_in_transc (usbh_host *uhost)
if (URB_DONE == usbh_urb_wait (uhost, uhost->control.pipe_in_num, DATA_STAGE_TIMEOUT)) {
uhost->control.ctl_state = CTL_STATUS_OUT;
- uhost->control.timer = (uint16_t)usb_curframe_get(uhost->data);
}
}
@@ -315,8 +319,6 @@ static void usbh_data_out_transc (usbh_host *uhost)
if (URB_DONE == usbh_urb_wait (uhost, uhost->control.pipe_out_num, DATA_STAGE_TIMEOUT)) {
uhost->control.ctl_state = CTL_STATUS_IN;
-
- uhost->control.timer = (uint16_t)usb_curframe_get(uhost->data);
}
}
@@ -361,10 +363,15 @@ static void usbh_status_out_transc (usbh_host *uhost)
\param[out] none
\retval operation status
*/
-static uint32_t usbh_request_submit (usb_core_driver *udev, uint8_t pp_num)
+static uint32_t usbh_request_submit (usb_core_driver *udev, uint8_t pp_num)
{
udev->host.pipe[pp_num].urb_state = URB_IDLE;
udev->host.pipe[pp_num].xfer_count = 0U;
+ if (1U == udev->host.pipe[pp_num].do_ping) {
+ (void)usb_pipe_ping (udev, (uint8_t)pp_num);
+ return USB_OK;
+ }
+
return (uint32_t)usb_pipe_xfer (udev, pp_num);
}
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/cdc/usb_cdc.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/cdc/usb_cdc.h
index df3e56538d..0a2595cd02 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/cdc/usb_cdc.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/cdc/usb_cdc.h
@@ -3,32 +3,34 @@
\brief the header file of communication device class standard
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/hid/usb_hid.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/hid/usb_hid.h
index 220468f42b..dacec6e8e6 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/hid/usb_hid.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/hid/usb_hid.h
@@ -3,32 +3,34 @@
\brief definitions for the USB HID class
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -78,6 +80,6 @@ typedef struct
usb_desc_hid hid_vendor;
usb_desc_ep hid_epin;
usb_desc_ep hid_epout;
-}usb_hid_desc_config_set;
+} usb_hid_desc_config_set;
#endif /* __USB_HID_H */
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/msc/msc_bbb.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/msc/msc_bbb.h
index dddab34227..b3c5130313 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/msc/msc_bbb.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/msc/msc_bbb.h
@@ -3,32 +3,34 @@
\brief definitions for the USB MSC BBB(bulk/bulk/bulk) protocol
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -50,14 +52,14 @@ typedef struct {
uint8_t bCBWLUN;
uint8_t bCBWCBLength;
uint8_t CBWCB[16];
-}msc_bbb_cbw;
+} msc_bbb_cbw;
typedef struct {
uint32_t dCSWSignature;
uint32_t dCSWTag;
uint32_t dCSWDataResidue;
uint8_t bCSWStatus;
-}msc_bbb_csw;
+} msc_bbb_csw;
/* CSW command status */
enum msc_csw_status {
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/msc/msc_scsi.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/msc/msc_scsi.h
index 5e836d36da..d8cacdd49d 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/msc/msc_scsi.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/msc/msc_scsi.h
@@ -3,32 +3,34 @@
\brief definitions for the USB MSC SCSI commands
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/msc/usb_msc.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/msc/usb_msc.h
index 541bfb037b..e032a7621d 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/msc/usb_msc.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/class/msc/usb_msc.h
@@ -3,32 +3,34 @@
\brief definitions for the USB MSC class
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/common/usb_ch9_std.h b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/common/usb_ch9_std.h
index c52931c91e..bf0fe0aa39 100644
--- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/common/usb_ch9_std.h
+++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/GD32F4xx_usb_library/ustd/common/usb_ch9_std.h
@@ -3,32 +3,34 @@
\brief USB 2.0 standard defines
\version 2020-08-01, V3.0.0, firmware for GD32F4xx
+ \version 2022-03-09, V3.1.0, firmware for GD32F4xx
+ \version 2022-06-30, V3.2.0, firmware for GD32F4xx
*/
/*
- Copyright (c) 2020, GigaDevice Semiconductor Inc.
+ Copyright (c) 2022, GigaDevice Semiconductor Inc.
- Redistribution and use in source and binary forms, with or without modification,
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice, this
+ 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@@ -237,7 +239,7 @@ typedef struct _usb_desc_LANGID {
typedef struct _usb_desc_str {
usb_desc_header header; /*!< descriptor header, including type and size. */
- uint16_t unicode_string[64]; /*!< unicode string data */
+ uint16_t unicode_string[128]; /*!< unicode string data */
} usb_desc_str;
#pragma pack()
diff --git a/components/net/netdev/src/netdev.c b/components/net/netdev/src/netdev.c
index 44eecea6b8..b41351dd39 100644
--- a/components/net/netdev/src/netdev.c
+++ b/components/net/netdev/src/netdev.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2022, RT-Thread Development Team
+ * Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*