5/10/2012

Output PWM from PM8058 GPIO

The following is the sample code using GPIO25 to output the PWM waveform. 

struct pwm_device *pwm; 
// LPG bank_1 => GPIO24 
// LPG bank_2 => GPIO25 
// LPG bank_3 => GPIO26 

// select LPG bank 2 for GPIO25
pwm=pwm_request(1, "lpg_bank2"); 

// set the duty time and period time 
int duty_us = 1000; 
int period_us = 2000; 

pwm_config(pwm, duty_us, period_us); 
pwm_enable(pwm); 

// LPG use DTEST1 for GPIO24 
// LPG use DTEST2 for GPIO25 
// LPG use DTEST3 for GPIO26 

static struct pm8058_gpio pmic_config = { 
.direction = PM_GPIO_DIR_OUT, 
.output_buffer = PM_GPIO_OUT_BUF_CMOS, 
.output_value = 1, 
.out_strength = PM_GPIO_STRENGTH_HIGH, 
.function = PM_GPIO_DTEST2, 
}; 

pm8058_gpio_config(24, &pmic_config); //GPIO25

No comments:

Post a Comment