drivers/pwm/pwm_k64_ftm.c
/**
 * @brief API call to set the phase
 *
 * Phase describes number of clock ticks of delay before the start of the
 * pulse.  The maximum count of the FTM timer is 65536 so the phase value is
 * an integer from 0 to 65536.
 *
 * A non-zero phase value requires the timer pair to be set to combined mode
 * so the odd-numbered (n+1) channel is not available for output
 *
 * Note: non-zero phase is not supported in this implementation
 *
 * @param dev Device struct
 * @param access_op Access operation (pin or port)
 * @param channel The pwm channel number
 * @param phase Clock ticks of delay before start of the pulse (must be 0)
 *
 * @return 0 if successful, failed otherwise
 */
@brief API call to set the phase
Phase describes number of clock ticks of delay before the start of the
pulse.  The maximum count of the FTM timer is 65536 so the phase value is
an integer from 0 to 65536.

A non-zero phase value requires the timer pair to be set to combined mode
so the odd-numbered (n+1) channel is not available for output

non-zero phase is not supported in this implementation

@param dev Device struct
@param access_op Access operation (pin or port)
@param channel The pwm channel number
@param phase Clock ticks of delay before start of the pulse (must be 0)

@return 0 if successful, failed otherwise
@brief API call to set the phase Phase describes number of clock ticks of delay before the start of the pulse . The maximum count of the FTM timer is 65536 so the phase value is an integer from 0 to 65536 . A non - zero phase value requires the timer pair to be set to combined mode so the odd - numbered ( n + 1 ) channel is not available for output non - zero phase is not supported in this implementation @param dev Device struct @param access_op Access operation ( pin or port ) @param channel The pwm channel number @param phase Clock ticks of delay before start of the pulse ( must be 0 ) @return 0 if successful failed otherwise
static int pwm_ftm_set_phase(struct device *dev, int access_op,
			     u32_t channel, u8_t phase)
{
#ifdef COMBINE_MODE_SUPPORT
	const struct pwm_ftm_config * const config =
		dev->config->config_info;
	struct pwm_ftm_drv_data * const drv_data =
		(struct pwm_ftm_drv_data * const)dev->driver_data;
	ARG_UNUSED(access_op);
	SYS_LOG_DBG("...");
	if ((phase < 0) || (phase > config->period))
		return -ENOTSUP;
	switch (channel) {
	case 0:
		if (!config->phase_enable0)
			return -ENOTSUP;
		drv_data->phase[0] = phase;
		break;
	case 2:
		if (!config->phase_enable2)
			return -ENOTSUP;
		drv_data->phase[1] = phase;
		break;
	case 4:
		if (!config->phase_enable4)
			return -ENOTSUP;
		drv_data->phase[2] = phase;
		break;
	case 6:
		if (!config->phase_enable6)
			return -ENOTSUP;
		drv_data->phase[3] = phase;
		break;
	default:
		return -ENOTSUP;
	}
	SYS_LOG_DBG("done.");
	return 0;
#else 
	ARG_UNUSED(dev);
	ARG_UNUSED(access_op);
	ARG_UNUSED(channel);
	ARG_UNUSED(phase);
	SYS_LOG_ERR("non-zero phase is not supported.");
	return -ENOTSUP;
#endif 
}
static int pwm_ftm_set_phase ( struct device * dev , int access_op , u32_t channel , u8_t phase ) { #ifdef COMBINE_MODE_SUPPORT const struct pwm_ftm_config * const config = dev -> config -> config_info ; struct pwm_ftm_drv_data * const drv_data = ( struct pwm_ftm_drv_data * const ) dev -> driver_data ; ARG_UNUSED ( access_op ) ; SYS_LOG_DBG ( " " ) ; if ( ( phase < 0 ) || ( phase > config -> period ) ) return - ENOTSUP ; switch ( channel ) { case 0 : if ( ! config -> phase_enable0 ) return - ENOTSUP ; drv_data -> phase [ 0 ] = phase ; break ; case 2 : if ( ! config -> phase_enable2 ) return - ENOTSUP ; drv_data -> phase [ 1 ] = phase ; break ; case 4 : if ( ! config -> phase_enable4 ) return - ENOTSUP ; drv_data -> phase [ 2 ] = phase ; break ; case 6 : if ( ! config -> phase_enable6 ) return - ENOTSUP ; drv_data -> phase [ 3 ] = phase ; break ; default : return - ENOTSUP ; } SYS_LOG_DBG ( " " ) ; return 0 ; #else ARG_UNUSED ( dev ) ; ARG_UNUSED ( access_op ) ; ARG_UNUSED ( channel ) ; ARG_UNUSED ( phase ) ; SYS_LOG_ERR ( " " ) ; return - ENOTSUP ; #endif }
@brief API call to set the phase
 Phase describes number of clock ticks of delay before the start of the
 pulse.
@brief API call to set the phase Phase describes number of clock ticks of delay before the start of the pulse .
/* channel must be 0, 2, 4, or 6 */ /*COMBINE_MODE_SUPPORT*/ /*COMBINE_MODE_SUPPORT*/