• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

BASIC compiler/interpreter for PIC32MX/MZ-80K


Commit MetaInfo

修订版f701f7162b8a7ced5e76a550eaf710638fb75658 (tree)
时间2019-04-14 10:51:06
作者Katsumi <kmorimatsu@sour...>
CommiterKatsumi

Log Message

CORETIMER and interrupt. EXEC() function.

更改概述

差异

--- a/mips/megalopa/compiler.h
+++ b/mips/megalopa/compiler.h
@@ -280,6 +280,7 @@ char* fput_statement();
280280 char* fputc_statement();
281281 char* fremove_statement();
282282 char* label_statement();
283+char* exec_statement();
283284
284285 char* function(void);
285286 char* str_function(void);
@@ -375,6 +376,8 @@ void stop_timer();
375376 char* usetimer_statement();
376377 char* timer_statement();
377378 char* timer_function();
379+char* coretimer_statement();
380+char* coretimer_function();
378381 char* interrupt_statement();
379382
380383 /* Error messages */
@@ -493,6 +496,7 @@ char* interrupt_statement();
493496 #define INTERRUPT_INKEY 3
494497 #define INTERRUPT_MUSIC 4
495498 #define INTERRUPT_WAVE 5
499+#define INTERRUPT_CORETIMER 6
496500
497501 extern int g_interrupt_flags;
498502 extern int g_int_vector[];
--- a/mips/megalopa/function.c
+++ b/mips/megalopa/function.c
@@ -391,6 +391,10 @@ char* getdir_function(){
391391 return 0;
392392 }
393393
394+char* exec_function(){
395+ return exec_statement();
396+}
397+
394398 char* float_constant(float val){
395399 volatile int i;
396400 ((float*)(&i))[0]=val;
@@ -597,6 +601,8 @@ static const void* int_func_list[]={
597601 "NEW(",new_function,
598602 "SETDIR(",setdir_function,
599603 "TIMER(",timer_function,
604+ "EXEC(",exec_function,
605+ "CORETIMER(",coretimer_function,
600606 // Additional functions follow
601607 ADDITIONAL_INT_FUNCTIONS
602608 };
--- a/mips/megalopa/statement.c
+++ b/mips/megalopa/statement.c
@@ -1741,6 +1741,7 @@ static const void* statement_list[]={
17411741 "TIMER ",timer_statement,
17421742 "INTERRUPT ",interrupt_statement,
17431743 "IDLE",idle_statement,
1744+ "CORETIMER",coretimer_statement,
17441745 // List of additional statements follows
17451746 ADDITIONAL_STATEMENTS
17461747 };
--- a/mips/megalopa/timer.c
+++ b/mips/megalopa/timer.c
@@ -33,6 +33,7 @@ static const void* interrupt_list[]={
3333 "INKEY", (void*)INTERRUPT_INKEY,
3434 "MUSIC", (void*)INTERRUPT_MUSIC,
3535 "WAVE", (void*)INTERRUPT_WAVE,
36+ "CORETIMER",(void*)INTERRUPT_CORETIMER,
3637 ADDITIONAL_INTERRUPT_FUNCTIONS
3738 };
3839 #define NUM_INTERRUPT_TYPES ((sizeof(interrupt_list)/sizeof(interrupt_list[0]))/2)
@@ -157,6 +158,40 @@ char* timer_function(){
157158 }
158159
159160 /*
161+ Coretimer implementaion
162+*/
163+
164+#pragma interrupt CTHandler IPL2SOFT vector 0
165+void CTHandler(void){
166+ // Clear CT interrupt flag
167+ IFS0bits.CTIF=0;
168+ // Raise TIMER interrupt flag
169+ raise_interrupt_flag(INTERRUPT_CORETIMER);
170+}
171+
172+char* coretimer_function(){
173+ check_obj_space(1);
174+ g_object[g_objpos++]=0x40024800; // mfc0 v0,Count
175+ return 0;
176+}
177+
178+void lib_coretimer(){
179+ // CT interrupt: priority 2
180+ IPC0bits.CTIP=2;
181+ IPC0bits.CTIS=0;
182+ IEC0bits.CTIE=1;
183+}
184+
185+char* coretimer_statement(){
186+ char* err;
187+ err=get_value();
188+ if (err) return err;
189+ // 0x40825800: mtc0 v0,Compare
190+ call_quicklib_code(lib_coretimer,0x40825800);
191+ return 0;
192+}
193+
194+/*
160195 Interrupt interprtation
161196 To cause interruption, use raise_interrupt_flag() macro
162197 For example,