使用STM32F103RCT6开发板实现定时器闪烁LED以及1.8寸SPI驱动的TFT屏幕,显示菜单,按键KEY1切换画面。
各位如有需要可根据原理图进行设计,或改变引脚配置进行移植
单片机源程序如下:
- //C Header File
- #include <stdio.h>
- //Peripheral Header File
- #include "delay.h"
- #include "timer.h"
- #include "usart.h"
- //Hardware Header File
- #include "led.h"
- #include "beep.h"
- #include "key.h"
- #include "lcd.h"
- #include "picture.h"
- //Software Header File
- uint16_t LED1 = 0;
- int main(void)
- {
- delay_Init();
- LCD_Init();
- LCD_Fill(0, 0, LCD_W, LCD_H, WHITE);
- Usart1_Inital(9600);
- LED_Inital();
- BEEP_Inital();
- KEY_Inital();
- TIM2_Config(7199, 9999);
- TIM3_Config(7199, 4999);
-
- while (1)
- {
- switch (KEY_Scan(1)) {
- case (1): Usart_SendString(USART1, "KEY1\r\n");
- LED1 = !LED1;
- LCD_Fill(0, 0, LCD_W, LCD_H, WHITE);
- break;
- }
- if (!LED1) {
- LED1_OFF;
- LCD_ShowPicture(12, 40, 40, 40, gImage_QQ);
- LCD_ShowString(28, 80, "QQ", BLACK, WHITE, 12, 0);
- LCD_ShowPicture(76, 40, 40, 40, gImage_We);
- LCD_ShowString(78, 80, "We", BLACK, WHITE, 12, 0);
- LCD_ShowPicture(12, 100, 40, 40, gImage_Game);
- LCD_ShowString(18, 140, "Games", BLACK, WHITE, 12, 0);
- LCD_ShowPicture(76, 100, 40, 40, gImage_Setting);
- LCD_ShowString(76, 140, "Setting", BLACK, WHITE, 12, 0);
- } else {
- LED1_ON;
- LCD_ShowPicture(24, 40, 80, 80, gImage_YunQy);
- }
- }
- }
复制代码 Keil代码下载:
STM32F103RCT6.7z
(206.47 KB, 下载次数: 60)
|