提交 2c55f26f 编写于 作者: B Bernard Xiong

Merge pull request #252 from nongxiaoming/rb4088-1.2.x

update the led driver.
#include <rtthread.h> #include <rtthread.h>
#include "board.h" #include "board.h"
#include "drv_led.h"
#define RT_DEVICE_CTRL_RTC_GET_COUNT 0x81 /**< get count */ #define LED_DEVICE_CTRL 0x01 /*LED control command*/
#define LED_NUM 4 #define LED_NUM 4
struct led_ctrl struct led_ctrl
...@@ -92,11 +93,11 @@ static rt_size_t rt_led_write(rt_device_t dev, rt_off_t pos, ...@@ -92,11 +93,11 @@ static rt_size_t rt_led_write(rt_device_t dev, rt_off_t pos,
{ {
if (*value++) if (*value++)
{ {
led.ctrl[pos + index].port->CLR |= (1 << led.ctrl[pos + index].num); led.ctrl[pos + index].port->CLR = (1 << led.ctrl[pos + index].num);
} }
else else
{ {
led.ctrl[pos + index].port->SET |= (1 << led.ctrl[pos + index].num); led.ctrl[pos + index].port->SET = (1 << led.ctrl[pos + index].num);
} }
} }
return index; return index;
...@@ -106,7 +107,7 @@ static rt_err_t rt_led_control(rt_device_t dev, rt_uint8_t cmd, void *args) ...@@ -106,7 +107,7 @@ static rt_err_t rt_led_control(rt_device_t dev, rt_uint8_t cmd, void *args)
{ {
RT_ASSERT(dev == &led.parent); RT_ASSERT(dev == &led.parent);
if (cmd == RT_DEVICE_CTRL_RTC_GET_COUNT) if (cmd == LED_DEVICE_CTRL)
{ {
rt_uint32_t *led_num = args; rt_uint32_t *led_num = args;
*led_num = LED_NUM; *led_num = LED_NUM;
......
#ifndef __DRV_LED_H
#define __DRV_LED_H
#define LED_DEVICE_CTRL 0x01 /*LED control command*/
void rt_led_hw_init(void);
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册