/*
应用层控制led的方法:
读: cat /sys/class/leds/xxx/delay_on
写: echo 255 > /sys/class/leds/xxx/delay_off
读 cat:
static ssize_t led_delay_on_show(struct device *dev, struct device_attribute *attr, char *buf)
|
return sprintf(buf, "%lu\n", led_cdev->blink_delay_on);
写 echo:
static ssize_t led_delay_on_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
|
kstrtoul(buf, 10, &state);
led_blink_set(led_cdev, &state, &led_cdev->blink_delay_off);
led_blink_set(struct led_classdev *led_cdev, unsigned long *delay_on, unsigned long *delay_off)
|
led_blink_setup(led_cdev, delay_on, delay_off);
|
led_cdev->blink_set(led_cdev, delay_on, delay_off)
|
//g_leds_data[i]->cdev.blink_set = mt65xx_blink_set; // 函数指针
mt65xx_blink_set(struct led_classdev *led_cdev, unsigned long *delay_on, unsigned long *delay_off)
|
if (mt_mt65xx_blink_set(led_cdev, delay_on, delay_off))
|
if (*delay_on != led_data->delay_on || *delay_off != led_data->delay_off) {
led_data->delay_on = *delay_on; // delay_on() 指针
led_data->delay_off = *delay_off;
if (led_data->delay_on && led_data->delay_off) { // enable blink
led_data->level = 255;
if (led_data->cust.mode == MT65XX_LED_MODE_PWM) {
nled_tmp_setting.nled_mode = NLED_BLINK;
nled_tmp_setting.blink_off_time = led_data->delay_off; // delay_on() 指针
nled_tmp_setting.blink_on_time = led_data->delay_on;
mt_led_set_pwm(led_data->cust.data, &nled_tmp_setting);
|
pwm_setting.pwm_no = pwm_num;
pwm_setting.mode = PWM_MODE_OLD;
pwm_setting.clk_src = PWM_CLK_OLD_MODE_32K;
switch (led->nled_mode) {
case NLED_OFF:
pwm_setting.PWM_MODE_OLD_REGS.THRESH = 0;
pwm_setting.clk_div = CLK_DIV1;
pwm_setting.PWM_MODE_OLD_REGS.DA
led子系统分析:源码核心层4. kernel-3.18\drivers\leds\trigger\ledtrig-timer.c
最新推荐文章于 2024-07-10 15:03:31 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)