STM32F407学习之GPIO驱动NOKIA LCD5110
来源:互联网 发布:手机主板测试软件 编辑:程序博客网 时间:2024/05/22 05:33
1、nokia5110显示器介绍
这款液晶显示屏是通过PCD8554驱动控制器来驱动的,主要的特征如下:
单芯片 LCD 控制/驱动
48 行,84 列输出
显示数据 RAM 48*84 位
芯片集成:
——LCD电压发生器(也可以使用外部电压供应)
——LCD偏置电压发生器
——振荡器不需要外接元件(也可以使用外部时钟)
外部 RES(复位)输入引脚
串行界面最高4.0Mbits/S
CMOS兼容输入
混合速率:48
逻辑电压范围VDD到 VSS:2.7V~3.3V
显示电压范围VLCD到 VSS:
——6.0~8.5V LCD内部电压发生器(充许电压发生器)
——6.0~9.0V LCD外部电压供应(电压发生器关闭)
低功耗,适用于电池供电系统
关于VLCD的温度补偿
使用温度范围:-25~70℃
PCD8544 是一块低功耗的CMOS LCD控制驱动器,设计为驱动48 行84 列的图形显示。所有必须的显示功能集成在一块芯片上,包括LCD 电压及偏置电压发生器,只须很少外部元件且功耗小。 PCD8544 与微控制器的接口使用串行总线。PCD8544 采用 CMOS工艺。
方框图:
引脚图:
2、STM32控制LCD_5110连接图
GPIOB5<======================>SCE
GPIOB6<======================>RES
GPIOB7<======================>DC
GPIOB8<======================>SDIN
GPIOB9<======================>SCLK
3、程序
main.c/*芯片:STM32F407*/#include "stm32f4xx.h"#include "lcd5110.h"#include "delay.h"int main(void){GPIO_Configuration();LCD_init(); LCD_clear();LCD_write_chinese(10,0,0);LCD_write_chinese(22,0,1);LCD_write_chinese(34,0,2);LCD_write_chinese(46,0,3);LCD_write_chinese(58,0,4);LCD_write_chinese(70,0,5);//LCD_write_Picture(tu);//display full screen picture.return 0; }
lcd5110.c/*file:lcd 5110 driverauthor:Allen和大家分享,共同学习,一起进步。Share more,learn better.some code is referenced from network.*/#include "lcd5110.h"#include "delay.h"unsigned char tu[]={0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0x60,0x60,0x60,0x20,0x30,0x20,0x20,0x20,0x62,0x62,0x72,0xCC,0xF7,0xF2,0x23,0x02,0xC4,0x78,0x0C,0xE6,0xF2,0xE3,0x02,0x02,0x02,0x07,0x0C,0x3C,0xC2,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xFC,0x0E,0x03,0x01,0x00,0x80,0x60,0x10,0x40,0x14,0x00,0x00,0x00,0x00,0x00,0x20,0x38,0x18,0x58,0x19,0x59,0x23,0x03,0x07,0x0C,0x08,0x10,0x30,0x30,0x30,0x90,0x38,0x5C,0x3F,0xF1,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x1F,0x3C,0x70,0xE0,0xC0,0xC2,0x8D,0xA2,0x08,0x21,0x40,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xE0,0x20,0x00,0x00,0x00,0x02,0x51,0x04,0xAB,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0A,0x3F,0xF3,0xD7,0xAF,0x5B,0x33,0xE3,0x42,0xDF,0xE6,0x86,0x82,0x82,0x82,0xC3,0x7E,0x43,0x63,0x21,0x31,0x18,0x06,0x81,0x00,0x00,0xA0,0x80,0xC8,0xE1,0xF4,0x7A,0x3F,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x07,0x0E,0x0D,0x1C,0x1D,0x3A,0x39,0xFA,0xF8,0x7A,0xB8,0x1A,0xB8,0x1C,0xAD,0x1C,0xBE,0x1E,0xBE,0x3F,0xF3,0xE3,0xC1,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; unsigned char tu1[]= {0x00,0x00,0x00,0x00,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xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xBF,0xDF,0xEF,0xF3,0x7C,0x3F,0x0F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x3E,0x7D,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0x7D,0x3E,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x07,0x0F,0x0E,0x1D,0x3B,0x77,0xEF,0xEF,0x77,0x3B,0x1D,0x0E,0x0F,0x07,0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};//中文字模const unsigned char chinese_character[][24]={//hua{0x88,0x84,0xBE,0x91,0x90,0xC8,0xBF,0xA8,0xA4,0xA2,0xB8,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00},//dong{0x02,0x22,0x32,0xAA,0x26,0xFB,0x22,0x62,0xA2,0x22,0x02,0x00,0x02,0x02,0x01,0x00,0x04,0x07,0x00,0x00,0x00,0x01,0x02,0x00},//li{0x12,0x12,0xFE,0x12,0x3F,0xA5,0xA5,0xFF,0xA5,0xA5,0x3F,0x00,0x02,0x02,0x01,0x05,0x04,0x04,0x04,0x07,0x04,0x04,0x04,0x00},//gong{0x00,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x03,0x02,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x07,0x04,0x04,0x04,0x04,0x04,0x00},//da{0x08,0x08,0x08,0x08,0xC8,0x3F,0xC8,0x08,0x08,0x0C,0x08,0x00,0x04,0x04,0x02,0x01,0x00,0x00,0x00,0x01,0x02,0x04,0x04,0x00},//xue{0x9C,0x84,0x95,0x96,0x95,0xD6,0xB4,0x94,0x87,0x94,0x8C,0x00,0x00,0x00,0x00,0x04,0x04,0x07,0x00,0x00,0x00,0x00,0x00,0x00},//long{0x04,0x04,0x04,0xC4,0x3F,0x04,0xFC,0x45,0x26,0x14,0x04,0x00,0x04,0x02,0x01,0x02,0x02,0x01,0x07,0x04,0x04,0x04,0x07,0x00},//fei{0x01,0x01,0x01,0x01,0x01,0x7F,0x90,0x18,0x24,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x04,0x07,0x00},};//6X8字库unsigned char font6x8[][6] ={{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },// sp{ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 },// !{ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 },// "{ 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 },// #{ 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 },// ${ 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 },// %{ 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 },// &{ 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 },// '{ 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 },// ({ 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 },// ){ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 },// *{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 },// +{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 },// ,{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 },// -{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 },// .{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 },// /{ 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E },// 0{ 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 },// 1{ 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 },// 2{ 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 },// 3{ 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 },// 4{ 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 },// 5{ 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 },// 6{ 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 },// 7{ 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 },// 8{ 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E },// 9{ 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 },// :{ 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 },// ;{ 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 },// <{ 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 },// ={ 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 },// >{ 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 },// ?{ 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E },// @{ 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C },// A{ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 },// B{ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 },// C{ 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C },// D{ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 },// E{ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 },// F{ 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A },// G{ 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F },// H{ 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 },// I{ 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 },// J{ 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 },// K{ 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 },// L{ 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F },// M{ 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F },// N{ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E },// O{ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 },// P{ 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E },// Q{ 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 },// R{ 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 },// S{ 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 },// T{ 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F },// U{ 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F },// V{ 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F },// W{ 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 },// X{ 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 },// Y{ 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 },// Z{ 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 },// [{ 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 },// 55{ 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 },// ]{ 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 },// ^{ 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 },// _{ 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 },// '{ 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 },// a{ 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 },// b{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 },// c{ 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F },// d{ 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 },// e{ 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 },// f{ 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C },// g{ 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 },// h{ 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 },// i{ 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 },// j{ 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 },// k{ 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 },// l{ 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 },// m{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 },// n{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 },// o{ 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 },// p{ 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC },// q{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 },// r{ 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 },// s{ 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 },// t{ 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C },// u{ 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C },// v{ 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C },// w{ 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 },// x{ 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C },// y{ 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 },// z{ 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 }// horiz lines};/*@brief:set and clear the control bits of 5110 lcd.@usage:you can use funtion set_XXX() to set a bit and use funtion clear_XXX() to clear a bit.*/void set_SCE(void){ GPIO_WriteBit(GPIOB, GPIO_Pin_5, Bit_SET);}void clear_SCE(void){ GPIO_WriteBit(GPIOB, GPIO_Pin_5, Bit_RESET);}void set_RES(void){ GPIO_WriteBit(GPIOB, GPIO_Pin_6, Bit_SET);}void clear_RES(void){ GPIO_WriteBit(GPIOB, GPIO_Pin_6, Bit_RESET);}void set_DC(void){ GPIO_WriteBit(GPIOB, GPIO_Pin_7, Bit_SET);}void clear_DC(void){ GPIO_WriteBit(GPIOB, GPIO_Pin_7, Bit_RESET);}void set_SDIN(void){ GPIO_WriteBit(GPIOB, GPIO_Pin_8, Bit_SET);}void clear_SDIN(void){ GPIO_WriteBit(GPIOB, GPIO_Pin_8, Bit_RESET);}void set_SCLK(void){ GPIO_WriteBit(GPIOB, GPIO_Pin_9, Bit_SET);}void clear_SCLK(void){ GPIO_WriteBit(GPIOB, GPIO_Pin_9, Bit_RESET);}/*************************************************函数名: GPIO_Configuration *参 数:无*功 能: 配置GPIO *返回值:无 *备 注:无 *日 期:2013/07/23 *************************************************/ GPIO_InitTypeDef GPIO_InitStructure;void GPIO_Configuration(void){ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); GPIO_InitStructure.GPIO_Pin=GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_Init(GPIOB, &GPIO_InitStructure);}/*************************************************函数名: LCD_write_byte **参 数:data:写入的数据 ** cmd: 1-数据/0-命令 **功 能: 向5110LCD写入数据 **返回值:无 **日 期:2013/07/23 **************************************************/ void LCD_write_byte(unsigned char data,unsigned char cmd){ unsigned char i; clear_SCE(); if(cmd) set_DC(); else clear_DC(); for(i=0;i<8;i++) { if(data&0x80) //如果一个字节的最高位是1 set_SDIN(); //则设置SDIN=1 else clear_SDIN();//否则设置SDIN=0;SDIN是即将写入数据DDRAM的值 data = data<<1; //将传送的一个字节数据的每一位进行左移一位,等待下一次传输 clear_SCLK(); //SDIN在SCLK的上升沿写入DDRAM set_SCLK(); // clear_SCLK(); // } }/*************************************************函数名: LCD_init **参 数:无 **功 能: 初始化LCD **返回值:无 * **日 期:2013/07/23 **************************************************/void LCD_init(void){set_SCE();set_RES();delay_us(200);clear_RES(); delay_ms(20);set_RES(); delay_us(200); LCD_write_byte(0x21,0);//LCD功能设置:芯片活动,水平寻址,使用扩展指令 LCD_write_byte(0xd0,0);//设置VOP值,室温下的编程范围为3.00-10.68 //Vlcd=3.06+(VOP)*0.06,本例VOP为0B01010000为十进制的80,Vlcd=7.86V LCD_write_byte(0x20,0);//LCD功能设置:芯片活动,水平寻址,使用基本指令 LCD_write_byte(0x0c,0);//设定显示配置:普通模式 set_SCE();//SCE为高电平时串行口被初始化,SCLK时钟不起作用,串行接口不消耗电力,所以最后都将SCE置高电平}/*************************************************函数名: LCD_set_XY **参 数:X:列 ** Y:行 **功 能: 选择写入液晶位置 **返回值:无 **日 期:2013/07/23 **************************************************/void LCD_set_XY(unsigned char X, unsigned char Y){ LCD_write_byte(0x40 | Y, 0);// 行 LCD_write_byte(0x80 | X, 0);// 列 set_SCE();} /*************************************************函数名: LCD_clear **参 数:无 **功 能: 清屏 **返回值:无 **备 注:无 **日 期:2013/07/23 **************************************************/void LCD_clear(void){ unsigned char t; unsigned char k; LCD_set_XY(0,0); for(t=0;t<6;t++) { for(k=0;k<84;k++) { LCD_write_byte(0x00,1); } } set_SCE();}/*************************************************函数名: LCD_write_char **参 数:c:需写入的字符 **功 能: 写入字符命令 **返回值:无 **日 期:2013/07/23 **************************************************/void LCD_write_char(unsigned char c){ unsigned char c_line;c-=32;for (c_line=0; c_line<6; c_line++)LCD_write_byte(font6x8[c][c_line], 1); }/*************************************************函数名: LCD_write_String **参 数:X:设置写入字符串列位置 ** Y:设置写入字符串行位置 ** *s:写入字符串首地址 **功 能: LCD显示字符串 **返回值:无 **日 期:2013/07/23 **************************************************/void LCD_write_String(unsigned char X,unsigned char Y,char *s){ LCD_set_XY(X,Y); while (*s) { LCD_write_char(*s); s++; }} /*************************************************函数名: LCD_write_chinese **参 数:X:设置写入汉字列位置 ** Y:设置写入汉字行位置 **功 能: LCD显示汉字 **返回值:无 **日 期:2013/07/23 **************************************************/void LCD_write_chinese(unsigned char X, unsigned char Y,char n){ int i;LCD_set_XY(X,Y); for(i = 0;i < 12; i++){LCD_write_byte(chinese_character[n][i],1);}LCD_set_XY(X,Y+1); for(i = 12; i < 24; i++){LCD_write_byte(chinese_character[n][i],1);}}/*************************************************函数名: LCD_write_Picture **功 能: 写整屏的图片 **返回值:无 **日 期:2013/07/23 **************************************************/void LCD_write_Picture(unsigned char *c){unsigned i,j;for(i=0;i<6;i++){LCD_set_XY(0,i);for(j=0;j<84;j++){LCD_write_byte(c[i*84+j],1);}}}
delay.c#include "delay.h"__IO u16 ntime; void delay_ms(u16 nms){ ntime=nms;SysTick_Config(168000);//1ms产生一次中断while(ntime);SysTick->CTRL=0x00; } void delay_us(u32 nus){ntime=nus;SysTick_Config(168);//1us产生一次中断while(ntime);SysTick->CTRL=0x00;}void Delay(u32 count){while(count--);}
/** ************************************************************************************ * @file LCD5110.h * @author Allen * @version V1.0.0 * @date 22-July-2012,21:30 IN ECUST * @brief This file contains all the functions prototypes for the 5110 LCD driver ************************************************************************************ @NOTE:*THIS FILE IS JUST FOR STUDY,CREATED BY LONGFEI WHICH HAS SOME REFERENCE FROM NETWORK*//* Define to prevent recursive inclusion -------------------------------------*/#ifndef __LCD5110_H#define __LCD5110_Hextern unsigned char tu[];extern unsigned char tu1[];extern unsigned char tu2[];/* Exported functions --------------------------------------------------------*/ /* Funtion used to Configuration GPIO ----------------------------------------*/ void GPIO_Configuration(void);/* Funtion used to SET SCE----------------------------------------------------*/ void set_SCE(void);/* Funtion used to CLEAR SCE--------------------------------------------------*/ void clear_SCE(void);/* Funtion used to SET RES----------------------------------------------------*/ void set_RES(void);/* Funtion used toCLEAR SCE--------------------------------------------------*/ void clear_RES(void);/* Funtion used toSET DC-----------------------------------------------------*/ void set_DC(void);/* Funtion used toCLEAR DC---------------------------------------------------*/ void clear_DC(void);/* LCD_write_byte funtion---------------------------------------------------*/ void LCD_write_byte(unsigned char data,unsigned char cmd);/* LCD_Init function--------------------------------------------------------*/ void LCD_init(void);/* LCD_set_XY---------------------------------------------------------------*/ void LCD_set_XY(unsigned char X,unsigned char Y);/* LCD_clear function-------------------------------------------------------*/ void LCD_clear(void);/* LCD_write_char function--------------------------------------------------*/ void LCD_write_char(unsigned char c);/* LCD_write_string function-----------------------------------------------*/ void LCD_write_String(unsigned char X,unsigned char Y,char *s);/* LCD_write_chinese function------------------------------------------ ---*/ void LCD_write_chinese(unsigned char X,unsigned char Y,char n);/* LCD_write_Picture function------------------------------------------ ---*/ void LCD_write_Picture(unsigned char *c);#endif
#ifndef __DELAY_H#define __DELAY_H#include "stm32f4xx_conf.h"void delay_ms(u16 nms);void delay_us(u32 nus);void Delay(u32 count);#endif
- STM32F407学习之GPIO驱动NOKIA LCD5110
- STM32F407学习之GPIO
- STM32F407学习笔记----GPIO
- STM32F407之GPIO
- STM32F407学习之初始STM32F407
- 树莓派驱动学习之GPIO
- STM32F407学习笔记二(GPIO)
- stm32f407之GPIO(操作寄存器)
- stm32f407之GPIO(操作寄存器)
- STM32F407学习之时钟
- tonyos学习笔记之二 GPIO驱动
- LCD5110
- STM32F407学习之Interrupts/Event
- STM32F407学习之硬件认识
- STM32F407的GPIO操作
- wince GPIO 驱动 学习
- ((硬件spi+dma)+模拟spi)驱动LCD5110
- Zynq-Linux移植学习笔记之12-gpio驱动配置
- 嵌入式Linux驱动程序之编程常见错误
- 关于silverhight中动态添加itemcontrol时"值不在预期的范围内" 的一个问题
- 一个4年Java程序员的总结
- jquery 中在浏览器大小大于图片大小后图片正常显示,否则图片进行缩放
- /MT、/MD编译选项,以及可能引起在不同堆中申请、释放内存的问题
- STM32F407学习之GPIO驱动NOKIA LCD5110
- iOS开发之详解剪贴板
- 不必担心安卓系统被植入棱镜
- iBatis Demo
- hdu1258 Sum It Up (DFS)
- MySQL基础配置之mysql的默认字符编码的设置(my.ini设置字符编码) .
- 黑马程序员--JAVA<多线程>--多线程
- 【Win8系统下打不开软件,无法登录该如何解决】
- linux2.6内核initrd机制解析