⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 board.c

📁 RT-Thread是发展中的下一代微内核嵌入式实时操作系统
💻 C
字号:
/* * File      : board.c * This file is part of RT-Thread RTOS * COPYRIGHT (C) 2006, RT-Thread Develop Team * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://openlab.rt-thread.com/license/LICENSE * * Change Logs: * Date           Author       Notes * 2006-03-24     Bernard      first implementation * 2006-05-05     Bernard      add DATA_COUNT definition * 2006-10-05     Alsor.Z      for s3c2410x porting * 2007-11-20     Yi.Qiu	   add lcd,touch,console */#include <rtthread.h>#include <rthw.h>#include <s3c2410.h>/** * @addtogroup s3ceb2410 *//*@{*/extern rt_uint32_t PCLK;extern rt_uint32_t FCLK;extern rt_uint32_t HCLK;extern rt_uint32_t UCLK;extern rt_uint8_t asc16_font[];extern rt_uint16_t _rt_hw_framebuffer[];extern void rt_hw_touch_init(void);extern void rt_hw_lcd_init(void);extern void rt_console_init(rt_uint8_t*, rt_uint8_t*, rt_uint8_t);extern void rt_hw_mmu_init();extern void rt_hw_get_clock(void);extern void rt_hw_set_clock(rt_uint8_t sdiv, rt_uint8_t pdiv, rt_uint8_t mdiv);extern void rt_hw_set_dividor(rt_uint8_t hdivn, rt_uint8_t pdivn);static rt_uint32_t timer_load_val = 0;void rt_timer_handler(int vector){	/* reset TDATA0 */	TCNTB4 = timer_load_val;	rt_tick_increase();}/** * This function will init s3ceb2410 board */void rt_hw_board_init(){	/* FCLK = 304.8M */	#define MDIV		68	#define PDIV		1	#define SDIV		1	//rt_hw_set_clock(SDIV, PDIV, MDIV);	/* HCLK = PCLK = FCLK */	rt_hw_set_dividor(0, 0);	/* use PWM Timer 4 because it has no output */	/* prescaler for Timer 4 is 16 */	TCFG0 = 0x0f00;	/* all divider = 1/2 */	TCFG1 = 0x0;	rt_hw_get_clock();	if (timer_load_val == 0)	{		/*		 * for 10 ms clock period @ PCLK with 4 bit divider = 1/2		 * (default) and prescaler = 16. Should be 10390		 * @33.25MHz and 15625 @ 50 MHz		 */		timer_load_val = PCLK/(2 * 16 * 100);	}	/* load value for 10 ms timeout */	TCNTB4 = timer_load_val;	/* auto load, manual update of Timer 4 */	TCON = (TCON & ~0x0700000) | 0x600000;	/* auto load, start Timer 4 */	TCON = (TCON & ~0x0700000) | 0x500000 | 0x3;	/*Enable NAND, USBD, PWM TImer, UART0,1 and GPIO clock,*/	CLKCON = 0xfffff0;#ifndef RT_USING_EMULATOR	/* init mmu system */	rt_hw_mmu_init();#else	lowlevel_init();#endif	rt_hw_lcd_init();	//rt_console_init(&_rt_hw_framebuffer[0], &asc16_font[0], 2);#ifdef RT_USING_RTGUI	rt_hw_touch_init();#endif	/* install interrupt handler */	rt_hw_interrupt_install(INTTIMER4, rt_timer_handler, RT_NULL);	rt_hw_interrupt_umask(INTTIMER4);	/* stop timer 	*/	/* TCON = 0x0;	*/}#ifdef RT_USING_FINSHextern void finsh_notify(void);void rt_serial_isr(int vector){	INTSUBMSK |= (BIT_SUB_RXD0);	finsh_notify();	SUBSRCPND |= BIT_SUB_RXD0;	/*Unmask sub interrupt (RXD0)*/	INTSUBMSK  &=~(BIT_SUB_RXD0);}void rt_hw_finsh_init(){	/* install UART isr */	INTSUBMSK &= ~(BIT_SUB_RXD0);	rt_hw_interrupt_install(INTUART0, rt_serial_isr, RT_NULL);	rt_hw_interrupt_umask(INTUART0);}#endif/*@}*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -