Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wwsmg1
rt-thread
提交
1549b7db
R
rt-thread
项目概览
wwsmg1
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1549b7db
编写于
3月 23, 2013
作者:
wuyangyong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update LPC214X: Modify the interrupt interface implementations.
上级
eab20a99
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
80 addition
and
54 deletion
+80
-54
bsp/lpc2148/drivers/board.c
bsp/lpc2148/drivers/board.c
+7
-7
bsp/lpc2148/drivers/serial.c
bsp/lpc2148/drivers/serial.c
+27
-23
libcpu/arm/lpc214x/cpuport.c
libcpu/arm/lpc214x/cpuport.c
+46
-24
未找到文件。
bsp/lpc2148/drivers/board.c
浏览文件 @
1549b7db
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
* This is the timer interrupt service routine.
* This is the timer interrupt service routine.
* @param vector the irq number for timer
* @param vector the irq number for timer
*/
*/
void
rt_hw_timer_handler
(
int
vector
)
void
rt_hw_timer_handler
(
int
vector
,
void
*
param
)
{
{
rt_tick_increase
();
rt_tick_increase
();
...
@@ -53,10 +53,10 @@ void rt_hw_console_output(const char* str)
...
@@ -53,10 +53,10 @@ void rt_hw_console_output(const char* str)
while
(
!
(
U0LSR
&
0x20
));
while
(
!
(
U0LSR
&
0x20
));
U0THR
=
'\r'
;
U0THR
=
'\r'
;
}
}
while
(
!
(
U0LSR
&
0x20
));
while
(
!
(
U0LSR
&
0x20
));
U0THR
=
*
str
;
U0THR
=
*
str
;
str
++
;
str
++
;
}
}
}
}
...
@@ -82,11 +82,11 @@ void rt_hw_console_init()
...
@@ -82,11 +82,11 @@ void rt_hw_console_init()
/**
/**
* This function will initial sam7x256 board.
* This function will initial sam7x256 board.
*/
*/
void
rt_hw_board_init
()
void
rt_hw_board_init
(
void
)
{
{
/* console init */
/* console init */
rt_hw_console_init
();
rt_hw_console_init
();
/* prescaler = 0*/
/* prescaler = 0*/
T0PR
=
0
;
T0PR
=
0
;
T0PC
=
0
;
T0PC
=
0
;
...
@@ -94,12 +94,12 @@ void rt_hw_board_init()
...
@@ -94,12 +94,12 @@ void rt_hw_board_init()
/* reset and enable MR0 interrupt */
/* reset and enable MR0 interrupt */
T0MCR
=
0x3
;
T0MCR
=
0x3
;
T0MR0
=
PCLK
/
RT_TICK_PER_SECOND
;
T0MR0
=
PCLK
/
RT_TICK_PER_SECOND
;
/* enable timer 0 */
/* enable timer 0 */
T0TCR
=
1
;
T0TCR
=
1
;
/* install timer handler */
/* install timer handler */
rt_hw_interrupt_install
(
TIMER0_INT
,
rt_hw_timer_handler
,
RT_NULL
);
rt_hw_interrupt_install
(
TIMER0_INT
,
rt_hw_timer_handler
,
RT_NULL
,
"TIMER0"
);
rt_hw_interrupt_umask
(
TIMER0_INT
);
rt_hw_interrupt_umask
(
TIMER0_INT
);
}
}
...
...
bsp/lpc2148/drivers/serial.c
浏览文件 @
1549b7db
...
@@ -69,7 +69,7 @@ void rt_hw_uart_isr(struct rt_lpcserial* lpc_serial)
...
@@ -69,7 +69,7 @@ void rt_hw_uart_isr(struct rt_lpcserial* lpc_serial)
UNUSED
rt_uint32_t
iir
;
UNUSED
rt_uint32_t
iir
;
RT_ASSERT
(
lpc_serial
!=
RT_NULL
)
RT_ASSERT
(
lpc_serial
!=
RT_NULL
)
if
(
UART_LSR
(
lpc_serial
->
hw_base
)
&
0x01
)
if
(
UART_LSR
(
lpc_serial
->
hw_base
)
&
0x01
)
{
{
rt_base_t
level
;
rt_base_t
level
;
...
@@ -80,12 +80,12 @@ void rt_hw_uart_isr(struct rt_lpcserial* lpc_serial)
...
@@ -80,12 +80,12 @@ void rt_hw_uart_isr(struct rt_lpcserial* lpc_serial)
level
=
rt_hw_interrupt_disable
();
level
=
rt_hw_interrupt_disable
();
/* read character */
/* read character */
lpc_serial
->
rx_buffer
[
lpc_serial
->
save_index
]
=
lpc_serial
->
rx_buffer
[
lpc_serial
->
save_index
]
=
UART_RBR
(
lpc_serial
->
hw_base
);
UART_RBR
(
lpc_serial
->
hw_base
);
lpc_serial
->
save_index
++
;
lpc_serial
->
save_index
++
;
if
(
lpc_serial
->
save_index
>=
RT_UART_RX_BUFFER_SIZE
)
if
(
lpc_serial
->
save_index
>=
RT_UART_RX_BUFFER_SIZE
)
lpc_serial
->
save_index
=
0
;
lpc_serial
->
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
(
lpc_serial
->
save_index
==
lpc_serial
->
read_index
)
if
(
lpc_serial
->
save_index
==
lpc_serial
->
read_index
)
{
{
...
@@ -113,7 +113,7 @@ void rt_hw_uart_isr(struct rt_lpcserial* lpc_serial)
...
@@ -113,7 +113,7 @@ void rt_hw_uart_isr(struct rt_lpcserial* lpc_serial)
}
}
#ifdef RT_USING_UART1
#ifdef RT_USING_UART1
void
rt_hw_uart_isr_1
(
int
irqno
)
void
rt_hw_uart_isr_1
(
int
irqno
,
void
*
param
)
{
{
/* get lpc serial device */
/* get lpc serial device */
rt_hw_uart_isr
(
&
serial1
);
rt_hw_uart_isr
(
&
serial1
);
...
@@ -121,7 +121,7 @@ void rt_hw_uart_isr_1(int irqno)
...
@@ -121,7 +121,7 @@ void rt_hw_uart_isr_1(int irqno)
#endif
#endif
#ifdef RT_USING_UART2
#ifdef RT_USING_UART2
void
rt_hw_uart_isr_2
(
int
irqno
)
void
rt_hw_uart_isr_2
(
int
irqno
,
void
*
param
)
{
{
/* get lpc serial device */
/* get lpc serial device */
rt_hw_uart_isr
(
&
serial2
);
rt_hw_uart_isr
(
&
serial2
);
...
@@ -153,13 +153,15 @@ static rt_err_t rt_serial_open(rt_device_t dev, rt_uint16_t oflag)
...
@@ -153,13 +153,15 @@ static rt_err_t rt_serial_open(rt_device_t dev, rt_uint16_t oflag)
if
(
lpc_serial
->
irqno
==
UART0_INT
)
if
(
lpc_serial
->
irqno
==
UART0_INT
)
{
{
#ifdef RT_USING_UART1
#ifdef RT_USING_UART1
rt_hw_interrupt_install
(
lpc_serial
->
irqno
,
rt_hw_uart_isr_1
,
RT_NULL
);
rt_hw_interrupt_install
(
lpc_serial
->
irqno
,
rt_hw_uart_isr_1
,
&
serial1
,
"UART1"
);
#endif
#endif
}
}
else
else
{
{
#ifdef RT_USING_UART2
#ifdef RT_USING_UART2
rt_hw_interrupt_install
(
lpc_serial
->
irqno
,
rt_hw_uart_isr_2
,
RT_NULL
);
rt_hw_interrupt_install
(
lpc_serial
->
irqno
,
rt_hw_uart_isr_2
,
&
serial2
,
"UART2"
);
#endif
#endif
}
}
...
@@ -173,7 +175,7 @@ static rt_err_t rt_serial_close(rt_device_t dev)
...
@@ -173,7 +175,7 @@ static rt_err_t rt_serial_close(rt_device_t dev)
{
{
struct
rt_lpcserial
*
lpc_serial
;
struct
rt_lpcserial
*
lpc_serial
;
lpc_serial
=
(
struct
rt_lpcserial
*
)
dev
;
lpc_serial
=
(
struct
rt_lpcserial
*
)
dev
;
RT_ASSERT
(
lpc_serial
!=
RT_NULL
);
RT_ASSERT
(
lpc_serial
!=
RT_NULL
);
if
(
dev
->
flag
&
RT_DEVICE_FLAG_INT_RX
)
if
(
dev
->
flag
&
RT_DEVICE_FLAG_INT_RX
)
...
@@ -244,7 +246,7 @@ static rt_size_t rt_serial_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_
...
@@ -244,7 +246,7 @@ static rt_size_t rt_serial_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_
{
{
/* Read Character */
/* Read Character */
*
ptr
=
UART_RBR
(
lpc_serial
->
hw_base
);
*
ptr
=
UART_RBR
(
lpc_serial
->
hw_base
);
ptr
++
;
ptr
++
;
size
--
;
size
--
;
}
}
...
@@ -271,7 +273,7 @@ static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void* buff
...
@@ -271,7 +273,7 @@ static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void* buff
/* polling write */
/* polling write */
ptr
=
(
char
*
)
buffer
;
ptr
=
(
char
*
)
buffer
;
if
(
dev
->
flag
&
RT_DEVICE_FLAG_STREAM
)
if
(
dev
->
flag
&
RT_DEVICE_FLAG_STREAM
)
{
{
/* stream mode */
/* stream mode */
...
@@ -285,7 +287,7 @@ static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void* buff
...
@@ -285,7 +287,7 @@ static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void* buff
while
(
!
(
UART_LSR
(
lpc_serial
->
hw_base
)
&
0x20
));
while
(
!
(
UART_LSR
(
lpc_serial
->
hw_base
)
&
0x20
));
UART_THR
(
lpc_serial
->
hw_base
)
=
*
ptr
;
UART_THR
(
lpc_serial
->
hw_base
)
=
*
ptr
;
ptr
++
;
ptr
++
;
size
--
;
size
--
;
}
}
...
@@ -296,37 +298,37 @@ static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void* buff
...
@@ -296,37 +298,37 @@ static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void* buff
{
{
while
(
!
(
UART_LSR
(
lpc_serial
->
hw_base
)
&
0x20
));
while
(
!
(
UART_LSR
(
lpc_serial
->
hw_base
)
&
0x20
));
UART_THR
(
lpc_serial
->
hw_base
)
=
*
ptr
;
UART_THR
(
lpc_serial
->
hw_base
)
=
*
ptr
;
ptr
++
;
ptr
++
;
size
--
;
size
--
;
}
}
}
}
return
(
rt_size_t
)
ptr
-
(
rt_size_t
)
buffer
;
return
(
rt_size_t
)
ptr
-
(
rt_size_t
)
buffer
;
}
}
void
rt_hw_serial_init
(
void
)
void
rt_hw_serial_init
(
void
)
{
{
struct
rt_lpcserial
*
lpc_serial
;
struct
rt_lpcserial
*
lpc_serial
;
#ifdef RT_USING_UART1
#ifdef RT_USING_UART1
lpc_serial
=
&
serial1
;
lpc_serial
=
&
serial1
;
lpc_serial
->
parent
.
type
=
RT_Device_Class_Char
;
lpc_serial
->
parent
.
type
=
RT_Device_Class_Char
;
lpc_serial
->
hw_base
=
0xE000C000
;
lpc_serial
->
hw_base
=
0xE000C000
;
lpc_serial
->
baudrate
=
115200
;
lpc_serial
->
baudrate
=
115200
;
lpc_serial
->
irqno
=
UART0_INT
;
lpc_serial
->
irqno
=
UART0_INT
;
rt_memset
(
lpc_serial
->
rx_buffer
,
0
,
sizeof
(
lpc_serial
->
rx_buffer
));
rt_memset
(
lpc_serial
->
rx_buffer
,
0
,
sizeof
(
lpc_serial
->
rx_buffer
));
lpc_serial
->
read_index
=
lpc_serial
->
save_index
=
0
;
lpc_serial
->
read_index
=
lpc_serial
->
save_index
=
0
;
/* Enable UART0 RxD and TxD pins */
/* Enable UART0 RxD and TxD pins */
PINSEL0
|=
0x05
;
PINSEL0
|=
0x05
;
/* 8 bits, no Parity, 1 Stop bit */
/* 8 bits, no Parity, 1 Stop bit */
UART_LCR
(
lpc_serial
->
hw_base
)
=
0x83
;
UART_LCR
(
lpc_serial
->
hw_base
)
=
0x83
;
/* Setup Baudrate */
/* Setup Baudrate */
UART_DLL
(
lpc_serial
->
hw_base
)
=
(
PCLK
/
16
/
lpc_serial
->
baudrate
)
&
0xFF
;
UART_DLL
(
lpc_serial
->
hw_base
)
=
(
PCLK
/
16
/
lpc_serial
->
baudrate
)
&
0xFF
;
UART_DLM
(
lpc_serial
->
hw_base
)
=
((
PCLK
/
16
/
lpc_serial
->
baudrate
)
>>
8
)
&
0xFF
;
UART_DLM
(
lpc_serial
->
hw_base
)
=
((
PCLK
/
16
/
lpc_serial
->
baudrate
)
>>
8
)
&
0xFF
;
...
@@ -334,6 +336,7 @@ void rt_hw_serial_init(void)
...
@@ -334,6 +336,7 @@ void rt_hw_serial_init(void)
/* DLAB = 0 */
/* DLAB = 0 */
UART_LCR
(
lpc_serial
->
hw_base
)
=
0x03
;
UART_LCR
(
lpc_serial
->
hw_base
)
=
0x03
;
lpc_serial
->
parent
.
type
=
RT_Device_Class_Char
;
lpc_serial
->
parent
.
init
=
rt_serial_init
;
lpc_serial
->
parent
.
init
=
rt_serial_init
;
lpc_serial
->
parent
.
open
=
rt_serial_open
;
lpc_serial
->
parent
.
open
=
rt_serial_open
;
lpc_serial
->
parent
.
close
=
rt_serial_close
;
lpc_serial
->
parent
.
close
=
rt_serial_close
;
...
@@ -342,13 +345,13 @@ void rt_hw_serial_init(void)
...
@@ -342,13 +345,13 @@ void rt_hw_serial_init(void)
lpc_serial
->
parent
.
control
=
rt_serial_control
;
lpc_serial
->
parent
.
control
=
rt_serial_control
;
lpc_serial
->
parent
.
user_data
=
RT_NULL
;
lpc_serial
->
parent
.
user_data
=
RT_NULL
;
rt_device_register
(
&
lpc_serial
->
parent
,
rt_device_register
(
&
lpc_serial
->
parent
,
"uart1"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
);
"uart1"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
);
#endif
#endif
#ifdef RT_USING_UART2
#ifdef RT_USING_UART2
lpc_serial
=
&
serial2
;
lpc_serial
=
&
serial2
;
lpc_serial
->
parent
.
type
=
RT_Device_Class_Char
;
lpc_serial
->
parent
.
type
=
RT_Device_Class_Char
;
lpc_serial
->
hw_base
=
0xE0010000
;
lpc_serial
->
hw_base
=
0xE0010000
;
...
@@ -363,7 +366,7 @@ void rt_hw_serial_init(void)
...
@@ -363,7 +366,7 @@ void rt_hw_serial_init(void)
/* 8 bits, no Parity, 1 Stop bit */
/* 8 bits, no Parity, 1 Stop bit */
UART_LCR
(
lpc_serial
->
hw_base
)
=
0x83
;
UART_LCR
(
lpc_serial
->
hw_base
)
=
0x83
;
/* Setup Baudrate */
/* Setup Baudrate */
UART_DLL
(
lpc_serial
->
hw_base
)
=
(
PCLK
/
16
/
lpc_serial
->
baudrate
)
&
0xFF
;
UART_DLL
(
lpc_serial
->
hw_base
)
=
(
PCLK
/
16
/
lpc_serial
->
baudrate
)
&
0xFF
;
UART_DLM
(
lpc_serial
->
hw_base
)
=
((
PCLK
/
16
/
lpc_serial
->
baudrate
)
>>
8
)
&
0xFF
;
UART_DLM
(
lpc_serial
->
hw_base
)
=
((
PCLK
/
16
/
lpc_serial
->
baudrate
)
>>
8
)
&
0xFF
;
...
@@ -371,6 +374,7 @@ void rt_hw_serial_init(void)
...
@@ -371,6 +374,7 @@ void rt_hw_serial_init(void)
/* DLAB = 0 */
/* DLAB = 0 */
UART_LCR
(
lpc_serial
->
hw_base
)
=
0x03
;
UART_LCR
(
lpc_serial
->
hw_base
)
=
0x03
;
lpc_serial
->
parent
.
type
=
RT_Device_Class_Char
;
lpc_serial
->
parent
.
init
=
rt_serial_init
;
lpc_serial
->
parent
.
init
=
rt_serial_init
;
lpc_serial
->
parent
.
open
=
rt_serial_open
;
lpc_serial
->
parent
.
open
=
rt_serial_open
;
lpc_serial
->
parent
.
close
=
rt_serial_close
;
lpc_serial
->
parent
.
close
=
rt_serial_close
;
...
@@ -379,7 +383,7 @@ void rt_hw_serial_init(void)
...
@@ -379,7 +383,7 @@ void rt_hw_serial_init(void)
lpc_serial
->
parent
.
control
=
rt_serial_control
;
lpc_serial
->
parent
.
control
=
rt_serial_control
;
lpc_serial
->
parent
.
user_data
=
RT_NULL
;
lpc_serial
->
parent
.
user_data
=
RT_NULL
;
rt_device_register
(
&
lpc_serial
->
parent
,
rt_device_register
(
&
lpc_serial
->
parent
,
"uart2"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
);
"uart2"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
);
#endif
#endif
}
}
...
...
libcpu/arm/lpc214x/cpuport.c
浏览文件 @
1549b7db
...
@@ -10,9 +10,11 @@
...
@@ -10,9 +10,11 @@
* Change Logs:
* Change Logs:
* Date Author Notes
* Date Author Notes
* 2011-06-15 aozima the first version for lpc214x
* 2011-06-15 aozima the first version for lpc214x
* 2013-03-29 aozima Modify the interrupt interface implementations.
*/
*/
#include <rtthread.h>
#include <rtthread.h>
#include <rthw.h>
#include "lpc214x.h"
#include "lpc214x.h"
#define MAX_HANDLERS 32
#define MAX_HANDLERS 32
...
@@ -20,6 +22,9 @@
...
@@ -20,6 +22,9 @@
extern
rt_uint32_t
rt_interrupt_nest
;
extern
rt_uint32_t
rt_interrupt_nest
;
/* exception and interrupt handler table */
struct
rt_irq_desc
irq_desc
[
MAX_HANDLERS
];
/**
/**
* @addtogroup LPC214x
* @addtogroup LPC214x
*/
*/
...
@@ -71,7 +76,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
...
@@ -71,7 +76,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
rt_uint32_t
rt_interrupt_from_thread
,
rt_interrupt_to_thread
;
rt_uint32_t
rt_interrupt_from_thread
,
rt_interrupt_to_thread
;
rt_uint32_t
rt_thread_switch_interrupt_flag
;
rt_uint32_t
rt_thread_switch_interrupt_flag
;
void
rt_hw_interrupt_handler
(
int
vector
)
void
rt_hw_interrupt_handler
(
int
vector
,
void
*
param
)
{
{
rt_kprintf
(
"Unhandled interrupt %d occured!!!
\n
"
,
vector
);
rt_kprintf
(
"Unhandled interrupt %d occured!!!
\n
"
,
vector
);
}
}
...
@@ -79,7 +84,7 @@ void rt_hw_interrupt_handler(int vector)
...
@@ -79,7 +84,7 @@ void rt_hw_interrupt_handler(int vector)
/**
/**
* This function will initialize hardware interrupt
* This function will initialize hardware interrupt
*/
*/
void
rt_hw_interrupt_init
()
void
rt_hw_interrupt_init
(
void
)
{
{
rt_base_t
index
;
rt_base_t
index
;
rt_uint32_t
*
vect_addr
,
*
vect_ctl
;
rt_uint32_t
*
vect_addr
,
*
vect_ctl
;
...
@@ -90,12 +95,15 @@ void rt_hw_interrupt_init()
...
@@ -90,12 +95,15 @@ void rt_hw_interrupt_init()
/* set all to IRQ */
/* set all to IRQ */
VICIntSelect
=
0
;
VICIntSelect
=
0
;
rt_memset
(
irq_desc
,
0x00
,
sizeof
(
irq_desc
));
for
(
index
=
0
;
index
<
MAX_HANDLERS
;
index
++
)
for
(
index
=
0
;
index
<
MAX_HANDLERS
;
index
++
)
{
{
irq_desc
[
index
].
handler
=
rt_hw_interrupt_handler
;
vect_addr
=
(
rt_uint32_t
*
)(
VIC_BASE_ADDR
+
0x100
+
(
index
<<
2
));
vect_addr
=
(
rt_uint32_t
*
)(
VIC_BASE_ADDR
+
0x100
+
(
index
<<
2
));
vect_ctl
=
(
rt_uint32_t
*
)(
VIC_BASE_ADDR
+
0x200
+
(
index
<<
2
));
vect_ctl
=
(
rt_uint32_t
*
)(
VIC_BASE_ADDR
+
0x200
+
(
index
<<
2
));
*
vect_addr
=
(
rt_uint32_t
)
rt_hw_interrupt_handler
;
*
vect_addr
=
(
rt_uint32_t
)
&
irq_desc
[
index
]
;
*
vect_ctl
=
0xF
;
*
vect_ctl
=
0xF
;
}
}
...
@@ -127,30 +135,39 @@ void rt_hw_interrupt_umask(int vector)
...
@@ -127,30 +135,39 @@ void rt_hw_interrupt_umask(int vector)
/**
/**
* This function will install a interrupt service routine to a interrupt.
* This function will install a interrupt service routine to a interrupt.
* @param vector the interrupt number
* @param vector the interrupt number
* @param new_handler the interrupt service routine to be installed
* @param handler the interrupt service routine to be installed
* @param old_handler the old interrupt service routine
* @param param the interrupt service function parameter
* @param name the interrupt name
* @return old handler
*/
*/
void
rt_hw_interrupt_install
(
int
vector
,
rt_isr_handler_t
new_handler
,
rt_isr_handler_t
*
old_handler
)
rt_isr_handler_t
rt_hw_interrupt_install
(
int
vector
,
rt_isr_handler_t
handler
,
void
*
param
,
char
*
name
)
{
{
if
(
vector
>=
0
&&
vector
<
MAX_HANDLERS
)
rt_isr_handler_t
old_handler
=
RT_NULL
;
{
/* get VIC address */
rt_uint32_t
*
vect_addr
=
(
rt_uint32_t
*
)(
VIC_BASE_ADDR
+
0x100
+
(
vector
<<
2
));
rt_uint32_t
*
vect_ctl
=
(
rt_uint32_t
*
)(
VIC_BASE_ADDR
+
0x200
+
(
vector
<<
2
));
/* assign IRQ slot and enable this slot */
if
(
vector
>=
0
&&
vector
<
MAX_HANDLERS
)
*
vect_ctl
=
0x20
|
(
vector
&
0x1F
);
{
rt_uint32_t
*
vect_ctl
=
(
rt_uint32_t
*
)(
VIC_BASE_ADDR
+
0x200
+
(
vector
<<
2
));
if
(
old_handler
!=
RT_NULL
)
*
old_handler
=
(
rt_isr_handler_t
)
*
vect_addr
;
/* assign IRQ slot and enable this slot */
if
(
new_handler
!=
RT_NULL
)
*
vect_addr
=
(
rt_uint32_t
)
new_handler
;
*
vect_ctl
=
0x20
|
(
vector
&
0x1F
);
}
old_handler
=
irq_desc
[
vector
].
handler
;
if
(
handler
!=
RT_NULL
)
{
irq_desc
[
vector
].
handler
=
handler
;
irq_desc
[
vector
].
param
=
param
;
}
}
return
old_handler
;
}
}
/**
/**
* this function will reset CPU
* this function will reset CPU
*
*
*/
*/
void
rt_hw_cpu_reset
()
void
rt_hw_cpu_reset
(
void
)
{
{
}
}
...
@@ -165,18 +182,23 @@ void rt_hw_cpu_shutdown()
...
@@ -165,18 +182,23 @@ void rt_hw_cpu_shutdown()
while
(
1
);
while
(
1
);
}
}
void
rt_hw_trap_irq
()
void
rt_hw_trap_irq
(
void
)
{
{
rt_isr_handler_t
isr_func
;
int
irqno
;
struct
rt_irq_desc
*
irq
;
extern
struct
rt_irq_desc
irq_desc
[];
irq
=
(
struct
rt_irq_desc
*
)
VICVectAddr
;
irqno
=
((
rt_uint32_t
)
irq
-
(
rt_uint32_t
)
&
irq_desc
[
0
])
/
sizeof
(
struct
rt_irq_desc
);
isr_func
=
(
rt_isr_handler_t
)
VICVectAddr
;
/* invoke isr */
i
sr_func
(
0
);
i
rq
->
handler
(
irqno
,
irq
->
param
);
/* acknowledge Interrupt */
/* acknowledge Interrupt */
// VICVectAddr = 0;
// VICVectAddr = 0;
}
}
void
rt_hw_trap_fiq
()
void
rt_hw_trap_fiq
(
void
)
{
{
rt_kprintf
(
"fast interrupt request
\n
"
);
rt_kprintf
(
"fast interrupt request
\n
"
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录