Ejemplo n.º 1
0
/* initialize for touch & calibration */
int touch_calibration_init(void)
{
    rt_uint8_t magic = 0;
    calculate_data_t data;
    struct rtgui_calibration_ops *ops;

    ops = calibration_get_ops();

    /* initialization the eeprom  on chip  */
    EEPROM_Init();
    /* initialization the touch driver */
    rtgui_touch_hw_init("spi10");
    /* set callback to save calibration data */
    calibration_set_after(calibration_data_save);
    /* initialization rtgui tonch server */
    rtgui_touch_init(ops);
    /* restore calibration data */
    EEPROM_Read(0, CALIBRATION_DATA_PAGE, &magic, MODE_8_BIT, 1);
    if (CALIBRATION_DATA_MAGIC != magic)
    {
        rt_kprintf("touch is not calibration,now calibration it please.\n");
        calibration_init(RT_NULL);
    }
    else
    {
        EEPROM_Read(CALIBRATION_DATA_OFFSET, CALIBRATION_DATA_PAGE, &data, MODE_8_BIT, sizeof(calculate_data_t));
        calibration_set_data(&data);
    }
    /* power down the EEPROM */
    EEPROM_PowerDown(ENABLE);
    return 0;
}
Ejemplo n.º 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 */
}