NOKIA5110参考程序.docx

上传人:b****7 文档编号:9666496 上传时间:2023-02-05 格式:DOCX 页数:40 大小:25.33KB
下载 相关 举报
NOKIA5110参考程序.docx_第1页
第1页 / 共40页
NOKIA5110参考程序.docx_第2页
第2页 / 共40页
NOKIA5110参考程序.docx_第3页
第3页 / 共40页
NOKIA5110参考程序.docx_第4页
第4页 / 共40页
NOKIA5110参考程序.docx_第5页
第5页 / 共40页
点击查看更多>>
下载资源
资源描述

NOKIA5110参考程序.docx

《NOKIA5110参考程序.docx》由会员分享,可在线阅读,更多相关《NOKIA5110参考程序.docx(40页珍藏版)》请在冰豆网上搜索。

NOKIA5110参考程序.docx

NOKIA5110参考程序

//说明:

以下函数在STM32F405RGT6上验证过,应用于其他条件下根据自身需要做移植

//nokia5110.h

//*********************nokia5110.h*********************//

//串行线协议,并非I2c总线协议,可达4MHz

//84*4814*6个6*8字符左上角为(0,0)纵向六个字节,可水平会垂直寻址

//高位在下面,先写入高位工作电压2.7V~3.3V六根线控制背光线可省

//*********************nokia5110.h*********************//

#include"stm32f4xx.h"

//*****************调试函数启用****************//

//#defineNokia5110_debug1

#ifdefNokia5110_debug

voidNokia5110_dbg(void);

#endif

//*********************IO引脚定义*********************

//Nokia5110:

PC0-RSTCS-PC1DC-PC2Din-PC3PA0-CLKPA1-BL

//注:

要对IO进行设置,设置在其他文件中,为包含在本WORD文档中

//液晶背光控制

#definelcd_lbg_1GPIOA->BSRRL=GPIO_Pin_1//背光高电平亮

#definelcd_lbg_0GPIOA->BSRRH=GPIO_Pin_1//背光低电平灭

#definelcd_rst_1GPIOC->BSRRL=GPIO_Pin_0//复位,0复位

#definelcd_ce_1GPIOC->BSRRL=GPIO_Pin_1//片选端口

#definelcd_dc_1GPIOC->BSRRL=GPIO_Pin_2//数据1/指令0

#definelcd_da_1GPIOC->BSRRL=GPIO_Pin_3//数据

#definelcd_clk_1GPIOA->BSRRL=GPIO_Pin_0//时钟(4Mhz)

#definelcd_rst_0GPIOC->BSRRH=GPIO_Pin_0//复位,0复位

#definelcd_ce_0GPIOC->BSRRH=GPIO_Pin_1//片选端口

#definelcd_dc_0GPIOC->BSRRH=GPIO_Pin_2//数据1/指令0

#definelcd_da_0GPIOC->BSRRH=GPIO_Pin_3//数据

#definelcd_clk_0GPIOA->BSRRH=GPIO_Pin_0//时钟(4Mhz)

//*********************IO引脚定义*********************

//*********************nokia5110命令定义*********************

#definekongbai0x08//显示空白

#definezhengchang0x0c//显示正常

#definequanxian0x09//全部显示

#definefanzhuan0x0d//显示反转

#definepd_h_kz0x80;//显示空白

//*********************nokia5110命令定义*********************

//***********************字库定义声明************************

//6x8ascii码,0x10--0x1f可以自定义

externconstu8font6x8[128][6];

//8*16数字字母字小写asc码-0x57

externconstu8font8x16[36][16];

//0_哈//1_尔//2_滨//3_工//4_程//5_大//6_学//7_图//8_书//9_馆

externconstu8hanzi[10][32];

//数据水平字节垂直,40*40qq图片

externconstu8Image_QQ[200];

//*********************字库定义声明************************

//***********************函数声明**************************

//写入的数据

voidlcdwrdat(u8dat);

//连续写入的数据,*s为字符数组或字符串ascii码

voidlcdwrcom(u8com);

voidlcdclear(void);//清屏

//lcd反清屏函数

voidlcdall(void);

//5110lcd初始化函数上电100ms内完成

voidlcd_init(void);

//**0<=x<=83,0<=y<=47,设置坐标

voidlcd_set_xy(u8x,u8y);

//**0<=x<=13,0<=y<=5,写一个字符dat为asc码

voidlcddispone(u8x,u8y,u8dat);

//**0<=x<=13,0<=y<=5,写字符串*s字符串或字符数组,num为数据长度

voidlcddispmore(u8x,u8y,u8num,u8*s);

//**0<=x<=13,0<=y<=5,写字符串*s字符串或字符数组

voidlcddispstr(u8x,u8y,u8*s);

//**0<=x<=9,0<=y<=5,写8x16数字或小写字母

voidlcd_write_shu(u8x,u8y,u8dat);

//**0<=x<=9,0<=y<=5,写16x16汉字index为汉字编号如0_哈

voidlcd_write_hanzi(u8x,u8y,u8index);

//**0<=x<=83,0<=y<=5,显示图片,width为宽度,hight为高度自动除8如40*40

voidlcddispimage(u8x,u8y,u8*s,u8width,u8hight);

//显示10位数占用11位

voiddisp_long(u8x,u8y,longdat);

//有符号数显示,占6位

voiddisp_s16(u8x,u8y,s16dat);

//8位无符号数显示,占3位

voiddisp_u8(u8x,u8y,u8dat);

//8位数HEX码显示,占2位

voiddisp_hex(u8x,u8y,u8dat);

//16位数HEX码显示,占4位

voiddisp_hex2(u8x,u8y,u16dat);

//32位数HEX码显示,占8位

voiddisp_hex4(u8x,u8y,u32dat);

//***********************函数声明**************************

/*函数调用示例

lcd_lbg_1;//开背光

lcd_init();//初始化lcd模块

lcdclear();//清屏幕

for(i=0;i<2;i++)

for(j=0;j<5;j++)

lcd_write_hanzi(j,i,j*5+i);

lcddispmore(0,4,6,"shgued");

lcddispmore(0,5,6,"shgued");

lcddispone(6,4,0x30);

lcddispone(7,4,'1');

lcddispone(6,5,0x32);

lcddispone(7,5,'3');

lcd_write_shu(6,5,'4');

lcd_write_shu(9,5,'9');

delay(2000);

lcdclear();//清屏幕

lcddispimage(10,1,(u8*)Image_QQ,40,40);//?

?

u8*

*/

//Nokia5110.c

//*********************Nokia5110.c*********************//

//串行线协议,并非I2c总线协议,可达4MHz(实际上上可以比这快,自己验证下,改变下面系统频率)

//84*4814*6个6*8字符左上角为(0,0)纵向六个字节,可水平会垂直寻址

//高位在下面,先写入高位工作电压2.7V~3.3V六根线控制背光线可省

//*********************Nokia5110.c*********************//

#include"stm32f4xx.h"

#include"Nokia5110.h"

#definelcd_adress_check1//地址范围检验功能启用

//Nokia5110延时,系统频率定义!

!

根据需要设置

//#definecpuclk_84Mhz

//#definecpuclk_72Mhz

//#definecpuclk_144Mhz

//#definecpuclk_168Mhz

//#definecpuclk_48Mhz

//#definecpuclk_24Mhz

#definecpuclk_16Mhz

//72Mhz16*(n+1)个nop

//#definedelay_4Mhzfor(lcd_cnt=0;lcd_cnt<3;lcd_cnt++)//0.125us

//72Mhz9clk4Mhz*2

#ifdefcpuclk_84Mhz

#definedelay_4Mhz__asm("nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop")

#elifdefinedcpuclk_72Mhz

#definedelay_4Mhz__asm("nop;nop;nop;nop;nop;nop;nop;nop;nop")

#elifdefinedcpuclk_144Mhz

#definedelay_4Mhz__asm("nop;nop;nop;nop;nop;nop;nop;nop;nop");__asm("nop;nop;nop;nop;nop;nop;nop;nop;nop")

#elifdefinedcpuclk_168Mhz

#definedelay_4Mhz__asm("nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop");__asm("nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop");__asm("nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop")

#elifdefinedcpuclk_48Mhz

#definedelay_4Mhz__asm("nop;nop;nop;nop;nop;nop")

#elifdefinedcpuclk_24Mhz

#definedelay_4Mhz__asm("nop;nop;nop")

#elifdefinedcpuclk_16Mhz

#definedelay_4Mhz__asm("nop;nop")

#else

#definedelay_4Mhz__asm("nop")

#endif

//6x8ascii码,0x10--0x1f可以自定义

//右上5*7字节倒序高位在下

constu8font6x8[128][6]=

{

{0x00,0x3E,0x51,0x49,0x45,0x3E},//0x00//0?

?

{0x00,0x00,0x42,0x7F,0x40,0x00},//0x01//1

{0x00,0x42,0x61,0x51,0x49,0x46},//0x02//2

{0x00,0x21,0x41,0x45,0x4B,0x31},//0x03//3

{0x00,0x18,0x14,0x12,0x7F,0x10},//0x04//4

{0x00,0x27,0x45,0x45,0x45,0x39},//0x05//5

{0x00,0x3C,0x4A,0x49,0x49,0x30},//0x06//6

{0x00,0x01,0x71,0x09,0x05,0x03},//0x07//7

{0x00,0x36,0x49,0x49,0x49,0x36},//0x08//8

{0x00,0x06,0x49,0x49,0x29,0x1E},//0x09//9

{0x00,0x14,0x08,0x3E,0x08,0x14},//0x0a//*

{0x00,0x08,0x08,0x3E,0x08,0x08},//0x0b//+

{0x00,0x00,0x00,0xA0,0x60,0x00},//0x0c//,

{0x00,0x08,0x08,0x08,0x08,0x08},//0x0d//-

{0x00,0x00,0x60,0x60,0x00,0x00},//0x0e//.

{0x00,0x20,0x10,0x08,0x04,0x02},//0x0f///

{0x00,0x00,0x00,0x00,0x00,0x00},//0x10//sp

{0x00,0x00,0x00,0x2f,0x00,0x00},//0x11//!

{0x00,0x00,0x07,0x00,0x07,0x00},//0x12//"

{0x00,0x14,0x7f,0x14,0x7f,0x14},//0x13//#

{0x00,0x24,0x2a,0x7f,0x2a,0x12},//0x14//$

{0x00,0x23,0x13,0x08,0x64,0x62},//0x15//%?

{0x00,0x36,0x49,0x55,0x22,0x50},//0x16//&

{0x00,0x00,0x05,0x03,0x00,0x00},//0x17//'

{0x00,0x00,0x1c,0x22,0x41,0x00},//0x18//(

{0x00,0x00,0x41,0x22,0x1c,0x00},//0x19//)

{0x00,0x14,0x08,0x3E,0x08,0x14},//0x1a//*

{0x00,0x08,0x08,0x3E,0x08,0x08},//0x1b//+

{0x00,0x00,0x00,0xA0,0x60,0x00},//0x1c//,

{0x00,0x08,0x08,0x08,0x08,0x08},//0x1d//-

{0x00,0x00,0x60,0x60,0x00,0x00},//0x1e//.

{0x00,0x20,0x10,0x08,0x04,0x02},//0x1f///?

?

{0x00,0x00,0x00,0x00,0x00,0x00},//0x20//sp

{0x00,0x00,0x00,0x2f,0x00,0x00},//0x21//!

{0x00,0x00,0x07,0x00,0x07,0x00},//0x22//"

{0x00,0x14,0x7f,0x14,0x7f,0x14},//0x23//#

{0x00,0x24,0x2a,0x7f,0x2a,0x12},//0x24//$

{0x00,0x23,0x13,0x08,0x64,0x62},//0x25//%

{0x00,0x36,0x49,0x55,0x22,0x50},//0x26//&

{0x00,0x04,0x08,0x10,0x20,0x40},//0x27//\换行

{0x00,0x00,0x1c,0x22,0x41,0x00},//0x28//(

{0x00,0x00,0x41,0x22,0x1c,0x00},//0x29//)

{0x00,0x14,0x08,0x3E,0x08,0x14},//0x2a//*

{0x00,0x08,0x08,0x3E,0x08,0x08},//0x2b//+

{0x00,0x00,0x00,0xA0,0x60,0x00},//0x2c//,

{0x00,0x08,0x08,0x08,0x08,0x08},//0x2d//-

{0x00,0x00,0x60,0x60,0x00,0x00},//0x2e//.

{0x00,0x20,0x10,0x08,0x04,0x02},//0x2f///

{0x00,0x3E,0x51,0x49,0x45,0x3E},//0x30//0

{0x00,0x00,0x42,0x7F,0x40,0x00},//0x31//1

{0x00,0x42,0x61,0x51,0x49,0x46},//0x32//2

{0x00,0x21,0x41,0x45,0x4B,0x31},//0x33//3

{0x00,0x18,0x14,0x12,0x7F,0x10},//0x34//4

{0x00,0x27,0x45,0x45,0x45,0x39},//0x35//5

{0x00,0x3C,0x4A,0x49,0x49,0x30},//0x36//6

{0x00,0x01,0x71,0x09,0x05,0x03},//0x37//7

{0x00,0x36,0x49,0x49,0x49,0x36},//0x38//8

{0x00,0x06,0x49,0x49,0x29,0x1E},//0x39//9

{0x00,0x00,0x36,0x36,0x00,0x00},//0x3a//:

{0x00,0x00,0x56,0x36,0x00,0x00},//0x3b//;

{0x00,0x08,0x14,0x22,0x41,0x00},//0x3c//<

{0x00,0x14,0x14,0x14,0x14,0x14},//0x3d//=

{0x00,0x00,0x41,0x22,0x14,0x08},//0x3e//>

{0x00,0x02,0x01,0x51,0x09,0x06},//0x3f//?

{0x00,0x32,0x49,0x59,0x51,0x3E},//0x40//@

{0x00,0x7C,0x12,0x11,0x12,0x7C},//0x41//A

{0x00,0x7F,0x49,0x49,0x49,0x36},//0x42//B

{0x00,0x3E,0x41,0x41,0x41,0x22},//0x43//C

{0x00,0x7F,0x41,0x41,0x22,0x1C},//0x44//D

{0x00,0x7F,0x49,0x49,0x49,0x41},//0x45//E

{0x00,0x7F,0x09,0x09,0x09,0x01},//0x46//F

{0x00,0x3E,0x41,0x49,0x49,0x7A},//0x47//G

{0x00,0x7F,0x08,0x08,0x08,0x7F},//0x48//H

{0x00,0x00,0x41,0x7F,0x41,0x00},//0x49//I

{0x00,0x20,0x40,0x41,0x3F,0x01},//0x4a//J

{0x00,0x7F,0x08,0x14,0x22,0x41},//0x4b//K

{0x00,0x7F,0x40,0x40,0x40,0x40},//0x4c//L

{0x00,0x7F,0x02,0x0C,0x02,0x7F},//0x4d//M

{0x00,0x7F,0x04,0x08,0x10,0x7F},//0x4e//N

{0x00,0x3E,0x41,0x41,0x41,0x3E},//0x4f//O

{0x00,0x7F,0x09,0x09,0x09,0x06},//0x50//P

{0x00,0x3E,0x41,0x51,0x21,0x5E},//0x51//Q

{0x00,0x7F,0x09,0x19,0x29,0x46},//0x52//R

{0x00,0x46,0x49,0x49,0x49,0x31},//0x53//S

{0x00,0x01,0x01,0x7F,0x01,0x01},//0x54//T

{0x00,0x3F,0x40,0x40,0x40,0x3F},//0x55//U

{0x00,0x1F,0x20,0x40,0x20,0x1F},//0x56//V

{0x00,0x3F,0x40,0x38,0x40,0x3F},//0x57//W

{0x00,0x63,0x14,0x08,0x14,0x63},//0x58//X

{0x00,0x07,0x08,0x70,0x08,0x07},//0x59//Y

{0x00,0x61,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1