Mark Gottscho / HardwareTimersLib

Fork of HardwareTimersLib by Mark Gottscho

Timer_PIT.h

Committer:
mgottscho
Date:
2014-03-09
Revision:
2:5056ec8c52e8
Child:
3:dd54446143ee

File content as of revision 2:5056ec8c52e8:

/* Timer_PIT.h
 * Tested with mbed board: FRDM-KL46Z
 * Author: Mark Gottscho
 * mgottscho@ucla.edu
 */

#ifndef TIMER_PIT_H
#define TIMER_PIT_H

#include "mbed.h"
#include "HardwareTimer.h"
#include "PreciseTime.h"

/**
 * Base class for PIT timing on the FRDM-KL46Z.
 */
class Timer_PIT : public HardwareTimer {
    public:
        Timer_PIT(float tickValue);
        ~Timer_PIT();
        virtual void enableTimer() = 0;
        virtual void disableTimer();
        virtual PreciseTime getTime() = 0;
        virtual uint32_t getTick();
    
    protected:        
        /**
         * Sets the hardware PIT timer.
         * @param count raw value to load into the timer
         */
        static void __set_pit(uint32_t count);
        
        /**
         * Interrupt service routine for pit hardware timer.
         */
        static void __isr_pit();
                
        static bool __initialized_pit;
        static uint16_t __rolloverValue;
        static uint32_t __count;
};

#endif