likewu 发表于 2013-2-19 10:27:07

在skyeye1.3.5里,at91的lcd是通过什么接口连接的?

在skyeye1.3.5里,at91的lcd是通过什么接口连接的?
对lcd控制器用什么io地址输出数据?

ksh 发表于 2013-2-19 22:16:58

在配置文件中,配置lcd类型为ep7312如下:
lcd: type=ep7312,mod=gtk

在ep7312的lcd模拟文件device/lcd/dev_lcd_ep7312.c, 相关代码如下:
32 static struct device_default_value ep7312_lcd_def[] = {
33         /* name         base      size   interrupt array */
34         {"ep7312", 0x800002c0, 0x4, {0, 0, 0, 0}},
35         {"at91", 0xffc002c0, 0x4, {0, 0, 0, 0}},
36         {NULL},
37 };

如35行,at91的io基地址为0xffc002c0

likewu 发表于 2013-2-20 23:55:21

用freepascal写了个at91的程序,贴出来供大家参考。

{for at91sam7x256
$fffd001c is at91 uart0 address}

program tled7;

//uses at91sam7x256;

const
BOARD_LBEN = (1 shl 12);
SPI0CS1 = (1 shl 13);
SPI0CS2 = (1 shl 14);
SPI0CS3 = (1 shl 15);
MOSI0 = (1 shl 16);
MISO0 = (1 shl 17);
SCLK0 = (1 shl 18 );
AT91C_SPI_PCS = ($F shl 16);
AT91C_SPI_SPIEN = ($1 shl 0);
AT91C_SPI_TXEMPTY = ($1 shl 9);
AT91C_SPI_TDRE = ($1 shl 1);
AT91C_SPI_MSTR = ($1 shl 0); // (SPI) Master/Slave Mode
AT91C_SPI_MODFDIS = ($1 shl 4); // (SPI) Mode Fault Detection
// -------- PDC_PTCR : (PDC Offset: 0x20) PDC Transfer Control Register --------
AT91C_PDC_RXTEN = ($1 shl 0); // (PDC) Receiver Transfer Enable
AT91C_PDC_RXTDIS = ($1 shl 1); // (PDC) Receiver Transfer Disable
AT91C_PDC_TXTEN = ($1 shl 8 ); // (PDC) Transmitter Transfer Enable
AT91C_PDC_TXTDIS = ($1 shl 9); // (PDC) Transmitter Transfer Disable

type
AT91PS_SPI = record
          CR,         // Control Register
          MR,         // Mode Register
          RDR,         // Receive Data Register
          TDR,         // Transmit Data Register
          SR,         // Status Register
          IER,         // Interrupt Enable Register
          IDR,         // Interrupt Disable Register
          IMR: dword;         // Interrupt Mask Register
          Reserved0: array of dword;         //
          CSR: array of dword;         // Chip Select Register
          Reserved1: array of dword;         //
          RPR,         // Receive Pointer Register
          RCR,         // Receive Counter Register
          TPR,         // Transmit Pointer Register
          TCR,         // Transmit Counter Register
          RNPR,         // Receive Next Pointer Register
          RNCR,         // Receive Next Counter Register
          TNPR,         // Transmit Next Pointer Register
          TNCR,         // Transmit Next Counter Register
          PTCR,         // PDC Transfer Control Register
          PTSR: dword;         // PDC Transfer Status Register
end;

AT91PS_PDC = record
          RPR,         // Receive Pointer Register
          RCR,         // Receive Counter Register
          TPR,         // Transmit Pointer Register
          TCR,         // Transmit Counter Register
          RNPR,         // Receive Next Pointer Register
          RNCR,         // Receive Next Counter Register
          TNPR,         // Transmit Next Pointer Register
          TNCR,         // Transmit Next Counter Register
          PTCR,         // PDC Transfer Control Register
          PTSR: dword;         // PDC Transfer Status Register
end;
      
var
//        vidmem: PChar = PChar($E000C01C);
//        i: Integer;
UART0_SCR: DWord absolute $fffd001c;
        pSPI0: AT91PS_SPI absolute $fffe0000;
        pPDC: AT91PS_PDC absolute $fffe0100;
        AT91PS_SPI_CSR0: DWord absolute $fffe0030;
       
        SYSCON1: DWord absolute $ffc00100;
LCDCON: DWord absolute $ffc002c0;                //* LCD Control register ---------------------------- */
PALLSW: DWord absolute $ffc00540;                //* Least-significant 32-bit word of LCD Palette reg. */
PALMSW: DWord absolute $ffc00580;                //* Most-significant 32-bit word of LCD Palette reg. */
VBUFSIZ: DWord = $00001fff;        //* Video buffer size (bits/128-1) */
LINELEN: DWord = $0007e000;        //* Line length (pix/16-1) */
LINELEN_SHIFT: DWord = 13;
        PIXPSC: DWord = $01f80000;        //* Pixel prescale (526628/pixels-1) */
PIXPSC_SHIFT: DWord = 19;
ACPSC: DWord = $3e000000;        //* AC prescale */
ACPSC_SHIFT: DWord = 25;
GSEN: DWord = $40000000;        //* Grayscale enable (0: monochrome) */
        GSMD: DWord = $80000000;        //* Grayscale mode (0: 2 bit, 1: 4 bit) */
        FBADDR: DWord absolute $ffc01000;
        LCDEN: DWord = $00001000;        //* LCD enable */

procedure LCD_Delayus(ius: cardinal);
var
i: integer;
begin
   while (ius>0) do
   begin
      for i:=0 to 6 do ;
      dec(ius);
   end;
end;

procedure LCD_Delayms(ims: cardinal);
begin
   while (ims>0) do
   begin
      LCD_Delayus(1000);
      dec(ims);
   end;
end;

procedure LCD_ChipDisable;
begin
   AT91C_PMC_PCER:= 1 shl AT91C_PIOB_IDR;
   
   AT91C_PIOB_SODR:= $ff;
   
   AT91C_PIOB_PER:= $ff;
   AT91C_PIOB_OER:= $ff;
   
   LCD_Delayus(10);
end;

procedure SPI_Write(spi: AT91PS_SPI; npcs: cardinal; data: byte);
begin
// Discard contents of RDR register
//volatile unsigned int discard = spi->SPI_RDR;

// Send data
while ((spi.SR and AT91C_SPI_TXEMPTY) = 0) do ;
spi.TDR:= data or ((not (1 shl npcs) and $F) shl 16);
while ((spi.SR and AT91C_SPI_TDRE) = 0) do ;
end;

procedure LCD_Reset;
var
i, j: cardinal;
linelin: DWord;
vbufsize: DWord;
p: ^DWord;
begin
linelin := 320 * 3 div 16 - 1;
vbufsize := 240 * 320 * 3 * 4 div 128 - 1;

AT91C_US0_RPR:= AT91C_US0_RPR and (not LCDEN);//关闭lcd

//LCDCON:= (( LINELEN shl LINELEN_SHIFT) +VBUFSIZ);
//LCDCON:= ( linelin shl LINELEN_SHIFT) + vbufsize;
LCDCON:= $e60f7c1f; //1/4vga

PALLSW:= $76543210;
PALMSW:= $fedcba98;
FBADDR:= $c0000000;

AT91C_US0_RPR:= AT91C_US0_RPR or LCDEN;//打开lcd

//LCD_Delayms(15);

p:= Pointer(FBADDR);

for j:=0 to 20 do
          for i:=0 to 320*240-1 do
          //for i:=0 to 32*24-1 do
          begin
                  //UART0_SCR:= $55;
                  //LCD_Delayms(3);
                  if (i mod 3 = 0) then
              p^:= $33
          else if (i mod 6 = 0) then
              p^:= $66
          else
              p^:= $9e;
             
          inc(p);
          end;
end;

var
i: integer;
begin
UART0_SCR:= $44;
UART0_SCR:= $45;

LCD_Reset;

{for i:= 0 to slen do
begin
    SPI_Write(pSPI0, 3, sdata);
end;}
//SPI_Write(pSPI0, 3, $46);

UART0_SCR:= $48;
UART0_SCR:= $49;
end.

这个程序在skyeye里lcd窗口可以显示出来,但是显示颜色还不行。

[ 本帖最后由 likewu 于 2013-2-20 23:56 编辑 ]

David_yu 发表于 2013-2-26 17:38:39

你可以将源码、编译环境、skyeye.config文件打包贴出来,让大家用skyeye运行一下,互相学习交流。

likewu 发表于 2013-3-5 14:01:20

编译文件build-tled7.bat,编译环境fpc2.7

@echo off

set path=%path%;E:\Project\FPC\arm-eabi\bin

C:\codetyphon\fpc\bin\i386-win32\ppcrossarm @armembedded27.cfg -Parm-Tembedded -Cparmv4t -Wpat91sam7x256 -XParm-none-eabi-   tled7.lpr

rem C:\codetyphon\fpc\bin\i386-win32\arm-embedded-objcopy -O binary tled7.elf tled7.bin

rem C:\codetyphon\fpc\bin\i386-win32\readelf -a tled7.elf > tled7.elf.txt

echo step 2----------------
rem E:\Project\FPC\arm-eabi\bin\arm-none-eabi-ld --emit-relocs --strip-all -N -p -X -Tskyeye.ld -o tled7arm at91sam7x256.o system.o tled7.o
rem C:\codetyphon\fpc\bin\i386-win32\readelf -a tled7arm > tled7arm.txt


if not errorlevel 1 goto end

pause

:end
@echo on

likewu 发表于 2013-3-5 14:02:26

skyeye.conf配置文件,skyeye1.3.5r1

#skyeye config file sample
arch:arm
cpu: arm7tdmi

#mach: lpc
mach: at91

mem_bank: map=M, type=RW, addr=0x00000000, size=0x00004000
mem_bank: map=M, type=RW, addr=0x01000000, size=0x00400000
mem_bank: map=M, type=R,addr=0x01400000, size=0x00400000
mem_bank: map=M, type=RW, addr=0x02000000, size=0x00400000
mem_bank: map=M, type=RW, addr=0x02400000, size=0x00008000
mem_bank: map=M, type=RW, addr=0x04000000, size=0x00400000
mem_bank: map=M, type=RW, addr=0xc0000000, size=0x00100000
#mem_bank: map=I, type=RW, addr=0xe0000000, size=0x20000000
mem_bank: map=I, type=RW, addr=0xf0000000, size=0x10000000

#mem_bank: map=M, type=RW, addr=0x10000000, size=0x00000800, file=./loader.bin,boot=yes

#uart:mod=term
uart:mod=stdio
#uart: fd_in=/dev/ttyS0, fd_out=/dev/ttyS0
#则你可以使用minicon来监听COM1口来进行数据交换
uart_16550:base=0xd1000000, length=0x100, irq=0x20
#net: state = on, mac=0:4:3:2:1:f, ethmod=tuntap, hostip=10.0.0.1

#lcd:state=on
#lcd: type=at91, mod=gtk
lcd: type=ep7312,mod=gtk

#dbct: state=on

#instr_log: logon=0, logfile=./sk1.log, start=0, end=200000

likewu 发表于 2013-3-5 14:16:39

elf,bin,hex问件

这是我编译好的执行文件,大家可以测试下。
页: [1]
查看完整版本: 在skyeye1.3.5里,at91的lcd是通过什么接口连接的?