summaryrefslogtreecommitdiff
path: root/bsp/x1000/drivers/board_led.c
blob: 181aed753623f79a028074e9d792c90a9099ec54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
 * File      : drv_gpio_led.c
 * This file is part of RT-Thread RTOS
 * COPYRIGHT (C) 2008 - 2012, RT-Thread Development Team
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Change Logs:
 * Date           Author       Notes
 * 2016/05/13     Urey         the first version
 */

#include <rthw.h>
#include <rtthread.h>
#include <rtdevice.h>

#include "board.h"
#include "drv_gpio.h"

#if 0
#include "board_led.h"

#if defined(BOARD_CANNA)

#define MAX_LED_NBR     3

struct led_io_def led_io_tbl[MAX_LED_NBR] =
{
    //LED_POWER
    {
        GPIO_PORT_C,
        GPIO_Pin_24
    },

    //LED_WIFI
    {
        GPIO_PORT_D,
        GPIO_Pin_5
    },

    //LED_CHARGING
    {
        GPIO_PORT_A,
        GPIO_Pin_0
    },

};

#else
#define MAX_LED_NBR     0
struct led_io_def led_io_tbl[] =
{
    //LED_POWER
    {
        GPIO_PORT_B,
        GPIO_Pin_6
    },
};
#endif

void rt_hw_led_on(int led)
{
    if((led >= LED_LAST) || (led > MAX_LED_NBR))
        return;

    gpio_set_value(led_io_tbl[led].port,led_io_tbl[led].pin,0);
}

void rt_hw_led_off(int led)
{
    if((led >= LED_LAST) || (led > MAX_LED_NBR))
        return;

    gpio_set_value(led_io_tbl[led].port,led_io_tbl[led].pin,1);
}

int rt_hw_led_init(void)
{
    rt_uint8_t  i;

    /* Init all IO for keyboard */
    for (i = 0; i < MAX_LED_NBR; ++i)
    {
        gpio_set_func(led_io_tbl[i].port,led_io_tbl[i].pin,GPIO_OUTPUT1);
    }

    return 0;
}
INIT_DEVICE_EXPORT(rt_hw_led_init);


#endif