mbed library for STMicroelectronics' X-NUCLEO-IKA01A1 expansion board.
Dependents: HelloWorld_IKA01A1
Fork of X_NUCLEO_IKA01A1 by
Library for STMicroelectronics' X-NUCLEO-IKA01A1 multifunctional expansion board based on operational amplifiers.
Revision 16:2f9443aedbe8, committed 2016-04-08
- Comitter:
- hemddabral
- Date:
- Fri Apr 08 08:00:29 2016 +0000
- Parent:
- 15:114514787e83
- Child:
- 17:cbdee5f7a2aa
- Commit message:
- implemented code review comments - part 1
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Common/photosensor.h Fri Apr 08 08:00:29 2016 +0000
@@ -0,0 +1,121 @@
+/**
+ ******************************************************************************
+ * @file photodiode.h
+ * @author Central Labs
+ * @version 1.0.0
+ * @date 11-February-2016
+ * @brief Portable architecture for TSU104
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+
+#ifndef __PHOTODIODE_H
+#define __PHOTODIODE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Includes ------------------------------------------------------------------*/
+
+#include <stdint.h>
+#include "component.h"
+
+
+/* Types ---------------------------------------------------------------------*/
+
+/** @addtogroup BSP
+ * @{
+ */
+
+/** @addtogroup Components
+ * @{
+ */
+
+/** @addtogroup PHOTODIODE
+ * @{
+ */
+
+/** @defgroup PHOTODIODE_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief PHOTODIODE component identifier enumerator definition.
+ */
+typedef enum
+{
+ PHOTODIODE_NONE_COMPONENT = 0,
+ PHOTODIODE_TSU104_COMPONENT = 1
+} PHOTODIODEE_Component_t;
+
+/**
+ * @brief PHOTODIODE driver virtual table structure definition.
+ */
+typedef struct
+{
+ /* ACTION ----------------------------------------------------------------*
+ * Declare here the component's generic functions. *
+ * Tag this group of functions with the " Generic " C-style comment. *
+ * A component's interface has to define at least the two generic *
+ * functions provided here below within the "Example" section, as the *
+ * first and second functions of its Virtual Table. They have to be *
+ * specified exactly in the given way. *
+ * *
+ * Example: *
+ * Status_t (*Init) (void *handle, void *init); *
+ * Status_t (*ReadID) (void *handle, uint8_t *id); *
+ *------------------------------------------------------------------------*/
+ /* Generic */
+ Status_t (*Init) (void *handle, void *init);
+ Status_t (*ReadID) (void *handle, uint8_t *id);
+
+ /* ACTION ----------------------------------------------------------------*
+ * Declare here the component's specific functions. *
+ * Tag this group of functions with the " Specific " C-style comment. *
+ * Do not specify any function if not required. *
+ * *
+ * Example: *
+ * Status_t (*GetValue) (void *handle, float *f); *
+ *------------------------------------------------------------------------*/
+ /* Specific */
+ unsigned int (*Get_PhotoSensor_GetVoltage) (void *handle);
+} WINDCOMP_VTable_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PHOTODIODE_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/Common/windcomp.h Fri Apr 08 05:58:02 2016 +0000
+++ b/Components/Common/windcomp.h Fri Apr 08 08:00:29 2016 +0000
@@ -1,6 +1,6 @@
/**
******************************************************************************
- * @file photodiode.h
+ * @file WIND_COMP.h
* @author Central Labs
* @version 1.0.0
* @date 11-February-2016
@@ -38,8 +38,8 @@
/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __PHOTODIODE_H
-#define __PHOTODIODE_H
+#ifndef __WIND_COMP_H
+#define __WIND_COMP_H
#ifdef __cplusplus
extern "C" {
@@ -62,25 +62,25 @@
* @{
*/
-/** @addtogroup PHOTODIODE
+/** @addtogroup WIND_COMP
* @{
*/
-/** @defgroup PHOTODIODE_Exported_Types
+/** @defgroup WIND_COMP_Exported_Types
* @{
*/
/**
- * @brief PHOTODIODE component identifier enumerator definition.
+ * @brief WIND_COMP component identifier enumerator definition.
*/
typedef enum
{
- PHOTODIODE_NONE_COMPONENT = 0,
- PHOTODIODE_TSU104_COMPONENT = 1
-} PHOTODIODEE_Component_t;
+ WIND_COMP_NONE_COMPONENT = 0,
+ WIND_COMP_TSU104_COMPONENT = 1
+} WIND_COMPE_Component_t;
/**
- * @brief PHOTODIODE driver virtual table structure definition.
+ * @brief WIND_COMP driver virtual table structure definition.
*/
typedef struct
{
@@ -111,14 +111,13 @@
/* Specific */
unsigned int (*WindComp_Get_Signal1) (void *handle);
unsigned int (*WindComp_Get_Signal2) (void *handle);
- unsigned int (*TSU104_PhotoSensor_GetVoltage) (void *handle);
} WINDCOMP_VTable_t;
#ifdef __cplusplus
}
#endif
-#endif /* __PHOTODIODE_H */
+#endif /* __WIND_COMP_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Interfaces/PhotoSensor_class.h Fri Apr 08 08:00:29 2016 +0000
@@ -0,0 +1,86 @@
+/**
+ ******************************************************************************
+ * @file PHOTO_SENSOR_class.h
+ * @author AST
+ * @version V1.0.0
+ * @date April 13th, 2015
+ * @brief This file contains the abstract class describing the interface of a
+ * PHOTO_SENSOR component.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+
+/* Generated with STM32CubeTOO -----------------------------------------------*/
+
+
+/* Revision ------------------------------------------------------------------*/
+/*
+ Repository: http://svn.x-nucleodev.codex.cro.st.com/svnroot/X-NucleoDev
+ Branch/Trunk/Tag: trunk
+ Based on: X-CUBE-IKA01A1/trunk/Drivers/BSP/Components/Common/PHOTO_SENSOR.h
+ Revision: 385
+*/
+
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+
+#ifndef __PHOTO_SENSOR_CLASS_H
+#define __PHOTO_SENSOR_CLASS_H
+
+
+/* Includes ------------------------------------------------------------------*/
+
+#include <Component_class.h>
+
+
+/* Classes ------------------------------------------------------------------*/
+
+/** An abstract class for photo sensor components.
+ */
+class PhotoSensor : public Component
+{
+public:
+ /* ACTION 1 --------------------------------------------------------------*
+ * Declare here the interface's methods. *
+ * They should be: *
+ * + Methods with the same name of the C component's virtual table *
+ * (and extended virtual table, if any)'s functions, provided that *
+ * the component's driver implements them (i.e.: the corresponding *
+ * pointer to function is not "0"). *
+ * *
+ * Example: *
+ * virtual int GetValue(float *f) = 0; *
+ *------------------------------------------------------------------------*/
+ virtual unsigned int Get_PhotoSensor_GetVoltage(void) = 0;
+};
+
+#endif /* __PHOTO_SENSOR_CLASS_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/Interfaces/Windcomp_class.h Fri Apr 08 05:58:02 2016 +0000 +++ b/Components/Interfaces/Windcomp_class.h Fri Apr 08 08:00:29 2016 +0000 @@ -79,9 +79,7 @@ * virtual int GetValue(float *f) = 0; * *------------------------------------------------------------------------*/ virtual unsigned int WindComp_Get_Signal1(void) = 0; - virtual unsigned int WindComp_Get_Signal2(void) = 0; - virtual unsigned int TSU104_PhotoSensor_GetVoltage(void) = 0; -}; + virtual unsigned int WindComp_Get_Signal2(void) = 0;}; #endif /* __WINDCOMP_CLASS_H */
--- a/Components/tsu104/tsu104.h Fri Apr 08 05:58:02 2016 +0000
+++ b/Components/tsu104/tsu104.h Fri Apr 08 08:00:29 2016 +0000
@@ -1,113 +1,109 @@
-/**
- ******************************************************************************
- * @file tsz124.h
- * @author Central Labs
- * @version 1.0.0
- * @date 11-February-2016
- * @brief Portable architecture for TSU104
- ******************************************************************************
- * @attention
- *
- * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-
-#ifndef __TSU104_H
-#define __TSU104_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-
-/* Includes ------------------------------------------------------------------*/
-
-/* ACTION --------------------------------------------------------------------*
- * Include here interface specific header files. *
- *----------------------------------------------------------------------------*/
-#include "../Common/windcomp.h"
-
-
-/* Definitions ---------------------------------------------------------------*/
-
-/** @addtogroup BSP
- * @{
- */
-
-/** @addtogroup Components
- * @{
- */
-
-/** @addtogroup tsz124
- * @{
- */
-
-/** @defgroup tsz124_Exported_Defines tsz124_Exported_Defines
- * @{
- */
-#ifndef NULL
- #define NULL (void *) 0
-#endif
-
-/**
- * @brief Device Address
- */
-#define TSU104_ADDRESS (0x10)
-
-/* ACTION --------------------------------------------------------------------*
- * Put here the component's registers' addresses. *
- *----------------------------------------------------------------------------*/
-
-/**
- * @brief Device identification register.
- * \code
- * Read
- * Default value: 0xXX
- * 7:0 This read-only register contains the device identifier.
- * \endcode
-*/
-#define TSU104_WHO_AM_I_ADDR (0x11)
-
-/**
- * @brief Device Identifier. Default value of the WHO_AM_I register.
- */
-#define I_AM_TSU104 ((uint8_t) (0x24))
-
-extern unsigned int TSU104_Read_Pin_D2();
-extern unsigned int TSU104_Read_Pin_D4();
-extern unsigned int TSU104_Read_Pin_A4();
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif /* __TSU104_H */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+/**
+ ******************************************************************************
+ * @file tsz124.h
+ * @author Central Labs
+ * @version 1.0.0
+ * @date 11-February-2016
+ * @brief Portable architecture for TSU104
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+
+#ifndef __TSU104_H
+#define __TSU104_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+/* Includes ------------------------------------------------------------------*/
+
+/* ACTION --------------------------------------------------------------------*
+ * Include here interface specific header files. *
+ *----------------------------------------------------------------------------*/
+#include "../Common/windcomp.h"
+
+/* Definitions ---------------------------------------------------------------*/
+
+/** @addtogroup BSP
+ * @{
+ */
+
+/** @addtogroup Components
+ * @{
+ */
+
+/** @addtogroup tsz124
+ * @{
+ */
+
+/** @defgroup tsz124_Exported_Defines tsz124_Exported_Defines
+ * @{
+ */
+#ifndef NULL
+ #define NULL (void *) 0
+#endif
+
+/**
+ * @brief Device Address
+ */
+#define TSU104_ADDRESS (0x10)
+
+/* ACTION --------------------------------------------------------------------*
+ * Put here the component's registers' addresses. *
+ *----------------------------------------------------------------------------*/
+
+/**
+ * @brief Device identification register.
+ * \code
+ * Read
+ * Default value: 0xXX
+ * 7:0 This read-only register contains the device identifier.
+ * \endcode
+*/
+#define TSU104_WHO_AM_I_ADDR (0x11)
+
+/**
+ * @brief Device Identifier. Default value of the WHO_AM_I register.
+ */
+#define I_AM_TSU104 ((uint8_t) (0x24))
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* __TSU104_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+
--- a/Components/tsu104/tsu104_class.cpp Fri Apr 08 05:58:02 2016 +0000
+++ b/Components/tsu104/tsu104_class.cpp Fri Apr 08 08:00:29 2016 +0000
@@ -56,9 +56,6 @@
/* Methods -------------------------------------------------------------------*/
-//static Status_t GetVoltage(unsigned int *ptrVoltage);
-//static Status_t GetCurrent(unsigned int *ptrCurrent);
-
/* TSU104's private functions. */
@@ -75,19 +72,6 @@
}
-/*
-static unsigned int TSU104_WindComp_Get_D2(void) {
- return COMPONENT_OK;
-}
-
-static unsigned int TSU104_WindComp_Get_D4(void) {
- return COMPONENT_OK;
-}
-
-static unsigned int TSU104_PhotoSensor_GetVoltage(PinName pin) {
- return COMPONENT_OK;
-}
-*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/tsu104/tsu104_class.h Fri Apr 08 05:58:02 2016 +0000
+++ b/Components/tsu104/tsu104_class.h Fri Apr 08 08:00:29 2016 +0000
@@ -72,6 +72,7 @@
* #include "../Interfaces/Temperature_class.h" *
*----------------------------------------------------------------------------*/
#include "../Interfaces/Windcomp_class.h"
+#include "../Interfaces/PhotoSensor_class.h"
/* Classes -------------------------------------------------------------------*/
@@ -81,7 +82,7 @@
* configuration allows the user to compare a signal to two threshold voltages. When the signal
* is out of the required voltage range, the output of the operational amplifier toggles
*/
-class TSU104 : public Windcomp
+class TSU104 : public Windcomp, public PhotoSensor
{
public:
@@ -149,7 +150,7 @@
* @param pin AnalogIn pin to use for detecting the voltage
* @retval voltage detected by photo sensor
*/
- virtual unsigned int TSU104_PhotoSensor_GetVoltage(void)
+ virtual unsigned int Get_PhotoSensor_GetVoltage(void)
{
AnalogIn photoSensor(photo_sensor_pin);
double voltage = photoSensor.read();
@@ -235,29 +236,6 @@
/*** Component's I/O Methods ***/
- /* ACTION 8 --------------------------------------------------------------*
- * Implement here other I/O methods beyond those already implemented *
- * above, which are declared extern within the component's header file. *
- *------------------------------------------------------------------------*/
- unsigned int TSU104_Read_Pin_D2()
- {
- /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs. */
- return (unsigned int) 0;
- }
-
- unsigned int TSU104_Read_Pin_D4()
- {
- /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs. */
- return (unsigned int) 0;
- }
-
- unsigned int TSU104_Read_Pin_A4()
- {
- /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs. */
- return (unsigned int) 0;
- }
-
-
/*** Component's Instance Variables ***/
/* ACTION 9 --------------------------------------------------------------*
--- a/Components/tsv734/tsv734_class.h Fri Apr 08 05:58:02 2016 +0000
+++ b/Components/tsv734/tsv734_class.h Fri Apr 08 08:00:29 2016 +0000
@@ -88,9 +88,13 @@
/**
* @brief Constructor.
*/
- TSV734(PinName ledDriverPin) : Led_driver()
+ TSV734(PinName ledDriverPin, unsigned int ledDutyCycle_ms) : Led_driver()
{
led_driver_pin = ledDriverPin;
+
+ period = ledDutyCycle_ms;
+ PwmOut ledOut(led_driver_pin);
+ ledOut.period_ms(period);
}
/**
@@ -120,18 +124,6 @@
return (int) TSV734_ReadID((uint8_t *) id);
}
- /**
- * @brief set the duty cycle of LED in LED driver configuration
- * @param Configure the TSV734 operational amplifier in LED driver configuration
- * @retval 0
- */
- virtual int Configure(unsigned int period_us)
- {
- period = period_us;
- PwmOut ledOut(led_driver_pin);
- ledOut.period_ms(period);
- return 0;
- }
/**
* @brief set the duty cycle of LED in LED driver configuration
@@ -141,7 +133,7 @@
virtual int SetDutyCycle(float dc)
{
PwmOut ledOut(led_driver_pin);
- ledOut.pulsewidth_us((period*dc)/100);
+ ledOut.pulsewidth_us(period*dc);
return (int) dc;
}
--- a/x_nucleo_ika01a1_class.cpp Fri Apr 08 05:58:02 2016 +0000
+++ b/x_nucleo_ika01a1_class.cpp Fri Apr 08 08:00:29 2016 +0000
@@ -63,7 +63,7 @@
* @brief Constructor.
*/
X_NUCLEO_IKA01A1::X_NUCLEO_IKA01A1(PinName photoSensorPin, PinName windCmpSignalPin_1,PinName windCmpSignalPin_2,
- PinName ledDriverPin)
+ PinName ledDriverPin, unsigned int ledDutyCycle_ms)
{
/* Instantiating the components. */
@@ -76,7 +76,7 @@
*------------------------------------------------------------------------*/
tsz124 = new TSZ124();
tsu104 = new TSU104(photoSensorPin, windCmpSignalPin_1, windCmpSignalPin_2);
- tsv734 = new TSV734(ledDriverPin);
+ tsv734 = new TSV734(ledDriverPin, ledDutyCycle_ms);
}
/**
@@ -84,12 +84,12 @@
* @retval a singleton instance of X_NUCLEO_IKA01A1 class.
*/
X_NUCLEO_IKA01A1 *X_NUCLEO_IKA01A1::Instance(PinName photoSensorPin, PinName windCmpSignalPin_1,PinName windCmpSignalPin_2,
- PinName ledDriverPin)
+ PinName ledDriverPin, unsigned int ledDutyCycle_ms)
{
if (_instance == NULL)
{
/* Instantiating the board. */
- _instance = new X_NUCLEO_IKA01A1(photoSensorPin, windCmpSignalPin_1, windCmpSignalPin_2, ledDriverPin);
+ _instance = new X_NUCLEO_IKA01A1(photoSensorPin, windCmpSignalPin_1, windCmpSignalPin_2, ledDriverPin, ledDutyCycle_ms);
/* Initializing the components. */
if (!_instance->Init())
--- a/x_nucleo_ika01a1_class.h Fri Apr 08 05:58:02 2016 +0000 +++ b/x_nucleo_ika01a1_class.h Fri Apr 08 08:00:29 2016 +0000 @@ -95,7 +95,7 @@ * @retval a singleton instance of X_NUCLEO_IKA01A1 class. */ static X_NUCLEO_IKA01A1 *Instance(PinName photoSensorPin, PinName windCmpSignalPin_1,PinName windCmpSignalPin_2, - PinName ledDriverPin); + PinName ledDriverPin, unsigned int ledDutyCycle_ms); /** * @brief Initialize the singleton's operational amplifiers to default settings @@ -134,7 +134,7 @@ * @brief Constructor. */ X_NUCLEO_IKA01A1(PinName photoSensorPin, PinName windCmpSignalPin_1,PinName windCmpSignalPin_2, - PinName ledDriverPin); + PinName ledDriverPin, unsigned int ledDutyCycle_ms); /*** Protected Expansion Board Related Initialization Methods ***/

X-NUCLEO-IKA01A1 Multifunctional board based on operational amplifiers.