mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-09 20:45:41 +08:00
remove bsp/simlinux
This commit is contained in:
1 parent
f2636ea813
commit
832bbb9fe2
20 files changed
-2596
No files matched your search
@@ -1,12 +0,0 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
objs = []
|
||||
list = os.listdir(cwd)
|
||||
|
||||
for d in list:
|
||||
path = os.path.join(cwd, d)
|
||||
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||
objs = objs + SConscript(os.path.join(d, 'SConscript'))
|
||||
|
||||
Return('objs')
|
||||
@@ -1,91 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
import rtconfig
|
||||
|
||||
if os.getenv('RTT_ROOT'):
|
||||
RTT_ROOT = os.getenv('RTT_ROOT')
|
||||
else:
|
||||
RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
|
||||
|
||||
if os.getenv('RTT_RTGUI'):
|
||||
RTT_RTGUI = os.getenv('RTT_RTGUI')
|
||||
else:
|
||||
# set the rtgui root directory by hand
|
||||
# empty string means use the RTGUI in svn
|
||||
# RTT_RTGUI = os.path.normpath(r'F:\Project\git\rt-gui\components\rtgui')
|
||||
RTT_RTGUI =''
|
||||
|
||||
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
||||
from building import *
|
||||
|
||||
|
||||
env = Environment()
|
||||
|
||||
Export('RTT_ROOT')
|
||||
Export('rtconfig')
|
||||
|
||||
if rtconfig.PLATFORM == 'cl':
|
||||
TARGET = 'rtthread-win32.' + rtconfig.TARGET_EXT
|
||||
|
||||
libs = Split('''
|
||||
winmm
|
||||
gdi32
|
||||
winspool
|
||||
comdlg32
|
||||
advapi32
|
||||
shell32
|
||||
ole32
|
||||
oleaut32
|
||||
uuid
|
||||
odbc32
|
||||
odbccp32
|
||||
''')
|
||||
definitions = Split('''
|
||||
WIN32
|
||||
_DEBUG
|
||||
_CONSOLE
|
||||
MSVC
|
||||
_TIME_T_DEFINED
|
||||
''')
|
||||
env.Append(CCFLAGS=rtconfig.CFLAGS)
|
||||
env.Append(LINKFLAGS=rtconfig.LFLAGS)
|
||||
env['LIBS']=libs
|
||||
env['CPPDEFINES']=definitions
|
||||
else:
|
||||
TARGET = 'rtthread'
|
||||
env.Append(CCFLAGS=rtconfig.CFLAGS)
|
||||
env.Append(LINKFLAGS=rtconfig.LFLAGS)
|
||||
|
||||
|
||||
# prepare building environment
|
||||
|
||||
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False, remove_components=['rtgui'])
|
||||
if GetDepend('RT_USING_RTGUI'):
|
||||
sdl_lib = ['SDL', 'SDLmain']
|
||||
sdl_lib_path = [os.path.abspath('SDL/lib/x86')]
|
||||
sdl_include_path = [os.path.abspath('SDL/include')]
|
||||
env.Append(LIBS=sdl_lib)
|
||||
env.Append(LIBPATH=sdl_lib_path)
|
||||
env.Append(CPPPATH=sdl_include_path)
|
||||
|
||||
if RTT_RTGUI:
|
||||
objs += SConscript(os.path.join(RTT_RTGUI, 'SConscript'),
|
||||
variant_dir='build/components/rtgui',
|
||||
duplicate=0)
|
||||
objs = objs + SConscript(RTT_RTGUI+'/../../demo/examples/SConscript',
|
||||
variant_dir='build/examples/gui', duplicate=0)
|
||||
else:
|
||||
objs += SConscript(os.path.join(RTT_ROOT + '/components/rtgui', 'SConscript'),
|
||||
variant_dir='build/components/rtgui',
|
||||
duplicate=0)
|
||||
objs = objs + SConscript(RTT_ROOT + '/examples/gui/SConscript',
|
||||
variant_dir='build/examples/gui', duplicate=0)
|
||||
|
||||
if GetDepend('RT_USING_TC'):
|
||||
objs = objs + SConscript(RTT_ROOT + '/examples/kernel/SConscript', variant_dir = 'build/tc/kernel', duplicate=0)
|
||||
|
||||
# build program
|
||||
program = env.Program(TARGET, objs)
|
||||
|
||||
# end building
|
||||
EndBuilding(TARGET, program)
|
||||
@@ -1,9 +0,0 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd, str(Dir('#'))]
|
||||
|
||||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* File : application.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2009-01-05 Bernard the first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <stdio.h>
|
||||
#include <board.h>
|
||||
|
||||
#include <components.h>
|
||||
|
||||
|
||||
void rt_init_thread_entry(void *parameter)
|
||||
{
|
||||
#ifdef RT_USING_LWIP
|
||||
pcap_netif_hw_init();
|
||||
#endif
|
||||
|
||||
/* initialization RT-Thread Components */
|
||||
rt_components_init();
|
||||
|
||||
rt_platform_init();
|
||||
|
||||
/* File system Initialization */
|
||||
#ifdef RT_USING_DFS
|
||||
{
|
||||
#ifdef RT_USING_DFS_WINSHAREDIR
|
||||
{
|
||||
extern rt_err_t rt_win_sharedir_init(const char *name);
|
||||
extern int dfs_win32_init(void);
|
||||
|
||||
rt_win_sharedir_init("wdd");
|
||||
dfs_win32_init();
|
||||
|
||||
if (dfs_mount("wdd", "/", "wdir", 0, 0) == 0)
|
||||
rt_kprintf("win32 share directory initialized!\n");
|
||||
else
|
||||
rt_kprintf("win32 share directory initialized failed!\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_DFS_ELMFAT
|
||||
/* mount sd card fatfs as root directory */
|
||||
//if (dfs_mount("sd0", "/disk/sd", "elm", 0, 0) == 0)
|
||||
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
|
||||
rt_kprintf("fatfs initialized!\n");
|
||||
else
|
||||
rt_kprintf("fatfs initialization failed!\n");
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_DFS_UFFS
|
||||
/* mount uffs as the nand flash file system */
|
||||
if (dfs_mount("nand0", "/disk/nand", "uffs", 0, 0) == 0)
|
||||
rt_kprintf("uffs initialized!\n");
|
||||
else
|
||||
rt_kprintf("uffs initialization failed!\n");
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_DFS_JFFS2
|
||||
/* mount jffs2 as the nor flash file system */
|
||||
if (dfs_mount("nor", "/disk/nor", "jffs2", 0, 0) == 0)
|
||||
rt_kprintf("jffs2 initialized!\n");
|
||||
else
|
||||
rt_kprintf("jffs2 initialization failed!\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(RT_USING_RTGUI)
|
||||
//rt_thread_delay(RT_TICK_PER_SECOND);
|
||||
//snake_main();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void rt_test_thread_entry(void *parameter)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
rt_kprintf("hello, world\n");
|
||||
rt_thread_delay(RT_TICK_PER_SECOND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int rt_application_init()
|
||||
{
|
||||
rt_thread_t tid;
|
||||
|
||||
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);
|
||||
|
||||
tid = rt_thread_create("test",
|
||||
rt_test_thread_entry, RT_NULL,
|
||||
2048, RT_THREAD_PRIORITY_MAX * 3 / 4, 20);
|
||||
if (tid != RT_NULL)
|
||||
rt_thread_startup(tid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
@@ -1,29 +0,0 @@
|
||||
#include <rtthread.h>
|
||||
#include "board.h"
|
||||
|
||||
void rt_platform_init(void)
|
||||
{
|
||||
#ifdef RT_USING_DFS
|
||||
/* initialize sd card */
|
||||
rt_hw_sdcard_init();
|
||||
|
||||
#if defined(RT_USING_MTD_NAND)
|
||||
rt_hw_mtd_nand_init();
|
||||
#endif
|
||||
|
||||
#if defined(RT_USING_MTD_NOR)
|
||||
sst25vfxx_mtd_init("nor", 0, RT_UINT32_MAX);
|
||||
#endif
|
||||
|
||||
#endif /* RT_USING_DFS */
|
||||
|
||||
#ifdef RT_USING_RTGUI
|
||||
/* start sdl thread to simulate an LCD */
|
||||
rt_hw_sdl_start();
|
||||
#endif /* RT_USING_RTGUI */
|
||||
|
||||
#ifdef _WIN32
|
||||
rt_thread_idle_sethook(rt_hw_win32_low_cpu);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* File : startup.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006, RT-Thread Develop Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://openlab.rt-thread.com/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2012-09-03 prife first implementation
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "board.h"
|
||||
|
||||
/**
|
||||
* @addtogroup win32
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
|
||||
extern int rt_application_init(void);
|
||||
#ifdef RT_USING_FINSH
|
||||
extern void finsh_system_init(void);
|
||||
extern void finsh_set_device(const char *device);
|
||||
#endif
|
||||
|
||||
extern rt_uint8_t *heap;
|
||||
/**
|
||||
* This function will startup RT-Thread RTOS.
|
||||
*/
|
||||
void rtthread_startup(void)
|
||||
{
|
||||
/* init 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
|
||||
/* init memory system */
|
||||
rt_system_heap_init((void *)heap, (void *)&heap[RT_HEAP_SIZE - 1]);
|
||||
#endif
|
||||
|
||||
/* init scheduler system */
|
||||
rt_system_scheduler_init();
|
||||
|
||||
/* init all device */
|
||||
#ifdef RT_USING_DEVICE
|
||||
rt_device_init_all();
|
||||
#endif
|
||||
/* init application */
|
||||
rt_application_init();
|
||||
|
||||
/* init timer thread */
|
||||
rt_system_timer_thread_init();
|
||||
|
||||
/* init idle thread */
|
||||
rt_thread_idle_init();
|
||||
|
||||
/* start scheduler */
|
||||
rt_system_scheduler_start();
|
||||
|
||||
/* never reach here */
|
||||
return ;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* disable interrupt first */
|
||||
rt_hw_interrupt_disable();
|
||||
|
||||
/* startup RT-Thread RTOS */
|
||||
rtthread_startup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
@@ -1,22 +0,0 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
|
||||
# remove no need file.
|
||||
if GetDepend('RT_USING_RTGUI') == False:
|
||||
SrcRemove(src, 'sdl_fb.c')
|
||||
if GetDepend('RT_USING_DFS') == False or GetDepend('RT_USING_DFS_ELMFAT') == False:
|
||||
SrcRemove(src, 'sd_sim.c')
|
||||
if GetDepend('RT_USING_DFS') == False or GetDepend('RT_USING_MTD_NAND') == False:
|
||||
SrcRemove(src, 'nanddrv_file.c')
|
||||
if GetDepend('RT_USING_DFS') == False or GetDepend('RT_USING_MTD_NOR') == False:
|
||||
SrcRemove(src, 'sst25vfxx_mtd_sim.c')
|
||||
#if GetDepend('RT_USING_SERIAL') == False:
|
||||
# SrcRemove(src, 'usart_sim.c')
|
||||
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* File : board.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2009 RT-Thread Develop Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2009-01-05 Bernard first implementation
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
#include "board.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* @addtogroup simulator on win32
|
||||
*/
|
||||
rt_uint8_t *heap;
|
||||
|
||||
rt_uint8_t *rt_hw_sram_init(void)
|
||||
{
|
||||
rt_uint8_t *heap;
|
||||
heap = malloc(RT_HEAP_SIZE);
|
||||
if (heap == RT_NULL)
|
||||
{
|
||||
rt_kprintf("there is no memory in pc.");
|
||||
#ifdef _WIN32
|
||||
_exit(1);
|
||||
#else
|
||||
exit(1);
|
||||
#endif
|
||||
}
|
||||
return heap;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
void rt_hw_win32_low_cpu(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/* in windows */
|
||||
Sleep(1000);
|
||||
#else
|
||||
/* in linux */
|
||||
sleep(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef _CRT_TERMINATE_DEFINED
|
||||
#define _CRT_TERMINATE_DEFINED
|
||||
_CRTIMP __declspec(noreturn) void __cdecl exit(__in int _Code);
|
||||
_CRTIMP __declspec(noreturn) void __cdecl _exit(__in int _Code);
|
||||
_CRTIMP void __cdecl abort(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(RT_USING_FINSH)
|
||||
#include <finsh.h>
|
||||
void rt_hw_exit(void)
|
||||
{
|
||||
rt_kprintf("RT-Thread, bye\n");
|
||||
#if !defined(_WIN32) && defined(__GNUC__)
|
||||
/* *
|
||||
* getchar reads key from buffer, while finsh need an non-buffer getchar
|
||||
* in windows, getch is such an function, in linux, we had to change
|
||||
* the behaviour of terminal to get an non-buffer getchar.
|
||||
* in usart_sim.c, set_stty is called to do this work
|
||||
* */
|
||||
{
|
||||
extern void restore_stty(void);
|
||||
restore_stty();
|
||||
}
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(rt_hw_exit, exit, exit rt - thread);
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
/**
|
||||
* This function will initial win32
|
||||
*/
|
||||
void rt_hw_board_init()
|
||||
{
|
||||
/* init system memory */
|
||||
heap = rt_hw_sram_init();
|
||||
|
||||
//#if defined(RT_USING_USART)
|
||||
rt_hw_usart_init();
|
||||
//#endif
|
||||
|
||||
#if defined(RT_USING_CONSOLE)
|
||||
rt_hw_serial_init();
|
||||
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
#endif
|
||||
}
|
||||
/*@}*/
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* File : board.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2009, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2009-09-22 Bernard add board.h to this bsp
|
||||
*/
|
||||
|
||||
#ifndef __BOARD_H__
|
||||
#define __BOARD_H__
|
||||
void rt_hw_board_init(void);
|
||||
rt_uint8_t *rt_hw_sram_init(void);
|
||||
|
||||
/* SD Card init function */
|
||||
void rt_hw_sdcard_init(void);
|
||||
|
||||
int rt_hw_mtd_nand_init(void);
|
||||
int sst25vfxx_mtd_init(const char *, unsigned int , unsigned int);
|
||||
void pcap_netif_hw_init(void);
|
||||
void rt_platform_init(void);
|
||||
void rt_hw_usart_init(void);
|
||||
void rt_hw_serial_init(void);
|
||||
void rt_hw_sdl_start(void);
|
||||
void rt_hw_win32_low_cpu(void);
|
||||
|
||||
void rt_hw_exit(void);
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,193 +0,0 @@
|
||||
#include <rtthread.h>
|
||||
#include <stdio.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <string.h>
|
||||
#include <dfs_def.h>
|
||||
|
||||
// #define SD_TRACE rt_kprintf
|
||||
#define SD_TRACE(...)
|
||||
|
||||
//#define SDCARD_SIM "F:\\Project\\tools\\SDCARD"
|
||||
#define SDCARD_SIM "sd.bin"
|
||||
#define SDCARD_SIZE (16*1024*1024) //16M
|
||||
|
||||
struct sdcard_device
|
||||
{
|
||||
struct rt_device parent;
|
||||
FILE *file;
|
||||
};
|
||||
static struct sdcard_device _sdcard;
|
||||
|
||||
#define SDCARD_DEVICE(device) (( struct sdcard_device*)(device))
|
||||
|
||||
static rt_mutex_t lock;
|
||||
|
||||
/* RT-Thread device interface */
|
||||
|
||||
static rt_err_t rt_sdcard_init(rt_device_t dev)
|
||||
{
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt_sdcard_open(rt_device_t dev, rt_uint16_t oflag)
|
||||
{
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt_sdcard_close(rt_device_t dev)
|
||||
{
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
/* position: block page address, not bytes address
|
||||
* buffer:
|
||||
* size : how many blocks
|
||||
*/
|
||||
static rt_size_t rt_sdcard_read(rt_device_t device, rt_off_t position, void *buffer, rt_size_t size)
|
||||
{
|
||||
struct sdcard_device *sd;
|
||||
int result = 0;
|
||||
|
||||
SD_TRACE("sd read: pos %d, size %d\n", position, size);
|
||||
|
||||
rt_mutex_take(lock, RT_WAITING_FOREVER);
|
||||
sd = SDCARD_DEVICE(device);
|
||||
fseek(sd->file, position * SECTOR_SIZE, SEEK_SET);
|
||||
|
||||
result = fread(buffer, size * SECTOR_SIZE, 1, sd->file);
|
||||
if (result < 0)
|
||||
goto _err;
|
||||
|
||||
rt_mutex_release(lock);
|
||||
return size;
|
||||
|
||||
_err:
|
||||
SD_TRACE("sd read errors!\n");
|
||||
rt_mutex_release(lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* position: block page address, not bytes address
|
||||
* buffer:
|
||||
* size : how many blocks
|
||||
*/
|
||||
static rt_size_t rt_sdcard_write(rt_device_t device, rt_off_t position, const void *buffer, rt_size_t size)
|
||||
{
|
||||
struct sdcard_device *sd;
|
||||
int result = 0;
|
||||
|
||||
SD_TRACE("sst write: pos %d, size %d\n", position, size);
|
||||
|
||||
rt_mutex_take(lock, RT_WAITING_FOREVER);
|
||||
sd = SDCARD_DEVICE(device);
|
||||
fseek(sd->file, position * SECTOR_SIZE, SEEK_SET);
|
||||
|
||||
result = fwrite(buffer, size * SECTOR_SIZE, 1, sd->file);
|
||||
if (result < 0)
|
||||
goto _err;
|
||||
|
||||
rt_mutex_release(lock);
|
||||
return size;
|
||||
|
||||
_err:
|
||||
SD_TRACE("sd write errors!\n");
|
||||
rt_mutex_release(lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static rt_err_t rt_sdcard_control(rt_device_t dev, rt_uint8_t cmd, void *args)
|
||||
{
|
||||
struct sdcard_device *sd;
|
||||
unsigned int size;
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
sd = SDCARD_DEVICE(dev);
|
||||
|
||||
if (cmd == RT_DEVICE_CTRL_BLK_GETGEOME)
|
||||
{
|
||||
struct rt_device_blk_geometry *geometry;
|
||||
|
||||
geometry = (struct rt_device_blk_geometry *)args;
|
||||
if (geometry == RT_NULL) return -RT_ERROR;
|
||||
|
||||
geometry->bytes_per_sector = SECTOR_SIZE;
|
||||
geometry->block_size = SECTOR_SIZE;
|
||||
|
||||
fseek(sd->file, 0, SEEK_END);
|
||||
size = ftell(sd->file);
|
||||
|
||||
geometry->sector_count = size / SECTOR_SIZE;
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
|
||||
rt_err_t rt_hw_sdcard_init(const char *spi_device_name)
|
||||
{
|
||||
int size;
|
||||
struct sdcard_device *sd;
|
||||
struct rt_device *device;
|
||||
|
||||
sd = &_sdcard;
|
||||
device = &(sd->parent);
|
||||
|
||||
lock = rt_mutex_create("lock", RT_IPC_FLAG_FIFO);
|
||||
|
||||
/* open sd card file, if not exist, then create it */
|
||||
sd->file = fopen(SDCARD_SIM, "rb+");
|
||||
if (sd->file == NULL)
|
||||
{
|
||||
/* create a file to simulate sd card */
|
||||
sd->file = fopen(SDCARD_SIM, "wb+");
|
||||
|
||||
fseek(sd->file, 0, SEEK_END);
|
||||
size = ftell(sd->file);
|
||||
|
||||
fseek(sd->file, 0, SEEK_SET);
|
||||
if (size < SDCARD_SIZE)
|
||||
{
|
||||
int i;
|
||||
unsigned char *ptr;
|
||||
|
||||
ptr = (unsigned char *) malloc(1024 * 1024);
|
||||
if (ptr == NULL)
|
||||
{
|
||||
SD_TRACE("malloc error, no memory!\n");
|
||||
return RT_ERROR;
|
||||
}
|
||||
memset(ptr, 0x0, 1024 * 1024);
|
||||
|
||||
fseek(sd->file, 0, SEEK_SET);
|
||||
|
||||
for (i = 0; i < (SDCARD_SIZE / (1024 * 1024)); i++)
|
||||
fwrite(ptr, 1024 * 1024, 1, sd->file);
|
||||
|
||||
free(ptr);
|
||||
}
|
||||
}
|
||||
fseek(sd->file, 0, SEEK_SET);
|
||||
|
||||
device->type = RT_Device_Class_Block;
|
||||
device->init = rt_sdcard_init;
|
||||
device->open = rt_sdcard_open;
|
||||
device->close = rt_sdcard_close;
|
||||
device->read = rt_sdcard_read;
|
||||
device->write = rt_sdcard_write;
|
||||
device->control = rt_sdcard_control;
|
||||
device->user_data = NULL;
|
||||
|
||||
rt_device_register(device, "sd0",
|
||||
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE | RT_DEVICE_FLAG_STANDALONE);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
#include <finsh.h>
|
||||
void eraseall(void)
|
||||
{
|
||||
printf("had not implemented yet!\n");
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(eraseall, erase all block in SPI flash);
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,177 +0,0 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* By : parai
|
||||
* email:parai@foxmail.com
|
||||
* virtual serial driver
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#define _DEBUG_SERIAL 0
|
||||
#include "serial.h"
|
||||
#include <stdio.h>
|
||||
struct rt_device serial_device;
|
||||
//extern struct serial_int_rx serial_rx;
|
||||
struct serial_int_rx serial_rx;
|
||||
|
||||
#if 0
|
||||
static FILE *fp = RT_NULL;
|
||||
#endif
|
||||
|
||||
/*@{*/
|
||||
|
||||
/* RT-Thread Device Interface */
|
||||
/**
|
||||
* This function initializes serial
|
||||
*/
|
||||
static rt_err_t rt_serial_init(rt_device_t dev)
|
||||
{
|
||||
if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED))
|
||||
{
|
||||
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
|
||||
{
|
||||
rt_memset(serial_rx.rx_buffer, 0,
|
||||
sizeof(serial_rx.rx_buffer));
|
||||
serial_rx.read_index = 0;
|
||||
serial_rx.save_index = 0;
|
||||
}
|
||||
|
||||
dev->flag |= RT_DEVICE_FLAG_ACTIVATED;
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt_serial_open(rt_device_t dev, rt_uint16_t oflag)
|
||||
{
|
||||
#if _DEBUG_SERIAL==1
|
||||
printf("in rt_serial_open()\n");
|
||||
#endif
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt_serial_close(rt_device_t dev)
|
||||
{
|
||||
#if _DEBUG_SERIAL==1
|
||||
printf("in rt_serial_close()\n");
|
||||
#endif
|
||||
return RT_EOK;
|
||||
}
|
||||
static rt_size_t rt_serial_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
|
||||
{
|
||||
rt_uint8_t *ptr;
|
||||
rt_err_t err_code;
|
||||
|
||||
ptr = buffer;
|
||||
err_code = RT_EOK;
|
||||
|
||||
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
|
||||
{
|
||||
/* interrupt mode Rx */
|
||||
while (size)
|
||||
{
|
||||
rt_base_t level;
|
||||
|
||||
/* disable interrupt */
|
||||
level = rt_hw_interrupt_disable();
|
||||
|
||||
if (serial_rx.read_index != serial_rx.save_index)
|
||||
{
|
||||
/* read a character */
|
||||
*ptr++ = serial_rx.rx_buffer[serial_rx.read_index];
|
||||
size--;
|
||||
|
||||
/* move to next position */
|
||||
serial_rx.read_index ++;
|
||||
if (serial_rx.read_index >= SERIAL_RX_BUFFER_SIZE)
|
||||
serial_rx.read_index = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* set error code */
|
||||
err_code = -RT_EEMPTY;
|
||||
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(level);
|
||||
break;
|
||||
}
|
||||
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* set error code */
|
||||
rt_set_errno(err_code);
|
||||
return (rt_uint32_t)ptr - (rt_uint32_t)buffer;
|
||||
}
|
||||
|
||||
static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
|
||||
{
|
||||
#if _DEBUG_SERIAL==1
|
||||
printf("in rt_serial_write()\n");
|
||||
#endif
|
||||
#if 0
|
||||
if (fp == NULL)
|
||||
fp = fopen("log.txt", "wb+");
|
||||
|
||||
if (fp != NULL)
|
||||
fwrite(buffer, size, 1, fp);
|
||||
#endif
|
||||
|
||||
printf("%s", (char *)buffer);
|
||||
fflush(stdout);
|
||||
return size;
|
||||
}
|
||||
|
||||
static rt_err_t rt_serial_control(rt_device_t dev, rt_uint8_t cmd, void *args)
|
||||
{
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case RT_DEVICE_CTRL_SUSPEND:
|
||||
/* suspend device */
|
||||
dev->flag |= RT_DEVICE_FLAG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case RT_DEVICE_CTRL_RESUME:
|
||||
/* resume device */
|
||||
dev->flag &= ~RT_DEVICE_FLAG_SUSPENDED;
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
/*
|
||||
* serial register
|
||||
*/
|
||||
static rt_err_t rt_hw_serial_register(rt_device_t device, const char *name, rt_uint32_t flag)
|
||||
{
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
#if _DEBUG_SERIAL==1
|
||||
printf("in rt_serial_register()\n");
|
||||
#endif
|
||||
device->type = RT_Device_Class_Char;
|
||||
device->rx_indicate = RT_NULL;
|
||||
device->tx_complete = RT_NULL;
|
||||
device->init = rt_serial_init;
|
||||
device->open = rt_serial_open;
|
||||
device->close = rt_serial_close;
|
||||
device->read = rt_serial_read;
|
||||
device->write = rt_serial_write;
|
||||
device->control = rt_serial_control;
|
||||
device->user_data = RT_NULL;
|
||||
|
||||
/* register a character device */
|
||||
return rt_device_register(device, name, (rt_uint16_t)(RT_DEVICE_FLAG_RDWR | flag));
|
||||
}
|
||||
|
||||
rt_err_t rt_hw_serial_init(void)
|
||||
{
|
||||
return rt_hw_serial_register(&serial_device, RT_CONSOLE_DEVICE_NAME,
|
||||
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM);
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* MC9S12DP256/DG128 Specific code
|
||||
* BANKED MEMORY MODEL
|
||||
*
|
||||
* File : rthw.c
|
||||
* By : parai
|
||||
* email:parai@foxmail.com
|
||||
*******************************************************************************************************/
|
||||
|
||||
#ifndef __RT_HW_SERIAL_H__
|
||||
#define __RT_HW_SERIAL_H__
|
||||
|
||||
#define SERIAL_RX_BUFFER_SIZE 80
|
||||
struct serial_int_rx
|
||||
{
|
||||
rt_uint8_t rx_buffer[SERIAL_RX_BUFFER_SIZE];
|
||||
rt_uint32_t read_index, save_index;
|
||||
};
|
||||
|
||||
rt_err_t rt_hw_serial_init(void);
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* File : sst25vfxx_mtd.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2011, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2011-12-16 aozima the first version
|
||||
* 2012-02-01 mbbill MTD driver version
|
||||
*/
|
||||
|
||||
#ifndef SST25VFXX_MTD_H
|
||||
#define SST25VFXX_MTD_H
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <drivers/spi.h>
|
||||
|
||||
rt_err_t sst25vfxx_mtd_init(const char *spi_device_name, rt_uint32_t block_start, rt_uint32_t block_end);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,192 +0,0 @@
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <conio.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "serial.h"
|
||||
|
||||
struct serial_int_rx serial_rx;
|
||||
extern struct rt_device serial_device;
|
||||
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
* Handler for OSKey Thread
|
||||
*/
|
||||
static HANDLE OSKey_Thread;
|
||||
static DWORD OSKey_ThreadID;
|
||||
|
||||
static DWORD WINAPI ThreadforKeyGet(LPVOID lpParam);
|
||||
void rt_hw_usart_init(void)
|
||||
{
|
||||
/*
|
||||
* create serial thread that receive key input from keyboard
|
||||
*/
|
||||
|
||||
OSKey_Thread = CreateThread(NULL,
|
||||
0,
|
||||
(LPTHREAD_START_ROUTINE)ThreadforKeyGet,
|
||||
0,
|
||||
CREATE_SUSPENDED,
|
||||
&OSKey_ThreadID);
|
||||
if (OSKey_Thread == NULL)
|
||||
{
|
||||
//Display Error Message
|
||||
|
||||
return;
|
||||
}
|
||||
SetThreadPriority(OSKey_Thread,
|
||||
THREAD_PRIORITY_NORMAL);
|
||||
SetThreadPriorityBoost(OSKey_Thread,
|
||||
TRUE);
|
||||
SetThreadAffinityMask(OSKey_Thread,
|
||||
0x01);
|
||||
/*
|
||||
* Start OS get key Thread
|
||||
*/
|
||||
ResumeThread(OSKey_Thread);
|
||||
}
|
||||
|
||||
#else /* POSIX version */
|
||||
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <termios.h> /* for tcxxxattr, ECHO, etc */
|
||||
#include <unistd.h> /* for STDIN_FILENO */
|
||||
|
||||
|
||||
static void * ThreadforKeyGet(void * lpParam);
|
||||
static pthread_t OSKey_Thread;
|
||||
void rt_hw_usart_init(void)
|
||||
{
|
||||
int res;
|
||||
res = pthread_create(&OSKey_Thread, NULL, &ThreadforKeyGet, NULL);
|
||||
if (res)
|
||||
{
|
||||
printf("pthread create faild, <%d>\n", res);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* 方向键(←): 0xe04b
|
||||
* 方向键(↑): 0xe048
|
||||
* 方向键(→): 0xe04d
|
||||
* 方向键(↓): 0xe050
|
||||
*/
|
||||
static int savekey(unsigned char key)
|
||||
{
|
||||
/* save on rx buffer */
|
||||
{
|
||||
rt_base_t level;
|
||||
|
||||
/* disable interrupt */
|
||||
//暂时关闭中断,因为要操作uart数据结构
|
||||
level = rt_hw_interrupt_disable();
|
||||
|
||||
/* save character */
|
||||
serial_rx.rx_buffer[serial_rx.save_index] = key;
|
||||
serial_rx.save_index ++;
|
||||
//下面的代码检查save_index是否已经到到缓冲区尾部,如果是则回转到头部,称为一个环形缓冲区
|
||||
if (serial_rx.save_index >= SERIAL_RX_BUFFER_SIZE)
|
||||
serial_rx.save_index = 0;
|
||||
|
||||
//这种情况表示反转后的save_index追上了read_index,则增大read_index,丢弃一个旧的数据
|
||||
/* if the next position is read index, discard this 'read char' */
|
||||
if (serial_rx.save_index == serial_rx.read_index)
|
||||
{
|
||||
serial_rx.read_index ++;
|
||||
if (serial_rx.read_index >= SERIAL_RX_BUFFER_SIZE)
|
||||
serial_rx.read_index = 0;
|
||||
}
|
||||
|
||||
/* enable interrupt */
|
||||
//uart数据结构已经操作完成,重新使能中断
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
|
||||
/* invoke callback */
|
||||
if (serial_device.rx_indicate != RT_NULL)
|
||||
{
|
||||
rt_size_t rx_length;
|
||||
|
||||
/* get rx length */
|
||||
rx_length = serial_rx.read_index > serial_rx.save_index ?
|
||||
SERIAL_RX_BUFFER_SIZE - serial_rx.read_index + serial_rx.save_index :
|
||||
serial_rx.save_index - serial_rx.read_index;
|
||||
|
||||
serial_device.rx_indicate(&serial_device, rx_length);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
static DWORD WINAPI ThreadforKeyGet(LPVOID lpParam)
|
||||
#else
|
||||
|
||||
static struct termios oldt, newt;
|
||||
/*simulate windows' getch(), it works!!*/
|
||||
void set_stty(void)
|
||||
{
|
||||
/* get terminal input's attribute */
|
||||
tcgetattr(STDIN_FILENO, &oldt);
|
||||
newt = oldt;
|
||||
|
||||
/* set termios' local mode */
|
||||
newt.c_lflag &= ~(ECHO|ICANON);
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
|
||||
}
|
||||
|
||||
void restore_stty(void)
|
||||
{
|
||||
/* recover terminal's attribute */
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
|
||||
}
|
||||
|
||||
#define getch getchar
|
||||
|
||||
static void * ThreadforKeyGet(void * lpParam)
|
||||
#endif /* not _WIN32*/
|
||||
{
|
||||
unsigned char key;
|
||||
|
||||
#ifndef _WIN32
|
||||
sigset_t sigmask, oldmask;
|
||||
/* set the getchar without buffer */
|
||||
sigfillset(&sigmask);
|
||||
pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask);
|
||||
set_stty();
|
||||
#endif
|
||||
(void)lpParam; //prevent compiler warnings
|
||||
for (;;)
|
||||
{
|
||||
key = getch();
|
||||
#ifdef _WIN32
|
||||
if (key == 0xE0)
|
||||
{
|
||||
key = getch();
|
||||
|
||||
if (key == 0x48) //up key , 0x1b 0x5b 0x41
|
||||
{
|
||||
savekey(0x1b);
|
||||
savekey(0x5b);
|
||||
savekey(0x41);
|
||||
}
|
||||
else if (key == 0x50)//0x1b 0x5b 0x42
|
||||
{
|
||||
savekey(0x1b);
|
||||
savekey(0x5b);
|
||||
savekey(0x42);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
savekey(key);
|
||||
}
|
||||
} /*** ThreadforKeyGet ***/
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,82 +0,0 @@
|
||||
# toolchains options
|
||||
ARCH='sim'
|
||||
#CPU='win32'
|
||||
#CPU='posix'
|
||||
CPU='posix'
|
||||
CROSS_TOOL='gcc' #msvc # gcc
|
||||
|
||||
# lcd panel options
|
||||
# 'FMT0371','ILI932X', 'SSD1289'
|
||||
# RT_USING_LCD_TYPE = 'SSD1289'
|
||||
|
||||
# cross_tool provides the cross compiler
|
||||
# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
|
||||
if CROSS_TOOL == 'gcc':
|
||||
PLATFORM = 'gcc'
|
||||
EXEC_PATH = '/usr/bin/gcc'
|
||||
|
||||
if CROSS_TOOL == 'msvc':
|
||||
PLATFORM = 'cl'
|
||||
EXEC_PATH = ''
|
||||
|
||||
BUILD = 'debug'
|
||||
#BUILD = ''
|
||||
|
||||
if PLATFORM == 'gcc':
|
||||
# toolchains
|
||||
PREFIX = ''
|
||||
CC = PREFIX + 'gcc'
|
||||
AS = PREFIX + 'gcc'
|
||||
AR = PREFIX + 'ar'
|
||||
LINK = PREFIX + 'gcc'
|
||||
TARGET_EXT = 'axf'
|
||||
SIZE = PREFIX + 'size'
|
||||
OBJDUMP = PREFIX + 'objdump'
|
||||
OBJCPY = PREFIX + 'objcopy'
|
||||
|
||||
DEVICE = ' -ffunction-sections -fdata-sections'
|
||||
DEVICE = ' '
|
||||
CFLAGS = DEVICE + ' -I/usr/include -w -D_REENTRANT'
|
||||
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
|
||||
#LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-linux.map,-cref,-u,Reset_Handler -T stm32_rom.ld'
|
||||
#LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-linux.map -lpthread'
|
||||
#LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-linux.map -pthread'
|
||||
LFLAGS = DEVICE + ' -Wl,-Map=rtthread-linux.map -pthread -T gcc.ld'
|
||||
|
||||
CPATH = ''
|
||||
LPATH = ''
|
||||
|
||||
if BUILD == 'debug':
|
||||
CFLAGS += ' -g -O0 -gdwarf-2'
|
||||
AFLAGS += ' -gdwarf-2'
|
||||
else:
|
||||
CFLAGS += ' -O2'
|
||||
|
||||
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
|
||||
|
||||
elif PLATFORM == 'cl':
|
||||
# toolchains
|
||||
PREFIX = ''
|
||||
TARGET_EXT = 'exe'
|
||||
AS = PREFIX + 'cl'
|
||||
CC = PREFIX + 'cl'
|
||||
AR = PREFIX + 'cl'
|
||||
LINK = PREFIX + 'cl'
|
||||
AFLAGS = ''
|
||||
CFLAGS = ''
|
||||
LFLAGS = ''
|
||||
|
||||
if BUILD == 'debug':
|
||||
CFLAGS += ' /MTd'
|
||||
LFLAGS += ' /DEBUG'
|
||||
else:
|
||||
CFLAGS += ' /MT'
|
||||
LFLAGS += ''
|
||||
|
||||
CFLAGS += ' /ZI /Od /W 3 /WL '
|
||||
LFLAGS += ' /SUBSYSTEM:CONSOLE /MACHINE:X86 '
|
||||
|
||||
CPATH = ''
|
||||
LPATH = ''
|
||||
|
||||
POST_ACTION = ''
|
||||
Reference in new issue
Block a user