git-svn-id: https://rt-thread.googlecode.com/svn/trunk@246 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
6abb53c3d4
commit
1df7e4fdc7
|
@ -35,7 +35,7 @@ if rtconfig.RT_USING_DFS:
|
||||||
if rtconfig.RT_USING_LWIP:
|
if rtconfig.RT_USING_LWIP:
|
||||||
objs = objs + SConscript(RTT_ROOT + '/net/lwip/SConscript', variant_dir='build/net/lwip', duplicate=0)
|
objs = objs + SConscript(RTT_ROOT + '/net/lwip/SConscript', variant_dir='build/net/lwip', duplicate=0)
|
||||||
|
|
||||||
src_bsp = ['application.c', 'startup.c', 'board.c']
|
src_bsp = ['application.c', 'startup.c', 'board.c','led.c']
|
||||||
src_drv = ['console.c']
|
src_drv = ['console.c']
|
||||||
|
|
||||||
if rtconfig.RT_USING_DFS:
|
if rtconfig.RT_USING_DFS:
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include <board.h>
|
#include <board.h>
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
|
#include "led.h"
|
||||||
|
|
||||||
#ifdef RT_USING_DFS
|
#ifdef RT_USING_DFS
|
||||||
/* dfs init */
|
/* dfs init */
|
||||||
|
@ -87,23 +88,50 @@ void rt_init_thread_entry(void* parameter)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rt_led_thread_entry(void* parameter)
|
||||||
|
{
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
/* led on 1s */
|
||||||
|
rt_hw_led_on(LED2|LED3);
|
||||||
|
rt_thread_delay(100);
|
||||||
|
|
||||||
|
/* led off 1s */
|
||||||
|
rt_hw_led_off(LED2|LED3);
|
||||||
|
rt_thread_delay(100);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int rt_application_init()
|
int rt_application_init()
|
||||||
{
|
{
|
||||||
rt_thread_t init_thread;
|
rt_thread_t init_thread;
|
||||||
|
rt_thread_t led_thread;
|
||||||
|
|
||||||
#if (RT_THREAD_PRIORITY_MAX == 32)
|
#if (RT_THREAD_PRIORITY_MAX == 32)
|
||||||
init_thread = rt_thread_create("init",
|
init_thread = rt_thread_create("init",
|
||||||
rt_init_thread_entry, RT_NULL,
|
rt_init_thread_entry, RT_NULL,
|
||||||
2048, 8, 20);
|
2048, 8, 20);
|
||||||
|
|
||||||
|
led_thread = rt_thread_create("led",
|
||||||
|
rt_led_thread_entry, RT_NULL,
|
||||||
|
512, 20, 20);
|
||||||
#else
|
#else
|
||||||
init_thread = rt_thread_create("init",
|
init_thread = rt_thread_create("init",
|
||||||
rt_init_thread_entry, RT_NULL,
|
rt_init_thread_entry, RT_NULL,
|
||||||
2048, 80, 20);
|
2048, 80, 20);
|
||||||
|
|
||||||
|
led_thread = rt_thread_create("led",
|
||||||
|
rt_led_thread_entry, RT_NULL,
|
||||||
|
512, 200, 20);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (init_thread != RT_NULL)
|
if (init_thread != RT_NULL)
|
||||||
rt_thread_startup(init_thread);
|
rt_thread_startup(init_thread);
|
||||||
|
|
||||||
|
if(led_thread != RT_NULL)
|
||||||
|
rt_thread_startup(led_thread);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <rthw.h>
|
#include <rthw.h>
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
#include "led.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup mini2440
|
* @addtogroup mini2440
|
||||||
|
@ -41,7 +42,6 @@ extern void rt_hw_get_clock(void);
|
||||||
extern void rt_hw_set_dividor(rt_uint8_t hdivn, rt_uint8_t pdivn);
|
extern void rt_hw_set_dividor(rt_uint8_t hdivn, rt_uint8_t pdivn);
|
||||||
extern void rt_hw_set_clock(rt_uint8_t sdiv, rt_uint8_t pdiv, rt_uint8_t mdiv);
|
extern void rt_hw_set_clock(rt_uint8_t sdiv, rt_uint8_t pdiv, rt_uint8_t mdiv);
|
||||||
|
|
||||||
static rt_uint32_t timer_load_val = 0;
|
|
||||||
|
|
||||||
#define UART0 ((struct uartport *)U0BASE)
|
#define UART0 ((struct uartport *)U0BASE)
|
||||||
struct serial_int_rx uart0_int_rx;
|
struct serial_int_rx uart0_int_rx;
|
||||||
|
@ -58,9 +58,6 @@ struct rt_device uart0_device;
|
||||||
*/
|
*/
|
||||||
void rt_timer_handler(int vector)
|
void rt_timer_handler(int vector)
|
||||||
{
|
{
|
||||||
/* reset TDATA0 */
|
|
||||||
TCNTB4 = timer_load_val;
|
|
||||||
|
|
||||||
rt_tick_increase();
|
rt_tick_increase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +112,29 @@ void rt_hw_uart_init(void)
|
||||||
rt_hw_interrupt_umask(INTUART0);
|
rt_hw_interrupt_umask(INTUART0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will init timer4 for system ticks
|
||||||
|
*/
|
||||||
|
void rt_hw_timer_init()
|
||||||
|
{
|
||||||
|
/* timer4, pre = 15+1 */
|
||||||
|
TCFG0 &= 0xffff00ff;
|
||||||
|
TCFG0 |= 15 << 8;
|
||||||
|
/* all are interrupt mode,set Timer 4 MUX 1/4 */
|
||||||
|
TCFG1 &= 0xfff0ffff;
|
||||||
|
TCFG1 |= 0x00010000;
|
||||||
|
|
||||||
|
TCNTB4 = (rt_int32_t)(PCLK / (4 *16* RT_TICK_PER_SECOND)) - 1;
|
||||||
|
/* manual update */
|
||||||
|
TCON = TCON & (~(0x0f<<20)) | (0x02<<20);
|
||||||
|
/* install interrupt handler */
|
||||||
|
rt_hw_interrupt_install(INTTIMER4, rt_timer_handler, RT_NULL);
|
||||||
|
rt_hw_interrupt_umask(INTTIMER4);
|
||||||
|
|
||||||
|
/* start timer4, reload */
|
||||||
|
TCON = TCON & (~(0x0f<<20)) | (0x05<<20);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function will init s3ceb2410 board
|
* This function will init s3ceb2410 board
|
||||||
*/
|
*/
|
||||||
|
@ -126,6 +146,9 @@ void rt_hw_board_init()
|
||||||
/* Get the clock */
|
/* Get the clock */
|
||||||
rt_hw_get_clock();
|
rt_hw_get_clock();
|
||||||
|
|
||||||
|
/* initialize led port */
|
||||||
|
rt_hw_led_init();
|
||||||
|
|
||||||
/* initialize uart */
|
/* initialize uart */
|
||||||
rt_hw_uart_init();
|
rt_hw_uart_init();
|
||||||
|
|
||||||
|
@ -139,12 +162,8 @@ void rt_hw_board_init()
|
||||||
rt_hw_touch_init();
|
rt_hw_touch_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* install interrupt handler */
|
/* initialize timer4 */
|
||||||
rt_hw_interrupt_install(INTTIMER4, rt_timer_handler, RT_NULL);
|
rt_hw_timer_init();
|
||||||
rt_hw_interrupt_umask(INTTIMER4);
|
|
||||||
|
|
||||||
/* stop timer */
|
|
||||||
/* TCON = 0x0; */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* File : led.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2006, RT-Thread Develop Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2009-12-27 rdghx mini2440
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <s3c24x0.h>
|
||||||
|
#include "led.h"
|
||||||
|
|
||||||
|
void rt_hw_led_init(void)
|
||||||
|
{
|
||||||
|
/* GPB5,GPB6,GPB7,GPB8 for LED */
|
||||||
|
GPBCON = GPBCON & (~(0xff << 10)) | (0x55 << 10);
|
||||||
|
GPBUP |= (0x0f << 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rt_hw_led_on(unsigned char value)
|
||||||
|
{
|
||||||
|
GPBDAT &= ~ ((value & 0x0f) << 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rt_hw_led_off(unsigned char value)
|
||||||
|
{
|
||||||
|
GPBDAT |= (value & 0x0f) << 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* File : led.h
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2006, RT-Thread Develop Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2009-12-27 rdghx mini2440
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LED_H__
|
||||||
|
#define __LED_H__
|
||||||
|
|
||||||
|
#define LED1 0x01
|
||||||
|
#define LED2 0x02
|
||||||
|
#define LED3 0x04
|
||||||
|
#define LED4 0x08
|
||||||
|
#define LED_ALL 0x0f
|
||||||
|
|
||||||
|
void rt_hw_led_init(void);
|
||||||
|
void rt_hw_led_on(unsigned char value);
|
||||||
|
void rt_hw_led_off(unsigned char value);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue