A33_LED驱动调试

由于A33硬件原理图中,LED只有一个LED_EN引脚,所以在 lichee\tools\pack\chips\sun8iw5p1\configs\m86sysconfig.fex中,只需配置LED_EN引脚的GPIO即可,如果把LED配置在audio下,如下

[audio0]
audio_used           = 1

;added by Dechao,for contrle microphone
microphone_used  = 1

led_shou          = port:PG11<1><default><default><0>

则需在lichee/linux-3.4/sound/soc/sunxi/audiocodec/sun8iw5_sndcodec.c中

static int gpio_shou;

static script_item_u item_shou;

static ssize_t shou_store(struct class *class,
   struct class_attribute *attr, const char *buf, size_t count) //供应用层write调用copy_from_user
{
 if(buf[0] == '1')
 {
      shou_flag = 1;
      gpio_set_value(gpio_shou, 1);
 }
 else
 {
     shou_flag = 0;
        gpio_set_value(gpio_shou, 0);  
 }
    return count;
}

static ssize_t shou_show(struct class *class,
   struct class_attribute *attr, char *buf) //供应用层read调用,相当于copy_to_user(buf, &key_val, 1);
{
 return sprintf(buf, "%d\n", shou_flag);
}
static struct class_attribute wire_class_attrs[] = {
 __ATTR(shou,0666,shou_show,shou_store), //这里的第一个参数还没搞清楚
 __ATTR_NULL
};

static struct class wire_class = {
 .name = "wire",
 .class_attrs = wire_class_attrs,
};

static int __init sndpcm_codec_probe(struct platform_device *pdev)
{

         script_item_value_type_e  type;

         type = script_get_item("audio0", "led_shou", &item_shou);
                 if (SCIRPT_ITEM_VALUE_TYPE_PIO != type) {
                        printk("script_get_item 'led_shou' return type err\n");
                        return -EFAULT;
    }
    gpio_shou = item_shou.gpio.gpio;

err = gpio_request(gpio_shou, "led_shou");
    if (0 != err) {
     printk("request led shou failed!\n");
    }
    gpio_direction_output(gpio_shou,0);
    gpio_set_value(gpio_shou, 1); //给gpio写1,灯常亮

    class_register(&wire_class);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zeropoint127

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值