LingYun Studio embeded system framwork software, such as thirdparty build shell and lingyun library
guowenxue
2024-08-21 1e32814e0bc7ee1eb5b7f64b703f8bd03cba7805
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
/*********************************************************************************
 *      Copyright:  (C) 2024 LingYun IoT System Studio
 *                  All rights reserved.
 *
 *       Filename:  led.h
 *    Description:  This file is used to control RGB 3-colors LED
 *
 *
 * Pin connection:
 *               RGB Led Module           IGKBoard-IMX6ULL
 *                   R        <----->      #Pin36 (GPIO1_IO11)
 *                   G        <----->      #Pin38 (GPIO1_IO10)
 *                   B        <----->      #Pin40 (GPIO5_IO09)
 *                  GND       <----->      GND
 *
 ********************************************************************************/
 
#ifndef  _LED_H_
#define  _LED_H_
 
#include "gpiod.h"
 
#define DELAY     300
 
#define ON        1
#define OFF       0
 
/* Three LEDs number */
enum
{
    LED_R = 0,
    LED_G,
    LED_B,
    LED_CNT,
};
 
enum
{
    ACTIVE_HIGH, /* High level will turn led on */
    ACTIVE_LOW,  /* Low level will turn led on */
};
 
/* Three LEDs hardware information */
typedef struct led_s
{
    const char               *name;      /* RGB 3-color LED name  */
    int                       chip_num;  /* RGB 3-color LED connect chip */
    int                       gpio_num;  /* RGB 3-color LED connect line */
    int                       active;    /* RGB 3-color LED active level */
    int                       status;    /* RGB 3-color LED current status */
    struct gpiod_line_request *request;  /* libgpiod gpio request handler */
} led_t;
 
/* Three LEDs structure */
typedef struct leds_s
{
    led_t               *leds;  /* led pointer to leds_info */
    int                  count; /* led count */
} leds_t;
 
 
/* initial leds */
int init_led(void);
 
/* terminate leds   */
int term_led(void);
 
/* turn $which led ON/OFF */
int turn_led(int which, int cmd);
 
/* toggle $which led status */
int toggle_led(int which);
 
/* blink $which led status with $interval ms */
void blink_led(int which, int interval);
 
#endif