diff --git a/bsp/lpc178x/SConscript b/bsp/lpc178x/SConscript index 569e67de75..e489710e77 100644 --- a/bsp/lpc178x/SConscript +++ b/bsp/lpc178x/SConscript @@ -1,5 +1,3 @@ -import rtconfig -Import('RTT_ROOT') from building import * cwd = str(Dir('#')) diff --git a/bsp/lpc178x/applications/application.c b/bsp/lpc178x/applications/application.c index 8b7265d9ce..ad08f61e54 100644 --- a/bsp/lpc178x/applications/application.c +++ b/bsp/lpc178x/applications/application.c @@ -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 #include @@ -39,10 +31,13 @@ #include #endif +#ifdef RT_USING_RTGUI +#include +#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 +#include +#include + +#include + +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 diff --git a/bsp/lpc178x/applications/startup.c b/bsp/lpc178x/applications/startup.c index 4900d62b1f..1b87bb71c4 100644 --- a/bsp/lpc178x/applications/startup.c +++ b/bsp/lpc178x/applications/startup.c @@ -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; } - -/*@}*/ diff --git a/bsp/lpc178x/drivers/SConscript b/bsp/lpc178x/drivers/SConscript index 80dff26c0f..b5a9b36b11 100644 --- a/bsp/lpc178x/drivers/SConscript +++ b/bsp/lpc178x/drivers/SConscript @@ -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] diff --git a/bsp/lpc178x/drivers/board.c b/bsp/lpc178x/drivers/board.c index 787f0ad645..0564a1ccc2 100644 --- a/bsp/lpc178x/drivers/board.c +++ b/bsp/lpc178x/drivers/board.c @@ -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 - } /*@}*/ diff --git a/bsp/lpc178x/drivers/board.h b/bsp/lpc178x/drivers/board.h index 38937d362b..b20597036f 100644 --- a/bsp/lpc178x/drivers/board.h +++ b/bsp/lpc178x/drivers/board.h @@ -18,27 +18,28 @@ #include "LPC177x_8x.h" -/* whether use board external SDRAM memory */ -// Use external SDRAM memory on the board -// Enable External SDRAM memory -#define LPC_EXT_SDRAM 0 -// Begin Address of External SDRAM -// Default: 0x60000000 -#define LPC_EXT_SDRAM_BEGIN 0xA0000000 /* the begining address of external SDRAM */ -// End Address of External SDRAM -// Default: 0x60000000 -#define LPC_EXT_SDRAM_END 0xA4000000 /* the end address of external SDRAM */ -// +// -/* RT_USING_UART */ -#define RT_UART_RX_BUFFER_SIZE 64 +// +#define LPC_EXT_SDRAM 1 +// +#define LPC_EXT_SDRAM_BEGIN 0xA0000000 +// +#define LPC_EXT_SDRAM_END 0xA4000000 + +// #define RT_USING_UART0 +// //#define RT_USING_UART1 +// //#define RT_USING_UART2 -#define CONSOLE_DEVICE "uart0" -#define FINSH_DEVICE_NAME CONSOLE_DEVICE +// +#define RT_CONSOLE_DEVICE_NAME "uart0" +// + +#define FINSH_DEVICE_NAME RT_CONSOLE_DEVICE_NAME void rt_hw_board_init(void); #endif diff --git a/bsp/lpc178x/drivers/drv_glcd.c b/bsp/lpc178x/drivers/drv_glcd.c new file mode 100644 index 0000000000..e4893305cc --- /dev/null +++ b/bsp/lpc178x/drivers/drv_glcd.c @@ -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 +#include +#include +//#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; + } +} + + diff --git a/bsp/lpc178x/drivers/drv_glcd.h b/bsp/lpc178x/drivers/drv_glcd.h new file mode 100644 index 0000000000..5f11b822fc --- /dev/null +++ b/bsp/lpc178x/drivers/drv_glcd.h @@ -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 diff --git a/bsp/lpc178x/drivers/emac.c b/bsp/lpc178x/drivers/emac.c index 9c78088ee2..bc0b8ba459 100644 --- a/bsp/lpc178x/drivers/emac.c +++ b/bsp/lpc178x/drivers/emac.c @@ -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); diff --git a/bsp/lpc178x/drivers/lpc17xx_lcd.c b/bsp/lpc178x/drivers/lpc17xx_lcd.c index 3eb9d14971..671e55ed17 100644 --- a/bsp/lpc178x/drivers/lpc17xx_lcd.c +++ b/bsp/lpc178x/drivers/lpc17xx_lcd.c @@ -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 +FINSH_FUNCTION_EXPORT(lcd_fill, lcd_fill ); +#endif diff --git a/bsp/lpc178x/drivers/sdram.c b/bsp/lpc178x/drivers/sdram.c new file mode 100644 index 0000000000..a35b85ef74 --- /dev/null +++ b/bsp/lpc178x/drivers/sdram.c @@ -0,0 +1,278 @@ +#include + +#include +#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); + +} + + diff --git a/bsp/lpc178x/drivers/sdram.h b/bsp/lpc178x/drivers/sdram.h new file mode 100644 index 0000000000..d89e515ebb --- /dev/null +++ b/bsp/lpc178x/drivers/sdram.h @@ -0,0 +1,8 @@ +#ifndef SDRAM_H_INCLUDED +#define SDRAM_H_INCLUDED + +#define SDRAM_CONFIG_32BIT + +void SDRAM_Init (void); + +#endif // SDRAM_H_INCLUDED diff --git a/bsp/lpc178x/drivers/uart.c b/bsp/lpc178x/drivers/uart.c index 608bbaec61..725b7d4028 100644 --- a/bsp/lpc178x/drivers/uart.c +++ b/bsp/lpc178x/drivers/uart.c @@ -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 diff --git a/bsp/lpc178x/rtconfig.h b/bsp/lpc178x/rtconfig.h index 2302e56094..4e33135dbd 100644 --- a/bsp/lpc178x/rtconfig.h +++ b/bsp/lpc178x/rtconfig.h @@ -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__ + +// + +// +#define RT_NAME_MAX 6 +// +#define RT_ALIGN_SIZE 4 +// +// 8 +// 32 +// 256 +// +#define RT_THREAD_PRIORITY_MAX 32 +// +#define RT_TICK_PER_SECOND 100 +//
+#define RT_DEBUG +// +// #define RT_THREAD_DEBUG +// +#define RT_USING_OVERFLOW_CHECK +//
+ +// +#define RT_USING_HOOK +//
+// #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 +//
+ +//
+// +#define RT_USING_SEMAPHORE +// +#define RT_USING_MUTEX +// +#define RT_USING_EVENT +// +#define RT_USING_MAILBOX +// +#define RT_USING_MESSAGEQUEUE +//
+ +//
+// +#define RT_USING_MEMPOOL +// +#define RT_USING_MEMHEAP +// +#define RT_USING_HEAP +// +#define RT_USING_SMALL_MEM +// +// #define RT_USING_SLAB +//
+ +//
+#define RT_USING_DEVICE +// +#define RT_UART_RX_BUFFER_SIZE 64 +//
+ +//
+#define RT_USING_CONSOLE +// +#define RT_CONSOLEBUF_SIZE 128 +//
+ +// +// #define RT_USING_COMPONENTS_INIT +//
+#define RT_USING_FINSH +// +#define FINSH_USING_SYMTAB +// +#define FINSH_USING_DESCRIPTION +// +#define FINSH_THREAD_STACK_SIZE 4096 +//
+ +//
+// +// #define RT_USING_NEWLIB +// +// #define RT_USING_PTHREADS +//
+ +//
+// #define RT_USING_DFS +// +// #define DFS_USING_WORKDIR +// +#define DFS_FILESYSTEMS_MAX 2 +// +#define DFS_FD_MAX 4 +// +#define RT_USING_DFS_ELMFAT +// +// 1 +// 2 +// +#define RT_DFS_ELM_USE_LFN 1 +// +#define RT_DFS_ELM_MAX_LFN 64 +// +// #define RT_USING_DFS_YAFFS2 +// +// #define RT_USING_DFS_UFFS +// +// #define RT_USING_DFS_DEVFS +// +// #define RT_USING_DFS_NFS +// +#define RT_NFS_HOST_EXPORT "192.168.1.5:/" +//
+ +//
+// #define RT_USING_LWIP +// +#define RT_LWIP_ICMP +// +// #define RT_LWIP_IGMP +// +#define RT_LWIP_UDP +// +#define RT_LWIP_TCP +// +#define RT_LWIP_DNS +// +#define RT_LWIP_PBUF_NUM 4 +// +#define RT_LWIP_TCP_PCB_NUM 3 +// +#define RT_LWIP_TCP_SND_BUF 2048 +// +#define RT_LWIP_TCP_WND 2048 +// +// #define RT_LWIP_SNMP +// +// #define RT_LWIP_DHCP +// +#define RT_LWIP_TCP_SEG_NUM 4 +// +#define RT_LWIP_TCPTHREAD_PRIORITY 12 +// +#define RT_LWIP_TCPTHREAD_MBOX_SIZE 8 +// +#define RT_LWIP_TCPTHREAD_STACKSIZE 4096 +// +#define RT_LWIP_ETHTHREAD_PRIORITY 14 +// +#define RT_LWIP_ETHTHREAD_MBOX_SIZE 8 +// +#define RT_LWIP_ETHTHREAD_STACKSIZE 512 +// +#define RT_LWIP_IPADDR0 192 +#define RT_LWIP_IPADDR1 168 +#define RT_LWIP_IPADDR2 1 +#define RT_LWIP_IPADDR3 30 +// +#define RT_LWIP_GWADDR0 192 +#define RT_LWIP_GWADDR1 168 +#define RT_LWIP_GWADDR2 1 +#define RT_LWIP_GWADDR3 1 +// +#define RT_LWIP_MSKADDR0 255 +#define RT_LWIP_MSKADDR1 255 +#define RT_LWIP_MSKADDR2 255 +#define RT_LWIP_MSKADDR3 0 +//
+ +//
+#define RT_USING_RTGUI +// +#define RTGUI_NAME_MAX 12 +// +#define RTGUI_USING_SMALL_SIZE +// +#define RTGUI_USING_FONT16 +// +// #define RTGUI_USING_FONT12 +// +#define RTGUI_USING_FONTHZ +// +#define RTGUI_DEFAULT_FONT_SIZE 16 +// +#define RTGUI_USING_DFS_FILERW +// +#define RTGUI_USING_HZ_BMP +// +// #define RTGUI_USING_HZ_FILE +// +// #define RTGUI_USING_MOUSE_CURSOR +//
+ +//
+ +#endif diff --git a/bsp/lpc178x/rtconfig.py b/bsp/lpc178x/rtconfig.py index e3d5c23743..3fd8b5ccb4 100644 --- a/bsp/lpc178x/rtconfig.py +++ b/bsp/lpc178x/rtconfig.py @@ -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' diff --git a/bsp/lpc178x/rtthread-lpc177x.ld b/bsp/lpc178x/rtthread-lpc177x.ld new file mode 100644 index 0000000000..872f55dd9f --- /dev/null +++ b/bsp/lpc178x/rtthread-lpc177x.ld @@ -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) } +} diff --git a/bsp/lpc178x/rtthread-lpc178x.sct b/bsp/lpc178x/rtthread-lpc178x.sct new file mode 100644 index 0000000000..893f49ce4a --- /dev/null +++ b/bsp/lpc178x/rtthread-lpc178x.sct @@ -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) + } +} +