提交 cc3c4fe6 编写于 作者: B Bernard Xiong

[bsp] code cleanup.

上级 a9f03fb4
......@@ -11,8 +11,8 @@
* Date Author Notes
* 2009-01-05 Bernard the first version
*/
#include <rtthread.h>
#ifdef RT_USING_FINSH
#include <finsh.h>
#include <shell.h>
......@@ -40,6 +40,5 @@ int rt_application_init()
if (tid != RT_NULL)
rt_thread_startup(tid);
return 0;
}
......@@ -24,8 +24,6 @@
#include <components.h>
#endif
/**
* This is the timer interrupt service routine.
*
......@@ -41,9 +39,6 @@ void SysTick_Handler(void)
rt_interrupt_leave();
}
/**
* This function will initial LPC54xx board.
*/
......@@ -68,29 +63,17 @@ void rt_hw_board_init()
rt_hw_uart_init();
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#if LPC_EXT_SDRAM == 1
lpc_sdram_hw_init();
mpu_init();
#endif
#ifdef RT_USING_COMPONENTS_INIT
/* initialization board with RT-Thread Components */
rt_components_board_init();
#endif
}
/* initialization for system heap */
int rt_hw_board_heap_init(void)
{
#ifdef RT_USING_HEAP
#if LPC_EXT_SDRAM
#include "drv_sram.h"
rt_system_heap_init((void *)LPC_EXT_SDRAM_BEGIN, (void *)LPC_EXT_SDRAM_END);
sram_init();
#else
rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
#endif
#endif
return 0;
......
......@@ -53,7 +53,6 @@ static rt_err_t rt_led_close(rt_device_t dev)
return RT_EOK;
}
static rt_size_t rt_led_read(rt_device_t dev, rt_off_t pos, void *buffer,
rt_size_t size)
{
......@@ -66,7 +65,6 @@ static rt_size_t rt_led_read(rt_device_t dev, rt_off_t pos, void *buffer,
for (index = 0; index < nr; index++)
{
//if ((LPC_GPIO->PIN[led.ctrl[pos + index].port]) & 1 << led.ctrl[pos + index].num)
if ((LPC_GPIO->B[0][led.ctrl[pos + index].num]))
{
*value = 0;
......@@ -80,8 +78,6 @@ static rt_size_t rt_led_read(rt_device_t dev, rt_off_t pos, void *buffer,
return index;
}
static rt_size_t rt_led_write(rt_device_t dev, rt_off_t pos,
const void *buffer, rt_size_t size)
{
......@@ -108,7 +104,6 @@ static rt_size_t rt_led_write(rt_device_t dev, rt_off_t pos,
return index;
}
static rt_err_t rt_led_control(rt_device_t dev, rt_uint8_t cmd, void *args)
{
return RT_EOK;
......@@ -134,8 +129,6 @@ int rt_led_hw_init(void)
return 0;
}
void Led_Control(rt_uint32_t Set_led, rt_uint32_t value)
{
if ( Set_led == 0 )
......@@ -191,10 +184,8 @@ void Led_Control(rt_uint32_t Set_led, rt_uint32_t value)
}
}
}
INIT_DEVICE_EXPORT(rt_led_hw_init);
#ifdef RT_USING_FINSH
#include <finsh.h>
void led_test(rt_uint32_t led_num, rt_uint32_t value)
......@@ -204,7 +195,3 @@ void led_test(rt_uint32_t led_num, rt_uint32_t value)
}
FINSH_FUNCTION_EXPORT(led_test, e.g: led_test(0, 100).)
#endif
......@@ -26,16 +26,12 @@ static int32_t _CalcErr(uint32_t n, uint32_t d, uint32_t *prev);
static ErrorCode_t _UART_CalcDiv(UART_BAUD_T *ub);
static void _UART_CalcMul(UART_BAUD_T *ub);
struct lpc_uart
{
LPC_USART_T *UART;
IRQn_Type UART_IRQn;
};
static rt_err_t lpc_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
{
struct lpc_uart *uart;
......@@ -79,11 +75,9 @@ static rt_err_t lpc_configure(struct rt_serial_device *serial, struct serial_con
uart->UART->BRG = (UART_cfg.div - 1) & 0xFFFF;
uart->UART->CFG = UART_CFG_ENABLE | (UART_cfg.cfg & ~UART_CFG_RES);
return RT_EOK;
}
static rt_err_t lpc_control(struct rt_serial_device *serial, int cmd, void *arg)
{
struct lpc_uart *uart;
......@@ -106,7 +100,6 @@ static rt_err_t lpc_control(struct rt_serial_device *serial, int cmd, void *arg)
return RT_EOK;
}
static int lpc_putc(struct rt_serial_device *serial, char c)
{
struct lpc_uart *uart;
......@@ -174,13 +167,11 @@ void UART0_IRQHandler(void)
rt_interrupt_leave();
}
void rt_hw_uart_init(void)
{
struct lpc_uart *uart;
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
uart = &uart0;
serial0.ops = &lpc_uart_ops;
......@@ -212,10 +203,6 @@ void rt_hw_uart_init(void)
/* Controls the clock for the Fractional Rate Generator used with the USARTs P57*/
LPC_ASYNC_SYSCON->ASYNCAPBCLKCTRLSET = (1 << 0x0F); /* Enable clock to Fractional divider */
/* preemption = 1, sub-priority = 1 */
NVIC_SetPriority(uart->UART_IRQn, ((0x01 << 3) | 0x01));
......@@ -243,8 +230,10 @@ static uint32_t _UART_DivClk(uint32_t pclk, uint32_t m)
static uint32_t _UART_GetHighDiv(uint32_t val, uint8_t strict)
{
int32_t i, max = strict ? 16 : 5;
for (i = 16; i >= max; i--) {
if (!(val % i)) {
for (i = 16; i >= max; i--)
{
if (!(val % i))
{
return i;
}
}
......
#ifndef __DRV_UART_H_
#define __DRV_UART_H_
void rt_hw_uart_init(void);
#endif /* __BOARD_H_ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册