code/WPILib/CInterfaces/CPWM.cpp
/**
 * Alloate a PWM based object
 *
 * Allocate an instance of a PWM based object. This code is shared between the subclasses
 * of PWM and is not usually created as a standalone object.
 *
 * @param module The slot the digital module is plugged into that corresponds to this serial port
 * @param channel The PWM channel for this PWM object
 * @param createObject The function callback in the subclass object that actually creates an instance
 * of the appropriate class.
 */
Alloate a PWM based object
Allocate an instance of a PWM based object. This code is shared between the subclasses
of PWM and is not usually created as a standalone object.

@param module The slot the digital module is plugged into that corresponds to this serial port
@param channel The PWM channel for this PWM object
@param createObject The function callback in the subclass object that actually creates an instance
of the appropriate class.
Alloate a PWM based object Allocate an instance of a PWM based object . This code is shared between the subclasses of PWM and is not usually created as a standalone object . @param module The slot the digital module is plugged into that corresponds to this serial port @param channel The PWM channel for this PWM object @param createObject The function callback in the subclass object that actually creates an instance of the appropriate class .
PWM *AllocatePWM(UINT32 module, UINT32 channel, SensorCreator createObject)
{
	if (!PWMsInitialized)
	{
		for (unsigned i = 0; i < SensorBase::kDigitalModules; i++)
			for (unsigned j = 0; j < SensorBase::kPwmChannels; j++)
				PWMs[i][j] = NULL;
		PWMsInitialized = true;
	}
	if (!SensorBase::CheckPWMModule(module) || !SensorBase::CheckPWMChannel(channel))
		return NULL;
	PWM *pwm = PWMs[DigitalModule::SlotToIndex(module)][channel - 1];
	if (pwm == NULL)
	{
		pwm = (PWM *) createObject(module, channel);
		PWMs[DigitalModule::SlotToIndex(module)][channel - 1] = pwm;
	}
	return pwm;
}
PWM * AllocatePWM ( UINT32 module , UINT32 channel , SensorCreator createObject ) { if ( ! PWMsInitialized ) { for ( unsigned i = 0 ; i < SensorBase :: kDigitalModules ; i ++ ) for ( unsigned j = 0 ; j < SensorBase :: kPwmChannels ; j ++ ) PWMs [ i ] [ j ] = NULL ; PWMsInitialized = true ; } if ( ! SensorBase :: CheckPWMModule ( module ) || ! SensorBase :: CheckPWMChannel ( channel ) ) return NULL ; PWM * pwm = PWMs [ DigitalModule :: SlotToIndex ( module ) ] [ channel - 1 ] ; if ( pwm == NULL ) { pwm = ( PWM * ) createObject ( module , channel ) ; PWMs [ DigitalModule :: SlotToIndex ( module ) ] [ channel - 1 ] = pwm ; } return pwm ; }
Alloate a PWM based object
 Allocate an instance of a PWM based object.
Alloate a PWM based object Allocate an instance of a PWM based object .