rt-thread/bsp/mini4020/lcdc.c

112 lines
2.4 KiB
C
Raw Normal View History

#include "lcdc.h"
#include <sep4020.h>
#define writel(DATA,ADDRESS) *((volatile rt_off_t *) ADDRESS)= DATA;
unsigned long pVideoBuffer;
rt_err_t sep4020_lcd_init(void)
{
pVideoBuffer =(unsigned long) rt_malloc(LCDWIDTH*LCDHEIGHT*2);
*(RP)GPIO_PORTC_SEL |= 0X0008; //Portc8<63><38><EFBFBD><EFBFBD>Ϊͨ<CEAA>ÿ<EFBFBD>
*(RP)GPIO_PORTC_DIR &= (~0X0008); //Portc8<63><38><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
*(RP)GPIO_PORTC_DATA |= 0X0008; //Portc8<63><38><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>ƽ
writel(0x00000000,LCDC_LECR); //<2F><><EFBFBD><EFBFBD>LCDC
writel(pVideoBuffer,LCDC_SSA); //lcd<63><64><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
writel(YMAX | XMAX,LCDC_SIZE);
writel(TFT|COLOR|PBSIZE|BPIX|PIXPOL|FLMPOL|LPPOL|CLKPOL|OEPOL|END_SEL|ACD_SEL|ACD|PCD,LCDC_PCR);
writel(H_WIDTH|H_WAIT_1|H_WAIT_2,LCDC_HCR);
writel(V_WIDTH|PASS_FRAME_WAIT|V_WAIT_1|V_WAIT_2,LCDC_VCR);
writel(SCR|CC_EN|PW,LCDC_PWMR);
writel(BL|HM|TM,LCDC_DMACR);
writel(0x00000001,LCDC_LECR); //ʹ<><CAB9>LCDC
writel(0x00000000,LCDC_LCDISREN); //<2F>ж<EFBFBD><D0B6>ڼ<EFBFBD><DABC><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ã<EFBFBD><C3A3><EFBFBD>LCD֮<44><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʱ
return RT_EOK;
}
void lcd_set_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
{
unsigned short p;
/* get color pixel */
p = rtgui_color_to_565p(*c);
*(unsigned short *)(pVideoBuffer+2*y*LCDWIDTH+2*x)=p;
}
void lcd_get_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
{
*c = rtgui_color_from_565p( *(unsigned short *)(pVideoBuffer+2*y*LCDWIDTH+2*x));
}
void lcd_draw_hline(rtgui_color_t *c, rt_base_t x1, rt_base_t x2, rt_base_t y)
{
unsigned short p;
/* get color pixel */
p = rtgui_color_to_565p(*c);
while (x1 < x2)
{
*(unsigned short *)(pVideoBuffer+2*y*LCDWIDTH+2*x1)=p;
x1 ++;
}
}
void lcd_draw_vline(rtgui_color_t *c, rt_base_t x, rt_base_t y1, rt_base_t y2)
{
unsigned short p;
/* get color pixel */
p = rtgui_color_to_565p(*c);
while (y1 < y2)
{
*(unsigned short *)(pVideoBuffer+2*y1*LCDWIDTH+2*x)=p;
y1 ++;
}
}
void lcd_draw_raw_hline(rt_uint8_t *pixels, rt_base_t x1, rt_base_t x2, rt_base_t y)
{
rt_uint16_t *ptr;
/* get pixel */
ptr = (rt_uint16_t*) pixels;
while (x1 < x2)
{
*(unsigned short *)(pVideoBuffer+2*y*LCDWIDTH+2*x1)=*ptr;
x1 ++;
ptr ++;
}
}
void lcd_update(rtgui_rect_t *rect)
{
/* nothing for none-DMA mode driver */
}
rt_uint8_t * lcd_get_framebuffer(void)
{
return RT_NULL; /* no framebuffer driver */
}