资源简介
这是128*32OLED点阵屏驱动,含GUI移植部分
代码片段和文件信息
/*******************************************************************************
* File Name : Motor.c
* Author : baohua disp Technology
* Date First Issued : 08/27/2009
* Description : Step Motor Driver
********************************************************************************/
#include “inc.h“
#include “disp.h“
/******************Here is for driver************************************/
#define LCD_XSIZE_PHYS 132
#define LCD_YSIZE_PHYS 32
#define LCD_YSIZE_BITY 4
#define XY2OFF(x y) (x + 4 + (y >> 3) * LCD_XSIZE_PHYS)
#define Max_Column 132
#define Max_Row 32
#define Brightness 0xBF
//#define SCLK(a) GPIO_WriteBit(GPIOA GPIO_Pin_15 a)
//#define SDIN(a) GPIO_WriteBit(GPIOA GPIO_Pin_15 a)
#define RES(a) GPIO_WriteBit(GPIOC GPIO_Pin_11 a)
#define CS(a) GPIO_WriteBit(GPIOC GPIO_Pin_10 a)
#define DC(a) GPIO_WriteBit(GPIOC GPIO_Pin_12 a)
#define E(a) GPIO_WriteBit(GPIOA GPIO_Pin_11 a)
#define RW(a) GPIO_WriteBit(GPIOA GPIO_Pin_12 a)
#define RD_oled(a) GPIO_WriteBit(GPIOA GPIO_Pin_11 a)
#define WR_oled(a) GPIO_WriteBit(GPIOA GPIO_Pin_12 a)
UINT8 Cache[132 * 4];
UINT32 LCD_Adr = 0;
void oled_setdata(u8 data)
{
u8 temp = 0;
temp = temp | data;
GPIO_WriteBit(GPIOC GPIO_Pin_3 (temp&0x01));
GPIO_WriteBit(GPIOC GPIO_Pin_2 ((temp>>1)&0x01));
GPIO_WriteBit(GPIOC GPIO_Pin_1 ((temp>>2)&0x01));
GPIO_WriteBit(GPIOC GPIO_Pin_0 ((temp>>3)&0x01));
GPIO_WriteBit(GPIOC GPIO_Pin_4 ((temp>>4)&0x01));
GPIO_WriteBit(GPIOC GPIO_Pin_5 ((temp>>5)&0x01));
GPIO_WriteBit(GPIOC GPIO_Pin_6 ((temp>>6)&0x01));
GPIO_WriteBit(GPIOC GPIO_Pin_7 ((temp>>7)&0x01));
}
void Write_Command(unsigned char Data)
{
RW(0);
oled_setdata(Data);
DC(0);
CS(0);
WR_oled(0);
WR_oled(1);
CS(1);
DC(1);
RW(0);
}
void Write_Data(unsigned char Data)
{ RW(0);
oled_setdata(Data);
DC(1);
CS(0);
WR_oled(0);
WR_oled(1);
CS(1);
DC(1);
RW(0);
}
void Set_Start_Column(unsigned char d)
{
Write_Command(0x00+d%16); // Set Lower Column Start Address for Page Addressing Mode
// Default => 0x00
Write_Command(0x10+d/16); // Set Higher Column Start Address for Page Addressing Mode
// Default => 0x10
}
void Set_Addressing_Mode(unsigned char d)
{
Write_Command(0x20); // Set Memory Addressing Mode
Write_Command(d); // Default => 0x02
// 0x00 => Horizontal Addressing Mode
// 0x01 => Vertical Addressing Mode
// 0x02 => Page Addressing Mode
}
void Set_Column_Address(unsigned char a unsigned char b)
{
Write_Command(0x21); // Set Column Address
Write_Command(a); // Default => 0x00 (Column Start Address)
Write_Command(b); // Default => 0x83 (Column End Address)
}
void Set_Page_Address(unsigned char a unsigned char b)
{
Write_Command(0x22); // Set Page Address
Write_Command(a); /
- 上一篇:计算机操作系统2009-2015考研真题
- 下一篇:键盘记录器klogger
评论
共有 条评论