提交 cf52e574 编写于 作者: wuyangyong's avatar wuyangyong

update pic32ethernet

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1684 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 c41b9c29
......@@ -63,7 +63,7 @@ static void rt_hw_timer_handler(void)
}
/**
* This function will initial FM3 Easy Kit board.
* This function will initial board.
*/
void rt_hw_board_init()
{
......@@ -73,7 +73,11 @@ void rt_hw_board_init()
// The PBDIV value is already set via the pragma FPBDIV option above.
SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);
rt_hw_console_init();
/* use DBPRINTF */
/* rt_hw_console_init(); */
rt_hw_usart_init();
rt_console_set_device("uart1");
rt_hw_show_info();
......@@ -94,9 +98,6 @@ void rt_hw_board_init()
/* Setup the software interrupt. */
mConfigIntCoreSW0( CSW_INT_ON | CSW_INT_PRIOR_1 | CSW_INT_SUB_PRIOR_0 );
// configure PORTD.RD0 = output,Toggle in CoreSW0Handler.
mPORTDSetPinsDigitalOut(BIT_0);
}
void __ISR(_TIMER_1_VECTOR, ipl2) Timer1Handler(void)
......@@ -106,9 +107,6 @@ void __ISR(_TIMER_1_VECTOR, ipl2) Timer1Handler(void)
// .. things to do
rt_hw_timer_handler();
// // .. in this case, toggle the LED
// mPORTDToggleBits(BIT_1);
}
//void __ISR(_CORE_TIMER_VECTOR, ipl2) CoreTimerHandler(void)
......@@ -121,9 +119,6 @@ void __ISR(_TIMER_1_VECTOR, ipl2) Timer1Handler(void)
//
// // update the period
// UpdateCoreTimer(CORE_TICK_RATE);
//
// // .. Toggle the LED
// mPORTDToggleBits(BIT_1);
//}
......
/*************************************************************************
* Processor-specific object file. Contains SFR definitions.
*************************************************************************/
INPUT("processor.o")
/*************************************************************************
* For interrupt vector handling
*************************************************************************/
PROVIDE(_vector_spacing = 0x00000001);
_ebase_address = 0x9FC01000;
/*************************************************************************
* Memory Address Equates
*************************************************************************/
_RESET_ADDR = 0xBFC00000;
_BEV_EXCPT_ADDR = 0xBFC00380;
_DBG_EXCPT_ADDR = 0xBFC00480;
_DBG_CODE_ADDR = 0xBFC02000;
_GEN_EXCPT_ADDR = _ebase_address + 0x180;
/*************************************************************************
* Memory Regions
*
* Memory regions without attributes cannot be used for orphaned sections.
* Only sections specifically assigned to these regions can be allocated
* into these regions.
*************************************************************************/
MEMORY
{
kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = 0x80000
kseg0_boot_mem : ORIGIN = 0x9FC00490, LENGTH = 0x970
exception_mem : ORIGIN = 0x9FC01000, LENGTH = 0x1000
kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0x490
debug_exec_mem : ORIGIN = 0xBFC02000, LENGTH = 0xFF0
config3 : ORIGIN = 0xBFC02FF0, LENGTH = 0x4
config2 : ORIGIN = 0xBFC02FF4, LENGTH = 0x4
config1 : ORIGIN = 0xBFC02FF8, LENGTH = 0x4
config0 : ORIGIN = 0xBFC02FFC, LENGTH = 0x4
kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x20000
sfrs : ORIGIN = 0xBF800000, LENGTH = 0x100000
configsfrs : ORIGIN = 0xBFC02FF0, LENGTH = 0x10
}
SECTIONS
{
.config_BFC02FF0 : {
KEEP(*(.config_BFC02FF0))
} > config3
.config_BFC02FF4 : {
KEEP(*(.config_BFC02FF4))
} > config2
.config_BFC02FF8 : {
KEEP(*(.config_BFC02FF8))
} > config1
.config_BFC02FFC : {
KEEP(*(.config_BFC02FFC))
} > config0
.text :
{
__fsymtab_start = .;
KEEP(*(FSymTab))
__fsymtab_end = .;
__vsymtab_start = .;
KEEP(*(VSymTab))
__vsymtab_end = .;
} > kseg0_program_mem
}
\ No newline at end of file
......@@ -28,10 +28,343 @@
<Unit filename="console.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="pic32_eth.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="pic32_eth.h" />
<Unit filename="rtconfig.h" />
<Unit filename="startup.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="uart.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="uart.h" />
<Unit filename="..\..\components\finsh\cmd.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\finsh\finsh.h" />
<Unit filename="..\..\components\finsh\finsh_compiler.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\finsh\finsh_error.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\finsh\finsh_error.h" />
<Unit filename="..\..\components\finsh\finsh_heap.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\finsh\finsh_heap.h" />
<Unit filename="..\..\components\finsh\finsh_init.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\finsh\finsh_node.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\finsh\finsh_node.h" />
<Unit filename="..\..\components\finsh\finsh_ops.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\finsh\finsh_ops.h" />
<Unit filename="..\..\components\finsh\finsh_parser.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\finsh\finsh_parser.h" />
<Unit filename="..\..\components\finsh\finsh_token.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\finsh\finsh_token.h" />
<Unit filename="..\..\components\finsh\finsh_var.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\finsh\finsh_var.h" />
<Unit filename="..\..\components\finsh\finsh_vm.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\finsh\finsh_vm.h" />
<Unit filename="..\..\components\finsh\shell.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\finsh\shell.h" />
<Unit filename="..\..\components\finsh\symbol.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\apps\chargen.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\apps\ftpd.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\apps\netio.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\apps\ping.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\apps\sntp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\apps\tcpecho.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\apps\tftp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\apps\udpecho.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\api\api_lib.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\api\api_msg.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\api\err.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\api\netbuf.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\api\netdb.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\api\netifapi.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\api\sockets.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\api\tcpip.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\arch\include\arch\bpstruct.h" />
<Unit filename="..\..\components\net\lwip\src\arch\include\arch\cc.h" />
<Unit filename="..\..\components\net\lwip\src\arch\include\arch\cpu.h" />
<Unit filename="..\..\components\net\lwip\src\arch\include\arch\epstruct.h" />
<Unit filename="..\..\components\net\lwip\src\arch\include\arch\init.h" />
<Unit filename="..\..\components\net\lwip\src\arch\include\arch\lib.h" />
<Unit filename="..\..\components\net\lwip\src\arch\include\arch\perf.h" />
<Unit filename="..\..\components\net\lwip\src\arch\include\arch\sys_arch.h" />
<Unit filename="..\..\components\net\lwip\src\arch\include\arch\sys_arch_init.h" />
<Unit filename="..\..\components\net\lwip\src\arch\sys_arch.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\arch\sys_arch_init.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\dhcp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\dns.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\init.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\ipv4\autoip.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\ipv4\icmp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\ipv4\igmp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\ipv4\inet.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\ipv4\inet_chksum.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\ipv4\ip.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\ipv4\ip_addr.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\ipv4\ip_frag.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\ipv6\icmp6.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\ipv6\inet6.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\ipv6\ip6.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\ipv6\ip6_addr.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\mem.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\memp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\netif.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\pbuf.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\raw.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\snmp\asn1_dec.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\snmp\asn1_enc.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\snmp\mib2.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\snmp\mib_structs.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\snmp\msg_in.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\snmp\msg_out.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\stats.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\sys.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\tcp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\tcp_in.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\tcp_out.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\core\udp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\include\ipv4\lwip\autoip.h" />
<Unit filename="..\..\components\net\lwip\src\include\ipv4\lwip\icmp.h" />
<Unit filename="..\..\components\net\lwip\src\include\ipv4\lwip\igmp.h" />
<Unit filename="..\..\components\net\lwip\src\include\ipv4\lwip\inet.h" />
<Unit filename="..\..\components\net\lwip\src\include\ipv4\lwip\inet_chksum.h" />
<Unit filename="..\..\components\net\lwip\src\include\ipv4\lwip\ip.h" />
<Unit filename="..\..\components\net\lwip\src\include\ipv4\lwip\ip_addr.h" />
<Unit filename="..\..\components\net\lwip\src\include\ipv4\lwip\ip_frag.h" />
<Unit filename="..\..\components\net\lwip\src\include\ipv6\lwip\icmp.h" />
<Unit filename="..\..\components\net\lwip\src\include\ipv6\lwip\inet.h" />
<Unit filename="..\..\components\net\lwip\src\include\ipv6\lwip\ip.h" />
<Unit filename="..\..\components\net\lwip\src\include\ipv6\lwip\ip_addr.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\api.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\api_msg.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\arch.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\debug.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\def.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\dhcp.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\dns.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\err.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\init.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\mem.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\memp.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\memp_std.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\netbuf.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\netdb.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\netif.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\netifapi.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\opt.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\pbuf.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\raw.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\sio.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\snmp.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\snmp_asn1.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\snmp_msg.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\snmp_structs.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\sockets.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\stats.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\sys.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\tcp.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\tcpip.h" />
<Unit filename="..\..\components\net\lwip\src\include\lwip\udp.h" />
<Unit filename="..\..\components\net\lwip\src\include\netif\etharp.h" />
<Unit filename="..\..\components\net\lwip\src\include\netif\ethernetif.h" />
<Unit filename="..\..\components\net\lwip\src\include\netif\loopif.h" />
<Unit filename="..\..\components\net\lwip\src\include\netif\ppp_oe.h" />
<Unit filename="..\..\components\net\lwip\src\include\netif\slipif.h" />
<Unit filename="..\..\components\net\lwip\src\lwipopts.h" />
<Unit filename="..\..\components\net\lwip\src\netif\etharp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\ethernetif.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\loopif.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\ppp\auth.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\ppp\auth.h" />
<Unit filename="..\..\components\net\lwip\src\netif\ppp\chap.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\ppp\chap.h" />
<Unit filename="..\..\components\net\lwip\src\netif\ppp\chpms.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\ppp\chpms.h" />
<Unit filename="..\..\components\net\lwip\src\netif\ppp\fsm.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\ppp\fsm.h" />
<Unit filename="..\..\components\net\lwip\src\netif\ppp\ipcp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\ppp\ipcp.h" />
<Unit filename="..\..\components\net\lwip\src\netif\ppp\lcp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\ppp\lcp.h" />
<Unit filename="..\..\components\net\lwip\src\netif\ppp\magic.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\ppp\magic.h" />
<Unit filename="..\..\components\net\lwip\src\netif\ppp\md5.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\ppp\md5.h" />
<Unit filename="..\..\components\net\lwip\src\netif\ppp\pap.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\ppp\pap.h" />
<Unit filename="..\..\components\net\lwip\src\netif\ppp\ppp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\ppp\ppp.h" />
<Unit filename="..\..\components\net\lwip\src\netif\ppp\ppp_oe.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\ppp\pppdebug.h" />
<Unit filename="..\..\components\net\lwip\src\netif\ppp\randm.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\ppp\randm.h" />
<Unit filename="..\..\components\net\lwip\src\netif\ppp\vj.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\ppp\vj.h" />
<Unit filename="..\..\components\net\lwip\src\netif\ppp\vjbsdhdr.h" />
<Unit filename="..\..\components\net\lwip\src\netif\skeleton.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\components\net\lwip\src\netif\skeleton.h" />
<Unit filename="..\..\components\net\lwip\src\netif\slipif.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\include\rtdef.h" />
<Unit filename="..\..\include\rthw.h" />
<Unit filename="..\..\include\rtm.h" />
......
......@@ -8,7 +8,7 @@ dir_src=
dir_bin=./obj
dir_tmp=./obj
dir_sin=
dir_inc=.;../../include
dir_inc=.;../../include;../../components/finsh
dir_lib=C:\Program Files\Microchip\MPLAB C32 Suite\lib;C:\Program Files\Microchip\MPLAB C32 Suite\pic32mx\lib
dir_lkr=
[CAT_FILTERS]
......@@ -18,7 +18,7 @@ filter_obj=*.o
filter_lib=*.a
filter_lkr=*.ld
[CAT_SUBFOLDERS]
subfolder_src=kernel;pic32
subfolder_src=finsh;kernel;pic32
subfolder_inc=
subfolder_obj=
subfolder_lib=
......@@ -46,7 +46,21 @@ file_018=pic32
file_019=pic32
file_020=.
file_021=pic32
file_022=.
file_022=finsh
file_023=finsh
file_024=finsh
file_025=finsh
file_026=finsh
file_027=finsh
file_028=finsh
file_029=finsh
file_030=finsh
file_031=finsh
file_032=finsh
file_033=finsh
file_034=finsh
file_035=.
file_036=.
[GENERATED_FILES]
file_000=no
file_001=no
......@@ -71,6 +85,20 @@ file_019=no
file_020=no
file_021=no
file_022=no
file_023=no
file_024=no
file_025=no
file_026=no
file_027=no
file_028=no
file_029=no
file_030=no
file_031=no
file_032=no
file_033=no
file_034=no
file_035=no
file_036=no
[OTHER_FILES]
file_000=no
file_001=no
......@@ -95,6 +123,20 @@ file_019=no
file_020=no
file_021=no
file_022=no
file_023=no
file_024=no
file_025=no
file_026=no
file_027=no
file_028=no
file_029=no
file_030=no
file_031=no
file_032=no
file_033=no
file_034=no
file_035=no
file_036=no
[FILE_INFO]
file_000=board.c
file_001=application.c
......@@ -118,13 +160,28 @@ file_018=..\..\libcpu\mips\pic32\context_gcc.S
file_019=..\..\libcpu\mips\pic32\stack.c
file_020=console.c
file_021=..\..\libcpu\mips\pic32\interrupt.c
file_022=rtconfig.h
file_022=..\..\components\finsh\finsh_node.c
file_023=..\..\components\finsh\finsh_ops.c
file_024=..\..\components\finsh\finsh_parser.c
file_025=..\..\components\finsh\finsh_token.c
file_026=..\..\components\finsh\finsh_var.c
file_027=..\..\components\finsh\finsh_vm.c
file_028=..\..\components\finsh\shell.c
file_029=..\..\components\finsh\symbol.c
file_030=..\..\components\finsh\cmd.c
file_031=..\..\components\finsh\finsh_compiler.c
file_032=..\..\components\finsh\finsh_error.c
file_033=..\..\components\finsh\finsh_heap.c
file_034=..\..\components\finsh\finsh_init.c
file_035=uart.c
file_036=rtconfig.h
[SUITE_INFO]
suite_guid={14495C23-81F8-43F3-8A44-859C583D7760}
suite_state=
[TOOL_SETTINGS]
TS{CB0AF4B8-4022-429D-8F99-8A56782B2C6D}=--gdwarf-2
TS{9C698E0A-CBC9-4EFF-AE7D-B569F93E7322}=-g -DPIC32_STARTER_KIT
TS{9C698E0A-CBC9-4EFF-AE7D-B569F93E7322}=-g -DPIC32_STARTER_KIT -G0
TS{9C698E0A-CBC9-4EFF-AE7D-B569F93E7322}_alt=yes
TS{77F59DA1-3C53-4677-AC5F-A03EB0125170}=-Map="$(BINDIR_)$(TARGETBASE).map" -o"$(BINDIR_)$(TARGETBASE).$(TARGETSUFFIX)"
TS{0396C0A1-9052-4E4F-8B84-EF0162B1B4E9}=
[INSTRUMENTED_TRACE]
......
......@@ -70,17 +70,13 @@
/* the buffer size of console*/
#define RT_CONSOLEBUF_SIZE 128
#define RT_USING_NEWLIB
//#define RT_USING_NEWLIB
/* SECTION: finsh, a C-Express shell */
//#define RT_USING_FINSH
#define RT_USING_FINSH
/* Using symbol table */
#define FINSH_USING_SYMTAB
#define FINSH_USING_DESCRIPTION
#define __fsymtab_start _alt_partition_FSymTab_start
#define __fsymtab_end _alt_partition_FSymTab_end
#define __vsymtab_start _alt_partition_VSymTab_start
#define __vsymtab_end _alt_partition_VSymTab_end
/* SECTION: device filesystem */
//#define RT_USING_DFS
......
......@@ -19,6 +19,11 @@
extern int _ramfunc_end;
#define PIC32_SRAM_END (0xA0000000+0x8000) //795F512L 512KB
#ifdef RT_USING_FINSH
extern void finsh_system_init(void);
extern void finsh_set_device(const char* device);
#endif
/**
* This function will startup RT-Thread RTOS.
*/
......@@ -71,13 +76,13 @@ void rtthread_startup(void)
/* init application */
rt_application_init();
//#ifdef RT_USING_FINSH
// /* init finsh */
// finsh_system_init();
//#ifdef RT_USING_DEVICE
// finsh_set_device("uart2");
//#endif
//#endif
#ifdef RT_USING_FINSH
/* init finsh */
finsh_system_init();
#ifdef RT_USING_DEVICE
finsh_set_device("uart1");
#endif
#endif
/* init timer thread */
rt_system_timer_thread_init();
......
#include <GenericTypeDefs.h>
#include <plib.h>
#include <rtthread.h>
#include "uart.h"
#define GetSystemClock() (80000000ul)
#define GetPeripheralClock() (GetSystemClock()/(1 << OSCCONbits.PBDIV))
#define GetInstructionClock() (GetSystemClock())
struct rt_uart_pic32
{
struct rt_device parent;
int uart; /* UART Module ID. */
/* buffer for reception */
rt_uint8_t read_index, save_index;
rt_uint8_t rx_buffer[RT_UART_RX_BUFFER_SIZE];
};
#ifdef RT_USING_UART1
static struct rt_uart_pic32 uart1_device;
#endif
#ifdef RT_USING_UART2
static struct rt_uart_pic32 uart2_device;
#endif
static rt_err_t rt_uart_init (rt_device_t dev)
{
struct rt_uart_pic32 *uart_device = (struct rt_uart_pic32*)dev;
UARTConfigure(uart_device->uart, UART_ENABLE_PINS_TX_RX_ONLY);
UARTSetFifoMode(uart_device->uart, UART_INTERRUPT_ON_TX_NOT_FULL | UART_INTERRUPT_ON_RX_NOT_EMPTY);
UARTSetLineControl(uart_device->uart, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1);
UARTSetDataRate(uart_device->uart, GetPeripheralClock(), 115200);
UARTEnable(uart_device->uart, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX));
// Configure UART RX Interrupt
INTEnable(INT_SOURCE_UART_RX(uart_device->uart), INT_ENABLED);
INTSetVectorPriority(INT_VECTOR_UART(uart_device->uart), INT_PRIORITY_LEVEL_2);
INTSetVectorSubPriority(INT_VECTOR_UART(uart_device->uart), INT_SUB_PRIORITY_LEVEL_0);
return RT_EOK;
}
static rt_err_t rt_uart_open(rt_device_t dev, rt_uint16_t oflag)
{
return RT_EOK;
}
static rt_err_t rt_uart_close(rt_device_t dev)
{
return RT_EOK;
}
static rt_size_t rt_uart_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size)
{
rt_uint8_t* ptr;
struct rt_uart_pic32 *uart_device = (struct rt_uart_pic32*)dev;
RT_ASSERT(uart_device != RT_NULL);
/* point to buffer */
ptr = (rt_uint8_t*) buffer;
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
{
while (size)
{
/* interrupt receive */
rt_base_t level;
/* disable interrupt */
level = rt_hw_interrupt_disable();
if (uart_device->read_index != uart_device->save_index)
{
*ptr = uart_device->rx_buffer[uart_device->read_index];
uart_device->read_index ++;
if (uart_device->read_index >= RT_UART_RX_BUFFER_SIZE)
uart_device->read_index = 0;
}
else
{
/* no data in rx buffer */
/* enable interrupt */
rt_hw_interrupt_enable(level);
break;
}
/* enable interrupt */
rt_hw_interrupt_enable(level);
ptr ++;
size --;
}
return (rt_uint32_t)ptr - (rt_uint32_t)buffer;
}
return 0;
}
static rt_size_t rt_uart_write(rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
{
struct rt_uart_pic32 *uart_device = (struct rt_uart_pic32*)dev;
char *ptr;
ptr = (char*)buffer;
if (dev->flag & RT_DEVICE_FLAG_STREAM)
{
/* stream mode */
while (size)
{
if (*ptr == '\n')
{
while(!UARTTransmitterIsReady(uart_device->uart));
UARTSendDataByte(uart_device->uart,'\r' );
while(!UARTTransmissionHasCompleted(uart_device->uart));
}
while(!UARTTransmitterIsReady(uart_device->uart));
UARTSendDataByte(uart_device->uart, *ptr);
while(!UARTTransmissionHasCompleted(uart_device->uart));
ptr ++;
size --;
}
}
else
{
while ( size != 0 )
{
while(!UARTTransmitterIsReady(uart_device->uart));
UARTSendDataByte(uart_device->uart, *ptr);
while(!UARTTransmissionHasCompleted(uart_device->uart));
ptr++;
size--;
}
}
return (rt_size_t) ptr - (rt_size_t) buffer;
}
#ifdef RT_USING_UART1
// UART 1 interrupt handler
// it is set at priority level 2
void __ISR(_UART1_VECTOR, ipl2) IntUART1Handler(void)
{
struct rt_uart_pic32 *uart_device = &uart1_device;
// Is this an RX interrupt?
if(INTGetFlag(INT_SOURCE_UART_RX(uart_device->uart)))
{
// Clear the RX interrupt Flag
INTClearFlag(INT_SOURCE_UART_RX(uart_device->uart));
/* Receive Data Available */
uart_device->rx_buffer[uart_device->save_index] = UARTGetDataByte(uart_device->uart);//UARTGetDataByte(UART1);
uart_device->save_index ++;
if (uart_device->save_index >= RT_UART_RX_BUFFER_SIZE)
uart_device->save_index = 0;
/* invoke callback */
if(uart_device->parent.rx_indicate != RT_NULL)
{
rt_size_t length;
if (uart_device->read_index > uart_device->save_index)
length = RT_UART_RX_BUFFER_SIZE - uart_device->read_index + uart_device->save_index;
else
length = uart_device->save_index - uart_device->read_index;
uart_device->parent.rx_indicate(&uart_device->parent, length);
}
// Clear the RX interrupt Flag
INTClearFlag(INT_SOURCE_UART_RX(uart_device->uart));
} // Is this an RX interrupt?
// We don't care about TX interrupt
if ( INTGetFlag(INT_SOURCE_UART_TX(uart_device->uart)) )
{
INTClearFlag(INT_SOURCE_UART_TX(uart_device->uart));
}
}
#endif
#ifdef RT_USING_UART2
// UART 2 interrupt handler
// it is set at priority level 2
void __ISR(_UART2_VECTOR, ipl2) IntUART2Handler(void)
{
struct rt_uart_pic32 *uart_device = &uart2_device;
// Is this an RX interrupt?
if(INTGetFlag(INT_SOURCE_UART_RX(uart_device->uart)))
{
// Clear the RX interrupt Flag
INTClearFlag(INT_SOURCE_UART_RX(uart_device->uart));
/* Receive Data Available */
uart_device->rx_buffer[uart_device->save_index] = UARTGetDataByte(uart_device->uart);//UARTGetDataByte(UART1);
uart_device->save_index ++;
if (uart_device->save_index >= RT_UART_RX_BUFFER_SIZE)
uart_device->save_index = 0;
/* invoke callback */
if(uart_device->parent.rx_indicate != RT_NULL)
{
rt_size_t length;
if (uart_device->read_index > uart_device->save_index)
length = RT_UART_RX_BUFFER_SIZE - uart_device->read_index + uart_device->save_index;
else
length = uart_device->save_index - uart_device->read_index;
uart_device->parent.rx_indicate(&uart_device->parent, length);
}
// Clear the RX interrupt Flag
INTClearFlag(INT_SOURCE_UART_RX(uart_device->uart));
} // Is this an RX interrupt?
// We don't care about TX interrupt
if ( INTGetFlag(INT_SOURCE_UART_TX(uart_device->uart)) )
{
INTClearFlag(INT_SOURCE_UART_TX(uart_device->uart));
}
}
#endif
void rt_hw_usart_init(void)
{
struct rt_uart_pic32 *uart_device;
#ifdef RT_USING_UART1
/* device initialization */
uart_device = &uart1_device;
rt_memset(uart_device,0,sizeof(struct rt_uart_pic32));
uart_device->uart = UART1;
uart_device->parent.type = RT_Device_Class_Char;
/* device interface */
uart_device->parent.init = rt_uart_init;
uart_device->parent.open = rt_uart_open;
uart_device->parent.close = rt_uart_close;
uart_device->parent.read = rt_uart_read;
uart_device->parent.write = rt_uart_write;
uart_device->parent.control = RT_NULL;
uart_device->parent.user_data = RT_NULL;
rt_device_register(&uart_device->parent,
"uart1", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_INT_RX);
#endif
#ifdef RT_USING_UART2
/* device initialization */
uart_device = &uart2_device;
rt_memset(uart_device,0,sizeof(struct rt_uart_pic32));
uart_device->uart = UART2;
uart_device->parent.type = RT_Device_Class_Char;
/* device interface */
uart_device->parent.init = rt_uart_init;
uart_device->parent.open = rt_uart_open;
uart_device->parent.close = rt_uart_close;
uart_device->parent.read = rt_uart_read;
uart_device->parent.write = rt_uart_write;
uart_device->parent.control = RT_NULL;
uart_device->parent.user_data = RT_NULL;
rt_device_register(&uart_device->parent,
"uart2", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_INT_RX);
#endif
}
#ifndef UART_H_INCLUDED
#define UART_H_INCLUDED
#define RT_UART_RX_BUFFER_SIZE 64
#define RT_USING_UART1
#define RT_USING_UART2
#endif // UART_H_INCLUDED
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册