diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 18:42:24 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 18:42:24 +0000 |
commit | f508189682b6fba62e08feeb1596f682bad5fff9 (patch) | |
tree | 28aeb0e6c19386c385c1ce5edf8a92c1bca15281 /test/boost/interrupt.cpp | |
download | piklab-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/interrupt.cpp')
-rw-r--r-- | test/boost/interrupt.cpp | 80 |
1 files changed, 80 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 +} |