summaryrefslogtreecommitdiffstats
path: root/test/boost
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
commitf508189682b6fba62e08feeb1596f682bad5fff9 (patch)
tree28aeb0e6c19386c385c1ce5edf8a92c1bca15281 /test/boost
downloadpiklab-f508189682b6fba62e08feeb1596f682bad5fff9.tar.gz
piklab-f508189682b6fba62e08feeb1596f682bad5fff9.zip
Added KDE3 version of PikLab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1095639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'test/boost')
-rw-r--r--test/boost/interrupt.cpp80
-rw-r--r--test/boost/interrupt.pic16.bas34
-rw-r--r--test/boost/rand.piklab41
-rw-r--r--test/boost/randtest.c48
4 files changed, 203 insertions, 0 deletions
diff --git a/test/boost/interrupt.cpp b/test/boost/interrupt.cpp
new file mode 100644
index 0000000..a5c8963
--- /dev/null
+++ b/test/boost/interrupt.cpp
@@ -0,0 +1,80 @@
+/*
+ Basic sample for BoostC++ compiler.
+ Use the 'Led Block' plugin to see
+ changing value on port B.
+*/
+#include <system.h>
+
+// Set configuration word (sample only, ajust for your particular case)
+#ifdef _PIC16
+ #pragma DATA 0x2007, _HS_OSC & _WDT_OFF
+#endif //_PIC16
+
+class CPort
+{
+public:
+ CPort();
+
+ void Toggle( void )
+ {
+#ifdef _PIC16
+ portb++;
+#else
+ latb++;
+#endif
+
+ }
+};
+
+CPort::CPort()
+{
+ trisb = 0; //configure port B
+
+#ifdef _PIC16
+ portb = 0; //clear port B
+#else
+ latb = 0; //clear port B
+#endif
+}
+
+class CTimer
+{
+public:
+ CTimer();
+};
+
+CTimer::CTimer()
+{
+#ifdef _PIC16
+ option_reg = 7; //set prescaler
+#else
+ // configure Timer0
+ set_bit( t0con, TMR0ON ); //enable timer
+ clear_bit( t0con, T08BIT ); //set 16-bit mode
+ clear_bit( t0con, T0CS ); // select internal clock
+ clear_bit( t0con, PSA ); // select prescaler
+ set_bit( t0con, T0PS0 ); // set 1:64 prescale ratio
+ clear_bit( t0con, T0PS1 );
+ set_bit( t0con, T0PS2 );
+#endif
+ // enable interrupts
+ set_bit( intcon, T0IE ); //enable TMR0 overflow bit
+}
+
+class CPort port; //configure port
+class CTimer timer; //configure prescaler
+
+void interrupt( void )
+{
+ port.Toggle();
+
+ clear_bit( intcon, T0IF ); //clear TMR0 overflow flag
+}
+
+void main()
+{
+ // enable interrupts
+ set_bit( intcon, GIE );
+
+ while( 1 ); //endless loop
+}
diff --git a/test/boost/interrupt.pic16.bas b/test/boost/interrupt.pic16.bas
new file mode 100644
index 0000000..370e582
--- /dev/null
+++ b/test/boost/interrupt.pic16.bas
@@ -0,0 +1,34 @@
+#include <basic\PIC16F877.bas>
+'
+' Basic sample for BoostBasic compiler.
+' Use the "Led Block" plugin to see
+' changing value on port B.
+'
+
+' Set configuration word (sample only, ajust for your particular case)
+#pragma DATA _CONFIG, _HS_OSC & _WDT_OFF
+
+Sub interrupt()
+
+ portb = portb + 1
+
+ intcon = intcon & ~(1 << T0IF) 'clear TMR0 overflow flag
+
+End Sub
+
+Sub main()
+
+ trisb = 0 'configure port B
+ portb = 0 'clear port B
+
+ option_reg = 7 'set prescaler
+
+ ' enable interrupts
+ intcon = intcon | (1 << T0IE) 'enable TMR0 overflow bit
+ intcon = intcon | (1 << GIE) 'set global interrupt bit
+
+ ' endless loop
+ Do while 1
+ Loop
+
+End Sub
diff --git a/test/boost/rand.piklab b/test/boost/rand.piklab
new file mode 100644
index 0000000..e1127c6
--- /dev/null
+++ b/test/boost/rand.piklab
@@ -0,0 +1,41 @@
+<!DOCTYPE piklab>
+<piklab>
+ <general>
+ <device>16F873</device>
+ <files>
+ <item>randtest.c</item>
+ </files>
+ <description/>
+ <version>0.1</version>
+ <tool>boostc16</tool>
+ <opened_files>
+ <item>randtest.c</item>
+ </opened_files>
+ </general>
+ <compiler>
+ <has_custom_arguments>false</has_custom_arguments>
+ <custom_options/>
+ <custom_arguments>
+ <item>-t %DEVICE</item>
+ <item>-i</item>
+ <item>-I$(SRCPATH)</item>
+ <item>%I</item>
+ </custom_arguments>
+ <includes>
+ <item>$(SRCPATH)</item>
+ </includes>
+ </compiler>
+ <linker>
+ <has_custom_arguments>false</has_custom_arguments>
+ <custom_options>rand.pic16.lib</custom_options>
+ <custom_arguments>
+ <item>-t %DEVICE</item>
+ <item>-p</item>
+ <item>rand</item>
+ <item>-ld</item>
+ <item>/home/nicolas/wine/Program Files/SourceBoost/Lib</item>
+ <item>rand.pic16.lib</item>
+ <item>%OBJS</item>
+ </custom_arguments>
+ </linker>
+</piklab>
diff --git a/test/boost/randtest.c b/test/boost/randtest.c
new file mode 100644
index 0000000..812dfd6
--- /dev/null
+++ b/test/boost/randtest.c
@@ -0,0 +1,48 @@
+/*
+ Random number generator sample for BoostC compiler.
+ Use the 'Led Block' plugin to see
+ changing random value on port B.
+*/
+
+#include <system.h>
+#include <rand.h>
+
+#pragma CLOCK_FREQ 20000000
+
+// Set configuration word
+#ifdef _PIC16
+ #pragma DATA 0x2007, _HS_OSC & _WDT_OFF
+#endif //_PIC16
+
+
+void main()
+{
+ trisb = 0; //configure port B
+ portb = 0;
+
+#ifdef _PIC16
+ option_reg = 7; //set prescaler
+
+ set_bit( intcon, GIE );
+ set_bit( intcon, T0IE ); //enable TMR0 overflow bit
+#else
+ clear_bit( t0con, T0CS ); // select internal clock
+ clear_bit( t0con, PSA ); // select pres-scaler
+ set_bit( t0con, T0PS0 ); // set pres-scaler to 1:256
+ set_bit( t0con, T0PS1 );
+ set_bit( t0con, T0PS2 );
+
+ // enable interrupts
+ set_bit( intcon, GIE );
+ set_bit( intcon, TMR0IE ); //enable TMR0 overflow bit
+#endif
+
+ //Set ramdom number generator seed
+ srand( 0x1234 );
+
+ while( 1 ) //endless loop
+ {
+ portb = rand();
+ delay_ms( 100 );
+ }
+}