codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#define ENABLE_BIT_DEFINITIONS #include "iocan32.h" #include "inavr.h" #include "port.h" #include "fled.h" #include "mb.h" #include "mbport.h" /******************************************************************************** * defines *******************************************************************************/ #define MB_TIMER_PRESCALER ( 1024UL ) #define MB_TIMER_TICKS ( F_CPU / MB_TIMER_PRESCALER ) #define MB_50US_TICKS ( 20000UL ) /******************************************************************************** * vars *******************************************************************************/ static USHORT usTimerOCRADelta; //static USHORT usTimerOCRBDelta; /******************************************************************************** * global *******************************************************************************/ BOOL xMBPortTimersInit( USHORT usTim1Timerout50us ) { /* Calculate overflow counter an OCR values for Timer1. */ usTimerOCRADelta = ( MB_TIMER_TICKS * usTim1Timerout50us ) / ( MB_50US_TICKS ); TCCR1A = 0x00; TCCR1B = 0x00; TCCR1C = 0x00; vMBPortTimersDisable( ); return TRUE; } inline void vMBPortTimersEnable( ) { TCNT1 = 0x0000; if( usTimerOCRADelta > 0 ) { TIMSK1 |= ( 1<<OCIE1A ); OCR1A = usTimerOCRADelta; } TCCR1B |= ( 1<<CS12 ) | ( 1<<CS10 ); } inline void vMBPortTimersDisable( ) { /* Disable the timer. */ TCCR1B &= ~(( 1<<CS12 ) | ( 1<<CS10 )); /* Disable the output compare interrupts for channel A/B. */ TIMSK1 &= ~(1<<OCIE1A ); /* Clear output compare flags for channel A/B. */ TIFR1 |= ( 1<<OCF1A ) ; } #pragma vector=TIMER1_COMPA_vect __interrupt void timer1CompAInterruptHandler ( void ) { ( void )pxMBPortCBTimerExpired( ); } /******************************************************************************** * EOF *******************************************************************************/
Private
[
?
]
Run code
Submit