|
void oled_init(void)
{
*AT91C_PIOA_PER = OLED_DC|OLED_RES;
*AT91C_PIOA_OER = OLED_DC|OLED_RES;
*AT91C_PIOA_MDER = OLED_DC|OLED_RES;
RESET_ON();
for(i=0;i<500;i++);
RESET_OFF();
oled_write_cmd(SWRESET);
oled_write_cmd(COMLCK);
oled_write_data(0x12);
oled_write_cmd(COMLCK);
oled_write_data(0xb3);
oled_write_cmd(SLPIN);
oled_write_cmd(CASET);//set column address
oled_write_data(0x00);
oled_write_data(0x7f);
oled_write_cmd(RASET);//set raw address
oled_write_data(0x00);
oled_write_data(0x7f);
oled_write_cmd(SDCOSCF);//set clock
oled_write_data(0x1a);
oled_write_cmd(MADCTL); //memory access control
oled_write_data(0x08);
oled_write_data(0x00);
oled_write_cmd(SETMUX); //set mux ratio
oled_write_data(0x7f);
oled_write_cmd(SETDO); //set display offset and when MADCTL bit7 = 0,display start line is seted
oled_write_data(0x00);
oled_write_cmd(GPIO); //set GPIO
oled_write_data(0x00);
oled_write_cmd(COLMOD);
oled_write_data(0x05); //(101)b :65k pixel color 16bit/pixel
oled_write_cmd(TEON);
oled_write_data(0x00);
oled_write_cmd(FUSEL);
oled_write_data(0x03);
oled_write_cmd(0xba);
oled_write_data(0x80);
oled_write_cmd(0xbb);
oled_write_data(0x80);
oled_write_cmd(0xbc);
oled_write_data(0x80);
oled_write_cmd(SETLUM);
oled_write_data(0xf0);
oled_write_cmd(LINGLUT);
oled_write_cmd(GLUT);
for(i=0;i<96;i++)
{
oled_write_data(Gamma_Table); //Gamma_Table
}
oled_write_cmd(PHLEN);
oled_write_data(0x32);
oled_write_cmd(VPSET);
oled_write_data(0x09);
oled_write_cmd(SECPLEN);
oled_write_data(0x0B);
oled_write_cmd(SSPS);
oled_write_data(0x03);
oled_write_cmd(SETVCOMH);
oled_write_data(0x04);
oled_write_cmd(DISPON);
oled_write_cmd(INVOFF);
oled_write_cmd(NORON);
oled_write_cmd(RAMWR);
oled_write_cmd(SLPOUT);
}
void oled_write_cmd(char cmd)
{
CMD_ON();
spi_send(cmd);
DATA_ON();
}
void oled_write_data(char data)
{
DATA_ON();
spi_send(data);
DATA_ON();
}
void Oled_SetRowColumn_Lcd(RECT *rect)//设置显示范围
{
oled_write_cmd(CASET); //column set
oled_write_data(0x00);
oled_write_data(0x7f);
oled_write_cmd(RASET); //row set
oled_write_data(0x00);
oled_write_data(0x7f);
oled_write_cmd(RAMWR); // start memory write
}
void oled_show_wh(void) //全部显示白色
{
int y,x;
RECT pp;
pp.h = 127; //窗口测试
pp.w= 127;
pp.x = 0;
pp.y=0;
Oled_SetRowColumn_Lcd(&pp);
for(y=0;y<128;y++)
{
for(x=0;x<128;x++)
{
oled_write_data(0xff);
oled_write_data(0xff);
}
}
oled_write_cmd(NOP); // end memory write
}
用示波器测量,SPI数据是能够正常发送的。其中CS,D/C,的时序也是正常。
点亮后,能够控制 ALL PIXES ON/OFF。
但是想要刷GDDRAM的数据,却没有响应,只是显示雪花状态。
对了,屏幕的尺寸大小是128×128的
以下附上芯片资料 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|