mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-23 04:04:15 +08:00
As you know, most branches of RT-thread project has used "scons" tools to compile project or construct MDK project automatically for specific branch. this is a very simple and effective method.Now this method could have been available for sep4020, and the necessary script files has been wrote and uploaded.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1293 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
/******************************************************************************/
|
||||||
|
/* MEMORY.INI: Memory Debug Initialization File */
|
||||||
|
/******************************************************************************/
|
||||||
|
/* This file is part of the uVision/ARM development tools. */
|
||||||
|
/* Copyright (c) 2005-2006 Keil Software. All rights reserved. */
|
||||||
|
/* This software may only be used under the terms of a valid, current, */
|
||||||
|
/* end user licence from KEIL for a compatible version of KEIL software */
|
||||||
|
/* development tools. Nothing else gives you the right to use this software. */
|
||||||
|
/******************************************************************************/
|
||||||
|
RESET
|
||||||
|
FUNC void InitEmi(void)
|
||||||
|
{
|
||||||
|
_WWORD(0x11000000,0x08a6a6a1);
|
||||||
|
_WWORD(0x11000010,0x8cfffff1);
|
||||||
|
_WWORD(0x11000018,0x1e104177);
|
||||||
|
_WWORD(0x1100001C,0x80001860);
|
||||||
|
_WWORD(0x11000020,0x0000000b);
|
||||||
|
}
|
||||||
|
InitEmi();
|
||||||
|
Load %L INCREMENTAL;
|
||||||
|
PC = 0x30000000;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import rtconfig
|
||||||
|
Import('RTT_ROOT')
|
||||||
|
from building import *
|
||||||
|
|
||||||
|
src = Glob('*.c')
|
||||||
|
CPPPATH = [RTT_ROOT + '/bsp/mini4020']
|
||||||
|
group = DefineGroup('Startup', src, depend = [''], CPPPATH = CPPPATH)
|
||||||
|
|
||||||
|
Return('group')
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import rtconfig
|
||||||
|
|
||||||
|
RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
|
||||||
|
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
||||||
|
from building import *
|
||||||
|
|
||||||
|
TARGET = 'rtthread-mini4020.' + rtconfig.TARGET_EXT
|
||||||
|
|
||||||
|
env = Environment(tools = ['mingw'],
|
||||||
|
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
|
||||||
|
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
|
||||||
|
AR = rtconfig.AR, ARFLAGS = '-rc',
|
||||||
|
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
|
||||||
|
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
||||||
|
|
||||||
|
Export('RTT_ROOT')
|
||||||
|
Export('rtconfig')
|
||||||
|
|
||||||
|
# prepare building environment
|
||||||
|
objs = PrepareBuilding(env, RTT_ROOT)
|
||||||
|
|
||||||
|
# build program
|
||||||
|
env.Program(TARGET, objs)
|
||||||
|
|
||||||
|
# end building
|
||||||
|
EndBuilding(TARGET)
|
||||||
@@ -40,7 +40,7 @@ void rt_init_thread_entry(void* parameter)
|
|||||||
char buffer[20];
|
char buffer[20];
|
||||||
#ifdef RT_USING_DFS
|
#ifdef RT_USING_DFS
|
||||||
dfs_init();
|
dfs_init();
|
||||||
#ifdef RT_USING_DFS_ELMFATFS
|
#ifdef RT_USING_DFS_ELMFAT
|
||||||
elm_init();
|
elm_init();
|
||||||
/* mount sd card fat partition 1 as root directory */
|
/* mount sd card fat partition 1 as root directory */
|
||||||
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
|
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
|
||||||
|
|||||||
@@ -86,7 +86,7 @@
|
|||||||
/* SECTION: Device filesystem support */
|
/* SECTION: Device filesystem support */
|
||||||
/* using DFS support */
|
/* using DFS support */
|
||||||
#define RT_USING_DFS
|
#define RT_USING_DFS
|
||||||
#define RT_USING_DFS_ELMFATFS
|
#define RT_USING_DFS_ELMFAT
|
||||||
/* #define RT_USING_DFS_YAFFS2 */
|
/* #define RT_USING_DFS_YAFFS2 */
|
||||||
|
|
||||||
/* #define DFS_USING_WORKDIR */
|
/* #define DFS_USING_WORKDIR */
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
|
|
||||||
/* SECTION: lwip, a lighwight TCP/IP protocol stack */
|
/* SECTION: lwip, a lighwight TCP/IP protocol stack */
|
||||||
/* Using lighweight TCP/IP protocol stack */
|
/* Using lighweight TCP/IP protocol stack */
|
||||||
//#define RT_USING_LWIP
|
#define RT_USING_LWIP
|
||||||
#define RT_LWIP_DNS
|
#define RT_LWIP_DNS
|
||||||
|
|
||||||
/* Trace LwIP protocol */
|
/* Trace LwIP protocol */
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
# toolchains options
|
||||||
|
ARCH = 'arm'
|
||||||
|
CPU = 'sep4020'
|
||||||
|
|
||||||
|
CROSS_TOOL = 'keil'
|
||||||
|
|
||||||
|
if CROSS_TOOL == 'gcc':
|
||||||
|
PLATFORM = 'gcc'
|
||||||
|
EXEC_PATH = 'E:/Program Files/CodeSourcery/Sourcery G++ Lite/bin'
|
||||||
|
elif CROSS_TOOL == 'keil':
|
||||||
|
PLATFORM = 'armcc'
|
||||||
|
EXEC_PATH = 'c:/Keil'
|
||||||
|
BUILD = 'debug'
|
||||||
|
|
||||||
|
if PLATFORM == 'gcc':
|
||||||
|
# toolchains
|
||||||
|
PREFIX = 'arm-none-eabi-'
|
||||||
|
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 = ' -mcpu=arm720t'
|
||||||
|
CFLAGS = DEVICE
|
||||||
|
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp' + ' -DTEXT_BASE=' + TextBase
|
||||||
|
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread_mini4020.map,-cref,-u,_start -T mini4020_ram.ld' + ' -Ttext ' + TextBase
|
||||||
|
|
||||||
|
CPATH = ''
|
||||||
|
LPATH = ''
|
||||||
|
|
||||||
|
if BUILD == 'debug':
|
||||||
|
CFLAGS += ' -O0 -gdwarf-2'
|
||||||
|
AFLAGS += ' -gdwarf-2'
|
||||||
|
else:
|
||||||
|
CFLAGS += ' -O2'
|
||||||
|
|
||||||
|
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
|
||||||
|
|
||||||
|
elif PLATFORM == 'armcc':
|
||||||
|
# toolchains
|
||||||
|
CC = 'armcc'
|
||||||
|
AS = 'armasm'
|
||||||
|
AR = 'armar'
|
||||||
|
LINK = 'armlink'
|
||||||
|
TARGET_EXT = 'axf'
|
||||||
|
|
||||||
|
DEVICE = ' --device DARMP'
|
||||||
|
CFLAGS = DEVICE + ' --apcs=interwork --diag_suppress=870'
|
||||||
|
AFLAGS = DEVICE
|
||||||
|
LFLAGS = DEVICE + ' --strict --info sizes --info totals --info unused --info veneers --list rtthread-mini4020.map -scatter rtthread-mini4020.sct'
|
||||||
|
|
||||||
|
CFLAGS += ' -I"' + EXEC_PATH + '/ARM/RV31/INC"'
|
||||||
|
LFLAGS += ' --libpath "' + EXEC_PATH + '/ARM/RV31/LIB"'
|
||||||
|
|
||||||
|
EXEC_PATH += '/arm/bin40/'
|
||||||
|
|
||||||
|
if BUILD == 'debug':
|
||||||
|
CFLAGS += ' -g -O0'
|
||||||
|
AFLAGS += ' -g'
|
||||||
|
else:
|
||||||
|
CFLAGS += ' -O2'
|
||||||
|
|
||||||
|
POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET'
|
||||||
|
|
||||||
|
elif PLATFORM == 'iar':
|
||||||
|
# toolchains
|
||||||
|
CC = 'armcc'
|
||||||
|
AS = 'armasm'
|
||||||
|
AR = 'armar'
|
||||||
|
LINK = 'armlink'
|
||||||
|
|
||||||
|
CFLAGS = ''
|
||||||
|
AFLAGS = ''
|
||||||
|
LFLAGS = ''
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
; *************************************************************
|
||||||
|
; *** Scatter-Loading Description File generated by uVision ***
|
||||||
|
; *************************************************************
|
||||||
|
|
||||||
|
; *************************************************************
|
||||||
|
; *** Scatter-Loadig Description File generated by uVision ***n
|
||||||
|
; *************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
LR_ROM1 0x30000000 0x0FFD00 ; load region size_region
|
||||||
|
{
|
||||||
|
ER_ROM1 0x30000000 0x0FFD00 ; load address = execution address
|
||||||
|
{
|
||||||
|
*.o (RESET, +First)
|
||||||
|
*(InRoot$$Sections)
|
||||||
|
.ANY (+RO)
|
||||||
|
}
|
||||||
|
RW_RAM1 0x30100000 0x100000 ; RW data
|
||||||
|
{
|
||||||
|
.ANY (+RW +ZI)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,282 +0,0 @@
|
|||||||
/*
|
|
||||||
* File : serial.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://openlab.rt-thread.com/license/LICENSE
|
|
||||||
*
|
|
||||||
* Change Logs:
|
|
||||||
* Date Author Notes
|
|
||||||
* 2006-03-13 Bernard first version
|
|
||||||
* 2009-04-20 yi.qiu modified according bernard's stm32 version
|
|
||||||
* 2010-10-6 wangmeng added sep4020 surpport
|
|
||||||
*/
|
|
||||||
#include <rtthread.h>
|
|
||||||
#include <rthw.h>
|
|
||||||
#include "serial.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @addtogroup SEP4020
|
|
||||||
*/
|
|
||||||
/*@{*/
|
|
||||||
|
|
||||||
/* RT-Thread Device Interface */
|
|
||||||
/**
|
|
||||||
* This function initializes serial
|
|
||||||
*/
|
|
||||||
static rt_err_t rt_serial_init (rt_device_t dev)
|
|
||||||
{
|
|
||||||
struct serial_device* uart = (struct serial_device*) dev->user_data;
|
|
||||||
|
|
||||||
if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED))
|
|
||||||
{
|
|
||||||
|
|
||||||
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
|
|
||||||
{
|
|
||||||
rt_memset(uart->int_rx->rx_buffer, 0,
|
|
||||||
sizeof(uart->int_rx->rx_buffer));
|
|
||||||
uart->int_rx->read_index = uart->int_rx->save_index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dev->flag & RT_DEVICE_FLAG_INT_TX)
|
|
||||||
{
|
|
||||||
rt_memset(uart->int_tx->tx_buffer, 0,
|
|
||||||
sizeof(uart->int_tx->tx_buffer));
|
|
||||||
uart->int_tx->write_index = uart->int_tx->save_index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->flag |= RT_DEVICE_FLAG_ACTIVATED;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RT_EOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* save a char to serial buffer */
|
|
||||||
static void rt_serial_savechar(struct serial_device* uart, char ch)
|
|
||||||
{
|
|
||||||
rt_base_t level;
|
|
||||||
|
|
||||||
/* disable interrupt */
|
|
||||||
level = rt_hw_interrupt_disable();
|
|
||||||
|
|
||||||
uart->int_rx->rx_buffer[uart->int_rx->save_index] = ch;
|
|
||||||
uart->int_rx->save_index ++;
|
|
||||||
if (uart->int_rx->save_index >= UART_RX_BUFFER_SIZE)
|
|
||||||
uart->int_rx->save_index = 0;
|
|
||||||
|
|
||||||
/* if the next position is read index, discard this 'read char' */
|
|
||||||
if (uart->int_rx->save_index == uart->int_rx->read_index)
|
|
||||||
{
|
|
||||||
uart->int_rx->read_index ++;
|
|
||||||
if (uart->int_rx->read_index >= UART_RX_BUFFER_SIZE)
|
|
||||||
uart->int_rx->read_index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* enable interrupt */
|
|
||||||
rt_hw_interrupt_enable(level);
|
|
||||||
}
|
|
||||||
|
|
||||||
static rt_err_t rt_serial_open(rt_device_t dev, rt_uint16_t oflag)
|
|
||||||
{
|
|
||||||
RT_ASSERT(dev != RT_NULL);
|
|
||||||
return RT_EOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static rt_err_t rt_serial_close(rt_device_t dev)
|
|
||||||
{
|
|
||||||
RT_ASSERT(dev != RT_NULL);
|
|
||||||
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;
|
|
||||||
struct serial_device* uart;
|
|
||||||
|
|
||||||
ptr = buffer;
|
|
||||||
err_code = RT_EOK;
|
|
||||||
uart = (struct serial_device*)dev->user_data;
|
|
||||||
|
|
||||||
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
|
|
||||||
{
|
|
||||||
rt_base_t level;
|
|
||||||
|
|
||||||
/* interrupt mode Rx */
|
|
||||||
while (size)
|
|
||||||
{
|
|
||||||
if (uart->int_rx->read_index != uart->int_rx->save_index)
|
|
||||||
{
|
|
||||||
*ptr++ = uart->int_rx->rx_buffer[uart->int_rx->read_index];
|
|
||||||
size --;
|
|
||||||
|
|
||||||
/* disable interrupt */
|
|
||||||
level = rt_hw_interrupt_disable();
|
|
||||||
|
|
||||||
uart->int_rx->read_index ++;
|
|
||||||
if (uart->int_rx->read_index >= UART_RX_BUFFER_SIZE)
|
|
||||||
uart->int_rx->read_index = 0;
|
|
||||||
|
|
||||||
/* enable interrupt */
|
|
||||||
rt_hw_interrupt_enable(level);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* set error code */
|
|
||||||
err_code = -RT_EEMPTY;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* polling mode */
|
|
||||||
while ((rt_uint32_t)ptr - (rt_uint32_t)buffer < size)
|
|
||||||
{
|
|
||||||
while (uart->uart_device->lsr & USTAT_RCV_READY)
|
|
||||||
{
|
|
||||||
*ptr = uart->uart_device->dlbl_fifo.txfifo & 0xff;
|
|
||||||
ptr ++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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)
|
|
||||||
{
|
|
||||||
rt_uint8_t* ptr;
|
|
||||||
rt_err_t err_code;
|
|
||||||
struct serial_device* uart;
|
|
||||||
|
|
||||||
err_code = RT_EOK;
|
|
||||||
ptr = (rt_uint8_t*)buffer;
|
|
||||||
uart = (struct serial_device*)dev->user_data;
|
|
||||||
|
|
||||||
if (dev->flag & RT_DEVICE_FLAG_INT_TX)
|
|
||||||
{
|
|
||||||
/* interrupt mode Tx */
|
|
||||||
while (uart->int_tx->save_index != uart->int_tx->write_index)
|
|
||||||
{
|
|
||||||
/* save on tx buffer */
|
|
||||||
uart->int_tx->tx_buffer[uart->int_tx->save_index] = *ptr++;
|
|
||||||
|
|
||||||
-- size;
|
|
||||||
|
|
||||||
/* move to next position */
|
|
||||||
uart->int_tx->save_index ++;
|
|
||||||
|
|
||||||
/* wrap save index */
|
|
||||||
if (uart->int_tx->save_index >= UART_TX_BUFFER_SIZE)
|
|
||||||
uart->int_tx->save_index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set error code */
|
|
||||||
if (size > 0)
|
|
||||||
err_code = -RT_EFULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* polling mode */
|
|
||||||
while (size)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* to be polite with serial console add a line feed
|
|
||||||
* to the carriage return character
|
|
||||||
*/
|
|
||||||
if (*ptr == '\n' && (dev->flag & RT_DEVICE_FLAG_STREAM))
|
|
||||||
{
|
|
||||||
while (!(uart->uart_device->lsr & USTAT_TXB_EMPTY));
|
|
||||||
uart->uart_device->dlbl_fifo.txfifo = '\r';
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!(uart->uart_device->lsr & USTAT_TXB_EMPTY));
|
|
||||||
uart->uart_device->dlbl_fifo.txfifo = (*ptr & 0x1FF);
|
|
||||||
|
|
||||||
++ptr; --size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set error code */
|
|
||||||
rt_set_errno(err_code);
|
|
||||||
|
|
||||||
return (rt_uint32_t)ptr - (rt_uint32_t)buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t flag, struct serial_device *serial)
|
|
||||||
{
|
|
||||||
RT_ASSERT(device != RT_NULL);
|
|
||||||
|
|
||||||
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 = serial;
|
|
||||||
|
|
||||||
/* register a character device */
|
|
||||||
return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR | flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ISR for serial interrupt */
|
|
||||||
void rt_hw_serial_isr(rt_device_t device)
|
|
||||||
{
|
|
||||||
struct serial_device* uart = (struct serial_device*) device->user_data;
|
|
||||||
|
|
||||||
/* interrupt mode receive */
|
|
||||||
RT_ASSERT(device->flag & RT_DEVICE_FLAG_INT_RX);
|
|
||||||
|
|
||||||
/* save on rx buffer */
|
|
||||||
while (uart->uart_device->lsr & USTAT_RCV_READY)
|
|
||||||
{
|
|
||||||
rt_serial_savechar(uart, uart->uart_device->dlbl_fifo.rxfifo & 0xff);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* invoke callback */
|
|
||||||
if (device->rx_indicate != RT_NULL)
|
|
||||||
{
|
|
||||||
rt_size_t rx_length;
|
|
||||||
|
|
||||||
/* get rx length */
|
|
||||||
rx_length = uart->int_rx->read_index > uart->int_rx->save_index ?
|
|
||||||
UART_RX_BUFFER_SIZE - uart->int_rx->read_index + uart->int_rx->save_index :
|
|
||||||
uart->int_rx->save_index - uart->int_rx->read_index;
|
|
||||||
|
|
||||||
device->rx_indicate(device, rx_length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*@}*/
|
|
||||||
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* File : serial.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://openlab.rt-thread.com/license/LICENSE
|
|
||||||
*
|
|
||||||
* Change Logs:
|
|
||||||
* Date Author Notes
|
|
||||||
* 2006-03-13 Bernard first version
|
|
||||||
* 2009-04-20 yi.qiu modified according bernard's stm32 version
|
|
||||||
* 2010-10-6 wangmeng added sep4020 surpport
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __SERIAL_H__
|
|
||||||
#define __SERIAL_H__
|
|
||||||
|
|
||||||
#include <sep4020.h>
|
|
||||||
|
|
||||||
#define USTAT_RCV_READY 0x01 /* receive data ready */
|
|
||||||
#define USTAT_TXB_EMPTY 0x40 /* tx buffer empty */
|
|
||||||
#define BPS 115200 /* serial baudrate */
|
|
||||||
|
|
||||||
#define UART_RX_BUFFER_SIZE 64
|
|
||||||
#define UART_TX_BUFFER_SIZE 64
|
|
||||||
|
|
||||||
/*For sep4020's uart have several secondary function*/
|
|
||||||
/*we use union to decribe it*/
|
|
||||||
|
|
||||||
union dlbl_fifo
|
|
||||||
{
|
|
||||||
rt_uint32_t dlbl;
|
|
||||||
rt_uint32_t rxfifo;
|
|
||||||
rt_uint32_t txfifo;
|
|
||||||
};
|
|
||||||
|
|
||||||
union dlbh_ier
|
|
||||||
{
|
|
||||||
rt_uint32_t dlbh;
|
|
||||||
rt_uint32_t ier;
|
|
||||||
};
|
|
||||||
|
|
||||||
union iir_fcr
|
|
||||||
{
|
|
||||||
rt_uint32_t iir;
|
|
||||||
rt_uint32_t fcr;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct serial_int_rx
|
|
||||||
{
|
|
||||||
rt_uint8_t rx_buffer[UART_RX_BUFFER_SIZE];
|
|
||||||
rt_uint32_t read_index, save_index;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct serial_int_tx
|
|
||||||
{
|
|
||||||
rt_uint8_t tx_buffer[UART_TX_BUFFER_SIZE];
|
|
||||||
rt_uint32_t write_index, save_index;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct uartport
|
|
||||||
{
|
|
||||||
union dlbl_fifo dlbl_fifo;
|
|
||||||
union dlbh_ier dlbh_ier;
|
|
||||||
union iir_fcr iir_fcr;
|
|
||||||
rt_uint32_t lcr;
|
|
||||||
rt_uint32_t mcr;
|
|
||||||
rt_uint32_t lsr;
|
|
||||||
rt_uint32_t msr;
|
|
||||||
}uartport;
|
|
||||||
|
|
||||||
struct serial_device
|
|
||||||
{
|
|
||||||
uartport* uart_device;
|
|
||||||
|
|
||||||
/* rx structure */
|
|
||||||
struct serial_int_rx* int_rx;
|
|
||||||
|
|
||||||
/* tx structure */
|
|
||||||
struct serial_int_tx* int_tx;
|
|
||||||
};
|
|
||||||
|
|
||||||
rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t flag, struct serial_device *serial);
|
|
||||||
|
|
||||||
void rt_hw_serial_isr(rt_device_t device);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
### uVision2 Project, (C) Keil Software
|
||||||
|
### Do not modify !
|
||||||
|
|
||||||
|
Target (RT-Thread_Mini4020), 0x0004 // Tools: 'ARM-ADS'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Options 1,0,0 // Target 'RT-Thread_Mini4020'
|
||||||
|
Device (ARM7 (Little Endian))
|
||||||
|
Vendor (ARM)
|
||||||
|
Cpu (CLOCK(60000000) CPUTYPE(ARM7TDMI))
|
||||||
|
FlashUt ()
|
||||||
|
StupF ()
|
||||||
|
FlashDR ()
|
||||||
|
DevID (3654)
|
||||||
|
Rgf ()
|
||||||
|
Mem ()
|
||||||
|
C ()
|
||||||
|
A ()
|
||||||
|
RL ()
|
||||||
|
OH ()
|
||||||
|
DBC_IFX ()
|
||||||
|
DBC_CMS ()
|
||||||
|
DBC_AMS ()
|
||||||
|
DBC_LMS ()
|
||||||
|
UseEnv=0
|
||||||
|
EnvBin ()
|
||||||
|
EnvInc ()
|
||||||
|
EnvLib ()
|
||||||
|
EnvReg ()
|
||||||
|
OrgReg ()
|
||||||
|
TgStat=16
|
||||||
|
OutDir (.\)
|
||||||
|
OutName (rtthread-mini4020)
|
||||||
|
GenApp=1
|
||||||
|
GenLib=0
|
||||||
|
GenHex=0
|
||||||
|
Debug=1
|
||||||
|
Browse=0
|
||||||
|
LstDir (.\)
|
||||||
|
HexSel=1
|
||||||
|
MG32K=0
|
||||||
|
TGMORE=0
|
||||||
|
RunUsr 0 0 <>
|
||||||
|
RunUsr 1 0 <>
|
||||||
|
BrunUsr 0 0 <>
|
||||||
|
BrunUsr 1 0 <>
|
||||||
|
CrunUsr 0 0 <>
|
||||||
|
CrunUsr 1 0 <>
|
||||||
|
SVCSID <>
|
||||||
|
GLFLAGS=1790
|
||||||
|
ADSFLGA { 243,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
||||||
|
ACPUTYP (ARM7TDMI)
|
||||||
|
RVDEV ()
|
||||||
|
ADSTFLGA { 0,0,64,0,160,0,64,8,0,0,0,0,0,0,0,0,0,0,0,0 }
|
||||||
|
OCMADSOCM { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
||||||
|
OCMADSIRAM { 0,0,0,0,0,0,0,0,0 }
|
||||||
|
OCMADSIROM { 0,0,0,0,0,0,0,0,0 }
|
||||||
|
OCMADSXRAM { 0,0,0,0,0,0,0,0,0 }
|
||||||
|
OCR_RVCT { 1,0,0,0,32,0,0,0,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,128,0,0,0,0,0,0,0,0,0,0,0 }
|
||||||
|
RV_STAVEC ()
|
||||||
|
ADSCCFLG { 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
||||||
|
ADSCMISC (-g)
|
||||||
|
ADSCDEFN ()
|
||||||
|
ADSCUDEF ()
|
||||||
|
ADSCINCD ()
|
||||||
|
ADSASFLG { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
||||||
|
ADSAMISC ()
|
||||||
|
ADSADEFN ()
|
||||||
|
ADSAUDEF ()
|
||||||
|
ADSAINCD ()
|
||||||
|
PropFld { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
||||||
|
IncBld=1
|
||||||
|
AlwaysBuild=0
|
||||||
|
GenAsm=0
|
||||||
|
AsmAsm=0
|
||||||
|
PublicsOnly=0
|
||||||
|
StopCode=3
|
||||||
|
CustArgs ()
|
||||||
|
LibMods ()
|
||||||
|
ADSLDFG { 16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
||||||
|
ADSLDTA (0x00000000)
|
||||||
|
ADSLDDA (0x00000000)
|
||||||
|
ADSLDSC (.\rtthread-mini4020.sct)
|
||||||
|
ADSLDIB ()
|
||||||
|
ADSLDIC ()
|
||||||
|
ADSLDMC ()
|
||||||
|
ADSLDIF ()
|
||||||
|
ADSLDDW ()
|
||||||
|
OPTDL (SARM.DLL)()(DARMP.DLL)()(SARM.DLL)()(TARMP.DLL)()
|
||||||
|
OPTDBG 48126,6,()()()()()()()()()(.\Ext_SDRAM.ini) (Segger\JLTAgdi.dll)()()()
|
||||||
|
FLASH1 { 1,0,0,0,1,0,0,0,4,16,0,0,0,0,0,0,0,0,0,0 }
|
||||||
|
FLASH2 (Segger\JLTAgdi.dll)
|
||||||
|
FLASH3 ("" ())
|
||||||
|
FLASH4 ()
|
||||||
|
EndOpt
|
||||||
|
|
||||||
Reference in New Issue
Block a user