4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-02-28 05:37:04 +08:00

update the led driver.

This commit is contained in:
xiaonong 2014-04-03 12:12:17 +08:00
parent ed2d2b0d70
commit 5f26d0e1f8
2 changed files with 13 additions and 4 deletions

View File

@ -1,7 +1,8 @@
#include <rtthread.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
struct led_ctrl
@ -92,11 +93,11 @@ static rt_size_t rt_led_write(rt_device_t dev, rt_off_t pos,
{
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
{
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;
@ -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);
if (cmd == RT_DEVICE_CTRL_RTC_GET_COUNT)
if (cmd == LED_DEVICE_CTRL)
{
rt_uint32_t *led_num = args;
*led_num = LED_NUM;

View File

@ -0,0 +1,8 @@
#ifndef __DRV_LED_H
#define __DRV_LED_H
#define LED_DEVICE_CTRL 0x01 /*LED control command*/
void rt_led_hw_init(void);
#endif