Browse Source

update PIC32 example project

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1698 bbd45198-f89e-11dd-88c7-29a3b14d5316
wuyangyong 13 years ago
parent
commit
0f50919f30

+ 1 - 1
bsp/pic32ethernet/board.c

@@ -122,5 +122,5 @@ void __ISR(_TIMER_1_VECTOR, ipl2) Timer1Handler(void)
 //}
 //}
 
 
 
 
-void __ISR(_CORE_SOFTWARE_0_VECTOR, ipl2) CoreSW0Handler(void);
+void __ISR(_CORE_SOFTWARE_0_VECTOR, ipl1) CoreSW0Handler(void);
 
 

+ 3 - 2
bsp/pic32ethernet/project.cbp

@@ -18,6 +18,7 @@
 		</Build>
 		</Build>
 		<Compiler>
 		<Compiler>
 			<Add option="-Wall" />
 			<Add option="-Wall" />
+			<Add directory="C:\Program Files\Microchip\MPLAB C32 Suite\pic32mx\include" />
 		</Compiler>
 		</Compiler>
 		<Unit filename="application.c">
 		<Unit filename="application.c">
 			<Option compilerVar="CC" />
 			<Option compilerVar="CC" />
@@ -380,10 +381,10 @@
 		<Unit filename="..\..\libcpu\mips\common\mipsregs.h" />
 		<Unit filename="..\..\libcpu\mips\common\mipsregs.h" />
 		<Unit filename="..\..\libcpu\mips\common\stackframe.h" />
 		<Unit filename="..\..\libcpu\mips\common\stackframe.h" />
 		<Unit filename="..\..\libcpu\mips\pic32\context_gcc.S" />
 		<Unit filename="..\..\libcpu\mips\pic32\context_gcc.S" />
-		<Unit filename="..\..\libcpu\mips\pic32\interrupt.c">
+		<Unit filename="..\..\libcpu\mips\pic32\cpuport.c">
 			<Option compilerVar="CC" />
 			<Option compilerVar="CC" />
 		</Unit>
 		</Unit>
-		<Unit filename="..\..\libcpu\mips\pic32\stack.c">
+		<Unit filename="..\..\libcpu\mips\pic32\exceptions.c">
 			<Option compilerVar="CC" />
 			<Option compilerVar="CC" />
 		</Unit>
 		</Unit>
 		<Unit filename="..\..\src\clock.c">
 		<Unit filename="..\..\src\clock.c">

+ 24 - 25
bsp/pic32ethernet/project.mcp

@@ -43,9 +43,9 @@ file_015=kernel
 file_016=kernel
 file_016=kernel
 file_017=.
 file_017=.
 file_018=pic32
 file_018=pic32
-file_019=pic32
-file_020=.
-file_021=pic32
+file_019=.
+file_020=finsh
+file_021=finsh
 file_022=finsh
 file_022=finsh
 file_023=finsh
 file_023=finsh
 file_024=finsh
 file_024=finsh
@@ -57,9 +57,9 @@ file_029=finsh
 file_030=finsh
 file_030=finsh
 file_031=finsh
 file_031=finsh
 file_032=finsh
 file_032=finsh
-file_033=finsh
-file_034=finsh
-file_035=.
+file_033=.
+file_034=pic32
+file_035=pic32
 file_036=.
 file_036=.
 [GENERATED_FILES]
 [GENERATED_FILES]
 file_000=no
 file_000=no
@@ -157,31 +157,30 @@ file_015=..\..\src\timer.c
 file_016=..\..\src\clock.c
 file_016=..\..\src\clock.c
 file_017=startup.c
 file_017=startup.c
 file_018=..\..\libcpu\mips\pic32\context_gcc.S
 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=..\..\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_019=console.c
+file_020=..\..\components\finsh\finsh_node.c
+file_021=..\..\components\finsh\finsh_ops.c
+file_022=..\..\components\finsh\finsh_parser.c
+file_023=..\..\components\finsh\finsh_token.c
+file_024=..\..\components\finsh\finsh_var.c
+file_025=..\..\components\finsh\finsh_vm.c
+file_026=..\..\components\finsh\shell.c
+file_027=..\..\components\finsh\symbol.c
+file_028=..\..\components\finsh\cmd.c
+file_029=..\..\components\finsh\finsh_compiler.c
+file_030=..\..\components\finsh\finsh_error.c
+file_031=..\..\components\finsh\finsh_heap.c
+file_032=..\..\components\finsh\finsh_init.c
+file_033=uart.c
+file_034=..\..\libcpu\mips\pic32\exceptions.c
+file_035=..\..\libcpu\mips\pic32\cpuport.c
 file_036=rtconfig.h
 file_036=rtconfig.h
 [SUITE_INFO]
 [SUITE_INFO]
 suite_guid={14495C23-81F8-43F3-8A44-859C583D7760}
 suite_guid={14495C23-81F8-43F3-8A44-859C583D7760}
 suite_state=
 suite_state=
 [TOOL_SETTINGS]
 [TOOL_SETTINGS]
 TS{CB0AF4B8-4022-429D-8F99-8A56782B2C6D}=--gdwarf-2
 TS{CB0AF4B8-4022-429D-8F99-8A56782B2C6D}=--gdwarf-2
-TS{9C698E0A-CBC9-4EFF-AE7D-B569F93E7322}=-g -DPIC32_STARTER_KIT -G0
-TS{9C698E0A-CBC9-4EFF-AE7D-B569F93E7322}_alt=yes
+TS{9C698E0A-CBC9-4EFF-AE7D-B569F93E7322}=-g -DPIC32_STARTER_KIT
 TS{77F59DA1-3C53-4677-AC5F-A03EB0125170}=-Map="$(BINDIR_)$(TARGETBASE).map" -o"$(BINDIR_)$(TARGETBASE).$(TARGETSUFFIX)"
 TS{77F59DA1-3C53-4677-AC5F-A03EB0125170}=-Map="$(BINDIR_)$(TARGETBASE).map" -o"$(BINDIR_)$(TARGETBASE).$(TARGETSUFFIX)"
 TS{0396C0A1-9052-4E4F-8B84-EF0162B1B4E9}=
 TS{0396C0A1-9052-4E4F-8B84-EF0162B1B4E9}=
 [INSTRUMENTED_TRACE]
 [INSTRUMENTED_TRACE]

BIN
bsp/pic32ethernet/project.mcw


+ 36 - 18
bsp/pic32ethernet/uart.c

@@ -155,25 +155,34 @@ void __ISR(_UART1_VECTOR, ipl2) IntUART1Handler(void)
     // Is this an RX interrupt?
     // Is this an RX interrupt?
     if(INTGetFlag(INT_SOURCE_UART_RX(uart_device->uart)))
     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;
+        while( U1STAbits.URXDA )
+        {
+            /* 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 */
         /* invoke callback */
         if(uart_device->parent.rx_indicate != RT_NULL)
         if(uart_device->parent.rx_indicate != RT_NULL)
         {
         {
             rt_size_t length;
             rt_size_t length;
             if (uart_device->read_index > uart_device->save_index)
             if (uart_device->read_index > uart_device->save_index)
+            {
                 length = RT_UART_RX_BUFFER_SIZE - uart_device->read_index + uart_device->save_index;
                 length = RT_UART_RX_BUFFER_SIZE - uart_device->read_index + uart_device->save_index;
+            }
             else
             else
+            {
                 length = uart_device->save_index - uart_device->read_index;
                 length = uart_device->save_index - uart_device->read_index;
+            }
 
 
-            uart_device->parent.rx_indicate(&uart_device->parent, length);
+            if( length )
+            {
+                uart_device->parent.rx_indicate(&uart_device->parent, length);
+            }
         }
         }
 
 
         // Clear the RX interrupt Flag
         // Clear the RX interrupt Flag
@@ -198,25 +207,34 @@ void __ISR(_UART2_VECTOR, ipl2) IntUART2Handler(void)
     // Is this an RX interrupt?
     // Is this an RX interrupt?
     if(INTGetFlag(INT_SOURCE_UART_RX(uart_device->uart)))
     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;
+        while( U2STAbits.URXDA )
+        {
+            /* 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 */
         /* invoke callback */
         if(uart_device->parent.rx_indicate != RT_NULL)
         if(uart_device->parent.rx_indicate != RT_NULL)
         {
         {
             rt_size_t length;
             rt_size_t length;
             if (uart_device->read_index > uart_device->save_index)
             if (uart_device->read_index > uart_device->save_index)
+            {
                 length = RT_UART_RX_BUFFER_SIZE - uart_device->read_index + uart_device->save_index;
                 length = RT_UART_RX_BUFFER_SIZE - uart_device->read_index + uart_device->save_index;
+            }
             else
             else
+            {
                 length = uart_device->save_index - uart_device->read_index;
                 length = uart_device->save_index - uart_device->read_index;
+            }
 
 
-            uart_device->parent.rx_indicate(&uart_device->parent, length);
+            if( length )
+            {
+                uart_device->parent.rx_indicate(&uart_device->parent, length);
+            }
         }
         }
 
 
         // Clear the RX interrupt Flag
         // Clear the RX interrupt Flag