add license and copyright info

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@226 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong 2009-12-25 12:18:53 +00:00
parent 6cd35a87c3
commit 51e2d91378
45 changed files with 473 additions and 252 deletions

View File

@ -1,7 +1,7 @@
/* /*
* File : application.c * File : application.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at

View File

@ -1,7 +1,7 @@
/* /*
* File : board.c * File : board.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009 RT-Thread Develop Team * COPYRIGHT (C) 2009 RT-Thread Develop Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@ -9,7 +9,7 @@
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2006-08-23 Bernard first implementation * 2009-01-05 Bernard first implementation
*/ */
#include <rthw.h> #include <rthw.h>

View File

@ -1,7 +1,7 @@
/* /*
* File : board.h * File : board.h
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team * COPYRIGHT (C) 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at

View File

@ -1,3 +1,16 @@
/*
* File : dm9000a.c
* 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-07-01 Bernard the first version
*/
#include <rtthread.h> #include <rtthread.h>
#include "dm9000a.h" #include "dm9000a.h"
@ -620,10 +633,10 @@ static void FSMC_Configuration()
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef p; FSMC_NORSRAMTimingInitTypeDef p;
GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOG | RCC_APB2Periph_GPIOE | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOG | RCC_APB2Periph_GPIOE |
RCC_APB2Periph_GPIOF, ENABLE); RCC_APB2Periph_GPIOF, ENABLE);
/*-- GPIO Configuration ------------------------------------------------------*/ /*-- GPIO Configuration ------------------------------------------------------*/
/* SRAM Data lines configuration */ /* SRAM Data lines configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 |
@ -631,37 +644,37 @@ static void FSMC_Configuration()
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 |
GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 |
GPIO_Pin_15; GPIO_Pin_15;
GPIO_Init(GPIOE, &GPIO_InitStructure); GPIO_Init(GPIOE, &GPIO_InitStructure);
/* SRAM Address lines configuration */ /* SRAM Address lines configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 |
GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_12 | GPIO_Pin_13 |
GPIO_Pin_14 | GPIO_Pin_15; GPIO_Pin_14 | GPIO_Pin_15;
GPIO_Init(GPIOF, &GPIO_InitStructure); GPIO_Init(GPIOF, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 |
GPIO_Pin_4 | GPIO_Pin_5; GPIO_Pin_4 | GPIO_Pin_5;
GPIO_Init(GPIOG, &GPIO_InitStructure); GPIO_Init(GPIOG, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13;
GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_Init(GPIOD, &GPIO_InitStructure);
/* NOE and NWE configuration */ /* NOE and NWE configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 |GPIO_Pin_5; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 |GPIO_Pin_5;
GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_Init(GPIOD, &GPIO_InitStructure);
/* NE3 NE4 configuration */ /* NE3 NE4 configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_12; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_12;
GPIO_Init(GPIOG, &GPIO_InitStructure); GPIO_Init(GPIOG, &GPIO_InitStructure);
/* NBL0, NBL1 configuration */ /* NBL0, NBL1 configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
GPIO_Init(GPIOE, &GPIO_InitStructure); GPIO_Init(GPIOE, &GPIO_InitStructure);
/*-- FSMC Configuration ------------------------------------------------------*/ /*-- FSMC Configuration ------------------------------------------------------*/
p.FSMC_AddressSetupTime = 0; p.FSMC_AddressSetupTime = 0;
p.FSMC_AddressHoldTime = 0; p.FSMC_AddressHoldTime = 0;
@ -670,7 +683,7 @@ static void FSMC_Configuration()
p.FSMC_CLKDivision = 0; p.FSMC_CLKDivision = 0;
p.FSMC_DataLatency = 0; p.FSMC_DataLatency = 0;
p.FSMC_AccessMode = FSMC_AccessMode_A; p.FSMC_AccessMode = FSMC_AccessMode_A;
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM4; FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM4;
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
@ -685,9 +698,9 @@ static void FSMC_Configuration()
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
/* Enable FSMC Bank1_SRAM Bank4 */ /* Enable FSMC Bank1_SRAM Bank4 */
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE); FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);
} }

View File

@ -1,3 +1,17 @@
/*
* File : dm9000a.c
* 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-07-01 Bernard the first version
*/
#ifndef __DM9000_H__ #ifndef __DM9000_H__
#define __DM9000_H__ #define __DM9000_H__

View File

@ -1,3 +1,16 @@
/*
* File : enc28j60.c
* 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-05-05 Bernard the first version
*/
#include "enc28j60.h" #include "enc28j60.h"
#include <netif/ethernetif.h> #include <netif/ethernetif.h>

View File

@ -1,3 +1,17 @@
/*
* File : enc28j60.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-01-05 Bernard the first version
*/
#ifndef __ENC28J60_H__ #ifndef __ENC28J60_H__
#define __ENC28J60_H__ #define __ENC28J60_H__

View File

@ -1,3 +1,16 @@
/*
* File : led.c
* 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-01-05 Bernard the first version
*/
#include <rtthread.h> #include <rtthread.h>
#include <stm32f10x.h> #include <stm32f10x.h>

View File

@ -1,5 +1,20 @@
/*
* File : led.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-01-05 Bernard the first version
*/
#ifndef __LED_H__ #ifndef __LED_H__
#define __LED_H__ #define __LED_H__
#include <rtthread.h> #include <rtthread.h>
void rt_hw_led_init(void); void rt_hw_led_init(void);

View File

@ -1,3 +1,17 @@
/*
* File : rtc.c
* 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-01-05 Bernard the first version
*/
#include <rtthread.h> #include <rtthread.h>
#include <stm32f10x.h> #include <stm32f10x.h>
@ -8,7 +22,7 @@ static rt_err_t rt_rtc_open(rt_device_t dev, rt_uint16_t oflag)
{ {
/* Open Interrupt */ /* Open Interrupt */
} }
return RT_EOK; return RT_EOK;
} }
@ -29,14 +43,14 @@ static rt_err_t rt_rtc_control(rt_device_t dev, rt_uint8_t cmd, void *args)
/* read device */ /* read device */
*time = RTC_GetCounter(); *time = RTC_GetCounter();
break; break;
case RT_DEVICE_CTRL_RTC_SET_TIME: case RT_DEVICE_CTRL_RTC_SET_TIME:
{ {
time = (rt_time_t *)args; time = (rt_time_t *)args;
/* Enable PWR and BKP clocks */ /* Enable PWR and BKP clocks */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
/* Allow access to BKP Domain */ /* Allow access to BKP Domain */
PWR_BackupAccessCmd(ENABLE); PWR_BackupAccessCmd(ENABLE);
@ -45,11 +59,11 @@ static rt_err_t rt_rtc_control(rt_device_t dev, rt_uint8_t cmd, void *args)
/* Change the current time */ /* Change the current time */
RTC_SetCounter(*time); RTC_SetCounter(*time);
/* Wait until last write operation on RTC registers has finished */ /* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask(); RTC_WaitForLastTask();
BKP_WriteBackupRegister(BKP_DR1, 0xA5A5); BKP_WriteBackupRegister(BKP_DR1, 0xA5A5);
} }
break; break;
} }
@ -124,10 +138,10 @@ void rt_hw_rtc_init(void)
rtc.read = rt_rtc_read; rtc.read = rt_rtc_read;
rtc.write = RT_NULL; rtc.write = RT_NULL;
rtc.control = rt_rtc_control; rtc.control = rt_rtc_control;
/* no private */ /* no private */
rtc.private = RT_NULL; rtc.private = RT_NULL;
rt_device_register(&rtc, "rtc", RT_DEVICE_FLAG_RDWR); rt_device_register(&rtc, "rtc", RT_DEVICE_FLAG_RDWR);
return; return;
@ -138,14 +152,14 @@ time_t time(time_t* t)
{ {
rt_device_t device; rt_device_t device;
time_t time; time_t time;
device = rt_device_find("rtc"); device = rt_device_find("rtc");
if (device != RT_NULL) if (device != RT_NULL)
{ {
rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
if (t != RT_NULL) *t = time; if (t != RT_NULL) *t = time;
} }
return time; return time;
} }
@ -156,11 +170,11 @@ void set_date(rt_uint32_t year, rt_uint32_t month, rt_uint32_t day)
time_t now; time_t now;
struct tm* ti; struct tm* ti;
rt_device_t device; rt_device_t device;
ti = RT_NULL; ti = RT_NULL;
/* get current time */ /* get current time */
time(&now); time(&now);
ti = localtime(&now); ti = localtime(&now);
if (ti != RT_NULL) if (ti != RT_NULL)
{ {
@ -168,9 +182,9 @@ void set_date(rt_uint32_t year, rt_uint32_t month, rt_uint32_t day)
ti->tm_mon = month; ti->tm_mon = month;
ti->tm_mday = day; ti->tm_mday = day;
} }
now = mktime(ti); now = mktime(ti);
device = rt_device_find("rtc"); device = rt_device_find("rtc");
if (device != RT_NULL) if (device != RT_NULL)
{ {
@ -188,7 +202,7 @@ void set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second)
ti = RT_NULL; ti = RT_NULL;
/* get current time */ /* get current time */
time(&now); time(&now);
ti = localtime(&now); ti = localtime(&now);
if (ti != RT_NULL) if (ti != RT_NULL)
{ {
@ -196,7 +210,7 @@ void set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second)
ti->tm_min = minute; ti->tm_min = minute;
ti->tm_sec = second; ti->tm_sec = second;
} }
now = mktime(ti); now = mktime(ti);
device = rt_device_find("rtc"); device = rt_device_find("rtc");
if (device != RT_NULL) if (device != RT_NULL)
@ -209,7 +223,7 @@ FINSH_FUNCTION_EXPORT(set_time, set second)
void list_date() void list_date()
{ {
time_t now; time_t now;
time(&now); time(&now);
rt_kprintf("%s\n", ctime(&now)); rt_kprintf("%s\n", ctime(&now));
} }

View File

@ -1,3 +1,17 @@
/*
* File : rtc.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-01-05 Bernard the first version
*/
#ifndef __RTC_H__ #ifndef __RTC_H__
#define __RTC_H__ #define __RTC_H__

View File

@ -17,7 +17,7 @@
/* SECTION: RT_DEBUG */ /* SECTION: RT_DEBUG */
/* Thread Debug */ /* Thread Debug */
#define RT_DEBUG #define RT_DEBUG
#define RT_THREAD_DEBUG /* #define RT_THREAD_DEBUG */
#define RT_USING_OVERFLOW_CHECK #define RT_USING_OVERFLOW_CHECK
@ -31,7 +31,7 @@
#define RT_TIMER_TICK_PER_SECOND 10 #define RT_TIMER_TICK_PER_SECOND 10
/* SECTION: IPC */ /* SECTION: IPC */
/* Using Semaphore*/ /* Using Semaphore */
#define RT_USING_SEMAPHORE #define RT_USING_SEMAPHORE
/* Using Mutex */ /* Using Mutex */
@ -62,16 +62,17 @@
#define RT_USING_UART1 #define RT_USING_UART1
/* SECTION: Console options */ /* SECTION: Console options */
/* the buffer size of console*/ /* the buffer size of console */
#define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLEBUF_SIZE 128
/* SECTION: finsh, a C-Express shell */ /* SECTION: finsh, a C-Express shell */
/* Using FinSH as Shell*/
#define RT_USING_FINSH #define RT_USING_FINSH
/* Using symbol table */ /* Using symbol table */
#define FINSH_USING_SYMTAB #define FINSH_USING_SYMTAB
#define FINSH_USING_DESCRIPTION #define FINSH_USING_DESCRIPTION
/* SECTION: device filesystem */ /* SECTION: device filesystem support */
#define RT_USING_DFS #define RT_USING_DFS
#define RT_USING_DFS_EFSL #define RT_USING_DFS_EFSL
/* #define RT_USING_DFS_ELMFAT */ /* #define RT_USING_DFS_ELMFAT */

View File

@ -1,15 +1,15 @@
/* /*
* File : startup.c * File : startup.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team * COPYRIGHT (C) 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2006-08-31 Bernard first implementation * 2009-01-05 Bernard first implementation
*/ */
#include <rthw.h> #include <rthw.h>

View File

@ -1,3 +1,17 @@
/*
* File : stm3210c_eval_lcd.c
* 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-11-01 Bernard the first version
*/
#include <rtthread.h> #include <rtthread.h>
#include "stm3210c_eval_lcd.h" #include "stm3210c_eval_lcd.h"
#include "stm32f10x.h" #include "stm32f10x.h"

View File

@ -1,3 +1,17 @@
/*
* File : stm3210c_eval_lcd.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-11-01 Bernard the first version
*/
#ifndef __STM3210C_EVAL_LCD_H__ #ifndef __STM3210C_EVAL_LCD_H__
#define __STM3210C_EVAL_LCD_H__ #define __STM3210C_EVAL_LCD_H__

View File

@ -1,3 +1,17 @@
/*
* File : stm3210e_eval_lcd.c
* 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-11-01 Bernard the first version
*/
#include <rtthread.h> #include <rtthread.h>
#include "stm32f10x.h" #include "stm32f10x.h"
@ -9,8 +23,8 @@
#include <rtgui/driver.h> #include <rtgui/driver.h>
#include <rtgui/color.h> #include <rtgui/color.h>
/* /*
* LCD Driver * LCD Driver
* RGB mode (5-6-5) * RGB mode (5-6-5)
* 240 x 320 pixel LCD * 240 x 320 pixel LCD
*/ */
@ -119,14 +133,14 @@ void LCD_DisplayOn(void)
void LCD_DisplayOff(void) void LCD_DisplayOff(void)
{ {
/* Display Off */ /* Display Off */
LCD_WriteReg(0x26, 0x0); LCD_WriteReg(0x26, 0x0);
} }
/******************************************************************************* /*******************************************************************************
* Function Name : LCD_SetCursor * Function Name : LCD_SetCursor
* Description : Sets the cursor position. * Description : Sets the cursor position.
* Input : - Xpos: specifies the X position. * Input : - Xpos: specifies the X position.
* - Ypos: specifies the Y position. * - Ypos: specifies the Y position.
* Output : None * Output : None
* Return : None * Return : None
*******************************************************************************/ *******************************************************************************/
@ -134,10 +148,10 @@ void LCD_SetCursor(rt_uint32_t x, rt_uint32_t y)
{ {
LCD_WriteReg(0x06, (x & 0xff00) >> 8); LCD_WriteReg(0x06, (x & 0xff00) >> 8);
LCD_WriteReg(0x07, (x & 0x00ff)); LCD_WriteReg(0x07, (x & 0x00ff));
LCD_WriteReg(0x02, (y & 0xff00) >> 8); LCD_WriteReg(0x02, (y & 0xff00) >> 8);
LCD_WriteReg(0x03, (y & 0x00ff)); LCD_WriteReg(0x03, (y & 0x00ff));
} }
/******************************************************************************* /*******************************************************************************
* Function Name : LCD_CtrlLinesConfig * Function Name : LCD_CtrlLinesConfig
@ -150,10 +164,10 @@ void LCD_SetCursor(rt_uint32_t x, rt_uint32_t y)
void LCD_CtrlLinesConfig(void) void LCD_CtrlLinesConfig(void)
{ {
GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitTypeDef GPIO_InitStructure;
/* Enable FSMC, GPIOD, GPIOE, GPIOF, GPIOG and AFIO clocks */ /* Enable FSMC, GPIOD, GPIOE, GPIOF, GPIOG and AFIO clocks */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE |
RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG | RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG |
RCC_APB2Periph_AFIO, ENABLE); RCC_APB2Periph_AFIO, ENABLE);
@ -169,10 +183,10 @@ void LCD_CtrlLinesConfig(void)
GPIO_SetBits(GPIOC, GPIO_Pin_6); GPIO_SetBits(GPIOC, GPIO_Pin_6);
/* Set PD.00(D2), PD.01(D3), PD.04(NOE), PD.05(NWE), PD.08(D13), PD.09(D14), /* Set PD.00(D2), PD.01(D3), PD.04(NOE), PD.05(NWE), PD.08(D13), PD.09(D14),
PD.10(D15), PD.14(D0), PD.15(D1) as alternate PD.10(D15), PD.14(D0), PD.15(D1) as alternate
function push pull */ function push pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 |
GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_14 |
GPIO_Pin_15; GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
@ -180,8 +194,8 @@ void LCD_CtrlLinesConfig(void)
/* Set PE.07(D4), PE.08(D5), PE.09(D6), PE.10(D7), PE.11(D8), PE.12(D9), PE.13(D10), /* Set PE.07(D4), PE.08(D5), PE.09(D6), PE.10(D7), PE.11(D8), PE.12(D9), PE.13(D10),
PE.14(D11), PE.15(D12) as alternate function push pull */ PE.14(D11), PE.15(D12) as alternate function push pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 |
GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 |
GPIO_Pin_15; GPIO_Pin_15;
GPIO_Init(GPIOE, &GPIO_InitStructure); GPIO_Init(GPIOE, &GPIO_InitStructure);
@ -189,7 +203,7 @@ void LCD_CtrlLinesConfig(void)
/* Set PF.00(A0 (RS)) as alternate function push pull */ /* Set PF.00(A0 (RS)) as alternate function push pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_Init(GPIOF, &GPIO_InitStructure); GPIO_Init(GPIOF, &GPIO_InitStructure);
/* Set PG.12(NE4 (LCD/CS)) as alternate function push pull - CE3(LCD /CS) */ /* Set PG.12(NE4 (LCD/CS)) as alternate function push pull - CE3(LCD /CS) */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_Init(GPIOG, &GPIO_InitStructure); GPIO_Init(GPIOG, &GPIO_InitStructure);
@ -206,7 +220,7 @@ void LCD_FSMCConfig(void)
{ {
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef p; FSMC_NORSRAMTimingInitTypeDef p;
/*-- FSMC Configuration ------------------------------------------------------*/ /*-- FSMC Configuration ------------------------------------------------------*/
/*----------------------- SRAM Bank 4 ----------------------------------------*/ /*----------------------- SRAM Bank 4 ----------------------------------------*/
/* FSMC_Bank1_NORSRAM4 configuration */ /* FSMC_Bank1_NORSRAM4 configuration */
@ -217,7 +231,7 @@ void LCD_FSMCConfig(void)
p.FSMC_CLKDivision = 0; p.FSMC_CLKDivision = 0;
p.FSMC_DataLatency = 0; p.FSMC_DataLatency = 0;
p.FSMC_AccessMode = FSMC_AccessMode_A; p.FSMC_AccessMode = FSMC_AccessMode_A;
/* Color LCD configuration ------------------------------------ /* Color LCD configuration ------------------------------------
LCD configured as follow: LCD configured as follow:
- Data/Address MUX = Disable - Data/Address MUX = Disable
@ -241,9 +255,9 @@ void LCD_FSMCConfig(void)
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
/* BANK 4 (of NOR/SRAM Bank 1~4) is enabled */ /* BANK 4 (of NOR/SRAM Bank 1~4) is enabled */
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE); FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);
} }
@ -266,7 +280,7 @@ void rt_hw_lcd_set_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
p = rtgui_color_to_565p(*c); p = rtgui_color_to_565p(*c);
LCD_SetCursor(y, x); LCD_SetCursor(y, x);
/* Prepare to write GRAM */ /* Prepare to write GRAM */
LCD_WriteRAM_Prepare(); LCD_WriteRAM_Prepare();
LCD_WriteRAM(p); LCD_WriteRAM(p);
@ -275,7 +289,7 @@ void rt_hw_lcd_set_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
void rt_hw_lcd_get_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y) void rt_hw_lcd_get_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
{ {
rt_uint16_t hc; rt_uint16_t hc;
LCD_SetCursor(y, x); LCD_SetCursor(y, x);
hc = LCD_ReadRAM(); hc = LCD_ReadRAM();
*c = rtgui_color_from_565p(hc); *c = rtgui_color_from_565p(hc);
@ -284,7 +298,7 @@ void rt_hw_lcd_get_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
void rt_hw_lcd_draw_hline(rtgui_color_t *c, rt_base_t x1, rt_base_t x2, rt_base_t y) void rt_hw_lcd_draw_hline(rtgui_color_t *c, rt_base_t x1, rt_base_t x2, rt_base_t y)
{ {
rt_uint16_t hc; rt_uint16_t hc;
hc = rtgui_color_to_565p(*c); hc = rtgui_color_to_565p(*c);
LCD_SetCursor(y, x1); LCD_SetCursor(y, x1);
@ -356,10 +370,10 @@ void rt_hw_lcd_init()
{ {
/* Configure the LCD Control pins --------------------------------------------*/ /* Configure the LCD Control pins --------------------------------------------*/
LCD_CtrlLinesConfig(); LCD_CtrlLinesConfig();
/* Configure the FSMC Parallel interface -------------------------------------*/ /* Configure the FSMC Parallel interface -------------------------------------*/
LCD_FSMCConfig(); LCD_FSMCConfig();
Delay(5); /* delay 50 ms */ Delay(5); /* delay 50 ms */
// Gamma for CMO 3.2¡± // Gamma for CMO 3.2¡±
LCD_WriteReg(0x46,0x94); LCD_WriteReg(0x46,0x94);
@ -374,7 +388,7 @@ void rt_hw_lcd_init()
LCD_WriteReg(0x4f,0xcc); LCD_WriteReg(0x4f,0xcc);
LCD_WriteReg(0x50,0x46); LCD_WriteReg(0x50,0x46);
LCD_WriteReg(0x51,0x82); LCD_WriteReg(0x51,0x82);
//240x320 window setting //240x320 window setting
LCD_WriteReg(0x02,0x00); LCD_WriteReg(0x02,0x00);
LCD_WriteReg(0x03,0x00); LCD_WriteReg(0x03,0x00);
@ -382,49 +396,49 @@ void rt_hw_lcd_init()
LCD_WriteReg(0x05,0x3f); LCD_WriteReg(0x05,0x3f);
LCD_WriteReg(0x06,0x00); LCD_WriteReg(0x06,0x00);
LCD_WriteReg(0x07,0x00); LCD_WriteReg(0x07,0x00);
LCD_WriteReg(0x08,0x00); LCD_WriteReg(0x08,0x00);
LCD_WriteReg(0x09,0xef); LCD_WriteReg(0x09,0xef);
// Display Setting // Display Setting
LCD_WriteReg(0x01,0x06); LCD_WriteReg(0x01,0x06);
LCD_WriteReg(0x16,0x68); LCD_WriteReg(0x16,0x68);
LCD_WriteReg(0x23,0x95); LCD_WriteReg(0x23,0x95);
LCD_WriteReg(0x24,0x95); LCD_WriteReg(0x24,0x95);
LCD_WriteReg(0x25,0xff); LCD_WriteReg(0x25,0xff);
LCD_WriteReg(0x27,0x02); LCD_WriteReg(0x27,0x02);
LCD_WriteReg(0x28,0x02); LCD_WriteReg(0x28,0x02);
LCD_WriteReg(0x29,0x02); LCD_WriteReg(0x29,0x02);
LCD_WriteReg(0x2a,0x02); LCD_WriteReg(0x2a,0x02);
LCD_WriteReg(0x2c,0x02); LCD_WriteReg(0x2c,0x02);
LCD_WriteReg(0x2d,0x02); LCD_WriteReg(0x2d,0x02);
LCD_WriteReg(0x3a,0x01);///******************* LCD_WriteReg(0x3a,0x01);///*******************
LCD_WriteReg(0x3b,0x01); LCD_WriteReg(0x3b,0x01);
LCD_WriteReg(0x3c,0xf0); LCD_WriteReg(0x3c,0xf0);
LCD_WriteReg(0x3d,0x00); LCD_WriteReg(0x3d,0x00);
Delay(2); Delay(2);
LCD_WriteReg(0x35,0x38); LCD_WriteReg(0x35,0x38);
LCD_WriteReg(0x36,0x78); LCD_WriteReg(0x36,0x78);
LCD_WriteReg(0x3e,0x38); LCD_WriteReg(0x3e,0x38);
LCD_WriteReg(0x40,0x0f); LCD_WriteReg(0x40,0x0f);
LCD_WriteReg(0x41,0xf0); LCD_WriteReg(0x41,0xf0);
// Power Supply Setting // Power Supply Setting
LCD_WriteReg(0x19,0x49);//******** LCD_WriteReg(0x19,0x49);//********
LCD_WriteReg(0x93,0x0f);//******* LCD_WriteReg(0x93,0x0f);//*******
Delay(1); Delay(1);
LCD_WriteReg(0x20,0x30); LCD_WriteReg(0x20,0x30);
LCD_WriteReg(0x1d,0x07); LCD_WriteReg(0x1d,0x07);
LCD_WriteReg(0x1e,0x00); LCD_WriteReg(0x1e,0x00);
LCD_WriteReg(0x1f,0x07); LCD_WriteReg(0x1f,0x07);
// VCOM Setting for CMO 3.2¡± Panel // VCOM Setting for CMO 3.2¡± Panel
LCD_WriteReg(0x44,0x4d);//4d***************4f LCD_WriteReg(0x44,0x4d);//4d***************4f
LCD_WriteReg(0x45,0x13);//0x0a); LCD_WriteReg(0x45,0x13);//0x0a);
@ -435,9 +449,9 @@ void rt_hw_lcd_init()
Delay(5); Delay(5);
LCD_WriteReg(0x1b,0x08); LCD_WriteReg(0x1b,0x08);
Delay(4); Delay(4);
LCD_WriteReg(0x1b,0x10); LCD_WriteReg(0x1b,0x10);
Delay(4); Delay(4);
// Display ON Setting // Display ON Setting
LCD_WriteReg(0x90,0x7f); LCD_WriteReg(0x90,0x7f);
LCD_WriteReg(0x26,0x04); LCD_WriteReg(0x26,0x04);
@ -446,12 +460,12 @@ void rt_hw_lcd_init()
LCD_WriteReg(0x26,0x2c); LCD_WriteReg(0x26,0x2c);
Delay(4); Delay(4);
LCD_WriteReg(0x26,0x3c); LCD_WriteReg(0x26,0x3c);
// Set internal VDDD voltage // Set internal VDDD voltage
LCD_WriteReg(0x57,0x02); LCD_WriteReg(0x57,0x02);
LCD_WriteReg(0x55,0x00); LCD_WriteReg(0x55,0x00);
LCD_WriteReg(0x57,0x00); LCD_WriteReg(0x57,0x00);
/* add lcd driver into graphic driver */ /* add lcd driver into graphic driver */
rtgui_list_init(&_rtgui_lcd_driver.list); rtgui_list_init(&_rtgui_lcd_driver.list);
rtgui_graphic_driver_add(&_rtgui_lcd_driver); rtgui_graphic_driver_add(&_rtgui_lcd_driver);

View File

@ -1,3 +1,17 @@
/*
* File : stm3210e_eval_lcd.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-11-01 Bernard the first version
*/
#ifndef __LCD_H__ #ifndef __LCD_H__
#define __LCD_H__ #define __LCD_H__

View File

@ -1,3 +1,17 @@
/*
* File : usart.c
* 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-01-05 Bernard the first version
*/
#include "usart.h" #include "usart.h"
#include <serial.h> #include <serial.h>
#include <stm32f10x_dma.h> #include <stm32f10x_dma.h>

View File

@ -1,3 +1,17 @@
/*
* File : usart.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-01-05 Bernard the first version
*/
#ifndef __USART_H__ #ifndef __USART_H__
#define __USART_H__ #define __USART_H__

View File

@ -1,7 +1,7 @@
/* /*
* File : context_gcc.S * File : context_gcc.S
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team * COPYRIGHT (C) 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@ -151,9 +151,9 @@ rt_hw_context_switch_to:
LDR r0, =NVIC_INT_CTRL /* trigger the PendSV exception (causes context switch) */ LDR r0, =NVIC_INT_CTRL /* trigger the PendSV exception (causes context switch) */
LDR r1, =NVIC_PENDSVSET LDR r1, =NVIC_PENDSVSET
STR r1, [r0] STR r1, [r0]
CPSIE I /* enable interrupts at processor level */ CPSIE I /* enable interrupts at processor level */
/* never reach here! */ /* never reach here! */
/* compatible with old version */ /* compatible with old version */

View File

@ -1,7 +1,7 @@
;/* ;/*
; * File : context.S ; * File : context_iar.S
; * This file is part of RT-Thread RTOS ; * This file is part of RT-Thread RTOS
; * COPYRIGHT (C) 2006, RT-Thread Development Team ; * COPYRIGHT (C) 2009, RT-Thread Development Team
; * ; *
; * The license and distribution terms for this file may be ; * The license and distribution terms for this file may be
; * found in the file LICENSE in this distribution or at ; * found in the file LICENSE in this distribution or at
@ -109,7 +109,7 @@ rt_hw_pend_sv:
swtich_to_thread swtich_to_thread
LDR r1, =rt_interrupt_to_thread LDR r1, =rt_interrupt_to_thread
LDR r1, [r1] LDR r1, [r1]
LDR r1, [r1] ; load thread stack pointer LDR r1, [r1] ; load thread stack pointer
LDMFD r1!, {r4 - r11} ; pop r4 - r11 register LDMFD r1!, {r4 - r11} ; pop r4 - r11 register
MSR psp, r1 ; update stack pointer MSR psp, r1 ; update stack pointer
@ -148,9 +148,9 @@ rt_hw_context_switch_to:
LDR r0, =NVIC_INT_CTRL ; trigger the PendSV exception (causes context switch) LDR r0, =NVIC_INT_CTRL ; trigger the PendSV exception (causes context switch)
LDR r1, =NVIC_PENDSVSET LDR r1, =NVIC_PENDSVSET
STR r1, [r0] STR r1, [r0]
CPSIE I ; enable interrupts at processor level CPSIE I ; enable interrupts at processor level
; never reach here! ; never reach here!
; compatible with old version ; compatible with old version

View File

@ -1,7 +1,7 @@
;/* ;/*
; * File : context.S ; * File : context_rvds.S
; * This file is part of RT-Thread RTOS ; * This file is part of RT-Thread RTOS
; * COPYRIGHT (C) 2006, RT-Thread Development Team ; * COPYRIGHT (C) 2009, RT-Thread Development Team
; * ; *
; * The license and distribution terms for this file may be ; * The license and distribution terms for this file may be
; * found in the file LICENSE in this distribution or at ; * found in the file LICENSE in this distribution or at
@ -112,7 +112,7 @@ rt_hw_pend_sv PROC
swtich_to_thread swtich_to_thread
LDR r1, =rt_interrupt_to_thread LDR r1, =rt_interrupt_to_thread
LDR r1, [r1] LDR r1, [r1]
LDR r1, [r1] ; load thread stack pointer LDR r1, [r1] ; load thread stack pointer
LDMFD r1!, {r4 - r11} ; pop r4 - r11 register LDMFD r1!, {r4 - r11} ; pop r4 - r11 register
MSR psp, r1 ; update stack pointer MSR psp, r1 ; update stack pointer
@ -155,10 +155,10 @@ rt_hw_context_switch_to PROC
LDR r0, =NVIC_INT_CTRL LDR r0, =NVIC_INT_CTRL
LDR r1, =NVIC_PENDSVSET LDR r1, =NVIC_PENDSVSET
STR r1, [r0] STR r1, [r0]
; enable interrupts at processor level ; enable interrupts at processor level
CPSIE I CPSIE I
; never reach here! ; never reach here!
ENDP ENDP

View File

@ -1,15 +1,15 @@
/* /*
* File : cpu.c * File : cpu.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team * COPYRIGHT (C) 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2006-03-13 Bernard first version * 2009-01-05 Bernard first version
*/ */
#include <rtthread.h> #include <rtthread.h>

View File

@ -1,3 +1,16 @@
/*
* File : fault.c
* 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-01-05 Bernard first version
*/
#include <rtthread.h> #include <rtthread.h>
struct stack_contex struct stack_contex

View File

@ -1,7 +1,7 @@
/* /*
* File : fault_gcc.S * File : fault_gcc.S
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team * COPYRIGHT (C) 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at

View File

@ -1,7 +1,7 @@
;/* ;/*
; * File : context.S ; * File : fault_iar.S
; * This file is part of RT-Thread RTOS ; * This file is part of RT-Thread RTOS
; * COPYRIGHT (C) 2006, RT-Thread Development Team ; * COPYRIGHT (C) 2009, RT-Thread Development Team
; * ; *
; * The license and distribution terms for this file may be ; * The license and distribution terms for this file may be
; * found in the file LICENSE in this distribution or at ; * found in the file LICENSE in this distribution or at

View File

@ -1,5 +1,5 @@
;/* ;/*
; * File : context.S ; * File : fault_rvds.S
; * This file is part of RT-Thread RTOS ; * This file is part of RT-Thread RTOS
; * COPYRIGHT (C) 2006, RT-Thread Development Team ; * COPYRIGHT (C) 2006, RT-Thread Development Team
; * ; *

View File

@ -1,15 +1,15 @@
/* /*
* File : trap.c * File : interrupt.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2006-03-13 Bernard first version * 2009-01-05 Bernard first version
*/ */
#include <rtthread.h> #include <rtthread.h>

View File

@ -1,11 +1,11 @@
/* /*
* File : serial.c * File : serial.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
@ -17,7 +17,7 @@
#include "serial.h" #include "serial.h"
#include <stm32f10x_dma.h> #include <stm32f10x_dma.h>
static void rt_serial_enable_dma(DMA_Channel_TypeDef* dma_channel, static void rt_serial_enable_dma(DMA_Channel_TypeDef* dma_channel,
rt_uint32_t address, rt_uint32_t size); rt_uint32_t address, rt_uint32_t size);
/** /**
@ -34,10 +34,10 @@ int rt_serial_getc(struct stm32_serial_device* uart)
{ {
rt_base_t level; rt_base_t level;
int ch = -1; int ch = -1;
/* disable interrupt */ /* disable interrupt */
level = rt_hw_interrupt_disable(); level = rt_hw_interrupt_disable();
if (uart->int_rx->read_index != uart->int_rx->save_index) if (uart->int_rx->read_index != uart->int_rx->save_index)
{ {
ch = uart->int_rx->rx_buffer[uart->int_rx->read_index]; ch = uart->int_rx->rx_buffer[uart->int_rx->read_index];
@ -46,10 +46,10 @@ int rt_serial_getc(struct stm32_serial_device* uart)
if (uart->int_rx->read_index >= UART_RX_BUFFER_SIZE) if (uart->int_rx->read_index >= UART_RX_BUFFER_SIZE)
uart->int_rx->read_index = 0; uart->int_rx->read_index = 0;
} }
/* enable interrupt */ /* enable interrupt */
rt_hw_interrupt_enable(level); rt_hw_interrupt_enable(level);
return ch; return ch;
} }
@ -57,7 +57,7 @@ int rt_serial_getc(struct stm32_serial_device* uart)
void rt_serial_savechar(struct stm32_serial_device* uart, char ch) void rt_serial_savechar(struct stm32_serial_device* uart, char ch)
{ {
rt_base_t level; rt_base_t level;
/* disable interrupt */ /* disable interrupt */
level = rt_hw_interrupt_disable(); level = rt_hw_interrupt_disable();
@ -65,7 +65,7 @@ void rt_serial_savechar(struct stm32_serial_device* uart, char ch)
uart->int_rx->save_index ++; uart->int_rx->save_index ++;
if (uart->int_rx->save_index >= UART_RX_BUFFER_SIZE) if (uart->int_rx->save_index >= UART_RX_BUFFER_SIZE)
uart->int_rx->save_index = 0; uart->int_rx->save_index = 0;
/* if the next position is read index, discard this 'read char' */ /* if the next position is read index, discard this 'read char' */
if (uart->int_rx->save_index == uart->int_rx->read_index) if (uart->int_rx->save_index == uart->int_rx->read_index)
{ {
@ -107,26 +107,26 @@ static rt_err_t rt_serial_init (rt_device_t dev)
{ {
if (dev->flag & RT_DEVICE_FLAG_INT_RX) if (dev->flag & RT_DEVICE_FLAG_INT_RX)
{ {
rt_memset(uart->int_rx->rx_buffer, 0, rt_memset(uart->int_rx->rx_buffer, 0,
sizeof(uart->int_rx->rx_buffer)); sizeof(uart->int_rx->rx_buffer));
uart->int_rx->read_index = 0; uart->int_rx->read_index = 0;
uart->int_rx->save_index = 0; uart->int_rx->save_index = 0;
} }
if (dev->flag & RT_DEVICE_FLAG_DMA_RX) if (dev->flag & RT_DEVICE_FLAG_DMA_RX)
{ {
RT_ASSERT(uart->dma_rx->dma_channel != RT_NULL); RT_ASSERT(uart->dma_rx->dma_channel != RT_NULL);
uart->dma_rx->read_index = uart->dma_rx->read_descriptor = 0; uart->dma_rx->read_index = uart->dma_rx->read_descriptor = 0;
uart->dma_rx->is_full = RT_FALSE; uart->dma_rx->is_full = RT_FALSE;
} }
if (dev->flag & RT_DEVICE_FLAG_INT_TX) if (dev->flag & RT_DEVICE_FLAG_INT_TX)
{ {
rt_memset(uart->int_tx->tx_buffer, 0, rt_memset(uart->int_tx->tx_buffer, 0,
sizeof(uart->int_tx->tx_buffer)); sizeof(uart->int_tx->tx_buffer));
uart->int_tx->write_index = uart->int_tx->save_index = 0; uart->int_tx->write_index = uart->int_tx->save_index = 0;
} }
if (dev->flag & RT_DEVICE_FLAG_DMA_TX) if (dev->flag & RT_DEVICE_FLAG_DMA_TX)
{ {
RT_ASSERT(uart->dma_rx->dma_channel != RT_NULL); RT_ASSERT(uart->dma_rx->dma_channel != RT_NULL);
@ -145,28 +145,28 @@ static rt_err_t rt_serial_init (rt_device_t dev)
static rt_err_t rt_serial_open(rt_device_t dev, rt_uint16_t oflag) static rt_err_t rt_serial_open(rt_device_t dev, rt_uint16_t oflag)
{ {
struct stm32_serial_device* uart; struct stm32_serial_device* uart;
RT_ASSERT(dev != RT_NULL); RT_ASSERT(dev != RT_NULL);
uart = (struct stm32_serial_device*)dev->private; uart = (struct stm32_serial_device*)dev->private;
if (dev->flag & RT_DEVICE_FLAG_DMA_RX) if (dev->flag & RT_DEVICE_FLAG_DMA_RX)
{ {
/* enable Rx DMA */ /* enable Rx DMA */
rt_serial_enable_dma(uart->dma_rx->dma_channel, rt_serial_enable_dma(uart->dma_rx->dma_channel,
(rt_uint32_t)&(uart->dma_rx->rx_buffer[uart->dma_rx->save_descriptor][0]), (rt_uint32_t)&(uart->dma_rx->rx_buffer[uart->dma_rx->save_descriptor][0]),
UART_DMA_RX_BUFFER_SIZE); UART_DMA_RX_BUFFER_SIZE);
} }
return RT_EOK; return RT_EOK;
} }
static rt_err_t rt_serial_close(rt_device_t dev) static rt_err_t rt_serial_close(rt_device_t dev)
{ {
struct stm32_serial_device* uart; struct stm32_serial_device* uart;
RT_ASSERT(dev != RT_NULL); RT_ASSERT(dev != RT_NULL);
uart = (struct stm32_serial_device*)dev->private; uart = (struct stm32_serial_device*)dev->private;
if (dev->flag & RT_DEVICE_FLAG_DMA_RX) if (dev->flag & RT_DEVICE_FLAG_DMA_RX)
@ -182,7 +182,7 @@ static rt_size_t rt_serial_read (rt_device_t dev, rt_off_t pos, void* buffer, rt
rt_uint8_t* ptr; rt_uint8_t* ptr;
rt_err_t err_code; rt_err_t err_code;
struct stm32_serial_device* uart; struct stm32_serial_device* uart;
ptr = buffer; ptr = buffer;
err_code = RT_EOK; err_code = RT_EOK;
uart = (struct stm32_serial_device*)dev->private; uart = (struct stm32_serial_device*)dev->private;
@ -217,7 +217,7 @@ static rt_size_t rt_serial_read (rt_device_t dev, rt_off_t pos, void* buffer, rt
/* set error code */ /* set error code */
err_code = -RT_EEMPTY; err_code = -RT_EEMPTY;
} }
else else
{ {
/* read data */ /* read data */
while ((rt_uint32_t)ptr - (rt_uint32_t)buffer < size) while ((rt_uint32_t)ptr - (rt_uint32_t)buffer < size)
@ -225,16 +225,16 @@ static rt_size_t rt_serial_read (rt_device_t dev, rt_off_t pos, void* buffer, rt
/* read buffer */ /* read buffer */
*ptr ++ = uart->dma_rx-> *ptr ++ = uart->dma_rx->
rx_buffer[uart->dma_rx->read_descriptor][uart->dma_rx->read_index]; rx_buffer[uart->dma_rx->read_descriptor][uart->dma_rx->read_index];
/* move to next position */ /* move to next position */
uart->dma_rx->read_index ++; uart->dma_rx->read_index ++;
/* wrap read index */ /* wrap read index */
if (uart->dma_rx->read_index >= UART_DMA_RX_BUFFER_SIZE) if (uart->dma_rx->read_index >= UART_DMA_RX_BUFFER_SIZE)
{ {
/* wrap read index */ /* wrap read index */
uart->dma_rx->read_index = 0; uart->dma_rx->read_index = 0;
/* move to next read descriptor */ /* move to next read descriptor */
uart->dma_rx->read_descriptor ++; uart->dma_rx->read_descriptor ++;
/* wrap read descriptor */ /* wrap read descriptor */
@ -252,7 +252,7 @@ static rt_size_t rt_serial_read (rt_device_t dev, rt_off_t pos, void* buffer, rt
rt_hw_interrupt_enable(level); rt_hw_interrupt_enable(level);
/* re-enable DMA to receive */ /* re-enable DMA to receive */
rt_serial_enable_dma(uart->dma_rx->dma_channel, rt_serial_enable_dma(uart->dma_rx->dma_channel,
(rt_uint32_t)&(uart->dma_rx->rx_buffer[uart->dma_rx->save_descriptor][0]), (rt_uint32_t)&(uart->dma_rx->rx_buffer[uart->dma_rx->save_descriptor][0]),
UART_DMA_RX_BUFFER_SIZE); UART_DMA_RX_BUFFER_SIZE);
} }
@ -286,11 +286,11 @@ static rt_size_t rt_serial_read (rt_device_t dev, rt_off_t pos, void* buffer, rt
return (rt_uint32_t)ptr - (rt_uint32_t)buffer; return (rt_uint32_t)ptr - (rt_uint32_t)buffer;
} }
static void rt_serial_enable_dma(DMA_Channel_TypeDef* dma_channel, static void rt_serial_enable_dma(DMA_Channel_TypeDef* dma_channel,
rt_uint32_t address, rt_uint32_t size) rt_uint32_t address, rt_uint32_t size)
{ {
RT_ASSERT(dma_channel != RT_NULL); RT_ASSERT(dma_channel != RT_NULL);
/* disable DMA */ /* disable DMA */
DMA_Cmd(dma_channel, DISABLE); DMA_Cmd(dma_channel, DISABLE);
@ -298,7 +298,7 @@ static void rt_serial_enable_dma(DMA_Channel_TypeDef* dma_channel,
dma_channel->CMAR = address; dma_channel->CMAR = address;
/* set size */ /* set size */
dma_channel->CNDTR = size; dma_channel->CNDTR = size;
/* enable DMA */ /* enable DMA */
DMA_Cmd(dma_channel, ENABLE); DMA_Cmd(dma_channel, ENABLE);
} }
@ -308,7 +308,7 @@ static rt_size_t rt_serial_write (rt_device_t dev, rt_off_t pos, const void* buf
rt_uint8_t* ptr; rt_uint8_t* ptr;
rt_err_t err_code; rt_err_t err_code;
struct stm32_serial_device* uart; struct stm32_serial_device* uart;
err_code = RT_EOK; err_code = RT_EOK;
ptr = (rt_uint8_t*)buffer; ptr = (rt_uint8_t*)buffer;
uart = (struct stm32_serial_device*)dev->private; uart = (struct stm32_serial_device*)dev->private;
@ -320,17 +320,17 @@ static rt_size_t rt_serial_write (rt_device_t dev, rt_off_t pos, const void* buf
{ {
/* save on tx buffer */ /* save on tx buffer */
uart->int_tx->tx_buffer[uart->int_tx->save_index] = *ptr++; uart->int_tx->tx_buffer[uart->int_tx->save_index] = *ptr++;
-- size; -- size;
/* move to next position */ /* move to next position */
uart->int_tx->save_index ++; uart->int_tx->save_index ++;
/* wrap save index */ /* wrap save index */
if (uart->int_tx->save_index >= UART_TX_BUFFER_SIZE) if (uart->int_tx->save_index >= UART_TX_BUFFER_SIZE)
uart->int_tx->save_index = 0; uart->int_tx->save_index = 0;
} }
/* set error code */ /* set error code */
if (size > 0) if (size > 0)
err_code = -RT_EFULL; err_code = -RT_EFULL;
@ -338,9 +338,9 @@ static rt_size_t rt_serial_write (rt_device_t dev, rt_off_t pos, const void* buf
else if (dev->flag & RT_DEVICE_FLAG_DMA_TX) else if (dev->flag & RT_DEVICE_FLAG_DMA_TX)
{ {
/* DMA mode Tx */ /* DMA mode Tx */
/* allocate a data node */ /* allocate a data node */
struct stm32_serial_data_node* data_node = struct stm32_serial_data_node* data_node =
(struct stm32_serial_data_node*) rt_malloc (sizeof(struct stm32_serial_data_node)); (struct stm32_serial_data_node*) rt_malloc (sizeof(struct stm32_serial_data_node));
if (data_node == RT_NULL) if (data_node == RT_NULL)
{ {
@ -350,14 +350,14 @@ static rt_size_t rt_serial_write (rt_device_t dev, rt_off_t pos, const void* buf
else else
{ {
rt_uint32_t level; rt_uint32_t level;
/* fill data node */ /* fill data node */
data_node->data_ptr = ptr; data_node->data_ptr = ptr;
data_node->data_size = size; data_node->data_size = size;
/* insert to data link */ /* insert to data link */
data_node->next = RT_NULL; data_node->next = RT_NULL;
/* disable interrupt */ /* disable interrupt */
level = rt_hw_interrupt_disable(); level = rt_hw_interrupt_disable();
@ -365,15 +365,15 @@ static rt_size_t rt_serial_write (rt_device_t dev, rt_off_t pos, const void* buf
if (uart->dma_tx->list_tail != RT_NULL) if (uart->dma_tx->list_tail != RT_NULL)
uart->dma_tx->list_tail->next = data_node; uart->dma_tx->list_tail->next = data_node;
uart->dma_tx->list_tail = data_node; uart->dma_tx->list_tail = data_node;
if (uart->dma_tx->list_head == RT_NULL) if (uart->dma_tx->list_head == RT_NULL)
{ {
/* start DMA to transmit data */ /* start DMA to transmit data */
uart->dma_tx->list_head = data_node; uart->dma_tx->list_head = data_node;
/* Enable DMA Channel */ /* Enable DMA Channel */
rt_serial_enable_dma(uart->dma_tx->dma_channel, rt_serial_enable_dma(uart->dma_tx->dma_channel,
(rt_uint32_t)uart->dma_tx->list_head->data_ptr, (rt_uint32_t)uart->dma_tx->list_head->data_ptr,
uart->dma_tx->list_head->data_size); uart->dma_tx->list_head->data_size);
} }
@ -389,18 +389,18 @@ static rt_size_t rt_serial_write (rt_device_t dev, rt_off_t pos, const void* buf
rt_serial_putc(dev, *ptr); rt_serial_putc(dev, *ptr);
++ptr; --size; ++ptr; --size;
} }
} }
/* set error code */ /* set error code */
rt_set_errno(err_code); rt_set_errno(err_code);
return (rt_uint32_t)ptr - (rt_uint32_t)buffer; 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) static rt_err_t rt_serial_control (rt_device_t dev, rt_uint8_t cmd, void *args)
{ {
struct stm32_serial_device* uart; struct stm32_serial_device* uart;
RT_ASSERT(dev != RT_NULL); RT_ASSERT(dev != RT_NULL);
uart = (struct stm32_serial_device*)dev->private; uart = (struct stm32_serial_device*)dev->private;
@ -411,19 +411,19 @@ static rt_err_t rt_serial_control (rt_device_t dev, rt_uint8_t cmd, void *args)
dev->flag |= RT_DEVICE_FLAG_SUSPENDED; dev->flag |= RT_DEVICE_FLAG_SUSPENDED;
USART_Cmd(uart->uart_device, DISABLE); USART_Cmd(uart->uart_device, DISABLE);
break; break;
case RT_DEVICE_CTRL_RESUME: case RT_DEVICE_CTRL_RESUME:
/* resume device */ /* resume device */
dev->flag &= ~RT_DEVICE_FLAG_SUSPENDED; dev->flag &= ~RT_DEVICE_FLAG_SUSPENDED;
USART_Cmd(uart->uart_device, ENABLE); USART_Cmd(uart->uart_device, ENABLE);
break; break;
} }
return RT_EOK; return RT_EOK;
} }
/* /*
* serial register for STM32 * serial register for STM32
* support STM32F103VB and STM32F103ZE * support STM32F103VB and STM32F103ZE
*/ */
rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t flag, struct stm32_serial_device *serial) rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t flag, struct stm32_serial_device *serial)
@ -449,10 +449,10 @@ rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t
void rt_hw_serial_isr(rt_device_t device) void rt_hw_serial_isr(rt_device_t device)
{ {
struct stm32_serial_device* uart = (struct stm32_serial_device*) device->private; struct stm32_serial_device* uart = (struct stm32_serial_device*) device->private;
if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET) if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
{ {
/* interrupt mode receive */ /* interrupt mode receive */
RT_ASSERT(device->flag & RT_DEVICE_FLAG_INT_RX); RT_ASSERT(device->flag & RT_DEVICE_FLAG_INT_RX);
/* save on rx buffer */ /* save on rx buffer */
@ -460,7 +460,7 @@ void rt_hw_serial_isr(rt_device_t device)
{ {
rt_serial_savechar(uart, uart->uart_device->DR & 0xff); rt_serial_savechar(uart, uart->uart_device->DR & 0xff);
} }
/* clear interrupt */ /* clear interrupt */
USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE); USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);
@ -468,7 +468,7 @@ void rt_hw_serial_isr(rt_device_t device)
if (device->rx_indicate != RT_NULL) if (device->rx_indicate != RT_NULL)
{ {
rt_size_t rx_length; rt_size_t rx_length;
/* get rx length */ /* get rx length */
rx_length = uart->int_rx->read_index > uart->int_rx->save_index ? 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_RX_BUFFER_SIZE - uart->int_rx->read_index + uart->int_rx->save_index :
@ -477,12 +477,12 @@ void rt_hw_serial_isr(rt_device_t device)
device->rx_indicate(device, rx_length); device->rx_indicate(device, rx_length);
} }
} }
if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET) if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET)
{ {
/* interrupt mode transmission */ /* interrupt mode transmission */
RT_ASSERT(device->flag & RT_DEVICE_FLAG_INT_TX); RT_ASSERT(device->flag & RT_DEVICE_FLAG_INT_TX);
/* transmission completed */ /* transmission completed */
uart->int_tx->write_index ++; uart->int_tx->write_index ++;
if (uart->int_tx->write_index >= UART_TX_BUFFER_SIZE) if (uart->int_tx->write_index >= UART_TX_BUFFER_SIZE)
@ -490,7 +490,7 @@ void rt_hw_serial_isr(rt_device_t device)
/* clear interrupt */ /* clear interrupt */
USART_ClearITPendingBit(uart->uart_device, USART_IT_TC); USART_ClearITPendingBit(uart->uart_device, USART_IT_TC);
/* start next transmission */ /* start next transmission */
if (uart->int_tx->write_index < if (uart->int_tx->write_index <
uart->int_tx->save_index) uart->int_tx->save_index)
@ -501,33 +501,33 @@ void rt_hw_serial_isr(rt_device_t device)
} }
} }
/* /*
* ISR for DMA mode Rx * ISR for DMA mode Rx
*/ */
void rt_hw_serial_dma_rx_isr(rt_device_t device) void rt_hw_serial_dma_rx_isr(rt_device_t device)
{ {
rt_uint32_t next_descriptor; rt_uint32_t next_descriptor;
struct stm32_serial_device* uart = (struct stm32_serial_device*) device->private; struct stm32_serial_device* uart = (struct stm32_serial_device*) device->private;
/* DMA mode receive */ /* DMA mode receive */
RT_ASSERT(device->flag & RT_DEVICE_FLAG_DMA_RX); RT_ASSERT(device->flag & RT_DEVICE_FLAG_DMA_RX);
/* invoke callback */ /* invoke callback */
if (device->rx_indicate != RT_NULL) if (device->rx_indicate != RT_NULL)
device->rx_indicate(device, UART_DMA_RX_BUFFER_SIZE); device->rx_indicate(device, UART_DMA_RX_BUFFER_SIZE);
next_descriptor = uart->dma_rx->save_descriptor; next_descriptor = uart->dma_rx->save_descriptor;
/* move to next descriptor */ /* move to next descriptor */
next_descriptor ++; next_descriptor ++;
if (next_descriptor >= UART_DMA_RX_DESCRIPTOR) if (next_descriptor >= UART_DMA_RX_DESCRIPTOR)
next_descriptor = 0; next_descriptor = 0;
if (next_descriptor != uart->dma_rx->read_descriptor) if (next_descriptor != uart->dma_rx->read_descriptor)
{ {
uart->dma_rx->save_descriptor = next_descriptor; uart->dma_rx->save_descriptor = next_descriptor;
/* enable next DMA */ /* enable next DMA */
rt_serial_enable_dma(uart->dma_rx->dma_channel, rt_serial_enable_dma(uart->dma_rx->dma_channel,
(rt_uint32_t)&(uart->dma_rx->rx_buffer[uart->dma_rx->save_descriptor][0]), (rt_uint32_t)&(uart->dma_rx->rx_buffer[uart->dma_rx->save_descriptor][0]),
UART_DMA_RX_BUFFER_SIZE); UART_DMA_RX_BUFFER_SIZE);
} }
@ -539,7 +539,7 @@ void rt_hw_serial_dma_rx_isr(rt_device_t device)
} }
} }
/* /*
* ISR for DMA mode Tx * ISR for DMA mode Tx
*/ */
void rt_hw_serial_dma_tx_isr(rt_device_t device) void rt_hw_serial_dma_tx_isr(rt_device_t device)
@ -548,20 +548,20 @@ void rt_hw_serial_dma_tx_isr(rt_device_t device)
struct stm32_serial_data_node* data_node; struct stm32_serial_data_node* data_node;
struct stm32_serial_device* uart = (struct stm32_serial_device*) device->private; struct stm32_serial_device* uart = (struct stm32_serial_device*) device->private;
/* DMA mode receive */ /* DMA mode receive */
RT_ASSERT(device->flag & RT_DEVICE_FLAG_DMA_TX); RT_ASSERT(device->flag & RT_DEVICE_FLAG_DMA_TX);
/* get the first data node */ /* get the first data node */
data_node = uart->dma_tx->list_head; data_node = uart->dma_tx->list_head;
RT_ASSERT(data_node != RT_NULL); RT_ASSERT(data_node != RT_NULL);
/* invoke call to notify tx complete */ /* invoke call to notify tx complete */
if (device->tx_complete != RT_NULL) if (device->tx_complete != RT_NULL)
device->tx_complete(device, data_node->data_ptr); device->tx_complete(device, data_node->data_ptr);
/* disable interrupt */ /* disable interrupt */
level = rt_hw_interrupt_disable(); level = rt_hw_interrupt_disable();
/* remove list tail */ /* remove list tail */
uart->dma_tx->list_tail = data_node->prev; uart->dma_tx->list_tail = data_node->prev;
if (uart->dma_tx->list_tail == RT_NULL) if (uart->dma_tx->list_tail == RT_NULL)
@ -569,10 +569,10 @@ void rt_hw_serial_dma_tx_isr(rt_device_t device)
/* enable interrupt */ /* enable interrupt */
rt_hw_interrupt_enable(level); rt_hw_interrupt_enable(level);
/* free data node memory */ /* free data node memory */
rt_free(data_node); rt_free(data_node);
if (uart->dma_tx->list_tail != RT_NULL) if (uart->dma_tx->list_tail != RT_NULL)
{ {
/* transmit next data node */ /* transmit next data node */

View File

@ -1,3 +1,16 @@
/*
* File : serial.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-01-05 Bernard first version
*/
#ifndef __RT_HW_SERIAL_H__ #ifndef __RT_HW_SERIAL_H__
#define __RT_HW_SERIAL_H__ #define __RT_HW_SERIAL_H__

View File

@ -1,11 +1,11 @@
/* /*
* File : stack.c * File : stack.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes

View File

@ -1,11 +1,11 @@
/* /*
* File : clock.c * File : clock.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
@ -50,7 +50,7 @@ rt_tick_t rt_tick_get()
} }
/** /**
* This function will notify kernel there is one tick passed. Normally, * This function will notify kernel there is one tick passed. Normally,
* this function is invoked by clock ISR. * this function is invoked by clock ISR.
*/ */
void rt_tick_increase() void rt_tick_increase()

View File

@ -1,11 +1,11 @@
/* /*
* File : device.c * File : device.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
@ -81,7 +81,7 @@ rt_err_t rt_device_init_all()
result = init(device); result = init(device);
if (result != RT_EOK) if (result != RT_EOK)
{ {
rt_kprintf("To initialize device:%s failed. The error code is %d\n", rt_kprintf("To initialize device:%s failed. The error code is %d\n",
device->parent.name, result); device->parent.name, result);
} }
else else

View File

@ -1,11 +1,11 @@
/* /*
* File : idle.c * File : idle.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes

View File

@ -1,7 +1,7 @@
/* /*
* File : ipc.c * File : ipc.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@ -26,9 +26,9 @@
* 2009-07-18 Bernard fix the event clear bug * 2009-07-18 Bernard fix the event clear bug
* 2009-09-09 Bernard remove fast event and fix ipc release bug * 2009-09-09 Bernard remove fast event and fix ipc release bug
* 2009-10-10 Bernard change semaphore and mutex value to unsigned value * 2009-10-10 Bernard change semaphore and mutex value to unsigned value
* 2009-10-25 Bernard change the mb/mq receive timeout to 0 if the * 2009-10-25 Bernard change the mb/mq receive timeout to 0 if the
* re-calculated delta tick is a negative number. * re-calculated delta tick is a negative number.
* 2009-12-16 Bernard fix the rt_ipc_object_suspend issue when IPC flag * 2009-12-16 Bernard fix the rt_ipc_object_suspend issue when IPC flag
* is RT_IPC_FLAG_PRIO * is RT_IPC_FLAG_PRIO
*/ */
@ -334,7 +334,7 @@ rt_err_t rt_sem_take (rt_sem_t sem, rt_int32_t time)
temp = rt_hw_interrupt_disable(); temp = rt_hw_interrupt_disable();
#ifdef RT_IPC_DEBUG #ifdef RT_IPC_DEBUG
rt_kprintf("thread %s take sem:%s, which value is: %d\n", rt_thread_self()->name, rt_kprintf("thread %s take sem:%s, which value is: %d\n", rt_thread_self()->name,
((struct rt_object*)sem)->name, sem->value); ((struct rt_object*)sem)->name, sem->value);
#endif #endif
if (sem->value > 0) if (sem->value > 0)
@ -437,7 +437,7 @@ rt_err_t rt_sem_release(rt_sem_t sem)
temp = rt_hw_interrupt_disable(); temp = rt_hw_interrupt_disable();
#ifdef RT_IPC_DEBUG #ifdef RT_IPC_DEBUG
rt_kprintf("thread %s releases sem:%s, which value is: %d\n", rt_thread_self()->name, rt_kprintf("thread %s releases sem:%s, which value is: %d\n", rt_thread_self()->name,
((struct rt_object*)sem)->name, sem->value); ((struct rt_object*)sem)->name, sem->value);
#endif #endif
@ -612,7 +612,7 @@ rt_err_t rt_mutex_take (rt_mutex_t mutex, rt_int32_t time)
#endif #endif
#ifdef RT_IPC_DEBUG #ifdef RT_IPC_DEBUG
rt_kprintf("mutex_take: current thread %s, mutex value: %d, hold: %d\n", rt_kprintf("mutex_take: current thread %s, mutex value: %d, hold: %d\n",
thread->name, mutex->value, mutex->hold); thread->name, mutex->value, mutex->hold);
#endif #endif
@ -626,7 +626,7 @@ rt_err_t rt_mutex_take (rt_mutex_t mutex, rt_int32_t time)
} }
else else
{ {
/* in initialization status, the value is 1. Therefore, if the /* in initialization status, the value is 1. Therefore, if the
* value is great than 1, which indicates the mutex is avaible. * value is great than 1, which indicates the mutex is avaible.
*/ */
if (mutex->value > 0) if (mutex->value > 0)
@ -737,7 +737,7 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
temp = rt_hw_interrupt_disable(); temp = rt_hw_interrupt_disable();
#ifdef RT_IPC_DEBUG #ifdef RT_IPC_DEBUG
rt_kprintf("mutex_release:current thread %s, mutex value: %d, hold: %d\n", rt_kprintf("mutex_release:current thread %s, mutex value: %d, hold: %d\n",
thread->name, mutex->value, mutex->hold); thread->name, mutex->value, mutex->hold);
#endif #endif
@ -803,7 +803,7 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
/* perform a schedule */ /* perform a schedule */
if (need_schedule == RT_TRUE) rt_schedule(); if (need_schedule == RT_TRUE) rt_schedule();
return RT_EOK; return RT_EOK;
} }
@ -1799,7 +1799,7 @@ rt_err_t rt_mq_recv (rt_mq_t mq, void* buffer, rt_size_t size, rt_int32_t timeou
/* get current thread */ /* get current thread */
thread = rt_thread_self(); thread = rt_thread_self();
/* message queue is empty */ /* message queue is empty */
while (mq->entry == 0) while (mq->entry == 0)
{ {
@ -1824,7 +1824,7 @@ rt_err_t rt_mq_recv (rt_mq_t mq, void* buffer, rt_size_t size, rt_int32_t timeou
{ {
/* get the start tick of timer */ /* get the start tick of timer */
tick_delta = rt_tick_get(); tick_delta = rt_tick_get();
#ifdef RT_IPC_DEBUG #ifdef RT_IPC_DEBUG
rt_kprintf("set thread:%s to timer list\n", thread->name); rt_kprintf("set thread:%s to timer list\n", thread->name);
#endif #endif

View File

@ -1,11 +1,11 @@
/* /*
* File : irq.c * File : irq.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
@ -36,7 +36,7 @@ volatile rt_uint32_t rt_interrupt_nest;
void rt_interrupt_enter() void rt_interrupt_enter()
{ {
rt_base_t level; rt_base_t level;
#ifdef IRQ_DEBUG #ifdef IRQ_DEBUG
rt_kprintf("irq comming..., irq nest:%d\n", rt_interrupt_nest); rt_kprintf("irq comming..., irq nest:%d\n", rt_interrupt_nest);
#endif #endif

View File

@ -1,11 +1,11 @@
/* /*
* File : kservice.c * File : kservice.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
@ -31,16 +31,16 @@ int errno;
/* /*
* This function will get errno * This function will get errno
* *
* @return errno * @return errno
*/ */
rt_err_t rt_get_errno(void) rt_err_t rt_get_errno(void)
{ {
rt_thread_t tid; rt_thread_t tid;
tid = rt_thread_self(); tid = rt_thread_self();
if (tid == RT_NULL) return errno; if (tid == RT_NULL) return errno;
return tid->error; return tid->error;
} }
@ -52,10 +52,10 @@ rt_err_t rt_get_errno(void)
void rt_set_errno(rt_err_t error) void rt_set_errno(rt_err_t error)
{ {
rt_thread_t tid; rt_thread_t tid;
tid = rt_thread_self(); tid = rt_thread_self();
if (tid == RT_NULL) { errno = error; return; } if (tid == RT_NULL) { errno = error; return; }
tid->error = error; tid->error = error;
} }
@ -605,12 +605,12 @@ static rt_int32_t vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list
end = buf + size - 1; end = buf + size - 1;
/* Make sure end is always >= buf */ /* Make sure end is always >= buf */
if (end < buf) if (end < buf)
{ {
end = ((char *)-1); end = ((char *)-1);
size = end - buf; size = end - buf;
} }
for (; *fmt ; ++fmt) for (; *fmt ; ++fmt)
{ {
if (*fmt != '%') if (*fmt != '%')
@ -859,7 +859,7 @@ rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *fmt, ...)
* This function will fill a formatted string to buffer * This function will fill a formatted string to buffer
* *
* @param buf the buffer to save formatted string * @param buf the buffer to save formatted string
* @param arg_ptr the arg_ptr * @param arg_ptr the arg_ptr
* @param format the format * @param format the format
*/ */
rt_int32_t rt_vsprintf(char *buf, const char *format, va_list arg_ptr) rt_int32_t rt_vsprintf(char *buf, const char *format, va_list arg_ptr)
@ -877,11 +877,11 @@ rt_int32_t rt_sprintf(char *buf ,const char *format,...)
{ {
rt_int32_t n; rt_int32_t n;
va_list arg_ptr; va_list arg_ptr;
va_start(arg_ptr, format); va_start(arg_ptr, format);
n = rt_vsprintf(buf ,format,arg_ptr); n = rt_vsprintf(buf ,format,arg_ptr);
va_end (arg_ptr); va_end (arg_ptr);
return n; return n;
} }

View File

@ -1,11 +1,11 @@
/* /*
* File : kservice.h * File : kservice.h
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
@ -49,7 +49,7 @@ rt_inline void rt_list_insert_after(rt_list_t *l, rt_list_t *n)
} }
/** /**
* @brief insert a node before a list * @brief insert a node before a list
* *
* @param n new node to be inserted * @param n new node to be inserted
* @param l list to insert it * @param l list to insert it

View File

@ -1,7 +1,7 @@
/* /*
* File : kservice.c * File : mem.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2008, RT-Thread Development Team * COPYRIGHT (C) 2008 - 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@ -61,9 +61,9 @@ static void (*rt_free_hook)(void *ptr);
/*@{*/ /*@{*/
/** /**
* This function will set a hook function, which will be invoked when a memory * This function will set a hook function, which will be invoked when a memory
* block is allocated from heap memory. * block is allocated from heap memory.
* *
* @param hook the hook function * @param hook the hook function
*/ */
void rt_malloc_sethook(void (*hook)(void *ptr, rt_size_t size)) void rt_malloc_sethook(void (*hook)(void *ptr, rt_size_t size))
@ -72,9 +72,9 @@ void rt_malloc_sethook(void (*hook)(void *ptr, rt_size_t size))
} }
/** /**
* This function will set a hook function, which will be invoked when a memory * This function will set a hook function, which will be invoked when a memory
* block is released to heap memory. * block is released to heap memory.
* *
* @param hook the hook function * @param hook the hook function
*/ */
void rt_free_sethook(void (*hook)(void *ptr)) void rt_free_sethook(void (*hook)(void *ptr))
@ -238,7 +238,7 @@ void *rt_malloc(rt_size_t size)
/* take memory semaphore */ /* take memory semaphore */
rt_sem_take(&heap_sem, RT_WAITING_FOREVER); rt_sem_take(&heap_sem, RT_WAITING_FOREVER);
for (ptr = (rt_uint8_t *)lfree - heap_ptr; ptr < mem_size_aligned - size; for (ptr = (rt_uint8_t *)lfree - heap_ptr; ptr < mem_size_aligned - size;
ptr = ((struct heap_mem *)&heap_ptr[ptr])->next) ptr = ((struct heap_mem *)&heap_ptr[ptr])->next)
{ {
mem = (struct heap_mem *)&heap_ptr[ptr]; mem = (struct heap_mem *)&heap_ptr[ptr];
@ -334,7 +334,7 @@ void *rt_malloc(rt_size_t size)
* *
* @param rmem pointer to memory allocated by rt_malloc * @param rmem pointer to memory allocated by rt_malloc
* @param newsize the required new size * @param newsize the required new size
* *
* @return the changed memory block address * @return the changed memory block address
*/ */
void *rt_realloc(void *rmem, rt_size_t newsize) void *rt_realloc(void *rmem, rt_size_t newsize)
@ -356,7 +356,7 @@ void *rt_realloc(void *rmem, rt_size_t newsize)
rt_sem_take(&heap_sem, RT_WAITING_FOREVER); rt_sem_take(&heap_sem, RT_WAITING_FOREVER);
if ((rt_uint8_t *)rmem < (rt_uint8_t *)heap_ptr || if ((rt_uint8_t *)rmem < (rt_uint8_t *)heap_ptr ||
(rt_uint8_t *)rmem >= (rt_uint8_t *)heap_end) (rt_uint8_t *)rmem >= (rt_uint8_t *)heap_end)
{ {
/* illegal memory */ /* illegal memory */
@ -404,8 +404,8 @@ void *rt_realloc(void *rmem, rt_size_t newsize)
} }
/** /**
* This function will contiguously allocate enough space for count objects * This function will contiguously allocate enough space for count objects
* that are size bytes of memory each and returns a pointer to the allocated * that are size bytes of memory each and returns a pointer to the allocated
* memory. * memory.
* *
* The allocated memory is filled with bytes of value zero. * The allocated memory is filled with bytes of value zero.
@ -429,7 +429,7 @@ void *rt_calloc(rt_size_t count, rt_size_t size)
} }
/** /**
* This function will release the previously allocated memory block by rt_malloc. * This function will release the previously allocated memory block by rt_malloc.
* The released memory block is taken back to system heap. * The released memory block is taken back to system heap.
* *
* @param rmem the address of memory which will be released * @param rmem the address of memory which will be released
@ -488,7 +488,7 @@ void rt_free(void *rmem)
} }
#ifdef RT_MEM_STATS #ifdef RT_MEM_STATS
void rt_memory_info(rt_uint32_t *total, void rt_memory_info(rt_uint32_t *total,
rt_uint32_t *used, rt_uint32_t *used,
rt_uint32_t *max_used) rt_uint32_t *max_used)
{ {
@ -496,7 +496,7 @@ void rt_memory_info(rt_uint32_t *total,
if (used != RT_NULL) *used = used_mem; if (used != RT_NULL) *used = used_mem;
if (max_used != RT_NULL) *max_used = max_mem; if (max_used != RT_NULL) *max_used = max_mem;
} }
#ifdef RT_USING_FINSH #ifdef RT_USING_FINSH
#include <finsh.h> #include <finsh.h>
void list_mem() void list_mem()

View File

@ -1,16 +1,16 @@
/* /*
* File : partition.c * File : mempool.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2006-05-27 Bernard implement memory pool * 2006-05-27 Bernard implement memory pool
* 2006-06-03 Bernard fix the thread timer init bug * 2006-06-03 Bernard fix the thread timer init bug
* 2006-06-30 Bernard fix the allocate/free block bug * 2006-06-30 Bernard fix the allocate/free block bug
* 2006-08-04 Bernard add hook support * 2006-08-04 Bernard add hook support
* 2006-08-10 Bernard fix interrupt bug in rt_mp_alloc * 2006-08-10 Bernard fix interrupt bug in rt_mp_alloc
@ -35,7 +35,7 @@ static void (*rt_mp_free_hook)(struct rt_mempool* mp, void *block);
/** /**
* This function will set a hook function, which will be invoked when a memory * This function will set a hook function, which will be invoked when a memory
* block is allocated from memory pool. * block is allocated from memory pool.
* *
* @param hook the hook function * @param hook the hook function
*/ */
void rt_mp_alloc_sethook(void (*hook)(struct rt_mempool* mp, void *block)) void rt_mp_alloc_sethook(void (*hook)(struct rt_mempool* mp, void *block))
@ -46,7 +46,7 @@ void rt_mp_alloc_sethook(void (*hook)(struct rt_mempool* mp, void *block))
/** /**
* This function will set a hook function, which will be invoked when a memory * This function will set a hook function, which will be invoked when a memory
* block is released to memory pool. * block is released to memory pool.
* *
* @param hook the hook function * @param hook the hook function
*/ */
void rt_mp_free_sethook(void (*hook)(struct rt_mempool* mp, void *block)) void rt_mp_free_sethook(void (*hook)(struct rt_mempool* mp, void *block))
@ -135,7 +135,7 @@ rt_err_t rt_mp_detach(struct rt_mempool* mp)
thread->error = -RT_ERROR; thread->error = -RT_ERROR;
/* /*
* resume thread * resume thread
* In rt_thread_resume function, it will remove current thread from suspend * In rt_thread_resume function, it will remove current thread from suspend
* list * list
*/ */
@ -238,7 +238,7 @@ rt_err_t rt_mp_delete(rt_mp_t mp)
thread->error = -RT_ERROR; thread->error = -RT_ERROR;
/* /*
* resume thread * resume thread
* In rt_thread_resume function, it will remove current thread from suspend * In rt_thread_resume function, it will remove current thread from suspend
* list * list
*/ */
@ -253,7 +253,7 @@ rt_err_t rt_mp_delete(rt_mp_t mp)
/* release allocated room */ /* release allocated room */
rt_free(mp->start_address); rt_free(mp->start_address);
/* detach object */ /* detach object */
rt_object_delete(&(mp->parent)); rt_object_delete(&(mp->parent));
@ -275,7 +275,7 @@ void *rt_mp_alloc (rt_mp_t mp, rt_int32_t time)
rt_uint8_t* block_ptr; rt_uint8_t* block_ptr;
register rt_base_t level; register rt_base_t level;
struct rt_thread* thread; struct rt_thread* thread;
/* disable interrupt */ /* disable interrupt */
level = rt_hw_interrupt_disable(); level = rt_hw_interrupt_disable();
@ -314,7 +314,7 @@ void *rt_mp_alloc (rt_mp_t mp, rt_int32_t time)
{ {
/* init thread timer and start it */ /* init thread timer and start it */
rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, &time); rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, &time);
rt_timer_start(&(thread->thread_timer)); rt_timer_start(&(thread->thread_timer));
} }
/* enable interrupt */ /* enable interrupt */
@ -336,7 +336,7 @@ void *rt_mp_alloc (rt_mp_t mp, rt_int32_t time)
mp->block_list = *(rt_uint8_t**)block_ptr; mp->block_list = *(rt_uint8_t**)block_ptr;
/* point to memory pool */ /* point to memory pool */
*(rt_uint8_t**)block_ptr = (rt_uint8_t*)mp; *(rt_uint8_t**)block_ptr = (rt_uint8_t*)mp;
} }
} }

View File

@ -1,11 +1,11 @@
/* /*
* File : object.c * File : object.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes

View File

@ -1,11 +1,11 @@
/* /*
* File : scheduler.c * File : scheduler.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes

View File

@ -1,7 +1,7 @@
/* /*
* File : slab.c * File : slab.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2008, RT-Thread Development Team * COPYRIGHT (C) 2008 - 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at

View File

@ -1,11 +1,11 @@
/* /*
* File : thread.c * File : thread.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
@ -81,7 +81,7 @@ static rt_err_t _rt_thread_init(struct rt_thread* thread,
/* init user data */ /* init user data */
thread->user_data = 0; thread->user_data = 0;
/* init thread timer */ /* init thread timer */
rt_timer_init(&(thread->thread_timer), rt_timer_init(&(thread->thread_timer),
thread->name, thread->name,

View File

@ -1,7 +1,7 @@
/* /*
* File : timer.c * File : timer.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@ -420,12 +420,12 @@ static struct rt_thread timer_thread;
static rt_uint8_t timer_thread_stack[RT_TIMER_THREAD_STACK_SIZE]; static rt_uint8_t timer_thread_stack[RT_TIMER_THREAD_STACK_SIZE];
static struct rt_semaphore timer_sem; static struct rt_semaphore timer_sem;
static rt_uint16_t timer_ex_cnt; static rt_uint16_t timer_ex_cnt;
void rt_soft_timer_tick_increase (void) void rt_soft_timer_tick_increase (void)
{ {
timer_ex_cnt++; timer_ex_cnt++;
if (timer_ex_cnt >= (RT_TICK_PER_SECOND / RT_TIMER_EX_TICKS_PER_SEC)) if (timer_ex_cnt >= (RT_TICK_PER_SECOND / RT_TIMER_TICK_PER_SECOND))
{ {
timer_ex_cnt = 0; timer_ex_cnt = 0;
rt_sem_release(&timer_sem); rt_sem_release(&timer_sem);