提交 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 @@
// Adds support for PIC32 Peripheral library functions and macros
#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;
for(i=0;i<500000;i++);
// configure PORTD.RD1 = output
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)
{
PORTSetPinsDigitalOut(IOPORT_D, BIT_0);
while(1)
{
delay();
delay();
delay();
delay();
delay();
delay();
delay();
delay();
delay();
delay();
delay();
delay();
delay();
delay();
PORTSetBits(IOPORT_D, BIT_0);
delay();
PORTClearBits(IOPORT_D, BIT_0);
}
rt_thread_t thread;
rt_thread_init(&thread_led1,
"led1",
thread_led1_entry, RT_NULL,
&thread_led1_stack[0], sizeof(thread_led1_stack),
20, 10);
rt_thread_startup(&thread_led1);
/* create led2 thread */
thread = rt_thread_create("led2",
thread_led2_entry, RT_NULL,
1024,
20, 5);
if (thread != RT_NULL)
rt_thread_startup(thread);
return 0;
}
......@@ -14,6 +14,7 @@
// Adds support for PIC32 Peripheral library functions and macros
#include <plib.h>
#include <rtthread.h>
// Configuration Bits
#pragma config FNOSC = PRIPLL // Oscillator Selection
......@@ -35,7 +36,12 @@
#pragma config DEBUG = OFF // Debugger Disabled for Starter Kit
// 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)
{
......@@ -45,6 +51,17 @@ static void rt_hw_show_info(void)
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.
*/
......@@ -59,5 +76,56 @@ void rt_hw_board_init()
rt_hw_console_init();
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 @@
void rt_hw_console_init(void)
{
//Initialize the DB_UTILS IO channel
DBINIT();
// DBINIT();
}
/**
......@@ -34,6 +34,6 @@ void rt_hw_console_init(void)
*/
void rt_hw_console_output(const char* str)
{
DBPRINTF(str);
// DBPRINTF(str);
}
......@@ -36,6 +36,16 @@
<Unit filename="..\..\include\rthw.h" />
<Unit filename="..\..\include\rtm.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\interrupt.c">
<Option compilerVar="CC" />
......
......@@ -45,7 +45,8 @@ file_017=.
file_018=pic32
file_019=pic32
file_020=.
file_021=.
file_021=pic32
file_022=.
[GENERATED_FILES]
file_000=no
file_001=no
......@@ -69,6 +70,7 @@ file_018=no
file_019=no
file_020=no
file_021=no
file_022=no
[OTHER_FILES]
file_000=no
file_001=no
......@@ -92,6 +94,7 @@ file_018=no
file_019=no
file_020=no
file_021=no
file_022=no
[FILE_INFO]
file_000=board.c
file_001=application.c
......@@ -114,12 +117,13 @@ file_017=startup.c
file_018=..\..\libcpu\mips\pic32\context_gcc.S
file_019=..\..\libcpu\mips\pic32\stack.c
file_020=console.c
file_021=rtconfig.h
file_021=..\..\libcpu\mips\pic32\interrupt.c
file_022=rtconfig.h
[SUITE_INFO]
suite_guid={14495C23-81F8-43F3-8A44-859C583D7760}
suite_state=
[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{77F59DA1-3C53-4677-AC5F-A03EB0125170}=-Map="$(BINDIR_)$(TARGETBASE).map" -o"$(BINDIR_)$(TARGETBASE).$(TARGETSUFFIX)"
TS{0396C0A1-9052-4E4F-8B84-EF0162B1B4E9}=
......
......@@ -55,7 +55,7 @@
#define RT_USING_MEMPOOL
/* Using Dynamic Heap Management */
//#define RT_USING_HEAP
#define RT_USING_HEAP
/* Using Small MM */
#define RT_USING_SMALL_MEM
......
......@@ -14,6 +14,10 @@
// Adds support for PIC32 Peripheral library functions and macros
#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.
......@@ -35,16 +39,10 @@ void rtthread_startup(void)
/* init timer system */
rt_system_timer_init();
//#ifdef RT_USING_HEAP
// #ifdef __CC_ARM
// rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)FM3_SRAM_END);
// #elif __ICCARM__
// 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
#ifdef RT_USING_HEAP
/* init memory system */
rt_system_heap_init((void*)&_ramfunc_end, (void*)PIC32_SRAM_END);
#endif
/* init scheduler system */
rt_system_scheduler_init();
......@@ -96,8 +94,8 @@ void rtthread_startup(void)
int main(void)
{
// /* disable interrupt first */
// rt_hw_interrupt_disable();
/* disable interrupt first */
rt_hw_interrupt_disable();
/* startup RT-Thread RTOS */
rtthread_startup();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册