// ------------------------------------------------------------ // enables the PIT clock if not already enabled, then checks to // see if any PITs are available for use. if one is available, // it's initialized and started with the specified value, and // the function returns true, otherwise it returns false // ------------------------------------------------------------ bool IntervalTimer::allocate_PIT(uint32_t newValue) { // enable clock to the PIT module if necessary if (!PIT_enabled) enable_PIT(); // check for an available PIT, and if so, start it for (uint8_t id = 0; id < NUM_PIT; id++) { if (!PIT_used[id]) { PIT_id = id; start_PIT(newValue); PIT_used[id] = true; return true; } } // no PIT available return false; }
void restart_timer(void) { start_PIT(); }