timer.h


0001: /******************************************************************************
0002:  *
0003:  *                      PIC32MX Core and Peripheral Timer Library definitions
0004:  *
0005:  ******************************************************************************
0006:  * FileName:        timer.h
0007:  * Dependencies:
0008:  * Processor:       PIC32MX family
0009:  *
0010:  * Complier:        MPLAB C32
0011:  *                  MPLAB IDE
0012:  * Company:         Microchip Technology, Inc.
0013:  *
0014:  * Software License Agreement
0015:  *
0016:  * The software supplied herewith by Microchip Technology Incorporated
0017:  * (the “Company”) for its PIC32MX Microcontroller is intended
0018:  * and supplied to you, the Company’s customer, for use solely and
0019:  * exclusively on Microchip Microcontroller products.
0020:  * The software is owned by the Company and/or its supplier, and is
0021:  * protected under applicable copyright laws. All rights are reserved.
0022:  * Any use in violation of the foregoing restrictions may subject the
0023:  * user to criminal sanctions under applicable laws, as well as to
0024:  * civil liability for the breach of the terms and conditions of this
0025:  * license.
0026:  *
0027:  * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
0028:  * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
0029:  * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
0030:  * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
0031:  * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
0032:  * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
0033:  *
0034:  *
0035:  * $Id: Timer.h,v 1.14 2006/11/27 18:35:04 C11842 Exp $
0036:  * $Name:  $
0037:  *
0038:  *****************************************************************************/
0039: #ifndef _TIMER_H_
0040: #define _TIMER_H_
0041: 
0042: #include <p32xxxx.h>
0043: #include <peripheral/int.h>
0044: 
0045: /*********************************************************************
0046:  * Core Timer Control Interrupt Functions
0047:  *
0048:  * Function:        void OpenCoreTimer(unsigned int period)
0049:  *
0050:  * PreCondition:    None
0051:  *
0052:  * Inputs:                      period - 32 bit value for the timer
0053:  *
0054:  * Output:          None
0055:  *
0056:  * Side Effects:    None
0057:  *
0058:  * Overview:        None
0059:  ********************************************************************/
0060: void __attribute__((nomips16)) OpenCoreTimer(unsigned int period);
0061: 
0062: 
0063: /*********************************************************************
0064:  * Core Timer
0065:  *
0066:  * Function:        void UpdateCoreTimer(unsigned int period)
0067:  *
0068:  * PreCondition:    None
0069:  *
0070:  * Inputs:                      period - 32 bit value for the timer
0071:  *
0072:  * Output:          None
0073:  *
0074:  * Side Effects:    None
0075:  *
0076:  * Overview:        None
0077:  ********************************************************************/
0078:  void __attribute__((nomips16)) UpdateCoreTimer(unsigned int period);
0079: 
0080: 
0081: /******************************************************************************
0082:  * Function:        void ConfigIntCoreTimer(int config)
0083:  *
0084:  * Description:         Configures Core Timer  interrupt
0085:  *
0086:  * PreCondition:    None
0087:  *
0088:  * Inputs:                      config: Bit-wise OR value of CT_INT_XXX, CT_INT_PRIOR_XXX
0089:  *                                                        and CT_INT_SUB_PRIOR_X
0090:  *
0091:  *                                      Note: An absent symbol assumes corresponding bit(s)
0092:  *                                      are disabled, or default value, and will be set = 0.
0093:  *
0094:  * Output:          None
0095:  *
0096:  * Example:                     ConfigIntCoreTimer(CT_INT_ON | CT_INT_PRIOR_3 | CT_INT_SUB_PRIOR_1)
0097:  *
0098:  *****************************************************************************/
0099: #define mConfigIntCoreTimer(config)      (mCTClearIntFlag(), mCTSetIntPriority(((config) & 7)),\
0100:         mCTSetIntSubPriority((((config) >> 4) & 3)), mCTIntEnable(((config) >> 15)))
0101: 
0102:         /******************************************************************************
0103:          * Available options for config parameter
0104:          *****************************************************************************/
0105:                 // Interrupt on/off - values are mutually exclusive
0106:                 #define CT_INT_ON                               (1 << 15)
0107:                 #define CT_INT_OFF                                              (0)
0108: 
0109:                 // Interrupt priority - values are mutually exclusive
0110:                 #define CT_INT_PRIOR_7                  (7)
0111:                 #define CT_INT_PRIOR_6                  (6)
0112:                 #define CT_INT_PRIOR_5                  (5)
0113:                 #define CT_INT_PRIOR_4                  (4)
0114:                 #define CT_INT_PRIOR_3                  (3)
0115:                 #define CT_INT_PRIOR_2                  (2)
0116:                 #define CT_INT_PRIOR_1                  (1)
0117:                 #define CT_INT_PRIOR_0                  (0)
0118: 
0119:                 // Interrupt sub-priority - values are mutually exclusive
0120:                 #define CT_INT_SUB_PRIOR_3              (3 << 4)
0121:                 #define CT_INT_SUB_PRIOR_2              (2 << 4)
0122:                 #define CT_INT_SUB_PRIOR_1              (1 << 4)
0123:                 #define CT_INT_SUB_PRIOR_0              (0 << 4)
0124:         /***********************************
0125:          * End config parameter values
0126:          ************************************/
0127: 
0128: 
0129: /******************************************************************************
0130:  * Function:        EnableIntCoreTimer(void)
0131:  *
0132:  * Description:         Enables Core Timer interrupt
0133:  *
0134:  * PreCondition:    None
0135:  *
0136:  * Inputs:                      None
0137:  *
0138:  * Output:          None
0139:  *
0140:  * Example:                     EnableIntCoreTimer()
0141:  *****************************************************************************/
0142: #define mEnableIntCoreTimer()            mCTIntEnable(1)
0143: 
0144: 
0145: /******************************************************************************
0146:  * Function:        DisableIntCoreTimer(void)
0147:  *
0148:  * Description:         Disables Core Timer interrupt
0149:  *
0150:  * PreCondition:    None
0151:  *
0152:  * Inputs:                      None
0153:  *
0154:  * Output:          None
0155:  *
0156:  * Example:                     DisableIntCoreTimer()
0157:  *****************************************************************************/
0158: #define mDisableIntCoreTimer()           mCTIntEnable(0)
0159: 
0160: /******************************************************************************
0161:  * Function:        void SetPriorityIntCoreTimer(int priority)
0162:  *
0163:  * Description:         Sets the priority for Core Timer interrupt
0164:  *                                      The ConfigIntCoreTimer() sets the priority. Use this
0165:  *                                      macro to change the previously set priority
0166:  *                                      without any need to respecify other parameters.
0167:  *
0168:  * PreCondition:    None
0169:  *
0170:  * Inputs:                      priority : A value of CT_INT_PRIOR_XXX
0171:  *
0172:  * Output:          None
0173:  *
0174:  *
0175:  * Example:                     SetPriorityIntCoreTimer(CT_INT_PRIORITY_3)
0176:  *****************************************************************************/
0177: #define mSetPriorityIntCoreTimer(priority)      mCTSetIntPriority(priority)
0178: 
0179: /******************************************************************************
0180:  * Function:        unsigned int ReadCoreTimer(void)
0181:  *
0182:  * Description:         Returns the current Core Timer value.
0183:  *
0184:  * PreCondition:    None
0185:  *
0186:  * Inputs:                      None
0187:  *
0188:  * Output:          Count value.
0189:  *
0190:  * Example:                     ReadCoreTimer()
0191:  *
0192:  *****************************************************************************/
0193: unsigned int __attribute__((nomips16)) ReadCoreTimer(void);
0194: 
0195: 
0196: /******************************************************************************
0197:  * Function:        void WriteCoreTimer(unsigned int value)
0198:  *
0199:  * Description:         Loads 32-bit value into CoreTimer.
0200:  *
0201:  * PreCondition:    None
0202:  *
0203:  * Inputs:                      value: The value to be loaded.
0204:  *
0205:  * Output:          None
0206:  *
0207:  * Example:                     WriteCoreTimer(0x1234)
0208:  *
0209:  *****************************************************************************/
0210: void __attribute__((nomips16)) WriteCoreTimer(unsigned int timer);
0211: 
0212: 
0213: #if defined _TMR1
0214: 
0215: /******************************************************************************
0216:  * Function:        void OpenTimer1(unsigned int config, unsigned int period)
0217:  *
0218:  * Description:         Configures Timer 1
0219:  *
0220:  * PreCondition:    None
0221:  *
0222:  * Inputs:                      config: Bit-wise OR value of T1_ON/OFF, T1_IDLE_XXX,
0223:  *                                                      T1_GATE_XXX, T1_PS_XXX, T1_SYC_EXT_XXX,
0224:  *                                                      T1_SOURCE_XXX.
0225:  *                                      period: A value between 0 - 0xffff inclusive
0226:  *
0227:  *                                      Note: An absent symbol assumes corresponding bit(s)
0228:  *                                      are disabled, or default value, and will be set = 0.
0229:  *
0230:  * Output:          None
0231:  *
0232:  * Example:                     OpenTimer1(T1_ON | T1_IDLE_ON | T1_PS_1_4, 123)
0233:  *
0234:  *****************************************************************************/
0235: #define OpenTimer1(config, period)      (TMR1 = 0, PR1 = (period), T1CON = (config))
0236: 
0237:         /******************************************************************************
0238:          * Available options for config parameter
0239:          *****************************************************************************/
0240:                 // On/off control - values are mutually exclusive
0241:                 #define T1_ON                           (1 << _T1CON_ON_POSITION)           /* Timer1 ON */
0242:                 #define T1_OFF                                                  (0)
0243: 
0244:                 // Stop-in-idle control - values are mutually exclusive
0245:                 #define T1_IDLE_STOP                            (1 << _T1CON_SIDL_POSITION)
0246:                 #define T1_IDLE_CON                                             (0)                                                             /* Operate during idle */
0247: 
0248:                 // Asynchronous write control - values are mutually exclusive
0249:                 #define T1_TMWDIS_ON                                    (1 << _T1CON_TMWDIS_POSITION)   /* Asynchronous Write Disable */
0250:                 #define T1_TMWDIS_OFF                                   (0)
0251: 
0252:                 // Timer gate control - values are mutually exclusive
0253:                 #define T1_GATE_ON                              (1 << _T1CON_TGATE_POSITION)    /* Timer Gate accumulation mode ON */
0254:                 #define T1_GATE_OFF                                             (0)
0255: 
0256:                 // Timer prescaler control - values are mutually exclusive
0257:                 #define T1_PS_1_256                     (3 << _T1CON_TCKPS_POSITION)    /* Prescaler 1:256 */
0258:                 #define T1_PS_1_64                      (2 << _T1CON_TCKPS_POSITION)    /*           1:64 */
0259:                 #define T1_PS_1_8                       (1 << _T1CON_TCKPS_POSITION)    /*           1:8 */
0260:                 #define T1_PS_1_1                       (0)                                                             /*           1:1 */
0261: 
0262:                 // Sync option - values are mutually exclusive
0263:                 #define T1_SYNC_EXT_ON                  (1 << _T1CON_TSYNC_POSITION)    /* Synch external clk input */
0264:                 #define T1_SYNC_EXT_OFF                                 (0)
0265: 
0266:                 // Source selection - values are mutually exclusive
0267:                 #define T1_SOURCE_EXT                   (1 << _T1CON_TCS_POSITION)      /* External clock source */
0268:                 #define T1_SOURCE_INT                                   (0)                                                             /* Internal clock source */
0269:         /***********************************
0270:          * End config parameter values
0271:          ************************************/
0272: 
0273: 
0274: /******************************************************************************
0275:  * Function:        CloseTimer1()
0276:  *
0277:  * Description:         Switches off the Timer1
0278:  *
0279:  * PreCondition:    None
0280:  *
0281:  * Inputs:                      None
0282:  *
0283:  * Output:          None
0284:  *
0285:  * Example:                     CloseTimer1()
0286:  *
0287:  *****************************************************************************/
0288: #define CloseTimer1()   (mT1IntEnable(0), T1CON = 0)
0289: 
0290: 
0291: /******************************************************************************
0292:  * Function:        void ConfigIntTimer1(unsigned int config)
0293:  *
0294:  * Description:         Configures Timer 1 interrupt
0295:  *
0296:  * PreCondition:    None
0297:  *
0298:  * Inputs:                      config: Bit-wise OR value of T1_INT_XXX, T1_INT_PRIOR_XXX
0299:  *                                                        and T1_INT_SUB_PRIOR_X
0300:  *
0301:  *                                      Note: An absent symbol assumes corresponding bit(s)
0302:  *                                      are disabled, or default value, and will be set = 0.
0303:  *
0304:  * Output:          None
0305:  *
0306:  * Example:                     ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_3 | T1_INT_SUB_PRIOR1)
0307:  *
0308:  *****************************************************************************/
0309: #define ConfigIntTimer1(config) (mT1ClearIntFlag(), mT1SetIntPriority((config) & 7),\
0310:         mT1SetIntSubPriority(((config) >> 4) & 3), mT1IntEnable((config) >> 15))
0311: 
0312: 
0313:         /******************************************************************************
0314:          * Available options for config parameter
0315:          *****************************************************************************/
0316:                 // Interrupt on/off - values are mutually exclusive
0317:                 #define T1_INT_ON                               (1 << 15)
0318:                 #define T1_INT_OFF                                              (0)
0319: 
0320:                 // Interrupt priority - values are mutually exclusive
0321:                 #define T1_INT_PRIOR_7                  (7)
0322:                 #define T1_INT_PRIOR_6                  (6)
0323:                 #define T1_INT_PRIOR_5                  (5)
0324:                 #define T1_INT_PRIOR_4                  (4)
0325:                 #define T1_INT_PRIOR_3                  (3)
0326:                 #define T1_INT_PRIOR_2                  (2)
0327:                 #define T1_INT_PRIOR_1                  (1)
0328:                 #define T1_INT_PRIOR_0                  (0)
0329: 
0330:                 // Interrupt sub-priority - values are mutually exclusive
0331:                 #define T1_INT_SUB_PRIOR_3              (3 << 4)
0332:                 #define T1_INT_SUB_PRIOR_2              (2 << 4)
0333:                 #define T1_INT_SUB_PRIOR_1              (1 << 4)
0334:                 #define T1_INT_SUB_PRIOR_0              (0 << 4)
0335:         /***********************************
0336:          * End config parameter values
0337:          ************************************/
0338: 
0339: 
0340: 
0341: /******************************************************************************
0342:  * Function:        EnableIntT1
0343:  *
0344:  * Description:         Enables Timer1 interrupt
0345:  *
0346:  * PreCondition:    None
0347:  *
0348:  * Inputs:                      None
0349:  *
0350:  * Output:          None
0351:  *
0352:  * Example:                     EnableIntT1()
0353:  *****************************************************************************/
0354: #define EnableIntT1                                     mT1IntEnable(1)
0355: 
0356: 
0357: /******************************************************************************
0358:  * Function:        DisableIntT1
0359:  *
0360:  * Description:         Disables Timer1 interrupt
0361:  *
0362:  * PreCondition:    None
0363:  *
0364:  * Inputs:                      None
0365:  *
0366:  * Output:          None
0367:  *
0368:  * Example:                     DisableIntT1()
0369:  *****************************************************************************/
0370: #define DisableIntT1                            mT1IntEnable(0)
0371: 
0372: 
0373: /******************************************************************************
0374:  * Function:        void SetPriorityIntT1(int priority)
0375:  *
0376:  * Description:         Sets the priority for Timer 1 interrupt
0377:  *                                      The OpenTimerx() sets the priority. Use this
0378:  *                                      macro to change the previously set priority
0379:  *                                      without any need to respecify other parameters.
0380:  *
0381:  * PreCondition:    None
0382:  *
0383:  * Inputs:                      priority : A value of T1_INT_PRIOR_XXX
0384:  *
0385:  * Output:          None
0386:  *
0387:  *
0388:  * Example:                     SetPriorityIntT1(T1_INT_PRIORITY_3)
0389:  *****************************************************************************/
0390: #define SetPriorityIntT1(priority)      mT1SetIntPriority((priority))
0391: 
0392: 
0393: /******************************************************************************
0394:  * Function:        unsigned int ReadTimer1(void)
0395:  *
0396:  * Description:         Returns the current Timer1 value.
0397:  *
0398:  * PreCondition:    None
0399:  *
0400:  * Inputs:                      None
0401:  *
0402:  * Output:          TMR1 value.
0403:  *
0404:  * Example:                     ReadTimer1()
0405:  *
0406:  *****************************************************************************/
0407: #define ReadTimer1()    (TMR1)
0408: 
0409:  
0410: /******************************************************************************
0411:  * Function:        void WriteTimer1(unsigned int value)
0412:  *
0413:  * Description:         Loads given value into Timer1 register.
0414:  *
0415:  * PreCondition:    None
0416:  *
0417:  * Inputs:                      value: The value to be loaded.
0418:  *
0419:  * Output:          None
0420:  *
0421:  * Example:                     WriteTimer1(1234)
0422:  *
0423:  *****************************************************************************/
0424: #define WriteTimer1(value)      TMR1 = ((value))
0425: 
0426: 
0427: /******************************************************************************
0428:  * Function:        unsigned int ReadPeriod1(void)
0429:  *
0430:  * Description:         Returns the current Period1 value.
0431:  *
0432:  * PreCondition:    None
0433:  *
0434:  * Inputs:                      None
0435:  *
0436:  * Output:          PR1 value.
0437:  *
0438:  * Example:                     ReadPeriod1()
0439:  *
0440:  *****************************************************************************/
0441: #define ReadPeriod1()   (PR1)
0442: 
0443: 
0444: /******************************************************************************
0445:  * Function:        void WritePeriod1(unsigned int value)
0446:  *
0447:  * Description:         Loads given value into Period1 register.
0448:  *
0449:  * PreCondition:    None
0450:  *
0451:  * Inputs:                      value: The value to be loaded.
0452:  *
0453:  * Output:          None
0454:  *
0455:  * Example:                     WritePeriod1(1234)
0456:  *
0457:  *****************************************************************************/
0458: #define WritePeriod1(value)     PR1 = ((value))
0459: 
0460: #endif          // _TMR1
0461: 
0462: #if defined _TMR2
0463: 
0464: /******************************************************************************
0465:  * Function:        void OpenTimer2(unsigned int config, unsigned int period)
0466:  *
0467:  * Description:         Configures Timer 2
0468:  *
0469:  * PreCondition:    None
0470:  *
0471:  * Inputs:                      config: Bit-wise OR value of T2_ON/OFF, T2_IDLE_XXX,
0472:  *                                                      T2_GATE_XXX, T1_PS_XXX, T2_32BIT_MODE_ON, and
0473:  *                                                      T2_SOURCE_XXX.
0474:  *
0475:  *                                      Note: An absent symbol assumes corresponding bit(s)
0476:  *                                      are disabled, or default value, and will be set = 0.
0477:  *
0478:  *                                      period: A value between 0 - 0xffff inclusive
0479:  *
0480:  * Output:          None
0481:  *
0482:  * Example:                     OpenTimer2(T2_ON | T2_IDLE_ON | T2_PS_1_4, 123)
0483:  *
0484:  *****************************************************************************/
0485: #define OpenTimer2(config, period)      (TMR2 = 0, PR2 = (period), T2CON = (config))
0486: 
0487:         /******************************************************************************
0488:          * Available options for config parameter
0489:          *****************************************************************************/
0490:                 // On/off control - values are mutually exclusive
0491:                 #define T2_ON                           (1 << _T2CON_ON_POSITION)               /* Timer2 ON */
0492:                 #define T2_OFF                                                  (0)
0493: 
0494:                 // Stop-in-idle control - values are mutually exclusive
0495:                 #define T2_IDLE_CON                     (1 << _T2CON_SIDL_POSITION)     /* operate during idle */
0496:                 #define T2_IDLE_STOP                                    (0)
0497: 
0498:                 // Timer gate control - values are mutually exclusive
0499:                 #define T2_GATE_ON                      (1 << _T2CON_TGATE_POSITION)    /* Timer Gate accumulation mode ON */
0500:                 #define T2_GATE_OFF                                             (0)
0501: 
0502:                 // Prescale values - values are mutually exclusive
0503:                 #define T2_PS_1_256                     (7 << _T2CON_TCKPS_POSITION)    /* Prescaler 1:256 */
0504:                 #define T2_PS_1_64                      (6 << _T2CON_TCKPS_POSITION)    /*           1:64 */
0505:                 #define T2_PS_1_32                      (5 << _T2CON_TCKPS_POSITION)    /*           1:32 */
0506:                 #define T2_PS_1_16                      (4 << _T2CON_TCKPS_POSITION)    /*           1:16 */
0507:                 #define T2_PS_1_8                       (3 << _T2CON_TCKPS_POSITION)    /*           1:8 */
0508:                 #define T2_PS_1_4                       (2 << _T2CON_TCKPS_POSITION)    /*           1:4 */
0509:                 #define T2_PS_1_2                       (1 << _T2CON_TCKPS_POSITION)    /*           1:2 */
0510:                 #define T2_PS_1_1                       (0)                                                             /*           1:1 */
0511: 
0512:                 // 32-bit or 16-bit - values are mutually exclusive
0513:                 #define T2_32BIT_MODE_ON                (1 << _T2CON_T32_POSITION)      /* Enable 32-bit mode */
0514:                 #define T2_32BIT_MODE_OFF                               (0)
0515: 
0516:                 // Sync external clock option - values are mutually exclusive
0517:                 #define T2_SOURCE_EXT                   (1 << _T2CON_TCS_POSITION)      /* External clock source */
0518:                 #define T2_SOURCE_INT                                   (0)                                                             /* Internal clock source */
0519:         /***********************************
0520:          * End config parameter values
0521:          ************************************/
0522: 
0523: 
0524: /******************************************************************************
0525:  * Function:        CloseTimer2()
0526:  *
0527:  * Description:         Switches off the Timer2
0528:  *
0529:  * PreCondition:    None
0530:  *
0531:  * Inputs:                      None
0532:  *
0533:  * Output:          None
0534:  *
0535:  * Example:                     CloseTimer2()
0536:  *
0537:  *****************************************************************************/
0538: #define CloseTimer2()   (mT2IntEnable(0), T2CON = 0)
0539: 
0540: 
0541: /******************************************************************************
0542:  * Function:        void ConfigIntTimer2(unsigned int config)
0543:  *
0544:  * Description:         Configures Timer 2 interrupt
0545:  *
0546:  * PreCondition:    None
0547:  *
0548:  * Inputs:                      priority: Bit-wise OR value of T2_INT_XXX, T2_INT_PRIOR_XXX
0549:  *                                                        and T2_INT_SUB_PRIOR_X
0550:  *
0551:  *                                      Note: An absent symbol assumes corresponding bit(s)
0552:  *                                      are disabled, or default value, and will be set = 0.
0553:  *
0554:  * Output:          None
0555:  *
0556:  * Example:                     ConfigIntTimer2(T2_INT_ON | T2_INT_PRIOR_3 | T2_INT_SUB_PRIOR1)
0557:  *
0558:  *****************************************************************************/
0559: #define ConfigIntTimer2(config) (mT2ClearIntFlag(), mT2SetIntPriority(((config) & 7)),\
0560:         mT2SetIntSubPriority(((config) >> 4) & 3), mT2IntEnable((config) >> 15))
0561: 
0562:         /******************************************************************************
0563:          * Available options for config parameter
0564:          *****************************************************************************/
0565:                 // Interrupt on/off - values are mutually exclusive
0566:                 #define T2_INT_ON                                   (1 << 15)           /* T2 Interrupt Enable */
0567:                 #define T2_INT_OFF                                              (0)
0568: 
0569:                 // Interrupt priority - values are mutually exclusive
0570:                 #define T2_INT_PRIOR_7                  (7)
0571:                 #define T2_INT_PRIOR_6                  (6)
0572:                 #define T2_INT_PRIOR_5                  (5)
0573:                 #define T2_INT_PRIOR_4                  (4)
0574:                 #define T2_INT_PRIOR_3                  (3)
0575:                 #define T2_INT_PRIOR_2                  (2)
0576:                 #define T2_INT_PRIOR_1                  (1)
0577:                 #define T2_INT_PRIOR_0                  (0)
0578: 
0579:                 // Interrupt sub-priority - values are mutually exclusive
0580:                 #define T2_INT_SUB_PRIOR_3              (3 << 4)
0581:                 #define T2_INT_SUB_PRIOR_2              (2 << 4)
0582:                 #define T2_INT_SUB_PRIOR_1              (1 << 4)
0583:                 #define T2_INT_SUB_PRIOR_0              (0 << 4)
0584:         /***********************************
0585:          * End config parameter values
0586:          ************************************/
0587: 
0588: 
0589: 
0590: /******************************************************************************
0591:  * Function:        EnableIntT2
0592:  *
0593:  * Description:         Enables Timer2 interrupt
0594:  *
0595:  * PreCondition:    None
0596:  *
0597:  * Inputs:                      None
0598:  *
0599:  * Output:          None
0600:  *
0601:  * Example:                     EnableIntT2()
0602:  *****************************************************************************/
0603: #define EnableIntT2                                     mT2IntEnable(1)
0604: 
0605: 
0606: /******************************************************************************
0607:  * Function:        DisableIntT2
0608:  *
0609:  * Description:         Disables Timer2 interrupt
0610:  *
0611:  * PreCondition:    None
0612:  *
0613:  * Inputs:                      None
0614:  *
0615:  * Output:          None
0616:  *
0617:  * Example:                     DisableIntT2()
0618:  *****************************************************************************/
0619: #define DisableIntT2                            mT2IntEnable(0)
0620: 
0621: 
0622: /******************************************************************************
0623:  * Function:        void SetPriorityIntT2(int priority)
0624:  *
0625:  * Description:         Sets the priority for Timer 2 interrupt
0626:  *                                      The OpenTimerx() sets the priority. Use this
0627:  *                                      macro to change the previously set priority
0628:  *                                      without any need to respecify other parameters.
0629:  *
0630:  * PreCondition:    None
0631:  *
0632:  * Inputs:                      priority : A value of T2_INT_PRIOR_XXX
0633:  *
0634:  * Output:          None
0635:  *
0636:  * Example:                     SetPriorityIntT2(T2_INT_PRIORITY_3)
0637:  *****************************************************************************/
0638: #define SetPriorityIntT2(priority)      mT2SetIntPriority((priority))
0639: 
0640: 
0641: /******************************************************************************
0642:  * Function:        unsigned int ReadTimer2(void)
0643:  *
0644:  * Description:         Returns the current Timer2 value.
0645:  *
0646:  * PreCondition:    None
0647:  *
0648:  * Inputs:                      None
0649:  *
0650:  * Output:          TMR2 value.
0651:  *
0652:  * Example:                     ReadTimer2()
0653:  *
0654:  *****************************************************************************/
0655: #define ReadTimer2()    (TMR2)
0656: 
0657: 
0658: /******************************************************************************
0659:  * Function:        void WriteTimer2(unsigned int value)
0660:  *
0661:  * Description:         Loads given value into Timer2 register.
0662:  *
0663:  * PreCondition:    None
0664:  *
0665:  * Inputs:                      value: The value to be loaded.
0666:  *
0667:  * Output:          None
0668:  *
0669:  * Example:                     WriteTimer2(1234)
0670:  *
0671:  *****************************************************************************/
0672: #define WriteTimer2(value)      TMR2 = (value)
0673: 
0674: 
0675: /******************************************************************************
0676:  * Function:        unsigned int ReadPeriod2(void)
0677:  *
0678:  * Description:         Returns the current Period2 value.
0679:  *
0680:  * PreCondition:    None
0681:  *
0682:  * Inputs:                      None
0683:  *
0684:  * Output:          PR2 value.
0685:  *
0686:  * Example:                     ReadPeriod2()
0687:  *
0688:  *****************************************************************************/
0689: #define ReadPeriod2()   (PR2)
0690: 
0691: 
0692: /******************************************************************************
0693:  * Function:        void WritePeriod2(unsigned int value)
0694:  *
0695:  * Description:         Loads given value into Period2 register.
0696:  *
0697:  * PreCondition:    None
0698:  *
0699:  * Inputs:                      value: The value to be loaded.
0700:  *
0701:  * Output:          None
0702:  *
0703:  * Example:                     WritePeriod2(1234)
0704:  *
0705:  *****************************************************************************/
0706: #define WritePeriod2(value)     PR2 = ((value))
0707: 
0708: 
0709: 
0710: #endif  // _TMR2
0711: 
0712: 
0713: #if defined _TMR3
0714: 
0715: /******************************************************************************
0716:  * Function:        void OpenTimer3(unsigned int config, unsigned int period)
0717:  *
0718:  * Description:         Configures Timer 3
0719:  *
0720:  * PreCondition:    None
0721:  *
0722:  * Inputs:                      config: Bit-wise OR value of T3_ON/OFF, T3_IDLE_XXX,
0723:  *                                                      T3_GATE_XXX, T3_PS_XXX, T3_SOURCE_XXX.
0724:  *
0725:  *                                      Note: An absent symbol assumes corresponding bit(s)
0726:  *                                      are disabled, or default value, and will be set = 0.
0727:  *
0728:  *                                      period: A value between 0 - 0xffff inclusive
0729:  *
0730:  * Output:          None
0731:  *
0732:  * Example:                     OpenTimer3(T3_ON | T3_IDLE_ON | T3_PS_1_4, 123)
0733:  *
0734:  *****************************************************************************/
0735: #define OpenTimer3(config, period)      (TMR3 = 0, PR3 = (period), T3CON = (config))
0736: 
0737:         /******************************************************************************
0738:          * Available options for config parameter
0739:          *****************************************************************************/
0740:                 // On/off control - values are mutually exclusive
0741:                 #define T3_ON                           (1 << _T3CON_ON_POSITION)               /* Timer3 ON */
0742:                 #define T3_OFF                                                  (0)
0743: 
0744:                 // Stop-in-idle control - values are mutually exclusive
0745:                 #define T3_IDLE_CON                     (1 << _T3CON_SIDL_POSITION)     /* operate during idle */
0746:                 #define T3_IDLE_STOP                                    (0)
0747: 
0748:                 // Timer gate control - values are mutually exclusive
0749:                 #define T3_GATE_ON                      (1 << _T3CON_TGATE_POSITION)    /* Timer Gate accumulation mode ON */
0750:                 #define T3_GATE_OFF                                             (0)
0751: 
0752:                 // Timer prescaler control - values are mutually exclusive
0753:                 #define T3_PS_1_256                     (7 << _T3CON_TCKPS_POSITION)    /* Prescaler 1:256 */
0754:                 #define T3_PS_1_64                      (6 << _T3CON_TCKPS_POSITION)    /*           1:64 */
0755:                 #define T3_PS_1_32                      (5 << _T3CON_TCKPS_POSITION)    /*           1:32 */
0756:                 #define T3_PS_1_16                      (4 << _T3CON_TCKPS_POSITION)    /*           1:16 */
0757:                 #define T3_PS_1_8                       (3 << _T3CON_TCKPS_POSITION)    /*           1:8 */
0758:                 #define T3_PS_1_4                       (2 << _T3CON_TCKPS_POSITION)    /*           1:4 */
0759:                 #define T3_PS_1_2                       (1 << _T3CON_TCKPS_POSITION)    /*           1:2 */
0760:                 #define T3_PS_1_1                       (0)                                                             /*           1:1 */
0761: 
0762:                 // Source selection - values are mutually exclusive
0763:                 #define T3_SOURCE_EXT                   (1 << _T3CON_TCS_POSITION)      /* External clock source */
0764:                 #define T3_SOURCE_INT                                   (0)                                                             /* Internal clock source */
0765:         /***********************************
0766:          * End config parameter values
0767:          ************************************/
0768: 
0769: 
0770: 
0771: /******************************************************************************
0772:  * Function:        CloseTimer3()
0773:  *
0774:  * Description:         Switches off the Timer3
0775:  *
0776:  * PreCondition:    None
0777:  *
0778:  * Inputs:                      None
0779:  *
0780:  * Output:          None
0781:  *
0782:  * Example:                     CloseTimer3()
0783:  *
0784:  *****************************************************************************/
0785: #define CloseTimer3()   (mT3IntEnable(0), T3CON = 0)
0786: 
0787: 
0788: 
0789: /******************************************************************************
0790:  * Function:        void ConfigIntTimer3(unsigned int config)
0791:  *
0792:  * Description:         Configures Timer 3 interrupt
0793:  *
0794:  * PreCondition:    None
0795:  *
0796:  * Inputs:                      config: Bit-wise OR value of T3_INT_XXX, T3_INT_PRIOR_XXX
0797:  *                                                        and T3_INT_SUB_PRIOR_X
0798:  *
0799:  *                                      Note: An absent symbol assumes corresponding bit(s)
0800:  *                                      are disabled, or default value, and will be set = 0.
0801:  *
0802:  * Output:          None
0803:  *
0804:  * Example:                     ConfigIntTimer3(T3_INT_ON | T3_INT_PRIOR_3 | T3_INT_SUB_PRIOR1)
0805:  *
0806:  *****************************************************************************/
0807: #define ConfigIntTimer3(config) (mT3ClearIntFlag(), mT3SetIntPriority(((config) & 7)),\
0808:         mT3SetIntSubPriority(((config) >> 4) & 3), mT3IntEnable((config) >> 15))
0809: 
0810:         /******************************************************************************
0811:          * Available options for config parameter
0812:          *****************************************************************************/
0813:                 // Interrupt on/off - values are mutually exclusive
0814:                 #define T3_INT_ON                                   (1<<15)             /* Interrupt Enable */
0815:                 #define T3_INT_OFF                                              (0)
0816: 
0817:                 // Interrupt priority - values are mutually exclusive
0818:                 #define T3_INT_PRIOR_7                  (7)
0819:                 #define T3_INT_PRIOR_6                  (6)
0820:                 #define T3_INT_PRIOR_5                  (5)
0821:                 #define T3_INT_PRIOR_4                  (4)
0822:                 #define T3_INT_PRIOR_3                  (3)
0823:                 #define T3_INT_PRIOR_2                  (2)
0824:                 #define T3_INT_PRIOR_1                  (1)
0825:                 #define T3_INT_PRIOR_0                  (0)
0826: 
0827:                 // Interrupt sub-priority - values are mutually exclusive
0828:                 #define T3_INT_SUB_PRIOR_3              (3 << 4)
0829:                 #define T3_INT_SUB_PRIOR_2              (2 << 4)
0830:                 #define T3_INT_SUB_PRIOR_1              (1 << 4)
0831:                 #define T3_INT_SUB_PRIOR_0              (0 << 4)
0832:         /***********************************
0833:          * End config parameter values
0834:          ************************************/
0835: 
0836: 
0837: /******************************************************************************
0838:  * Function:        EnableIntT3()
0839:  *
0840:  * Description:         Enables Timer3 interrupt
0841:  *
0842:  * PreCondition:    None
0843:  *
0844:  * Inputs:                      None
0845:  *
0846:  * Output:          None
0847:  *
0848:  * Example:                     EnableIntT3()
0849:  *****************************************************************************/
0850: #define EnableIntT3                                     mT3IntEnable(1)
0851: 
0852: 
0853: /******************************************************************************
0854:  * Function:        DisableIntT3
0855:  *
0856:  * Description:         Disables Timer3 interrupt
0857:  *
0858:  * PreCondition:    None
0859:  *
0860:  * Inputs:                      None
0861:  *
0862:  * Output:          None
0863:  *
0864:  * Example:                     DisableIntT3()
0865:  *****************************************************************************/
0866: #define DisableIntT3                            mT3IntEnable(0)
0867: 
0868: 
0869: /******************************************************************************
0870:  * Function:        void SetPriorityIntT3(unsigned int priority)
0871:  *
0872:  * Description:         Sets the priority for Timer 3 interrupt
0873:  *                                      The OpenTimerx() sets the priority. Use this
0874:  *                                      macro to change the previously set priority
0875:  *                                      without any need to respecify other parameters.
0876:  *
0877:  * PreCondition:    None
0878:  *
0879:  * Inputs:                      priority : A value of T3_INT_PRIOR_XXX
0880:  *
0881:  * Output:          None
0882:  *
0883:  * Example:                     SetPriorityIntT3(T3_INT_PRIORITY_3)
0884:  *****************************************************************************/
0885: #define SetPriorityIntT3(priority)      mT3SetIntPriority((priority))
0886: 
0887: 
0888: /******************************************************************************
0889:  * Function:        unsigned int ReadTimer3(void)
0890:  *
0891:  * Description:         Returns the current Timer3 value.
0892:  *
0893:  * PreCondition:    None
0894:  *
0895:  * Inputs:                      None
0896:  *
0897:  * Output:          TMR3 value.
0898:  *
0899:  * Example:                     ReadTimer3()
0900:  *
0901:  *****************************************************************************/
0902: #define ReadTimer3()    (TMR3)
0903: 
0904: 
0905: /******************************************************************************
0906:  * Function:        void WriteTimer3(unsigned int value)
0907:  *
0908:  * Description:         Loads given value into Timer3 register.
0909:  *
0910:  * PreCondition:    None
0911:  *
0912:  * Inputs:                      value: The value to be loaded.
0913:  *
0914:  * Output:          None
0915:  *
0916:  * Example:                     WriteTimer3(1234)
0917:  *
0918:  *****************************************************************************/
0919: #define WriteTimer3(value)      TMR3 = (value)
0920: 
0921: 
0922: /******************************************************************************
0923:  * Function:        unsigned int ReadPeriod3(void)
0924:  *
0925:  * Description:         Returns the current Period3 value.
0926:  *
0927:  * PreCondition:    None
0928:  *
0929:  * Inputs:                      None
0930:  *
0931:  * Output:          PR3 value.
0932:  *
0933:  * Example:                     ReadPeriod3()
0934:  *
0935:  *****************************************************************************/
0936: #define ReadPeriod3()   (PR3)
0937: 
0938: 
0939: /******************************************************************************
0940:  * Function:        void WritePeriod3(unsigned int value)
0941:  *
0942:  * Description:         Loads given value into Period3 register.
0943:  *
0944:  * PreCondition:    None
0945:  *
0946:  * Inputs:                      value: The value to be loaded.
0947:  *
0948:  * Output:          None
0949:  *
0950:  * Example:                     WritePeriod3(1234)
0951:  *
0952:  *****************************************************************************/
0953: #define WritePeriod3(value)     PR3 = ((value))
0954: 
0955: 
0956: #endif  // _TMR3
0957: 
0958: #if defined _TMR23
0959: 
0960: /******************************************************************************
0961:  * Function:        void OpenTimer23(unsigned int config, unsigned int period)
0962:  *
0963:  * Description:         Configures Timer 23 - A 32-bit time by pairing
0964:  *                                      Timer 2 & 3.
0965:  *
0966:  * PreCondition:    None
0967:  *
0968:  * Inputs:                      config: Bit-wise OR value of T2_ON/OFF, T2_IDLE_XXX,
0969:  *                                                      T2_GATE_XXX, T2_PS_XXX, T2_SOURCE_XXX.
0970:  *
0971:  *                                      Note: An absent symbol assumes corresponding bit(s)
0972:  *                                      are disabled, or default value, and will be set = 0.
0973:  *
0974:  *                                      period: A value between 0 - 0xffffffff inclusive
0975:  *
0976:  * Output:          None
0977:  *
0978:  * Example:                     OpenTimer23(T2_ON | T2_IDLE_ON | T2_PS_1_4, 123)
0979:  *****************************************************************************/
0980: #define OpenTimer23(config, period) \
0981: (TMR3 = 0, OpenTimer2((config) | T2_32BIT_MODE_ON, (period)))
0982: 
0983: 
0984: /******************************************************************************
0985:  * Function:        CloseTimer23()
0986:  *
0987:  * Description:         Switches off the 32-bit Timer23
0988:  *
0989:  * PreCondition:    None
0990:  *
0991:  * Inputs:                      None
0992:  *
0993:  * Output:          None
0994:  *
0995:  * Example:                     CloseTimer23()
0996:  *
0997:  *****************************************************************************/
0998: #define CloseTimer23()  (CloseTimer2(), CloseTimer3())
0999: 
1000: 
1001: /******************************************************************************
1002:  * Function:        void ConfigIntTimer23(unsigned int config)
1003:  *
1004:  * Description:         Configures the 32-bit Timer23 interrupt
1005:  *
1006:  * PreCondition:    None
1007:  *
1008:  * Inputs:                      priority: Bit-wise OR value of T23_INT_XXX, T23_INT_PRIOR_XXX
1009:  *                                                        and T23_INT_SUB_PRIOR_X
1010:  *
1011:  *                                      Note: An absent symbol assumes corresponding bit(s)
1012:  *                                      are disabled, or default value, and will be set = 0.
1013:  *
1014:  * Output:          None
1015:  *
1016:  * Example:                     ConfigIntTimer23(T23_INT_ON | T23_INT_PRIOR_3 | T23_INT_SUB_PRIOR1)
1017:  *
1018:  *****************************************************************************/
1019: #define ConfigIntTimer23(config)        ConfigIntTimer3((config))
1020: 
1021:         /******************************************************************************
1022:          * Available options for config parameter
1023:          *****************************************************************************/
1024:                 // Interrupt on/off - values are mutually exclusive
1025:                 #define T23_INT_ON                                  (1<<15)             /* Interrupt Enable */
1026:                 #define T23_INT_OFF                                             (0)
1027: 
1028:                 // Interrupt priority - values are mutually exclusive
1029:                 #define T23_INT_PRIOR_7                  (7)
1030:                 #define T23_INT_PRIOR_6                  (6)
1031:                 #define T23_INT_PRIOR_5                  (5)
1032:                 #define T23_INT_PRIOR_4                  (4)
1033:                 #define T23_INT_PRIOR_3                  (3)
1034:                 #define T23_INT_PRIOR_2                  (2)
1035:                 #define T23_INT_PRIOR_1                  (1)
1036:                 #define T23_INT_PRIOR_0                  (0)
1037: 
1038:                 // Interrupt sub-priority - values are mutually exclusive
1039:                 #define T23_INT_SUB_PRIOR_3              (3 << 4)
1040:                 #define T23_INT_SUB_PRIOR_2              (2 << 4)
1041:                 #define T23_INT_SUB_PRIOR_1              (1 << 4)
1042:                 #define T23_INT_SUB_PRIOR_0              (0 << 4)
1043:         /***********************************
1044:          * End config parameter values
1045:          ************************************/
1046: 
1047: 
1048: 
1049: /******************************************************************************
1050:  * Function:        EnableIntT23()
1051:  *
1052:  * Description:         Enables the 32-bit Timer23 interrupt(Timer3 interrupt)
1053:  *
1054:  * PreCondition:    None
1055:  *
1056:  * Inputs:                      None
1057:  *
1058:  * Output:          None
1059:  *
1060:  * Example:                     EnableIntT23()
1061:  *****************************************************************************/
1062: #define EnableIntT23                            EnableIntT3
1063: 
1064: 
1065: /******************************************************************************
1066:  * Function:        DisableIntT23
1067:  *
1068:  * Description:         Disables 32-bit Timer23 interrupt(Timer3 interrupt)
1069:  *
1070:  * PreCondition:    None
1071:  *
1072:  * Inputs:                      None
1073:  *
1074:  * Output:          None
1075:  *
1076:  * Example:                     DisableIntT23()
1077:  *****************************************************************************/
1078: #define DisableIntT23                           DisableIntT3
1079: 
1080: 
1081: /******************************************************************************
1082:  * Function:        void SetPriorityIntT23(unsigned int priority)
1083:  *
1084:  * Description:         Sets the priority for 32-bit Timer 23 interrupt
1085:  *                                      The OpenTimerx() sets the priority. Use this
1086:  *                                      macro to change the previously set priority
1087:  *                                      without any need to respecify other parameters.
1088:  *                  Interrupts are Timer3.
1089:  *
1090:  * PreCondition:    None
1091:  *
1092:  * Inputs:                      priority : A value of T2_INT_PRIOR_XXX
1093:  *
1094:  * Output:          None
1095:  *
1096:  * Example:                     SetPriorityIntT23(T2_INT_PRIORITY_3)
1097:  *****************************************************************************/
1098: #define SetPriorityIntT23(priority)     SetPriorityIntT3((priority))
1099: 
1100: 
1101: /******************************************************************************
1102:  * Function:        unsigned int ReadTimer23(void)
1103:  *
1104:  * Description:         Returns the current 32-bit Timer23 value.
1105:  *
1106:  * PreCondition:    None
1107:  *
1108:  * Inputs:                      None
1109:  *
1110:  * Output:          The current 32-bit timer value.
1111:  *
1112:  * Example:                     ReadTimer23()
1113:  *
1114:  *****************************************************************************/
1115: #define ReadTimer23()   ReadTimer2()
1116: 
1117: 
1118: /******************************************************************************
1119:  * Function:        void WriteTimer23(unsigned int value)
1120:  *
1121:  * Description:         Loads given value into 32-bit Timer23 register.
1122:  *
1123:  * PreCondition:    None
1124:  *
1125:  * Inputs:                      value: The value to be loaded.
1126:  *
1127:  * Output:          None
1128:  *
1129:  * Example:                     WriteTimer23(1234)
1130:  *
1131:  *****************************************************************************/
1132: #define WriteTimer23(value)     WriteTimer2((value))
1133: 
1134: 
1135: /******************************************************************************
1136:  * Function:        unsigned int ReadPeriod23(void)
1137:  *
1138:  * Description:         Returns the current Period23 value.
1139:  *
1140:  * PreCondition:    None
1141:  *
1142:  * Inputs:                      None
1143:  *
1144:  * Output:          PR23 value.
1145:  *
1146:  * Example:                     ReadPeriod23()
1147:  *
1148:  *****************************************************************************/
1149: #define ReadPeriod23()  (PR23)
1150: 
1151: 
1152: /******************************************************************************
1153:  * Function:        void WritePeriod23(unsigned int value)
1154:  *
1155:  * Description:         Loads given value into Period23 register.
1156:  *
1157:  * PreCondition:    None
1158:  *
1159:  * Inputs:                      value: The value to be loaded.
1160:  *
1161:  * Output:          None
1162:  *
1163:  * Example:                     WritePeriod23(1234)
1164:  *
1165:  *****************************************************************************/
1166: #define WritePeriod23(value)    PR23 = (value)
1167: 
1168: 
1169: 
1170: #endif // _TMR23
1171: 
1172: 
1173: #if defined _TMR4
1174: 
1175: /******************************************************************************
1176:  * Function:        void OpenTimer4(unsigned int config, unsigned int period)
1177:  *
1178:  * Description:         Configures Timer 4
1179:  *
1180:  * PreCondition:    None
1181:  *
1182:  * Inputs:                      config: Bit-wise OR value of T4_ON/OFF, T4_IDLE_XXX,
1183:  *                                                      T4_GATE_XXX, T4_PS_XXX, T4_32BIT_MODE_ON, and
1184:  *                                                      T4_SOURCE_XXX.
1185:  *
1186:  *                                      Note: An absent symbol assumes corresponding bit(s)
1187:  *                                      are disabled, or default value, and will be set = 0.
1188:  *
1189:  *                                      period: A value between 0 - 0xffff inclusive
1190:  *
1191:  * Output:          None
1192:  *
1193:  * Example:                     OpenTimer4(T4_ON | T4_IDLE_ON | T4_PS_1_4, 123)
1194:  *
1195:  *****************************************************************************/
1196: #define OpenTimer4(config, period)  (TMR4 = 0, PR4 = (period), T4CON = (config))
1197: 
1198:         /******************************************************************************
1199:          * Available options for config parameter
1200:          *****************************************************************************/
1201:                 // On/off control - values are mutually exclusive
1202:                 #define T4_ON                           (1 << _T4CON_ON_POSITION)               /* Timer4 ON */
1203:                 #define T4_OFF                                                  (0)
1204: 
1205:                 // Stop-in-idle control - values are mutually exclusive
1206:                 #define T4_IDLE_CON                     (1 << _T4CON_SIDL_POSITION)     /* operate during idle */
1207:                 #define T4_IDLE_STOP                                    (0)
1208: 
1209:                 // Timer gate control - values are mutually exclusive
1210:                 #define T4_GATE_ON                      (1 << _T4CON_TGATE_POSITION)    /* Timer Gate accumulation mode ON */
1211:                 #define T4_GATE_OFF                                             (0)
1212: 
1213:                 // Timer prescaler control - values are mutually exclusive
1214:                 #define T4_PS_1_256                     (7 << _T4CON_TCKPS_POSITION)    /* Prescaler 1:256 */
1215:                 #define T4_PS_1_64                      (6 << _T4CON_TCKPS_POSITION)    /*           1:64 */
1216:                 #define T4_PS_1_32                      (5 << _T4CON_TCKPS_POSITION)    /*           1:32 */
1217:                 #define T4_PS_1_16                      (4 << _T4CON_TCKPS_POSITION)    /*           1:16 */
1218:                 #define T4_PS_1_8                       (3 << _T4CON_TCKPS_POSITION)    /*           1:8 */
1219:                 #define T4_PS_1_4                       (2 << _T4CON_TCKPS_POSITION)    /*           1:4 */
1220:                 #define T4_PS_1_2                       (1 << _T4CON_TCKPS_POSITION)    /*           1:2 */
1221:                 #define T4_PS_1_1                       (0)                                                             /*           1:1 */
1222: 
1223:                 // 32-bit or 16-bit option - values are mutually exclusive
1224:                 #define T4_32BIT_MODE_ON                (1 << _T4CON_T32_POSITION)      /* Enable 32-bit mode */
1225:                 #define T4_32BIT_MODE_OFF                               (0)
1226: 
1227:                 // Source selection - values are mutually exclusive
1228:                 #define T4_SOURCE_EXT                   (1 << _T4CON_TCS_POSITION)      /* External clock source */
1229:                 #define T4_SOURCE_INT                                   (0)                                                             /* Internal clock source */
1230:         /***********************************
1231:          * End config parameter values
1232:          ************************************/
1233: 
1234: 
1235: /******************************************************************************
1236:  * Function:        void CloseTimer4(void)
1237:  *
1238:  * Description:         Switches off the Timer4
1239:  *
1240:  * PreCondition:    None
1241:  *
1242:  * Inputs:                      None
1243:  *
1244:  * Output:          None
1245:  *
1246:  * Example:                     CloseTimer4()
1247:  *
1248:  *****************************************************************************/
1249: #define CloseTimer4()   (mT4IntEnable(0), T4CON = 0x0)
1250: 
1251: 
1252: 
1253: /******************************************************************************
1254:  * Function:        void ConfigIntTimer4(unsigned int config)
1255:  *
1256:  * Description:         Configures Timer 4 interrupt
1257:  *
1258:  * PreCondition:    None
1259:  *
1260:  * Inputs:                      priority: Bit-wise OR value of T4_INT_XXX, T4_INT_PRIOR_XXX
1261:  *                                                        and T4_INT_SUB_PRIOR_X
1262:  *
1263:  *                                      Note: An absent symbol assumes corresponding bit(s)
1264:  *                                      are disabled, or default value, and will be set = 0.
1265:  *
1266:  * Output:          None
1267:  *
1268:  * Example:                     ConfigIntTimer4(T4_INT_ON | T4_INT_PRIOR_3 | T4_INT_SUB_PRIOR1)
1269:  *
1270:  *****************************************************************************/
1271: #define ConfigIntTimer4(config) (mT4ClearIntFlag(), mT4SetIntPriority((config) & 7), \
1272:         mT4SetIntSubPriority(((config) >> 4) & 3),  mT4IntEnable((config) >> 15))
1273: 
1274: 
1275:         /******************************************************************************
1276:          * Available options for config parameter
1277:          *****************************************************************************/
1278:                 // Interrupt on/off - values are mutually exclusive
1279:                 #define T4_INT_ON                                   (1<<15)             /* Interrupt Enable */
1280:                 #define T4_INT_OFF                                              (0)
1281: 
1282:                 // Interrupt priority - values are mutually exclusive
1283:                 #define T4_INT_PRIOR_7                  (7)
1284:                 #define T4_INT_PRIOR_6                  (6)
1285:                 #define T4_INT_PRIOR_5                  (5)
1286:                 #define T4_INT_PRIOR_4                  (4)
1287:                 #define T4_INT_PRIOR_3                  (3)
1288:                 #define T4_INT_PRIOR_2                  (2)
1289:                 #define T4_INT_PRIOR_1                  (1)
1290:                 #define T4_INT_PRIOR_0                  (0)
1291: 
1292:                 // Interrupt sub-priority - values are mutually exclusive
1293:                 #define T4_INT_SUB_PRIOR_3              (3 << 4)
1294:                 #define T4_INT_SUB_PRIOR_2              (2 << 4)
1295:                 #define T4_INT_SUB_PRIOR_1              (1 << 4)
1296:                 #define T4_INT_SUB_PRIOR_0              (0 << 4)
1297:         /***********************************
1298:          * End config parameter values
1299:          ************************************/
1300: 
1301: 
1302: /******************************************************************************
1303:  * Function:        EnableIntT4()
1304:  *
1305:  * Description:         Enables Timer4 interrupt
1306:  *
1307:  * PreCondition:    None
1308:  *
1309:  * Inputs:                      None
1310:  *
1311:  * Output:          None
1312:  *
1313:  * Example:                     EnableIntT4()
1314:  *****************************************************************************/
1315: #define EnableIntT4                                     mT4IntEnable(1)
1316: 
1317: 
1318: /******************************************************************************
1319:  * Function:        DisableIntT4
1320:  *
1321:  * Description:         Disables Timer4 interrupt
1322:  *
1323:  * PreCondition:    None
1324:  *
1325:  * Inputs:                      None
1326:  *
1327:  * Output:          None
1328:  *
1329:  * Example:                     DisableIntT4()
1330:  *****************************************************************************/
1331: #define DisableIntT4                            mT4IntEnable(0)
1332: 
1333: 
1334: /******************************************************************************
1335:  * Function:        void SetPriorityIntT4(unsigned int priority)
1336:  *
1337:  * Description:         Sets the priority for Timer 4 interrupt
1338:  *                                      The OpenTimerx() sets the priority. Use this
1339:  *                                      macro to change the previously set priority
1340:  *                                      without any need to respecify other parameters.
1341:  *
1342:  * PreCondition:    None
1343:  *
1344:  * Inputs:                      priority : A value of T4_INT_PRIOR_XXX
1345:  *
1346:  * Output:          None
1347:  *
1348:  * Example:                     SetPriorityIntT4(T4_INT_PRIORITY_3)
1349:  *****************************************************************************/
1350: #define SetPriorityIntT4(priority)      mT4SetIntPriority(priority)
1351: 
1352: 
1353: /******************************************************************************
1354:  * Function:        unsigned int ReadTimer4(void)
1355:  *
1356:  * Description:         Returns the current Timer4 value.
1357:  *
1358:  * PreCondition:    None
1359:  *
1360:  * Inputs:                      None
1361:  *
1362:  * Output:          TMR4 value.
1363:  *
1364:  * Example:                     ReadTimer4()
1365:  *
1366:  *****************************************************************************/
1367: #define ReadTimer4()    (TMR4)
1368: 
1369: 
1370: /******************************************************************************
1371:  * Function:        void WriteTimer4(unsigned int value)
1372:  *
1373:  * Description:         Loads given value into Timer4 register.
1374:  *
1375:  * PreCondition:    None
1376:  *
1377:  * Inputs:                      value: The value to be loaded.
1378:  *
1379:  * Output:          None
1380:  *
1381:  * Example:                     WriteTimer4(1234)
1382:  *
1383:  *****************************************************************************/
1384: #define WriteTimer4(value)      TMR4 = value
1385: 
1386: 
1387: /******************************************************************************
1388:  * Function:        unsigned int ReadPeriod4(void)
1389:  *
1390:  * Description:         Returns the current Period4 value.
1391:  *
1392:  * PreCondition:    None
1393:  *
1394:  * Inputs:                      None
1395:  *
1396:  * Output:          PR4 value.
1397:  *
1398:  * Example:                     ReadPeriod4()
1399:  *
1400:  *****************************************************************************/
1401: #define ReadPeriod4()   (PR4)
1402: 
1403: 
1404: /******************************************************************************
1405:  * Function:        void WritePeriod4(unsigned int value)
1406:  *
1407:  * Description:         Loads given value into Period4 register.
1408:  *
1409:  * PreCondition:    None
1410:  *
1411:  * Inputs:                      value: The value to be loaded.
1412:  *
1413:  * Output:          None
1414:  *
1415:  * Example:                     WritePeriod4(1234)
1416:  *
1417:  *****************************************************************************/
1418: #define WritePeriod4(value)     PR4 = (value)
1419: 
1420: #endif  // _TMR4
1421: 
1422: 
1423: #if defined _TMR5
1424: 
1425: /******************************************************************************
1426:  * Function:        void OpenTimer5(unsigned int config, unsigned int period)
1427:  *
1428:  * Description:         Configures Timer 5
1429:  *
1430:  * PreCondition:    None
1431:  *
1432:  * Inputs:                      config: Bit-wise OR value of T5_ON/OFF, T5_IDLE_XXX,
1433:  *                                                      T5_GATE_XXX, T5_PS_XXX, T5_SOURCE_XXX.
1434:  *
1435:  *                                      Note: An absent symbol assumes corresponding bit(s)
1436:  *                                      are disabled, or default value, and will be set = 0.
1437:  *
1438:  *                                      period: A value between 0 - 0xffff inclusive
1439:  *
1440:  * Output:          None
1441:  *
1442:  * Example:                     OpenTimer5(T5_ON | T5_IDLE_ON | T5_PS_1_4, 123)
1443:  *
1444:  *****************************************************************************/
1445: #define OpenTimer5(config, period)      (TMR5 = 0, PR5 = period, T5CON = config)
1446: 
1447:         /******************************************************************************
1448:          * Available options for config parameter
1449:          *****************************************************************************/
1450:                 // On/off control - values are mutually exclusive
1451:                 #define T5_ON                           (1 << _T5CON_ON_POSITION)               /* Timer5 ON */
1452:                 #define T5_OFF                                                  (0)
1453: 
1454:                 // Stop-in-idle control - values are mutually exclusive
1455:                 #define T5_IDLE_CON                     (1 << _T5CON_SIDL_POSITION)     /* operate during idle */
1456:                 #define T5_IDLE_STOP                                    (0)
1457: 
1458:                 // Timer gate control - values are mutually exclusive
1459:                 #define T5_GATE_ON                      (1 << _T5CON_TGATE_POSITION)    /* Timer Gate accumulation mode ON */
1460:                 #define T5_GATE_OFF                                             (0)
1461: 
1462:                 // Prescale values - values are mutually exclusive
1463:                 #define T5_PS_1_256                     (7 << _T5CON_TCKPS_POSITION)    /* Prescaler 1:256 */
1464:                 #define T5_PS_1_64                      (6 << _T5CON_TCKPS_POSITION)    /*           1:64 */
1465:                 #define T5_PS_1_32                      (5 << _T5CON_TCKPS_POSITION)    /*           1:32 */
1466:                 #define T5_PS_1_16                      (4 << _T5CON_TCKPS_POSITION)    /*           1:16 */
1467:                 #define T5_PS_1_8                       (3 << _T5CON_TCKPS_POSITION)    /*           1:8 */
1468:                 #define T5_PS_1_4                       (2 << _T5CON_TCKPS_POSITION)    /*           1:4 */
1469:                 #define T5_PS_1_2                       (1 << _T5CON_TCKPS_POSITION)    /*           1:2 */
1470:                 #define T5_PS_1_1                       (0)                                                             /*           1:1 */
1471: 
1472:                 // Sync external clock option - values are mutually exclusive
1473:                 #define T5_SOURCE_EXT                   (1 << _T5CON_TCS_POSITION)      /* External clock source */
1474:                 #define T5_SOURCE_INT                                   (0)                                                             /* Internal clock source */
1475:         /***********************************
1476:          * End config parameter values
1477:          ************************************/
1478: 
1479: /******************************************************************************
1480:  * Function:        void CloseTimer5(void)
1481:  *
1482:  * Description:         Switches off the Timer5
1483:  *
1484:  * PreCondition:    None
1485:  *
1486:  * Inputs:                      None
1487:  *
1488:  * Output:          None
1489:  *
1490:  * Example:                     CloseTimer5()
1491:  *
1492:  *****************************************************************************/
1493: #define CloseTimer5()   (mT5IntEnable(0), T5CON = 0x0)
1494: 
1495: 
1496: 
1497: /******************************************************************************
1498:  * Function:        void ConfigIntTimer5(unsigned int config)
1499:  *
1500:  * Description:         Configures Timer 5 interrupt
1501:  *
1502:  * PreCondition:    None
1503:  *
1504:  * Inputs:                      config: Bit-wise OR value of T5_INT_XXX, T5_INT_PRIOR_XXX
1505:  *                                                        and T5_INT_SUB_PRIOR_X
1506:  *
1507:  *                                      Note: An absent symbol assumes corresponding bit(s)
1508:  *                                      are disabled, or default value, and will be set = 0.
1509:  *
1510:  * Output:          None
1511:  *
1512:  * Example:                     ConfigIntTimer5(T5_INT_ON | T5_INT_PRIOR_3 | T5_INT_SUB_PRIOR1)
1513:  *
1514:  *****************************************************************************/
1515: #define ConfigIntTimer5(config) (mT5ClearIntFlag(), mT5SetIntPriority((config) & 7), \
1516:         mT5SetIntSubPriority(((config) >> 4) & 3), mT5IntEnable((config) >> 15))
1517: 
1518:         /******************************************************************************
1519:          * Available options for config parameter
1520:          *****************************************************************************/
1521:                 // Interrupt on/off - values are mutually exclusive
1522:                 #define T5_INT_ON                                   (1<<15)             /* Interrupt Enable */
1523:                 #define T5_INT_OFF                                              (0)
1524: 
1525:                 // Interrupt priority - values are mutually exclusive
1526:                 #define T5_INT_PRIOR_7                  (7)
1527:                 #define T5_INT_PRIOR_6                  (6)
1528:                 #define T5_INT_PRIOR_5                  (5)
1529:                 #define T5_INT_PRIOR_4                  (4)
1530:                 #define T5_INT_PRIOR_3                  (3)
1531:                 #define T5_INT_PRIOR_2                  (2)
1532:                 #define T5_INT_PRIOR_1                  (1)
1533:                 #define T5_INT_PRIOR_0                  (0)
1534: 
1535:                 // Interrupt sub-priority - values are mutually exclusive
1536:                 #define T5_INT_SUB_PRIOR_3              (3 << 4)
1537:                 #define T5_INT_SUB_PRIOR_2              (2 << 4)
1538:                 #define T5_INT_SUB_PRIOR_1              (1 << 4)
1539:                 #define T5_INT_SUB_PRIOR_0              (0 << 4)
1540:         /***********************************
1541:          * End config parameter values
1542:          ************************************/
1543: 
1544: 
1545: /******************************************************************************
1546:  * Function:        EnableIntT5()
1547:  *
1548:  * Description:         Enables Timer5 interrupt
1549:  *
1550:  * PreCondition:    None
1551:  *
1552:  * Inputs:                      None
1553:  *
1554:  * Output:          None
1555:  *
1556:  * Example:                     EnableIntT5()
1557:  *****************************************************************************/
1558: #define EnableIntT5                                     mT5IntEnable(1)
1559: 
1560: 
1561: /******************************************************************************
1562:  * Function:        DisableIntT5
1563:  *
1564:  * Description:         Disables Timer5 interrupt
1565:  *
1566:  * PreCondition:    None
1567:  *
1568:  * Inputs:                      None
1569:  *
1570:  * Output:          None
1571:  *
1572:  * Example:                     DisableIntT5()
1573:  *****************************************************************************/
1574: #define DisableIntT5                            mT5IntEnable(0)
1575: 
1576: 
1577: /******************************************************************************
1578:  * Function:        void SetPriorityIntT5(unsigned int priority)
1579:  *
1580:  * Description:         Sets the priority for Timer 5 interrupt
1581:   *                                     The OpenTimerx() sets the priority. Use this
1582:  *                                      macro to change the previously set priority
1583:  *                                      without any need to respecify other parameters.
1584: *
1585:  * PreCondition:    None
1586:  *
1587:  * Inputs:                      priority : A value of T5_INT_PRIOR_XXX
1588:  *
1589:  * Output:          None
1590:  *
1591:  * Example:                     SetPriorityIntT5(T5_INT_PRIORITY_3)
1592:  *****************************************************************************/
1593: #define SetPriorityIntT5(priority)      mT5SetIntPriority(priority)
1594: 
1595: 
1596: /******************************************************************************
1597:  * Function:        unsigned int ReadTimer5(void)
1598:  *
1599:  * Description:         Returns the current Timer5 value.
1600:  *
1601:  * PreCondition:    None
1602:  *
1603:  * Inputs:                      None
1604:  *
1605:  * Output:          TMR5 value.
1606:  *
1607:  * Example:                     ReadTimer5()
1608:  *
1609:  *****************************************************************************/
1610: #define ReadTimer5()    (TMR5)
1611: 
1612: 
1613: /******************************************************************************
1614:  * Function:        void WriteTimer5(unsigned int value)
1615:  *
1616:  * Description:         Loads given value into Timer5 register.
1617:  *
1618:  * PreCondition:    None
1619:  *
1620:  * Inputs:                      value: The value to be loaded.
1621:  *
1622:  * Output:          None
1623:  *
1624:  * Example:                     WriteTimer5(1234)
1625:  *
1626:  *****************************************************************************/
1627: #define WriteTimer5(value)      TMR5 = value
1628: 
1629: 
1630: /******************************************************************************
1631:  * Function:        unsigned int ReadPeriod5(void)
1632:  *
1633:  * Description:         Returns the current Period5 value.
1634:  *
1635:  * PreCondition:    None
1636:  *
1637:  * Inputs:                      None
1638:  *
1639:  * Output:          PR5 value.
1640:  *
1641:  * Example:                     ReadPeriod5()
1642:  *
1643:  *****************************************************************************/
1644: #define ReadPeriod5()   (PR5)
1645: 
1646: 
1647: /******************************************************************************
1648:  * Function:        void WritePeriod5(unsigned int value)
1649:  *
1650:  * Description:         Loads given value into Period5 register.
1651:  *
1652:  * PreCondition:    None
1653:  *
1654:  * Inputs:                      value: The value to be loaded.
1655:  *
1656:  * Output:          None
1657:  *
1658:  * Example:                     WritePeriod5(1234)
1659:  *
1660:  *****************************************************************************/
1661: #define WritePeriod5(value)     PR5 = (value)
1662: 
1663: 
1664: #endif  // _TMR5
1665: 
1666: 
1667: #if defined _TMR45
1668: 
1669: /******************************************************************************
1670:  * Function:        void OpenTimer45(unsigned int config, unsigned int period)
1671:  *
1672:  * Description:         Configures Timer 45 - A 32-bit time by pairing
1673:  *                                      Timer 4 & 5.
1674:  *
1675:  * PreCondition:    None
1676:  *
1677:  * Inputs:                      config: Bit-wise OR value of T4_ON/OFF, T4_IDLE_XXX,
1678:  *                                                      T4_GATE_XXX, T4_PS_XXX, T4_SOURCE_XXX.
1679:  *
1680:  *                                      Note: An absent symbol assumes corresponding bit(s)
1681:  *                                      are disabled, or default value, and will be set = 0.
1682:  *
1683:  *                                      period: A value between 0 - 0xffffffff inclusive
1684:  *
1685:  * Output:          None
1686:  *
1687:  * Example:                     OpenTimer45(T4_ON | T4_IDLE_ON | T4_PS_1_4, 123)
1688:  *****************************************************************************/
1689: #define OpenTimer45(config, period) \
1690: (TMR4 = 0, OpenTimer4(config | T4_32BIT_MODE_ON, period))
1691: 
1692: 
1693: /******************************************************************************
1694:  * Function:        CloseTimer45()
1695:  *
1696:  * Description:         Switches off the 32-bit Timer45
1697:  *
1698:  * PreCondition:    None
1699:  *
1700:  * Inputs:                      None
1701:  *
1702:  * Output:          None
1703:  *
1704:  * Example:                     CloseTimer45()
1705:  *
1706:  *****************************************************************************/
1707: #define CloseTimer45()  (CloseTimer4(), CloseTimer5())
1708: 
1709: 
1710: /******************************************************************************
1711:  * Function:        void ConfigIntTimer45(unsigned int config)
1712:  *
1713:  * Description:         Configures the 32-bit Timer45 interrupt
1714:  *
1715:  * PreCondition:    None
1716:  *
1717:  * Inputs:                      priority: Bit-wise OR value of T4_INT_XXX, T4_INT_PRIOR_XXX
1718:  *                                                        and T4_INT_SUB_PRIOR_X
1719:  *
1720:  *                                      Note: An absent symbol assumes corresponding bit(s)
1721:  *                                      are disabled, or default value, and will be set = 0.
1722:  *
1723:  * Output:          None
1724:  *
1725:  * Example:                     ConfigIntTimer45(T4_INT_ON | T4_INT_PRIOR_3 | T4_INT_SUB_PRIOR1)
1726:  *
1727:  *****************************************************************************/
1728: #define ConfigIntTimer45(config)        ConfigIntTimer5(config)
1729: 
1730:         /******************************************************************************
1731:          * Available options for config parameter
1732:          *****************************************************************************/
1733:                 // Interrupt on/off - values are mutually exclusive
1734:                 #define T45_INT_ON                                  (1<<15)             /* Interrupt Enable */
1735:                 #define T45_INT_OFF                                             (0)
1736: 
1737:                 // Interrupt priority - values are mutually exclusive
1738:                 #define T45_INT_PRIOR_7                  (7)
1739:                 #define T45_INT_PRIOR_6                  (6)
1740:                 #define T45_INT_PRIOR_5                  (5)
1741:                 #define T45_INT_PRIOR_4                  (4)
1742:                 #define T45_INT_PRIOR_3                  (3)
1743:                 #define T45_INT_PRIOR_2                  (2)
1744:                 #define T45_INT_PRIOR_1                  (1)
1745:                 #define T45_INT_PRIOR_0                  (0)
1746: 
1747:                 // Interrupt sub-priority - values are mutually exclusive
1748:                 #define T45_INT_SUB_PRIOR_3              (3 << 4)
1749:                 #define T45_INT_SUB_PRIOR_2              (2 << 4)
1750:                 #define T45_INT_SUB_PRIOR_1              (1 << 4)
1751:                 #define T45_INT_SUB_PRIOR_0              (0 << 4)
1752:         /***********************************
1753:          * End config parameter values
1754:          ************************************/
1755: 
1756: 
1757: /******************************************************************************
1758:  * Function:        EnableIntT45()
1759:  *
1760:  * Description:         Enables the 32-bit Timer45 interrupt(Timer5 interrupt)
1761:  *
1762:  * PreCondition:    None
1763:  *
1764:  * Inputs:                      None
1765:  *
1766:  * Output:          None
1767:  *
1768:  * Example:                     EnableIntT45()
1769:  *****************************************************************************/
1770: #define EnableIntT45                            EnableIntT5
1771: 
1772: 
1773: /******************************************************************************
1774:  * Function:        DisableIntT45
1775:  *
1776:  * Description:         Disables 32-bit Timer45 interrupt(Timer5 interrupt)
1777:  *
1778:  * PreCondition:    None
1779:  *
1780:  * Inputs:                      None
1781:  *
1782:  * Output:          None
1783:  *
1784:  * Example:                     DisableIntT45()
1785:  *****************************************************************************/
1786: #define DisableIntT45                           DisableIntT5
1787: 
1788: 
1789: /******************************************************************************
1790:  * Function:        void SetPriorityIntT45(int priority)
1791:  *
1792:  * Description:         Sets the priority for 32-bit Timer 45 interrupt
1793:  *                                      The OpenTimerx() sets the priority. Use this
1794:  *                                      macro to change the previously set priority
1795:  *                                      without any need to respecify other parameters.
1796:  *                  Timer5 interrupt.
1797:  *
1798:  * PreCondition:    None
1799:  *
1800:  * Inputs:                      priority : A value of T4_INT_PRIOR_XXX
1801:  *
1802:  * Output:          None
1803:  *
1804:  * Example:                     SetPriorityIntT45(T4_INT_PRIORITY_3)
1805:  *****************************************************************************/
1806: #define SetPriorityIntT45(priority)     SetPriorityIntT5(priority)
1807: 
1808: 
1809: /******************************************************************************
1810:  * Function:        unsigned int ReadTimer45(void)
1811:  *
1812:  * Description:         Returns the current 32-bit Timer45 value.
1813:  *
1814:  * PreCondition:    None
1815:  *
1816:  * Inputs:                      None
1817:  *
1818:  * Output:          The current 32-bit timer value.
1819:  *
1820:  * Example:                     ReadTimer45()
1821:  *
1822:  *****************************************************************************/
1823: #define ReadTimer45()   ReadTimer4()
1824: 
1825: 
1826: /******************************************************************************
1827:  * Function:        void WriteTimer45(unsigned int value)
1828:  *
1829:  * Description:         Loads given value into 32-bit Timer45 register.
1830:  *
1831:  * PreCondition:    None
1832:  *
1833:  * Inputs:                      value: The value to be loaded.
1834:  *
1835:  * Output:          None
1836:  *
1837:  * Example:                     WriteTimer45(1234)
1838:  *
1839:  *****************************************************************************/
1840: #define WriteTimer45(value)     WriteTimer4(value)
1841: 
1842: 
1843: /******************************************************************************
1844:  * Function:        unsigned int ReadPeriod45(void)
1845:  *
1846:  * Description:         Returns the current Period45 value.
1847:  *
1848:  * PreCondition:    None
1849:  *
1850:  * Inputs:                      None
1851:  *
1852:  * Output:          PR45 value.
1853:  *
1854:  * Example:                     ReadPeriod45()
1855:  *
1856:  *****************************************************************************/
1857: #define ReadPeriod45()  PR45
1858: 
1859: 
1860: /******************************************************************************
1861:  * Function:        void WritePeriod45(unsigned int value)
1862:  *
1863:  * Description:         Loads given value into Period45 register.
1864:  *
1865:  * PreCondition:    None
1866:  *
1867:  * Inputs:                      value: The value to be loaded.
1868:  *
1869:  * Output:          None
1870:  *
1871:  * Example:                     WritePeriod45(1234)
1872:  *
1873:  *****************************************************************************/
1874: #define WritePeriod45(value)    PR45 = (value)
1875: 
1876: #endif          // _TMR45
1877: #endif /*TIMER_H_*/


Maintained by John Loomis, updated Tue Jul 29 14:41:22 2008