📄 gpio_in.c
字号:
/*
\\\|///
\\ - - //
( @ @ )
+---------------------oOOo-(_)-oOOo-------------------------+
| 智林STM32开发板试验程序 |
| Timer2 PWM 输出方式试验 |
| 刘笑然 by Xiaoran Liu |
| 2008.4.16 |
| |
| 智林测控技术研究所 ZERO research group |
| www.the0.net |
| Oooo |
+-----------------------oooO--( )-------------------------+
( ) ) /
\ ( (_/
\_)
*/
/*----------------------------------------------------------*\
| 引入相关芯片的头文件 |
\*----------------------------------------------------------*/
#include <stm32f10x_lib.h> // STM32F10x Library Definitions
#include "STM32_Init.h" // STM32 Initialization
#include "TFT018.h"
/*----------------------------------------------------------*\
| HARDWARE DEFINE |
\*----------------------------------------------------------*/
#define LED ( 1 << 5 ) // PB5: LED D2
#define BP2 0x2000 // PC13: BP2
#define BP3 0x0001 // PA0 : BP3
#define UP 0x0800 // PB11: UP
#define RIGHT 0x1000 // PB12: RIGHT
#define LEFT 0x2000 // PB13: LEFT
#define DOWN 0x4000 // PB14: DOWN
#define OK 0x8000 // PB15: OK
#define JOYSTICK 0xF800 // JOYSTICK ALL KEYS
/*----------------------------------------------------------*\
| SOFTWARE DATA |
\*----------------------------------------------------------*/
/*----------------------------------------------------------*\
| Delay |
| 延时 Inserts a delay time. |
| nCount: 延时时间 |
| nCount: specifies the delay time length. |
\*----------------------------------------------------------*/
void Delay(vu32 nCount) {
for(; nCount != 0; nCount--);
}
/*----------------------------------------------------------*\
| MIAN ENTRY |
\*----------------------------------------------------------*/
int main (void) {
stm32_Init (); // STM32 setup
LCD_Init();
LCD_Clear_Screen(Blue);
for(;;) {
Font = 0;
LCD_PutString(30,0,"STM32F 开发板",Cyan,Blue);
LCD_PutString(30,16,"GPIO 输入演示",Red,Yellow);
Font = 1;
LCD_PutString(38,32,"Version 1.0",Green,Blue);
Font = 0;
LCD_PutString(10,94,"智林测控技术研究所",Yellow,Blue);
LCD_PutString(36,111,"www.the0.net",Magenta,Blue);
if (((GPIOB->IDR & JOYSTICK) == JOYSTICK )) { // Check if JOYSTICK key is pressed
GPIOB->ODR &= ~LED; // switch off LED
}
else { // JOYSTICK key is pressed
GPIOB->ODR |= LED; // switch on LED
}
if (((GPIOB->IDR & UP) == 0 )) // Check if UP is pressed
LCD_PutString(48,40,"上",Yellow,Red);
else
LCD_PutString(48,40,"上",Red,Yellow);
if (((GPIOB->IDR & DOWN) == 0 )) // Check if DOWN is pressed
LCD_PutString(48,76,"下",Yellow,Red);
else
LCD_PutString(48,76,"下",Red,Yellow);
if (((GPIOB->IDR & LEFT) == 0 )) // Check if LEFT is pressed
LCD_PutString(30,58,"左",Yellow,Red);
else
LCD_PutString(30,58,"左",Red,Yellow);
if (((GPIOB->IDR & RIGHT) == 0 )) // Check if RIGHT is pressed
LCD_PutString(66,58,"右",Yellow,Red);
else
LCD_PutString(66,58,"右",Red,Yellow);
if (((GPIOB->IDR & OK) == 0 )) // Check if OK is pressed
LCD_PutString(48,58,"OK",Yellow,Red);
else
LCD_PutString(48,58,"OK",Red,Yellow);
if (((GPIOC->IDR & BP2) == 0 )) // Check if BP2 is not pressed
LCD_PutString(100,40,"BP2",Yellow,Red);
else
LCD_PutString(100,40,"BP2",Red,Yellow);
if (((GPIOA->IDR & BP3) == 0 )) // Check if BP3 is not pressed
LCD_PutString(100,76,"BP3",Yellow,Red);
else
LCD_PutString(100,76,"BP3",Red,Yellow);
}
}
/*----------------------------------------------------------*\
| END OF FILE |
\*----------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -