Added LCD driver and enable SDRAM.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2077 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong@gmail.com 2012-04-16 04:16:19 +00:00
parent 50955197d5
commit 0982f6e079
17 changed files with 1595 additions and 259 deletions

View File

@ -1,5 +1,3 @@
import rtconfig
Import('RTT_ROOT')
from building import *
cwd = str(Dir('#'))

View File

@ -9,17 +9,9 @@
*
* Change Logs:
* Date Author Notes
* 2009-01-05 Bernard the first version
* 2010-03-04 Magicoe for LPC1766 version
* 2010-05-02 Aozima add led function
* 2010-05-24 Bernard add filesystem initialization and move led function to led.c
*/
/**
* @addtogroup LPC1700
*/
/*@{*/
#include <rtthread.h>
#include <board.h>
@ -39,10 +31,13 @@
#include <netif/ethernetif.h>
#endif
#ifdef RT_USING_RTGUI
#include <rtgui/driver.h>
#endif
/* thread phase init */
void rt_init_thread_entry(void *parameter)
{
/* Filesystem Initialization */
#ifdef RT_USING_DFS
{
@ -78,6 +73,28 @@ void rt_init_thread_entry(void *parameter)
rt_kprintf("TCP/IP initialized!\n");
}
#endif
#ifdef RT_USING_RTGUI
{
rt_device_t lcd;
/* init lcd */
rt_hw_lcd_init();
/* re-init device driver */
rt_device_init_all();
/* find lcd device */
lcd = rt_device_find("lcd");
if (lcd != RT_NULL)
{
/* set lcd device as rtgui graphic driver */
rtgui_graphic_set_device(lcd);
/* startup rtgui in demo of RT-Thread/GUI examples */
// rtgui_startup();
}
}
#endif
}
// init led
@ -118,29 +135,47 @@ static void rt_thread_entry_led(void* parameter)
int rt_application_init()
{
rt_thread_t init_thread;
rt_thread_t tid;
//------- init led thread
rt_thread_init(&thread_led,
"led",
rt_thread_entry_led,
RT_NULL,
&thread_led_stack[0],
sizeof(thread_led_stack),11,5);
rt_thread_startup(&thread_led);
rt_thread_init(&thread_led,
"led",
rt_thread_entry_led,
RT_NULL,
&thread_led_stack[0],
sizeof(thread_led_stack),11,5);
rt_thread_startup(&thread_led);
#if (RT_THREAD_PRIORITY_MAX == 32)
init_thread = rt_thread_create("init",
rt_init_thread_entry, RT_NULL,
2048, 8, 20);
#else
init_thread = rt_thread_create("init",
rt_init_thread_entry, RT_NULL,
2048, 80, 20);
#endif
if (init_thread != RT_NULL) rt_thread_startup(init_thread);
tid = rt_thread_create("init",
rt_init_thread_entry, RT_NULL,
2048, RT_THREAD_PRIORITY_MAX/3, 20);
if (tid != RT_NULL) rt_thread_startup(tid);
return 0;
return 0;
}
/*@}*/
#if defined(RT_USING_RTGUI) && defined(RT_USING_FINSH)
#include <rtgui/rtgui_server.h>
#include <rtgui/event.h>
#include <rtgui/kbddef.h>
#include <finsh.h>
void key(rt_uint32_t key)
{
struct rtgui_event_kbd ekbd;
RTGUI_EVENT_KBD_INIT(&ekbd);
ekbd.mod = RTGUI_KMOD_NONE;
ekbd.unicode = 0;
ekbd.key = key;
ekbd.type = RTGUI_KEYDOWN;
rtgui_server_post_event((struct rtgui_event*)&ekbd, sizeof(ekbd));
rt_thread_delay(2);
ekbd.type = RTGUI_KEYUP;
rtgui_server_post_event((struct rtgui_event*)&ekbd, sizeof(ekbd));
}
FINSH_FUNCTION_EXPORT(key, send a key to gui server);
#endif

View File

@ -19,16 +19,6 @@
#include "LPC177x_8x.h"
#include "board.h"
#ifdef RT_USING_DFS
#include "sd.h"
#endif
/**
* @addtogroup LPC17
*/
/*@{*/
extern int rt_application_init(void);
#ifdef RT_USING_FINSH
extern void finsh_system_init(void);
@ -68,56 +58,39 @@ void assert_failed(u8* file, u32 line)
*/
void rtthread_startup(void)
{
/* init board */
/* initialize board */
rt_hw_board_init();
/* show version */
rt_show_version();
/* init tick */
rt_system_tick_init();
/* init kernel object */
rt_system_object_init();
/* init timer system */
rt_system_timer_init();
#ifdef RT_USING_HEAP
/* initialize memory system */
#ifdef __CC_ARM
rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)(0x10000000 + 1024*64));
#elif __ICCARM__
rt_system_heap_init(__segment_end("HEAP"), (void*)(0x10000000 + 1024*64));
#else
/* init memory system */
rt_system_heap_init((void*)&__bss_end, (void*)(0x10000000 + 1024*64));
#endif
#endif
/* init scheduler system */
/* initialize scheduler system */
rt_system_scheduler_init();
#ifdef RT_USING_DEVICE
#ifdef RT_USING_DFS
rt_hw_sdcard_init();
#endif
/* init all device */
rt_device_init_all();
#endif
/* init application */
/* initialize application */
rt_application_init();
#ifdef RT_USING_FINSH
/* init finsh */
/* initialize finsh */
finsh_system_init();
finsh_set_device( FINSH_DEVICE_NAME );
#endif
/* init timer thread */
/* initialize timer thread */
rt_system_timer_thread_init();
/* init idle thread */
/* initialize idle thread */
rt_thread_idle_init();
/* start scheduler */
@ -137,5 +110,3 @@ int main(void)
return 0;
}
/*@}*/

View File

@ -1,15 +1,11 @@
import copy
Import('RTT_ROOT')
Import('rtconfig')
from building import *
cwd = GetCurrentDir()
src = Glob('*.c')
cwd = GetCurrentDir()
src = Glob('*.c')
# remove no need file.
if GetDepend('RT_USING_LWIP') == False:
src_need_remove = ['emac.c'] # need remove file list.
SrcRemove(src, src_need_remove)
SrcRemove(src, 'emac.c')
CPPPATH = [cwd]

View File

@ -21,6 +21,7 @@
#include "board.h"
#include "LPC177x_8x.h"
#include "system_LPC177x_8x.h"
#include "sdram.h"
/**
* @addtogroup LPC17xx
@ -69,16 +70,13 @@ void rt_hw_board_init()
NVIC_SetPriority(PendSV_IRQn, (1<<__NVIC_PRIO_BITS) - 1);
rt_hw_uart_init();
rt_console_set_device( CONSOLE_DEVICE );
rt_kprintf("\r\n\r\nSystemInit......\r\n");
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#if LPC_EXT_SDRAM == 1
{
SDRAM_Init();
}
#endif
}
/*@}*/

View File

@ -18,27 +18,28 @@
#include "LPC177x_8x.h"
/* whether use board external SDRAM memory */
// <e>Use external SDRAM memory on the board
// <i>Enable External SDRAM memory
#define LPC_EXT_SDRAM 0
// <o>Begin Address of External SDRAM
// <i>Default: 0x60000000
#define LPC_EXT_SDRAM_BEGIN 0xA0000000 /* the begining address of external SDRAM */
// <o>End Address of External SDRAM
// <i>Default: 0x60000000
#define LPC_EXT_SDRAM_END 0xA4000000 /* the end address of external SDRAM */
// </e>
// <RDTConfigurator URL="http://www.rt-thread.com/eclipse">
/* RT_USING_UART */
#define RT_UART_RX_BUFFER_SIZE 64
// <integer name="LPC_EXT_SDRAM" description="Enable External SDRAM memory" default="0" />
#define LPC_EXT_SDRAM 1
// <integer name="LPC_EXT_SDRAM" description="Begin Address of External SDRAM" default="0xA0000000" />
#define LPC_EXT_SDRAM_BEGIN 0xA0000000
// <integer name="LPC_EXT_SDRAM_END" description="End Address of External SDRAM" default="0xA4000000" />
#define LPC_EXT_SDRAM_END 0xA4000000
// <bool name="RT_USING_UART0" description="Using UART0" default="true" />
#define RT_USING_UART0
// <bool name="RT_USING_UART1" description="Using UART1" default="true" />
//#define RT_USING_UART1
// <bool name="RT_USING_UART2" description="Using UART2" default="true" />
//#define RT_USING_UART2
#define CONSOLE_DEVICE "uart0"
#define FINSH_DEVICE_NAME CONSOLE_DEVICE
// <string name="RT_CONSOLE_DEVICE_NAME" description="The device name for console" default="uart" />
#define RT_CONSOLE_DEVICE_NAME "uart0"
// </RDTConfigurator>
#define FINSH_DEVICE_NAME RT_CONSOLE_DEVICE_NAME
void rt_hw_board_init(void);
#endif

View File

@ -0,0 +1,668 @@
/*************************************************************************
*
* Used with ICCARM and AARM.
*
* (c) Copyright IAR Systems 2008
*
* File name : drv_glcd.c
* Description : Graphical LCD driver
*
* History :
* 1. Date : 6, March 2008
* Author : Stanimir Bonev
* Description : Create
*
*
* $Revision: 24636 $
*
* @Modify: NXP MCU Application Team - NguyenCao
* @Date: 04. March. 2011
**************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
//#include "ConstGlbPtrs.h"
//#include "Ex_sdram.h"
#include "drv_glcd.h"
#include "lpc177x_8x_clkpwr.h"
#include "lpc177x_8x_pinsel.h"
//#include "Cursor.h"
//#include "logo.h"
//#define MHZ
#define C_GLCD_CLK_PER_LINE (C_GLCD_H_SIZE + C_GLCD_H_PULSE + C_GLCD_H_FRONT_PORCH + C_GLCD_H_BACK_PORCH)
#define C_GLCD_LINES_PER_FRAME (C_GLCD_V_SIZE + C_GLCD_V_PULSE + C_GLCD_V_FRONT_PORCH + C_GLCD_V_BACK_PORCH)
#define C_GLCD_PIX_CLK (C_GLCD_CLK_PER_LINE * C_GLCD_LINES_PER_FRAME)
//LPC_LCD_TypeDef * const g_pLCD = ((LPC_LCD_TypeDef*) LPC_LCD_BASE);
//LPC_SC_TypeDef * const g_pSC = ((LPC_SC_TypeDef*) LPC_SC_BASE);
#define SDRAM_BASE 0xA0000000 /* CS0 */
#define SDRAM_BASE_ADDR SDRAM_BASE
#define LCD_VRAM_BASE_ADDR ((unsigned long)SDRAM_BASE_ADDR + 0x00000000)
#define LCD_CURSOR_BASE_ADDR ((unsigned long)0x20088800)
static pFontType_t pCurrFont = NULL;
static LdcPixel_t TextColour;
static LdcPixel_t TextBackgndColour;
static unsigned long TextX_Pos = 0;
static unsigned long TextY_Pos = 0;
static unsigned long XL_Win = 0;
static unsigned long YU_Win = 0;
static unsigned long XR_Win = C_GLCD_H_SIZE-1;
static unsigned long YD_Win = C_GLCD_V_SIZE-1;
static unsigned long TabSize = TEXT_DEF_TAB_SIZE;
static unsigned long WindY_Size, WindX_Size;
static unsigned long CurrY_Size, CurrX_Size;
static unsigned long *pWind;
static unsigned long *pPix;
/*************************************************************************
* Function Name: GLCD_Cursor_Cnfg
* Parameters:
*
* Return: none
*
* Description: Configure the cursor
*
*************************************************************************/
void GLCD_Cursor_Cfg(int Cfg)
{
LPC_LCD->CRSR_CFG = Cfg;
}
/*************************************************************************
* Function Name: GLCD_Cursor_En
* Parameters: cursor - Cursor Number
*
* Return: none
*
* Description: Enable Cursor
*
*************************************************************************/
void GLCD_Cursor_En(int cursor)
{
LPC_LCD->CRSR_CTRL |= (cursor<<4);
LPC_LCD->CRSR_CTRL |= 1;
}
/*************************************************************************
* Function Name: GLCD_Cursor_Dis
* Parameters: None
*
* Return: none
*
* Description: Disable Cursor
*
*************************************************************************/
void GLCD_Cursor_Dis(int cursor)
{
LPC_LCD->CRSR_CTRL &= (1<<0);
}
/*************************************************************************
* Function Name: GLCD_Move_Cursor
* Parameters: x - cursor x position
* y - cursor y position
*
* Return: none
*
* Description: Moves cursor on position (x,y). Negativ values are posible.
*
*************************************************************************/
void GLCD_Move_Cursor(int x, int y)
{
LPC_LCD->CRSR_CLIP = 0;
LPC_LCD->CRSR_XY = 0;
if(0 <= x)
{//no clipping
LPC_LCD->CRSR_XY |= (x & 0x3FF);
}
else
{//clip x
LPC_LCD->CRSR_CLIP |= -x;
}
if(0 <= y)
{//no clipping
LPC_LCD->CRSR_XY |= (y << 16);
}
else
{//clip y
LPC_LCD->CRSR_CLIP |= (-y << 8);
}
}
/*************************************************************************
* Function Name: GLCD_Copy_Cursor
* Parameters: pCursor - pointer to cursor conts image
* cursor - cursor Number (0,1,2 or 3)
* for 64x64(size 256) pix cursor always use 0
* size - cursor size in words
* Return: none
*
* Description: Copy Cursor from const image to LCD RAM image
*
*************************************************************************/
void GLCD_Copy_Cursor (const unsigned long *pCursor, int cursor, int size)
{
unsigned long i ;
unsigned long * pDst = (unsigned long *)LCD_CURSOR_BASE_ADDR;
pDst += cursor*64;
for(i = 0; i < size ; i++)
// *pDst++ = *pCursor++;
{
*pDst = *pCursor;
pDst++;
pCursor++;
}
}
/*************************************************************************
* Function Name: GLCD_Init
* Parameters: const unsigned long *pPain, const unsigned long * pPallete
*
* Return: none
*
* Description: GLCD controller init
*
*************************************************************************/
void GLCD_Init (void* VRAMBase)
{
// unsigned long i;
// Assign pins
LPC_IOCON->P2_9 = 0x06; // VD3, R0
LPC_IOCON->P2_6 = 0x07; // VD4, R1
LPC_IOCON->P2_7 = 0x07; // VD5, R2
LPC_IOCON->P4_28 = 0x05; // VD6, R3
LPC_IOCON->P4_29 = 0x05; // VD7, R4
LPC_IOCON->P1_20 = 0x07; // VD10, G0
LPC_IOCON->P1_21 = 0x07; // VD11, G1
LPC_IOCON->P1_22 = 0x07; // VD12, G2
LPC_IOCON->P1_23 = 0x07; // VD13, G3
LPC_IOCON->P1_24 = 0x07; // VD14, G4
LPC_IOCON->P1_25 = 0x07; // VD15, G5
LPC_IOCON->P2_13 = 0x07; // VD19, B0
LPC_IOCON->P1_26 = 0x07; // VD20, B1
LPC_IOCON->P1_27 = 0x07; // VD21, B2
LPC_IOCON->P1_28 = 0x07; // VD22, B3
LPC_IOCON->P1_29 = 0x07; // VD23, B4
LPC_IOCON->P2_2 = 0x07; // DCLK
LPC_IOCON->P2_0 = 0x07; // DSIP(power)
LPC_IOCON->P2_5 = 0x07; // HSYNC
LPC_IOCON->P2_3 = 0x07; // VSYNC
LPC_IOCON->P2_4 = 0x07; // DataEn
// LPC_IOCON->P5_4 = 0x00; // Backlight
// >>> debug >>>
// <<< debug <<<
/*Back light enable*/
// LPC_GPIO5->DIR = (1<<4);
// LPC_GPIO5->SET= (5<<4);
//Turn on LCD clock
CLKPWR_ConfigPPWR(CLKPWR_PCONP_PCLCD, ENABLE);
// Disable cursor
LPC_LCD->CRSR_CTRL &=~(1<<0);
// disable GLCD controller
LPC_LCD->CTRL = 0;
// RGB888
LPC_LCD->CTRL &= ~(0x07 <<1);
LPC_LCD->CTRL |= (6<<1);
// TFT panel
LPC_LCD->CTRL |= (1<<5);
// single panel
LPC_LCD->CTRL &= ~(1<<7);
// notmal output
LPC_LCD->CTRL &= ~(1<<8);
// little endian byte order
LPC_LCD->CTRL &= ~(1<<9);
// little endian pix order
LPC_LCD->CTRL &= ~(1<<10);
// disable power
LPC_LCD->CTRL &= ~(1<<11);
// init pixel clock
// g_pSC->LCD_CFG = CLKPWR_GetCLK(CLKPWR_CLKTYPE_PER) / ((unsigned long)C_GLCD_PIX_CLK);
LPC_SC->LCD_CFG = CLKPWR_GetCLK(CLKPWR_CLKTYPE_PER) / ((unsigned long)C_GLCD_PIX_CLK);
// bypass inrenal clk divider
LPC_LCD->POL |=(1<<26);
// clock source for the LCD block is HCLK
LPC_LCD->POL &= ~(1<<5);
// LCDFP pin is active LOW and inactive HIGH
LPC_LCD->POL |= (1<<11);
// LCDLP pin is active LOW and inactive HIGH
LPC_LCD->POL |= (1<<12);
// data is driven out into the LCD on the falling edge
LPC_LCD->POL &= ~(1<<13);
// active high
LPC_LCD->POL &= ~(1<<14);
LPC_LCD->POL &= ~(0x3FF <<16);
LPC_LCD->POL |= (C_GLCD_H_SIZE-1)<<16;
// init Horizontal Timing
LPC_LCD->TIMH = 0; //reset TIMH before set value
LPC_LCD->TIMH |= (C_GLCD_H_BACK_PORCH - 1)<<24;
LPC_LCD->TIMH |= (C_GLCD_H_FRONT_PORCH - 1)<<16;
LPC_LCD->TIMH |= (C_GLCD_H_PULSE - 1)<<8;
LPC_LCD->TIMH |= ((C_GLCD_H_SIZE/16) - 1)<<2;
// init Vertical Timing
LPC_LCD->TIMV = 0; //reset TIMV value before setting
LPC_LCD->TIMV |= (C_GLCD_V_BACK_PORCH)<<24;
LPC_LCD->TIMV |= (C_GLCD_V_FRONT_PORCH)<<16;
LPC_LCD->TIMV |= (C_GLCD_V_PULSE - 1)<<10;
LPC_LCD->TIMV |= C_GLCD_V_SIZE - 1;
// Frame Base Address doubleword aligned
LPC_LCD->UPBASE = (unsigned long)VRAMBase & ~7UL ;
LPC_LCD->LPBASE = (unsigned long)VRAMBase & ~7UL ;
}
/*************************************************************************
* Function Name: GLCD_SetPallet
* Parameters: const unsigned long * pPallete
*
* Return: none
*
* Description: GLCD init colour pallete
*
*************************************************************************/
void GLCD_SetPallet (const unsigned long * pPallete)
{
unsigned long i;
unsigned long * pDst = (unsigned long *)LPC_LCD->PAL;
// //assert(pPallete);
for (i = 0; i < 128; i++)
{
*pDst++ = *pPallete++;
}
}
/*************************************************************************
* Function Name: GLCD_Ctrl
* Parameters: Bool bEna
*
* Return: none
*
* Description: GLCD enable disabe sequence
*
*************************************************************************/
void GLCD_Ctrl (Bool bEna)
{
volatile unsigned long i;
if (bEna)
{
// LCD_CTRL_bit.LcdEn = 1;
LPC_LCD->CTRL |= (1<<0);
for(i = C_GLCD_PWR_ENA_DIS_DLY; i; i--);
// LCD_CTRL_bit.LcdPwr= 1; // enable power
LPC_LCD->CTRL |= (1<<11);
}
else
{
// LCD_CTRL_bit.LcdPwr= 0; // disable power
LPC_LCD->CTRL &= ~(1<<11);
for(i = C_GLCD_PWR_ENA_DIS_DLY; i; i--);
// LCD_CTRL_bit.LcdEn = 0;
LPC_LCD->CTRL &= ~(1<<0);
}
}
/*************************************************************************
* Function Name: GLCD_SetFont
* Parameters: pFontType_t pFont, LdcPixel_t Color
* LdcPixel_t BackgndColor
*
* Return: none
*
* Description: Set current font, font color and background color
*
*************************************************************************/
void GLCD_SetFont(pFontType_t pFont, LdcPixel_t Color, LdcPixel_t BackgndColor)
{
pCurrFont = pFont;
TextColour = Color;
TextBackgndColour = BackgndColor;
}
/*************************************************************************
* Function Name: GLCD_SetWindow
* Parameters: unsigned long X_Left, unsigned long Y_Up,
* unsigned long X_Right, unsigned long Y_Down
*
* Return: none
*
* Description: Set draw window XY coordinate in pixels
*
*************************************************************************/
void GLCD_SetWindow(unsigned long X_Left, unsigned long Y_Up,
unsigned long X_Right, unsigned long Y_Down)
{
// //assert(X_Right < C_GLCD_H_SIZE);
// //assert(Y_Down < C_GLCD_V_SIZE);
// //assert(X_Left < X_Right);
//assert(Y_Up < Y_Down);
XL_Win = X_Left;
YU_Win = Y_Up;
XR_Win = X_Right;
YD_Win = Y_Down;
}
/*************************************************************************
* Function Name: GLCD_TextSetPos
* Parameters: unsigned long X_UpLeft, unsigned long Y_UpLeft,
* unsigned long X_DownLeft, unsigned long Y_DownLeft
*
* Return: none
*
* Description: Set text X,Y coordinate in characters
*
*************************************************************************/
void GLCD_TextSetPos(unsigned long X, unsigned long Y)
{
TextX_Pos = X;
TextY_Pos = Y;
}
/*************************************************************************
* Function Name: GLCD_TextSetTabSize
* Parameters: unsigned long Size
*
* Return: none
*
* Description: Set text tab size in characters
*
*************************************************************************/
void GLCD_TextSetTabSize(unsigned long Size)
{
TabSize = Size;
}
/*************************************************************************
* Function Name: LCD_SET_WINDOW
* Parameters: int c
*
* Return: none
*
* Description: Put char function
*
*************************************************************************/
static
void LCD_SET_WINDOW (unsigned long X_Left, unsigned long X_Right,
unsigned long Y_Up, unsigned long Y_Down)
{
pPix = pWind = ((unsigned long *)LCD_VRAM_BASE_ADDR) + X_Left + (Y_Up*C_GLCD_H_SIZE);
WindX_Size = X_Right - X_Left;
WindY_Size = Y_Down - Y_Up;
CurrX_Size = CurrY_Size = 0;
}
/*************************************************************************
* Function Name: LCD_SET_WINDOW
* Parameters: int c
*
* Return: none
*
* Description: Put char function
*
*************************************************************************/
static
void LCD_WRITE_PIXEL (unsigned long Pixel)
{
*pPix++ = Pixel;
if (++CurrX_Size > WindX_Size)
{
CurrX_Size = 0;
if(++CurrY_Size > WindY_Size)
{
CurrY_Size = 0;
}
pPix = pWind + CurrY_Size * C_GLCD_H_SIZE;
}
}
/*************************************************************************
* Function Name: GLCD_TextCalcWindow
* Parameters: unsigned long * pXL, unsigned long * pXR,
* unsigned long * pYU, unsigned long * pYD,
* unsigned long * pH_Size, unsigned long * pV_Size
*
* Return: Bool
* FALSE - out of window coordinate aren't valid
* TRUE - the returned coordinate are valid
*
* Description: Calculate character window
*
*************************************************************************/
static
Bool GLCD_TextCalcWindow (unsigned long * pXL, unsigned long * pXR,
unsigned long * pYU, unsigned long * pYD,
unsigned long * pH_Size, unsigned long * pV_Size)
{
*pH_Size = pCurrFont->H_Size;
*pV_Size = pCurrFont->V_Size;
*pXL = XL_Win + (TextX_Pos*pCurrFont->H_Size);
if(*pXL > XR_Win)
{
return(FALSE);
}
*pYU = YU_Win + (TextY_Pos*pCurrFont->V_Size);
if(*pYU > YD_Win)
{
return(FALSE);
}
*pXR = XL_Win + ((TextX_Pos+1)*pCurrFont->H_Size) - 1;
if(*pXR > XR_Win)
{
*pH_Size -= *pXR - XR_Win;
*pXR = XR_Win;
}
*pYD = YU_Win + ((TextY_Pos+1)*pCurrFont->V_Size) - 1;
if(*pYD > YD_Win)
{
*pV_Size -= *pYD - YD_Win;
*pYD = YD_Win;
}
return(TRUE);
}
/*************************************************************************
* Function Name: putchar
* Parameters: int c
*
* Return: none
*
* Description: Put char function
*
*************************************************************************/
int _putchar (int c)
{
uint8_t *pSrc;
unsigned long H_Line;
unsigned long xl,xr,yu,yd,Temp,V_Size, H_Size, SrcInc = 1;
unsigned long WhiteSpaceNumb;
unsigned long i, j, k;
if(pCurrFont == NULL)
{
return(EOF);
}
H_Line = (pCurrFont->H_Size / 8) + ((pCurrFont->H_Size % 8)?1:0);
switch(c)
{
case '\n': // go to begin of next line (NewLine)
++TextY_Pos;
break;
case '\r': // go to begin of this line (Carriage Return)
// clear from current position to end of line
while(GLCD_TextCalcWindow(&xl,&xr,&yu,&yd,&H_Size,&V_Size))
{
LCD_SET_WINDOW(xl,xr,yu,yd);
for(i = 0; i < V_Size; ++i)
{
for(j = 0; j < H_Size; ++j)
{
LCD_WRITE_PIXEL(TextBackgndColour);
}
}
++TextX_Pos;
}
TextX_Pos = 0;
break;
case '\b': // go back one position (BackSpace)
if(TextX_Pos)
{
--TextX_Pos;
// del current position
if(GLCD_TextCalcWindow(&xl,&xr,&yu,&yd,&H_Size,&V_Size))
{
LCD_SET_WINDOW(xl,xr,yu,yd);
for(i = 0; i < V_Size; ++i)
{
for(j = 0; j < H_Size; ++j)
{
LCD_WRITE_PIXEL(TextBackgndColour);
}
}
}
}
break;
case '\t': // go to next Horizontal Tab stop
WhiteSpaceNumb = TabSize - (TextX_Pos%TabSize);
for(k = 0; k < WhiteSpaceNumb; ++k)
{
LCD_SET_WINDOW(xl,xr,yu,yd);
if(GLCD_TextCalcWindow(&xl,&xr,&yu,&yd,&H_Size,&V_Size))
{
for(i = 0; i < V_Size; ++i)
{
for(j = 0; j < H_Size; ++j)
{
LCD_WRITE_PIXEL(TextBackgndColour);
}
}
++TextX_Pos;
}
else
{
break;
}
}
break;
case '\f': // go to top of page (Form Feed)
// clear entire window
H_Size = XR_Win - XL_Win;
V_Size = YD_Win - YU_Win;
// set character window X left, Y right
LCD_SET_WINDOW(XL_Win,XR_Win,YU_Win,YD_Win);
// Fill window with background font color
for(i = 0; i <= V_Size; ++i)
{
for(j = 0; j <= H_Size; ++j)
{
LCD_WRITE_PIXEL(TextBackgndColour);
}
}
TextX_Pos = TextY_Pos = 0;
break;
case '\a': // signal an alert (BELl)
TEXT_BEL1_FUNC();
break;
default:
// Calculate the current character base address from stream
// and the character position
if((c < pCurrFont->CharacterOffset) &&
(c >= pCurrFont->CharactersNuber))
{
c = 0;
}
else
{
c -= pCurrFont->CharacterOffset;
}
pSrc = pCurrFont->pFontStream + (H_Line * pCurrFont->V_Size * c);
// Calculate character window and fit it in the text window
if(GLCD_TextCalcWindow(&xl,&xr,&yu,&yd,&H_Size,&V_Size))
{
// set character window X left, Y right
LCD_SET_WINDOW(xl,xr,yu,yd);
// Send char data
for(i = 0; i < V_Size; ++i)
{
SrcInc = H_Line;
for(j = 0; j < H_Size; ++j)
{
Temp = (*pSrc & (1UL << (j&0x7)))?TextColour:TextBackgndColour;
LCD_WRITE_PIXEL(Temp);
if((j&0x7) == 7)
{
++pSrc;
--SrcInc;
}
}
// next line of character
pSrc += SrcInc;
}
}
++TextX_Pos;
}
return(c);
}
/*************************************************************************
* Function Name: GLCD_LoadPic
* Parameters: unsigned long X_Left, unsigned long Y_Up, Bmp_t * pBmp
*
* Return: none
*
* Description: Load picture in VRAM memory area
*
*************************************************************************/
void GLCD_LoadPic (unsigned long X_Left, unsigned long Y_Up, Bmp_t * pBmp, unsigned long Mask)
{
unsigned long i, j;
unsigned long * pData = ((unsigned long *) LCD_VRAM_BASE_ADDR) + X_Left + (Y_Up * C_GLCD_H_SIZE);
unsigned long * pSrc = pBmp->pPicStream;
unsigned long X_LeftHold;
for(i = 0; i < pBmp->V_Size; i++)
{
if(Y_Up++ >= C_GLCD_V_SIZE)
{
break;
}
for(j = 0; j < pBmp->H_Size; j++)
{
if(X_LeftHold++ >= C_GLCD_H_SIZE)
{
pSrc += pBmp->H_Size - j;
break;
}
*(pData+j) = *pSrc++ ^ Mask;
}
X_LeftHold = X_Left;
pData += C_GLCD_H_SIZE;
}
}

View File

@ -0,0 +1,111 @@
/*************************************************************************
*
* Used with ICCARM and AARM.
*
* (c) Copyright IAR Systems 2008
*
* File name : drv_glcd.h
* Description : Graphical LCD driver include file
*
* History :
* 1. Date : 6, March 2008
* Author : Stanimir Bonev
* Description : Create
*
*
* $Revision: 24636 $
*
* @Modify: NXP MCU Application Team - NguyenCao
* @Date: 04. March. 2011
**************************************************************************/
#include "lpc_types.h"
#ifndef __GLCD_DRV_H
#define __GLCD_DRV_H
typedef unsigned long U32;
typedef unsigned char U8;
typedef unsigned long Boolean;
/**
* @brief A struct for Bitmap on LCD screen
*/
typedef struct _Bmp_t
{
U32 H_Size;
U32 V_Size;
U32 BitsPP;
U32 BytesPP;
U32 *pPalette;
U32 *pPicStream;
U8 *pPicDesc;
} Bmp_t, *pBmp_t;
/**
* @brief A struct for Font Type on LCD screen
*/
typedef struct _FontType_t
{
U32 H_Size;
U32 V_Size;
U32 CharacterOffset;
U32 CharactersNuber;
U8 *pFontStream;
U8 *pFontDesc;
} FontType_t, *pFontType_t;
typedef U32 LdcPixel_t, *pLdcPixel_t;
#define C_GLCD_REFRESH_FREQ (60HZ)
#define C_GLCD_H_SIZE 480
#define C_GLCD_H_PULSE 2 //
#define C_GLCD_H_FRONT_PORCH 5 //
#define C_GLCD_H_BACK_PORCH 40 //
#define C_GLCD_V_SIZE 272
#define C_GLCD_V_PULSE 2
#define C_GLCD_V_FRONT_PORCH 8
#define C_GLCD_V_BACK_PORCH 8
#define C_GLCD_PWR_ENA_DIS_DLY 10000
#define C_GLCD_ENA_DIS_DLY 10000
//Cursor 64x64 pixels
#define CURSOR_H_SIZE 64
#define CURSOR_V_SIZE 64
//
#define CIRCLE_R 18
#define CRSR_PIX_32 0
#define CRSR_PIX_64 1
#define CRSR_ASYNC 0
#define CRSR_FRAME_SYNC 2
#define TEXT_DEF_TAB_SIZE 5
#define TEXT_BEL1_FUNC()
void GLCD_Init (void* VRAMBase);
void GLCD_SetPallet (const U32 * pPallete);
void GLCD_Ctrl (Bool bEna);
void GLCD_Cursor_Cfg(int Cfg);
void GLCD_Cursor_En(int cursor);
void GLCD_Cursor_Dis(int cursor);
void GLCD_Move_Cursor(int x, int y);
void GLCD_Copy_Cursor (const U32 *pCursor, int cursor, int size);
void GLCD_SetFont(pFontType_t pFont, LdcPixel_t Color, LdcPixel_t BackgndColor);
void GLCD_SetWindow(U32 X_Left, U32 Y_Up,
U32 X_Right, U32 Y_Down);
void GLCD_TextSetPos(U32 X, U32 Y);
void GLCD_TextSetTabSize(U32 Size);
static void LCD_SET_WINDOW (U32 X_Left, U32 X_Right,
U32 Y_Up, U32 Y_Down);
static void LCD_WRITE_PIXEL (U32 Pixel);
static Bool GLCD_TextCalcWindow (U32 * pXL, U32 * pXR,
U32 * pYU, U32 * pYD,
U32 * pH_Size, U32 * pV_Size);
void GLCD_LoadPic (U32 X_Left, U32 Y_Up, Bmp_t * pBmp, U32 Mask);
int _putchar (int c);
#endif // __GLCD_DRV_H

View File

@ -171,7 +171,7 @@ REF_CLK P1_15
static rt_err_t lpc17xx_emac_init(rt_device_t dev)
{
/* Initialize the EMAC ethernet controller. */
rt_uint32_t regv, tout, id1, id2;
rt_uint32_t regv, tout;
/* Power Up the EMAC controller. */
LPC_SC->PCONP |= (1UL<<30);

View File

@ -3,11 +3,89 @@
#include "LPC177x_8x.h"
#include "lpc177x_8x_pinsel.h"
/* LCD BL P5_4 */
void rt_hw_lcd_init(void)
#include "drv_glcd.h"
#define RT_HW_LCD_WIDTH 480
#define RT_HW_LCD_HEIGHT 272
static struct rt_device_graphic_info _lcd_info;
static struct rt_device lcd;
/* RT-Thread Device Interface */
static rt_err_t rt_lcd_init (rt_device_t dev)
{
PINSEL_ConfigPin(5, 4, 0);
LPC_GPIO5->DIR |= 1<<4;
LPC_GPIO5->CLR = 1<<4;
LPC_GPIO5->SET = 1<<4;
/*Disable LCD controller*/
GLCD_Ctrl (FALSE);
/*Init LCD and copy picture in video RAM*/
GLCD_Init (_lcd_info.framebuffer);
/*Enable LCD*/
GLCD_Ctrl (TRUE);
return RT_EOK;
}
static rt_err_t rt_lcd_control (rt_device_t dev, rt_uint8_t cmd, void *args)
{
switch (cmd)
{
case RTGRAPHIC_CTRL_RECT_UPDATE:
break;
case RTGRAPHIC_CTRL_POWERON:
break;
case RTGRAPHIC_CTRL_POWEROFF:
break;
case RTGRAPHIC_CTRL_GET_INFO:
rt_memcpy(args, &_lcd_info, sizeof(_lcd_info));
break;
case RTGRAPHIC_CTRL_SET_MODE:
break;
}
return RT_EOK;
}
/* LCD BL P5_4 */
void rt_hw_lcd_init(void)
{
rt_uint16_t * _rt_framebuffer = RT_NULL;
// _rt_framebuffer = rt_malloc_align(sizeof(rt_uint16_t)*RT_HW_LCD_HEIGHT*RT_HW_LCD_WIDTH, 8);
// if (_rt_framebuffer == RT_NULL) return; /* no memory yet */
_rt_framebuffer = (rt_uint16_t *)0xA0000000;
_lcd_info.bits_per_pixel = 16;
_lcd_info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565;
_lcd_info.framebuffer = (void*)_rt_framebuffer;
_lcd_info.width = RT_HW_LCD_WIDTH;
_lcd_info.height = RT_HW_LCD_HEIGHT;
/* init device structure */
lcd.type = RT_Device_Class_Graphic;
lcd.init = rt_lcd_init;
lcd.open = RT_NULL;
lcd.close = RT_NULL;
lcd.control = rt_lcd_control;
lcd.user_data = (void*)&_lcd_info;
/* register lcd device to RT-Thread */
rt_device_register(&lcd, "lcd", RT_DEVICE_FLAG_RDWR);
}
void lcd_fill(uint8_t * start, uint8_t * end, uint8_t pixel)
{
while(start<end)
{
*start++ = pixel;
}
}
#ifdef RT_USING_FINSH
#include <finsh.h>
FINSH_FUNCTION_EXPORT(lcd_fill, lcd_fill );
#endif

278
bsp/lpc178x/drivers/sdram.c Normal file
View File

@ -0,0 +1,278 @@
#include <rtthread.h>
#include <system_LPC177x_8x.h>
#include "LPC177x_8x.h"
#include "sdram.h"
//LPC_EMC_TypeDef * const g_pEMC = ((LPC_EMC_TypeDef*) LPC_EMC_BASE);
//LPC_IOCON_TypeDef * const LPC_IOCON = ((LPC_IOCON_TypeDef*) LPC_IOCON_BASE);
#define SDRAM_BASE 0xA0000000 /* CS0 */
#define EMC_NS2CLK(ns, nsPerClk) ((ns + nsPerClk - 1) / nsPerClk)
static void delayMs(int a,int b)
{
volatile unsigned int i;
for(i=0;i<10000;i++);
}
/*****************************************************************************
** Function name: delayMs
**
** Descriptions: Start the timer delay in milo seconds
** until elapsed
**
** parameters: timer number, Delay value in milo second
**
** Returned value: None
**
*****************************************************************************/
//void delayMs(uint8_t timer_num, uint32_t delayInMs)
//{
// if ( timer_num == 0 )
// {
// LPC_TIM0->TCR = 0x02; /* reset timer */
// LPC_TIM0->PR = 0x00; /* set prescaler to zero */
// LPC_TIM0->MR0 = delayInMs * (PeripheralClock / 1000 - 1);
// LPC_TIM0->IR = 0xff; /* reset all interrrupts */
// LPC_TIM0->MCR = 0x04; /* stop timer on match */
// LPC_TIM0->TCR = 0x01; /* start timer */
//
// /* wait until delay time has elapsed */
// while (LPC_TIM0->TCR & 0x01);
// }
// else if ( timer_num == 1 )
// {
// LPC_TIM1->TCR = 0x02; /* reset timer */
// LPC_TIM1->PR = 0x00; /* set prescaler to zero */
// LPC_TIM1->MR0 = delayInMs * (PeripheralClock / 1000 - 1);
// LPC_TIM1->IR = 0xff; /* reset all interrrupts */
// LPC_TIM1->MCR = 0x04; /* stop timer on match */
// LPC_TIM1->TCR = 0x01; /* start timer */
//
// /* wait until delay time has elapsed */
// while (LPC_TIM1->TCR & 0x01);
// }
// else if ( timer_num == 2 )
// {
// LPC_TIM2->TCR = 0x02; /* reset timer */
// LPC_TIM2->PR = 0x00; /* set prescaler to zero */
// LPC_TIM2->MR0 = delayInMs * (PeripheralClock / 1000 - 1);
// LPC_TIM2->IR = 0xff; /* reset all interrrupts */
// LPC_TIM2->MCR = 0x04; /* stop timer on match */
// LPC_TIM2->TCR = 0x01; /* start timer */
//
// /* wait until delay time has elapsed */
// while (LPC_TIM2->TCR & 0x01);
// }
// else if ( timer_num == 3 )
// {
// LPC_TIM3->TCR = 0x02; /* reset timer */
// LPC_TIM3->PR = 0x00; /* set prescaler to zero */
// LPC_TIM3->MR0 = delayInMs * (PeripheralClock / 1000 - 1);
// LPC_TIM3->IR = 0xff; /* reset all interrrupts */
// LPC_TIM3->MCR = 0x04; /* stop timer on match */
// LPC_TIM3->TCR = 0x01; /* start timer */
//
// /* wait until delay time has elapsed */
// while (LPC_TIM3->TCR & 0x01);
// }
// return;
//}
static void EMC_GPIO_Init (void)
{
LPC_IOCON->P3_0 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D0 @ P3.0 */
LPC_IOCON->P3_1 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D1 @ P3.1 */
LPC_IOCON->P3_2 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D2 @ P3.2 */
LPC_IOCON->P3_3 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D3 @ P3.3 */
LPC_IOCON->P3_4 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D4 @ P3.4 */
LPC_IOCON->P3_5 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D5 @ P3.5 */
LPC_IOCON->P3_6 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D6 @ P3.6 */
LPC_IOCON->P3_7 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D7 @ P3.7 */
LPC_IOCON->P3_8 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D8 @ P3.8 */
LPC_IOCON->P3_9 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D9 @ P3.9 */
LPC_IOCON->P3_10 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D10 @ P3.10 */
LPC_IOCON->P3_11 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D11 @ P3.11 */
LPC_IOCON->P3_12 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D12 @ P3.12 */
LPC_IOCON->P3_13 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D13 @ P3.13 */
LPC_IOCON->P3_14 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D14 @ P3.14 */
LPC_IOCON->P3_15 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D15 @ P3.15 */
LPC_IOCON->P3_16 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D16 @ P3.16 */
LPC_IOCON->P3_17 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D17 @ P3.17 */
LPC_IOCON->P3_18 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D18 @ P3.18 */
LPC_IOCON->P3_19 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D19 @ P3.19 */
LPC_IOCON->P3_20 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D20 @ P3.20 */
LPC_IOCON->P3_21 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D21 @ P3.21 */
LPC_IOCON->P3_22 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D22 @ P3.22 */
LPC_IOCON->P3_23 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D23 @ P3.23 */
LPC_IOCON->P3_24 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D24 @ P3.24 */
LPC_IOCON->P3_25 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D25 @ P3.25 */
LPC_IOCON->P3_26 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D26 @ P3.26 */
LPC_IOCON->P3_27 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D27 @ P3.27 */
LPC_IOCON->P3_28 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D28 @ P3.28 */
LPC_IOCON->P3_29 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D29 @ P3.29 */
LPC_IOCON->P3_30 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D30 @ P3.30 */
LPC_IOCON->P3_31 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D31 @ P3.31 */
LPC_IOCON->P4_0 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A0 @ P4.0 */
LPC_IOCON->P4_1 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A1 @ P4.1 */
LPC_IOCON->P4_2 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A2 @ P4.2 */
LPC_IOCON->P4_3 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A3 @ P4.3 */
LPC_IOCON->P4_4 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A4 @ P4.4 */
LPC_IOCON->P4_5 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A5 @ P4.5 */
LPC_IOCON->P4_6 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A6 @ P4.6 */
LPC_IOCON->P4_7 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A7 @ P4.7 */
LPC_IOCON->P4_8 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A8 @ P4.8 */
LPC_IOCON->P4_9 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A9 @ P4.9 */
LPC_IOCON->P4_10 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A10 @ P4.10 */
LPC_IOCON->P4_11 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A11 @ P4.11 */
LPC_IOCON->P4_12 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A12 @ P4.12 */
LPC_IOCON->P4_13 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A13 @ P4.13 */
LPC_IOCON->P4_14 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A14 @ P4.14 */
LPC_IOCON->P4_15 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A15 @ P4.15 */
LPC_IOCON->P4_16 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A16 @ P4.16 */
LPC_IOCON->P4_17 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A17 @ P4.17 */
LPC_IOCON->P4_18 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A18 @ P4.18 */
LPC_IOCON->P4_19 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A19 @ P4.19 */
LPC_IOCON->P4_20 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A20 @ P4.20 */
LPC_IOCON->P4_21 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A21 @ P4.21 */
LPC_IOCON->P4_22 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A22 @ P4.22 */
LPC_IOCON->P4_23 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A23 @ P4.23 */
LPC_IOCON->P4_25 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* WEN @ P4.25 */
#if 1
LPC_IOCON->P4_24 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* OEN @ P4.24 */
LPC_IOCON->P4_26 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* BLSN[0] @ P4.26 */
LPC_IOCON->P4_27 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* BLSN[1] @ P4.27 */
LPC_IOCON->P4_28 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* BLSN[2] @ P4.28 */
LPC_IOCON->P4_29 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* BLSN[3] @ P4.29 */
LPC_IOCON->P4_30 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* CSN[0] @ P4.30 */
LPC_IOCON->P4_31 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* CSN[1] @ P4.31 */
LPC_IOCON->P2_14 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* CSN[2] @ P2.14 */
LPC_IOCON->P2_15 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* CSN[3] @ P2.15 */
#endif
#if 1
LPC_IOCON->P2_16 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* CASN @ P2.16 */
LPC_IOCON->P2_17 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* RASN @ P2.17 */
LPC_IOCON->P2_18 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* CLK[0] @ P2.18 */
LPC_IOCON->P2_19 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* CLK[1] @ P2.19 */
LPC_IOCON->P2_20 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* DYCSN[0] @ P2.20 */
LPC_IOCON->P2_21 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* DYCSN[1] @ P2.21 */
LPC_IOCON->P2_22 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* DYCSN[2] @ P2.22 */
LPC_IOCON->P2_23 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* DYCSN[3] @ P2.23 */
LPC_IOCON->P2_24 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* CKE[0] @ P2.24 */
// LPC_IOCON->P2_25 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* CKE[1] @ P2.25 */
LPC_IOCON->P2_26 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* CKE[2] @ P2.26 */
LPC_IOCON->P2_27 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* CKE[3] @ P2.27 */
LPC_IOCON->P2_28 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* DQM[0] @ P2.28 */
LPC_IOCON->P2_29 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* DQM[1] @ P2.29 */
LPC_IOCON->P2_30 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* DQM[2] @ P2.30 */
LPC_IOCON->P2_31 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* DQM[3] @ P2.31 */
#endif
}
void SDRAM_Init (void)
{
uint32_t i, dwtemp = dwtemp;
uint16_t wtemp = wtemp;
uint32_t mhz, nsPerClk;
/* Enable External Memory Controller power/clock */
LPC_SC->PCONP |= 0x00000800;
LPC_SC->EMCDLYCTL = 0x00001010;
LPC_EMC->Control = 0x00000001;
LPC_EMC->Config = 0x00000000;
EMC_GPIO_Init();
mhz = SystemCoreClock / 1000000;
if (LPC_SC->EMCCLKSEL)
mhz >>= 1;
nsPerClk = 1000 / mhz;
LPC_EMC->DynamicRP = EMC_NS2CLK(20, nsPerClk); /* 20ns, */
LPC_EMC->DynamicRAS = /*EMC_NS2CLK(42, nsPerClk);*/ 15; /* 42ns to 100K ns, */
LPC_EMC->DynamicSREX = 1 - 1; /* tSRE, 1clk, */
LPC_EMC->DynamicAPR = 2 - 1; /* Not found!!! Estimated as 2clk, */
LPC_EMC->DynamicDAL = EMC_NS2CLK(20, nsPerClk) + 2; /* tDAL = tRP + tDPL = 20ns + 2clk */
LPC_EMC->DynamicWR = 2 - 1; /* 2CLK, */
LPC_EMC->DynamicRC = EMC_NS2CLK(63, nsPerClk); /* H57V2562GTR-75C tRC=63ns(min)*/
LPC_EMC->DynamicRFC = EMC_NS2CLK(63, nsPerClk); /* H57V2562GTR-75C tRFC=tRC */
LPC_EMC->DynamicXSR = 0x0000000F; /* exit self-refresh to active, ²»ÖªµÀ£¬ÉèΪ×î¾Ã */
LPC_EMC->DynamicRRD = EMC_NS2CLK(63, nsPerClk); /* 3clk, tRRD=15ns(min) */
LPC_EMC->DynamicMRD = 2 - 1; /* 2clk, tMRD=2clk(min) */
// LPC_EMC->DynamicRP = 0x00000002; /* 3clk=24ns, */
// LPC_EMC->DynamicRAS = 0x00000005; /* 6clk=48ns, */
// LPC_EMC->DynamicSREX = 0x00000001; /* 2clk, */
// LPC_EMC->DynamicAPR = 0x00000001; /* 2clk, */
// LPC_EMC->DynamicDAL = 0x00000005; /* 6clk, */
// LPC_EMC->DynamicWR = 0x00000001; /* 2CLK, */
// LPC_EMC->DynamicRC = 0x00000008; /* 9clk, H57V2562GTR-75C tRC=63ns(min)*/
// LPC_EMC->DynamicRFC = 0x00000008; /* 9clk, H57V2562GTR-75C tRFC=63ns(min) */
// LPC_EMC->DynamicXSR = 0x00000007; /* 8clk, */
// LPC_EMC->DynamicRRD = 0x00000002; /* 3clk, tRRD=15ns(min) */
// LPC_EMC->DynamicMRD = 0x00000001; /* 2clk, tMRD=2clk(min) */
LPC_EMC->DynamicReadConfig = 0x00000001; /* Command delayed strategy, using EMCCLKDELAY */
/* H57V2562GTR-75C: tCL=3CLK, tRCD=20ns(min), 3 CLK=24ns */
LPC_EMC->DynamicRasCas0 = 0x00000303; /* 3 RAS, 3 CAS latency */
/* For Manley lpc1778 SDRAM: H57V2562GTR-75C, 256Mb, 16Mx16, 4 banks, row=13, column=9 */
#ifdef SDRAM_CONFIG_16BIT
LPC_EMC->DynamicConfig0 = 0x680; /* 256Mb, 16Mx16, 4 banks, row=13, column=9, RBC */
#elif defined SDRAM_CONFIG_32BIT
LPC_EMC->DynamicConfig0 = 0x4680; /* 256Mb, 16Mx16, 4 banks, row=13, column=9, RBC */
#endif
delayMs(0, 100);
LPC_EMC->DynamicControl = 0x00000183; /* Issue NOP command */
delayMs(0, 200); /* wait 200ms */
LPC_EMC->DynamicControl = 0x00000103; /* Issue PALL command */
LPC_EMC->DynamicRefresh = 0x00000002; /* ( n * 16 ) -> 32 clock cycles */
for(i = 0; i < 0x80; i++); /* wait 128 AHB clock cycles */
/* 64ms/8192=7.8125us, nx16x8.33ns<7.8125us, n<58.6*/
wtemp = 64000000 / (1 << 13);
wtemp -= 16;
wtemp >>= 4;
wtemp = wtemp * mhz / 1000;
LPC_EMC->DynamicRefresh = wtemp;
LPC_EMC->DynamicControl = 0x00000083; /* Issue MODE command */
#ifdef SDRAM_CONFIG_16BIT
wtemp = *((volatile uint16_t *)(SDRAM_BASE | (0x33<<12))); /* 8 burst, 3 CAS latency */
#elif defined SDRAM_CONFIG_32BIT
dwtemp = *((volatile uint32_t *)(SDRAM_BASE | (0x32<<13))); /* 4 burst, 3 CAS latency */
#endif
LPC_EMC->DynamicControl = 0x00000000; /* Issue NORMAL command */
LPC_EMC->DynamicConfig0 |= 0x80000; /* enable buffer */
delayMs(0, 1);
}

View File

@ -0,0 +1,8 @@
#ifndef SDRAM_H_INCLUDED
#define SDRAM_H_INCLUDED
#define SDRAM_CONFIG_32BIT
void SDRAM_Init (void);
#endif // SDRAM_H_INCLUDED

View File

@ -158,7 +158,6 @@ static rt_err_t rt_uart_init (rt_device_t dev)
// Enable UART Transmit
UART_TxCmd( uart->UART, ENABLE);
// UART_IntConfig( uart->UART, UART_INTCFG_RLS, ENABLE);
UART_IntConfig( uart->UART, UART_INTCFG_RBR, ENABLE);
}
#endif
@ -184,7 +183,6 @@ static rt_err_t rt_uart_init (rt_device_t dev)
// Enable UART Transmit
UART_TxCmd( uart->UART, ENABLE);
// UART_IntConfig( uart->UART, UART_INTCFG_RLS, ENABLE);
UART_IntConfig( uart->UART, UART_INTCFG_RBR, ENABLE);
}
#endif

View File

@ -1,158 +1,206 @@
/* RT-Thread config file */
#ifndef __RTTHREAD_CFG_H__
#define __RTTHREAD_CFG_H__
/* RT_NAME_MAX*/
#define RT_NAME_MAX 8
/* RT_ALIGN_SIZE*/
#define RT_ALIGN_SIZE 8
/* PRIORITY_MAX */
#define RT_THREAD_PRIORITY_MAX 32
/* Tick per Second */
#define RT_TICK_PER_SECOND 100
/* SECTION: RT_DEBUG */
/* Thread Debug */
#define RT_DEBUG
/* #define RT_THREAD_DEBUG */
#define RT_USING_OVERFLOW_CHECK
/* Using Hook */
#define RT_USING_HOOK
/* Using Software Timer */
/* #define RT_USING_TIMER_SOFT */
#define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 512
#define RT_TIMER_TICK_PER_SECOND 10
/* SECTION: IPC */
/* Using Semaphore */
#define RT_USING_SEMAPHORE
/* Using Mutex */
#define RT_USING_MUTEX
/* Using Event */
#define RT_USING_EVENT
/* Using MailBox */
#define RT_USING_MAILBOX
/* Using Message Queue */
#define RT_USING_MESSAGEQUEUE
/* SECTION: Memory Management */
/* Using Memory Pool Management*/
#define RT_USING_MEMPOOL
/* Using Dynamic Heap Management */
#define RT_USING_HEAP
/* Using Small MM */
#define RT_USING_SMALL_MEM
/* Using SLAB Allocator */
//#define RT_USING_SLAB
/* SECTION: Device System */
/* Using Device System */
#define RT_USING_DEVICE
/* SECTION: Console options */
#define RT_USING_CONSOLE
/* the buffer size of console */
#define RT_CONSOLEBUF_SIZE 128
/* SECTION: finsh, a C-Express shell */
/* Using FinSH as Shell*/
#define RT_USING_FINSH
/* Using symbol table */
#define FINSH_USING_SYMTAB
#define FINSH_USING_DESCRIPTION
/* SECTION: device filesystem support */
//#define RT_USING_DFS
#define RT_USING_DFS_ELMFAT
/* the max number of mounted filesystem */
#define DFS_FILESYSTEMS_MAX 2
/* the max number of opened files */
#define DFS_FD_MAX 4
/* the max number of cached sector */
#define DFS_CACHE_MAX_NUM 4
/* SECTION: lwip, a lighwight TCP/IP protocol stack */
/* #define RT_USING_LWIP */
#define RT_LWIP_USING_RT_MEM
/* Enable ICMP protocol*/
#define RT_LWIP_ICMP
/* Enable UDP protocol*/
#define RT_LWIP_UDP
/* Enable TCP protocol*/
#define RT_LWIP_TCP
/* Enable DNS */
#define RT_LWIP_DNS
/* the number of simulatenously active TCP connections*/
#define RT_LWIP_TCP_PCB_NUM 5
/* ip address of target*/
#define RT_LWIP_IPADDR0 192
#define RT_LWIP_IPADDR1 168
#define RT_LWIP_IPADDR2 1
#define RT_LWIP_IPADDR3 30
/* gateway address of target*/
#define RT_LWIP_GWADDR0 192
#define RT_LWIP_GWADDR1 168
#define RT_LWIP_GWADDR2 1
#define RT_LWIP_GWADDR3 1
/* mask address of target*/
#define RT_LWIP_MSKADDR0 255
#define RT_LWIP_MSKADDR1 255
#define RT_LWIP_MSKADDR2 255
#define RT_LWIP_MSKADDR3 0
/* tcp thread options */
#define RT_LWIP_TCPTHREAD_PRIORITY 12
#define RT_LWIP_TCPTHREAD_MBOX_SIZE 4
#define RT_LWIP_TCPTHREAD_STACKSIZE 1024
/* ethernet if thread options */
#define RT_LWIP_ETHTHREAD_PRIORITY 15
#define RT_LWIP_ETHTHREAD_MBOX_SIZE 4
#define RT_LWIP_ETHTHREAD_STACKSIZE 512
/* TCP sender buffer space */
#define RT_LWIP_TCP_SND_BUF 8192
/* TCP receive window. */
#define RT_LWIP_TCP_WND 8192
/* SECTION: RT-Thread/GUI */
/* #define RT_USING_RTGUI */
/* name length of RTGUI object */
#define RTGUI_NAME_MAX 12
/* support 16 weight font */
#define RTGUI_USING_FONT16
/* support Chinese font */
#define RTGUI_USING_FONTHZ
/* use DFS as file interface */
#define RTGUI_USING_DFS_FILERW
/* use font file as Chinese font */
#define RTGUI_USING_HZ_FILE
/* use small size in RTGUI */
#define RTGUI_USING_SMALL_SIZE
/* use mouse cursor */
/* #define RTGUI_USING_MOUSE_CURSOR */
/* default font size in RTGUI */
#define RTGUI_DEFAULT_FONT_SIZE 16
#endif
/* RT-Thread config file */
#ifndef __RTTHREAD_CFG_H__
#define __RTTHREAD_CFG_H__
// <RDTConfigurator URL="http://www.rt-thread.com/eclipse">
// <integer name="RT_NAME_MAX" description="Maximal size of kernel object name length" default="6" />
#define RT_NAME_MAX 6
// <integer name="RT_ALIGN_SIZE" description="Alignment size for CPU architecture data access" default="4" />
#define RT_ALIGN_SIZE 4
// <integer name="RT_THREAD_PRIORITY_MAX" description="Maximal level of thread priority" default="2">
// <item description="8">8</item>
// <item description="32">32</item>
// <item description="256">256</item>
// </integer>
#define RT_THREAD_PRIORITY_MAX 32
// <integer name="RT_TICK_PER_SECOND" description="OS tick per second" default="100" />
#define RT_TICK_PER_SECOND 100
// <section name="RT_DEBUG" description="Kernel Debug Configuration" default="true" >
#define RT_DEBUG
// <bool name="RT_THREAD_DEBUG" description="Thread debug enable" default="false" />
// #define RT_THREAD_DEBUG
// <bool name="RT_USING_OVERFLOW_CHECK" description="Thread stack over flow detect" default="true" />
#define RT_USING_OVERFLOW_CHECK
// </section>
// <bool name="RT_USING_HOOK" description="Using hook functions" default="true" />
#define RT_USING_HOOK
// <section name="RT_USING_TIMER_SOFT" description="Using software timer which will start a thread to handle soft-timer" default="true" >
// #define RT_USING_TIMER_SOFT
// <integer name="RT_TIMER_THREAD_PRIO" description="The priority level of timer thread" default="4" />
#define RT_TIMER_THREAD_PRIO 4
// <integer name="RT_TIMER_THREAD_STACK_SIZE" description="The stack size of timer thread" default="512" />
#define RT_TIMER_THREAD_STACK_SIZE 512
// <integer name="RT_TIMER_TICK_PER_SECOND" description="The soft-timer tick per second" default="10" />
#define RT_TIMER_TICK_PER_SECOND 10
// </section>
// <section name="IPC" description="Inter-Thread communication" default="always" >
// <bool name="RT_USING_SEMAPHORE" description="Using semaphore in the system" default="true" />
#define RT_USING_SEMAPHORE
// <bool name="RT_USING_MUTEX" description="Using mutex in the system" default="true" />
#define RT_USING_MUTEX
// <bool name="RT_USING_EVENT" description="Using event group in the system" default="true" />
#define RT_USING_EVENT
// <bool name="RT_USING_MAILBOX" description="Using mailbox in the system" default="true" />
#define RT_USING_MAILBOX
// <bool name="RT_USING_MESSAGEQUEUE" description="Using message queue in the system" default="true" />
#define RT_USING_MESSAGEQUEUE
// </section>
// <section name="MM" description="Memory Management" default="always" >
// <bool name="RT_USING_MEMPOOL" description="Using Memory Pool Management in the system" default="true" />
#define RT_USING_MEMPOOL
// <bool name="RT_USING_MEMHEAP" description="Using Memory Heap Object in the system" default="true" />
#define RT_USING_MEMHEAP
// <bool name="RT_USING_HEAP" description="Using Dynamic Heap Management in the system" default="true" />
#define RT_USING_HEAP
// <bool name="RT_USING_SMALL_MEM" description="Optimizing for small memory" default="false" />
#define RT_USING_SMALL_MEM
// <bool name="RT_USING_SLAB" description="Using SLAB memory management for large memory" default="false" />
// #define RT_USING_SLAB
// </section>
// <section name="RT_USING_DEVICE" description="Using Device Driver Framework" default="true" >
#define RT_USING_DEVICE
// <integer name="RT_UART_RX_BUFFER_SIZE" description="The buffer size for UART reception" default="64" />
#define RT_UART_RX_BUFFER_SIZE 64
// </section>
// <section name="RT_USING_CONSOLE" description="Using console" default="true" >
#define RT_USING_CONSOLE
// <integer name="RT_CONSOLEBUF_SIZE" description="The buffer size for console output" default="128" />
#define RT_CONSOLEBUF_SIZE 128
// </section>
// <bool name="RT_USING_COMPONENTS_INIT" description="Using RT-Thread components initialization" default="true" />
// #define RT_USING_COMPONENTS_INIT
// <section name="RT_USING_FINSH" description="Using finsh as shell, which is a C-Express shell" default="true" >
#define RT_USING_FINSH
// <bool name="FINSH_USING_SYMTAB" description="Using symbol table in finsh shell" default="true" />
#define FINSH_USING_SYMTAB
// <bool name="FINSH_USING_DESCRIPTION" description="Keeping description in symbol table" default="true" />
#define FINSH_USING_DESCRIPTION
// <integer name="FINSH_THREAD_STACK_SIZE" description="The stack size for finsh thread" default="4096" />
#define FINSH_THREAD_STACK_SIZE 4096
// </section>
// <section name="LIBC" description="C Runtime library setting" default="always" >
// <bool name="RT_USING_NEWLIB" description="Using newlib library, only available under GNU GCC" default="true" />
// #define RT_USING_NEWLIB
// <bool name="RT_USING_PTHREADS" description="Using POSIX threads library" default="true" />
// #define RT_USING_PTHREADS
// </section>
// <section name="RT_USING_DFS" description="Device file system" default="true" >
// #define RT_USING_DFS
// <bool name="DFS_USING_WORKDIR" description="Using working directory" default="true" />
// #define DFS_USING_WORKDIR
// <integer name="DFS_FILESYSTEMS_MAX" description="The maximal number of mounted file system" default="4" />
#define DFS_FILESYSTEMS_MAX 2
// <integer name="DFS_FD_MAX" description="The maximal number of opened files" default="4" />
#define DFS_FD_MAX 4
// <bool name="RT_USING_DFS_ELMFAT" description="Using ELM FatFs" default="true" />
#define RT_USING_DFS_ELMFAT
// <integer name="RT_DFS_ELM_USE_LFN" description="Support long file name" default="0">
// <item description="LFN1">1</item>
// <item description="LFN1">2</item>
// </integer>
#define RT_DFS_ELM_USE_LFN 1
// <integer name="RT_DFS_ELM_MAX_LFN" description="Maximal size of file name length" default="256" />
#define RT_DFS_ELM_MAX_LFN 64
// <bool name="RT_USING_DFS_YAFFS2" description="Using YAFFS2" default="false" />
// #define RT_USING_DFS_YAFFS2
// <bool name="RT_USING_DFS_UFFS" description="Using UFFS" default="false" />
// #define RT_USING_DFS_UFFS
// <bool name="RT_USING_DFS_DEVFS" description="Using devfs for device objects" default="true" />
// #define RT_USING_DFS_DEVFS
// <bool name="RT_USING_DFS_NFS" description="Using NFS v3 client file system" default="false" />
// #define RT_USING_DFS_NFS
// <string name="RT_NFS_HOST_EXPORT" description="NFSv3 host export" default="192.168.1.5:/" />
#define RT_NFS_HOST_EXPORT "192.168.1.5:/"
// </section>
// <section name="RT_USING_LWIP" description="lwip, a lightweight TCP/IP protocol stack" default="true" >
// #define RT_USING_LWIP
// <bool name="RT_LWIP_ICMP" description="Enable ICMP protocol" default="true" />
#define RT_LWIP_ICMP
// <bool name="RT_LWIP_IGMP" description="Enable IGMP protocol" default="false" />
// #define RT_LWIP_IGMP
// <bool name="RT_LWIP_UDP" description="Enable UDP protocol" default="true" />
#define RT_LWIP_UDP
// <bool name="RT_LWIP_TCP" description="Enable TCP protocol" default="true" />
#define RT_LWIP_TCP
// <bool name="RT_LWIP_DNS" description="Enable DNS protocol" default="true" />
#define RT_LWIP_DNS
// <integer name="RT_LWIP_PBUF_NUM" description="Maximal number of buffers in the pbuf pool" default="4" />
#define RT_LWIP_PBUF_NUM 4
// <integer name="RT_LWIP_TCP_PCB_NUM" description="Maximal number of simultaneously active TCP connections" default="5" />
#define RT_LWIP_TCP_PCB_NUM 3
// <integer name="RT_LWIP_TCP_SND_BUF" description="TCP sender buffer size" default="8192" />
#define RT_LWIP_TCP_SND_BUF 2048
// <integer name="RT_LWIP_TCP_WND" description="TCP receive window" default="8192" />
#define RT_LWIP_TCP_WND 2048
// <bool name="RT_LWIP_SNMP" description="Enable SNMP protocol" default="false" />
// #define RT_LWIP_SNMP
// <bool name="RT_LWIP_DHCP" description="Enable DHCP client to get IP address" default="false" />
// #define RT_LWIP_DHCP
// <integer name="RT_LWIP_TCP_SEG_NUM" description="the number of simultaneously queued TCP" default="4" />
#define RT_LWIP_TCP_SEG_NUM 4
// <integer name="RT_LWIP_TCPTHREAD_PRIORITY" description="the thread priority of TCP thread" default="128" />
#define RT_LWIP_TCPTHREAD_PRIORITY 12
// <integer name="RT_LWIP_TCPTHREAD_MBOX_SIZE" description="the mail box size of TCP thread to wait for" default="32" />
#define RT_LWIP_TCPTHREAD_MBOX_SIZE 8
// <integer name="RT_LWIP_TCPTHREAD_STACKSIZE" description="the thread stack size of TCP thread" default="4096" />
#define RT_LWIP_TCPTHREAD_STACKSIZE 4096
// <integer name="RT_LWIP_ETHTHREAD_PRIORITY" description="the thread priority of ethnetif thread" default="144" />
#define RT_LWIP_ETHTHREAD_PRIORITY 14
// <integer name="RT_LWIP_ETHTHREAD_MBOX_SIZE" description="the mail box size of ethnetif thread to wait for" default="8" />
#define RT_LWIP_ETHTHREAD_MBOX_SIZE 8
// <integer name="RT_LWIP_ETHTHREAD_STACKSIZE" description="the stack size of ethnetif thread" default="512" />
#define RT_LWIP_ETHTHREAD_STACKSIZE 512
// <ipaddr name="RT_LWIP_IPADDR" description="IP address of device" default="192.168.1.30" />
#define RT_LWIP_IPADDR0 192
#define RT_LWIP_IPADDR1 168
#define RT_LWIP_IPADDR2 1
#define RT_LWIP_IPADDR3 30
// <ipaddr name="RT_LWIP_GWADDR" description="Gateway address of device" default="192.168.1.1" />
#define RT_LWIP_GWADDR0 192
#define RT_LWIP_GWADDR1 168
#define RT_LWIP_GWADDR2 1
#define RT_LWIP_GWADDR3 1
// <ipaddr name="RT_LWIP_MSKADDR" description="Mask address of device" default="255.255.255.0" />
#define RT_LWIP_MSKADDR0 255
#define RT_LWIP_MSKADDR1 255
#define RT_LWIP_MSKADDR2 255
#define RT_LWIP_MSKADDR3 0
// </section>
// <section name="RT_USING_RTGUI" description="RT-Thread/GUI" default="true" >
#define RT_USING_RTGUI
// <integer name="RTGUI_NAME_MAX" description="the name size of RT-Thread/GUI widget/objects" default="12" />
#define RTGUI_NAME_MAX 12
// <bool name="RTGUI_USING_SMALL_SIZE" description="use small size in RT-Thread/GUI" default="true" />
#define RTGUI_USING_SMALL_SIZE
// <bool name="RTGUI_USING_FONT16" description="support 16 weight font" default="true" />
#define RTGUI_USING_FONT16
// <bool name="RTGUI_USING_FONT12" description="support 12 weight font" default="true" />
// #define RTGUI_USING_FONT12
// <bool name="RTGUI_USING_FONTHZ" description="support Chinese font" default="true" />
#define RTGUI_USING_FONTHZ
// <integer name="RTGUI_DEFAULT_FONT_SIZE" description="default font size in RT-Thread/GUI" default="16" />
#define RTGUI_DEFAULT_FONT_SIZE 16
// <bool name="RTGUI_USING_DFS_FILERW" description="use RT-Thread/DFS as file interface" default="true" />
#define RTGUI_USING_DFS_FILERW
// <bool name="RTGUI_USING_HZ_BMP" description="use Chinese font bitmap engine" default="true" />
#define RTGUI_USING_HZ_BMP
// <bool name="RTGUI_USING_HZ_FILE" description="use font file as Chinese font" default="false" />
// #define RTGUI_USING_HZ_FILE
// <bool name="RTGUI_USING_MOUSE_CURSOR" description="use mouse cursor" default="false" />
// #define RTGUI_USING_MOUSE_CURSOR
// </section>
// </RDTConfigurator>
#endif

View File

@ -40,7 +40,7 @@ if PLATFORM == 'gcc':
DEVICE = ' -mcpu=cortex-m3 -mthumb'
CFLAGS = DEVICE + ' -DRT_USING_MINILIBC'
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-lpc17xx.map,-cref,-u,Reset_Handler -T lpc17xx_rom.ld'
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-lpc178x.map,-cref,-u,Reset_Handler -T rtthread-lpc178x.ld'
CPATH = ''
LPATH = ''
@ -64,7 +64,7 @@ elif PLATFORM == 'armcc':
DEVICE = ' --device DARMP1'
CFLAGS = DEVICE + ' --apcs=interwork'
AFLAGS = DEVICE
LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers --list rtthread-lpc17xx.map --scatter lpc17xx_rom.sct'
LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers --list rtthread-lpc178x.map --scatter rtthread-lpc178x.sct'
CFLAGS += ' -I' + EXEC_PATH + '/ARM/RV31/INC'
LFLAGS += ' --libpath ' + EXEC_PATH + '/ARM/RV31/LIB'

View File

@ -0,0 +1,133 @@
/*
* linker script for LPC1788 (512kB Flash, 48kB + 48kB SRAM ) with GNU ld
* yiyue.fang 2012-04-14
*/
/* Program Entry, set to mark it as "used" and avoid gc */
MEMORY
{
CODE (rx) : ORIGIN = 0x00000000, LENGTH = 0x00080000
DATA (rw) : ORIGIN = 0x10000000, LENGTH = 0x00010000
}
ENTRY(Reset_Handler)
_system_stack_size = 0x200;
SECTIONS
{
.text :
{
. = ALIGN(4);
KEEP(*(.interrupt_vector)) /* Startup code */
. = ALIGN(4);
*(.text) /* remaining code */
*(.text.*) /* remaining code */
*(.rodata) /* read-only data (constants) */
*(.rodata*)
*(.glue_7)
*(.glue_7t)
*(.gnu.linkonce.t*)
/* section information for finsh shell */
. = ALIGN(4);
__fsymtab_start = .;
KEEP(*(FSymTab))
__fsymtab_end = .;
. = ALIGN(4);
__vsymtab_start = .;
KEEP(*(VSymTab))
__vsymtab_end = .;
. = ALIGN(4);
. = ALIGN(4);
_etext = .;
} > CODE = 0
/* .ARM.exidx is sorted, so has to go in its own output section. */
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
/* This is used by the startup in order to initialize the .data secion */
_sidata = .;
} > CODE
__exidx_end = .;
/* .data section which is used for initialized data */
.data : AT (_sidata)
{
. = ALIGN(4);
/* This is used by the startup in order to initialize the .data secion */
_sdata = . ;
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
. = ALIGN(4);
/* This is used by the startup in order to initialize the .data secion */
_edata = . ;
} >DATA
.stack :
{
. = . + _system_stack_size;
. = ALIGN(4);
_estack = .;
} >DATA
__bss_start = .;
.bss :
{
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .;
*(.bss)
*(.bss.*)
*(COMMON)
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_ebss = . ;
*(.bss.init)
} > DATA
__bss_end = .;
_end = .;
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
* Symbols in the DWARF debugging sections are relative to the beginning
* of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
}

View File

@ -0,0 +1,15 @@
; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
LR_IROM1 0x00000000 0x00080000 { ; load region size_region
ER_IROM1 0x00000000 0x00080000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x10000000 0x00010000 { ; RW data
.ANY (+RW +ZI)
}
}