You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by vi...@apache.org on 2018/06/05 22:15:31 UTC
[mynewt-core] branch master updated: hw/drivers/led: add led_itf
(#1160)
This is an automated email from the ASF dual-hosted git repository.
vipulrahane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new f6efb7c hw/drivers/led: add led_itf (#1160)
f6efb7c is described below
commit f6efb7ca3974b40421085dca1d3e17d7fc6e1525
Author: Vipul Rahane <vr...@gmail.com>
AuthorDate: Tue Jun 5 15:15:15 2018 -0700
hw/drivers/led: add led_itf (#1160)
- Add concept of an led_itf
- Change directory structure to have hw/drivers/led
- Create a seperate package for hw/drivers/led
---
hw/drivers/led/include/led/led_itf.h | 52 ++++++++++++
.../{ => led}/lp5523/include/lp5523/lp5523.h | 99 ++++++++++++++++------
hw/drivers/{ => led}/lp5523/pkg.yml | 6 +-
hw/drivers/{ => led}/lp5523/src/lp5523.c | 8 +-
hw/drivers/{ => led}/lp5523/src/lp5523_shell.c | 3 +-
hw/drivers/{ => led}/lp5523/syscfg.yml | 0
hw/drivers/{tlc5971 => led}/pkg.yml | 12 +--
.../{ => led}/tlc5971/include/tlc5971/tlc5971.h | 0
hw/drivers/{ => led}/tlc5971/pkg.yml | 2 +-
hw/drivers/{ => led}/tlc5971/src/tlc5971.c | 0
10 files changed, 137 insertions(+), 45 deletions(-)
diff --git a/hw/drivers/led/include/led/led_itf.h b/hw/drivers/led/include/led/led_itf.h
new file mode 100644
index 0000000..994a6a4
--- /dev/null
+++ b/hw/drivers/led/include/led/led_itf.h
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __LED_ITF_H__
+#define __LED_ITF_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * LED interfaces
+ */
+#define LED_ITF_SPI (0)
+#define LED_ITF_I2C (1)
+#define LED_ITF_UART (2)
+
+/*
+ * LED interface
+ */
+struct led_itf {
+
+ /* LED interface type */
+ uint8_t li_type;
+
+ /* interface number */
+ uint8_t li_num;
+
+ /* CS pin - optional, only needed for SPI */
+ uint8_t li_cs_pin;
+
+ /* LED chip address, only needed for I2C */
+ uint16_t li_addr;
+};
+
+#endif
diff --git a/hw/drivers/lp5523/include/lp5523/lp5523.h b/hw/drivers/led/lp5523/include/lp5523/lp5523.h
similarity index 95%
rename from hw/drivers/lp5523/include/lp5523/lp5523.h
rename to hw/drivers/led/lp5523/include/lp5523/lp5523.h
index 4f64779..a0a9250 100644
--- a/hw/drivers/lp5523/include/lp5523/lp5523.h
+++ b/hw/drivers/led/lp5523/include/lp5523/lp5523.h
@@ -24,7 +24,9 @@
extern "C" {
#endif
-#include <sensor/sensor.h>
+#include <led/led_itf.h>
+
+#define LP5523_MAX_PAYLOAD (10)
#if MYNEWT_VAL(LED_ENABLE_ABSTRACTION)
#include <led/led.h>
@@ -106,32 +108,9 @@ struct lp5523_cfg {
struct lp5523 {
struct os_dev dev;
-#if MYNEWT_VAL(LED_ENABLE_ABSTRACTION)
- struct led_dev led_dev;
-#endif
struct lp5523_cfg cfg;
};
-#if MYNEWT_VAL(LED_ENABLE_ABSTRACTION) == 0
-/*
- * LED interface
- */
-struct led_itf {
-
- /* LED interface type */
- uint8_t li_type;
-
- /* interface number */
- uint8_t li_num;
-
- /* CS pin - optional, only needed for SPI */
- uint8_t li_cs_pin;
-
- /* LED chip address, only needed for I2C */
- uint16_t li_addr;
-};
-#endif
-
/**** Config Values ****/
#define LP5523_ASEL00_ADDR_32h 0x00
#define LP5523_ASEL01_ADDR_33h 0x01
@@ -765,7 +744,77 @@ int lp5523_self_test(struct led_itf *itf);
* @return 0 on success, non-zero error on failure.
*/
int lp5523_init(struct os_dev *dev, void *arg);
-int lp5523_config(struct lp5523 *lp, struct lp5523_cfg *cfg);
+int lp5523_config(struct led_itf *itf, struct lp5523_cfg *cfg);
+
+/**
+ * Calculate Temp comp bits from correction factor
+ *
+ * @param corr_factor Correction factor -1.5 < corr_factor < +1.5
+ * @param temp_comp Temperature compensation bits 5 bits 11111 - 01111
+ *
+ * @return 0 on success, non-zero on failure
+ */
+int
+lp5523_calc_temp_comp(float corr_factor, uint8_t *temp_comp);
+
+/**
+ * Set output ON for particular output
+ *
+ * @param itf Ptr to LED itf
+ * @param output Number of the output
+ * @param on Output 1-ON/0-OFF
+ *
+ * @return 0 on success, non-zero on failure
+ */
+int
+lp5523_set_output_on(struct led_itf *itf, uint8_t output, uint8_t on);
+
+/**
+ * Get output ON for particular output
+ *
+ * @param itf Ptr to LED itf
+ * @param output Number of the output
+ * @param on Ptr to output variable Output 1-ON/0-OFF
+ *
+ * @return 0 on success, non-zero on failure
+ */
+int
+lp5523_get_output_on(struct led_itf *itf, uint8_t output, uint8_t *on);
+
+/**
+ *
+ * Get status
+ *
+ * @param LED interface
+ * @param Ptr to status
+ *
+ * @return 0 on success, non-zero on failure
+ */
+int
+lp5523_get_status(struct led_itf *itf, uint8_t *status);
+
+/**
+ * Get Output Current control
+ *
+ * @param itf LED interface
+ * @param output Number of the output
+ * @param curr_ctrl Ptr to Current control
+ *
+ * @return 0 on success, non-zero on failure
+ */
+int
+lp5523_get_output_curr_ctrl(struct led_itf *itf, uint8_t output, uint8_t *curr_ctrl);
+
+/**
+ *
+ * Set output Current control
+ *
+ * @param itf LED interface
+ * @param output Number of the output
+ * @param curr_ctrl Current control value to set
+ */
+int
+lp5523_set_output_curr_ctrl(struct led_itf *itf, uint8_t output, uint8_t curr_ctrl);
/**
* Calculate Temp comp bits from correction factor
diff --git a/hw/drivers/lp5523/pkg.yml b/hw/drivers/led/lp5523/pkg.yml
similarity index 93%
rename from hw/drivers/lp5523/pkg.yml
rename to hw/drivers/led/lp5523/pkg.yml
index a695429..51126a1 100644
--- a/hw/drivers/lp5523/pkg.yml
+++ b/hw/drivers/led/lp5523/pkg.yml
@@ -17,7 +17,7 @@
# under the License.
#
-pkg.name: hw/drivers/lp5523
+pkg.name: hw/drivers/led/lp5523
pkg.description: Driver for the TI LP5523
pkg.author: "Apache Mynewt dev@mynewt.apache.org"
pkg.homepage: "http://mynewt.apache.org/"
@@ -29,11 +29,11 @@ pkg.keywords:
pkg.deps:
- "@apache-mynewt-core/kernel/os"
- "@apache-mynewt-core/hw/hal"
- - "@apache-mynewt-core/hw/sensor"
+ - "@apache-mynewt-core/hw/drivers/led"
pkg.deps.LP5523_CLI:
- "@apache-mynewt-core/util/parse"
pkg.req_apis:
- stats
- - log
\ No newline at end of file
+ - log
diff --git a/hw/drivers/lp5523/src/lp5523.c b/hw/drivers/led/lp5523/src/lp5523.c
similarity index 99%
rename from hw/drivers/lp5523/src/lp5523.c
rename to hw/drivers/led/lp5523/src/lp5523.c
index c9da96a..7b30879 100644
--- a/hw/drivers/lp5523/src/lp5523.c
+++ b/hw/drivers/led/lp5523/src/lp5523.c
@@ -21,6 +21,7 @@
#include <hal/hal_i2c.h>
#include <log/log.h>
#include <stats/stats.h>
+#include <string.h>
#include "lp5523/lp5523.h"
@@ -939,15 +940,12 @@ lp5523_set_output_curr_ctrl(struct led_itf *itf, uint8_t output, uint8_t curr_ct
}
int
-lp5523_config(struct lp5523 *lp5523, struct lp5523_cfg *cfg)
+lp5523_config(struct led_itf *itf, struct lp5523_cfg *cfg)
{
int rc;
int i;
- struct led_itf *itf;
uint8_t misc_val;
- itf = LED_GET_ITF(&(lp5523->led_dev));
-
itf->li_addr = LP5523_I2C_BASE_ADDR + cfg->asel;
rc = lp5523_reset(itf);
@@ -1013,7 +1011,7 @@ lp5523_config(struct lp5523 *lp5523, struct lp5523_cfg *cfg)
goto err;
}
- for (i = 1; i <= MYNEWT_VAL(LEDS_PER_DRIVER); i++) {
+ for (i = 1; i <= MYNEWT_VAL(LP5523_LEDS_PER_DRIVER); i++) {
rc = lp5523_set_output_curr_ctrl(itf, i, cfg->per_led_cfg[i - 1].current_ctrl);
if (rc) {
goto err;
diff --git a/hw/drivers/lp5523/src/lp5523_shell.c b/hw/drivers/led/lp5523/src/lp5523_shell.c
similarity index 99%
rename from hw/drivers/lp5523/src/lp5523_shell.c
rename to hw/drivers/led/lp5523/src/lp5523_shell.c
index 43cd5cd..82301f9 100644
--- a/hw/drivers/lp5523/src/lp5523_shell.c
+++ b/hw/drivers/led/lp5523/src/lp5523_shell.c
@@ -20,14 +20,13 @@
#include <string.h>
#include <errno.h>
#include "os/mynewt.h"
+#if MYNEWT_VAL(LP5523_CLI)
#include "console/console.h"
-#include "sensor/sensor.h"
#include "shell/shell.h"
#include "hal/hal_gpio.h"
#include "lp5523/lp5523.h"
#include "parse/parse.h"
-#if MYNEWT_VAL(LP5523_CLI)
static int lp5523_shell_cmd(int argc, char **argv);
diff --git a/hw/drivers/lp5523/syscfg.yml b/hw/drivers/led/lp5523/syscfg.yml
similarity index 100%
rename from hw/drivers/lp5523/syscfg.yml
rename to hw/drivers/led/lp5523/syscfg.yml
diff --git a/hw/drivers/tlc5971/pkg.yml b/hw/drivers/led/pkg.yml
similarity index 78%
copy from hw/drivers/tlc5971/pkg.yml
copy to hw/drivers/led/pkg.yml
index 862d8a3..bcfc6fd 100644
--- a/hw/drivers/tlc5971/pkg.yml
+++ b/hw/drivers/led/pkg.yml
@@ -17,14 +17,8 @@
# under the License.
#
-pkg.name: hw/drivers/tlc5971
-pkg.description: Driver for the TI TLC5971
-pkg.author: "Apache Mynewt dev@mynewt.apache.org"
+pkg.name: hw/drivers/led
+pkg.description: LED Drivers
+pkg.author: "Apache Mynewt <de...@mynewt.apache.org>"
pkg.homepage: "http://mynewt.apache.org/"
pkg.keywords:
- - led
- - tlc5971
-
-pkg.deps:
- - "@apache-mynewt-core/kernel/os"
- - "@apache-mynewt-core/hw/hal"
diff --git a/hw/drivers/tlc5971/include/tlc5971/tlc5971.h b/hw/drivers/led/tlc5971/include/tlc5971/tlc5971.h
similarity index 100%
rename from hw/drivers/tlc5971/include/tlc5971/tlc5971.h
rename to hw/drivers/led/tlc5971/include/tlc5971/tlc5971.h
diff --git a/hw/drivers/tlc5971/pkg.yml b/hw/drivers/led/tlc5971/pkg.yml
similarity index 96%
rename from hw/drivers/tlc5971/pkg.yml
rename to hw/drivers/led/tlc5971/pkg.yml
index 862d8a3..b0cf090 100644
--- a/hw/drivers/tlc5971/pkg.yml
+++ b/hw/drivers/led/tlc5971/pkg.yml
@@ -17,7 +17,7 @@
# under the License.
#
-pkg.name: hw/drivers/tlc5971
+pkg.name: hw/drivers/led/tlc5971
pkg.description: Driver for the TI TLC5971
pkg.author: "Apache Mynewt dev@mynewt.apache.org"
pkg.homepage: "http://mynewt.apache.org/"
diff --git a/hw/drivers/tlc5971/src/tlc5971.c b/hw/drivers/led/tlc5971/src/tlc5971.c
similarity index 100%
rename from hw/drivers/tlc5971/src/tlc5971.c
rename to hw/drivers/led/tlc5971/src/tlc5971.c
--
To stop receiving notification emails like this one, please contact
vipulrahane@apache.org.