单总线led驱动芯片WS2811在linux下的驱动

硬件平台:mt7688  
软件平台:原生sdk MediaTek_ApSoC_SDK_4300_20140916  linux-3.10.14内核

ws2811是单总线接口的led驱动芯片,通过单个GPIO模拟高低时序发出颜色值,芯片收到后控制输出对应PWM改变三路RGB灯的颜色。

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/i2c.h>
#include <linux/timer.h>
#include <linux/delay.h>
#include <linux/cdev.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/device.h>
#include "ralink_gpio.h"


static dev_t sys_led_dev;
static struct class* sys_led_class = 0;
static struct cdev* sys_led_cdev = 0;
#define SYS_LED_NAME		"sys_led"

union _rgb
{
	unsigned int color;
	struct 
	{
		unsigned char r;
		unsigned char g;
		unsigned char b;
	}u_s;
};

#define set_led_hight()		*(volatile u32*)(RALINK_REG_PIOSET1) = (1 << (44 - 32))
#define set_led_low()		*(volatile u32*)(RALINK_REG_PIORESE
  • 5
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值