From 7deaa4a49b1d0fb2112a69719141709b9c261c7c Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Wed, 21 Aug 2024 16:05:07 +0800
Subject: [PATCH] Update leds source code
---
hal/api/leds.h | 77 ++++++++++++++++++++++++++++++++++++++
1 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/hal/api/leds.h b/hal/api/leds.h
new file mode 100644
index 0000000..f8f827c
--- /dev/null
+++ b/hal/api/leds.h
@@ -0,0 +1,77 @@
+/*********************************************************************************
+ * Copyright: (C) 2024 LingYun IoT System Studio
+ * All rights reserved.
+ *
+ * Filename: led.c
+ * Description: This file is used to control RGB 3-colors LED
+ *
+ *
+ * Pin connection:
+ * RGB Led Module IGKBoard
+ * R <-----> #Pin33
+ * G <-----> #Pin35
+ * B <-----> #Pin37
+ * GND <-----> GND
+ *
+ ********************************************************************************/
+
+#ifndef _LEDS_H_
+#define _LEDS_H_
+
+#include "gpiod.h"
+
+#define DELAY 300
+
+#define ON 1
+#define OFF 0
+
+/* Three LEDs number */
+enum
+{
+ LED_R = 0,
+ LED_G,
+ LED_B,
+ LEDCNT,
+};
+
+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 /* ----- #ifndef _LEDS_H_ ----- */
--
Gitblit v1.9.1