📄 main.c
字号:
// 基于LM3S驱动库的Stellaris系列单片机GPIO演示程序
// 包含必要的头文件
#include <hw_types.h>
#include <hw_memmap.h>
#include <hw_sysctl.h>
#include <hw_ints.h>
#include <interrupt.h>
#include <hw_gpio.h>
#include <sysctl.h>
#include <gpio.h>
#include "lcd.h"
// 定义按键
#define KEY_PORT SYSCTL_PERIPH_GPIOB
#define KEY_PIN GPIO_PORTB_BASE , GPIO_PIN_5
#define KeyGet() GPIOPinRead(KEY_PIN)
#define KEY3 GPIO_PIN_4 /* 定义KEY3的引脚PB4 */
extern uchar ucCol; // Col = x (0-127),
extern uchar ucRow; // Row = y (0-7)
extern uchar Base;
extern uchar xy; // 画线方向标志:1 = 水平 0 = 垂直
extern const uchar _Chinese_1[];
extern const uchar _Chinese_2[];
uchar STR1[]=" Hello World ";
/**********************************************************************************************/
// 防止JTAG失效
void WaitJTAG(void)
{
SysCtlPeripheralEnable(KEY_PORT); // 使能按键所在的GPIO端*/
GPIOPinTypeGPIOInput(KEY_PIN); // 设置按键所在管脚为输入
if ( KeyGet() == 0x00 ) // 如果有键按下,则进入
{
for (;;); // 死循环,以等待JTAG连接
}
SysCtlPeripheralDisable(KEY_PORT); // 禁止按键所在的GPIO端口
}
/*************************************************************************************************/
void Delay(unsigned long t)
{
while(--t);
}
/************************************************************************************************/
int main(void)
{
WaitJTAG(); // 防止JTAG失效,重要!
// SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_OSC_MAIN |
// SYSCTL_USE_PLL | SYSCTL_XTAL_6MHZ); // LCD程序在50M的速度下也能使用
/************************************ example ***********************************************/
LCD_PinConfig(); // LCD接口管脚配置
LCD_Init(); // LCD 初始化
LCD_Cls(); // LCD 清屏
ucCol=0; // 显示字符串的位置 uCCol 行
ucRow=0; // ucRow 列
Base=0;
PutEnStr(STR1,16); // 英文输出函数 字符的个数 英文最大16 中文最大8个
ucCol=0;
ucRow=2;
PutEnStr(" Author X ",16);
ucCol=32;
ucRow=4;
PutChStr(_Chinese_1,4); // 中文输出函数
ucCol=48;
ucRow=6;
PutChStr(_Chinese_2,2);
ucCol=0;
ucRow=0;
xy=0; // draw vertical line
LineTo(64);
ucCol=0;
ucRow=0;
xy=1; // draw horizontal line
LineTo(128);
ucCol=127;
ucRow=0;
xy=0; // draw vertical line
LineTo(64);
ucCol=0;
ucRow=63;
xy=1; // draw horizontal line
LineTo(128);
/**********************************************************************************************/
while (1)
{
Rollscreen(Base++); /* 向上滚屏显示 */
Delay(1000000);
}
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -