2009-12-11 17:42:01 +08:00
|
|
|
/*
|
2021-04-09 10:52:34 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
2009-12-11 17:42:01 +08:00
|
|
|
*
|
2021-04-09 10:52:34 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2009-12-11 17:42:01 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2006-03-24 Bernard first implementation
|
|
|
|
* 2006-05-05 Bernard add DATA_COUNT definition
|
2010-10-19 17:20:21 +08:00
|
|
|
* 2006-10-05 Alsor.Z for s3c2410x porting
|
2021-04-09 10:52:34 +08:00
|
|
|
* 2007-11-20 Yi.Qiu add lcd,touch,console
|
2009-12-11 17:42:01 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include <rthw.h>
|
|
|
|
|
|
|
|
#include "board.h"
|
2009-12-27 18:58:45 +08:00
|
|
|
#include "led.h"
|
2009-12-11 17:42:01 +08:00
|
|
|
|
|
|
|
/**
|
2009-12-18 13:25:41 +08:00
|
|
|
* @addtogroup mini2440
|
2009-12-11 17:42:01 +08:00
|
|
|
*/
|
|
|
|
/*@{*/
|
|
|
|
|
2020-04-10 21:40:33 +08:00
|
|
|
#if defined(__CC_ARM)
|
|
|
|
extern int Image$$ER_ZI$$ZI$$Base;
|
|
|
|
extern int Image$$ER_ZI$$ZI$$Length;
|
|
|
|
extern int Image$$ER_ZI$$ZI$$Limit;
|
|
|
|
#elif (defined (__GNUC__))
|
|
|
|
rt_uint8_t _irq_stack_start[1024];
|
|
|
|
rt_uint8_t _fiq_stack_start[1024];
|
|
|
|
rt_uint8_t _undefined_stack_start[512];
|
|
|
|
rt_uint8_t _abort_stack_start[512];
|
2021-02-09 23:25:56 +08:00
|
|
|
rt_uint8_t _svc_stack_start[4096] RT_SECTION(".nobss");
|
2020-04-10 21:40:33 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__CC_ARM)
|
|
|
|
extern int Image$$RW_IRAM1$$ZI$$Limit;
|
|
|
|
#define HEAP_BEGIN ((void*)&Image$$RW_IRAM1$$ZI$$Limit)
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
extern int __bss_end;
|
|
|
|
#define HEAP_BEGIN (((void*)&__bss_end) + 0x1000)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define HEAP_END (void*)(0x33F00000)
|
|
|
|
|
|
|
|
|
2009-12-11 17:42:01 +08:00
|
|
|
extern rt_uint32_t PCLK, FCLK, HCLK, UCLK;
|
2009-12-25 20:20:04 +08:00
|
|
|
|
2009-12-25 18:38:56 +08:00
|
|
|
extern void rt_hw_clock_init(void);
|
2009-12-11 17:42:01 +08:00
|
|
|
extern void rt_hw_mmu_init(void);
|
|
|
|
|
|
|
|
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_clock(rt_uint8_t sdiv, rt_uint8_t pdiv, rt_uint8_t mdiv);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function will handle rtos timer
|
|
|
|
*/
|
2013-03-23 16:38:13 +08:00
|
|
|
static void rt_timer_handler(int vector, void *param)
|
2009-12-11 17:42:01 +08:00
|
|
|
{
|
2021-04-09 10:52:34 +08:00
|
|
|
rt_tick_increase();
|
2009-12-11 17:42:01 +08:00
|
|
|
}
|
|
|
|
|
2009-12-27 18:58:45 +08:00
|
|
|
/**
|
|
|
|
* This function will init timer4 for system ticks
|
|
|
|
*/
|
2013-03-23 16:38:13 +08:00
|
|
|
static void rt_hw_timer_init(void)
|
2009-12-27 18:58:45 +08:00
|
|
|
{
|
2021-04-09 10:52:34 +08:00
|
|
|
/* 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, "tick");
|
|
|
|
rt_hw_interrupt_umask(INTTIMER4);
|
2009-12-27 18:58:45 +08:00
|
|
|
|
|
|
|
/* start timer4, reload */
|
2021-04-09 10:52:34 +08:00
|
|
|
TCON = TCON & (~(0x0f<<20)) | (0x05<<20);
|
2009-12-27 18:58:45 +08:00
|
|
|
}
|
|
|
|
|
2009-12-11 17:42:01 +08:00
|
|
|
/**
|
|
|
|
* This function will init s3ceb2410 board
|
|
|
|
*/
|
2013-03-23 16:38:13 +08:00
|
|
|
void rt_hw_board_init(void)
|
2009-12-25 20:20:04 +08:00
|
|
|
{
|
2021-04-09 10:52:34 +08:00
|
|
|
rt_hw_cpu_icache_enable();
|
|
|
|
rt_hw_cpu_dcache_enable();
|
2020-04-10 21:40:33 +08:00
|
|
|
|
2021-04-09 10:52:34 +08:00
|
|
|
/* init hardware interrupt */
|
|
|
|
rt_hw_interrupt_init();
|
2020-04-10 21:40:33 +08:00
|
|
|
|
2021-04-09 10:52:34 +08:00
|
|
|
/* initialize the system clock */
|
|
|
|
rt_hw_clock_init();
|
2009-12-25 20:20:04 +08:00
|
|
|
|
2021-04-09 10:52:34 +08:00
|
|
|
/* Get the clock */
|
|
|
|
rt_hw_get_clock();
|
2009-12-11 17:42:01 +08:00
|
|
|
|
2021-04-09 10:52:34 +08:00
|
|
|
/* initialize led port */
|
|
|
|
rt_hw_led_init();
|
2009-12-27 18:58:45 +08:00
|
|
|
|
2021-04-09 10:52:34 +08:00
|
|
|
/* initialize mmu */
|
|
|
|
rt_hw_mmu_init();
|
2009-12-11 17:42:01 +08:00
|
|
|
|
2021-04-09 10:52:34 +08:00
|
|
|
/* initialize timer4 */
|
|
|
|
rt_hw_timer_init();
|
2020-04-10 21:40:33 +08:00
|
|
|
|
2021-04-09 10:52:34 +08:00
|
|
|
/* initialize system heap */
|
|
|
|
rt_system_heap_init(HEAP_BEGIN, HEAP_END);
|
2020-04-10 21:40:33 +08:00
|
|
|
|
2021-04-09 10:52:34 +08:00
|
|
|
rt_components_board_init();
|
2020-04-10 21:40:33 +08:00
|
|
|
|
2022-01-08 23:29:41 +08:00
|
|
|
#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
|
2021-04-09 10:52:34 +08:00
|
|
|
rt_console_set_device("uart0");
|
2020-04-10 21:40:33 +08:00
|
|
|
#endif
|
|
|
|
|
2009-12-11 17:42:01 +08:00
|
|
|
}
|
2021-02-12 02:37:30 +08:00
|
|
|
|
2009-12-11 17:42:01 +08:00
|
|
|
/*@}*/
|