下面代码是在x4412板子上做的,Tiny4412最新板子背光打不开。
#include "regs.h"
#define RGB888(r, g, b) (((r) << 16) | ((g) << 8) | (b) )
void clean_screen(unsigned long *fb, int w, int h)
{
// green
int i, j;
for (i = 0; i < h; i ++) {
for (j = 0; j < w; j ++) {
fb[i * w + j] = RGB888(0, 255, 0);
}
}
// blue
for (i = 200; i < h-200; i ++) {
for (j = 200; j < w-300; j ++) {
fb[i * w + j] = RGB888(0, 0, 255);
}
}
}
void lcd_init(unsigned long fb)
{
//Blacklight
GPD0CON &= ~(0xf<<0);
GPD0CON |= (0x1<<0);
GPD0PUD &= ~(0x3<<0);
GPD0PUD |= (0x2<<0);
GPD0DAT &= ~(0x1<<0);
GPD0DAT |= (0x0<<0);
//Blacklight
GPX3CON &= ~(0xf<<20);
GPX3CON |= (0x1<<20);
GPX3PUD &= ~(0x3<<10);
GPX3PUD |= (0x2<<10);
GPX3DAT &= ~(0x1<<5);
GPX3DAT |= (0x1<<5);
/*
*<Exyons 4412 datasheet pg138 pg141 pg144 pg147>
*
* GPF0CON : [31:0] : 0x2
* GPF1CON : [31:0] : 0x2
* GPF2CON : [31:0] : 0x2
* GPF3CON : [31:0] : 0x2
* */
GPF0CON = 0x22222222;
GPF1CON = 0x22222222;
GPF2CON = 0x2222
#include "regs.h"
#define RGB888(r, g, b) (((r) << 16) | ((g) << 8) | (b) )
void clean_screen(unsigned long *fb, int w, int h)
{
// green
int i, j;
for (i = 0; i < h; i ++) {
for (j = 0; j < w; j ++) {
fb[i * w + j] = RGB888(0, 255, 0);
}
}
// blue
for (i = 200; i < h-200; i ++) {
for (j = 200; j < w-300; j ++) {
fb[i * w + j] = RGB888(0, 0, 255);
}
}
}
void lcd_init(unsigned long fb)
{
//Blacklight
GPD0CON &= ~(0xf<<0);
GPD0CON |= (0x1<<0);
GPD0PUD &= ~(0x3<<0);
GPD0PUD |= (0x2<<0);
GPD0DAT &= ~(0x1<<0);
GPD0DAT |= (0x0<<0);
//Blacklight
GPX3CON &= ~(0xf<<20);
GPX3CON |= (0x1<<20);
GPX3PUD &= ~(0x3<<10);
GPX3PUD |= (0x2<<10);
GPX3DAT &= ~(0x1<<5);
GPX3DAT |= (0x1<<5);
/*
*<Exyons 4412 datasheet pg138 pg141 pg144 pg147>
*
* GPF0CON : [31:0] : 0x2
* GPF1CON : [31:0] : 0x2
* GPF2CON : [31:0] : 0x2
* GPF3CON : [31:0] : 0x2
* */
GPF0CON = 0x22222222;
GPF1CON = 0x22222222;
GPF2CON = 0x2222