mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			pwmout - NRF52 - add read methods for period and pulsewidth
							parent
							
								
									3db5d7b595
								
							
						
					
					
						commit
						dda71f0262
					
				| 
						 | 
				
			
			@ -143,7 +143,7 @@ void pwmout_init(pwmout_t *obj, PinName pin)
 | 
			
		|||
    /* Get hardware instance from pinmap. */
 | 
			
		||||
    int instance = pin_instance_pwm(pin);
 | 
			
		||||
 | 
			
		||||
    MBED_ASSERT(instance < (int) (sizeof(nordic_nrf5_pwm_instance) / sizeof(nrfx_pwm_t)));
 | 
			
		||||
    MBED_ASSERT(instance < (int)(sizeof(nordic_nrf5_pwm_instance) / sizeof(nrfx_pwm_t)));
 | 
			
		||||
 | 
			
		||||
    /* Populate PWM object with default values. */
 | 
			
		||||
    obj->instance = instance;
 | 
			
		||||
| 
						 | 
				
			
			@ -287,6 +287,11 @@ void pwmout_period_us(pwmout_t *obj, int period)
 | 
			
		|||
    nordic_pwm_restart(obj);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int pwmout_read_period_us(pwmout_t *obj)
 | 
			
		||||
{
 | 
			
		||||
    return obj->period;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Set the PWM pulsewidth specified in seconds, keeping the period the same.
 | 
			
		||||
 *
 | 
			
		||||
 * Parameter obj     The pwmout object
 | 
			
		||||
| 
						 | 
				
			
			@ -348,6 +353,10 @@ void pwmout_pulsewidth_us(pwmout_t *obj, int pulse)
 | 
			
		|||
    nordic_pwm_restart(obj);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int pwmout_read_pulsewidth_us(pwmout_t *obj {
 | 
			
		||||
    return (obj->period) * (obj->percent);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const PinMap *pwmout_pinmap()
 | 
			
		||||
{
 | 
			
		||||
    return PinMap_PWM_testing;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue