// ------------------------------------------------------------ // enables the SIT clock if not already enabled, then checks to // see if any SITs 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_SIT(intPeriod Period, bool scale, TIMid id) { if (id < NUM_SIT) { // Allocate specified timer (id=TIMER3/4/5) or auto-allocate from pool (id=AUTO) if (!SIT_used[id]) { SIT_id = id; start_SIT(Period, scale); SIT_used[id] = true; return true; } } else { // Auto allocate - check for an available SIT, and if so, start it for (uint8_t tid = 0; tid < NUM_SIT; tid++) { if (!SIT_used[tid]) { SIT_id = tid; start_SIT(Period, scale); SIT_used[tid] = true; return true; } } } // Specified or no auto-allocate SIT available return false; }
// ------------------------------------------------------------ // enables the SIT clock if not already enabled, then checks to // see if any SITs 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_SIT(uint16_t newValue, bool scale) { // check for an available SIT, and if so, start it for (uint8_t id = 0; id < NUM_SIT; id++) { if (!SIT_used[id]) { SIT_id = id; start_SIT(newValue, scale); SIT_used[id] = true; return true; } } // no SIT available return false; }