commit | author | age
|
d6b4a7
|
1 |
/********************************************************************************* |
G |
2 |
* Copyright: (C) 2021 LingYun IoT System Studio |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* Filename: led.h |
|
6 |
* Description: This file is used to control RGB 3-colors LED |
|
7 |
* |
|
8 |
* |
|
9 |
* Pin connection: |
|
10 |
* RGB Led Module Raspberry Pi Board |
|
11 |
* R <-----> #Pin33(BCM GPIO13) |
|
12 |
* G <-----> #Pin35(BCM GPIO19) |
|
13 |
* B <-----> #Pin37(BCM GPIO26) |
|
14 |
* GND <-----> GND |
|
15 |
* |
|
16 |
* System install: |
|
17 |
* sudo apt install -y libgpiod-dev gpiod |
|
18 |
* |
|
19 |
* |
|
20 |
********************************************************************************/ |
|
21 |
|
|
22 |
#ifndef _LEDS_H_ |
|
23 |
#define _LEDS_H_ |
|
24 |
|
|
25 |
#define ON 1 |
|
26 |
#define OFF 0 |
|
27 |
|
|
28 |
/* Three LEDs code */ |
|
29 |
enum |
|
30 |
{ |
|
31 |
LED_R = 0, |
|
32 |
LED_G, |
|
33 |
LED_B, |
|
34 |
LED_CNT, |
|
35 |
}; |
|
36 |
|
|
37 |
/* Three LEDs hardware information */ |
|
38 |
typedef struct led_info_s |
|
39 |
{ |
|
40 |
const char *name; /* RGB 3-color LED name */ |
|
41 |
int gpio; /* RGB 3-color LED BCM pin number */ |
|
42 |
int active;/* RGB 3-color LED active GPIO level: 0->low 1->high */ |
|
43 |
struct gpiod_line *line; /* libgpiod line */ |
|
44 |
} led_info_t; |
|
45 |
|
|
46 |
/* Three LEDs API context */ |
|
47 |
typedef struct led_ctx_s |
|
48 |
{ |
|
49 |
struct gpiod_chip *chip; |
|
50 |
led_info_t *leds; |
|
51 |
int count; |
|
52 |
} led_ctx_t; |
|
53 |
|
|
54 |
extern int init_led(led_ctx_t *ctx, int which); |
|
55 |
extern int term_led(led_ctx_t *ctx, int which); |
|
56 |
extern int turn_led(int which, int cmd); |
|
57 |
|
|
58 |
#endif /* ----- #ifndef _LEDS_H_ ----- */ |