update mini4020 project

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2185 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
dzzxzz@gmail.com
2012-06-26 03:30:07 +00:00
parent 594ccd799a
commit aea59143b5
18 changed files with 468 additions and 420 deletions
+9 -6
View File
@@ -1,9 +1,12 @@
import rtconfig
Import('RTT_ROOT')
from building import *
src = Glob('*.c')
CPPPATH = [RTT_ROOT + '/bsp/mini4020']
group = DefineGroup('Startup', src, depend = [''], CPPPATH = CPPPATH)
cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
Return('group')
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))
Return('objs')
+9
View File
@@ -0,0 +1,9 @@
from building import *
cwd = GetCurrentDir()
src = Glob('*.c')
CPPPATH = [cwd, str(Dir('#'))]
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
@@ -1,7 +1,7 @@
/*
* File : application.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
* COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
@@ -14,8 +14,9 @@
*/
/**
* @addtogroup mini2440
* @addtogroup mini4020
*/
/*@{*/
#include <board.h>
@@ -27,13 +28,15 @@
#include <dfs_fs.h>
#include <dfs_posix.h>
#endif
#ifdef RT_USING_RTGUI
#include <rtgui/rtgui.h>
extern void radio_rtgui_init(void);
#endif
#define RT_INIT_THREAD_STACK_SIZE (2*1024)
void rt_init_thread_entry(void* parameter)
void rt_init_thread_entry(void *parameter)
{
int fd;
rt_uint32_t sz;
@@ -57,21 +60,21 @@ void rt_init_thread_entry(void* parameter)
sz = write(fd,"Hello RT-Thread!",sizeof("Hello RT-Thread!"));
if(sz!=0)
if (sz != 0)
{
rt_kprintf("written %d\n",sz);
}
else
rt_kprintf("haven't written\n");
lseek(fd,0,SEEK_SET);
lseek(fd, 0, SEEK_SET);
sz = read(fd,buffer,sizeof(buffer));
sz = read(fd, buffer, sizeof(buffer));
if(sz!=0)
if (sz != 0)
{
rt_kprintf("READ %d:",sz);
while(sz--)
while (sz--)
rt_kprintf("%c",buffer[sz]);//opposite
rt_kprintf("\n");
}
@@ -86,9 +89,9 @@ void rt_init_thread_entry(void* parameter)
#endif
}
void rt_led_thread_entry(void* parameter)
void rt_led_thread_entry(void *parameter)
{
/*
/*
while (1)
{
count++;
@@ -103,12 +106,11 @@ void rt_led_thread_entry(void* parameter)
}
int rt_application_init()
int rt_application_init(void)
{
rt_thread_t init_thread;
rt_thread_t led_thread;
init_thread = rt_thread_create("init",
rt_init_thread_entry, RT_NULL,
RT_INIT_THREAD_STACK_SIZE, 8, 20);
@@ -121,6 +123,7 @@ int rt_application_init()
if (led_thread != RT_NULL)
rt_thread_startup(led_thread);
return 0;
}
@@ -1,3 +1,16 @@
/*
* File : application.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 - 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
*/
#include <rthw.h>
#include <rtthread.h>
+19
View File
@@ -0,0 +1,19 @@
from building import *
cwd = GetCurrentDir()
src = Glob('*.c')
# remove no need file.
if GetDepend('RT_USING_LWIP') == False:
SrcRemove(src, 'dm9161.c')
if GetDepend('RT_USING_DFS') == False:
SrcRemove(src, 'sdcard.c')
if GetDepend('RT_USING_RTGUI') == False:
SrcRemove(src, 'lcd.c')
SrcRemove(src, 'lcdc.c')
CPPPATH = [cwd]
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
@@ -1,7 +1,7 @@
/*
* File : board.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009 RT-Thread Develop Team
* COPYRIGHT (C) 2006 - 2012 RT-Thread Develop Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
@@ -12,6 +12,7 @@
* 2009-05-16 Bernard first implementation
* 2010-10-5 Wangmeng sep4020 implementation
*/
#include <rthw.h>
#include <rtthread.h>
@@ -30,7 +31,6 @@ struct serial_device uart0 =
RT_NULL
};
/**
* This function will handle rtos timer
*/
@@ -41,7 +41,7 @@ void rt_timer_handler(int vector)
/*Clear timer interrupt*/
clear_int = *(RP)TIMER_T1ISCR;
*(RP)TIMER_T1ISCR=clear_int;
*(RP)TIMER_T1ISCR=clear_int;
}
/**
@@ -50,15 +50,13 @@ void rt_timer_handler(int vector)
void rt_serial_handler(int vector)
{
//rt_kprintf("in rt_serial_handler\n");
rt_int32_t stat = *(RP)UART0_IIR ;
rt_int32_t stat = *(RP)UART0_IIR ;
UNUSED char c;
/*Received data*/
if(((stat & 0x0E) >> 1) == 0x02)
if (((stat & 0x0E) >> 1) == 0x02)
{
rt_hw_serial_isr(&uart0_device);
rt_hw_serial_isr(&uart0_device);
}
else
{
@@ -67,6 +65,7 @@ void rt_serial_handler(int vector)
c = uart0.uart_device->dlbl_fifo.rxfifo;
}
}
/**
* This function will init led on the board
*/
@@ -82,10 +81,10 @@ static void rt_hw_board_led_init(void)
/**
* This function will init timer4 for system ticks
*/
void rt_hw_timer_init()
{
/*Set timer1*/
*(RP)TIMER_T1LCR = 880000;
void rt_hw_timer_init(void)
{
/*Set timer1*/
*(RP)TIMER_T1LCR = 880000;
*(RP)TIMER_T1CR = 0x06;
rt_hw_interrupt_install(INTSRC_TIMER1, rt_timer_handler, RT_NULL);
@@ -93,7 +92,7 @@ static void rt_hw_board_led_init(void)
/*Enable timer1*/
*(RP)TIMER_T1CR |= 0x01;
}
}
/**
* This function will handle init uart
@@ -128,9 +127,9 @@ void rt_hw_uart_init(void)
&uart0);
}
void rt_hw_board_init()
void rt_hw_board_init(void)
{
/* initialize uart */
/* initialize uart */
rt_hw_uart_init();
// rt_hw_board_led_init();
rt_hw_timer_init();
@@ -143,9 +142,11 @@ void rt_hw_serial_putc(const char c)
to be polite with serial console add a line feed
to the carriage return character
*/
if (c=='\n')rt_hw_serial_putc('\r');
if (c=='\n')
rt_hw_serial_putc('\r');
while (!((*(RP)UART0_LSR) & 0x40));
*(RP)(UART0_BASE) = c;
}
@@ -154,7 +155,7 @@ void rt_hw_serial_putc(const char c)
*
* @param str the displayed string
*/
void rt_hw_console_output(const char* str)
void rt_hw_console_output(const char *str)
{
while (*str)
{
@@ -1,7 +1,7 @@
/*
* File : board.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
* COPYRIGHT (C) 2009 - 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
File diff suppressed because it is too large Load Diff
@@ -1,3 +1,16 @@
/*
* File : dm9161.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 - 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
*/
#ifndef __DM9000_H__
#define __DM9000_H__
+74
View File
@@ -0,0 +1,74 @@
/*
* File : lcd.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 - 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
*/
#include "lcdc.h"
#include "rtthread.h"
#include "board.h"
#include <rtgui/rtgui.h>
#include <rtgui/driver.h>
#include <rtgui/rtgui_server.h>
#include <rtgui/rtgui_system.h>
extern rt_err_t sep4020_lcd_init(void);
extern unsigned long pVideoBuffer;
struct rtgui_graphic_driver _rtgui_lcd_driver;
struct rtgui_graphic_driver_ops _rtgui_graphic_driver_ops;
void radio_rtgui_init(void)
{
rtgui_rect_t rect;
rtgui_system_server_init();
/* register dock panel */
rect.x1 = 0;
rect.y1 = 0;
rect.x2 = 320;
rect.y2 = 25;
rtgui_panel_register("info", &rect);
rtgui_panel_set_nofocused("info");
/* register main panel */
rect.x1 = 0;
rect.y1 = 25;
rect.x2 = 320;
rect.y2 = 240;
rtgui_panel_register("main", &rect);
rtgui_panel_set_default_focused("main");
_rtgui_graphic_driver_ops.set_pixel=lcd_set_pixel;
_rtgui_graphic_driver_ops.get_pixel=lcd_get_pixel;
_rtgui_graphic_driver_ops.draw_hline=lcd_draw_hline;
_rtgui_graphic_driver_ops.draw_vline=lcd_draw_vline;
_rtgui_graphic_driver_ops.draw_raw_hline=lcd_draw_raw_hline;
_rtgui_lcd_driver.bits_per_pixel = 16;
_rtgui_lcd_driver.width = 320;
_rtgui_lcd_driver.height = 240;
_rtgui_lcd_driver.ops = &_rtgui_graphic_driver_ops;
//_rtgui_lcd_driver.screen_update = lcd_update;
//_rtgui_lcd_driver.get_framebuffer = lcd_get_framebuffer;
sep4020_lcd_init();
rt_memset((char*)pVideoBuffer,0xff,320*240*2);
//rt_memcpy((char*)pVideoBuffer,pic,320*240*2); //TESTING IMAGE
//´Ë´¦´ýÐÞÕý
/* add lcd driver into graphic driver */
// rtgui_graphic_driver_add(&_rtgui_lcd_driver);
}
@@ -1,54 +1,58 @@
/*
* File : lcdc.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 - 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
*/
#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)
rt_err_t sep4020_lcd_init(void)
{
pVideoBuffer =(unsigned long) rt_malloc(LCDWIDTH*LCDHEIGHT*2);
pVideoBuffer =(unsigned long)rt_malloc(LCDWIDTH * LCDHEIGHT * 2);
*(RP)GPIO_PORTC_SEL |= 0X0008; //Portc8设置为通用口
*(RP)GPIO_PORTC_DIR &= (~0X0008); //Portc8设置为输出
*(RP)GPIO_PORTC_DATA |= 0X0008; //Portc8输出高电平
writel(0x00000000,LCDC_LECR); //禁用LCDC
writel(pVideoBuffer,LCDC_SSA); //lcd数据帧的起始地址
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); //使能LCDC
writel(0x00000000,LCDC_LCDISREN); //中断在加载帧的最后一个或第一个数据时设置,到LCD之间会有一个延时
writel(0x00000000,LCDC_LECR); //禁用LCDC
writel(pVideoBuffer,LCDC_SSA); //lcd数据帧的起始地址
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); //使能LCDC
writel(0x00000000,LCDC_LCDISREN); //中断在加载帧的最后一个或第一个数据时设置,到LCD之间会有一个延时
return RT_EOK;
return RT_EOK;
}
void lcd_set_pixel(rtgui_color_t *c, int x,int y)
void lcd_set_pixel(rtgui_color_t *c, int x, int y)
{
unsigned short p;
/* get color pixel */
p = rtgui_color_to_565p(*c);
*(unsigned short *)(pVideoBuffer+2*y*LCDWIDTH+2*x)=p;
*(unsigned short *)(pVideoBuffer + 2*y*LCDWIDTH + 2*x) = p;
}
void lcd_get_pixel(rtgui_color_t *c, int x, int y)
{
*c = rtgui_color_from_565p( *(unsigned short *)(pVideoBuffer+2*y*LCDWIDTH+2*x));
}
@@ -59,12 +63,10 @@ void lcd_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
/* get color pixel */
p = rtgui_color_to_565p(*c);
while (x1 < x2)
{
*(unsigned short *)(pVideoBuffer+2*y*LCDWIDTH+2*x1)=p;
x1 ++;
}
}
@@ -75,11 +77,9 @@ void lcd_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
/* get color pixel */
p = rtgui_color_to_565p(*c);
while (y1 < y2)
{
*(unsigned short *)(pVideoBuffer+2*y1*LCDWIDTH+2*x)=p;
*(unsigned short *)(pVideoBuffer+2*y1*LCDWIDTH+2*x)=p;
y1 ++;
}
}
@@ -91,7 +91,6 @@ void lcd_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y)
/* get pixel */
ptr = (rt_uint16_t*) pixels;
while (x1 < x2)
{
*(unsigned short *)(pVideoBuffer+2*y*LCDWIDTH+2*x1)=*ptr;
@@ -105,7 +104,7 @@ void lcd_update(rtgui_rect_t *rect)
/* nothing for none-DMA mode driver */
}
rt_uint8_t * lcd_get_framebuffer(void)
rt_uint8_t *lcd_get_framebuffer(void)
{
return RT_NULL; /* no framebuffer driver */
}
@@ -1,3 +1,16 @@
/*
* File : lcdc.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 - 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
*/
#ifndef LCD_GENERAL_H_INCLUDED
#define LCD_GENERAL_H_INCLUDED
@@ -1,3 +1,15 @@
/*
* File : mii.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 - 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
*/
#ifndef __MII_H__
#define __MII_H__
@@ -1,7 +1,7 @@
/*
* File : sdcard.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, 2007, RT-Thread Develop Team
* COPYRIGHT (C) 2007 - 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
@@ -1,3 +1,15 @@
/*
* File : sdcard.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 - 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
*/
#ifndef __SDCARD_H
#define __SDCARD_H
@@ -15,8 +27,8 @@
/*struct of the SDC*/
struct sd_c
{
__IO rt_uint32_t clk_ctl;
__IO rt_uint32_t soft_rst;
__IO rt_uint32_t clk_ctl;
__IO rt_uint32_t soft_rst;
__IO rt_uint32_t arg;
__IO rt_uint32_t cmd;
__IO rt_uint32_t blk_sz;
@@ -44,8 +56,6 @@ struct sd_device
rt_uint32_t buf_size; /*buffer size*/
};
#endif
#endif
-69
View File
@@ -1,69 +0,0 @@
#include "lcdc.h"
#include "rtthread.h"
#include "board.h"
#include <rtgui/rtgui.h>
#include <rtgui/driver.h>
#include <rtgui/rtgui_server.h>
#include <rtgui/rtgui_system.h>
extern rt_err_t sep4020_lcd_init(void);
extern unsigned long pVideoBuffer;
struct rtgui_graphic_driver _rtgui_lcd_driver;
struct rtgui_graphic_driver_ops _rtgui_graphic_driver_ops;
void radio_rtgui_init(void)
{
rtgui_rect_t rect;
// rtgui_color_t c=0xff;
rtgui_system_server_init();
/* register dock panel */
rect.x1 = 0;
rect.y1 = 0;
rect.x2 = 320;
rect.y2 = 25;
rtgui_panel_register("info", &rect);
rtgui_panel_set_nofocused("info");
/* register main panel */
rect.x1 = 0;
rect.y1 = 25;
rect.x2 = 320;
rect.y2 = 240;
rtgui_panel_register("main", &rect);
rtgui_panel_set_default_focused("main");
_rtgui_graphic_driver_ops.set_pixel=lcd_set_pixel;
_rtgui_graphic_driver_ops.get_pixel=lcd_get_pixel;
_rtgui_graphic_driver_ops.draw_hline=lcd_draw_hline;
_rtgui_graphic_driver_ops.draw_vline=lcd_draw_vline;
_rtgui_graphic_driver_ops.draw_raw_hline=lcd_draw_raw_hline;
_rtgui_lcd_driver.bits_per_pixel = 16;
_rtgui_lcd_driver.width = 320;
_rtgui_lcd_driver.height = 240;
_rtgui_lcd_driver.ops = &_rtgui_graphic_driver_ops;
// _rtgui_lcd_driver.screen_update = lcd_update;
// _rtgui_lcd_driver.get_framebuffer = lcd_get_framebuffer;
sep4020_lcd_init();
rt_memset((char*)pVideoBuffer,0xff,320*240*2);
// rt_memcpy((char*)pVideoBuffer,pic,320*240*2); //TESTING IMAGE
//´Ë´¦´ýÐÞÕý
/* add lcd driver into graphic driver */
// rtgui_graphic_driver_add(&_rtgui_lcd_driver);
}
+85 -149
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -174,7 +174,7 @@
/* SECTION: RTGUI support */
/* using RTGUI support */
#define RT_USING_RTGUI
/* #define RT_USING_RTGUI */
/* name length of RTGUI object */
#define RTGUI_NAME_MAX 16