add finsh, but still cannot work, only can be built with gcc

This commit is contained in:
prife 2013-01-14 16:50:40 +08:00
parent 7b42f926a0
commit 8f70786c30
5 changed files with 59 additions and 12 deletions

View File

@ -12,8 +12,8 @@ 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')
#if GetDepend('RT_USING_SERIAL') == False:
# SrcRemove(src, 'usart_sim.c')
CPPPATH = [cwd]

View File

@ -53,15 +53,16 @@ void rt_hw_win32_low_cpu(void)
#endif
}
#if defined(RT_USING_FINSH)
#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)
{
@ -79,9 +80,9 @@ void rt_hw_board_init()
/* init system memory */
heap = rt_hw_sram_init();
#if defined(RT_USING_USART)
//#if defined(RT_USING_USART)
rt_hw_usart_init();
#endif
//#endif
#if defined(RT_USING_CONSOLE)
rt_hw_serial_init();

View File

@ -4,16 +4,16 @@
#ifdef _WIN32
#include <windows.h>
#include <mmsystem.h>
#include <conio.h>
#endif
#include <stdio.h>
#include <conio.h>
#include "serial.h"
struct serial_int_rx serial_rx;
extern struct rt_device serial_device;
#ifdef _WIN32
/*
* Handler for OSKey Thread
*/
@ -23,7 +23,6 @@ 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
*/
@ -50,9 +49,52 @@ void rt_hw_usart_init(void)
* Start OS get key Thread
*/
ResumeThread(OSKey_Thread);
}
#else /* POSIX version */
#include <pthread.h>
#include <semaphore.h>
#include <stdlib.h>
#include <termios.h> /* for tcxxxattr, ECHO, etc */
#include <unistd.h> /* for STDIN_FILENO */
/*simulate windows' getch(), it works!!*/
int getch(void)
{
int ch;
struct termios oldt, newt;
// 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);
//read character from terminal input
ch = getchar();
//recover terminal's attribute
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
return ch;
}
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
@ -104,7 +146,11 @@ static int savekey(unsigned char key)
}
return 0;
}
#ifdef _WIN32
static DWORD WINAPI ThreadforKeyGet(LPVOID lpParam)
#else
static void * ThreadforKeyGet(void * lpParam)
#endif
{
unsigned char key;

View File

@ -101,7 +101,7 @@
/* #define RT_USING_MTD_NOR */
/* SECTION: finsh, a C-Express shell */
/* #define RT_USING_FINSH */
#define RT_USING_FINSH
/* Using symbol table */
#define FINSH_USING_SYMTAB
#define FINSH_USING_DESCRIPTION

View File

@ -1,7 +1,7 @@
/*
* author : prife (goprife@gmail.com)
* date : 2013/01/14 01:18:50
* version: v 0.1.0
* version: v 0.2.0
*/
#include <rtthread.h>
#include <stdio.h>