hal库uc1701液晶LCD12864驱动程序移植

本来程序是准备用来驱动型号:YM12864P-69液晶模块的,但是本人手残,貌似把模块焊坏了...
程序是从coocox官方移植来的,不知道移植的对不对...
模块坏了,貌似测试不了了....

谁来帮我测试一下!

关于这个uc1701驱动器的相关资料,看下面的帖子
http://www.stm32cube.com/question/136
同时,相关的资料也在本站的共享里面找到

k5don7c766esiqf3m2l5jnj0m0_8965acf429df465099b1798d1772c86a1432007659.1932_.gif


配置如下:

QQ图片20150519125604.jpg


QQ图片20150519125705.jpg

相关GPIO口管脚AF,上拉,fast
二楼放程序.
本帖程序稍后会上传到本站网盘,届时请自行下载
文件名:12864_uc1701.zip
已邀请:

admin

赞同来自:

用到3个文件:uc1701.c,uc1701.h,hw_uc1701.h
其中,函数部分uc1701.c如下:


//*****************************************************************************
//
//*****************************************************************************
#include "uc1701.h"
#include "hw_uc1701.h"
#include "stm32f4xx_hal.h"
#include "spi.h"

unsigned char Ascii[];
unsigned char Ascii[]={
/[i] [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,
/[i] ! [/i]/
0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/[i] " [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,
/[i] # [/i]/
0x00,0x00,0x00,0xC0,0x30,0xC0,0x30,0x00,0xC8,0x39,0xCF,0x39,0x0F,0x09,0x01,0x00,
/[i] $ [/i]/
0xE0,0x10,0x10,0xF8,0x10,0x10,0x60,0x00,0x30,0x41,0x42,0xFF,0x42,0x44,0x38,0x00,
/[i] % [/i]/
0xC0,0x20,0x10,0xE0,0x20,0xE0,0x18,0x00,0x01,0xC2,0x31,0x0C,0x73,0x88,0x44,0x38
,
/[i] & [/i]/
0x00,0xE0,0x10,0x10,0xE0,0x00,0x00,0x00,0x78,0x85,0x82,0x8D,0x70,0xA2,0x9E,0x42
,
/[i] ' [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,
/[i] ( [/i]/
0xC0,0x30,0x08,0x04,0x00,0x00,0x00,0x00,0x1F,0x60,0x80,0x00,0x00,0x00,0x00,0x00
,
/[i] ) [/i]/
0x04,0x08,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x1F,0x00,0x00,0x00,0x00
,
/[i] [/i] */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x28,0xFE,0x28,0x44,0x00,0x00,0x00
,
/[i] + [/i]/
0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x08,0x08,0x08,0xFF,0x08,0x08,0x08,0x00,
/[i] , [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,0x00
,
/[i] - [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00
,
/[i] . [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00
,
/[i] / [/i]/
0x00,0x00,0x80,0x70,0x00,0x00,0x00,0x00,0xE0,0x1C,0x03,0x00,0x00,0x00,0x00,0x00
,
/[i] 0 [/i]/
0xC0,0x20,0x10,0x10,0x20,0xC0,0x00,0x00,0x3F,0x40,0x80,0x80,0x40,0x3F,0x00,0x00,
/[i] 1 [/i]/
0x20,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,
/[i] 2 [/i]/
0x60,0x10,0x10,0x10,0x20,0xC0,0x00,0x00,0xC0,0xA0,0x90,0x88,0x86,0xC1,0x00,0x00
,
/[i] 3 [/i]/
0x20,0x10,0x10,0x10,0xE0,0x00,0x00,0x00,0x80,0x80,0x82,0x83,0x44,0x38,0x00,0x00
,
/[i] 4 [/i]/
0x00,0x00,0x80,0x60,0xF0,0x00,0x00,0x00,0x18,0x16,0x11,0x10,0xFF,0x10,0x00,0x00,
/[i] 5 [/i]/
0x00,0xF0,0x10,0x10,0x10,0x10,0x00,0x00,0x80,0x81,0x81,0x81,0x42,0x3C,0x00,0x00
,
/[i] 6 [/i]/
0x80,0x40,0x20,0x10,0x10,0x10,0x00,0x00,0x3F,0x42,0x81,0x81,0x42,0x3C,0x00,0x00
,
/[i] 7 [/i]/
0x70,0x10,0x10,0x10,0x90,0x70,0x00,0x00,0x00,0x00,0xE0,0x1C,0x03,0x00,0x00,0x00
,
/[i] 8 [/i]/
0xC0,0x20,0x10,0x10,0x20,0xC0,0x00,0x00,0x38,0x45,0x82,0x82,0x45,0x38,0x00,0x00
,
/[i] 9 [/i]/
0xC0,0x20,0x10,0x10,0x20,0xC0,0x00,0x00,0x83,0x84,0x88,0x48,0x24,0x1F,0x00,0x00
,
/[i] : [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC3,0xC3,0x00,0x00,0x00,0x00,0x00,0x00
,
/[i] ; [/i]/
0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,0x00
,
/[i] < [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x28,0x28,0x44,0x44,0x82,0x00,0x00
,
/[i] = [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88
,
/[i] > [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x82,0x44,0x44,0x28,0x28,0x10,0x00,0x00
,
/[i] ? [/i]/
0xE0,0x10,0x10,0x10,0x20,0xC0,0x00,0x00,0x00,0x00,0xD8,0x06,0x01,0x00,0x00,0x00
,
/[i] @ [/i]/
0xC0,0x20,0x10,0x90,0x90,0x10,0xA0,0xC0,0x3F,0x40,0x8F,0x90,0x90,0x8F,0x50,0x5F,
/[i] A [/i]/
0x00,0x00,0x80,0x70,0x80,0x00,0x00,0x00,0x80,0xF0,0x8F,0x08,0x8F,0xF0,0x80,0x00,
/[i] B [/i]/
0x10,0xF0,0x10,0x10,0x10,0x20,0xC0,0x00,0x80,0xFF,0x82,0x82,0x82,0x45,0x38,0x00,
/[i] C [/i]/
0xC0,0x20,0x10,0x10,0x10,0x20,0x70,0x00,0x3F,0x40,0x80,0x80,0x80,0x80,0x40,0x00
,
/[i] D [/i]/
0x10,0xF0,0x10,0x10,0x10,0x60,0x80,0x00,0x80,0xFF,0x80,0x80,0x80,0x60,0x1F,0x00,
/[i] E [/i]/
0x10,0xF0,0x10,0x10,0x10,0x10,0x70,0x00,0x80,0xFF,0x82,0x82,0x82,0x87,0xE0,0x00,
/[i] F [/i]/
0x10,0xF0,0x10,0x10,0x10,0x10,0x70,0x00,0x80,0xFF,0x82,0x02,0x02,0x07,0x00,0x00,
/[i] G [/i]/
0xC0,0x20,0x10,0x10,0x20,0x70,0x00,0x00,0x3F,0x40,0x80,0x80,0x84,0x7C,0x04,0x00
,
/[i] H [/i]/
0x10,0xF0,0x10,0x00,0x10,0xF0,0x10,0x00,0x80,0xFF,0x82,0x02,0x82,0xFF,0x80,0x00,
/[i] I [/i]/
0x10,0xF0,0x10,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,
/[i] J [/i]/
0x00,0x00,0x10,0xF0,0x10,0x00,0x00,0x00,0x40,0x80,0x80,0x7F,0x00,0x00,0x00,0x00,
/[i] K [/i]/
0x10,0xF0,0x10,0x80,0x50,0x30,0x10,0x00,0x80,0xFF,0x83,0x0C,0xB0,0xC0,0x80,0x00,
/[i] L [/i]/
0x10,0xF0,0x10,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x80,0x80,0x80,0xC0,0x20,0x00,
/[i] M [/i]/
0x10,0xF0,0x80,0x00,0x80,0xF0,0x10,0x00,0x80,0xFF,0x83,0x3C,0x83,0xFF,0x80,0x00,
/[i] N [/i]/
0x10,0xF0,0xC0,0x00,0x10,0xF0,0x10,0x00,0x80,0xFF,0x80,0x0F,0x30,0xFF,0x00,0x00,
/[i] O [/i]/
0x80,0x60,0x10,0x10,0x10,0x60,0x80,0x00,0x1F,0x60,0x80,0x80,0x80,0x60,0x1F,0x00,
/[i] P [/i]/
0x10,0xF0,0x10,0x10,0x10,0x20,0xC0,0x00,0x80,0xFF,0x84,0x04,0x04,0x02,0x01,0x00,
/[i] Q [/i]/
0xE0,0x18,0x04,0x04,0x04,0x18,0xE0,0x00,0x07,0x18,0x20,0x20,0x60,0x98,0x87,0x00
,
/[i] R [/i]/
0x10,0xF0,0x10,0x10,0x10,0x20,0xC0,0x00,0x80,0xFF,0x84,0x0C,0x34,0xC2,0x81,0x00,
/[i] S [/i]/
0xC0,0x20,0x10,0x10,0x10,0x20,0x70,0x00,0xE0,0x41,0x82,0x82,0x84,0x48,0x30,0x00
,
/[i] T [/i]/
0x30,0x10,0x10,0xF0,0x10,0x10,0x30,0x00,0x00,0x00,0x80,0xFF,0x80,0x00,0x00,0x00,
/[i] U [/i]/
0x10,0xF0,0x10,0x00,0x10,0xF0,0x10,0x00,0x00,0x7F,0x80,0x80,0x80,0x7F,0x00,0x00,
/[i] V [/i]/
0x10,0xF0,0x10,0x00,0x10,0xF0,0x10,0x00,0x00,0x01,0x1E,0xE0,0x1E,0x01,0x00,0x00,
/[i] W [/i]/
0x10,0xF0,0x10,0xC0,0x10,0xF0,0x10,0x00,0x00,0x0F,0xF0,0x0F,0xF0,0x0F,0x00,0x00,
/[i] X [/i]/
0x10,0x70,0x90,0x00,0x90,0x70,0x10,0x00,0x80,0xE0,0x99,0x06,0x99,0xE0,0x80,0x00
,
/[i] Y [/i]/
0x10,0x70,0x90,0x00,0x90,0x70,0x10,0x00,0x00,0x00,0x83,0xFC,0x83,0x00,0x00,0x00
,
/[i] Z [/i]/
0x70,0x10,0x10,0x10,0x10,0xD0,0x30,0x00,0xC0,0xB0,0x88,0x86,0x81,0x80,0xE0,0x00
,
/[i] [/i]/
0x04,0x04,0xFC,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,
/[i] ^ [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x06,0x18,0x60,0x80,0x00
,
/[i] _ [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
,
/[i] ` [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x60,0x40,0x80,0x00,0x00,0x00,0x00
,
/[i] a [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x91,0x89,0x49,0xFE,0x80,0x00,0x00
,
/[i] b [/i]/
0x10,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x81,0x81,0x42,0x3C,0x00,0x00,
/[i] c [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x81,0x81,0x81,0x42,0x00,0x00
,
/[i] d [/i]/
0x00,0x00,0x00,0x10,0xF0,0x00,0x00,0x00,0x3C,0x42,0x81,0x81,0x7F,0x80,0x00,0x00,
/[i] e [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x4A,0x89,0x89,0x8A,0x4C,0x00,0x00
,
/[i] f [/i]/
0x00,0x00,0xE0,0x10,0x10,0x20,0x00,0x00,0x01,0x81,0xFF,0x81,0x01,0x00,0x00,0x00,
/[i] g [/i]/
0x80,0x40,0x40,0x40,0x80,0x40,0x00,0x00,0x53,0xAC,0xA4,0xA4,0xA3,0x40,0x00,0x00,
/[i] h [/i]/
0x10,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x01,0x01,0xFE,0x80,0x00,0x00,
/[i] i [/i]/
0x00,0xB0,0x00,0x00,0x00,0x00,0x00,0x00,0x81,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,
/[i] j [/i]/
0x00,0x00,0x80,0xCC,0x00,0x00,0x00,0x00,0x40,0x80,0x80,0x7F,0x00,0x00,0x00,0x00
,
/[i] k [/i]/
0x10,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x98,0x25,0xC3,0x81,0x00,0x00,
/[i] l [/i]/
0x10,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,
/[i] m [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x81,0xFE,0x01,0xFE,0x01,0xFE,0x80,0x00,
/[i] n [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x81,0xFE,0x01,0x01,0xFE,0x80,0x00,0x00,
/[i] o [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x81,0x81,0x42,0x3C,0x00,0x00
,
/[i] p [/i]/
0x40,0x80,0x40,0x40,0x80,0x00,0x00,0x00,0x80,0xFF,0xA0,0x20,0x10,0x0F,0x00,0x00,
/[i] q [/i]/
0x00,0x80,0x40,0x40,0x80,0x40,0x00,0x00,0x0F,0x10,0x20,0xA0,0xFF,0x80,0x00,0x00,
/[i] r [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x81,0xFF,0x82,0x01,0x01,0x00,0x00,0x00,
/[i] s [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE6,0x49,0x89,0x91,0x92,0x67,0x00,0x00
,
/[i] t [/i]/
0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x7F,0x81,0x81,0x40,0x00,0x00
,
/[i] u [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x7F,0x80,0x81,0x7F,0x80,0x00,0x00,
/[i] v [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x39,0xC0,0x39,0x07,0x01,0x00
,
/[i] w [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x1F,0xE1,0x1C,0xE1,0x1F,0x01,0x00,
/[i] x [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x81,0xE7,0x18,0x18,0xE7,0x81,0x00,0x00
,
/[i] y [/i]/
0x40,0xC0,0x40,0x00,0x40,0xC0,0x40,0x00,0x80,0x81,0x46,0x38,0x06,0x01,0x00,0x00
,
/[i] z [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC3,0xA1,0x91,0x89,0x85,0xC3,0x00,0x00
,
/[i] { [/i]/
0x00,0xF0,0x08,0x00,0x00,0x00,0x00,0x00,0x02,0x7D,0x80,0x00,0x00,0x00,0x00,0x00
,
/[i] | [/i]/
0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/[i] } [/i]/
0x08,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x7D,0x02,0x00,0x00,0x00,0x00,0x00
,
/[i] ~ [/i]/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x20,0x20,0x60,0xC0,0x80,0x80,0x60
};


static void delay_ms(long ms)
{
HAL_Delay(ms);
}


//*****************************************************************************
//
//
//*****************************************************************************
void UC1701Init(void)
{
//
// Disable UC1701 when Power up
//

HAL_GPIO_WritePin(GPIOD,GPIO_PIN_0,GPIO_PIN_SET);
//
// Reset the chip
//

HAL_GPIO_WritePin(GPIOD,GPIO_PIN_1,GPIO_PIN_RESET);
delay_ms(2);

HAL_GPIO_WritePin(GPIOD,GPIO_PIN_1,GPIO_PIN_SET);
delay_ms(6);

//
// Initial Configuration
//
UC1701CmdWrite(0xe2);//System Reset
UC1701CmdWrite(0x2c);//Power Rise Step1
delay_ms(8);
UC1701CmdWrite(0x2e);//Power Rise Step2
delay_ms(8);
UC1701CmdWrite(0x2f);//Power Rise Step3
delay_ms(8);
UC1701CmdWrite(0x23);
UC1701DoubleCmdWrite(0x81, 0x1f);//Set LCD resistor ratio

UC1701CmdWrite(0xa2);//Bias 1/9
UC1701CmdWrite(0xc0);//Set COM Direction
UC1701CmdWrite(0xa0);//Set SEG Direction
UC1701CmdWrite(0x40);//Set Scroll Line: the first line
UC1701CmdWrite(0xaf);//Display Enable

}


//*****************************************************************************
//
//
//*****************************************************************************
void UC1701DataWrite(unsigned char ucData)
{
unsigned long ulTemp;

//
//Step 1 Select Chip
//
// xGPIOSPinWrite(LCD_PIN_SPI_CS, 0);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_0,GPIO_PIN_RESET);
//
//Step 2 Set Display Enable
//
ulTemp = ucData;
// xGPIOSPinWrite(LCD_PIN_CD, 1);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_SET);
// xSPIDataWrite(LCD_PIN_SPI_PORT, &ulTemp, 1);
HAL_SPI_Transmit(&hspi3,(uint8_t *)&ulTemp,1,0xff);
//
//Step 3 Disable chip select
//
// xGPIOSPinWrite(LCD_PIN_SPI_CS, 1);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_0,GPIO_PIN_SET);
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701CmdWrite(unsigned char ucCmd)
{
//
//Step 1 Select Chip
//
// xGPIOSPinWrite(LCD_PIN_SPI_CS, 0);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_0,GPIO_PIN_RESET);
//
//Step 2 Send a command
//
// xGPIOSPinWrite(LCD_PIN_CD, 0);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_RESET);
// xSPIDataWrite(LCD_PIN_SPI_PORT, &ucCmd, 1);
HAL_SPI_Transmit(&hspi3,&ucCmd,1,0xff);
//
//Step 3 Disable chip select
//
// xGPIOSPinWrite(LCD_PIN_SPI_CS, 1);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_0,GPIO_PIN_SET);
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701DoubleCmdWrite(unsigned char ucCmd, unsigned char ucData)
{
//
//Step 1 Select Chip
//
// xGPIOSPinWrite(LCD_PIN_SPI_CS, 0);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_0,GPIO_PIN_RESET);
//
//Step 2 Set command
//
// xGPIOSPinWrite(LCD_PIN_CD, 0);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_RESET);
// xSPIDataWrite(LCD_PIN_SPI_PORT, &ucCmd, 1);
// xSPIDataWrite(LCD_PIN_SPI_PORT, &ucData, 1);
HAL_SPI_Transmit(&hspi3,&ucCmd,1,0xff);
HAL_SPI_Transmit(&hspi3,&ucData,1,0xff);
//
//Step 3 Disable chip select
//
// xGPIOSPinWrite(LCD_PIN_SPI_CS, 1);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_0,GPIO_PIN_SET);
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701AddressSet(unsigned char ucPA, unsigned char ucCA)
{

//
//Step 1 Set Page Address
//
UC1701CmdWrite((ucPA & UC1701_SET_PA_MASK) | UC1701_SET_PA);

//
//Step 2 Set Column Address MSB
//
UC1701CmdWrite(((ucCA>>4) & UC1701_SET_CA_MASK) | UC1701_SET_CA_MSB);

//
//Step 3 Set Column Address LSB
//
UC1701CmdWrite(((ucCA) & UC1701_SET_CA_MASK) | UC1701_SET_CA_LSB);
}


//*****************************************************************************
//
//
//*****************************************************************************
void UC1701Dispaly(unsigned char ucLine, unsigned char ucRow,
unsigned char ucAsciiWord)
{
int i=0,k=0;
unsigned char uctemp;
k=(ucAsciiWord-32)*16;

for(i=0;i<8;i++)
{
UC1701AddressSet((ucLine[i]2),(129-(ucRow[/i]8)-i));
uctemp=Ascii;
UC1701DataWrite(uctemp);
}
for(i=0;i<8;i++)
{
UC1701AddressSet((ucLine[i]2)+1,(129-(ucRow[/i]8)-i));
uctemp=Ascii;
UC1701DataWrite(uctemp);
}
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701InverseDispaly(unsigned char ucLine, unsigned char ucRow,
unsigned char ucAsciiWord)
{
int i=0,k=0;
unsigned char uctemp;
k=(ucAsciiWord-32)*16;

for(i=0;i<8;i++)
{
UC1701AddressSet((ucLine[i]2),(129-(ucRow[/i]8)-i));
uctemp=~Ascii;
UC1701DataWrite(uctemp);
}
for(i=0;i<8;i++)
{
UC1701AddressSet((ucLine[i]2)+1,(129-(ucRow[/i]8)-i));
uctemp=~Ascii;
UC1701DataWrite(uctemp);
}
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701CharDispaly(unsigned char ucLine, unsigned char ucRow,
char *pcChar)
{
// xASSERT((ucLine <= 3) && (ucRow <= 15));
do
{
UC1701Dispaly(ucLine,ucRow,*pcChar++);
ucRow++;
if(ucRow>15)
{
ucLine++;
ucRow=0;
if(ucLine>3)
break;
}
}
while(*pcChar!='\0');
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701ChineseDispaly(unsigned char ucLine, unsigned char ucRow,
unsigned char ucLength, char *pcChar)
{
int i,j=0;
// xASSERT((ucLine <= 3) && (ucRow <= 15));

for(j=0;j<ucLength;j++)
{
for(i=0;i<16;i++)
{
UC1701AddressSet((ucLine[i]2),(129-(ucRow[/i]8)-i));
UC1701DataWrite(pcChar);
}
for(i=0;i<16;i++)
{
UC1701AddressSet((ucLine[i]2)+1,(129-(ucRow[/i]8)-i));
UC1701DataWrite(pcChar);
}
ucRow = ucRow +2;
if (ucRow > 14)
{
ucLine++;
if(ucLine > 3)
{
break;
}
}
}
}
//*****************************************************************************
//
//
//*****************************************************************************
void UC1701DisplayN(unsigned char ucLine, unsigned char ucRow,
unsigned long n)
{
char pcBuf, *p;

if (n == 0)
{
UC1701Dispaly(ucLine, ucRow, '0');
}
else
{
p = pcBuf;
while (n != 0)
{
*p++ = (n % 10) + '0';
n /= 10;
}

while (p > pcBuf)
{
UC1701Dispaly(ucLine, ucRow, *--p);
ucRow++;
if (ucRow > 14)
{
ucLine++;
if(ucLine > 3)
{
break;
}
}
}
}
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701Clear(void)
{
unsigned char i,j;

for(i=0;i<9;i++)
{
// xGPIOSPinWrite(LCD_PIN_SPI_CS, 0);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_0,GPIO_PIN_RESET);
UC1701CmdWrite(0xb0+i);
UC1701CmdWrite(0x10);
UC1701CmdWrite(0x00);
for(j=0;j<132;j++)
{
UC1701DataWrite(0x00);
}
}
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701InverseEnable(void)
{
UC1701CmdWrite(UC1701_SET_DC0_EN);
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701InverseDisable(void)
{
UC1701CmdWrite(UC1701_SET_DC0);
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701AllPixelOnEnable(void)
{
UC1701CmdWrite(UC1701_SET_DC1_EN);
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701AllPixelOnDisable(void)
{
UC1701CmdWrite(UC1701_SET_DC1);
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701DisplayOn(void)
{
UC1701CmdWrite(UC1701_SET_DC2_EN);
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701DisplayOff(void)
{
UC1701CmdWrite(UC1701_SET_DC2);
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701ScrollLineSet(unsigned char ucLine)
{
// xASSERT((ucLine <= 63) && (ucLine >= 0));
UC1701CmdWrite(UC1701_SET_SL | (ucLine & UC1701_SET_SL_MASK));
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701PMSet(unsigned char ucPM)
{
UC1701DoubleCmdWrite(UC1701_SET_PM, ucPM);
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701BRSet(unsigned char ucBR)
{
UC1701CmdWrite(UC1701_SET_BR_MASK & ucBR);
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701SegDirSet(unsigned char ucSegDir)
{
UC1701CmdWrite(UC1701_SEG_DIR_MASK & ucSegDir);
}

//*****************************************************************************
//
//
//*****************************************************************************
void UC1701ComDirSet(unsigned char ucComDir)
{
UC1701CmdWrite(UC1701_COM_DIR_MASK & ucComDir);
}

admin

赞同来自:

文件uc1701.h内容如下:


//*****************************************************************************
//
//*****************************************************************************
#ifndef __UC1701_H__
#define __UC1701_H__
#include "hw_uc1701.h"
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//
//*****************************************************************************

//*****************************************************************************
//
//
//*****************************************************************************

//*****************************************************************************
//
//
//*****************************************************************************

//*****************************************************************************
//
//
//*****************************************************************************
//*****************************************************************************

//*****************************************************************************
//
//*****************************************************************************

//*****************************************************************************
//
//*****************************************************************************

//
//

//*****************************************************************************
//
//
//*****************************************************************************

//*****************************************************************************
//
//*****************************************************************************

//
//


//*****************************************************************************
//
//
//*****************************************************************************

//*****************************************************************************
//
//
//*****************************************************************************
extern void UC1701Init(void);
extern void UC1701DataWrite(unsigned char ucData);
extern void UC1701CmdWrite(unsigned char ucCmd);
extern void UC1701DoubleCmdWrite(unsigned char ucCmd, unsigned char ucData);
extern void UC1701AddressSet(unsigned char ucPA, unsigned char ucCA);
extern void UC1701Dispaly(unsigned char ucLine, unsigned char ucRow,
unsigned char ucAsciiWord);
extern void UC1701InverseDispaly(unsigned char ucLine, unsigned char ucRow,
unsigned char ucAsciiWord);
extern void UC1701CharDispaly(unsigned char ucLine, unsigned char ucRow,
char *pcChar);
extern void UC1701ChineseDispaly(unsigned char ucLine, unsigned char ucRow,
unsigned char ucLength, char *pcChar);
extern void UC1701DisplayN(unsigned char ucLine, unsigned char ucRow,
unsigned long n);
extern void UC1701Clear(void);
extern void UC1701InverseEnable(void);
extern void UC1701InverseDisable(void);
extern void UC1701AllPixelOnEnable(void);
extern void UC1701AllPixelOnDisable(void);
extern void UC1701DisplayOn(void);
extern void UC1701DisplayOff(void);
extern void UC1701ScrollLineSet(unsigned char ucLine);
extern void UC1701PMSet(unsigned char ucPM);
extern void UC1701BRSet(unsigned char ucBR);
extern void UC1701SegDirSet(unsigned char ucSegDir);
extern void UC1701ComDirSet(unsigned char ucComDir);

//*****************************************************************************
//
//
//*****************************************************************************

//*****************************************************************************
//
//
//*****************************************************************************

//*****************************************************************************
//
//
//*****************************************************************************

//*****************************************************************************
//
//
//*****************************************************************************

//*****************************************************************************
//
//
//*****************************************************************************

//*****************************************************************************
//
//
//*****************************************************************************

//*****************************************************************************
//
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif

#endif //__UC1701_H__


文件hw_uc1701.h内容如下:


//*****************************************************************************
//
//
//*****************************************************************************



#ifndef __HW_UC1701_H__
#define __HW_UC1701_H__

//*****************************************************************************
//
//
//*****************************************************************************

//*****************************************************************************
//
//
//*****************************************************************************

//
//
#define UC1701_WRITE_DATA 0x00

//
//
#define UC1701_READ_DATA 0x00

//
//
#define UC1701_GET_STATUS 0x00

//
//
#define UC1701_SET_CA_LSB 0x00

//
//
#define UC1701_SET_CA_MSB 0x10

//
//
#define UC1701_SET_CA_MASK 0x0F

//
//
#define UC1701_SET_PC 0x28
#define UC1701_SET_PC_MASK 0x07

//
//
#define UC1701_SET_SL 0x40
#define UC1701_SET_SL_MASK 0x1F

//
//
#define UC1701_SET_PA 0xB0
#define UC1701_SET_PA_MASK 0x0F

//
//
#define UC1701_SET_PM 0x81
#define UC1701_SET_PM_MASK 0x3F

//
//
#define UC1701_SET_DC1 0xA4
#define UC1701_SET_DC1_EN 0xA5

//
//
#define UC1701_SET_DC0 0xA6
#define UC1701_SET_DC0_EN 0xA7

//
//
#define UC1701_SET_DC2 0xAE
#define UC1701_SET_DC2_EN 0xAF

//
//
#define UC1701_SET_LC21 0xC0
#define UC1701_SET_LC21_MASK 0x06

//
//
#define UC1701_SET_SC 0xE2

//
//
#define UC1701_SET_NOP 0xE3

//
//
#define UC1701_SET_BR_MASK 0xA3
#define UC1701_SET_BR_7 0xA2
#define UC1701_SET_BR_9 0xA3

//
//
#define UC1701_SEG_DIR_MASK 0xA1
#define UC1701_SEG_DIR_NORMAL 0xA0
#define UC1701_SET_DIR_INVERSE 0xA1

//
//
#define UC1701_COM_DIR_MASK 0xC8
#define UC1701_COM_DIR_NORMAL 0xC0
#define UC1701_COM_DIR_INVERSE 0xC8

//
//
#define UC1701_READ_DATA_CMD 0xFF
#define UC1701_READ_DATA_MASK 0xFF

//
//
#define UC1701_GET_STATUS_CMD 0xFE
#define UC1701_READ_DATA_MASK 0xFF



//*****************************************************************************
//
//
//*****************************************************************************

//*****************************************************************************
//
//
//*****************************************************************************

//
//
#define UC1701_SPI_8BIT 0

//*****************************************************************************
//
//
//*****************************************************************************

//*****************************************************************************
//
//
//*****************************************************************************

#endif // __HW_UC1701_H__


以上的程序无需解释了吧......
用的时候看uc1701的资料,如果用的事SPI操作,那么只能写不能读,
所以上面SPI只用了translate发送功能...
使用的时候在main中加入


#include "uc1701.h"

然后定义一个例子


/[url=16x16,汉字]i[/url][/i]/
char HZ[]={
0x20,0x24,0x2C,0x35,0xE6,0x34,0x2C,0x24,0x00,0xFC,0x24,0x24,0xE2,0x22,0x22,0x00,
0x21,0x11,0x4D,0x81,0x7F,0x05,0x59,0x21,0x18,0x07,0x00,0x00,0xFF,0x00,0x00,0x00,
0x40,0x20,0x10,0x0C,0xE3,0x22,0x22,0x22,0xFE,0x22,0x22,0x22,0x22,0x02,0x00,0x00,
0x04,0x04,0x04,0x04,0x07,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x04,0x04,0x00,
0x70,0x00,0xFF,0x08,0xB0,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0xF8,0x80,0x80,0x00,
0x00,0x00,0xFF,0x00,0x80,0x40,0x30,0x0E,0x01,0x06,0x08,0x30,0x60,0xC0,0x40,0x00,
0x00,0x00,0x40,0xFC,0x44,0x44,0x44,0x46,0xFA,0x42,0x43,0x43,0x42,0x40,0x00,0x00,
0x00,0x20,0x18,0x0C,0x07,0x12,0x20,0x40,0x3F,0x00,0x00,0x02,0x0C,0x38,0x10,0x00};
//*****************************************************************************
//
//
//*****************************************************************************
void UC1701DispalyExample(void)
{

UC1701Init();

UC1701Clear();
UC1701CharDispaly(0, 1, "I love stm32cube.com?");
UC1701CharDispaly(1, 1, "Yes,I love!");
UC1701ChineseDispaly(3, 1, 4, (char *)&HZ);
UC1701DisplayN(2,1,5201314);
HAL_Delay(1000);
}

在main()函数初始化完成SPI之后调用


UC1701DispalyExample();


欢迎用到这个驱动的朋友测试下

男朋友

赞同来自:

不错  正在找这个

thxixi

赞同来自:

你好,源程序哪里可以下载??我编译有好多错误啊

pengzaiqin - 90后电子设计

赞同来自:

不错

孟津精益电器维修

赞同来自:

你好,这个可以分享一下吗?谢谢

广州贺工

赞同来自:

正在找这个,求分享。

要回复问题请先登录注册