示例#1
0
void rt_init_thread_entry(void *parameter)
{
#ifdef RT_USING_RTGUI
	{
		rt_device_t dc;

		/* init Display Controller */
		rt_hw_dc_init();
			
		/* re-init device driver */
		rt_device_init_all();
	
		/* find Display Controller device */
		dc = rt_device_find("dc");
	
		/* set Display Controller device as rtgui graphic driver */		
		rtgui_graphic_set_device(dc);
	}
#endif

#ifdef RT_USING_COMPONENTS_INIT
	/* initialization RT-Thread Components */
	rt_components_init();
#endif
}
示例#2
0
void rt_init_thread_entry(void* parameter)
{
#ifdef RT_USING_COMPONENTS_INIT
    /* initialization RT-Thread Components */
    rt_components_init();
#endif

#ifdef  RT_USING_FINSH
    finsh_set_device(RT_CONSOLE_DEVICE_NAME);
#endif  /* RT_USING_FINSH */

    /* Filesystem Initialization */
#if defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT)
    /* mount sd card fat partition 1 as root directory */
    if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
    {
        rt_kprintf("File System initialized!\n");
    }
    else
        rt_kprintf("File System initialzation failed!\n");
#endif  /* RT_USING_DFS */

#ifdef RT_USING_RTGUI
    {
        extern void rt_hw_lcd_init();
        extern void rtgui_touch_hw_init(void);

        rt_device_t lcd;

        /* init lcd */
        rt_hw_lcd_init();

        /* init touch panel */
        rtgui_touch_hw_init();

        /* re-init device driver */
        rt_device_init_all();

        /* find lcd device */
        lcd = rt_device_find("lcd");

        /* set lcd device as rtgui graphic driver */
        rtgui_graphic_set_device(lcd);

#ifndef RT_USING_COMPONENTS_INIT
        /* init rtgui system server */
        rtgui_system_server_init();
#endif

        calibration_set_restore(cali_setup);
        calibration_set_after(cali_store);
        calibration_init();
    }
#endif /* #ifdef RT_USING_RTGUI */
}
示例#3
0
/* initialize for gui driver */
int rtgui_lcd_init(void)
{
    rt_device_t device;

    rt_hw_lcd_init();

    device = rt_device_find("lcd");
    /* set graphic device */
    rtgui_graphic_set_device(device);

    return 0;
}
示例#4
0
/***************************************************************************//**
 * @brief
 *   Initialize OLED device
 *
 * @details
 *
 * @note
 *
 ******************************************************************************/
void bsp_hw_oled_init(void)
{
    do
    {
#if OLED_DEVICE_INTERFACE == INTERFACE_4WIRE_SPI
        /* Find SPI device */
        spi_dev = rt_device_find(OLED_USING_DEVICE_NAME);
        if (spi_dev == RT_NULL)
        {
            oled_debug("OLED: Can't find device %s!\n",
                OLED_USING_DEVICE_NAME);
            break;
        }
        oled_debug("OLED: Find device %s\n", OLED_USING_DEVICE_NAME);
#endif
        /* Register OLED device */
        oled_device.type            = RT_Device_Class_Graphic;
        oled_device.rx_indicate     = RT_NULL;
        oled_device.tx_complete     = RT_NULL;
        oled_device.init            = board_oled_init;
        oled_device.open            = miniStm32_oled_open;
        oled_device.close           = miniStm32_oled_close;
        oled_device.read            = RT_NULL;
        oled_device.write           = RT_NULL;
        oled_device.control         = miniStm32_oled_control;
#if defined(RT_USING_GUIENGINE)
        oled_device.user_data       = (void *)&oled_ops;
#else
        oled_device.user_data       = RT_NULL;
#endif
        if (rt_device_register(
            &oled_device,
            OLED_DEVICE_NAME,
            RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE //RT_DEVICE_FLAG_DMA_TX
            ) != RT_EOK)
        {
            break;
        }
#if defined(RT_USING_GUIENGINE)
        /* Set as rtgui graphic driver */
        if (rtgui_graphic_set_device(&oled_device) != RT_EOK)
        {
            break;
        }
#endif
        oled_debug("OLED: H/W init OK!\n");
        return;
    } while(0);

    oled_debug("OLED err: H/W init failed!\n");
}
示例#5
0
/***************************************************************************//**
 * @brief
 *   Initialize OLED device
 *
 * @details
 *
 * @note
 *
 ******************************************************************************/
void miniStm32_hw_oled_init(void)
{
    rt_uint32_t flag;
    rt_uint8_t status;

    do
    {
        /* Init OLED info */
        flag = RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE; //RT_DEVICE_FLAG_DMA_TX
        oled_info.pixel_format      = RTGRAPHIC_PIXEL_FORMAT_MONO;
        oled_info.bits_per_pixel    = 1;
        oled_info.width             = MINISTM32_OLED_WIDTH;
        oled_info.height            = MINISTM32_OLED_HEIGHT;
        oled_info.framebuffer       = RT_NULL; //(rt_uint8_t *)frame_buffer;
//        if (miniStm32_oled_register(&oled_device, OLED_DEVICE_NAME, flag, RT_NULL) != RT_EOK)
        if (miniStm32_oled_register(&oled_device, OLED_DEVICE_NAME, flag,
            (void *)&oled_ops) != RT_EOK)
        {
            break;
        }

        /* Init OLED lock */
        if (rt_sem_init(&oled_lock, OLED_DEVICE_NAME, 1, RT_IPC_FLAG_FIFO) != RT_EOK)
        {
            break;
        }

        /* Init ssd1306 */
        if (ssd1306_init() != RT_EOK)
        {
            break;
        }

        oled_readStatus(&status);
        oled_debug("OLED: status %x\n", status);

        /* Set as rtgui graphic driver */
        if (rtgui_graphic_set_device(&oled_device) != RT_EOK)
        {
            break;
        }

        oled_debug("OLED: H/W init OK!\n");
        return;
    } while(0);

    oled_debug("OLED err: H/W init failed!\n");
}
示例#6
0
void rt_init_thread_entry(void* parameter)
{    
     /* initialization RT-Thread Components */
#ifdef RT_USING_COMPONENTS_INIT
    rt_components_init();
#endif
    
#ifdef RT_USING_DFS  
    #ifdef RT_USING_DFS_ELMFAT
        /* mount spi flash as root directory */
        if (dfs_mount("W25Q64", "/", "elm", 0, 0) == 0)
        {
            rt_kprintf("spi flash mount to / !\n");
        }
        else
        {
            rt_kprintf("spi flash mount to / failed!\n");
        }
        
        /* mount sd card fat partition 0 as root directory */
        if (dfs_mount("sd0", "/sd0", "elm", 0, 0) == 0)
        {
            rt_kprintf("sd0 mount to /sd0 !\n");
        }
        else
        {
            rt_kprintf("sd0 mount to /sd0 failed!\n");
        }    
    #endif /* RT_USING_DFS_ELMFAT */
        
#endif /* DFS */
    
#ifdef RT_USING_GUIENGINE
	{
		rt_device_t device;

		device = rt_device_find("lcd");
		/* re-set graphic device */
		rtgui_graphic_set_device(device);
        
        rt_gui_demo_init();
	}
#endif
}
示例#7
0
void gui_init()
{
	extern void rtgui_touch_hw_init(void);
	extern rt_err_t load_setup(void);
    rtgui_rect_t rect;
	rt_device_t lcd;

	/* 初始化LCD驱动 */
    ra8875_init();
	lcd = rt_device_find("lcd");
	if (lcd != RT_NULL)
	{
		rt_device_init(lcd);
		rtgui_graphic_set_device(lcd);

		/* 初始化RT-Thread/GUI server */
	    rtgui_system_server_init();

    /* 注册面板 */
    rect.x1 = 0;
    rect.y1 = 0;
    rect.x2 = 800;
    rect.y2 = 480;
    rtgui_panel_register("main", &rect);
    rtgui_panel_set_default_focused("main");

		/* 初始化键盘驱动 */
//		rt_hw_key_init();

		/* 初始化触摸屏驱动 */
//		load_setup(); //touch装载默认值
//		rtgui_touch_hw_init();
	    rt_device_init_all();

		/* 初始化workbench */
		workbench_init();
	}
}
示例#8
0
static void *sdl_loop(void *lpParam)
#endif
{
    int quit = 0;
    SDL_Event event;
    int button_state = 0;
    rt_device_t device;

#ifndef _WIN32
    sigset_t  sigmask, oldmask;
    /* set the getchar without buffer */
    sigfillset(&sigmask);
    pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask);
#endif

    sdlfb_hw_init();

    device = rt_device_find("sdl");
    rtgui_graphic_set_device(device);
#ifdef _WIN32
    SetEvent(sdl_ok_event);
#endif
    /* handle SDL event */
    while (!quit)
    {
        SDL_WaitEvent(&event);

        switch (event.type)
        {
        case SDL_MOUSEMOTION:
        {
            struct rtgui_event_mouse emouse;
            emouse.parent.type = RTGUI_EVENT_MOUSE_MOTION;
            emouse.parent.sender = RT_NULL;
            emouse.wid = RT_NULL;

            emouse.x = ((SDL_MouseMotionEvent *)&event)->x;
            emouse.y = ((SDL_MouseMotionEvent *)&event)->y;

            /* init mouse button */
            emouse.button = button_state;

            /* send event to server */
            rtgui_server_post_event(&emouse.parent, sizeof(struct rtgui_event_mouse));
        }
        break;

        case SDL_MOUSEBUTTONDOWN:
        case SDL_MOUSEBUTTONUP:
        {
            struct rtgui_event_mouse emouse;
            SDL_MouseButtonEvent *mb;

            emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
            emouse.parent.sender = RT_NULL;
            emouse.wid = RT_NULL;

            mb = (SDL_MouseButtonEvent *)&event;

            emouse.x = mb->x;
            emouse.y = mb->y;

            /* init mouse button */
            emouse.button = 0;

            /* set emouse button */
            if (mb->button & (1 << (SDL_BUTTON_LEFT - 1)))
            {
                emouse.button |= RTGUI_MOUSE_BUTTON_LEFT;
            }
            else if (mb->button & (1 << (SDL_BUTTON_RIGHT - 1)))
            {
                emouse.button |= RTGUI_MOUSE_BUTTON_RIGHT;
            }
            else if (mb->button & (1 << (SDL_BUTTON_MIDDLE - 1)))
            {
                emouse.button |= RTGUI_MOUSE_BUTTON_MIDDLE;
            }

            if (mb->type == SDL_MOUSEBUTTONDOWN)
            {
                emouse.button |= RTGUI_MOUSE_BUTTON_DOWN;
                button_state = emouse.button;
            }
            else
            {
                emouse.button |= RTGUI_MOUSE_BUTTON_UP;
                button_state = 0;
            }


            /* send event to server */
            rtgui_server_post_event(&emouse.parent, sizeof(struct rtgui_event_mouse));
        }
        break;

        case SDL_KEYUP:
        {
            struct rtgui_event_kbd ekbd;
            ekbd.parent.type    = RTGUI_EVENT_KBD;
            ekbd.parent.sender  = RT_NULL;
            ekbd.type = RTGUI_KEYUP;
            ekbd.wid = RT_NULL;
            ekbd.mod = event.key.keysym.mod;
            ekbd.key = event.key.keysym.sym;

            /* FIXME: unicode */
            ekbd.unicode = 0;

            /* send event to server */
            rtgui_server_post_event(&ekbd.parent, sizeof(struct rtgui_event_kbd));
        }
        break;

        case SDL_KEYDOWN:
        {
            struct rtgui_event_kbd ekbd;
            ekbd.parent.type    = RTGUI_EVENT_KBD;
            ekbd.parent.sender  = RT_NULL;
            ekbd.type = RTGUI_KEYDOWN;
            ekbd.wid = RT_NULL;
            ekbd.mod = event.key.keysym.mod;
            ekbd.key = event.key.keysym.sym;

            /* FIXME: unicode */
            ekbd.unicode = 0;

            /* send event to server */
            rtgui_server_post_event(&ekbd.parent, sizeof(struct rtgui_event_kbd));
        }
        break;

        case SDL_QUIT:
            SDL_Quit();
            quit = 1;
            break;

        default:
            break;
        }

        if (quit)
            break;
    }
    //exit(0);
    return 0;
}
示例#9
0
void rt_init_thread_entry(void *parameter)
{
/* Filesystem Initialization */
#ifdef RT_USING_DFS
	{
		/* init the device filesystem */
		dfs_init();

#if defined(RT_USING_DFS_ELMFAT)
		/* init the elm chan FatFs filesystam*/
		elm_init();
		/* mount sd card fat partition 1 as root directory */
		if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
		{
			rt_kprintf("File System initialized!\n");
		}
		else
			rt_kprintf("File System initialzation failed!\n");
#endif

#if defined(RT_USING_DFS_ROMFS)
		dfs_romfs_init();
		if (dfs_mount(RT_NULL, "/rom", "rom", 0, &romfs_root) == 0)
		{
			rt_kprintf("ROM File System initialized!\n");
		}
		else
			rt_kprintf("ROM File System initialzation failed!\n");
#endif

#if defined(RT_USING_DFS_DEVFS)
		devfs_init();
		if (dfs_mount(RT_NULL, "/dev", "devfs", 0, 0) == 0)
			rt_kprintf("Device File System initialized!\n");
		else
			rt_kprintf("Device File System initialzation failed!\n");

		#ifdef RT_USING_NEWLIB
		/* init libc */
		libc_system_init("uart0");
		#endif
#endif

#if defined(RT_USING_DFS) && defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS)
		/* NFSv3 Initialization */
		nfs_init();

		if (dfs_mount(RT_NULL, "/nfs", "nfs", 0, RT_NFS_HOST_EXPORT) == 0)
			rt_kprintf("NFSv3 File System initialized!\n");
		else
			rt_kprintf("NFSv3 File System initialzation failed!\n");
#endif

#if defined(RT_USING_DFS_UFFS)
		/* init the uffs filesystem */
		dfs_uffs_init();

		/* mount flash device as flash directory */
		if (dfs_mount("nand0", "/nand0", "uffs", 0, 0) == 0)
			rt_kprintf("UFFS File System initialized!\n");
		else
			rt_kprintf("UFFS File System initialzation failed!\n");
#endif
	}
#endif

#ifdef RT_USING_RTGUI
	{
		extern void rtgui_system_server_init(void);

		rt_device_t lcd;

		/* init lcd */
		rt_hw_lcd_init();

		/* init touch panel */
		rtgui_touch_hw_init();

		/* init keypad */
		rt_hw_key_init();

		/* find lcd device */
		lcd = rt_device_find("lcd");

		/* set lcd device as rtgui graphic driver */
		rtgui_graphic_set_device(lcd);

		/* initalize rtgui system server */
		rtgui_system_server_init();
	}
#endif

/* LwIP Initialization */
#ifdef RT_USING_LWIP
	{
		extern void lwip_sys_init(void);
		eth_system_device_init();

		/* register ethernetif device */
		rt_hw_dm9000_init();

		/* init lwip system */
		lwip_sys_init();
		rt_kprintf("TCP/IP initialized!\n");
	}
#endif

#ifdef RT_USING_FTK
	{
		rt_thread_t ftk_thread;

		/* init lcd */
		rt_hw_lcd_init();

		/* init touch panel */
		rtgui_touch_hw_init();

		/* init keypad */
		rt_hw_key_init();

		/* create ftk thread */
		ftk_thread = rt_thread_create("ftk",
									rt_ftk_thread_entry, RT_NULL,
									10 * 1024, 8, 20);

		/* startup ftk thread */
		if (ftk_thread != RT_NULL)
			rt_thread_startup(ftk_thread);
	}
#endif
}
示例#10
0
/* thread phase init */
void rt_init_thread_entry(void *parameter)
{
#ifdef RT_USING_SPI
    {
        extern void rt_hw_spi0_init(void);
        rt_hw_spi0_init();
    }
#endif
#ifdef RT_USING_I2C
    {
        extern void rt_hw_i2c_init(void);
        rt_i2c_core_init();
        rt_hw_i2c_init();
    }
#endif

    /* Filesystem Initialization */
#ifdef RT_USING_DFS
    {
        /* init the device filesystem */
        dfs_init();

        /* init the elm FAT filesystam*/
        elm_init();

        /* mount sd card fat partition 1 as root directory */
        if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
            rt_kprintf("File System initialized!\n");
        else
            rt_kprintf("File System init failed!\n");
    }
#endif

    /* LwIP Initialization */
#ifdef RT_USING_LWIP
    {
        extern void lwip_sys_init(void);
        extern void lpc17xx_emac_hw_init(void);

        eth_system_device_init();

        /* register ethernetif device */
        lpc_emac_hw_init();
        /* init all device */
        rt_device_init_all();

        /* init lwip system */
        lwip_sys_init();
        rt_kprintf("TCP/IP initialized!\n");
    }
#endif

#ifdef RT_USING_RTGUI
    {
        extern void rtgui_system_server_init(void);
        extern void application_init(void);

        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);
            /* init rtgui system server */
            rtgui_system_server_init();
            rt_hw_joystick_init();
            rtgui_touch_hw_init("spi20");
            /* startup rtgui in demo of RT-Thread/GUI examples */
            application_init();
        }

    }
#endif

#ifdef RT_USING_FINSH
    /* initialize finsh */
    finsh_system_init();
    finsh_set_device(FINSH_DEVICE_NAME);
#endif
}
void rt_init_thread_entry(void* parameter)
{
    {
        extern void rt_platform_init(void);
        rt_platform_init();
    }

    /* Filesystem Initialization */
#if defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT)
	/* initialize the device file system */
	dfs_init();

	/* initialize the elm chan FatFS file system*/
	elm_init();
    
    /* mount sd card fat partition 1 as root directory */
    if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
    {
        rt_kprintf("File System initialized!\n");
    }
    else
    {
        rt_kprintf("File System initialzation failed!\n");
    }
#endif /* RT_USING_DFS && RT_USING_DFS_ELMFAT */

#ifdef RT_USING_LWIP
	/* initialize lwip stack */
	/* register ethernetif device */
	eth_system_device_init();

	/* initialize lwip system */
	lwip_system_init();
	rt_kprintf("TCP/IP initialized!\n");
#endif

#ifdef RT_USING_FINSH
	/* initialize finsh */
	finsh_system_init();
	finsh_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
        
#ifdef RT_USING_RTGUI
	{
                
		rt_device_t device;
		struct rt_device_rect_info info;
                
                extern int rtgui_system_server_init(void);
                rtgui_system_server_init();
                
		device = rt_device_find("lcd");
		/* re-set graphic device */
		rtgui_graphic_set_device(device);
		
		rtgui_system_server_init();

		/* ´¥ÃþÆÁУ׼
                calibration();*/
                               
		/* ²âÊÔ´¥ÃþÆÁ°´Å¥ ¼°¼òÒ×¼ÆËãÆ÷
		ui_button();*/
                               
                /*ÔËÐÐdemo */
                application_init();           
                
	}
#endif        

}
示例#12
0
void rt_init_thread_entry(void* parameter)
{
#ifdef RT_USING_COMPONENTS_INIT
	    /* initialization RT-Thread Components */
	    rt_components_init();
#endif

    /* LwIP Initialization */
#ifdef RT_USING_LWIP
    {
        extern void lwip_sys_init(void);

        /* register ethernetif device */
        eth_system_device_init();

        rt_hw_stm32_eth_init();
        /* re-init device driver */
        rt_device_init_all();

        /* init lwip system */
        lwip_sys_init();
        rt_kprintf("TCP/IP initialized!\n");
    }
#endif

//FS
#ifdef RT_USING_DFS
	dfs_init();
#ifdef RT_USING_MTD_NAND
	nand_mtd_init();
	dfs_uffs_init();

	if (dfs_mount("psram0", "/", "uffs", 0, 0) == 0)
	{
	rt_kprintf("uffs mount / partion ok\n");
	}
	else
	rt_kprintf("uffs mount / partion failed!\n");
#endif
#endif
	rt_hw_lcd_init();
//GUI
#ifdef RT_USING_RTGUI
    {
        extern void rt_hw_lcd_init();
        //extern void rtgui_touch_hw_init(void);

        rt_device_t lcd;

        /* init lcd */
        rt_hw_lcd_init();

        /* init touch panel */
        //rtgui_touch_hw_init();

        /* find lcd device */
        lcd = rt_device_find("lcd");

        /* set lcd device as rtgui graphic driver */
        rtgui_graphic_set_device(lcd);

#ifndef RT_USING_COMPONENTS_INIT
        /* init rtgui system server */
        rtgui_system_server_init();
#endif

        //calibration_set_restore(cali_setup);
        //calibration_set_after(cali_store);
        //calibration_init();
    }
#endif /* #ifdef RT_USING_RTGUI */

}
示例#13
0
/***************************************************************************//**
 * @brief
 *   Initialize LCD device
 *
 * @details
 *
 * @note
 *
 ******************************************************************************/
void efm32_spiLcd_init(void)
{
    struct efm32_usart_device_t *usart;
    rt_uint32_t                 flag;
    DMD_DisplayGeometry         *geometry;
    rt_uint32_t                 ret;

	do
	{
        USART_InitSync_TypeDef init = USART_INITSYNC_DEFAULT;

		/* Find SPI device */
		lcd = rt_device_find(LCD_USING_DEVICE_NAME);
		if (lcd == RT_NULL)
		{
			lcd_debug("LCD err: Can't find %s!\n", LCD_USING_DEVICE_NAME);
			break;
		}
		lcd_debug("LCD: Find device %s\n", LCD_USING_DEVICE_NAME);

        /* Config CS pin */
        usart = (struct efm32_usart_device_t *)(lcd->user_data);
        if (!(usart->state & USART_STATE_AUTOCS))
        {
            GPIO_PinModeSet(LCD_CS_PORT, LCD_CS_PIN, gpioModePushPull, 1);
            lcdAutoCs = false;
        }

        /* TFT initialize or reinitialize. Assumes EBI has been configured
           correctly in DVK_init(DVK_Init_EBI) */
        rt_uint32_t freq = SystemCoreClockGet();
        rt_uint32_t i;
        rt_bool_t warning = RT_FALSE;

        /* If we are in BC_UIF_AEM_EFM state, we can redraw graphics */
        while (DVK_readRegister(&BC_REGISTER->UIF_AEM) != BC_UIF_AEM_EFM)
        {
            if (!warning)
            {
                lcd_debug("LCD: Please press AEM button!!!\n");
                warning = RT_TRUE;
            }
        }

        lcd_debug("LCD: Got LCD control\n");
        /* If we're not BC_ARB_CTRL_EBI state, we need to reconfigure display controller */
        if (DVK_readRegister(&BC_REGISTER->ARB_CTRL) != BC_ARB_CTRL_EBI)
        {
            lcd_debug("LCD: Set to EBI mode\n");
            /* Configure for EBI mode and reset display */
            DVK_displayControl(DVK_Display_EBI);
            DVK_displayControl(DVK_Display_ResetAssert);
            DVK_displayControl(DVK_Display_PowerDisable);
            /* Short delay */
            freq = SystemCoreClockGet();
            for(i = 0; i < (freq / 100); i++)
            {
                __NOP();
            }
#if defined(LCD_MAPPED)
            /* Configure display for address mapped method + 3-wire SPI mode */
            DVK_displayControl(DVK_Display_Mode8080);
            DVK_displayControl(DVK_Display_PowerEnable);
            DVK_displayControl(DVK_Display_ResetRelease);

            /* Initialize graphics - abort on failure */
            ret = DMD_init(BC_SSD2119_BASE, BC_SSD2119_BASE + 2);
            if (ret == DMD_OK)
            {
                /* Make sure display is configured with correct rotation */
                DMD_flipDisplay(1, 1);
            }
            else if (ret != DMD_ERROR_DRIVER_ALREADY_INITIALIZED)
            {
                lcd_debug("LCD err: driver init failed %x\n", ret);
                break;
            }
#elif defined(LCD_DIRECT)
            /* Configure TFT direct drive method from EBI BANK2 */
            const EBI_TFTInit_TypeDef tftInit =
            {
                ebiTFTBank2,                  /* Select EBI Bank 2 */
                ebiTFTWidthHalfWord,          /* Select 2-byte (16-bit RGB565) increments */
                ebiTFTColorSrcMem,            /* Use memory as source for mask/blending */
                ebiTFTInterleaveUnlimited,    /* Unlimited interleaved accesses */
                ebiTFTFrameBufTriggerVSync,   /* VSYNC as frame buffer update trigger */
                false,                        /* Drive DCLK from negative edge of internal clock */
                ebiTFTMBDisabled,             /* No masking and alpha blending enabled */
                ebiTFTDDModeExternal,         /* Drive from external memory */
                ebiActiveLow,                 /* CS Active Low polarity */
                ebiActiveHigh,                /* DCLK Active High polarity */
                ebiActiveLow,                 /* DATAEN Active Low polarity */
                ebiActiveLow,                 /* HSYNC Active Low polarity */
                ebiActiveLow,                 /* VSYNC Active Low polarity */
                320,                          /* Horizontal size in pixels */
                1,                            /* Horizontal Front Porch */
                30,                           /* Horizontal Back Porch */
                2,                            /* Horizontal Synchronization Pulse Width */
                240,                          /* Vertical size in pixels */
                1,                            /* Vertical Front Porch */
                4,                            /* Vertical Back Porch */
                2,                            /* Vertical Synchronization Pulse Width */
                0x0000,                       /* Frame Address pointer offset to EBI memory base */
                4,                            /* DCLK Period */
                0,                            /* DCLK Start cycles */
                0,                            /* DCLK Setup cycles */
                0,                            /* DCLK Hold cycles */
            };

            DVK_enablePeripheral(DVK_TFT);

            /* Configure display for Direct Drive + 3-wire SPI mode */
            DVK_displayControl(DVK_Display_ModeGeneric);
            DVK_displayControl(DVK_Display_PowerEnable);
            DVK_displayControl(DVK_Display_ResetRelease);

            /* Configure GPIO for EBI and TFT */
            /* EBI TFT DCLK/Dot Clock */
            GPIO_PinModeSet(gpioPortA, 8, gpioModePushPull, 0);
            /* EBI TFT DATAEN */
            GPIO_PinModeSet(gpioPortA, 9, gpioModePushPull, 0);
            /* EBI TFT VSYNC  */
            GPIO_PinModeSet(gpioPortA, 10, gpioModePushPull, 0);
            /* EBI TFT HSYNC */
            GPIO_PinModeSet(gpioPortA, 11, gpioModePushPull, 0);

            /* Initialize display */
            DMD_init(0, (rt_uint32_t)EBI_BankAddress(EBI_BANK2));

            /* Configure EBI TFT direct drive */
            EBI_TFTInit(&tftInit);
#endif
        }

        /* Get LCD geometry */
        ret = DMD_getDisplayGeometry(&geometry);
        if (ret != DMD_OK)
        {
            lcd_debug("LCD err: get geometry failed!\n");
            break;
        }

        /* Init LCD info */
		flag = RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_DMA_TX;
        lcd_info.pixel_format       = RTGRAPHIC_PIXEL_FORMAT_RGB565P;
        lcd_info.bits_per_pixel     = 16;
        lcd_info.width              = geometry->xSize;
        lcd_info.height             = geometry->ySize;
#if defined(LCD_MAPPED)
        lcd_info.framebuffer        = RT_NULL;
        efm32_spiLcd_register(&lcd_device, LCD_DEVICE_NAME, flag, (void *)&lcd_ops);
#elif defined(LCD_DIRECT)
        lcd_info.framebuffer        = (rt_uint8_t *)EBI_BankAddress(EBI_BANK2);
        efm32_spiLcd_register(&lcd_device, LCD_DEVICE_NAME, flag, RT_NULL);
#endif

        /* Set clipping area */
        ret = DMD_setClippingArea(0, 0, geometry->xSize, geometry->ySize);
        if (ret != DMD_OK)
        {
            lcd_debug("LCD err: set clipping area failed!\n");
            break;
        }
        /* Read device code */
        rt_uint16_t code = 0xFFFF;
#if defined(LCD_MAPPED)
        code = DMDIF_readDeviceCode();
#endif
        /* Set as rtgui graphic driver */
        rtgui_graphic_set_device(&lcd_device);

        lcd_debug("LCD: H/W init OK!\n");
        return;
    } while(0);

    lcd_debug("LCD err: H/W init failed!\n");
}
示例#14
0
void rt_init_thread_entry(void *parameter)
{
    rt_device_t lcd;  
    
    rt_hw_led_init();
	rt_hw_key_init();
	rt_hw_adc_init();
	rt_hw_lcd_init();      
	rt_hw_cpu_init();

#ifdef RT_USING_RTGUI
	extern void rtgui_system_server_init(void);

	/* find lcd device */
	lcd = rt_device_find("lcd");    
    
	/* set lcd device as rtgui graphic driver */		
	rtgui_graphic_set_device(lcd);

	/* init rtgui system server */
	rtgui_system_server_init();
   
	/* startup rtgui */
	rtgui_startup();
#else
	{
	char buf[20] = {'\0'};
    struct lcd_msg msg;
    rt_device_t device;   
    device = rt_device_find("lcd");
	rt_device_control(device, RT_DEVICE_CTRL_LCD_CLEAR_SCR, RT_NULL);
	x = 1;
	y = 1;
	rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, "ADC"); 
	x = 1;
	y = 20;
	rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, "CPU");
	x = 1;
	y = 40;
	rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, "KEY");
    
    while(1)
    {
        if (rt_mq_recv(&mq, &msg, sizeof(msg), RT_WAITING_FOREVER) == RT_EOK)
        {
        	switch(msg.type)
    		{
    			case ADC_MSG:
					x = 40;
					y = 1;
					rt_memset(buf, 0, sizeof(buf));
					rt_sprintf(buf, "%04d", msg.adc_value);
					rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, buf); 
					break;
				case CPU_MSG:
					x = 40;
					y = 20;
					rt_memset(buf, 0, sizeof(buf));
					rt_sprintf(buf, "%03d %03d", msg.major, msg.minor);
					rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, buf); 
					break;
				case KEY_MSG:
					x = 40;
					y = 40;
					rt_memset(buf, 0, sizeof(buf));
                    switch(msg.key)
                	{
                		case KEY_DOWN:
							rt_sprintf(buf, "DOWN KEY ");
							break;
						case KEY_UP:
							rt_sprintf(buf, "UP KEY   ");
							break;	
                		case KEY_RIGHT:
							rt_sprintf(buf, "RIGHT KEY");
							break;
						case KEY_LEFT:
							rt_sprintf(buf, "LEFT KEY ");
							break;	
                		case KEY_ENTER:
							rt_sprintf(buf, "ENTER KEY");
							break;
						default:
							rt_sprintf(buf, "NO KEY   ");
							break;								
                	}
					rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, buf); 
                    break;                    
    		}
        }
    }
	}
#endif
}
示例#15
0
void rt_init_thread_entry(void* parameter)
{
#if RT_USING_RTC
	rt_device_t rtc_dev;
#endif
#if TEST_TRAP || EM_ALL_TYPE_BASE || TEST_485
	rt_thread_t thread_h;
#endif
	RT_APPS_INIT_DEBUG(("invoke rt_init_thread_entry()!\n"));

	say_thread_start();

#if TEST_485
	thread_h = rt_thread_create("t485", rt_test_485_entry, RT_NULL, 512, 30, 10);
	if (thread_h != RT_NULL)
		rt_thread_startup(thread_h);
#endif
#if TEST_TRAP
		trap_test_init();
#endif

#if EM_ALL_TYPE_BASE && !TEST_485
	/* recv ptct info server */
	thread_h = rt_thread_create("rpct-ser", recv_em_frame, RT_NULL, 1024, 30, 10);
	if (thread_h != RT_NULL)
		rt_thread_startup(thread_h);
#endif

#if RT_USING_RS485_BUS  && !TEST_485
#if EM_MASTER_DEV || EM_MULTI_MASTER_DEV
	rs485_master_init(); /* David */
#elif WIRELESS_MASTER_NODE
	rs485_slave_init();
#endif
#endif

	/* Filesystem Initialization */
#if RT_USING_FILESYSTEM
	RT_APPS_INIT_DEBUG(("will init fs\n"));
	rt_hw_spiflash_init();
	sf_set_prote_level_to_none();

	/* init the device filesystem */
	dfs_init();
#ifdef RT_USING_DFS_ELMFAT
	/* init the elm chan FatFs filesystam*/
	elm_init();

#if 1
	/* mount spi-flash fat partition 1 as root directory */
	if (dfs_mount("sf0", "/", "elm", 0, 0) == 0)
#else
	/* mount sd card fat partition 1 as root directory */
	if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
#endif
		rt_kprintf("File System initialized!\n");
	else
		rt_kprintf("File System initialzation failed!\n");
#endif

#endif

	/* LwIP Initialization */
#if RT_USING_TCPIP_STACK
	init_tcpip_lwip_stack();
#endif

#if RT_USING_GUI
	{
		extern void rtgui_startup();
		extern void rt_hw_lcd_init();
		extern void rtgui_touch_hw_init(void);

		rt_device_t lcd;

		/* init lcd */
		rt_hw_lcd_init();

		/* init touch panel */
		rtgui_touch_hw_init();

		/* re-init device driver */
		rt_device_init_all();

		/* find lcd device */
		lcd = rt_device_find("lcd");

		/* set lcd device as rtgui graphic driver */
		rtgui_graphic_set_device(lcd);

		/* startup rtgui */
		rtgui_startup();
	}
#endif /* #if RT_USING_GUI */

	nvic_cfg_app();
#if USE_STM32_IWDG
	IWDG_Enable();
#endif

#if RT_USING_RTC
	rtc_dev = rt_device_find("rtc");
	if (NULL != rtc_dev) {
		rtc_dev->control(rtc_dev, RT_DEVICE_CTRL_RTC_CALI_SET, NULL);
	} else {
		rt_kprintf("find rtc device fail\n");
	}
#endif

#if EM_ALL_TYPE_BASE
	extern void sinkinfo_ipc_init(void);
	sinkinfo_ipc_init();
#endif
#if (RT_USING_RS485_BUS && EM_ALL_TYPE_BASE  && !TEST_485)
	ammeter_init();
#endif

#if WIRELESS_MASTER_NODE
	creat_4432master_th();
#elif WIRELESS_SLAVE_NODE /* #if WIRELESS_MASTER_NODE */
	creat_4432slave_th();
#else
	/* none */
#endif /* #if WIRELESS_MASTER_NODE */

#if RT_USING_ADE7880 && !TEST_485
	start_7880();	/* 有较长的延迟, 秒级别, David */
#endif

#if EM_ALL_TYPE_BASE && !TEST_485
	sinkinfo_init();
#endif

}
void rt_init_thread_entry(void* parameter)
{
/* Filesystem Initialization */
#ifdef RT_USING_DFS
	{
		/* init the device filesystem */
		dfs_init();

#ifdef RT_USING_DFS_ELMFAT
		/* init the elm chan FatFs filesystam*/
		elm_init();

		/* mount sd card fat partition 1 as root directory */
		if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
		{
			rt_kprintf("File System initialized!\n");
		}
		else
			rt_kprintf("File System initialzation failed!\n");
#endif
	}
#endif

/* LwIP Initialization */
#ifdef RT_USING_LWIP
	{
		extern void lwip_sys_init(void);

		/* register ethernetif device */
		eth_system_device_init();

#ifdef STM32F10X_CL
		rt_hw_stm32_eth_init();
#else
	/* STM32F103 */
	#if STM32_ETH_IF == 0
			rt_hw_enc28j60_init();
	#elif STM32_ETH_IF == 1
			rt_hw_dm9000_init();
	#endif
#endif

		/* re-init device driver */
		rt_device_init_all();

		/* init lwip system */
		lwip_sys_init();
		rt_kprintf("TCP/IP initialized!\n");
	}
#endif

#ifdef RT_USING_RTGUI
	{
	    extern void rtgui_system_server_init(void);
	    extern void rt_hw_lcd_init();
	    extern void rtgui_touch_hw_init(void);

		rt_device_t lcd;

		/* init lcd */
		rt_hw_lcd_init();

		/* init touch panel */
		rtgui_touch_hw_init();

		/* re-init device driver */
		rt_device_init_all();

		/* find lcd device */
		lcd = rt_device_find("lcd");

		/* set lcd device as rtgui graphic driver */
		rtgui_graphic_set_device(lcd);

		/* init rtgui system server */
		rtgui_system_server_init();
	}
#endif /* #ifdef RT_USING_RTGUI */
}
示例#17
0
/* thread phase init */
void rt_init_thread_entry(void *parameter)
{
// #ifdef RT_USING_I2C
//     rt_i2c_core_init();
//     rt_hw_i2c_init();
// #endif

    rt_hw_spi_init();
    rt_system_module_init();
    /* Filesystem Initialization */
#ifdef RT_USING_DFS
    {
        extern rt_err_t mci_hw_init(const char *device_name);
        /* initilize sd card */
        mci_hw_init("sd0");
        /* init the device filesystem */
        dfs_init();

        /* init the elm FAT filesystam*/
        elm_init();
#ifdef RT_USING_NFTL
        {
            extern	void rt_hw_mtd_nand_init(void);
            rt_hw_mtd_nand_init();
            nftl_init();
            nftl_mount();

            // list_mem();
        }
#else
        /* mount sd card fat partition 1 as root directory */
        if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
            rt_kprintf("File System initialized!\n");
        else
            rt_kprintf("File System init failed!\n");
#endif
    }
#endif
    /* LwIP Initialization */
#ifdef RT_USING_LWIP
    {
        extern void lwip_sys_init(void);

        eth_system_device_init();

        /* register ethernetif device */
        lpc_emac_hw_init();
        /* init all device */
        rt_device_init_all();

        /* init lwip system */
        lwip_sys_init();
        rt_kprintf("TCP/IP initialized!\n");
    }
#endif

#ifdef RT_USING_RTGUI
    {
        extern void realtouch_ui_init(void);
        extern void rt_hw_key_init(void);
        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);

            /* init rtgui system server */
            rtgui_system_server_init();
            rt_thread_delay(5);
            rt_hw_key_init();
            rtgui_touch_hw_init("spi10");
            /* startup rtgui realtouch ui */
            realtouch_ui_init();

        }
    }
#endif

#ifdef RT_USING_FINSH
    /* initialize finsh */
    finsh_system_init();
    finsh_set_device(FINSH_DEVICE_NAME);
#endif
}