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

update pic32 bsp

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1480 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 f0054826
...@@ -14,37 +14,54 @@ ...@@ -14,37 +14,54 @@
// Adds support for PIC32 Peripheral library functions and macros // Adds support for PIC32 Peripheral library functions and macros
#include <plib.h> #include <plib.h>
#include <rtthread.h>
static void delay(void) ALIGN(RT_ALIGN_SIZE)
int thread_led1_stack[512];
struct rt_thread thread_led1;
void thread_led1_entry(void* parameter)
{ {
volatile unsigned long i; // configure PORTD.RD1 = output
for(i=0;i<500000;i++); mPORTDSetPinsDigitalOut(BIT_1);
while(1)
{
// .. Toggle the LED
mPORTDToggleBits(BIT_1);
rt_thread_delay( RT_TICK_PER_SECOND ); /* delay 1s */
}
}
static void thread_led2_entry(void* parameter)
{
// configure PORTD.RD2 = output
mPORTDSetPinsDigitalOut(BIT_2);
while (1)
{
// .. Toggle the LED
mPORTDToggleBits(BIT_2);
rt_thread_delay( RT_TICK_PER_SECOND*5 ); /* delay 1s */
}
} }
int rt_application_init(void) int rt_application_init(void)
{ {
PORTSetPinsDigitalOut(IOPORT_D, BIT_0); rt_thread_t thread;
while(1) rt_thread_init(&thread_led1,
{ "led1",
delay(); thread_led1_entry, RT_NULL,
delay(); &thread_led1_stack[0], sizeof(thread_led1_stack),
delay(); 20, 10);
delay(); rt_thread_startup(&thread_led1);
delay();
delay(); /* create led2 thread */
delay(); thread = rt_thread_create("led2",
delay(); thread_led2_entry, RT_NULL,
delay(); 1024,
delay(); 20, 5);
delay(); if (thread != RT_NULL)
delay(); rt_thread_startup(thread);
delay();
delay();
PORTSetBits(IOPORT_D, BIT_0);
delay();
PORTClearBits(IOPORT_D, BIT_0);
}
return 0; return 0;
} }
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
// Adds support for PIC32 Peripheral library functions and macros // Adds support for PIC32 Peripheral library functions and macros
#include <plib.h> #include <plib.h>
#include <rtthread.h>
// Configuration Bits // Configuration Bits
#pragma config FNOSC = PRIPLL // Oscillator Selection #pragma config FNOSC = PRIPLL // Oscillator Selection
...@@ -35,7 +36,12 @@ ...@@ -35,7 +36,12 @@
#pragma config DEBUG = OFF // Debugger Disabled for Starter Kit #pragma config DEBUG = OFF // Debugger Disabled for Starter Kit
// The following is used by the main application // The following is used by the main application
#define SYS_FREQ (80000000) #define SYS_FREQ (80000000UL)
#define PB_DIV 8
#define PRESCALE 256
#define TOGGLES_PER_SEC RT_TICK_PER_SECOND
#define T1_TICK (SYS_FREQ/PB_DIV/PRESCALE/TOGGLES_PER_SEC)
static void rt_hw_show_info(void) static void rt_hw_show_info(void)
{ {
...@@ -45,6 +51,17 @@ static void rt_hw_show_info(void) ...@@ -45,6 +51,17 @@ static void rt_hw_show_info(void)
rt_kprintf("CPU_FREQ: %uMHz\r\n",SYS_FREQ/1000000UL); rt_kprintf("CPU_FREQ: %uMHz\r\n",SYS_FREQ/1000000UL);
} }
static void rt_hw_timer_handler(void)
{
/* enter interrupt */
rt_interrupt_enter();
rt_tick_increase();
/* leave interrupt */
rt_interrupt_leave();
}
/** /**
* This function will initial FM3 Easy Kit board. * This function will initial FM3 Easy Kit board.
*/ */
...@@ -59,5 +76,56 @@ void rt_hw_board_init() ...@@ -59,5 +76,56 @@ void rt_hw_board_init()
rt_hw_console_init(); rt_hw_console_init();
rt_hw_show_info(); rt_hw_show_info();
// enable multi-vector interrupts
INTEnableSystemMultiVectoredInt();
rt_hw_interrupt_disable();
// // STEP 2. configure the core timer
// OpenCoreTimer(CORE_TICK_RATE);
//
// // set up the core timer interrupt with a prioirty of 2 and zero sub-priority
// mConfigIntCoreTimer((CT_INT_ON | CT_INT_PRIOR_2 | CT_INT_SUB_PRIOR_0));
// STEP 2. configure Timer 1 using internal clock, 1:256 prescale
OpenTimer1(T1_ON | T1_SOURCE_INT | T1_PS_1_256, T1_TICK);
// set up the timer interrupt with a priority of 2
ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_2);
/* 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)
{
// clear the interrupt flag
mT1ClearIntFlag();
// .. things to do
rt_hw_timer_handler();
// // .. in this case, toggle the LED
// mPORTDToggleBits(BIT_1);
}
//void __ISR(_CORE_TIMER_VECTOR, ipl2) CoreTimerHandler(void)
//{
// // clear the interrupt flag
// mCTClearIntFlag();
//
// // .. things to do
// rt_hw_timer_handler();
//
// // update the period
// UpdateCoreTimer(CORE_TICK_RATE);
//
// // .. Toggle the LED
// mPORTDToggleBits(BIT_1);
//}
void __ISR(_CORE_SOFTWARE_0_VECTOR, ipl2) CoreSW0Handler(void);
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
void rt_hw_console_init(void) void rt_hw_console_init(void)
{ {
//Initialize the DB_UTILS IO channel //Initialize the DB_UTILS IO channel
DBINIT(); // DBINIT();
} }
/** /**
...@@ -34,6 +34,6 @@ void rt_hw_console_init(void) ...@@ -34,6 +34,6 @@ void rt_hw_console_init(void)
*/ */
void rt_hw_console_output(const char* str) void rt_hw_console_output(const char* str)
{ {
DBPRINTF(str); // DBPRINTF(str);
} }
...@@ -36,6 +36,16 @@ ...@@ -36,6 +36,16 @@
<Unit filename="..\..\include\rthw.h" /> <Unit filename="..\..\include\rthw.h" />
<Unit filename="..\..\include\rtm.h" /> <Unit filename="..\..\include\rtm.h" />
<Unit filename="..\..\include\rtthread.h" /> <Unit filename="..\..\include\rtthread.h" />
<Unit filename="..\..\libcpu\mips\common\asm.h" />
<Unit filename="..\..\libcpu\mips\common\cache.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\libcpu\mips\common\cache.h" />
<Unit filename="..\..\libcpu\mips\common\exception.h" />
<Unit filename="..\..\libcpu\mips\common\mips.inc" />
<Unit filename="..\..\libcpu\mips\common\mipscfg.h" />
<Unit filename="..\..\libcpu\mips\common\mipsregs.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\interrupt.c">
<Option compilerVar="CC" /> <Option compilerVar="CC" />
......
...@@ -45,7 +45,8 @@ file_017=. ...@@ -45,7 +45,8 @@ file_017=.
file_018=pic32 file_018=pic32
file_019=pic32 file_019=pic32
file_020=. file_020=.
file_021=. file_021=pic32
file_022=.
[GENERATED_FILES] [GENERATED_FILES]
file_000=no file_000=no
file_001=no file_001=no
...@@ -69,6 +70,7 @@ file_018=no ...@@ -69,6 +70,7 @@ file_018=no
file_019=no file_019=no
file_020=no file_020=no
file_021=no file_021=no
file_022=no
[OTHER_FILES] [OTHER_FILES]
file_000=no file_000=no
file_001=no file_001=no
...@@ -92,6 +94,7 @@ file_018=no ...@@ -92,6 +94,7 @@ file_018=no
file_019=no file_019=no
file_020=no file_020=no
file_021=no file_021=no
file_022=no
[FILE_INFO] [FILE_INFO]
file_000=board.c file_000=board.c
file_001=application.c file_001=application.c
...@@ -114,12 +117,13 @@ file_017=startup.c ...@@ -114,12 +117,13 @@ 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_019=..\..\libcpu\mips\pic32\stack.c
file_020=console.c file_020=console.c
file_021=rtconfig.h file_021=..\..\libcpu\mips\pic32\interrupt.c
file_022=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}= 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
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}=
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
#define RT_USING_MEMPOOL #define RT_USING_MEMPOOL
/* Using Dynamic Heap Management */ /* Using Dynamic Heap Management */
//#define RT_USING_HEAP #define RT_USING_HEAP
/* Using Small MM */ /* Using Small MM */
#define RT_USING_SMALL_MEM #define RT_USING_SMALL_MEM
......
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
// Adds support for PIC32 Peripheral library functions and macros // Adds support for PIC32 Peripheral library functions and macros
#include <plib.h> #include <plib.h>
#include <rtthread.h>
extern int _ramfunc_end;
#define PIC32_SRAM_END (0xA0000000+0x8000) //795F512L 512KB
/** /**
* This function will startup RT-Thread RTOS. * This function will startup RT-Thread RTOS.
...@@ -35,16 +39,10 @@ void rtthread_startup(void) ...@@ -35,16 +39,10 @@ void rtthread_startup(void)
/* init timer system */ /* init timer system */
rt_system_timer_init(); rt_system_timer_init();
//#ifdef RT_USING_HEAP #ifdef RT_USING_HEAP
// #ifdef __CC_ARM /* init memory system */
// rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)FM3_SRAM_END); rt_system_heap_init((void*)&_ramfunc_end, (void*)PIC32_SRAM_END);
// #elif __ICCARM__ #endif
// rt_system_heap_init(__segment_end("HEAP"), (void*)FM3_SRAM_END);
// #else
// /* init memory system */
// rt_system_heap_init((void*)&__bss_end, (void*)FM3_SRAM_END);
// #endif
//#endif
/* init scheduler system */ /* init scheduler system */
rt_system_scheduler_init(); rt_system_scheduler_init();
...@@ -96,8 +94,8 @@ void rtthread_startup(void) ...@@ -96,8 +94,8 @@ void rtthread_startup(void)
int main(void) int main(void)
{ {
// /* disable interrupt first */ /* disable interrupt first */
// rt_hw_interrupt_disable(); rt_hw_interrupt_disable();
/* startup RT-Thread RTOS */ /* startup RT-Thread RTOS */
rtthread_startup(); rtthread_startup();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册