软件SPI可以驱动屏幕
This commit is contained in:
@@ -1,29 +1,33 @@
|
||||
[PreviousLibFiles]
|
||||
LibFiles=Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_spi.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_spi.h;Drivers\STM32F1xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_def.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_bus.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_system.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_utils.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio_ex.h;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_uart.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_usart.h;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_spi.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_uart.c;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_spi.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_spi.h;Drivers\STM32F1xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_def.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_bus.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_system.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_utils.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio_ex.h;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_uart.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_usart.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\stm32f103xb.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\stm32f1xx.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\system_stm32f1xx.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\system_stm32f1xx.h;Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;Drivers\CMSIS\Include\cmsis_armcc.h;Drivers\CMSIS\Include\cmsis_armclang.h;Drivers\CMSIS\Include\cmsis_compiler.h;Drivers\CMSIS\Include\cmsis_gcc.h;Drivers\CMSIS\Include\cmsis_iccarm.h;Drivers\CMSIS\Include\cmsis_version.h;Drivers\CMSIS\Include\core_armv8mbl.h;Drivers\CMSIS\Include\core_armv8mml.h;Drivers\CMSIS\Include\core_cm0.h;Drivers\CMSIS\Include\core_cm0plus.h;Drivers\CMSIS\Include\core_cm1.h;Drivers\CMSIS\Include\core_cm23.h;Drivers\CMSIS\Include\core_cm3.h;Drivers\CMSIS\Include\core_cm33.h;Drivers\CMSIS\Include\core_cm4.h;Drivers\CMSIS\Include\core_cm7.h;Drivers\CMSIS\Include\core_sc000.h;Drivers\CMSIS\Include\core_sc300.h;Drivers\CMSIS\Include\mpu_armv7.h;Drivers\CMSIS\Include\mpu_armv8.h;Drivers\CMSIS\Include\tz_context.h;
|
||||
|
||||
[PreviousUsedKeilFiles]
|
||||
SourceFiles=..\Core\Src\main.c;..\Core\Src\gpio.c;..\Core\Src\dma.c;..\Core\Src\spi.c;..\Core\Src\usart.c;..\Core\Src\stm32f1xx_it.c;..\Core\Src\stm32f1xx_hal_msp.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_spi.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_uart.c;..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;..\Core\Src\system_stm32f1xx.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_spi.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_uart.c;..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;..\Core\Src\system_stm32f1xx.c;;;
|
||||
HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Drivers\CMSIS\Include;..\Core\Inc;
|
||||
CDefines=USE_HAL_DRIVER;STM32F103xB;USE_HAL_DRIVER;USE_HAL_DRIVER;
|
||||
|
||||
[PreviousGenFiles]
|
||||
AdvancedFolderStructure=true
|
||||
HeaderFileListSize=5
|
||||
HeaderFileListSize=7
|
||||
HeaderFiles#0=..\Core\Inc\gpio.h
|
||||
HeaderFiles#1=..\Core\Inc\usart.h
|
||||
HeaderFiles#2=..\Core\Inc\stm32f1xx_it.h
|
||||
HeaderFiles#3=..\Core\Inc\stm32f1xx_hal_conf.h
|
||||
HeaderFiles#4=..\Core\Inc\main.h
|
||||
HeaderFiles#1=..\Core\Inc\dma.h
|
||||
HeaderFiles#2=..\Core\Inc\spi.h
|
||||
HeaderFiles#3=..\Core\Inc\usart.h
|
||||
HeaderFiles#4=..\Core\Inc\stm32f1xx_it.h
|
||||
HeaderFiles#5=..\Core\Inc\stm32f1xx_hal_conf.h
|
||||
HeaderFiles#6=..\Core\Inc\main.h
|
||||
HeaderFolderListSize=1
|
||||
HeaderPath#0=..\Core\Inc
|
||||
HeaderFiles=;
|
||||
SourceFileListSize=5
|
||||
SourceFileListSize=7
|
||||
SourceFiles#0=..\Core\Src\gpio.c
|
||||
SourceFiles#1=..\Core\Src\usart.c
|
||||
SourceFiles#2=..\Core\Src\stm32f1xx_it.c
|
||||
SourceFiles#3=..\Core\Src\stm32f1xx_hal_msp.c
|
||||
SourceFiles#4=..\Core\Src\main.c
|
||||
SourceFiles#1=..\Core\Src\dma.c
|
||||
SourceFiles#2=..\Core\Src\spi.c
|
||||
SourceFiles#3=..\Core\Src\usart.c
|
||||
SourceFiles#4=..\Core\Src\stm32f1xx_it.c
|
||||
SourceFiles#5=..\Core\Src\stm32f1xx_hal_msp.c
|
||||
SourceFiles#6=..\Core\Src\main.c
|
||||
SourceFolderListSize=1
|
||||
SourcePath#0=..\Core\Src
|
||||
SourceFiles=;
|
||||
|
||||
[PreviousLibFiles]
|
||||
LibFiles=Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_uart.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_usart.h;Drivers\STM32F1xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_def.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_bus.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_system.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_utils.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio_ex.h;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_exti.h;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_uart.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_uart.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_usart.h;Drivers\STM32F1xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_def.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_bus.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_system.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_utils.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio_ex.h;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_exti.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\stm32f103xb.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\stm32f1xx.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\system_stm32f1xx.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\system_stm32f1xx.h;Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;Drivers\CMSIS\Include\cmsis_armcc.h;Drivers\CMSIS\Include\cmsis_armclang.h;Drivers\CMSIS\Include\cmsis_compiler.h;Drivers\CMSIS\Include\cmsis_gcc.h;Drivers\CMSIS\Include\cmsis_iccarm.h;Drivers\CMSIS\Include\cmsis_version.h;Drivers\CMSIS\Include\core_armv8mbl.h;Drivers\CMSIS\Include\core_armv8mml.h;Drivers\CMSIS\Include\core_cm0.h;Drivers\CMSIS\Include\core_cm0plus.h;Drivers\CMSIS\Include\core_cm1.h;Drivers\CMSIS\Include\core_cm23.h;Drivers\CMSIS\Include\core_cm3.h;Drivers\CMSIS\Include\core_cm33.h;Drivers\CMSIS\Include\core_cm4.h;Drivers\CMSIS\Include\core_cm7.h;Drivers\CMSIS\Include\core_sc000.h;Drivers\CMSIS\Include\core_sc300.h;Drivers\CMSIS\Include\mpu_armv7.h;Drivers\CMSIS\Include\mpu_armv8.h;Drivers\CMSIS\Include\tz_context.h;
|
||||
|
||||
[PreviousUsedKeilFiles]
|
||||
SourceFiles=..\Core\Src\main.c;..\Core\Src\gpio.c;..\Core\Src\usart.c;..\Core\Src\stm32f1xx_it.c;..\Core\Src\stm32f1xx_hal_msp.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_uart.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;..\Core\Src\system_stm32f1xx.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_uart.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;..\Core\Src\system_stm32f1xx.c;;;
|
||||
HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Drivers\CMSIS\Include;..\Core\Inc;
|
||||
CDefines=USE_HAL_DRIVER;STM32F103xB;USE_HAL_DRIVER;USE_HAL_DRIVER;
|
||||
|
||||
|
||||
52
STM32F103C8T6/Core/Inc/dma.h
Normal file
52
STM32F103C8T6/Core/Inc/dma.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file dma.h
|
||||
* @brief This file contains all the function prototypes for
|
||||
* the dma.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2026 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __DMA_H__
|
||||
#define __DMA_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
|
||||
/* DMA memory to memory transfer handles -------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_DMA_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DMA_H__ */
|
||||
|
||||
@@ -63,12 +63,12 @@ void Error_Handler(void);
|
||||
#define KEY4_GPIO_Port GPIOC
|
||||
#define KEY5_Pin GPIO_PIN_15
|
||||
#define KEY5_GPIO_Port GPIOC
|
||||
#define LCD_DC_Pin GPIO_PIN_10
|
||||
#define LCD_DC_GPIO_Port GPIOB
|
||||
#define LCD_CS_Pin GPIO_PIN_11
|
||||
#define LCD_CS_GPIO_Port GPIOB
|
||||
#define LCD_RST_Pin GPIO_PIN_12
|
||||
#define LCD_RST_GPIO_Port GPIOB
|
||||
#define LCD_SCL_Pin GPIO_PIN_13
|
||||
#define LCD_SCL_GPIO_Port GPIOB
|
||||
#define LCD_SDA_Pin GPIO_PIN_15
|
||||
#define LCD_SDA_GPIO_Port GPIOB
|
||||
#define KEY3_Pin GPIO_PIN_3
|
||||
#define KEY3_GPIO_Port GPIOB
|
||||
#define KEY1_Pin GPIO_PIN_4
|
||||
|
||||
52
STM32F103C8T6/Core/Inc/spi.h
Normal file
52
STM32F103C8T6/Core/Inc/spi.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file spi.h
|
||||
* @brief This file contains all the function prototypes for
|
||||
* the spi.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2026 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __SPI_H__
|
||||
#define __SPI_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
extern SPI_HandleTypeDef hspi2;
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_SPI2_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SPI_H__ */
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
/*#define HAL_CORTEX_MODULE_ENABLED */
|
||||
/*#define HAL_CRC_MODULE_ENABLED */
|
||||
/*#define HAL_DAC_MODULE_ENABLED */
|
||||
/*#define HAL_DMA_MODULE_ENABLED */
|
||||
#define HAL_DMA_MODULE_ENABLED
|
||||
/*#define HAL_ETH_MODULE_ENABLED */
|
||||
/*#define HAL_FLASH_MODULE_ENABLED */
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
@@ -62,7 +62,7 @@
|
||||
/*#define HAL_MMC_MODULE_ENABLED */
|
||||
/*#define HAL_SDRAM_MODULE_ENABLED */
|
||||
/*#define HAL_SMARTCARD_MODULE_ENABLED */
|
||||
/*#define HAL_SPI_MODULE_ENABLED */
|
||||
#define HAL_SPI_MODULE_ENABLED
|
||||
/*#define HAL_SRAM_MODULE_ENABLED */
|
||||
/*#define HAL_TIM_MODULE_ENABLED */
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
|
||||
@@ -55,6 +55,7 @@ void SVC_Handler(void);
|
||||
void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
void DMA1_Channel5_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
55
STM32F103C8T6/Core/Src/dma.c
Normal file
55
STM32F103C8T6/Core/Src/dma.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file dma.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of all the requested memory to memory DMA transfers.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2026 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dma.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Configure DMA */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/**
|
||||
* Enable DMA controller clock
|
||||
*/
|
||||
void MX_DMA_Init(void)
|
||||
{
|
||||
|
||||
/* DMA controller clock enable */
|
||||
__HAL_RCC_DMA1_CLK_ENABLE();
|
||||
|
||||
/* DMA interrupt init */
|
||||
/* DMA1_Channel5_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
@@ -54,7 +54,7 @@ void MX_GPIO_Init(void)
|
||||
HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOB, LCD_RST_Pin|LCD_SCL_Pin|LCD_SDA_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOB, LCD_DC_Pin|LCD_CS_Pin|LCD_RST_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin : LED_Pin */
|
||||
GPIO_InitStruct.Pin = LED_Pin;
|
||||
@@ -69,8 +69,8 @@ void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : LCD_RST_Pin LCD_SCL_Pin LCD_SDA_Pin */
|
||||
GPIO_InitStruct.Pin = LCD_RST_Pin|LCD_SCL_Pin|LCD_SDA_Pin;
|
||||
/*Configure GPIO pins : LCD_DC_Pin LCD_CS_Pin LCD_RST_Pin */
|
||||
GPIO_InitStruct.Pin = LCD_DC_Pin|LCD_CS_Pin|LCD_RST_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
|
||||
@@ -18,12 +18,16 @@
|
||||
/* USER CODE END Header */
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "dma.h"
|
||||
#include "spi.h"
|
||||
#include "usart.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#include "lcd_data.h"
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include <stdio.h>
|
||||
#include "button_driver.h"
|
||||
#include "st7735s.h"
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
@@ -87,9 +91,21 @@ int main(void)
|
||||
|
||||
/* Initialize all configured peripherals */
|
||||
MX_GPIO_Init();
|
||||
MX_DMA_Init();
|
||||
MX_USART1_UART_Init();
|
||||
MX_SPI2_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
printf("\r\nSTM32F103C8T6 Boot OK\r\n");
|
||||
button_driver_init();
|
||||
st7735s_init();
|
||||
st7735s_fill_screen(COLOR_RED);
|
||||
HAL_Delay(500);
|
||||
st7735s_fill_screen(COLOR_GREEN);
|
||||
HAL_Delay(500);
|
||||
st7735s_fill_screen(COLOR_BLUE);
|
||||
HAL_Delay(500);
|
||||
st7735s_fill_screen(COLOR_BLACK);
|
||||
st7735s_draw_string(0, 0, "LCD OK", COLOR_WHITE, COLOR_BLACK);
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Infinite loop */
|
||||
@@ -101,7 +117,7 @@ int main(void)
|
||||
/* USER CODE BEGIN 3 */
|
||||
HAL_Delay(500);
|
||||
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
|
||||
printf("Hello word\n");
|
||||
//printf("Hello word\n");
|
||||
}
|
||||
/* USER CODE END 3 */
|
||||
}
|
||||
|
||||
136
STM32F103C8T6/Core/Src/spi.c
Normal file
136
STM32F103C8T6/Core/Src/spi.c
Normal file
@@ -0,0 +1,136 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file spi.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of the SPI instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2026 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "spi.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
SPI_HandleTypeDef hspi2;
|
||||
DMA_HandleTypeDef hdma_spi2_tx;
|
||||
|
||||
/* SPI2 init function */
|
||||
void MX_SPI2_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN SPI2_Init 0 */
|
||||
|
||||
/* USER CODE END SPI2_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN SPI2_Init 1 */
|
||||
|
||||
/* USER CODE END SPI2_Init 1 */
|
||||
hspi2.Instance = SPI2;
|
||||
hspi2.Init.Mode = SPI_MODE_MASTER;
|
||||
hspi2.Init.Direction = SPI_DIRECTION_2LINES;
|
||||
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
|
||||
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
|
||||
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||
hspi2.Init.NSS = SPI_NSS_SOFT;
|
||||
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
|
||||
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
||||
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||
hspi2.Init.CRCPolynomial = 10;
|
||||
if (HAL_SPI_Init(&hspi2) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN SPI2_Init 2 */
|
||||
|
||||
/* USER CODE END SPI2_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
|
||||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(spiHandle->Instance==SPI2)
|
||||
{
|
||||
/* USER CODE BEGIN SPI2_MspInit 0 */
|
||||
|
||||
/* USER CODE END SPI2_MspInit 0 */
|
||||
/* SPI2 clock enable */
|
||||
__HAL_RCC_SPI2_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
/**SPI2 GPIO Configuration
|
||||
PB13 ------> SPI2_SCK
|
||||
PB15 ------> SPI2_MOSI
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_15;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* SPI2 DMA Init */
|
||||
/* SPI2_TX Init */
|
||||
hdma_spi2_tx.Instance = DMA1_Channel5;
|
||||
hdma_spi2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
|
||||
hdma_spi2_tx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_spi2_tx.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_spi2_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_spi2_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_spi2_tx.Init.Mode = DMA_NORMAL;
|
||||
hdma_spi2_tx.Init.Priority = DMA_PRIORITY_LOW;
|
||||
if (HAL_DMA_Init(&hdma_spi2_tx) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
__HAL_LINKDMA(spiHandle,hdmatx,hdma_spi2_tx);
|
||||
|
||||
/* USER CODE BEGIN SPI2_MspInit 1 */
|
||||
|
||||
/* USER CODE END SPI2_MspInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle)
|
||||
{
|
||||
|
||||
if(spiHandle->Instance==SPI2)
|
||||
{
|
||||
/* USER CODE BEGIN SPI2_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END SPI2_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_SPI2_CLK_DISABLE();
|
||||
|
||||
/**SPI2 GPIO Configuration
|
||||
PB13 ------> SPI2_SCK
|
||||
PB15 ------> SPI2_MOSI
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_15);
|
||||
|
||||
/* SPI2 DMA DeInit */
|
||||
HAL_DMA_DeInit(spiHandle->hdmatx);
|
||||
/* USER CODE BEGIN SPI2_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END SPI2_MspDeInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "stm32f1xx_it.h"
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "multi_button.h"
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@@ -41,7 +43,7 @@
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
static uint8_t s_button_tick_counter = 0;
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
@@ -55,7 +57,7 @@
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
|
||||
extern DMA_HandleTypeDef hdma_spi2_tx;
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
@@ -188,6 +190,13 @@ void SysTick_Handler(void)
|
||||
HAL_IncTick();
|
||||
/* USER CODE BEGIN SysTick_IRQn 1 */
|
||||
|
||||
/* 每5ms调用一次button_ticks() */
|
||||
s_button_tick_counter++;
|
||||
if (s_button_tick_counter >= 5) {
|
||||
s_button_tick_counter = 0;
|
||||
button_ticks();
|
||||
}
|
||||
|
||||
/* USER CODE END SysTick_IRQn 1 */
|
||||
}
|
||||
|
||||
@@ -198,6 +207,20 @@ void SysTick_Handler(void)
|
||||
/* please refer to the startup file (startup_stm32f1xx.s). */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles DMA1 channel5 global interrupt.
|
||||
*/
|
||||
void DMA1_Channel5_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN DMA1_Channel5_IRQn 0 */
|
||||
|
||||
/* USER CODE END DMA1_Channel5_IRQn 0 */
|
||||
HAL_DMA_IRQHandler(&hdma_spi2_tx);
|
||||
/* USER CODE BEGIN DMA1_Channel5_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA1_Channel5_IRQn 1 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
297
STM32F103C8T6/Drivers/BSP/LCD/lcd_data.c
Normal file
297
STM32F103C8T6/Drivers/BSP/LCD/lcd_data.c
Normal file
@@ -0,0 +1,297 @@
|
||||
#include "lcd_data.h"
|
||||
/*ASCII字模数据*********************/
|
||||
|
||||
/*宽8像素,高16像素*/
|
||||
const uint8_t LCD_F8x16[][16] =
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
|
||||
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,// ! 1
|
||||
0x00,0x16,0x0E,0x00,0x16,0x0E,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// " 2
|
||||
0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,
|
||||
0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,// # 3
|
||||
0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,
|
||||
0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,// $ 4
|
||||
0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,
|
||||
0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,// % 5
|
||||
0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,
|
||||
0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,// & 6
|
||||
0x00,0x00,0x00,0x16,0x0E,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// ' 7
|
||||
0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,
|
||||
0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,// ( 8
|
||||
0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,
|
||||
0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,// ) 9
|
||||
0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,
|
||||
0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,// * 10
|
||||
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,
|
||||
0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,// + 11
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,// , 12
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,// - 13
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,// . 14
|
||||
0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,
|
||||
0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,// / 15
|
||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,// 0 16
|
||||
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,// 1 17
|
||||
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,
|
||||
0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,// 2 18
|
||||
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,
|
||||
0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,// 3 19
|
||||
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,
|
||||
0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,// 4 20
|
||||
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,
|
||||
0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,// 5 21
|
||||
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,
|
||||
0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,// 6 22
|
||||
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,
|
||||
0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,// 7 23
|
||||
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,
|
||||
0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,// 8 24
|
||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,// 9 25
|
||||
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,// : 26
|
||||
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,
|
||||
0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,// ; 27
|
||||
0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,
|
||||
0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,// < 28
|
||||
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,
|
||||
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,// = 29
|
||||
0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,
|
||||
0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,// > 30
|
||||
0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,
|
||||
0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,// ? 31
|
||||
0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,
|
||||
0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,// @ 32
|
||||
0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,
|
||||
0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,// A 33
|
||||
0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,// B 34
|
||||
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,
|
||||
0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,// C 35
|
||||
0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,// D 36
|
||||
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,// E 37
|
||||
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,
|
||||
0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,// F 38
|
||||
0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,
|
||||
0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,// G 39
|
||||
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,
|
||||
0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,// H 40
|
||||
0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,// I 41
|
||||
0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,
|
||||
0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,// J 42
|
||||
0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,
|
||||
0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,// K 43
|
||||
0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,// L 44
|
||||
0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,
|
||||
0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,// M 45
|
||||
0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,
|
||||
0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,// N 46
|
||||
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,// O 47
|
||||
0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,
|
||||
0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,// P 48
|
||||
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,// Q 49
|
||||
0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,
|
||||
0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,// R 50
|
||||
0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,
|
||||
0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,// S 51
|
||||
0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,
|
||||
0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,// T 52
|
||||
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,
|
||||
0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,// U 53
|
||||
0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,
|
||||
0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,// V 54
|
||||
0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,
|
||||
0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,// W 55
|
||||
0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,
|
||||
0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,// X 56
|
||||
0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,
|
||||
0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,// Y 57
|
||||
0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,
|
||||
0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,// Z 58
|
||||
0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,
|
||||
0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,// [ 59
|
||||
0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,// \ 60
|
||||
0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,
|
||||
0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,// ] 61
|
||||
0x00,0x20,0x10,0x08,0x04,0x08,0x10,0x20,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// ^ 62
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,// _ 63
|
||||
0x00,0x02,0x04,0x08,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// ` 64
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,// a 65
|
||||
0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,
|
||||
0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,// b 66
|
||||
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,// c 67
|
||||
0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,
|
||||
0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,// d 68
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,// e 69
|
||||
0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,// f 70
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,// g 71
|
||||
0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,
|
||||
0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,// h 72
|
||||
0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,// i 73
|
||||
0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,
|
||||
0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,// j 74
|
||||
0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,
|
||||
0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,// k 75
|
||||
0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,// l 76
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,// m 77
|
||||
0x00,0x80,0x80,0x00,0x80,0x80,0x00,0x00,
|
||||
0x00,0x20,0x3F,0x21,0x00,0x20,0x3F,0x20,// n 78
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,// o 79
|
||||
0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,
|
||||
0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,// p 80
|
||||
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,// q 81
|
||||
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,
|
||||
0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,// r 82
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,// s 83
|
||||
0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,
|
||||
0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,// t 84
|
||||
0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,
|
||||
0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,// u 85
|
||||
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,
|
||||
0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,// v 86
|
||||
0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,
|
||||
0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,// w 87
|
||||
0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,
|
||||
0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,// x 88
|
||||
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,
|
||||
0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,// y 89
|
||||
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,// z 90
|
||||
0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,
|
||||
0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,// { 91
|
||||
0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,// | 92
|
||||
0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,
|
||||
0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,// } 93
|
||||
0x00,0x80,0x40,0x40,0x80,0x00,0x00,0x80,
|
||||
0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,// ~ 94
|
||||
};
|
||||
|
||||
/*宽6像素,高8像素*/
|
||||
const uint8_t LCD_F6x8[][6] =
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,// 0
|
||||
0x00,0x00,0x00,0x2F,0x00,0x00,// ! 1
|
||||
0x00,0x00,0x07,0x00,0x07,0x00,// " 2
|
||||
0x00,0x14,0x7F,0x14,0x7F,0x14,// # 3
|
||||
0x00,0x24,0x2A,0x7F,0x2A,0x12,// $ 4
|
||||
0x00,0x23,0x13,0x08,0x64,0x62,// % 5
|
||||
0x00,0x36,0x49,0x55,0x22,0x50,// & 6
|
||||
0x00,0x00,0x00,0x07,0x00,0x00,// ' 7
|
||||
0x00,0x00,0x1C,0x22,0x41,0x00,// ( 8
|
||||
0x00,0x00,0x41,0x22,0x1C,0x00,// ) 9
|
||||
0x00,0x14,0x08,0x3E,0x08,0x14,// * 10
|
||||
0x00,0x08,0x08,0x3E,0x08,0x08,// + 11
|
||||
0x00,0x00,0x00,0xA0,0x60,0x00,// , 12
|
||||
0x00,0x08,0x08,0x08,0x08,0x08,// - 13
|
||||
0x00,0x00,0x60,0x60,0x00,0x00,// . 14
|
||||
0x00,0x20,0x10,0x08,0x04,0x02,// / 15
|
||||
0x00,0x3E,0x51,0x49,0x45,0x3E,// 0 16
|
||||
0x00,0x00,0x42,0x7F,0x40,0x00,// 1 17
|
||||
0x00,0x42,0x61,0x51,0x49,0x46,// 2 18
|
||||
0x00,0x21,0x41,0x45,0x4B,0x31,// 3 19
|
||||
0x00,0x18,0x14,0x12,0x7F,0x10,// 4 20
|
||||
0x00,0x27,0x45,0x45,0x45,0x39,// 5 21
|
||||
0x00,0x3C,0x4A,0x49,0x49,0x30,// 6 22
|
||||
0x00,0x01,0x71,0x09,0x05,0x03,// 7 23
|
||||
0x00,0x36,0x49,0x49,0x49,0x36,// 8 24
|
||||
0x00,0x06,0x49,0x49,0x29,0x1E,// 9 25
|
||||
0x00,0x00,0x36,0x36,0x00,0x00,// : 26
|
||||
0x00,0x00,0x56,0x36,0x00,0x00,// ; 27
|
||||
0x00,0x08,0x14,0x22,0x41,0x00,// < 28
|
||||
0x00,0x14,0x14,0x14,0x14,0x14,// = 29
|
||||
0x00,0x00,0x41,0x22,0x14,0x08,// > 30
|
||||
0x00,0x02,0x01,0x51,0x09,0x06,// ? 31
|
||||
0x00,0x3E,0x49,0x55,0x59,0x2E,// @ 32
|
||||
0x00,0x7C,0x12,0x11,0x12,0x7C,// A 33
|
||||
0x00,0x7F,0x49,0x49,0x49,0x36,// B 34
|
||||
0x00,0x3E,0x41,0x41,0x41,0x22,// C 35
|
||||
0x00,0x7F,0x41,0x41,0x22,0x1C,// D 36
|
||||
0x00,0x7F,0x49,0x49,0x49,0x41,// E 37
|
||||
0x00,0x7F,0x09,0x09,0x09,0x01,// F 38
|
||||
0x00,0x3E,0x41,0x49,0x49,0x7A,// G 39
|
||||
0x00,0x7F,0x08,0x08,0x08,0x7F,// H 40
|
||||
0x00,0x00,0x41,0x7F,0x41,0x00,// I 41
|
||||
0x00,0x20,0x40,0x41,0x3F,0x01,// J 42
|
||||
0x00,0x7F,0x08,0x14,0x22,0x41,// K 43
|
||||
0x00,0x7F,0x40,0x40,0x40,0x40,// L 44
|
||||
0x00,0x7F,0x02,0x0C,0x02,0x7F,// M 45
|
||||
0x00,0x7F,0x04,0x08,0x10,0x7F,// N 46
|
||||
0x00,0x3E,0x41,0x41,0x41,0x3E,// O 47
|
||||
0x00,0x7F,0x09,0x09,0x09,0x06,// P 48
|
||||
0x00,0x3E,0x41,0x51,0x21,0x5E,// Q 49
|
||||
0x00,0x7F,0x09,0x19,0x29,0x46,// R 50
|
||||
0x00,0x46,0x49,0x49,0x49,0x31,// S 51
|
||||
0x00,0x01,0x01,0x7F,0x01,0x01,// T 52
|
||||
0x00,0x3F,0x40,0x40,0x40,0x3F,// U 53
|
||||
0x00,0x1F,0x20,0x40,0x20,0x1F,// V 54
|
||||
0x00,0x3F,0x40,0x38,0x40,0x3F,// W 55
|
||||
0x00,0x63,0x14,0x08,0x14,0x63,// X 56
|
||||
0x00,0x07,0x08,0x70,0x08,0x07,// Y 57
|
||||
0x00,0x61,0x51,0x49,0x45,0x43,// Z 58
|
||||
0x00,0x00,0x7F,0x41,0x41,0x00,// [ 59
|
||||
0x00,0x02,0x04,0x08,0x10,0x20,// \ 60
|
||||
0x00,0x00,0x41,0x41,0x7F,0x00,// ] 61
|
||||
0x00,0x04,0x02,0x01,0x02,0x04,// ^ 62
|
||||
0x00,0x40,0x40,0x40,0x40,0x40,// _ 63
|
||||
0x00,0x00,0x01,0x02,0x04,0x00,// ` 64
|
||||
0x00,0x20,0x54,0x54,0x54,0x78,// a 65
|
||||
0x00,0x7F,0x48,0x44,0x44,0x38,// b 66
|
||||
0x00,0x38,0x44,0x44,0x44,0x20,// c 67
|
||||
0x00,0x38,0x44,0x44,0x48,0x7F,// d 68
|
||||
0x00,0x38,0x54,0x54,0x54,0x18,// e 69
|
||||
0x00,0x08,0x7E,0x09,0x01,0x02,// f 70
|
||||
0x00,0x18,0xA4,0xA4,0xA4,0x7C,// g 71
|
||||
0x00,0x7F,0x08,0x04,0x04,0x78,// h 72
|
||||
0x00,0x00,0x44,0x7D,0x40,0x00,// i 73
|
||||
0x00,0x40,0x80,0x84,0x7D,0x00,// j 74
|
||||
0x00,0x7F,0x10,0x28,0x44,0x00,// k 75
|
||||
0x00,0x00,0x41,0x7F,0x40,0x00,// l 76
|
||||
0x00,0x7C,0x04,0x18,0x04,0x78,// m 77
|
||||
0x00,0x7C,0x08,0x04,0x04,0x78,// n 78
|
||||
0x00,0x38,0x44,0x44,0x44,0x38,// o 79
|
||||
0x00,0xFC,0x24,0x24,0x24,0x18,// p 80
|
||||
0x00,0x18,0x24,0x24,0x18,0xFC,// q 81
|
||||
0x00,0x7C,0x08,0x04,0x04,0x08,// r 82
|
||||
0x00,0x48,0x54,0x54,0x54,0x20,// s 83
|
||||
0x00,0x04,0x3F,0x44,0x40,0x20,// t 84
|
||||
0x00,0x3C,0x40,0x40,0x20,0x7C,// u 85
|
||||
0x00,0x1C,0x20,0x40,0x20,0x1C,// v 86
|
||||
0x00,0x3C,0x40,0x30,0x40,0x3C,// w 87
|
||||
0x00,0x44,0x28,0x10,0x28,0x44,// x 88
|
||||
0x00,0x1C,0xA0,0xA0,0xA0,0x7C,// y 89
|
||||
0x00,0x44,0x64,0x54,0x4C,0x44,// z 90
|
||||
0x00,0x00,0x08,0x7F,0x41,0x00,// { 91
|
||||
0x00,0x00,0x00,0x7F,0x00,0x00,// | 92
|
||||
0x00,0x00,0x41,0x7F,0x08,0x00,// } 93
|
||||
0x00,0x08,0x04,0x08,0x10,0x08,// ~ 94
|
||||
};
|
||||
10
STM32F103C8T6/Drivers/BSP/LCD/lcd_data.h
Normal file
10
STM32F103C8T6/Drivers/BSP/LCD/lcd_data.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef __LCD_DATA_H_
|
||||
#define __LCD_DATA_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*ASCII字模数据声明*/
|
||||
extern const uint8_t LCD_F8x16[][16];
|
||||
extern const uint8_t LCD_F6x8[][6];
|
||||
|
||||
#endif
|
||||
621
STM32F103C8T6/Drivers/BSP/LCD/st7735s.c
Normal file
621
STM32F103C8T6/Drivers/BSP/LCD/st7735s.c
Normal file
@@ -0,0 +1,621 @@
|
||||
/*
|
||||
* 模块名称:ST7735S LCD驱动
|
||||
* 模块功能:提供128x160 RGB TFT屏幕的初始化、画点、画线、填充、显示字符串等功能
|
||||
* 适用平台:STM32F103C8T6 + SPI2
|
||||
* 作者:王建锋
|
||||
* 创建日期:2026-07-13
|
||||
* 修改记录:
|
||||
* 2026-07-13 王建锋 创建初始版本
|
||||
*/
|
||||
|
||||
#include "st7735s.h"
|
||||
#include "lcd_data.h"
|
||||
#include "spi.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static uint16_t s_lcd_width = LCD_WIDTH;
|
||||
static uint16_t s_lcd_height = LCD_HEIGHT;
|
||||
|
||||
extern DMA_HandleTypeDef hdma_spi2_tx;
|
||||
|
||||
/* 8x16 ASCII字体(ASCII 32-126),每字符16字节 - 定义在 lcd_data.c 中 */
|
||||
|
||||
/*
|
||||
* 函数功能:软件SPI写一个字节
|
||||
* 入口参数:data - 要发送的数据
|
||||
* 返回值:无
|
||||
* 函数说明:模拟SPI时序发送一个字节,MSB先
|
||||
*/
|
||||
static void st7735s_spi_write_byte(uint8_t data)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
HAL_GPIO_WritePin(LCD_SCL_PORT, LCD_SCL_PIN, GPIO_PIN_RESET);
|
||||
if (data & 0x80) {
|
||||
HAL_GPIO_WritePin(LCD_SDA_PORT, LCD_SDA_PIN, GPIO_PIN_SET);
|
||||
} else {
|
||||
HAL_GPIO_WritePin(LCD_SDA_PORT, LCD_SDA_PIN, GPIO_PIN_RESET);
|
||||
}
|
||||
__NOP();
|
||||
__NOP();
|
||||
HAL_GPIO_WritePin(LCD_SCL_PORT, LCD_SCL_PIN, GPIO_PIN_SET);
|
||||
__NOP();
|
||||
__NOP();
|
||||
data <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:写入命令
|
||||
* 入口参数:cmd - 命令字节
|
||||
* 返回值:无
|
||||
* 函数说明:拉低DC,选择芯片,发送命令,释放芯片
|
||||
*/
|
||||
static void st7735s_write_cmd(uint8_t cmd)
|
||||
{
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_RESET);
|
||||
st7735s_spi_write_byte(cmd);
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:写入数据
|
||||
* 入口参数:data - 数据字节
|
||||
* 返回值:无
|
||||
* 函数说明:拉高DC,选择芯片,发送数据,释放芯片
|
||||
*/
|
||||
static void st7735s_write_data(uint8_t data)
|
||||
{
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_SET);
|
||||
st7735s_spi_write_byte(data);
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:写入多字节数据(CS保持低)
|
||||
* 入口参数:p_data - 数据缓冲区指针
|
||||
* len - 字节数
|
||||
* 返回值:无
|
||||
* 函数说明:用于连续写入多个数据字节,省去中间CS跳变
|
||||
*/
|
||||
static void st7735s_write_data_multi(const uint8_t *p_data, uint16_t len)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_SET);
|
||||
for (i = 0; i < len; i++) {
|
||||
st7735s_spi_write_byte(p_data[i]);
|
||||
}
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:写入16位颜色数据
|
||||
* 入口参数:p_color - 16位颜色缓冲区指针
|
||||
* len - 像素个数
|
||||
* 返回值:无
|
||||
* 函数说明:MSB先发送RGB565数据
|
||||
*/
|
||||
static void st7735s_write_colors(uint16_t *p_color, uint16_t len)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_SET);
|
||||
for (i = 0; i < len; i++) {
|
||||
st7735s_spi_write_byte((uint8_t)(p_color[i] >> 8));
|
||||
st7735s_spi_write_byte((uint8_t)(p_color[i] & 0xFF));
|
||||
}
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:LCD初始化
|
||||
* 入口参数:无
|
||||
* 返回值:无
|
||||
* 函数说明:执行ST7735S标准初始化序列
|
||||
*/
|
||||
void st7735s_init(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
printf("LCD init start (soft SPI)...\r\n");
|
||||
|
||||
/* 将SCL和SDA引脚切换为GPIO输出(软件SPI) */
|
||||
GPIO_InitStruct.Pin = LCD_SCL_PIN | LCD_SDA_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
HAL_GPIO_WritePin(LCD_SCL_PORT, LCD_SCL_PIN, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(LCD_SDA_PORT, LCD_SDA_PIN, GPIO_PIN_SET);
|
||||
|
||||
/* 确保CS和RST初始为高,避免LCD在初始化期间被错误选中 */
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(LCD_RST_PORT, LCD_RST_PIN, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_RESET);
|
||||
HAL_Delay(10);
|
||||
|
||||
printf("IO: RST=%d DC=%d CS=%d\r\n",
|
||||
(int)HAL_GPIO_ReadPin(LCD_RST_PORT, LCD_RST_PIN),
|
||||
(int)HAL_GPIO_ReadPin(LCD_DC_PORT, LCD_DC_PIN),
|
||||
(int)HAL_GPIO_ReadPin(LCD_CS_PORT, LCD_CS_PIN));
|
||||
|
||||
/* 硬件复位 */
|
||||
printf("HW reset...\r\n");
|
||||
HAL_GPIO_WritePin(LCD_RST_PORT, LCD_RST_PIN, GPIO_PIN_RESET);
|
||||
HAL_Delay(10);
|
||||
HAL_GPIO_WritePin(LCD_RST_PORT, LCD_RST_PIN, GPIO_PIN_SET);
|
||||
HAL_Delay(120);
|
||||
|
||||
/* 软件复位 */
|
||||
printf("SW reset...\r\n");
|
||||
st7735s_write_cmd(LCD_CMD_SWRESET);
|
||||
HAL_Delay(150);
|
||||
|
||||
/* 退出睡眠模式 */
|
||||
printf("Sleep out...\r\n");
|
||||
st7735s_write_cmd(LCD_CMD_SLPOUT);
|
||||
HAL_Delay(500);
|
||||
|
||||
/* 帧率控制 */
|
||||
printf("Frame rate...\r\n");
|
||||
st7735s_write_cmd(LCD_CMD_FRMCTR1);
|
||||
st7735s_write_data(0x01);
|
||||
st7735s_write_data(0x2C);
|
||||
st7735s_write_data(0x2D);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_FRMCTR2);
|
||||
st7735s_write_data(0x01);
|
||||
st7735s_write_data(0x2C);
|
||||
st7735s_write_data(0x2D);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_FRMCTR3);
|
||||
st7735s_write_data(0x01);
|
||||
st7735s_write_data(0x2C);
|
||||
st7735s_write_data(0x2D);
|
||||
st7735s_write_data(0x01);
|
||||
st7735s_write_data(0x2C);
|
||||
st7735s_write_data(0x2D);
|
||||
|
||||
/* 显示反转控制 */
|
||||
st7735s_write_cmd(LCD_CMD_INVCTR);
|
||||
st7735s_write_data(0x07);
|
||||
|
||||
/* 功率控制 */
|
||||
printf("Power ctrl...\r\n");
|
||||
st7735s_write_cmd(LCD_CMD_PWCTR1);
|
||||
st7735s_write_data(0xA2);
|
||||
st7735s_write_data(0x02);
|
||||
st7735s_write_data(0x84);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_PWCTR2);
|
||||
st7735s_write_data(0xC5);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_PWCTR3);
|
||||
st7735s_write_data(0x0A);
|
||||
st7735s_write_data(0x00);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_PWCTR4);
|
||||
st7735s_write_data(0x8A);
|
||||
st7735s_write_data(0x2A);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_PWCTR5);
|
||||
st7735s_write_data(0x8A);
|
||||
st7735s_write_data(0xEE);
|
||||
|
||||
/* VCOM控制 */
|
||||
st7735s_write_cmd(LCD_CMD_VMCTR1);
|
||||
st7735s_write_data(0x0E);
|
||||
|
||||
/* 竖屏模式 */
|
||||
printf("MADCTL...\r\n");
|
||||
st7735s_write_cmd(LCD_CMD_MADCTL);
|
||||
st7735s_write_data(0xC8);
|
||||
|
||||
/* 像素格式: 16位RGB565 */
|
||||
printf("COLMOD...\r\n");
|
||||
st7735s_write_cmd(LCD_CMD_COLMOD);
|
||||
st7735s_write_data(0x05);
|
||||
|
||||
/* Gamma校正 */
|
||||
printf("Gamma...\r\n");
|
||||
st7735s_write_cmd(LCD_CMD_GMCTRP1);
|
||||
st7735s_write_data(0x02);
|
||||
st7735s_write_data(0x1C);
|
||||
st7735s_write_data(0x07);
|
||||
st7735s_write_data(0x12);
|
||||
st7735s_write_data(0x37);
|
||||
st7735s_write_data(0x32);
|
||||
st7735s_write_data(0x29);
|
||||
st7735s_write_data(0x2D);
|
||||
st7735s_write_data(0x29);
|
||||
st7735s_write_data(0x25);
|
||||
st7735s_write_data(0x2B);
|
||||
st7735s_write_data(0x39);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data(0x01);
|
||||
st7735s_write_data(0x03);
|
||||
st7735s_write_data(0x10);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_GMCTRN1);
|
||||
st7735s_write_data(0x03);
|
||||
st7735s_write_data(0x1D);
|
||||
st7735s_write_data(0x07);
|
||||
st7735s_write_data(0x06);
|
||||
st7735s_write_data(0x2E);
|
||||
st7735s_write_data(0x2C);
|
||||
st7735s_write_data(0x29);
|
||||
st7735s_write_data(0x2D);
|
||||
st7735s_write_data(0x2E);
|
||||
st7735s_write_data(0x2E);
|
||||
st7735s_write_data(0x37);
|
||||
st7735s_write_data(0x3F);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data(0x02);
|
||||
st7735s_write_data(0x10);
|
||||
|
||||
/* 关闭反转 */
|
||||
st7735s_write_cmd(0x20);
|
||||
|
||||
/* 进入正常显示模式(关键!) */
|
||||
printf("NORON...\r\n");
|
||||
st7735s_write_cmd(0x13);
|
||||
HAL_Delay(10);
|
||||
|
||||
/* 开启显示 */
|
||||
printf("DISPON...\r\n");
|
||||
st7735s_write_cmd(LCD_CMD_DISPON);
|
||||
HAL_Delay(100);
|
||||
printf("LCD init done\r\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:设置显示窗口
|
||||
* 入口参数:x1 - 起始列
|
||||
* y1 - 起始行
|
||||
* x2 - 结束列
|
||||
* y2 - 结束行
|
||||
* 返回值:无
|
||||
* 函数说明:设置后续写入操作的窗口区域
|
||||
*/
|
||||
void st7735s_set_window(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
|
||||
{
|
||||
st7735s_write_cmd(LCD_CMD_CASET);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data((uint8_t)x1);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data((uint8_t)x2);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_RASET);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data((uint8_t)y1);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data((uint8_t)y2);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_RAMWR);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:填充矩形区域
|
||||
* 入口参数:x1 - 起始列
|
||||
* y1 - 起始行
|
||||
* x2 - 结束列
|
||||
* y2 - 结束行
|
||||
* color - 填充颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:用指定颜色填充矩形区域
|
||||
*/
|
||||
void st7735s_fill_rect(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
|
||||
{
|
||||
uint32_t pixel_count;
|
||||
uint16_t i;
|
||||
uint16_t buf[64];
|
||||
|
||||
if (x1 > x2) {
|
||||
uint16_t t = x1;
|
||||
x1 = x2;
|
||||
x2 = t;
|
||||
}
|
||||
if (y1 > y2) {
|
||||
uint16_t t = y1;
|
||||
y1 = y2;
|
||||
y2 = t;
|
||||
}
|
||||
|
||||
pixel_count = (uint32_t)(x2 - x1 + 1) * (y2 - y1 + 1);
|
||||
|
||||
/* 预填充颜色缓冲区 */
|
||||
for (i = 0; i < 64; i++) {
|
||||
buf[i] = color;
|
||||
}
|
||||
|
||||
st7735s_set_window(x1, y1, x2, y2);
|
||||
|
||||
/* 分块发送 */
|
||||
while (pixel_count >= 64) {
|
||||
st7735s_write_colors(buf, 64);
|
||||
pixel_count -= 64;
|
||||
}
|
||||
if (pixel_count > 0) {
|
||||
st7735s_write_colors(buf, (uint16_t)pixel_count);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:全屏填充
|
||||
* 入口参数:color - 填充颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:用指定颜色填充整个屏幕
|
||||
*/
|
||||
void st7735s_fill_screen(uint16_t color)
|
||||
{
|
||||
printf("fill_screen 0x%04X\r\n", color);
|
||||
st7735s_fill_rect(0, 0, s_lcd_width - 1, s_lcd_height - 1, color);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:画点
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:在指定位置画一个点
|
||||
*/
|
||||
void st7735s_draw_pixel(uint16_t x, uint16_t y, uint16_t color)
|
||||
{
|
||||
if (x >= s_lcd_width || y >= s_lcd_height) {
|
||||
return;
|
||||
}
|
||||
st7735s_set_window(x, y, x, y);
|
||||
st7735s_write_data((uint8_t)(color >> 8));
|
||||
st7735s_write_data((uint8_t)color);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:画线
|
||||
* 入口参数:x1 - 起始列
|
||||
* y1 - 起始行
|
||||
* x2 - 结束列
|
||||
* y2 - 结束行
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:画一条直线(Bresenham算法)
|
||||
*/
|
||||
void st7735s_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
|
||||
{
|
||||
int16_t dx;
|
||||
int16_t dy;
|
||||
int16_t sx;
|
||||
int16_t sy;
|
||||
int16_t err;
|
||||
int16_t e2;
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
|
||||
if (x1 == x2) {
|
||||
/* 垂直线 */
|
||||
if (y1 > y2) {
|
||||
y = y1;
|
||||
y1 = y2;
|
||||
y2 = y;
|
||||
}
|
||||
st7735s_fill_rect(x1, y1, x1, y2, color);
|
||||
return;
|
||||
}
|
||||
|
||||
if (y1 == y2) {
|
||||
/* 水平线 */
|
||||
if (x1 > x2) {
|
||||
x = x1;
|
||||
x1 = x2;
|
||||
x2 = x;
|
||||
}
|
||||
st7735s_fill_rect(x1, y1, x2, y1, color);
|
||||
return;
|
||||
}
|
||||
|
||||
dx = (int16_t)x2 - (int16_t)x1;
|
||||
if (dx < 0) {
|
||||
dx = -dx;
|
||||
}
|
||||
sx = x1 < x2 ? 1 : -1;
|
||||
dy = (int16_t)y2 - (int16_t)y1;
|
||||
if (dy < 0) {
|
||||
dy = -dy;
|
||||
}
|
||||
sy = y1 < y2 ? 1 : -1;
|
||||
err = (dx > dy ? dx : -dy) / 2;
|
||||
|
||||
x = x1;
|
||||
y = y1;
|
||||
|
||||
while (1) {
|
||||
st7735s_draw_pixel(x, y, color);
|
||||
if (x == x2 && y == y2) {
|
||||
break;
|
||||
}
|
||||
e2 = err;
|
||||
if (e2 > -dx) {
|
||||
err -= dy;
|
||||
x += sx;
|
||||
}
|
||||
if (e2 < dy) {
|
||||
err += dx;
|
||||
y += sy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:画矩形
|
||||
* 入口参数:x - 左上角列
|
||||
* y - 左上角行
|
||||
* width - 宽度
|
||||
* height - 高度
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:画一个空心矩形
|
||||
*/
|
||||
void st7735s_draw_rect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color)
|
||||
{
|
||||
st7735s_draw_line(x, y, x + width - 1, y, color);
|
||||
st7735s_draw_line(x, y + height - 1, x + width - 1, y + height - 1, color);
|
||||
st7735s_draw_line(x, y, x, y + height - 1, color);
|
||||
st7735s_draw_line(x + width - 1, y, x + width - 1, y + height - 1, color);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:画圆
|
||||
* 入口参数:x0 - 圆心列
|
||||
* y0 - 圆心行
|
||||
* radius - 半径
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:画一个空心圆(Bresenham算法)
|
||||
*/
|
||||
void st7735s_draw_circle(uint16_t x0, uint16_t y0, uint16_t radius, uint16_t color)
|
||||
{
|
||||
int16_t f = 1 - radius;
|
||||
int16_t ddf_x = 1;
|
||||
int16_t ddf_y = -2 * radius;
|
||||
int16_t x = 0;
|
||||
int16_t y = radius;
|
||||
|
||||
st7735s_draw_pixel(x0, y0 + radius, color);
|
||||
st7735s_draw_pixel(x0, y0 - radius, color);
|
||||
st7735s_draw_pixel(x0 + radius, y0, color);
|
||||
st7735s_draw_pixel(x0 - radius, y0, color);
|
||||
|
||||
while (x < y) {
|
||||
if (f >= 0) {
|
||||
y--;
|
||||
ddf_y += 2;
|
||||
f += ddf_y;
|
||||
}
|
||||
x++;
|
||||
ddf_x += 2;
|
||||
f += ddf_x;
|
||||
|
||||
st7735s_draw_pixel(x0 + x, y0 + y, color);
|
||||
st7735s_draw_pixel(x0 - x, y0 + y, color);
|
||||
st7735s_draw_pixel(x0 + x, y0 - y, color);
|
||||
st7735s_draw_pixel(x0 - x, y0 - y, color);
|
||||
st7735s_draw_pixel(x0 + y, y0 + x, color);
|
||||
st7735s_draw_pixel(x0 - y, y0 + x, color);
|
||||
st7735s_draw_pixel(x0 + y, y0 - x, color);
|
||||
st7735s_draw_pixel(x0 - y, y0 - x, color);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:显示字符
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* ch - 字符 (ASCII 32-126)
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:在指定位置显示一个8x16 ASCII字符
|
||||
*/
|
||||
void st7735s_draw_char(uint16_t x, uint16_t y, char ch, uint16_t color, uint16_t bg_color)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t j;
|
||||
uint8_t line;
|
||||
|
||||
if (ch < 32 || ch > 126) {
|
||||
ch = ' ';
|
||||
}
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
line = LCD_F8x16[ch - 32][i];
|
||||
for (j = 0; j < 8; j++) {
|
||||
if (line & 0x80) {
|
||||
st7735s_draw_pixel(x + j, y + i, color);
|
||||
} else {
|
||||
st7735s_draw_pixel(x + j, y + i, bg_color);
|
||||
}
|
||||
line <<= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:显示字符串
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* str - 字符串指针
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:在指定位置显示字符串
|
||||
*/
|
||||
void st7735s_draw_string(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bg_color)
|
||||
{
|
||||
while (*str) {
|
||||
if (x + 8 > s_lcd_width) {
|
||||
x = 0;
|
||||
y += 16;
|
||||
}
|
||||
if (y + 16 > s_lcd_height) {
|
||||
break;
|
||||
}
|
||||
st7735s_draw_char(x, y, *str, color, bg_color);
|
||||
x += FONT_WIDTH_8;
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:设置屏幕方向
|
||||
* 入口参数:rotation - 方向 (0-3)
|
||||
* 返回值:无
|
||||
* 函数说明:0:竖屏 1:横屏 2:竖屏反转 3:横屏反转
|
||||
*/
|
||||
void st7735s_set_rotation(uint8_t rotation)
|
||||
{
|
||||
st7735s_write_cmd(LCD_CMD_MADCTL);
|
||||
switch (rotation) {
|
||||
case 0:
|
||||
st7735s_write_data(0xC8);
|
||||
s_lcd_width = 128;
|
||||
s_lcd_height = 160;
|
||||
break;
|
||||
case 1:
|
||||
st7735s_write_data(0x78);
|
||||
s_lcd_width = 160;
|
||||
s_lcd_height = 128;
|
||||
break;
|
||||
case 2:
|
||||
st7735s_write_data(0x08);
|
||||
s_lcd_width = 128;
|
||||
s_lcd_height = 160;
|
||||
break;
|
||||
case 3:
|
||||
st7735s_write_data(0xA8);
|
||||
s_lcd_width = 160;
|
||||
s_lcd_height = 128;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:设置背光
|
||||
* 入口参数:state - 1:开 0:关
|
||||
* 返回值:无
|
||||
* 函数说明:控制LCD背光(如有硬件背光控制)
|
||||
*/
|
||||
void st7735s_backlight(uint8_t state)
|
||||
{
|
||||
(void)state;
|
||||
/* 当前硬件未连接背光控制引脚,预留接口 */
|
||||
}
|
||||
213
STM32F103C8T6/Drivers/BSP/LCD/st7735s.h
Normal file
213
STM32F103C8T6/Drivers/BSP/LCD/st7735s.h
Normal file
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* 模块名称:ST7735S LCD驱动
|
||||
* 模块功能:提供128x160 RGB TFT屏幕的初始化、画点、画线、填充、显示字符串等功能
|
||||
* 适用平台:STM32F103C8T6 + SPI2
|
||||
* 作者:王建锋
|
||||
* 创建日期:2026-07-13
|
||||
* 修改记录:
|
||||
* 2026-07-13 王建锋 创建初始版本
|
||||
*/
|
||||
|
||||
#ifndef __ST7735S_H
|
||||
#define __ST7735S_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "main.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/* 屏幕参数 */
|
||||
#define LCD_WIDTH 128 /* 屏幕宽度 */
|
||||
#define LCD_HEIGHT 160 /* 屏幕高度 */
|
||||
|
||||
/* 颜色定义 (RGB565) */
|
||||
#define COLOR_BLACK 0x0000
|
||||
#define COLOR_WHITE 0xFFFF
|
||||
#define COLOR_RED 0xF800
|
||||
#define COLOR_GREEN 0x07E0
|
||||
#define COLOR_BLUE 0x001F
|
||||
#define COLOR_YELLOW 0xFFE0
|
||||
#define COLOR_CYAN 0x07FF
|
||||
#define COLOR_MAGENTA 0xF81F
|
||||
#define COLOR_ORANGE 0xFD20
|
||||
#define COLOR_DARK_BLUE 0x0010
|
||||
#define COLOR_DARK_GREEN 0x0200
|
||||
#define COLOR_DARK_RED 0x8000
|
||||
|
||||
/* 颜色转换宏 */
|
||||
#define RGB565(r, g, b) ((uint16_t)(((r) & 0xF8) << 8 | ((g) & 0xFC) << 3 | ((b) >> 3)))
|
||||
|
||||
/* LCD控制引脚定义 - 根据CubeMX配置修改 */
|
||||
#define LCD_CS_PORT LCD_CS_GPIO_Port
|
||||
#define LCD_CS_PIN LCD_CS_Pin
|
||||
#define LCD_DC_PORT LCD_DC_GPIO_Port
|
||||
#define LCD_DC_PIN LCD_DC_Pin
|
||||
#define LCD_RST_PORT LCD_RST_GPIO_Port
|
||||
#define LCD_RST_PIN LCD_RST_Pin
|
||||
#define LCD_SCL_PORT GPIOB
|
||||
#define LCD_SCL_PIN GPIO_PIN_13
|
||||
#define LCD_SDA_PORT GPIOB
|
||||
#define LCD_SDA_PIN GPIO_PIN_15
|
||||
|
||||
/* LCD命令定义 */
|
||||
#define LCD_CMD_SWRESET 0x01 /* 软件复位 */
|
||||
#define LCD_CMD_SLPOUT 0x11 /* 退出睡眠 */
|
||||
#define LCD_CMD_DISPON 0x29 /* 显示开启 */
|
||||
#define LCD_CMD_DISPOFF 0x28 /* 显示关闭 */
|
||||
#define LCD_CMD_CASET 0x2A /* 列地址设置 */
|
||||
#define LCD_CMD_RASET 0x2B /* 行地址设置 */
|
||||
#define LCD_CMD_RAMWR 0x2C /* 写入显存 */
|
||||
#define LCD_CMD_MADCTL 0x36 /* 存储器访问控制 */
|
||||
#define LCD_CMD_COLMOD 0x3A /* 像素格式设置 */
|
||||
#define LCD_CMD_FRMCTR1 0xB1 /* 帧率控制1 */
|
||||
#define LCD_CMD_FRMCTR2 0xB2 /* 帧率控制2 */
|
||||
#define LCD_CMD_FRMCTR3 0xB3 /* 帧率控制3 */
|
||||
#define LCD_CMD_INVCTR 0xB4 /* 显示反转控制 */
|
||||
#define LCD_CMD_PWCTR1 0xC0 /* 功率控制1 */
|
||||
#define LCD_CMD_PWCTR2 0xC1 /* 功率控制2 */
|
||||
#define LCD_CMD_PWCTR3 0xC2 /* 功率控制3 */
|
||||
#define LCD_CMD_PWCTR4 0xC3 /* 功率控制4 */
|
||||
#define LCD_CMD_PWCTR5 0xC4 /* 功率控制5 */
|
||||
#define LCD_CMD_VMCTR1 0xC5 /* VCOM控制1 */
|
||||
#define LCD_CMD_GMCTRP1 0xE0 /* Gamma正向校正 */
|
||||
#define LCD_CMD_GMCTRN1 0xE1 /* Gamma反向校正 */
|
||||
|
||||
/* 字体定义 */
|
||||
#define FONT_WIDTH_8 8 /* 8x16字体宽度(含间距) */
|
||||
#define FONT_HEIGHT_16 16 /* 8x16字体高度 */
|
||||
|
||||
/*
|
||||
* 函数功能:LCD初始化
|
||||
* 入口参数:无
|
||||
* 返回值:无
|
||||
* 函数说明:初始化ST7735S屏幕,包括SPI、GPIO、显示参数配置
|
||||
*/
|
||||
void st7735s_init(void);
|
||||
|
||||
/*
|
||||
* 函数功能:设置显示窗口
|
||||
* 入口参数:x1 - 起始列
|
||||
* y1 - 起始行
|
||||
* x2 - 结束列
|
||||
* y2 - 结束行
|
||||
* 返回值:无
|
||||
* 函数说明:设置后续写入操作的窗口区域
|
||||
*/
|
||||
void st7735s_set_window(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
||||
|
||||
/*
|
||||
* 函数功能:填充矩形区域
|
||||
* 入口参数:x1 - 起始列
|
||||
* y1 - 起始行
|
||||
* x2 - 结束列
|
||||
* y2 - 结束行
|
||||
* color - 填充颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:用指定颜色填充矩形区域
|
||||
*/
|
||||
void st7735s_fill_rect(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
|
||||
|
||||
/*
|
||||
* 函数功能:全屏填充
|
||||
* 入口参数:color - 填充颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:用指定颜色填充整个屏幕
|
||||
*/
|
||||
void st7735s_fill_screen(uint16_t color);
|
||||
|
||||
/*
|
||||
* 函数功能:画点
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:在指定位置画一个点
|
||||
*/
|
||||
void st7735s_draw_pixel(uint16_t x, uint16_t y, uint16_t color);
|
||||
|
||||
/*
|
||||
* 函数功能:画线
|
||||
* 入口参数:x1 - 起始列
|
||||
* y1 - 起始行
|
||||
* x2 - 结束列
|
||||
* y2 - 结束行
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:画一条直线(Bresenham算法)
|
||||
*/
|
||||
void st7735s_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
|
||||
|
||||
/*
|
||||
* 函数功能:画矩形
|
||||
* 入口参数:x - 左上角列
|
||||
* y - 左上角行
|
||||
* width - 宽度
|
||||
* height - 高度
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:画一个空心矩形
|
||||
*/
|
||||
void st7735s_draw_rect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
|
||||
|
||||
/*
|
||||
* 函数功能:画圆
|
||||
* 入口参数:x0 - 圆心列
|
||||
* y0 - 圆心行
|
||||
* radius - 半径
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:画一个空心圆(Bresenham算法)
|
||||
*/
|
||||
void st7735s_draw_circle(uint16_t x0, uint16_t y0, uint16_t radius, uint16_t color);
|
||||
|
||||
/*
|
||||
* 函数功能:显示字符
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* ch - 字符 (ASCII 32-126)
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:在指定位置显示一个8x16 ASCII字符
|
||||
*/
|
||||
void st7735s_draw_char(uint16_t x, uint16_t y, char ch, uint16_t color, uint16_t bg_color);
|
||||
|
||||
/*
|
||||
* 函数功能:显示字符串
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* str - 字符串指针
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:在指定位置显示字符串
|
||||
*/
|
||||
void st7735s_draw_string(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bg_color);
|
||||
|
||||
/*
|
||||
* 函数功能:设置屏幕方向
|
||||
* 入口参数:rotation - 方向 (0-3)
|
||||
* 返回值:无
|
||||
* 函数说明:设置屏幕显示方向
|
||||
* 0: 竖屏
|
||||
* 1: 横屏
|
||||
* 2: 竖屏反转
|
||||
* 3: 横屏反转
|
||||
*/
|
||||
void st7735s_set_rotation(uint8_t rotation);
|
||||
|
||||
/*
|
||||
* 函数功能:设置背光
|
||||
* 入口参数:state - 1:开 0:关
|
||||
* 返回值:无
|
||||
* 函数说明:控制LCD背光(如有硬件背光控制)
|
||||
*/
|
||||
void st7735s_backlight(uint8_t state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ST7735S_H */
|
||||
192
STM32F103C8T6/Drivers/BSP/MultiButton/button_driver.c
Normal file
192
STM32F103C8T6/Drivers/BSP/MultiButton/button_driver.c
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* 模块名称:按键驱动适配层
|
||||
* 模块功能:提供MultiButton库与STM32 HAL库的适配接口
|
||||
* 适用平台:STM32F103C8T6
|
||||
* 作者:王建锋
|
||||
* 创建日期:2026-07-13
|
||||
* 修改记录:
|
||||
* 2026-07-13 王建锋 创建初始版本
|
||||
*/
|
||||
|
||||
#include "button_driver.h"
|
||||
#include "main.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/* 按键句柄数组 */
|
||||
static Button s_button_handles[BUTTON_ID_MAX];
|
||||
|
||||
/* 按键GPIO端口和引脚映射表 */
|
||||
typedef struct {
|
||||
GPIO_TypeDef* port; /* GPIO端口 */
|
||||
uint16_t pin; /* GPIO引脚 */
|
||||
} ButtonGpio_t;
|
||||
|
||||
static const ButtonGpio_t s_button_gpio[BUTTON_ID_MAX] = {
|
||||
{KEY1_GPIO_Port, KEY1_Pin}, /* KEY1: PB4 左上*/
|
||||
{KEY2_GPIO_Port, KEY2_Pin}, /* KEY2: PB5 右上*/
|
||||
{KEY3_GPIO_Port, KEY3_Pin}, /* KEY3: PB3 右下*/
|
||||
{KEY4_GPIO_Port, KEY4_Pin}, /* KEY4: PC14 左下*/
|
||||
{KEY5_GPIO_Port, KEY5_Pin}, /* KEY5: PC15 中间*/
|
||||
};
|
||||
|
||||
/*
|
||||
* 函数功能:获取指定按键的电平状态
|
||||
* 入口参数:button_id - 按键标识符
|
||||
* 返回值:GPIO电平值 (0或1)
|
||||
* 函数说明:根据按键ID读取对应GPIO引脚的电平
|
||||
*/
|
||||
uint8_t button_driver_read_level(uint8_t button_id)
|
||||
{
|
||||
if (button_id >= BUTTON_ID_MAX) {
|
||||
return 0;
|
||||
}
|
||||
return HAL_GPIO_ReadPin(s_button_gpio[button_id].port, s_button_gpio[button_id].pin);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:KEY1按键回调函数
|
||||
* 入口参数:handle - 按键句柄
|
||||
* user_data - 用户数据指针
|
||||
* 返回值:无
|
||||
* 函数说明:KEY1按下时翻转LED
|
||||
*/
|
||||
static void button_key1_callback(Button* handle, void* user_data)
|
||||
{
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
printf("KEY1\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:KEY2单击回调函数
|
||||
* 入口参数:handle - 按键句柄
|
||||
* user_data - 用户数据指针
|
||||
* 返回值:无
|
||||
* 函数说明:KEY2单击时点亮LED
|
||||
*/
|
||||
static void button_key2_single_click(Button* handle, void* user_data)
|
||||
{
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
printf("KEY2\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:KEY3单击回调函数
|
||||
* 入口参数:handle - 按键句柄
|
||||
* user_data - 用户数据指针
|
||||
* 返回值:无
|
||||
* 函数说明:KEY3单击事件处理
|
||||
*/
|
||||
static void button_key3_single_click(Button* handle, void* user_data)
|
||||
{
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
printf("KEY3: \n");
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:KEY4单击回调函数
|
||||
* 入口参数:handle - 按键句柄
|
||||
* user_data - 用户数据指针
|
||||
* 返回值:无
|
||||
* 函数说明:KEY4单击事件处理
|
||||
*/
|
||||
static void button_key4_single_click(Button* handle, void* user_data)
|
||||
{
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
printf("KEY4\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:KEY5单击回调函数
|
||||
* 入口参数:handle - 按键句柄
|
||||
* user_data - 用户数据指针
|
||||
* 返回值:无
|
||||
* 函数说明:KEY5单击事件处理
|
||||
*/
|
||||
static void button_key5_single_click(Button* handle, void* user_data)
|
||||
{
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
printf("KEY5\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:按键驱动初始化
|
||||
* 入口参数:无
|
||||
* 返回值:无
|
||||
* 函数说明:初始化所有按键对象,注册回调函数,启动按键轮询
|
||||
*/
|
||||
void button_driver_init(void)
|
||||
{
|
||||
/* 初始化KEY1 */
|
||||
button_init(&s_button_handles[BUTTON_ID_KEY1],
|
||||
button_driver_read_level,
|
||||
BUTTON_ACTIVE_LEVEL_LOW,
|
||||
BUTTON_ID_KEY1);
|
||||
button_attach(&s_button_handles[BUTTON_ID_KEY1],
|
||||
BTN_SINGLE_CLICK,
|
||||
button_key1_callback,
|
||||
NULL);
|
||||
button_start(&s_button_handles[BUTTON_ID_KEY1]);
|
||||
|
||||
/* 初始化KEY2 */
|
||||
button_init(&s_button_handles[BUTTON_ID_KEY2],
|
||||
button_driver_read_level,
|
||||
BUTTON_ACTIVE_LEVEL_LOW,
|
||||
BUTTON_ID_KEY2);
|
||||
button_attach(&s_button_handles[BUTTON_ID_KEY2],
|
||||
BTN_SINGLE_CLICK,
|
||||
button_key2_single_click,
|
||||
NULL);
|
||||
button_start(&s_button_handles[BUTTON_ID_KEY2]);
|
||||
|
||||
/* 初始化KEY3 */
|
||||
button_init(&s_button_handles[BUTTON_ID_KEY3],
|
||||
button_driver_read_level,
|
||||
BUTTON_ACTIVE_LEVEL_LOW,
|
||||
BUTTON_ID_KEY3);
|
||||
button_attach(&s_button_handles[BUTTON_ID_KEY3],
|
||||
BTN_SINGLE_CLICK,
|
||||
button_key3_single_click,
|
||||
NULL);
|
||||
button_start(&s_button_handles[BUTTON_ID_KEY3]);
|
||||
|
||||
/* 初始化KEY4 */
|
||||
button_init(&s_button_handles[BUTTON_ID_KEY4],
|
||||
button_driver_read_level,
|
||||
BUTTON_ACTIVE_LEVEL_LOW,
|
||||
BUTTON_ID_KEY4);
|
||||
button_attach(&s_button_handles[BUTTON_ID_KEY4],
|
||||
BTN_SINGLE_CLICK,
|
||||
button_key4_single_click,
|
||||
NULL);
|
||||
button_start(&s_button_handles[BUTTON_ID_KEY4]);
|
||||
|
||||
/* 初始化KEY5 */
|
||||
button_init(&s_button_handles[BUTTON_ID_KEY5],
|
||||
button_driver_read_level,
|
||||
BUTTON_ACTIVE_LEVEL_LOW,
|
||||
BUTTON_ID_KEY5);
|
||||
button_attach(&s_button_handles[BUTTON_ID_KEY5],
|
||||
BTN_SINGLE_CLICK,
|
||||
button_key5_single_click,
|
||||
NULL);
|
||||
button_start(&s_button_handles[BUTTON_ID_KEY5]);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:获取指定按键的事件
|
||||
* 入口参数:button_id - 按键标识符
|
||||
* 返回值:按键事件
|
||||
* 函数说明:返回指定按键的当前事件
|
||||
*/
|
||||
ButtonEvent button_driver_get_event(uint8_t button_id)
|
||||
{
|
||||
if (button_id >= BUTTON_ID_MAX) {
|
||||
return BTN_NONE_PRESS;
|
||||
}
|
||||
return button_get_event(&s_button_handles[button_id]);
|
||||
}
|
||||
63
STM32F103C8T6/Drivers/BSP/MultiButton/button_driver.h
Normal file
63
STM32F103C8T6/Drivers/BSP/MultiButton/button_driver.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 模块名称:按键驱动适配层
|
||||
* 模块功能:提供MultiButton库与STM32 HAL库的适配接口
|
||||
* 适用平台:STM32F103C8T6
|
||||
* 作者:王建锋
|
||||
* 创建日期:2026-07-13
|
||||
* 修改记录:
|
||||
* 2026-07-13 王建锋 创建初始版本
|
||||
*/
|
||||
|
||||
#ifndef __BUTTON_DRIVER_H
|
||||
#define __BUTTON_DRIVER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "multi_button.h"
|
||||
#include "main.h"
|
||||
|
||||
/* 按键ID定义 */
|
||||
typedef enum {
|
||||
BUTTON_ID_KEY1 = 0, /* KEY1: PB4 */
|
||||
BUTTON_ID_KEY2, /* KEY2: PB5 */
|
||||
BUTTON_ID_KEY3, /* KEY3: PB3 */
|
||||
BUTTON_ID_KEY4, /* KEY4: PC14 */
|
||||
BUTTON_ID_KEY5, /* KEY5: PC15 */
|
||||
BUTTON_ID_MAX /* 按键总数 */
|
||||
} ButtonId_t;
|
||||
|
||||
/* 按键有效电平定义 */
|
||||
#define BUTTON_ACTIVE_LEVEL_LOW 0 /* 低电平有效 */
|
||||
#define BUTTON_ACTIVE_LEVEL_HIGH 1 /* 高电平有效 */
|
||||
|
||||
/*
|
||||
* 函数功能:按键驱动初始化
|
||||
* 入口参数:无
|
||||
* 返回值:无
|
||||
* 函数说明:初始化所有按键对象,注册回调函数,启动按键轮询
|
||||
*/
|
||||
void button_driver_init(void);
|
||||
|
||||
/*
|
||||
* 函数功能:获取指定按键的电平状态
|
||||
* 入口参数:button_id - 按键标识符
|
||||
* 返回值:GPIO电平值 (0或1)
|
||||
* 函数说明:根据按键ID读取对应GPIO引脚的电平
|
||||
*/
|
||||
uint8_t button_driver_read_level(uint8_t button_id);
|
||||
|
||||
/*
|
||||
* 函数功能:获取指定按键的事件
|
||||
* 入口参数:button_id - 按键标识符
|
||||
* 返回值:按键事件
|
||||
* 函数说明:返回指定按键的当前事件
|
||||
*/
|
||||
ButtonEvent button_driver_get_event(uint8_t button_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BUTTON_DRIVER_H */
|
||||
334
STM32F103C8T6/Drivers/BSP/MultiButton/multi_button.c
Normal file
334
STM32F103C8T6/Drivers/BSP/MultiButton/multi_button.c
Normal file
@@ -0,0 +1,334 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Zibin Zheng <znbin@qq.com>
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#include "multi_button.h"
|
||||
|
||||
/* 回调执行宏,包含空值检查,传递user_data */
|
||||
#define EVENT_CB(ev) do { if (handle->cb[ev]) handle->cb[ev](handle, handle->user_data); } while(0)
|
||||
|
||||
/* 按键句柄链表头 */
|
||||
static Button* head_handle = NULL;
|
||||
|
||||
/* 前向声明 */
|
||||
static void button_handler(Button* handle);
|
||||
static inline uint8_t button_read_level(Button* handle);
|
||||
|
||||
/*
|
||||
* 函数功能:初始化按键结构体句柄
|
||||
* 入口参数:handle - 按键句柄结构体指针
|
||||
* pin_level - 读取按键GPIO电平的函数指针
|
||||
* active_level - 按下时的有效电平
|
||||
* button_id - 按键标识符
|
||||
* 返回值:无
|
||||
* 函数说明:初始化按键状态机和所有参数
|
||||
*/
|
||||
void button_init(Button* handle, uint8_t(*pin_level)(uint8_t), uint8_t active_level, uint8_t button_id)
|
||||
{
|
||||
if (!handle || !pin_level) {
|
||||
return;
|
||||
}
|
||||
|
||||
memset(handle, 0, sizeof(Button));
|
||||
handle->event = (uint8_t)BTN_NONE_PRESS;
|
||||
handle->hal_button_level = pin_level;
|
||||
handle->button_level = !active_level;
|
||||
handle->active_level = active_level;
|
||||
handle->button_id = button_id;
|
||||
handle->state = BTN_STATE_IDLE;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:绑定按键事件回调函数
|
||||
* 入口参数:handle - 按键句柄结构体指针
|
||||
* event - 触发事件类型
|
||||
* cb - 回调函数
|
||||
* user_data - 传递给回调的用户上下文指针
|
||||
* 返回值:无
|
||||
* 函数说明:为指定事件注册回调函数
|
||||
*/
|
||||
void button_attach(Button* handle, ButtonEvent event, BtnCallback cb, void* user_data)
|
||||
{
|
||||
if (!handle || event >= BTN_EVENT_COUNT) {
|
||||
return;
|
||||
}
|
||||
handle->cb[event] = cb;
|
||||
handle->user_data = user_data;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:解绑按键事件回调函数
|
||||
* 入口参数:handle - 按键句柄结构体指针
|
||||
* event - 触发事件类型
|
||||
* 返回值:无
|
||||
* 函数说明:移除指定事件的回调函数
|
||||
*/
|
||||
void button_detach(Button* handle, ButtonEvent event)
|
||||
{
|
||||
if (!handle || event >= BTN_EVENT_COUNT) {
|
||||
return;
|
||||
}
|
||||
handle->cb[event] = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:获取按键事件
|
||||
* 入口参数:handle - 按键句柄结构体指针
|
||||
* 返回值:按键事件
|
||||
* 函数说明:返回当前发生的按键事件
|
||||
*/
|
||||
ButtonEvent button_get_event(Button* handle)
|
||||
{
|
||||
if (!handle) {
|
||||
return BTN_NONE_PRESS;
|
||||
}
|
||||
return (ButtonEvent)(handle->event);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:获取按键重复按下次数
|
||||
* 入口参数:handle - 按键句柄结构体指针
|
||||
* 返回值:重复按下次数
|
||||
* 函数说明:返回连击次数
|
||||
*/
|
||||
uint8_t button_get_repeat_count(Button* handle)
|
||||
{
|
||||
if (!handle) {
|
||||
return 0;
|
||||
}
|
||||
return handle->repeat;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:重置按键状态到空闲
|
||||
* 入口参数:handle - 按键句柄结构体指针
|
||||
* 返回值:无
|
||||
* 函数说明:将按键状态机重置为初始状态
|
||||
*/
|
||||
void button_reset(Button* handle)
|
||||
{
|
||||
if (!handle) {
|
||||
return;
|
||||
}
|
||||
handle->state = BTN_STATE_IDLE;
|
||||
handle->ticks = 0;
|
||||
handle->repeat = 0;
|
||||
handle->event = (uint8_t)BTN_NONE_PRESS;
|
||||
handle->debounce_cnt = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:检查按键是否按下
|
||||
* 入口参数:handle - 按键句柄结构体指针
|
||||
* 返回值:1 - 按下,0 - 未按下,-1 - 错误
|
||||
* 函数说明:检查当前按键是否处于按下状态
|
||||
*/
|
||||
int button_is_pressed(Button* handle)
|
||||
{
|
||||
if (!handle) {
|
||||
return -1;
|
||||
}
|
||||
return (handle->button_level == handle->active_level) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:读取按键电平
|
||||
* 入口参数:handle - 按键句柄结构体指针
|
||||
* 返回值:按键电平
|
||||
* 函数说明:通过HAL函数读取GPIO电平
|
||||
*/
|
||||
static inline uint8_t button_read_level(Button* handle)
|
||||
{
|
||||
return handle->hal_button_level(handle->button_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:按键驱动核心函数,驱动状态机
|
||||
* 入口参数:handle - 按键句柄结构体指针
|
||||
* 返回值:无
|
||||
* 函数说明:实现按键消抖和事件检测的状态机
|
||||
*/
|
||||
static void button_handler(Button* handle)
|
||||
{
|
||||
uint8_t read_gpio_level = button_read_level(handle);
|
||||
|
||||
/* 非空闲状态下增加tick计数器(饱和处理) */
|
||||
if (handle->state > BTN_STATE_IDLE) {
|
||||
if (handle->ticks < UINT16_MAX) {
|
||||
handle->ticks++;
|
||||
}
|
||||
}
|
||||
|
||||
/* 按键消抖处理 */
|
||||
if (read_gpio_level != handle->button_level) {
|
||||
if (++(handle->debounce_cnt) >= DEBOUNCE_TICKS) {
|
||||
handle->button_level = read_gpio_level;
|
||||
handle->debounce_cnt = 0;
|
||||
}
|
||||
} else {
|
||||
handle->debounce_cnt = 0;
|
||||
}
|
||||
|
||||
/* 状态机 */
|
||||
switch (handle->state) {
|
||||
case BTN_STATE_IDLE:
|
||||
if (handle->button_level == handle->active_level) {
|
||||
/* 检测到按键按下 */
|
||||
handle->event = (uint8_t)BTN_PRESS_DOWN;
|
||||
EVENT_CB(BTN_PRESS_DOWN);
|
||||
handle->ticks = 0;
|
||||
handle->repeat = 1;
|
||||
handle->state = BTN_STATE_PRESS;
|
||||
} else {
|
||||
handle->event = (uint8_t)BTN_NONE_PRESS;
|
||||
}
|
||||
break;
|
||||
|
||||
case BTN_STATE_PRESS:
|
||||
if (handle->button_level != handle->active_level) {
|
||||
/* 按键释放 */
|
||||
handle->event = (uint8_t)BTN_PRESS_UP;
|
||||
EVENT_CB(BTN_PRESS_UP);
|
||||
handle->ticks = 0;
|
||||
handle->state = BTN_STATE_RELEASE;
|
||||
} else if (handle->ticks > LONG_TICKS) {
|
||||
/* 检测到长按 */
|
||||
handle->event = (uint8_t)BTN_LONG_PRESS_START;
|
||||
EVENT_CB(BTN_LONG_PRESS_START);
|
||||
handle->state = BTN_STATE_LONG_HOLD;
|
||||
}
|
||||
break;
|
||||
|
||||
case BTN_STATE_RELEASE:
|
||||
if (handle->button_level == handle->active_level) {
|
||||
/* 按键再次按下 */
|
||||
handle->event = (uint8_t)BTN_PRESS_DOWN;
|
||||
EVENT_CB(BTN_PRESS_DOWN);
|
||||
if (handle->repeat < PRESS_REPEAT_MAX_NUM) {
|
||||
handle->repeat++;
|
||||
}
|
||||
handle->event = (uint8_t)BTN_PRESS_REPEAT;
|
||||
EVENT_CB(BTN_PRESS_REPEAT);
|
||||
handle->ticks = 0;
|
||||
handle->state = BTN_STATE_REPEAT;
|
||||
} else if (handle->ticks > SHORT_TICKS) {
|
||||
/* 超时,判断点击类型 */
|
||||
if (handle->repeat == 1) {
|
||||
handle->event = (uint8_t)BTN_SINGLE_CLICK;
|
||||
EVENT_CB(BTN_SINGLE_CLICK);
|
||||
} else if (handle->repeat == 2) {
|
||||
handle->event = (uint8_t)BTN_DOUBLE_CLICK;
|
||||
EVENT_CB(BTN_DOUBLE_CLICK);
|
||||
}
|
||||
handle->state = BTN_STATE_IDLE;
|
||||
}
|
||||
break;
|
||||
|
||||
case BTN_STATE_REPEAT:
|
||||
if (handle->button_level != handle->active_level) {
|
||||
/* 按键释放 */
|
||||
handle->event = (uint8_t)BTN_PRESS_UP;
|
||||
EVENT_CB(BTN_PRESS_UP);
|
||||
if (handle->ticks < SHORT_TICKS) {
|
||||
handle->ticks = 0;
|
||||
handle->state = BTN_STATE_RELEASE;
|
||||
} else {
|
||||
handle->state = BTN_STATE_IDLE;
|
||||
}
|
||||
} else if (handle->ticks > SHORT_TICKS) {
|
||||
/* 按住时间过长,视为普通按下 */
|
||||
handle->ticks = 0;
|
||||
handle->repeat = 0;
|
||||
handle->state = BTN_STATE_PRESS;
|
||||
}
|
||||
break;
|
||||
|
||||
case BTN_STATE_LONG_HOLD:
|
||||
if (handle->button_level == handle->active_level) {
|
||||
/* 继续保持按下 */
|
||||
handle->event = (uint8_t)BTN_LONG_PRESS_HOLD;
|
||||
EVENT_CB(BTN_LONG_PRESS_HOLD);
|
||||
} else {
|
||||
/* 从长按中释放 */
|
||||
handle->event = (uint8_t)BTN_PRESS_UP;
|
||||
EVENT_CB(BTN_PRESS_UP);
|
||||
handle->state = BTN_STATE_IDLE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* 无效状态,重置为空闲 */
|
||||
handle->state = BTN_STATE_IDLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:启动按键工作,将句柄添加到工作链表
|
||||
* 入口参数:handle - 目标句柄结构体指针
|
||||
* 返回值:0 - 成功,-1 - 已存在,-2 - 无效参数
|
||||
* 函数说明:将按键添加到轮询链表中
|
||||
*/
|
||||
int button_start(Button* handle)
|
||||
{
|
||||
if (!handle) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
Button* target = head_handle;
|
||||
while (target) {
|
||||
if (target == handle) {
|
||||
return -1;
|
||||
}
|
||||
target = target->next;
|
||||
}
|
||||
|
||||
handle->next = head_handle;
|
||||
head_handle = handle;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:停止按键工作,从工作链表移除句柄
|
||||
* 入口参数:handle - 目标句柄结构体指针
|
||||
* 返回值:无
|
||||
* 函数说明:将按键从轮询链表中移除
|
||||
*/
|
||||
void button_stop(Button* handle)
|
||||
{
|
||||
if (!handle) {
|
||||
return;
|
||||
}
|
||||
|
||||
Button** curr;
|
||||
for (curr = &head_handle; *curr; ) {
|
||||
Button* entry = *curr;
|
||||
if (entry == handle) {
|
||||
*curr = entry->next;
|
||||
entry->next = NULL;
|
||||
return;
|
||||
} else {
|
||||
curr = &entry->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:后台tick处理,定时器重复调用,间隔5ms
|
||||
* 入口参数:无
|
||||
* 返回值:无
|
||||
* 函数说明:遍历链表调用每个按键的状态机处理函数
|
||||
*/
|
||||
void button_ticks(void)
|
||||
{
|
||||
Button* target;
|
||||
Button* next;
|
||||
|
||||
target = head_handle;
|
||||
while (target) {
|
||||
next = target->next;
|
||||
button_handler(target);
|
||||
target = next;
|
||||
}
|
||||
}
|
||||
95
STM32F103C8T6/Drivers/BSP/MultiButton/multi_button.h
Normal file
95
STM32F103C8T6/Drivers/BSP/MultiButton/multi_button.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Zibin Zheng <znbin@qq.com>
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef MULTI_BUTTON_H
|
||||
#define MULTI_BUTTON_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
/* 版本信息 */
|
||||
#define MULTIBUTTON_VERSION_MAJOR 1
|
||||
#define MULTIBUTTON_VERSION_MINOR 1
|
||||
#define MULTIBUTTON_VERSION_PATCH 1
|
||||
|
||||
/* 配置常量 - 可根据需求修改 */
|
||||
#define TICKS_INTERVAL 5 /* 定时器轮询间隔,单位:毫秒 */
|
||||
#define DEBOUNCE_TICKS 3 /* 消抖滤波深度,最大7 (0~7) */
|
||||
#define SHORT_TICKS (300 / TICKS_INTERVAL) /* 短按阈值 */
|
||||
#define LONG_TICKS (1000 / TICKS_INTERVAL) /* 长按阈值 */
|
||||
#define PRESS_REPEAT_MAX_NUM 15 /* 最大重复计数器值 */
|
||||
|
||||
/* 编译时检查:debounce_cnt 是3位域,最大值为7 */
|
||||
#if DEBOUNCE_TICKS > 7
|
||||
#error "DEBOUNCE_TICKS exceeds 3-bit field maximum (7)"
|
||||
#endif
|
||||
|
||||
/* 前向声明 */
|
||||
typedef struct _Button Button;
|
||||
|
||||
/* 按键回调函数类型 */
|
||||
typedef void (*BtnCallback)(Button* handle, void* user_data);
|
||||
|
||||
/* 按键事件类型 */
|
||||
typedef enum {
|
||||
BTN_PRESS_DOWN = 0, /* 按键按下 */
|
||||
BTN_PRESS_UP, /* 按键释放 */
|
||||
BTN_PRESS_REPEAT, /* 重复按下检测 */
|
||||
BTN_SINGLE_CLICK, /* 单击完成 */
|
||||
BTN_DOUBLE_CLICK, /* 双击完成 */
|
||||
BTN_LONG_PRESS_START, /* 长按开始 */
|
||||
BTN_LONG_PRESS_HOLD, /* 长按保持 */
|
||||
BTN_EVENT_COUNT, /* 事件总数 */
|
||||
BTN_NONE_PRESS /* 无事件 */
|
||||
} ButtonEvent;
|
||||
|
||||
/* 按键状态机状态 */
|
||||
typedef enum {
|
||||
BTN_STATE_IDLE = 0, /* 空闲状态 */
|
||||
BTN_STATE_PRESS, /* 按下状态 */
|
||||
BTN_STATE_RELEASE, /* 释放后等待超时 */
|
||||
BTN_STATE_REPEAT, /* 重复按下状态 */
|
||||
BTN_STATE_LONG_HOLD /* 长按保持状态 */
|
||||
} ButtonState;
|
||||
|
||||
/* 按键结构体 */
|
||||
struct _Button {
|
||||
uint16_t ticks; /* tick计数器 */
|
||||
uint8_t repeat : 4; /* 重复计数器 (0-15) */
|
||||
uint8_t event : 4; /* 当前事件 (0-15) */
|
||||
uint8_t state : 3; /* 状态机状态 (0-7) */
|
||||
uint8_t debounce_cnt : 3; /* 消抖计数器 (0-7) */
|
||||
uint8_t active_level : 1; /* 有效GPIO电平 (0或1) */
|
||||
uint8_t button_level : 1; /* 当前按键电平 */
|
||||
uint8_t button_id; /* 按键标识符 */
|
||||
uint8_t (*hal_button_level)(uint8_t button_id); /* HAL读取GPIO函数 */
|
||||
BtnCallback cb[BTN_EVENT_COUNT]; /* 回调函数数组 */
|
||||
void* user_data; /* 传递给回调的用户上下文指针 */
|
||||
Button* next; /* 链表中的下一个按键 */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* 公共API函数 */
|
||||
void button_init(Button* handle, uint8_t(*pin_level)(uint8_t), uint8_t active_level, uint8_t button_id);
|
||||
void button_attach(Button* handle, ButtonEvent event, BtnCallback cb, void* user_data);
|
||||
void button_detach(Button* handle, ButtonEvent event);
|
||||
ButtonEvent button_get_event(Button* handle);
|
||||
int button_start(Button* handle);
|
||||
void button_stop(Button* handle);
|
||||
void button_ticks(void);
|
||||
|
||||
/* 工具函数 */
|
||||
uint8_t button_get_repeat_count(Button* handle);
|
||||
void button_reset(Button* handle);
|
||||
int button_is_pressed(Button* handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MULTI_BUTTON_H */
|
||||
@@ -0,0 +1,734 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f1xx_hal_spi.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header file of SPI HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32F1xx_HAL_SPI_H
|
||||
#define STM32F1xx_HAL_SPI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f1xx_hal_def.h"
|
||||
|
||||
/** @addtogroup STM32F1xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup SPI
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup SPI_Exported_Types SPI Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief SPI Configuration Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Mode; /*!< Specifies the SPI operating mode.
|
||||
This parameter can be a value of @ref SPI_Mode */
|
||||
|
||||
uint32_t Direction; /*!< Specifies the SPI bidirectional mode state.
|
||||
This parameter can be a value of @ref SPI_Direction */
|
||||
|
||||
uint32_t DataSize; /*!< Specifies the SPI data size.
|
||||
This parameter can be a value of @ref SPI_Data_Size */
|
||||
|
||||
uint32_t CLKPolarity; /*!< Specifies the serial clock steady state.
|
||||
This parameter can be a value of @ref SPI_Clock_Polarity */
|
||||
|
||||
uint32_t CLKPhase; /*!< Specifies the clock active edge for the bit capture.
|
||||
This parameter can be a value of @ref SPI_Clock_Phase */
|
||||
|
||||
uint32_t NSS; /*!< Specifies whether the NSS signal is managed by
|
||||
hardware (NSS pin) or by software using the SSI bit.
|
||||
This parameter can be a value of @ref SPI_Slave_Select_management */
|
||||
|
||||
uint32_t BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be
|
||||
used to configure the transmit and receive SCK clock.
|
||||
This parameter can be a value of @ref SPI_BaudRate_Prescaler
|
||||
@note The communication clock is derived from the master
|
||||
clock. The slave clock does not need to be set. */
|
||||
|
||||
uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
|
||||
This parameter can be a value of @ref SPI_MSB_LSB_transmission */
|
||||
|
||||
uint32_t TIMode; /*!< Specifies if the TI mode is enabled or not.
|
||||
This parameter can be a value of @ref SPI_TI_mode */
|
||||
|
||||
uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not.
|
||||
This parameter can be a value of @ref SPI_CRC_Calculation */
|
||||
|
||||
uint32_t CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation.
|
||||
This parameter must be an odd number between Min_Data = 1 and Max_Data = 65535 */
|
||||
} SPI_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL SPI State structure definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_SPI_STATE_RESET = 0x00U, /*!< Peripheral not Initialized */
|
||||
HAL_SPI_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
|
||||
HAL_SPI_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */
|
||||
HAL_SPI_STATE_BUSY_TX = 0x03U, /*!< Data Transmission process is ongoing */
|
||||
HAL_SPI_STATE_BUSY_RX = 0x04U, /*!< Data Reception process is ongoing */
|
||||
HAL_SPI_STATE_BUSY_TX_RX = 0x05U, /*!< Data Transmission and Reception process is ongoing */
|
||||
HAL_SPI_STATE_ERROR = 0x06U, /*!< SPI error state */
|
||||
HAL_SPI_STATE_ABORT = 0x07U /*!< SPI abort is ongoing */
|
||||
} HAL_SPI_StateTypeDef;
|
||||
|
||||
/**
|
||||
* @brief SPI handle Structure definition
|
||||
*/
|
||||
typedef struct __SPI_HandleTypeDef
|
||||
{
|
||||
SPI_TypeDef *Instance; /*!< SPI registers base address */
|
||||
|
||||
SPI_InitTypeDef Init; /*!< SPI communication parameters */
|
||||
|
||||
const uint8_t *pTxBuffPtr; /*!< Pointer to SPI Tx transfer Buffer */
|
||||
|
||||
uint16_t TxXferSize; /*!< SPI Tx Transfer size */
|
||||
|
||||
__IO uint16_t TxXferCount; /*!< SPI Tx Transfer Counter */
|
||||
|
||||
uint8_t *pRxBuffPtr; /*!< Pointer to SPI Rx transfer Buffer */
|
||||
|
||||
uint16_t RxXferSize; /*!< SPI Rx Transfer size */
|
||||
|
||||
__IO uint16_t RxXferCount; /*!< SPI Rx Transfer Counter */
|
||||
|
||||
void (*RxISR)(struct __SPI_HandleTypeDef *hspi); /*!< function pointer on Rx ISR */
|
||||
|
||||
void (*TxISR)(struct __SPI_HandleTypeDef *hspi); /*!< function pointer on Tx ISR */
|
||||
|
||||
DMA_HandleTypeDef *hdmatx; /*!< SPI Tx DMA Handle parameters */
|
||||
|
||||
DMA_HandleTypeDef *hdmarx; /*!< SPI Rx DMA Handle parameters */
|
||||
|
||||
HAL_LockTypeDef Lock; /*!< Locking object */
|
||||
|
||||
__IO HAL_SPI_StateTypeDef State; /*!< SPI communication state */
|
||||
|
||||
__IO uint32_t ErrorCode; /*!< SPI Error code */
|
||||
|
||||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
||||
void (* TxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Tx Completed callback */
|
||||
void (* RxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Rx Completed callback */
|
||||
void (* TxRxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI TxRx Completed callback */
|
||||
void (* TxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Tx Half Completed callback */
|
||||
void (* RxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Rx Half Completed callback */
|
||||
void (* TxRxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI TxRx Half Completed callback */
|
||||
void (* ErrorCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Error callback */
|
||||
void (* AbortCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Abort callback */
|
||||
void (* MspInitCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Msp Init callback */
|
||||
void (* MspDeInitCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Msp DeInit callback */
|
||||
|
||||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
||||
} SPI_HandleTypeDef;
|
||||
|
||||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
||||
/**
|
||||
* @brief HAL SPI Callback ID enumeration definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_SPI_TX_COMPLETE_CB_ID = 0x00U, /*!< SPI Tx Completed callback ID */
|
||||
HAL_SPI_RX_COMPLETE_CB_ID = 0x01U, /*!< SPI Rx Completed callback ID */
|
||||
HAL_SPI_TX_RX_COMPLETE_CB_ID = 0x02U, /*!< SPI TxRx Completed callback ID */
|
||||
HAL_SPI_TX_HALF_COMPLETE_CB_ID = 0x03U, /*!< SPI Tx Half Completed callback ID */
|
||||
HAL_SPI_RX_HALF_COMPLETE_CB_ID = 0x04U, /*!< SPI Rx Half Completed callback ID */
|
||||
HAL_SPI_TX_RX_HALF_COMPLETE_CB_ID = 0x05U, /*!< SPI TxRx Half Completed callback ID */
|
||||
HAL_SPI_ERROR_CB_ID = 0x06U, /*!< SPI Error callback ID */
|
||||
HAL_SPI_ABORT_CB_ID = 0x07U, /*!< SPI Abort callback ID */
|
||||
HAL_SPI_MSPINIT_CB_ID = 0x08U, /*!< SPI Msp Init callback ID */
|
||||
HAL_SPI_MSPDEINIT_CB_ID = 0x09U /*!< SPI Msp DeInit callback ID */
|
||||
|
||||
} HAL_SPI_CallbackIDTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL SPI Callback pointer definition
|
||||
*/
|
||||
typedef void (*pSPI_CallbackTypeDef)(SPI_HandleTypeDef *hspi); /*!< pointer to an SPI callback function */
|
||||
|
||||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup SPI_Exported_Constants SPI Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Error_Code SPI Error Code
|
||||
* @{
|
||||
*/
|
||||
#define HAL_SPI_ERROR_NONE (0x00000000U) /*!< No error */
|
||||
#define HAL_SPI_ERROR_MODF (0x00000001U) /*!< MODF error */
|
||||
#define HAL_SPI_ERROR_CRC (0x00000002U) /*!< CRC error */
|
||||
#define HAL_SPI_ERROR_OVR (0x00000004U) /*!< OVR error */
|
||||
#define HAL_SPI_ERROR_DMA (0x00000010U) /*!< DMA transfer error */
|
||||
#define HAL_SPI_ERROR_FLAG (0x00000020U) /*!< Error on RXNE/TXE/BSY Flag */
|
||||
#define HAL_SPI_ERROR_ABORT (0x00000040U) /*!< Error during SPI Abort procedure */
|
||||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
||||
#define HAL_SPI_ERROR_INVALID_CALLBACK (0x00000080U) /*!< Invalid Callback error */
|
||||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Mode SPI Mode
|
||||
* @{
|
||||
*/
|
||||
#define SPI_MODE_SLAVE (0x00000000U)
|
||||
#define SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Direction SPI Direction Mode
|
||||
* @{
|
||||
*/
|
||||
#define SPI_DIRECTION_2LINES (0x00000000U)
|
||||
#define SPI_DIRECTION_2LINES_RXONLY SPI_CR1_RXONLY
|
||||
#define SPI_DIRECTION_1LINE SPI_CR1_BIDIMODE
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Data_Size SPI Data Size
|
||||
* @{
|
||||
*/
|
||||
#define SPI_DATASIZE_8BIT (0x00000000U)
|
||||
#define SPI_DATASIZE_16BIT SPI_CR1_DFF
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Clock_Polarity SPI Clock Polarity
|
||||
* @{
|
||||
*/
|
||||
#define SPI_POLARITY_LOW (0x00000000U)
|
||||
#define SPI_POLARITY_HIGH SPI_CR1_CPOL
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Clock_Phase SPI Clock Phase
|
||||
* @{
|
||||
*/
|
||||
#define SPI_PHASE_1EDGE (0x00000000U)
|
||||
#define SPI_PHASE_2EDGE SPI_CR1_CPHA
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Slave_Select_management SPI Slave Select Management
|
||||
* @{
|
||||
*/
|
||||
#define SPI_NSS_SOFT SPI_CR1_SSM
|
||||
#define SPI_NSS_HARD_INPUT (0x00000000U)
|
||||
#define SPI_NSS_HARD_OUTPUT (SPI_CR2_SSOE << 16U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_BaudRate_Prescaler SPI BaudRate Prescaler
|
||||
* @{
|
||||
*/
|
||||
#define SPI_BAUDRATEPRESCALER_2 (0x00000000U)
|
||||
#define SPI_BAUDRATEPRESCALER_4 (SPI_CR1_BR_0)
|
||||
#define SPI_BAUDRATEPRESCALER_8 (SPI_CR1_BR_1)
|
||||
#define SPI_BAUDRATEPRESCALER_16 (SPI_CR1_BR_1 | SPI_CR1_BR_0)
|
||||
#define SPI_BAUDRATEPRESCALER_32 (SPI_CR1_BR_2)
|
||||
#define SPI_BAUDRATEPRESCALER_64 (SPI_CR1_BR_2 | SPI_CR1_BR_0)
|
||||
#define SPI_BAUDRATEPRESCALER_128 (SPI_CR1_BR_2 | SPI_CR1_BR_1)
|
||||
#define SPI_BAUDRATEPRESCALER_256 (SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_MSB_LSB_transmission SPI MSB LSB Transmission
|
||||
* @{
|
||||
*/
|
||||
#define SPI_FIRSTBIT_MSB (0x00000000U)
|
||||
#define SPI_FIRSTBIT_LSB SPI_CR1_LSBFIRST
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_TI_mode SPI TI Mode
|
||||
* @{
|
||||
*/
|
||||
#define SPI_TIMODE_DISABLE (0x00000000U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_CRC_Calculation SPI CRC Calculation
|
||||
* @{
|
||||
*/
|
||||
#define SPI_CRCCALCULATION_DISABLE (0x00000000U)
|
||||
#define SPI_CRCCALCULATION_ENABLE SPI_CR1_CRCEN
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Interrupt_definition SPI Interrupt Definition
|
||||
* @{
|
||||
*/
|
||||
#define SPI_IT_TXE SPI_CR2_TXEIE
|
||||
#define SPI_IT_RXNE SPI_CR2_RXNEIE
|
||||
#define SPI_IT_ERR SPI_CR2_ERRIE
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Flags_definition SPI Flags Definition
|
||||
* @{
|
||||
*/
|
||||
#define SPI_FLAG_RXNE SPI_SR_RXNE /* SPI status flag: Rx buffer not empty flag */
|
||||
#define SPI_FLAG_TXE SPI_SR_TXE /* SPI status flag: Tx buffer empty flag */
|
||||
#define SPI_FLAG_BSY SPI_SR_BSY /* SPI status flag: Busy flag */
|
||||
#define SPI_FLAG_CRCERR SPI_SR_CRCERR /* SPI Error flag: CRC error flag */
|
||||
#define SPI_FLAG_MODF SPI_SR_MODF /* SPI Error flag: Mode fault flag */
|
||||
#define SPI_FLAG_OVR SPI_SR_OVR /* SPI Error flag: Overrun flag */
|
||||
#define SPI_FLAG_MASK (SPI_SR_RXNE | SPI_SR_TXE | SPI_SR_BSY\
|
||||
| SPI_SR_CRCERR | SPI_SR_MODF | SPI_SR_OVR)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/** @defgroup SPI_Exported_Macros SPI Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Reset SPI handle state.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
||||
#define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) \
|
||||
do{ \
|
||||
(__HANDLE__)->State = HAL_SPI_STATE_RESET; \
|
||||
(__HANDLE__)->MspInitCallback = NULL; \
|
||||
(__HANDLE__)->MspDeInitCallback = NULL; \
|
||||
} while(0)
|
||||
#else
|
||||
#define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET)
|
||||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
||||
|
||||
/** @brief Enable the specified SPI interrupts.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @param __INTERRUPT__ specifies the interrupt source to enable.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
||||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
||||
* @arg SPI_IT_ERR: Error interrupt enable
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__))
|
||||
|
||||
/** @brief Disable the specified SPI interrupts.
|
||||
* @param __HANDLE__ specifies the SPI handle.
|
||||
* This parameter can be SPIx where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @param __INTERRUPT__ specifies the interrupt source to disable.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
||||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
||||
* @arg SPI_IT_ERR: Error interrupt enable
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__))
|
||||
|
||||
/** @brief Check whether the specified SPI interrupt source is enabled or not.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @param __INTERRUPT__ specifies the SPI interrupt source to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
||||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
||||
* @arg SPI_IT_ERR: Error interrupt enable
|
||||
* @retval The new state of __IT__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2\
|
||||
& (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
|
||||
|
||||
/** @brief Check whether the specified SPI flag is set or not.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @param __FLAG__ specifies the flag to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg SPI_FLAG_RXNE: Receive buffer not empty flag
|
||||
* @arg SPI_FLAG_TXE: Transmit buffer empty flag
|
||||
* @arg SPI_FLAG_CRCERR: CRC error flag
|
||||
* @arg SPI_FLAG_MODF: Mode fault flag
|
||||
* @arg SPI_FLAG_OVR: Overrun flag
|
||||
* @arg SPI_FLAG_BSY: Busy flag
|
||||
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
|
||||
|
||||
/** @brief Clear the SPI CRCERR pending flag.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_SPI_CLEAR_CRCERRFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR = (uint16_t)(~SPI_FLAG_CRCERR))
|
||||
|
||||
/** @brief Clear the SPI MODF pending flag.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__) \
|
||||
do{ \
|
||||
__IO uint32_t tmpreg_modf = 0x00U; \
|
||||
tmpreg_modf = (__HANDLE__)->Instance->SR; \
|
||||
CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE); \
|
||||
UNUSED(tmpreg_modf); \
|
||||
} while(0U)
|
||||
|
||||
/** @brief Clear the SPI OVR pending flag.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__) \
|
||||
do{ \
|
||||
__IO uint32_t tmpreg_ovr = 0x00U; \
|
||||
tmpreg_ovr = (__HANDLE__)->Instance->DR; \
|
||||
tmpreg_ovr = (__HANDLE__)->Instance->SR; \
|
||||
UNUSED(tmpreg_ovr); \
|
||||
} while(0U)
|
||||
|
||||
/** @brief Enable the SPI peripheral.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_SPI_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE)
|
||||
|
||||
/** @brief Disable the SPI peripheral.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_SPI_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/** @defgroup SPI_Private_Constants SPI Private Constants
|
||||
* @{
|
||||
*/
|
||||
#define SPI_INVALID_CRC_ERROR 0U /* CRC error wrongly detected */
|
||||
#define SPI_VALID_CRC_ERROR 1U /* CRC error is true */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup SPI_Private_Macros SPI Private Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Set the SPI transmit-only mode.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#define SPI_1LINE_TX(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_BIDIOE)
|
||||
|
||||
/** @brief Set the SPI receive-only mode.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#define SPI_1LINE_RX(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_BIDIOE)
|
||||
|
||||
/** @brief Reset the CRC calculation of the SPI.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#define SPI_RESET_CRC(__HANDLE__) \
|
||||
do{ \
|
||||
CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_CRCEN); \
|
||||
SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_CRCEN); \
|
||||
} while(0U)
|
||||
|
||||
/** @brief Check whether the specified SPI flag is set or not.
|
||||
* @param __SR__ copy of SPI SR register.
|
||||
* @param __FLAG__ specifies the flag to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg SPI_FLAG_RXNE: Receive buffer not empty flag
|
||||
* @arg SPI_FLAG_TXE: Transmit buffer empty flag
|
||||
* @arg SPI_FLAG_CRCERR: CRC error flag
|
||||
* @arg SPI_FLAG_MODF: Mode fault flag
|
||||
* @arg SPI_FLAG_OVR: Overrun flag
|
||||
* @arg SPI_FLAG_BSY: Busy flag
|
||||
* @retval SET or RESET.
|
||||
*/
|
||||
#define SPI_CHECK_FLAG(__SR__, __FLAG__) ((((__SR__) & ((__FLAG__) & SPI_FLAG_MASK)) == \
|
||||
((__FLAG__) & SPI_FLAG_MASK)) ? SET : RESET)
|
||||
|
||||
/** @brief Check whether the specified SPI Interrupt is set or not.
|
||||
* @param __CR2__ copy of SPI CR2 register.
|
||||
* @param __INTERRUPT__ specifies the SPI interrupt source to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
||||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
||||
* @arg SPI_IT_ERR: Error interrupt enable
|
||||
* @retval SET or RESET.
|
||||
*/
|
||||
#define SPI_CHECK_IT_SOURCE(__CR2__, __INTERRUPT__) ((((__CR2__) & (__INTERRUPT__)) == \
|
||||
(__INTERRUPT__)) ? SET : RESET)
|
||||
|
||||
/** @brief Checks if SPI Mode parameter is in allowed range.
|
||||
* @param __MODE__ specifies the SPI Mode.
|
||||
* This parameter can be a value of @ref SPI_Mode
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_MODE(__MODE__) (((__MODE__) == SPI_MODE_SLAVE) || \
|
||||
((__MODE__) == SPI_MODE_MASTER))
|
||||
|
||||
/** @brief Checks if SPI Direction Mode parameter is in allowed range.
|
||||
* @param __MODE__ specifies the SPI Direction Mode.
|
||||
* This parameter can be a value of @ref SPI_Direction
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_DIRECTION(__MODE__) (((__MODE__) == SPI_DIRECTION_2LINES) || \
|
||||
((__MODE__) == SPI_DIRECTION_2LINES_RXONLY) || \
|
||||
((__MODE__) == SPI_DIRECTION_1LINE))
|
||||
|
||||
/** @brief Checks if SPI Direction Mode parameter is 2 lines.
|
||||
* @param __MODE__ specifies the SPI Direction Mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_DIRECTION_2LINES(__MODE__) ((__MODE__) == SPI_DIRECTION_2LINES)
|
||||
|
||||
/** @brief Checks if SPI Direction Mode parameter is 1 or 2 lines.
|
||||
* @param __MODE__ specifies the SPI Direction Mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_DIRECTION_2LINES_OR_1LINE(__MODE__) (((__MODE__) == SPI_DIRECTION_2LINES) || \
|
||||
((__MODE__) == SPI_DIRECTION_1LINE))
|
||||
|
||||
/** @brief Checks if SPI Data Size parameter is in allowed range.
|
||||
* @param __DATASIZE__ specifies the SPI Data Size.
|
||||
* This parameter can be a value of @ref SPI_Data_Size
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_DATASIZE(__DATASIZE__) (((__DATASIZE__) == SPI_DATASIZE_16BIT) || \
|
||||
((__DATASIZE__) == SPI_DATASIZE_8BIT))
|
||||
|
||||
/** @brief Checks if SPI Serial clock steady state parameter is in allowed range.
|
||||
* @param __CPOL__ specifies the SPI serial clock steady state.
|
||||
* This parameter can be a value of @ref SPI_Clock_Polarity
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_CPOL(__CPOL__) (((__CPOL__) == SPI_POLARITY_LOW) || \
|
||||
((__CPOL__) == SPI_POLARITY_HIGH))
|
||||
|
||||
/** @brief Checks if SPI Clock Phase parameter is in allowed range.
|
||||
* @param __CPHA__ specifies the SPI Clock Phase.
|
||||
* This parameter can be a value of @ref SPI_Clock_Phase
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_CPHA(__CPHA__) (((__CPHA__) == SPI_PHASE_1EDGE) || \
|
||||
((__CPHA__) == SPI_PHASE_2EDGE))
|
||||
|
||||
/** @brief Checks if SPI Slave Select parameter is in allowed range.
|
||||
* @param __NSS__ specifies the SPI Slave Select management parameter.
|
||||
* This parameter can be a value of @ref SPI_Slave_Select_management
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_NSS(__NSS__) (((__NSS__) == SPI_NSS_SOFT) || \
|
||||
((__NSS__) == SPI_NSS_HARD_INPUT) || \
|
||||
((__NSS__) == SPI_NSS_HARD_OUTPUT))
|
||||
|
||||
/** @brief Checks if SPI Baudrate prescaler parameter is in allowed range.
|
||||
* @param __PRESCALER__ specifies the SPI Baudrate prescaler.
|
||||
* This parameter can be a value of @ref SPI_BaudRate_Prescaler
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_BAUDRATE_PRESCALER(__PRESCALER__) (((__PRESCALER__) == SPI_BAUDRATEPRESCALER_2) || \
|
||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_4) || \
|
||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_8) || \
|
||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_16) || \
|
||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_32) || \
|
||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_64) || \
|
||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_128) || \
|
||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_256))
|
||||
|
||||
/** @brief Checks if SPI MSB LSB transmission parameter is in allowed range.
|
||||
* @param __BIT__ specifies the SPI MSB LSB transmission (whether data transfer starts from MSB or LSB bit).
|
||||
* This parameter can be a value of @ref SPI_MSB_LSB_transmission
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_FIRST_BIT(__BIT__) (((__BIT__) == SPI_FIRSTBIT_MSB) || \
|
||||
((__BIT__) == SPI_FIRSTBIT_LSB))
|
||||
|
||||
/** @brief Checks if SPI TI mode parameter is disabled.
|
||||
* @param __MODE__ SPI_TIMODE_DISABLE. Device not support Ti Mode.
|
||||
* This parameter can be a value of @ref SPI_TI_mode
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_TIMODE(__MODE__) ((__MODE__) == SPI_TIMODE_DISABLE)
|
||||
|
||||
/** @brief Checks if SPI CRC calculation enabled state is in allowed range.
|
||||
* @param __CALCULATION__ specifies the SPI CRC calculation enable state.
|
||||
* This parameter can be a value of @ref SPI_CRC_Calculation
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_CRC_CALCULATION(__CALCULATION__) (((__CALCULATION__) == SPI_CRCCALCULATION_DISABLE) || \
|
||||
((__CALCULATION__) == SPI_CRCCALCULATION_ENABLE))
|
||||
|
||||
/** @brief Checks if SPI polynomial value to be used for the CRC calculation, is in allowed range.
|
||||
* @param __POLYNOMIAL__ specifies the SPI polynomial value to be used for the CRC calculation.
|
||||
* This parameter must be a number between Min_Data = 0 and Max_Data = 65535
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_CRC_POLYNOMIAL(__POLYNOMIAL__) (((__POLYNOMIAL__) >= 0x1U) && \
|
||||
((__POLYNOMIAL__) <= 0xFFFFU) && \
|
||||
(((__POLYNOMIAL__)&0x1U) != 0U))
|
||||
|
||||
/** @brief Checks if DMA handle is valid.
|
||||
* @param __HANDLE__ specifies a DMA Handle.
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_DMA_HANDLE(__HANDLE__) ((__HANDLE__) != NULL)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/** @defgroup SPI_Private_Functions SPI Private Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t SPI_ISCRCErrorValid(SPI_HandleTypeDef *hspi);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup SPI_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup SPI_Exported_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
/* Initialization/de-initialization functions ********************************/
|
||||
HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi);
|
||||
HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi);
|
||||
|
||||
/* Callbacks Register/UnRegister functions ***********************************/
|
||||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
||||
HAL_StatusTypeDef HAL_SPI_RegisterCallback(SPI_HandleTypeDef *hspi, HAL_SPI_CallbackIDTypeDef CallbackID,
|
||||
pSPI_CallbackTypeDef pCallback);
|
||||
HAL_StatusTypeDef HAL_SPI_UnRegisterCallback(SPI_HandleTypeDef *hspi, HAL_SPI_CallbackIDTypeDef CallbackID);
|
||||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup SPI_Exported_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
/* I/O operation functions ***************************************************/
|
||||
HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, const uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||
HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||
HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, const uint8_t *pTxData, uint8_t *pRxData,
|
||||
uint16_t Size, uint32_t Timeout);
|
||||
HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, const uint8_t *pData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, const uint8_t *pTxData, uint8_t *pRxData,
|
||||
uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, const uint8_t *pData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, const uint8_t *pTxData, uint8_t *pRxData,
|
||||
uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi);
|
||||
HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi);
|
||||
HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi);
|
||||
/* Transfer Abort functions */
|
||||
HAL_StatusTypeDef HAL_SPI_Abort(SPI_HandleTypeDef *hspi);
|
||||
HAL_StatusTypeDef HAL_SPI_Abort_IT(SPI_HandleTypeDef *hspi);
|
||||
|
||||
void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_TxHalfCpltCallback(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_RxHalfCpltCallback(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_TxRxHalfCpltCallback(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_AbortCpltCallback(SPI_HandleTypeDef *hspi);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup SPI_Exported_Functions_Group3
|
||||
* @{
|
||||
*/
|
||||
/* Peripheral State and Error functions ***************************************/
|
||||
HAL_SPI_StateTypeDef HAL_SPI_GetState(const SPI_HandleTypeDef *hspi);
|
||||
uint32_t HAL_SPI_GetError(const SPI_HandleTypeDef *hspi);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32F1xx_HAL_SPI_H */
|
||||
|
||||
1951
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_spi.h
Normal file
1951
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_spi.h
Normal file
File diff suppressed because it is too large
Load Diff
4025
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c
Normal file
4025
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -81,7 +81,7 @@
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<RunUserProg2>1</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
@@ -340,7 +340,7 @@
|
||||
<MiscControls></MiscControls>
|
||||
<Define>USE_HAL_DRIVER,STM32F103xB</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>../Core/Inc;../Drivers/STM32F1xx_HAL_Driver/Inc;../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy;../Drivers/CMSIS/Device/ST/STM32F1xx/Include;../Drivers/CMSIS/Include</IncludePath>
|
||||
<IncludePath>../Core/Inc;../Drivers/STM32F1xx_HAL_Driver/Inc;../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy;../Drivers/CMSIS/Device/ST/STM32F1xx/Include;../Drivers/CMSIS/Include;../Drivers/BSP/MultiButton;..\Drivers\BSP\LCD</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
@@ -404,6 +404,118 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../Core/Src/gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>dma.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../Core/Src/dma.c</FilePath>
|
||||
<FileOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>2</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>2</AlwaysBuild>
|
||||
<GenerateAssemblyFile>2</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>2</AssembleAssemblyFile>
|
||||
<PublicsOnly>2</PublicsOnly>
|
||||
<StopOnExitCode>11</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<FileArmAds>
|
||||
<Cads>
|
||||
<interw>2</interw>
|
||||
<Optim>0</Optim>
|
||||
<oTime>2</oTime>
|
||||
<SplitLS>2</SplitLS>
|
||||
<OneElfS>2</OneElfS>
|
||||
<Strict>2</Strict>
|
||||
<EnumInt>2</EnumInt>
|
||||
<PlainCh>2</PlainCh>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<wLevel>0</wLevel>
|
||||
<uThumb>2</uThumb>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<uC99>2</uC99>
|
||||
<uGnu>2</uGnu>
|
||||
<useXO>2</useXO>
|
||||
<v6Lang>0</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>2</vShortEn>
|
||||
<vShortWch>2</vShortWch>
|
||||
<v6Lto>2</v6Lto>
|
||||
<v6WtE>2</v6WtE>
|
||||
<v6Rtti>2</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
</FileArmAds>
|
||||
</FileOption>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>spi.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../Core/Src/spi.c</FilePath>
|
||||
<FileOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>2</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>2</AlwaysBuild>
|
||||
<GenerateAssemblyFile>2</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>2</AssembleAssemblyFile>
|
||||
<PublicsOnly>2</PublicsOnly>
|
||||
<StopOnExitCode>11</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<FileArmAds>
|
||||
<Cads>
|
||||
<interw>2</interw>
|
||||
<Optim>0</Optim>
|
||||
<oTime>2</oTime>
|
||||
<SplitLS>2</SplitLS>
|
||||
<OneElfS>2</OneElfS>
|
||||
<Strict>2</Strict>
|
||||
<EnumInt>2</EnumInt>
|
||||
<PlainCh>2</PlainCh>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<wLevel>0</wLevel>
|
||||
<uThumb>2</uThumb>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<uC99>2</uC99>
|
||||
<uGnu>2</uGnu>
|
||||
<useXO>2</useXO>
|
||||
<v6Lang>0</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>2</vShortEn>
|
||||
<vShortWch>2</vShortWch>
|
||||
<v6Lto>2</v6Lto>
|
||||
<v6WtE>2</v6WtE>
|
||||
<v6Rtti>2</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
</FileArmAds>
|
||||
</FileOption>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -430,9 +542,60 @@
|
||||
<FilePath>../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_uart.c</FileName>
|
||||
<FileName>stm32f1xx_hal_spi.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c</FilePath>
|
||||
<FilePath>../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c</FilePath>
|
||||
<FileOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>2</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>2</AlwaysBuild>
|
||||
<GenerateAssemblyFile>2</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>2</AssembleAssemblyFile>
|
||||
<PublicsOnly>2</PublicsOnly>
|
||||
<StopOnExitCode>11</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<FileArmAds>
|
||||
<Cads>
|
||||
<interw>2</interw>
|
||||
<Optim>0</Optim>
|
||||
<oTime>2</oTime>
|
||||
<SplitLS>2</SplitLS>
|
||||
<OneElfS>2</OneElfS>
|
||||
<Strict>2</Strict>
|
||||
<EnumInt>2</EnumInt>
|
||||
<PlainCh>2</PlainCh>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<wLevel>0</wLevel>
|
||||
<uThumb>2</uThumb>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<uC99>2</uC99>
|
||||
<uGnu>2</uGnu>
|
||||
<useXO>2</useXO>
|
||||
<v6Lang>0</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>2</vShortEn>
|
||||
<vShortWch>2</vShortWch>
|
||||
<v6Lto>2</v6Lto>
|
||||
<v6WtE>2</v6WtE>
|
||||
<v6Rtti>2</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
</FileArmAds>
|
||||
</FileOption>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal.c</FileName>
|
||||
@@ -484,6 +647,11 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
@@ -496,6 +664,31 @@
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Drivers/BSP</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>lcd_data.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Drivers\BSP\LCD\lcd_data.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>st7735s.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Drivers\BSP\LCD\st7735s.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>button_driver.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Drivers\BSP\MultiButton\button_driver.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>multi_button.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Drivers\BSP\MultiButton\multi_button.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
</Group>
|
||||
@@ -516,4 +709,13 @@
|
||||
<files/>
|
||||
</RTE>
|
||||
|
||||
<LayerInfo>
|
||||
<Layers>
|
||||
<Layer>
|
||||
<LayName>STM32F103C8T6</LayName>
|
||||
<LayPrjMark>1</LayPrjMark>
|
||||
</Layer>
|
||||
</Layers>
|
||||
</LayerInfo>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
"stm32f103c8t6\startup_stm32f103xb.o"
|
||||
"stm32f103c8t6\main.o"
|
||||
"stm32f103c8t6\gpio.o"
|
||||
"stm32f103c8t6\dma.o"
|
||||
"stm32f103c8t6\spi.o"
|
||||
"stm32f103c8t6\usart.o"
|
||||
"stm32f103c8t6\stm32f1xx_it.o"
|
||||
"stm32f103c8t6\stm32f1xx_hal_msp.o"
|
||||
"stm32f103c8t6\stm32f1xx_hal_gpio_ex.o"
|
||||
"stm32f103c8t6\stm32f1xx_hal_uart.o"
|
||||
"stm32f103c8t6\stm32f1xx_hal_spi.o"
|
||||
"stm32f103c8t6\stm32f1xx_hal.o"
|
||||
"stm32f103c8t6\stm32f1xx_hal_rcc.o"
|
||||
"stm32f103c8t6\stm32f1xx_hal_rcc_ex.o"
|
||||
@@ -17,7 +19,12 @@
|
||||
"stm32f103c8t6\stm32f1xx_hal_flash.o"
|
||||
"stm32f103c8t6\stm32f1xx_hal_flash_ex.o"
|
||||
"stm32f103c8t6\stm32f1xx_hal_exti.o"
|
||||
"stm32f103c8t6\stm32f1xx_hal_uart.o"
|
||||
"stm32f103c8t6\system_stm32f1xx.o"
|
||||
"stm32f103c8t6\lcd_data.o"
|
||||
"stm32f103c8t6\st7735s_1.o"
|
||||
"stm32f103c8t6\button_driver_1.o"
|
||||
"stm32f103c8t6\multi_button_1.o"
|
||||
--library_type=microlib --strict --scatter "STM32F103C8T6\STM32F103C8T6.sct"
|
||||
--summary_stderr --info summarysizes --map --load_addr_map_info --xref --callgraph --symbols
|
||||
--info sizes --info totals --info unused --info veneers
|
||||
|
||||
BIN
STM32F103C8T6/MDK-ARM/STM32F103C8T6/button_driver_1.crf
Normal file
BIN
STM32F103C8T6/MDK-ARM/STM32F103C8T6/button_driver_1.crf
Normal file
Binary file not shown.
BIN
STM32F103C8T6/MDK-ARM/STM32F103C8T6/dma.crf
Normal file
BIN
STM32F103C8T6/MDK-ARM/STM32F103C8T6/dma.crf
Normal file
Binary file not shown.
Binary file not shown.
BIN
STM32F103C8T6/MDK-ARM/STM32F103C8T6/lcd_data.crf
Normal file
BIN
STM32F103C8T6/MDK-ARM/STM32F103C8T6/lcd_data.crf
Normal file
Binary file not shown.
Binary file not shown.
BIN
STM32F103C8T6/MDK-ARM/STM32F103C8T6/multi_button_1.crf
Normal file
BIN
STM32F103C8T6/MDK-ARM/STM32F103C8T6/multi_button_1.crf
Normal file
Binary file not shown.
BIN
STM32F103C8T6/MDK-ARM/STM32F103C8T6/spi.crf
Normal file
BIN
STM32F103C8T6/MDK-ARM/STM32F103C8T6/spi.crf
Normal file
Binary file not shown.
BIN
STM32F103C8T6/MDK-ARM/STM32F103C8T6/st7735s_1.crf
Normal file
BIN
STM32F103C8T6/MDK-ARM/STM32F103C8T6/st7735s_1.crf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
STM32F103C8T6/MDK-ARM/STM32F103C8T6/stm32f1xx_hal_spi.crf
Normal file
BIN
STM32F103C8T6/MDK-ARM/STM32F103C8T6/stm32f1xx_hal_spi.crf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,41 +2,57 @@
|
||||
CAD.formats=
|
||||
CAD.pinconfig=
|
||||
CAD.provider=
|
||||
Dma.Request0=SPI2_TX
|
||||
Dma.RequestsNb=1
|
||||
Dma.SPI2_TX.0.Direction=DMA_MEMORY_TO_PERIPH
|
||||
Dma.SPI2_TX.0.Instance=DMA1_Channel5
|
||||
Dma.SPI2_TX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.SPI2_TX.0.MemInc=DMA_MINC_ENABLE
|
||||
Dma.SPI2_TX.0.Mode=DMA_NORMAL
|
||||
Dma.SPI2_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.SPI2_TX.0.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.SPI2_TX.0.Priority=DMA_PRIORITY_LOW
|
||||
Dma.SPI2_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
|
||||
File.Version=6
|
||||
GPIO.groupedBy=Group By Peripherals
|
||||
KeepUserPlacement=false
|
||||
Mcu.CPN=STM32F103C8T6
|
||||
Mcu.Family=STM32F1
|
||||
Mcu.IP0=NVIC
|
||||
Mcu.IP1=RCC
|
||||
Mcu.IP2=SYS
|
||||
Mcu.IP3=USART1
|
||||
Mcu.IPNb=4
|
||||
Mcu.IP0=DMA
|
||||
Mcu.IP1=NVIC
|
||||
Mcu.IP2=RCC
|
||||
Mcu.IP3=SPI2
|
||||
Mcu.IP4=SYS
|
||||
Mcu.IP5=USART1
|
||||
Mcu.IPNb=6
|
||||
Mcu.Name=STM32F103C(8-B)Tx
|
||||
Mcu.Package=LQFP48
|
||||
Mcu.Pin0=PC13-TAMPER-RTC
|
||||
Mcu.Pin1=PC14-OSC32_IN
|
||||
Mcu.Pin10=PA13
|
||||
Mcu.Pin11=PA14
|
||||
Mcu.Pin12=PB3
|
||||
Mcu.Pin13=PB4
|
||||
Mcu.Pin14=PB5
|
||||
Mcu.Pin15=VP_SYS_VS_Systick
|
||||
Mcu.Pin10=PA9
|
||||
Mcu.Pin11=PA10
|
||||
Mcu.Pin12=PA13
|
||||
Mcu.Pin13=PA14
|
||||
Mcu.Pin14=PB3
|
||||
Mcu.Pin15=PB4
|
||||
Mcu.Pin16=PB5
|
||||
Mcu.Pin17=VP_SYS_VS_Systick
|
||||
Mcu.Pin2=PC15-OSC32_OUT
|
||||
Mcu.Pin3=PD0-OSC_IN
|
||||
Mcu.Pin4=PD1-OSC_OUT
|
||||
Mcu.Pin5=PB12
|
||||
Mcu.Pin6=PB13
|
||||
Mcu.Pin7=PB15
|
||||
Mcu.Pin8=PA9
|
||||
Mcu.Pin9=PA10
|
||||
Mcu.PinsNb=16
|
||||
Mcu.Pin5=PB10
|
||||
Mcu.Pin6=PB11
|
||||
Mcu.Pin7=PB12
|
||||
Mcu.Pin8=PB13
|
||||
Mcu.Pin9=PB15
|
||||
Mcu.PinsNb=18
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32F103C8Tx
|
||||
MxCube.Version=6.17.0
|
||||
MxDb.Version=DB.6.0.170
|
||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.DMA1_Channel5_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
|
||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.ForceEnableDMAVector=true
|
||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
@@ -55,24 +71,31 @@ PA14.Mode=Serial_Wire
|
||||
PA14.Signal=SYS_JTCK-SWCLK
|
||||
PA9.Mode=Asynchronous
|
||||
PA9.Signal=USART1_TX
|
||||
PB10.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label
|
||||
PB10.GPIO_Label=LCD_DC
|
||||
PB10.GPIO_PuPd=GPIO_PULLUP
|
||||
PB10.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||
PB10.Locked=true
|
||||
PB10.Signal=GPIO_Output
|
||||
PB11.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label
|
||||
PB11.GPIO_Label=LCD_CS
|
||||
PB11.GPIO_PuPd=GPIO_PULLUP
|
||||
PB11.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||
PB11.Locked=true
|
||||
PB11.PinState=GPIO_PIN_RESET
|
||||
PB11.Signal=GPIO_Output
|
||||
PB12.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label
|
||||
PB12.GPIO_Label=LCD_RST
|
||||
PB12.GPIO_PuPd=GPIO_PULLUP
|
||||
PB12.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||
PB12.Locked=true
|
||||
PB12.Signal=GPIO_Output
|
||||
PB13.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label
|
||||
PB13.GPIO_Label=LCD_SCL
|
||||
PB13.GPIO_PuPd=GPIO_PULLUP
|
||||
PB13.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||
PB13.Locked=true
|
||||
PB13.Signal=GPIO_Output
|
||||
PB15.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label
|
||||
PB15.GPIO_Label=LCD_SDA
|
||||
PB15.GPIO_PuPd=GPIO_PULLUP
|
||||
PB15.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||
PB13.Mode=TX_Only_Simplex_Unidirect_Master
|
||||
PB13.Signal=SPI2_SCK
|
||||
PB15.Locked=true
|
||||
PB15.Signal=GPIO_Output
|
||||
PB15.Mode=TX_Only_Simplex_Unidirect_Master
|
||||
PB15.Signal=SPI2_MOSI
|
||||
PB3.GPIOParameters=GPIO_PuPd,GPIO_Label
|
||||
PB3.GPIO_Label=KEY3
|
||||
PB3.GPIO_PuPd=GPIO_PULLDOWN
|
||||
@@ -150,7 +173,7 @@ ProjectManager.ToolChainLocation=
|
||||
ProjectManager.UAScriptAfterPath=
|
||||
ProjectManager.UAScriptBeforePath=
|
||||
ProjectManager.UnderRoot=false
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_USART1_UART_Init-USART1-false-HAL-true
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_SPI2_Init-SPI2-false-HAL-true
|
||||
RCC.ADCFreqValue=36000000
|
||||
RCC.AHBFreq_Value=72000000
|
||||
RCC.APB1CLKDivider=RCC_HCLK_DIV2
|
||||
@@ -172,6 +195,12 @@ RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
|
||||
RCC.TimSysFreq_Value=72000000
|
||||
RCC.USBFreq_Value=72000000
|
||||
RCC.VCOOutput2Freq_Value=8000000
|
||||
SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2
|
||||
SPI2.CalculateBaudRate=18.0 MBits/s
|
||||
SPI2.Direction=SPI_DIRECTION_2LINES
|
||||
SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler
|
||||
SPI2.Mode=SPI_MODE_MASTER
|
||||
SPI2.VirtualType=VM_MASTER
|
||||
USART1.IPParameters=VirtualMode
|
||||
USART1.VirtualMode=VM_ASYNC
|
||||
VP_SYS_VS_Systick.Mode=SysTick
|
||||
|
||||
Reference in New Issue
Block a user